1""" 2Test lldb data formatter subsystem. 3""" 4 5 6 7import lldb 8from lldbsuite.test.lldbtest import * 9import lldbsuite.test.lldbutil as lldbutil 10 11 12class PtrToArrayDataFormatterTestCase(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 def test_with_run_command(self): 17 """Test that LLDB handles the clang typeclass Paren correctly.""" 18 self.build() 19 self.data_formatter_commands() 20 21 def setUp(self): 22 # Call super's setUp(). 23 TestBase.setUp(self) 24 # Find the line number to break at. 25 self.line = line_number('main.cpp', '// Set break point at this line.') 26 27 def data_formatter_commands(self): 28 """Test that LLDB handles the clang typeclass Paren correctly.""" 29 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 30 31 lldbutil.run_break_set_by_file_and_line( 32 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 33 34 self.runCmd("run", RUN_SUCCEEDED) 35 36 # The stop reason of the thread should be breakpoint. 37 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 38 substrs=['stopped', 39 'stop reason = breakpoint']) 40 41 # This is the function to remove the custom formats in order to have a 42 # clean slate for the next test case. 43 def cleanup(): 44 self.runCmd('type format delete hex', check=False) 45 self.runCmd('type summary clear', check=False) 46 47 # Execute the cleanup function during test case tear down. 48 self.addTearDownHook(cleanup) 49 50 self.expect('p *(int (*)[3])foo', 51 substrs=['(int[3]) $', '[0] = 1', '[1] = 2', '[2] = 3']) 52 53 self.expect('p *(int (*)[3])foo', matching=False, 54 substrs=['01 00 00 00 02 00 00 00 03 00 00 00']) 55 self.expect('p *(int (*)[3])foo', matching=False, 56 substrs=['0x000000030000000200000001']) 57