2e8ca4591c9047962b345de41108ce21563fbbdd
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class NSSetSyntheticTestCase(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_rdar12529957_with_run_command(self):
25         """Test that NSSet 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 set',
51                     substrs=['4 elements'])
52         self.expect('frame variable mutable',
53                     substrs=['9 elements'])
54         self.expect(
55             'frame variable set --ptr-depth 1 -d run -T',
56             substrs=[
57                 '4 elements',
58                 '[0]',
59                 '[1]',
60                 '[2]',
61                 '[3]',
62                 'hello',
63                 'world',
64                 '(int)1',
65                 '(int)2'])
66         self.expect(
67             'frame variable mutable --ptr-depth 1 -d run -T',
68             substrs=[
69                 '9 elements',
70                 '(int)5',
71                 '@"3 elements"',
72                 '@"www.apple.com"',
73                 '(int)3',
74                 '@"world"',
75                 '(int)4'])
76
77         self.runCmd("next")
78         self.expect('frame variable mutable',
79                     substrs=['0 elements'])
80
81         self.runCmd("next")
82         self.expect('frame variable mutable',
83                     substrs=['4 elements'])
84         self.expect(
85             'frame variable mutable --ptr-depth 1 -d run -T',
86             substrs=[
87                 '4 elements',
88                 '[0]',
89                 '[1]',
90                 '[2]',
91                 '[3]',
92                 'hello',
93                 'world',
94                 '(int)1',
95                 '(int)2'])
96
97         self.runCmd("next")
98         self.expect('frame variable mutable',
99                     substrs=['4 elements'])
100         self.expect(
101             'frame variable mutable --ptr-depth 1 -d run -T',
102             substrs=[
103                 '4 elements',
104                 '[0]',
105                 '[1]',
106                 '[2]',
107                 '[3]',
108                 'hello',
109                 'world',
110                 '(int)1',
111                 '(int)2'])