1""" 2Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class SyntheticCappingTestCase(TestBase): 14 15 def setUp(self): 16 # Call super's setUp(). 17 TestBase.setUp(self) 18 # Find the line number to break at. 19 self.line = line_number('main.cpp', '// Set break point at this line.') 20 21 def test_with_run_command(self): 22 """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs.""" 23 self.build() 24 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 25 26 lldbutil.run_break_set_by_file_and_line( 27 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 28 29 self.runCmd("run", RUN_SUCCEEDED) 30 31 process = self.dbg.GetSelectedTarget().GetProcess() 32 33 # The stop reason of the thread should be breakpoint. 34 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 35 substrs=['stopped', 36 'stop reason = breakpoint']) 37 38 # This is the function to remove the custom formats in order to have a 39 # clean slate for the next test case. 40 def cleanup(): 41 self.runCmd('type format clear', check=False) 42 self.runCmd('type summary clear', check=False) 43 self.runCmd('type filter clear', check=False) 44 self.runCmd('type synth clear', check=False) 45 self.runCmd( 46 "settings set target.max-children-count 256", 47 check=False) 48 49 # Execute the cleanup function during test case tear down. 50 self.addTearDownHook(cleanup) 51 52 # set up the synthetic children provider 53 self.runCmd("script from fooSynthProvider import *") 54 self.runCmd("type synth add -l fooSynthProvider foo") 55 56 # note that the value of fake_a depends on target byte order 57 if process.GetByteOrder() == lldb.eByteOrderLittle: 58 fake_a_val = 0x02000000 59 else: 60 fake_a_val = 0x00000100 61 62 # check that the synthetic children work, so we know we are doing the 63 # right thing 64 self.expect( 65 "frame variable f00_1", 66 substrs=[ 67 'a = 1', 68 'fake_a = %d' % fake_a_val, 69 'r = 34', 70 ]) 71 72 # check that capping works 73 self.runCmd("settings set target.max-children-count 2", check=False) 74 75 self.expect("frame variable f00_1", 76 substrs=[ 77 'a = 1', 78 'fake_a = %d' % fake_a_val, 79 '...', 80 ]) 81 82 self.expect("frame variable f00_1", matching=False, 83 substrs=['r = 34']) 84 85 self.runCmd("settings set target.max-children-count 256", check=False) 86 87 self.expect("frame variable f00_1", matching=True, 88 substrs=['r = 34']) 89