1""" 2Test lldb data formatter subsystem. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class NSArraySyntheticTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 def setUp(self): 18 # Call super's setUp(). 19 TestBase.setUp(self) 20 # Find the line number to break at. 21 self.line = line_number('main.m', '// Set break point at this line.') 22 23 @skipUnlessDarwin 24 def test_rdar11086338_with_run_command(self): 25 """Test that NSArray reports its synthetic children properly.""" 26 self.build() 27 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 28 29 lldbutil.run_break_set_by_file_and_line( 30 self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 31 32 self.runCmd("run", RUN_SUCCEEDED) 33 34 # The stop reason of the thread should be breakpoint. 35 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 36 substrs=['stopped', 37 'stop reason = breakpoint']) 38 39 # This is the function to remove the custom formats in order to have a 40 # clean slate for the next test case. 41 def cleanup(): 42 self.runCmd('type format clear', check=False) 43 self.runCmd('type summary clear', check=False) 44 self.runCmd('type synth clear', check=False) 45 46 # Execute the cleanup function during test case tear down. 47 self.addTearDownHook(cleanup) 48 49 # Now check that we are displaying Cocoa classes correctly 50 self.expect('frame variable arr', 51 substrs=['@"6 elements"']) 52 self.expect('frame variable other_arr', 53 substrs=['@"4 elements"']) 54 self.expect( 55 'frame variable arr --ptr-depth 1', 56 substrs=[ 57 '@"6 elements"', 58 '[0] = 0x', 59 '[1] = 0x', 60 '[2] = 0x', 61 '[3] = 0x', 62 '[4] = 0x', 63 '[5] = 0x']) 64 self.expect( 65 'frame variable other_arr --ptr-depth 1', 66 substrs=[ 67 '@"4 elements"', 68 '[0] = 0x', 69 '[1] = 0x', 70 '[2] = 0x', 71 '[3] = 0x']) 72 self.expect( 73 'frame variable arr --ptr-depth 1 -d no-run-target', 74 substrs=[ 75 '@"6 elements"', 76 '@"hello"', 77 '@"world"', 78 '@"this"', 79 '@"is"', 80 '@"me"', 81 '@"http://www.apple.com']) 82 self.expect( 83 'frame variable other_arr --ptr-depth 1 -d no-run-target', 84 substrs=[ 85 '@"4 elements"', 86 '(int)5', 87 '@"a string"', 88 '@"6 elements"']) 89 self.expect( 90 'frame variable other_arr --ptr-depth 2 -d no-run-target', 91 substrs=[ 92 '@"4 elements"', 93 '@"6 elements" {', 94 '@"hello"', 95 '@"world"', 96 '@"this"', 97 '@"is"', 98 '@"me"', 99 '@"http://www.apple.com']) 100 101 self.assertTrue( 102 self.frame().FindVariable("arr").MightHaveChildren(), 103 "arr says it does not have children!") 104 self.assertTrue( 105 self.frame().FindVariable("other_arr").MightHaveChildren(), 106 "arr says it does not have children!") 107