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 @skipIfwatchOS # libstdcpp not ported to watchos
29 def test_with_run_command(self):
30 """Test that that file and class static variables display correctly."""
32 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
34 lldbutil.run_break_set_by_source_regexp(
35 self, "Set break point at this line.")
37 self.runCmd("run", RUN_SUCCEEDED)
39 # The stop reason of the thread should be breakpoint.
40 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
42 'stop reason = breakpoint'])
44 # This is the function to remove the custom formats in order to have a
45 # clean slate for the next test case.
47 self.runCmd('type format clear', check=False)
48 self.runCmd('type summary clear', check=False)
49 self.runCmd('type filter clear', check=False)
50 self.runCmd('type synth clear', check=False)
52 "settings set target.max-children-count 256",
55 # Execute the cleanup function during test case tear down.
56 self.addTearDownHook(cleanup)
58 self.runCmd("frame variable ii --show-types")
61 "type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e")
63 self.expect('frame variable ii',
64 substrs=['map has 0 items',
69 self.expect('frame variable ii',
70 substrs=['map has 2 items',
80 self.expect('frame variable ii',
81 substrs=['map has 4 items',
91 self.expect("frame variable ii",
92 substrs=['map has 9 items',
101 substrs=['map has 9 items',
109 # check access-by-index
110 self.expect("frame variable ii[0]",
111 substrs=['first = 0',
113 self.expect("frame variable ii[3]",
117 self.expect("frame variable ii[8]", matching=True,
120 # check that MightHaveChildren() gets it right
122 self.frame().FindVariable("ii").MightHaveChildren(),
123 "ii.MightHaveChildren() says False for non empty!")
125 # check that the expression parser does not make use of
126 # synthetic children instead of running code
127 # TOT clang has a fix for this, which makes the expression command here succeed
128 # since this would make the test fail or succeed depending on clang version in use
129 # this is safer commented for the time being
130 # self.expect("expression ii[8]", matching=False, error=True,
131 # substrs = ['1234567'])
135 self.expect('frame variable ii',
136 substrs=['map has 0 items',
139 self.runCmd("frame variable si --show-types")
141 self.expect('frame variable si',
142 substrs=['map has 0 items',
147 self.expect('frame variable si',
148 substrs=['map has 1 items',
155 self.expect("frame variable si",
156 substrs=['map has 5 items',
174 substrs=['map has 5 items',
191 # check access-by-index
192 self.expect("frame variable si[0]",
193 substrs=['first = ', 'four',
196 # check that MightHaveChildren() gets it right
198 self.frame().FindVariable("si").MightHaveChildren(),
199 "si.MightHaveChildren() says False for non empty!")
201 # check that the expression parser does not make use of
202 # synthetic children instead of running code
203 # TOT clang has a fix for this, which makes the expression command here succeed
204 # since this would make the test fail or succeed depending on clang version in use
205 # this is safer commented for the time being
206 # self.expect("expression si[0]", matching=False, error=True,
207 # substrs = ['first = ', 'zero'])
211 self.expect('frame variable si',
212 substrs=['map has 0 items',
215 self.runCmd("frame variable is --show-types")
217 self.expect('frame variable is',
218 substrs=['map has 0 items',
223 self.expect("frame variable is",
224 substrs=['map has 4 items',
226 'second = \"goofy\"',
232 'second = \"smart\"',
239 substrs=['map has 4 items',
241 'second = \"goofy\"',
247 'second = \"smart\"',
253 # check access-by-index
254 self.expect("frame variable is[0]",
258 # check that MightHaveChildren() gets it right
260 self.frame().FindVariable("is").MightHaveChildren(),
261 "is.MightHaveChildren() says False for non empty!")
263 # check that the expression parser does not make use of
264 # synthetic children instead of running code
265 # TOT clang has a fix for this, which makes the expression command here succeed
266 # since this would make the test fail or succeed depending on clang version in use
267 # this is safer commented for the time being
268 # self.expect("expression is[0]", matching=False, error=True,
269 # substrs = ['first = ', 'goofy'])
273 self.expect('frame variable is',
274 substrs=['map has 0 items',
277 self.runCmd("frame variable ss --show-types")
279 self.expect('frame variable ss',
280 substrs=['map has 0 items',
285 self.expect("frame variable ss",
286 substrs=['map has 4 items',
288 'second = \"hello\"',
291 'second = \"house\"',
297 'second = \"..is always a Mac!\"',
298 'first = \"a Mac..\"'])
301 substrs=['map has 4 items',
303 'second = \"hello\"',
306 'second = \"house\"',
312 'second = \"..is always a Mac!\"',
313 'first = \"a Mac..\"'])
315 # check access-by-index
316 self.expect("frame variable ss[3]",
317 substrs=['gatto', 'cat'])
319 # check that MightHaveChildren() gets it right
321 self.frame().FindVariable("ss").MightHaveChildren(),
322 "ss.MightHaveChildren() says False for non empty!")
324 # check that the expression parser does not make use of
325 # synthetic children instead of running code
326 # TOT clang has a fix for this, which makes the expression command here succeed
327 # since this would make the test fail or succeed depending on clang version in use
328 # this is safer commented for the time being
329 # self.expect("expression ss[3]", matching=False, error=True,
330 # substrs = ['gatto'])
334 self.expect('frame variable ss',
335 substrs=['map has 0 items',