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
15 class LibcxxMapDataFormatterTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
19 @skipIf(compiler="gcc")
20 @skipIfWindows # libc++ not ported to Windows yet
21 def test_with_run_command(self):
22 """Test that that file and class static variables display correctly."""
24 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
26 bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line."))
28 self.runCmd("run", RUN_SUCCEEDED)
30 lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
32 # The stop reason of the thread should be breakpoint.
33 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
35 'stop reason = breakpoint'])
37 # This is the function to remove the custom formats in order to have a
38 # clean slate for the next test case.
40 self.runCmd('type format clear', check=False)
41 self.runCmd('type summary clear', check=False)
42 self.runCmd('type filter clear', check=False)
43 self.runCmd('type synth clear', check=False)
44 self.runCmd("settings set target.max-children-count 256", check=False)
46 # Execute the cleanup function during test case tear down.
47 self.addTearDownHook(cleanup)
49 self.expect('image list', substrs = self.getLibcPlusPlusLibs())
51 self.expect('frame variable ii',
55 lldbutil.continue_to_breakpoint(self.process(), bkpt)
57 self.expect('frame variable ii',
66 lldbutil.continue_to_breakpoint(self.process(), bkpt)
68 self.expect('frame variable ii',
77 lldbutil.continue_to_breakpoint(self.process(), bkpt)
79 self.expect("frame variable ii",
97 # check access-by-index
98 self.expect("frame variable ii[0]",
99 substrs = ['first = 0',
101 self.expect("frame variable ii[3]",
102 substrs = ['first =',
105 # check that MightHaveChildren() gets it right
106 self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!")
108 # check that the expression parser does not make use of
109 # synthetic children instead of running code
110 # TOT clang has a fix for this, which makes the expression command here succeed
111 # since this would make the test fail or succeed depending on clang version in use
112 # this is safer commented for the time being
113 #self.expect("expression ii[8]", matching=False, error=True,
114 # substrs = ['1234567'])
116 self.runCmd("continue");
118 self.expect('frame variable ii',
122 self.expect('frame variable si',
126 self.runCmd("continue");
128 self.expect('frame variable si',
134 lldbutil.continue_to_breakpoint(self.process(), bkpt)
136 self.expect("frame variable si",
166 # check that MightHaveChildren() gets it right
167 self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!")
169 # check access-by-index
170 self.expect("frame variable si[0]",
171 substrs = ['first = ', 'one',
174 # check that the expression parser does not make use of
175 # synthetic children instead of running code
176 # TOT clang has a fix for this, which makes the expression command here succeed
177 # since this would make the test fail or succeed depending on clang version in use
178 # this is safer commented for the time being
179 #self.expect("expression si[0]", matching=False, error=True,
180 # substrs = ['first = ', 'zero'])
182 lldbutil.continue_to_breakpoint(self.process(), bkpt)
184 self.expect('frame variable si',
188 lldbutil.continue_to_breakpoint(self.process(), bkpt)
190 self.expect('frame variable is',
194 lldbutil.continue_to_breakpoint(self.process(), bkpt)
196 self.expect("frame variable is",
199 'second = \"goofy\"',
205 'second = \"smart\"',
214 'second = \"goofy\"',
220 'second = \"smart\"',
226 # check that MightHaveChildren() gets it right
227 self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!")
229 # check access-by-index
230 self.expect("frame variable is[0]",
231 substrs = ['first = ',
234 # check that the expression parser does not make use of
235 # synthetic children instead of running code
236 # TOT clang has a fix for this, which makes the expression command here succeed
237 # since this would make the test fail or succeed depending on clang version in use
238 # this is safer commented for the time being
239 #self.expect("expression is[0]", matching=False, error=True,
240 # substrs = ['first = ', 'goofy'])
242 lldbutil.continue_to_breakpoint(self.process(), bkpt)
244 self.expect('frame variable is',
248 lldbutil.continue_to_breakpoint(self.process(), bkpt)
250 self.expect('frame variable ss',
254 lldbutil.continue_to_breakpoint(self.process(), bkpt)
256 self.expect("frame variable ss",
259 'second = \"hello\"',
262 'second = \"house\"',
266 'first = \"gatto\"'])
271 'second = \"hello\"',
274 'second = \"house\"',
278 'first = \"gatto\"'])
280 # check that MightHaveChildren() gets it right
281 self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!")
283 # check access-by-index
284 self.expect("frame variable ss[2]",
285 substrs = ['gatto', 'cat']);
287 # check that the expression parser does not make use of
288 # synthetic children instead of running code
289 # TOT clang has a fix for this, which makes the expression command here succeed
290 # since this would make the test fail or succeed depending on clang version in use
291 # this is safer commented for the time being
292 #self.expect("expression ss[3]", matching=False, error=True,
293 # substrs = ['gatto'])
295 lldbutil.continue_to_breakpoint(self.process(), bkpt)
297 self.expect('frame variable ss',