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 StdMapDataFormatterTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
18 # Call super's setUp().
20 # Find the line number to break at.
21 self.line = line_number('main.cpp', '// Set break point at this line.')
23 @add_test_categories(["libstdcxx"])
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 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)
53 self.runCmd("frame variable ii --show-types")
56 "type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e")
58 self.expect('frame variable ii',
59 substrs=['map has 0 items',
64 self.expect('frame variable ii',
65 substrs=['map has 2 items',
75 self.expect('frame variable ii',
76 substrs=['map has 4 items',
86 self.expect("frame variable ii",
87 substrs=['map has 9 items',
96 substrs=['map has 9 items',
104 # check access-by-index
105 self.expect("frame variable ii[0]",
106 substrs=['first = 0',
108 self.expect("frame variable ii[3]",
112 self.expect("frame variable ii[8]", matching=True,
115 # check that MightHaveChildren() gets it right
117 self.frame().FindVariable("ii").MightHaveChildren(),
118 "ii.MightHaveChildren() says False for non empty!")
120 # check that the expression parser does not make use of
121 # synthetic children instead of running code
122 # TOT clang has a fix for this, which makes the expression command here succeed
123 # since this would make the test fail or succeed depending on clang version in use
124 # this is safer commented for the time being
125 # self.expect("expression ii[8]", matching=False, error=True,
126 # substrs = ['1234567'])
130 self.expect('frame variable ii',
131 substrs=['map has 0 items',
134 self.runCmd("frame variable si --show-types")
136 self.expect('frame variable si',
137 substrs=['map has 0 items',
142 self.expect('frame variable si',
143 substrs=['map has 1 items',
150 self.expect("frame variable si",
151 substrs=['map has 5 items',
169 substrs=['map has 5 items',
186 # check access-by-index
187 self.expect("frame variable si[0]",
188 substrs=['first = ', 'four',
191 # check that MightHaveChildren() gets it right
193 self.frame().FindVariable("si").MightHaveChildren(),
194 "si.MightHaveChildren() says False for non empty!")
196 # check that the expression parser does not make use of
197 # synthetic children instead of running code
198 # TOT clang has a fix for this, which makes the expression command here succeed
199 # since this would make the test fail or succeed depending on clang version in use
200 # this is safer commented for the time being
201 # self.expect("expression si[0]", matching=False, error=True,
202 # substrs = ['first = ', 'zero'])
206 self.expect('frame variable si',
207 substrs=['map has 0 items',
210 self.runCmd("frame variable is --show-types")
212 self.expect('frame variable is',
213 substrs=['map has 0 items',
218 self.expect("frame variable is",
219 substrs=['map has 4 items',
221 'second = \"goofy\"',
227 'second = \"smart\"',
234 substrs=['map has 4 items',
236 'second = \"goofy\"',
242 'second = \"smart\"',
248 # check access-by-index
249 self.expect("frame variable is[0]",
253 # check that MightHaveChildren() gets it right
255 self.frame().FindVariable("is").MightHaveChildren(),
256 "is.MightHaveChildren() says False for non empty!")
258 # check that the expression parser does not make use of
259 # synthetic children instead of running code
260 # TOT clang has a fix for this, which makes the expression command here succeed
261 # since this would make the test fail or succeed depending on clang version in use
262 # this is safer commented for the time being
263 # self.expect("expression is[0]", matching=False, error=True,
264 # substrs = ['first = ', 'goofy'])
268 self.expect('frame variable is',
269 substrs=['map has 0 items',
272 self.runCmd("frame variable ss --show-types")
274 self.expect('frame variable ss',
275 substrs=['map has 0 items',
280 self.expect("frame variable ss",
281 substrs=['map has 4 items',
283 'second = \"hello\"',
286 'second = \"house\"',
292 'second = \"..is always a Mac!\"',
293 'first = \"a Mac..\"'])
296 substrs=['map has 4 items',
298 'second = \"hello\"',
301 'second = \"house\"',
307 'second = \"..is always a Mac!\"',
308 'first = \"a Mac..\"'])
310 # check access-by-index
311 self.expect("frame variable ss[3]",
312 substrs=['gatto', 'cat'])
314 # check that MightHaveChildren() gets it right
316 self.frame().FindVariable("ss").MightHaveChildren(),
317 "ss.MightHaveChildren() says False for non empty!")
319 # check that the expression parser does not make use of
320 # synthetic children instead of running code
321 # TOT clang has a fix for this, which makes the expression command here succeed
322 # since this would make the test fail or succeed depending on clang version in use
323 # this is safer commented for the time being
324 # self.expect("expression ss[3]", matching=False, error=True,
325 # substrs = ['gatto'])
329 self.expect('frame variable ss',
330 substrs=['map has 0 items',