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 VarInAggregateMisuseTestCase(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 def setUp(self): 17 # Call super's setUp(). 18 TestBase.setUp(self) 19 # Find the line number to break at. 20 self.line = line_number('main.cpp', '// Set break point at this line.') 21 22 def test_with_run_command(self): 23 """Test that that file and class static variables display correctly.""" 24 self.build() 25 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 26 27 lldbutil.run_break_set_by_file_and_line( 28 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 29 30 self.runCmd("run", RUN_SUCCEEDED) 31 32 # The stop reason of the thread should be breakpoint. 33 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 34 substrs=['stopped', 35 'stop reason = breakpoint']) 36 37 # This is the function to remove the custom formats in order to have a 38 # clean slate for the next test case. 39 def cleanup(): 40 self.runCmd('type summary clear', check=False) 41 42 # Execute the cleanup function during test case tear down. 43 self.addTearDownHook(cleanup) 44 45 self.runCmd( 46 "type summary add --summary-string \"SUMMARY SUCCESS ${var}\" Summarize") 47 48 self.expect('frame variable mine_ptr', 49 substrs=['SUMMARY SUCCESS summarize_ptr_t @ ']) 50 51 self.expect('frame variable *mine_ptr', 52 substrs=['SUMMARY SUCCESS summarize_t @']) 53 54 self.runCmd( 55 "type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") 56 57 self.expect('frame variable mine_ptr', 58 substrs=['SUMMARY SUCCESS 10']) 59 60 self.expect('frame variable *mine_ptr', 61 substrs=['SUMMARY SUCCESS 10']) 62 63 self.runCmd("type summary add --summary-string \"${var}\" Summarize") 64 self.runCmd( 65 "type summary add --summary-string \"${var}\" -e TwoSummarizes") 66 67 self.expect('frame variable', 68 substrs=['(TwoSummarizes) twos = TwoSummarizes @ ', 69 'first = summarize_t @ ', 70 'second = summarize_t @ ']) 71 72 self.runCmd( 73 "type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") 74 self.expect('frame variable', 75 substrs=['(TwoSummarizes) twos = TwoSummarizes @ ', 76 'first = SUMMARY SUCCESS 1', 77 'second = SUMMARY SUCCESS 3']) 78