2 Test lldb data formatter subsystem.
5 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
16 class StdMapDataFormatterTestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
21 # Call super's setUp().
23 # Find the line number to break at.
24 self.line = line_number('main.cpp', '// Set break point at this line.')
26 @skipIfWindows # libstdcpp not ported to Windows
28 def test_with_run_command(self):
29 """Test that that file and class static variables display correctly."""
31 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
33 lldbutil.run_break_set_by_source_regexp(
34 self, "Set break point at this line.")
36 self.runCmd("run", RUN_SUCCEEDED)
38 # The stop reason of the thread should be breakpoint.
39 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
41 'stop reason = breakpoint'])
43 # This is the function to remove the custom formats in order to have a
44 # clean slate for the next test case.
46 self.runCmd('type format clear', check=False)
47 self.runCmd('type summary clear', check=False)
48 self.runCmd('type filter clear', check=False)
49 self.runCmd('type synth clear', check=False)
51 "settings set target.max-children-count 256",
54 # Execute the cleanup function during test case tear down.
55 self.addTearDownHook(cleanup)
57 self.runCmd("frame variable ii --show-types")
60 "type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e")
62 self.expect('frame variable ii',
63 substrs=['map has 0 items',
68 self.expect('frame variable ii',
69 substrs=['map has 2 items',
79 self.expect('frame variable ii',
80 substrs=['map has 4 items',
90 self.expect("frame variable ii",
91 substrs=['map has 9 items',
100 substrs=['map has 9 items',
108 # check access-by-index
109 self.expect("frame variable ii[0]",
110 substrs=['first = 0',
112 self.expect("frame variable ii[3]",
116 self.expect("frame variable ii[8]", matching=True,
119 # check that MightHaveChildren() gets it right
121 self.frame().FindVariable("ii").MightHaveChildren(),
122 "ii.MightHaveChildren() says False for non empty!")
124 # check that the expression parser does not make use of
125 # synthetic children instead of running code
126 # TOT clang has a fix for this, which makes the expression command here succeed
127 # since this would make the test fail or succeed depending on clang version in use
128 # this is safer commented for the time being
129 # self.expect("expression ii[8]", matching=False, error=True,
130 # substrs = ['1234567'])
134 self.expect('frame variable ii',
135 substrs=['map has 0 items',
138 self.runCmd("frame variable si --show-types")
140 self.expect('frame variable si',
141 substrs=['map has 0 items',
146 self.expect('frame variable si',
147 substrs=['map has 1 items',
154 self.expect("frame variable si",
155 substrs=['map has 5 items',
173 substrs=['map has 5 items',
190 # check access-by-index
191 self.expect("frame variable si[0]",
192 substrs=['first = ', 'four',
195 # check that MightHaveChildren() gets it right
197 self.frame().FindVariable("si").MightHaveChildren(),
198 "si.MightHaveChildren() says False for non empty!")
200 # check that the expression parser does not make use of
201 # synthetic children instead of running code
202 # TOT clang has a fix for this, which makes the expression command here succeed
203 # since this would make the test fail or succeed depending on clang version in use
204 # this is safer commented for the time being
205 # self.expect("expression si[0]", matching=False, error=True,
206 # substrs = ['first = ', 'zero'])
210 self.expect('frame variable si',
211 substrs=['map has 0 items',
214 self.runCmd("frame variable is --show-types")
216 self.expect('frame variable is',
217 substrs=['map has 0 items',
222 self.expect("frame variable is",
223 substrs=['map has 4 items',
225 'second = \"goofy\"',
231 'second = \"smart\"',
238 substrs=['map has 4 items',
240 'second = \"goofy\"',
246 'second = \"smart\"',
252 # check access-by-index
253 self.expect("frame variable is[0]",
257 # check that MightHaveChildren() gets it right
259 self.frame().FindVariable("is").MightHaveChildren(),
260 "is.MightHaveChildren() says False for non empty!")
262 # check that the expression parser does not make use of
263 # synthetic children instead of running code
264 # TOT clang has a fix for this, which makes the expression command here succeed
265 # since this would make the test fail or succeed depending on clang version in use
266 # this is safer commented for the time being
267 # self.expect("expression is[0]", matching=False, error=True,
268 # substrs = ['first = ', 'goofy'])
272 self.expect('frame variable is',
273 substrs=['map has 0 items',
276 self.runCmd("frame variable ss --show-types")
278 self.expect('frame variable ss',
279 substrs=['map has 0 items',
284 self.expect("frame variable ss",
285 substrs=['map has 4 items',
287 'second = \"hello\"',
290 'second = \"house\"',
296 'second = \"..is always a Mac!\"',
297 'first = \"a Mac..\"'])
300 substrs=['map has 4 items',
302 'second = \"hello\"',
305 'second = \"house\"',
311 'second = \"..is always a Mac!\"',
312 'first = \"a Mac..\"'])
314 # check access-by-index
315 self.expect("frame variable ss[3]",
316 substrs=['gatto', 'cat'])
318 # check that MightHaveChildren() gets it right
320 self.frame().FindVariable("ss").MightHaveChildren(),
321 "ss.MightHaveChildren() says False for non empty!")
323 # check that the expression parser does not make use of
324 # synthetic children instead of running code
325 # TOT clang has a fix for this, which makes the expression command here succeed
326 # since this would make the test fail or succeed depending on clang version in use
327 # this is safer commented for the time being
328 # self.expect("expression ss[3]", matching=False, error=True,
329 # substrs = ['gatto'])
333 self.expect('frame variable ss',
334 substrs=['map has 0 items',