2 Test lldb data formatter subsystem.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class LibcxxMapDataFormatterTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
19 ns = 'ndk' if lldbplatformutil.target_is_android() else ''
20 self.namespace = 'std::__' + ns + '1'
22 @add_test_categories(["libc++"])
23 def test_with_run_command(self):
24 """Test that that file and class static variables display correctly."""
26 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
28 bkpt = self.target().FindBreakpointByID(
29 lldbutil.run_break_set_by_source_regexp(
30 self, "Set break point at this line."))
32 self.runCmd("run", RUN_SUCCEEDED)
34 # The stop reason of the thread should be breakpoint.
35 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
37 'stop reason = breakpoint'])
39 # This is the function to remove the custom formats in order to have a
40 # clean slate for the next test case.
42 self.runCmd('type format clear', check=False)
43 self.runCmd('type summary clear', check=False)
44 self.runCmd('type filter clear', check=False)
45 self.runCmd('type synth clear', check=False)
47 "settings set target.max-children-count 256",
50 # Execute the cleanup function during test case tear down.
51 self.addTearDownHook(cleanup)
55 substrs=['%s::map' % ns,
58 self.expect('frame var ii',
59 substrs=['%s::map' % ns,
63 lldbutil.continue_to_breakpoint(self.process(), bkpt)
66 substrs=['%s::map' % ns, 'size=2',
74 self.expect('frame variable ii',
75 substrs=['%s::map' % ns, 'size=2',
83 lldbutil.continue_to_breakpoint(self.process(), bkpt)
85 self.expect('frame variable ii',
86 substrs=['%s::map' % ns, 'size=4',
94 lldbutil.continue_to_breakpoint(self.process(), bkpt)
97 substrs=['%s::map' % ns, 'size=8',
105 self.expect("frame var ii",
106 substrs=['%s::map' % ns, 'size=8',
114 # check access-by-index
115 self.expect("frame variable ii[0]",
116 substrs=['first = 0',
118 self.expect("frame variable ii[3]",
122 # check that MightHaveChildren() gets it right
124 self.frame().FindVariable("ii").MightHaveChildren(),
125 "ii.MightHaveChildren() says False for non empty!")
127 # check that the expression parser does not make use of
128 # synthetic children instead of running code
129 # TOT clang has a fix for this, which makes the expression command here succeed
130 # since this would make the test fail or succeed depending on clang version in use
131 # this is safer commented for the time being
132 # self.expect("expression ii[8]", matching=False, error=True,
133 # substrs = ['1234567'])
135 self.runCmd("continue")
137 self.expect('frame variable ii',
138 substrs=['%s::map' % ns, 'size=0',
141 self.expect('frame variable si',
142 substrs=['%s::map' % ns, 'size=0',
145 self.runCmd("continue")
147 self.expect('frame variable si',
148 substrs=['%s::map' % ns, 'size=1',
153 lldbutil.continue_to_breakpoint(self.process(), bkpt)
155 self.expect("frame variable si",
156 substrs=['%s::map' % ns, 'size=4',
171 substrs=['%s::map' % ns, 'size=4',
185 # check that MightHaveChildren() gets it right
187 self.frame().FindVariable("si").MightHaveChildren(),
188 "si.MightHaveChildren() says False for non empty!")
190 # check access-by-index
191 self.expect("frame variable si[0]",
192 substrs=['first = ', 'one',
195 # check that the expression parser does not make use of
196 # synthetic children instead of running code
197 # TOT clang has a fix for this, which makes the expression command here succeed
198 # since this would make the test fail or succeed depending on clang version in use
199 # this is safer commented for the time being
200 # self.expect("expression si[0]", matching=False, error=True,
201 # substrs = ['first = ', 'zero'])
203 lldbutil.continue_to_breakpoint(self.process(), bkpt)
205 self.expect('frame variable si',
206 substrs=['%s::map' % ns, 'size=0',
209 lldbutil.continue_to_breakpoint(self.process(), bkpt)
211 self.expect('frame variable is',
212 substrs=['%s::map' % ns, 'size=0',
215 lldbutil.continue_to_breakpoint(self.process(), bkpt)
217 self.expect("frame variable is",
218 substrs=['%s::map' % ns, 'size=4',
220 'second = \"goofy\"',
226 'second = \"smart\"',
233 substrs=['%s::map' % ns, 'size=4',
235 'second = \"goofy\"',
241 'second = \"smart\"',
247 # check that MightHaveChildren() gets it right
249 self.frame().FindVariable("is").MightHaveChildren(),
250 "is.MightHaveChildren() says False for non empty!")
252 # check access-by-index
253 self.expect("frame variable is[0]",
257 # check that the expression parser does not make use of
258 # synthetic children instead of running code
259 # TOT clang has a fix for this, which makes the expression command here succeed
260 # since this would make the test fail or succeed depending on clang version in use
261 # this is safer commented for the time being
262 # self.expect("expression is[0]", matching=False, error=True,
263 # substrs = ['first = ', 'goofy'])
265 lldbutil.continue_to_breakpoint(self.process(), bkpt)
267 self.expect('frame variable is',
268 substrs=['%s::map' % ns, 'size=0',
271 lldbutil.continue_to_breakpoint(self.process(), bkpt)
273 self.expect('frame variable ss',
274 substrs=['%s::map' % ns, 'size=0',
277 lldbutil.continue_to_breakpoint(self.process(), bkpt)
279 self.expect("frame variable ss",
280 substrs=['%s::map' % ns, 'size=3',
282 'second = \"hello\"',
285 'second = \"house\"',
289 'first = \"gatto\"'])
292 substrs=['%s::map' % ns, 'size=3',
294 'second = \"hello\"',
297 'second = \"house\"',
301 'first = \"gatto\"'])
303 # check that MightHaveChildren() gets it right
305 self.frame().FindVariable("ss").MightHaveChildren(),
306 "ss.MightHaveChildren() says False for non empty!")
308 # check access-by-index
309 self.expect("frame variable ss[2]",
310 substrs=['gatto', 'cat'])
312 # check that the expression parser does not make use of
313 # synthetic children instead of running code
314 # TOT clang has a fix for this, which makes the expression command here succeed
315 # since this would make the test fail or succeed depending on clang version in use
316 # this is safer commented for the time being
317 # self.expect("expression ss[3]", matching=False, error=True,
318 # substrs = ['gatto'])
320 lldbutil.continue_to_breakpoint(self.process(), bkpt)
322 self.expect('frame variable ss',
323 substrs=['%s::map' % ns, 'size=0',