2 Test lldb data formatter subsystem.
5 from __future__ import print_function
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
14 class StdMapDataFormatterTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
19 # Call super's setUp().
21 # Find the line number to break at.
22 self.line = line_number('main.cpp', '// Set break point at this line.')
24 @expectedFailureIcc # llvm.org/pr15301: LLDB prints incorrect size of libstdc++ containers
25 @skipIfWindows # libstdcpp not ported to Windows
27 def test_with_run_command(self):
28 """Test that that file and class static variables display correctly."""
30 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
32 lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")
34 self.runCmd("run", RUN_SUCCEEDED)
36 # The stop reason of the thread should be breakpoint.
37 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
39 'stop reason = breakpoint'])
41 # This is the function to remove the custom formats in order to have a
42 # clean slate for the next test case.
44 self.runCmd('type format clear', check=False)
45 self.runCmd('type summary clear', check=False)
46 self.runCmd('type filter clear', check=False)
47 self.runCmd('type synth clear', check=False)
48 self.runCmd("settings set target.max-children-count 256", check=False)
50 # Execute the cleanup function during test case tear down.
51 self.addTearDownHook(cleanup)
53 self.runCmd("frame variable ii --show-types")
55 self.runCmd("type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e")
57 self.expect('frame variable ii',
58 substrs = ['map has 0 items',
63 self.expect('frame variable ii',
64 substrs = ['map has 2 items',
74 self.expect('frame variable ii',
75 substrs = ['map has 4 items',
85 self.expect("frame variable ii",
86 substrs = ['map has 9 items',
95 substrs = ['map has 9 items',
103 # check access-by-index
104 self.expect("frame variable ii[0]",
105 substrs = ['first = 0',
107 self.expect("frame variable ii[3]",
108 substrs = ['first =',
111 self.expect("frame variable ii[8]", matching=True,
112 substrs = ['1234567'])
114 # check that MightHaveChildren() gets it right
115 self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!")
117 # check that the expression parser does not make use of
118 # synthetic children instead of running code
119 # TOT clang has a fix for this, which makes the expression command here succeed
120 # since this would make the test fail or succeed depending on clang version in use
121 # this is safer commented for the time being
122 #self.expect("expression ii[8]", matching=False, error=True,
123 # substrs = ['1234567'])
127 self.expect('frame variable ii',
128 substrs = ['map has 0 items',
131 self.runCmd("frame variable si --show-types")
133 self.expect('frame variable si',
134 substrs = ['map has 0 items',
139 self.expect('frame variable si',
140 substrs = ['map has 1 items',
147 self.expect("frame variable si",
148 substrs = ['map has 5 items',
166 substrs = ['map has 5 items',
183 # check access-by-index
184 self.expect("frame variable si[0]",
185 substrs = ['first = ', 'four',
188 # check that MightHaveChildren() gets it right
189 self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!")
191 # check that the expression parser does not make use of
192 # synthetic children instead of running code
193 # TOT clang has a fix for this, which makes the expression command here succeed
194 # since this would make the test fail or succeed depending on clang version in use
195 # this is safer commented for the time being
196 #self.expect("expression si[0]", matching=False, error=True,
197 # substrs = ['first = ', 'zero'])
201 self.expect('frame variable si',
202 substrs = ['map has 0 items',
205 self.runCmd("frame variable is --show-types")
207 self.expect('frame variable is',
208 substrs = ['map has 0 items',
213 self.expect("frame variable is",
214 substrs = ['map has 4 items',
216 'second = \"goofy\"',
222 'second = \"smart\"',
229 substrs = ['map has 4 items',
231 'second = \"goofy\"',
237 'second = \"smart\"',
243 # check access-by-index
244 self.expect("frame variable is[0]",
245 substrs = ['first = ',
248 # check that MightHaveChildren() gets it right
249 self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!")
251 # check that the expression parser does not make use of
252 # synthetic children instead of running code
253 # TOT clang has a fix for this, which makes the expression command here succeed
254 # since this would make the test fail or succeed depending on clang version in use
255 # this is safer commented for the time being
256 #self.expect("expression is[0]", matching=False, error=True,
257 # substrs = ['first = ', 'goofy'])
261 self.expect('frame variable is',
262 substrs = ['map has 0 items',
265 self.runCmd("frame variable ss --show-types")
267 self.expect('frame variable ss',
268 substrs = ['map has 0 items',
273 self.expect("frame variable ss",
274 substrs = ['map has 4 items',
276 'second = \"hello\"',
279 'second = \"house\"',
285 'second = \"..is always a Mac!\"',
286 'first = \"a Mac..\"'])
289 substrs = ['map has 4 items',
291 'second = \"hello\"',
294 'second = \"house\"',
300 'second = \"..is always a Mac!\"',
301 'first = \"a Mac..\"'])
303 # check access-by-index
304 self.expect("frame variable ss[3]",
305 substrs = ['gatto', 'cat']);
307 # check that MightHaveChildren() gets it right
308 self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!")
310 # check that the expression parser does not make use of
311 # synthetic children instead of running code
312 # TOT clang has a fix for this, which makes the expression command here succeed
313 # since this would make the test fail or succeed depending on clang version in use
314 # this is safer commented for the time being
315 #self.expect("expression ss[3]", matching=False, error=True,
316 # substrs = ['gatto'])
320 self.expect('frame variable ss',
321 substrs = ['map has 0 items',