1 """ 2 Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs 3 """ 4 5 import os, time 6 import unittest2 7 import lldb 8 from lldbtest import * 9 import lldbutil 10 11 class Rdar10887661TestCase(TestBase): 12 13 mydir = os.path.join("functionalities", "data-formatter", "rdar-10887661") 14 15 # rdar://problem/10887661 16 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 17 @dsym_test 18 def test_with_dsym_and_run_command(self): 19 """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs.""" 20 self.buildDsym() 21 self.capping_test_commands() 22 23 # rdar://problem/10887661 24 @dwarf_test 25 def test_with_dwarf_and_run_command(self): 26 """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs.""" 27 self.buildDwarf() 28 self.capping_test_commands() 29 30 def setUp(self): 31 # Call super's setUp(). 32 TestBase.setUp(self) 33 # Find the line number to break at. 34 self.line = line_number('main.cpp', '// Set break point at this line.') 35 36 def capping_test_commands(self): 37 """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs.""" 38 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) 39 40 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 41 42 self.runCmd("run", RUN_SUCCEEDED) 43 44 # The stop reason of the thread should be breakpoint. 45 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 46 substrs = ['stopped', 47 'stop reason = breakpoint']) 48 49 # This is the function to remove the custom formats in order to have a 50 # clean slate for the next test case. 51 def cleanup(): 52 self.runCmd('type format clear', check=False) 53 self.runCmd('type summary clear', check=False) 54 self.runCmd('type filter clear', check=False) 55 self.runCmd('type synth clear', check=False) 56 self.runCmd("settings set target.max-children-count 256", check=False) 57 58 # Execute the cleanup function during test case tear down. 59 self.addTearDownHook(cleanup) 60 61 # set up the synthetic children provider 62 self.runCmd("script from fooSynthProvider import *") 63 self.runCmd("type synth add -l fooSynthProvider foo") 64 65 # check that the synthetic children work, so we know we are doing the right thing 66 self.expect("frame variable f00_1", 67 substrs = ['r = 33', 68 'fake_a = 16777216', 69 'a = 0']); 70 71 # check that capping works 72 self.runCmd("settings set target.max-children-count 2", check=False) 73 74 self.expect("frame variable f00_1", 75 substrs = ['...', 76 'fake_a = 16777216', 77 'a = 0']); 78 79 self.expect("frame variable f00_1", matching=False, 80 substrs = ['r = 33']); 81 82 83 self.runCmd("settings set target.max-children-count 256", check=False) 84 85 self.expect("frame variable f00_1", matching=True, 86 substrs = ['r = 33']); 87 88 if __name__ == '__main__': 89 import atexit 90 lldb.SBDebugger.Initialize() 91 atexit.register(lambda: lldb.SBDebugger.Terminate()) 92 unittest2.main() 93