1""" 2Test that the user can input a format but it will not prevail over summary format's choices. 3""" 4 5 6 7import lldb 8from lldbsuite.test.lldbtest import * 9import lldbsuite.test.lldbutil as lldbutil 10 11 12class UserFormatVSSummaryTestCase(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 the user can input a format but it will not prevail over summary format's choices.""" 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 self.expect("frame variable p1", substrs=[ 38 '(Pair) p1 = (x = 3, y = -3)']) 39 40 # This is the function to remove the custom formats in order to have a 41 # clean slate for the next test case. 42 def cleanup(): 43 self.runCmd('type format clear', check=False) 44 self.runCmd('type summary clear', check=False) 45 46 # Execute the cleanup function during test case tear down. 47 self.addTearDownHook(cleanup) 48 49 self.runCmd('type summary add Pair -s "x=${var.x%d},y=${var.y%u}"') 50 51 self.expect("frame variable p1", substrs=[ 52 '(Pair) p1 = x=3,y=4294967293']) 53 self.expect( 54 "frame variable -f x p1", 55 substrs=['(Pair) p1 = x=0x00000003,y=0xfffffffd'], 56 matching=False) 57 self.expect( 58 "frame variable -f d p1", 59 substrs=['(Pair) p1 = x=3,y=-3'], 60 matching=False) 61 self.expect("frame variable p1", substrs=[ 62 '(Pair) p1 = x=3,y=4294967293']) 63 64 self.runCmd('type summary add Pair -s "x=${var.x%x},y=${var.y%u}"') 65 66 self.expect("frame variable p1", substrs=[ 67 '(Pair) p1 = x=0x00000003,y=4294967293']) 68 self.expect( 69 "frame variable -f d p1", 70 substrs=['(Pair) p1 = x=3,y=-3'], 71 matching=False) 72