199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest lldb data formatter subsystem. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprechtimport lldb 6f9ad1127SRaphael Isemannfrom lldbsuite.test.decorators import * 799451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 899451b44SJordan Rupprechtimport lldbsuite.test.lldbutil as lldbutil 999451b44SJordan Rupprecht 1099451b44SJordan Rupprecht 1199451b44SJordan Rupprechtclass ValueObjectRecursionTestCase(TestBase): 1299451b44SJordan Rupprecht def setUp(self): 1399451b44SJordan Rupprecht # Call super's setUp(). 1499451b44SJordan Rupprecht TestBase.setUp(self) 1599451b44SJordan Rupprecht # Find the line number to break at. 16*2238dcc3SJonas Devlieghere self.line = line_number("main.cpp", "// Set break point at this line.") 1799451b44SJordan Rupprecht 18f9ad1127SRaphael Isemann @no_debug_info_test 1999451b44SJordan Rupprecht def test_with_run_command(self): 2099451b44SJordan Rupprecht """Test that deeply nested ValueObjects still work.""" 2199451b44SJordan Rupprecht self.build() 2299451b44SJordan Rupprecht self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 2399451b44SJordan Rupprecht 2499451b44SJordan Rupprecht lldbutil.run_break_set_by_file_and_line( 25*2238dcc3SJonas Devlieghere self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True 26*2238dcc3SJonas Devlieghere ) 2799451b44SJordan Rupprecht 2899451b44SJordan Rupprecht self.runCmd("run", RUN_SUCCEEDED) 2999451b44SJordan Rupprecht 3099451b44SJordan Rupprecht # The stop reason of the thread should be breakpoint. 31*2238dcc3SJonas Devlieghere self.expect( 32*2238dcc3SJonas Devlieghere "thread list", 33*2238dcc3SJonas Devlieghere STOPPED_DUE_TO_BREAKPOINT, 34*2238dcc3SJonas Devlieghere substrs=["stopped", "stop reason = breakpoint"], 35*2238dcc3SJonas Devlieghere ) 3699451b44SJordan Rupprecht 3799451b44SJordan Rupprecht # This is the function to remove the custom formats in order to have a 3899451b44SJordan Rupprecht # clean slate for the next test case. 3999451b44SJordan Rupprecht def cleanup(): 40*2238dcc3SJonas Devlieghere self.runCmd("type format clear", check=False) 41*2238dcc3SJonas Devlieghere self.runCmd("type summary clear", check=False) 4299451b44SJordan Rupprecht 4399451b44SJordan Rupprecht # Execute the cleanup function during test case tear down. 4499451b44SJordan Rupprecht self.addTearDownHook(cleanup) 4599451b44SJordan Rupprecht 4699451b44SJordan Rupprecht root = self.frame().FindVariable("root") 4799451b44SJordan Rupprecht child = root.GetChildAtIndex(1) 4899451b44SJordan Rupprecht if self.TraceOn(): 4999451b44SJordan Rupprecht print(root) 5099451b44SJordan Rupprecht print(child) 5199451b44SJordan Rupprecht for i in range(0, 15000): 5299451b44SJordan Rupprecht child = child.GetChildAtIndex(1) 5399451b44SJordan Rupprecht if self.TraceOn(): 5499451b44SJordan Rupprecht print(child) 55*2238dcc3SJonas Devlieghere self.assertTrue(child.IsValid(), "could not retrieve the deep ValueObject") 5699451b44SJordan Rupprecht self.assertTrue( 57*2238dcc3SJonas Devlieghere child.GetChildAtIndex(0).IsValid(), "the deep ValueObject has no value" 58*2238dcc3SJonas Devlieghere ) 591fb5c7a2SDave Lee self.assertNotEqual( 60*2238dcc3SJonas Devlieghere child.GetChildAtIndex(0).GetValueAsUnsigned(), 61*2238dcc3SJonas Devlieghere 0, 62*2238dcc3SJonas Devlieghere "the deep ValueObject has a zero value", 63*2238dcc3SJonas Devlieghere ) 641fb5c7a2SDave Lee self.assertNotEqual( 65*2238dcc3SJonas Devlieghere child.GetChildAtIndex(1).GetValueAsUnsigned(), 66*2238dcc3SJonas Devlieghere 0, 67*2238dcc3SJonas Devlieghere "the deep ValueObject has no next", 68*2238dcc3SJonas Devlieghere ) 69