2 Test lldb data formatter subsystem.
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class LibcxxMultiMapDataFormatterTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
20 ns = 'ndk' if lldbplatformutil.target_is_android() else ''
21 self.namespace = 'std::__' + ns + '1'
23 @add_test_categories(["libc++"])
24 def test_with_run_command(self):
25 """Test that that file and class static variables display correctly."""
27 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
29 bkpt = self.target().FindBreakpointByID(
30 lldbutil.run_break_set_by_source_regexp(
31 self, "Set break point at this line."))
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 filter clear', check=False)
46 self.runCmd('type synth clear', check=False)
48 "settings set target.max-children-count 256",
51 # Execute the cleanup function during test case tear down.
52 self.addTearDownHook(cleanup)
54 multimap = self.namespace + "::multimap"
55 self.expect('frame variable ii',
56 substrs=[multimap, 'size=0',
59 lldbutil.continue_to_breakpoint(self.process(), bkpt)
61 self.expect('frame variable ii',
62 substrs=[multimap, 'size=2',
70 lldbutil.continue_to_breakpoint(self.process(), bkpt)
72 self.expect('frame variable ii',
73 substrs=[multimap, 'size=4',
81 lldbutil.continue_to_breakpoint(self.process(), bkpt)
83 self.expect("frame variable ii",
84 substrs=[multimap, 'size=8',
93 substrs=[multimap, 'size=8',
101 # check access-by-index
102 self.expect("frame variable ii[0]",
103 substrs=['first = 0',
105 self.expect("frame variable ii[3]",
109 # check that MightHaveChildren() gets it right
111 self.frame().FindVariable("ii").MightHaveChildren(),
112 "ii.MightHaveChildren() says False for non empty!")
114 # check that the expression parser does not make use of
115 # synthetic children instead of running code
116 # TOT clang has a fix for this, which makes the expression command here succeed
117 # since this would make the test fail or succeed depending on clang version in use
118 # this is safer commented for the time being
119 # self.expect("expression ii[8]", matching=False, error=True,
120 # substrs = ['1234567'])
122 lldbutil.continue_to_breakpoint(self.process(), bkpt)
124 self.expect('frame variable ii',
125 substrs=[multimap, 'size=0',
128 self.expect('frame variable si',
129 substrs=[multimap, 'size=0',
132 lldbutil.continue_to_breakpoint(self.process(), bkpt)
134 self.expect('frame variable si',
135 substrs=[multimap, 'size=1',
140 lldbutil.continue_to_breakpoint(self.process(), bkpt)
142 self.expect("frame variable si",
143 substrs=[multimap, 'size=4',
158 substrs=[multimap, 'size=4',
172 # check that MightHaveChildren() gets it right
174 self.frame().FindVariable("si").MightHaveChildren(),
175 "si.MightHaveChildren() says False for non empty!")
177 # check access-by-index
178 self.expect("frame variable si[0]",
179 substrs=['first = ', 'one',
182 # check that the expression parser does not make use of
183 # synthetic children instead of running code
184 # TOT clang has a fix for this, which makes the expression command here succeed
185 # since this would make the test fail or succeed depending on clang version in use
186 # this is safer commented for the time being
187 # self.expect("expression si[0]", matching=False, error=True,
188 # substrs = ['first = ', 'zero'])
190 lldbutil.continue_to_breakpoint(self.process(), bkpt)
192 self.expect('frame variable si',
193 substrs=[multimap, 'size=0',
196 lldbutil.continue_to_breakpoint(self.process(), bkpt)
198 self.expect('frame variable is',
199 substrs=[multimap, 'size=0',
202 lldbutil.continue_to_breakpoint(self.process(), bkpt)
204 self.expect("frame variable is",
205 substrs=[multimap, 'size=4',
207 'second = \"goofy\"',
213 'second = \"smart\"',
220 substrs=[multimap, 'size=4',
222 'second = \"goofy\"',
228 'second = \"smart\"',
234 # check that MightHaveChildren() gets it right
236 self.frame().FindVariable("is").MightHaveChildren(),
237 "is.MightHaveChildren() says False for non empty!")
239 # check access-by-index
240 self.expect("frame variable is[0]",
244 # check that the expression parser does not make use of
245 # synthetic children instead of running code
246 # TOT clang has a fix for this, which makes the expression command here succeed
247 # since this would make the test fail or succeed depending on clang version in use
248 # this is safer commented for the time being
249 # self.expect("expression is[0]", matching=False, error=True,
250 # substrs = ['first = ', 'goofy'])
252 lldbutil.continue_to_breakpoint(self.process(), bkpt)
254 self.expect('frame variable is',
255 substrs=[multimap, 'size=0',
258 lldbutil.continue_to_breakpoint(self.process(), bkpt)
260 self.expect('frame variable ss',
261 substrs=[multimap, 'size=0',
264 lldbutil.continue_to_breakpoint(self.process(), bkpt)
266 self.expect("frame variable ss",
267 substrs=[multimap, 'size=3',
269 'second = \"hello\"',
272 'second = \"house\"',
276 'first = \"gatto\"'])
279 substrs=[multimap, 'size=3',
281 'second = \"hello\"',
284 'second = \"house\"',
288 'first = \"gatto\"'])
290 # check that MightHaveChildren() gets it right
292 self.frame().FindVariable("ss").MightHaveChildren(),
293 "ss.MightHaveChildren() says False for non empty!")
295 # check access-by-index
296 self.expect("frame variable ss[2]",
297 substrs=['gatto', 'cat'])
299 # check that the expression parser does not make use of
300 # synthetic children instead of running code
301 # TOT clang has a fix for this, which makes the expression command here succeed
302 # since this would make the test fail or succeed depending on clang version in use
303 # this is safer commented for the time being
304 # self.expect("expression ss[3]", matching=False, error=True,
305 # substrs = ['gatto'])
307 lldbutil.continue_to_breakpoint(self.process(), bkpt)
309 self.expect('frame variable ss',
310 substrs=[multimap, 'size=0',