2 Test lldb data formatter subsystem.
5 from __future__ import print_function
11 from lldbsuite.test.lldbtest import *
13 import lldbsuite.test.lldbutil as lldbutil
15 class NSArraySyntheticTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
20 # Call super's setUp().
22 # Find the line number to break at.
23 self.line = line_number('main.m', '// Set break point at this line.')
26 def test_rdar11086338_with_run_command(self):
27 """Test that NSArray reports its synthetic children properly."""
29 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
31 lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
33 self.runCmd("run", RUN_SUCCEEDED)
35 # The stop reason of the thread should be breakpoint.
36 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
38 'stop reason = breakpoint'])
40 # This is the function to remove the custom formats in order to have a
41 # clean slate for the next test case.
43 self.runCmd('type format clear', check=False)
44 self.runCmd('type summary clear', check=False)
45 self.runCmd('type synth clear', check=False)
47 # Execute the cleanup function during test case tear down.
48 self.addTearDownHook(cleanup)
50 # Now check that we are displaying Cocoa classes correctly
51 self.expect('frame variable arr',
52 substrs = ['@"6 elements"'])
53 self.expect('frame variable other_arr',
54 substrs = ['@"4 elements"'])
55 self.expect('frame variable arr --ptr-depth 1',
56 substrs = ['@"6 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x','[4] = 0x','[5] = 0x'])
57 self.expect('frame variable other_arr --ptr-depth 1',
58 substrs = ['@"4 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x'])
59 self.expect('frame variable arr --ptr-depth 1 -d no-run-target',
60 substrs = ['@"6 elements"','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com'])
61 self.expect('frame variable other_arr --ptr-depth 1 -d no-run-target',
62 substrs = ['@"4 elements"','(int)5','@"a string"','@"6 elements"'])
63 self.expect('frame variable other_arr --ptr-depth 2 -d no-run-target',
64 substrs = ['@"4 elements"','@"6 elements" {','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com'])
66 self.assertTrue(self.frame().FindVariable("arr").MightHaveChildren(), "arr says it does not have children!")
67 self.assertTrue(self.frame().FindVariable("other_arr").MightHaveChildren(), "arr says it does not have children!")