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 StdListDataFormatterTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
19 # Call super's setUp().
21 # Find the line numbers to break at for the different tests.
22 self.line = line_number('main.cpp', '// Set break point at this line.')
23 self.optional_line = line_number('main.cpp', '// Optional break point at this line.')
24 self.final_line = line_number('main.cpp', '// Set final break point at this line.')
26 @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_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
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 numbers_list --show-types")
55 self.runCmd("type format add -f hex int")
57 self.expect("frame variable numbers_list --raw", matching=False,
60 self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False,
64 self.expect("frame variable numbers_list",
68 self.expect("p numbers_list",
74 self.expect("frame variable numbers_list",
79 self.runCmd("n");self.runCmd("n");self.runCmd("n");
81 self.expect("frame variable numbers_list",
92 self.runCmd("n");self.runCmd("n");
94 self.expect("frame variable numbers_list",
106 self.expect("p numbers_list",
118 # check access-by-index
119 self.expect("frame variable numbers_list[0]",
120 substrs = ['0x12345678']);
121 self.expect("frame variable numbers_list[1]",
122 substrs = ['0x11223344']);
124 # but check that expression does not rely on us
125 self.expect("expression numbers_list[0]", matching=False, error=True,
126 substrs = ['0x12345678'])
128 # check that MightHaveChildren() gets it right
129 self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!")
133 self.expect("frame variable numbers_list",
137 self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
139 self.expect("frame variable numbers_list",
146 self.runCmd("type format delete int")
150 self.expect("frame variable text_list",
154 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.final_line, num_expected_locations=-1)
156 self.runCmd("c", RUN_SUCCEEDED)
158 # The stop reason of the thread should be breakpoint.
159 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
160 substrs = ['stopped',
161 'stop reason = breakpoint'])
163 self.expect("frame variable text_list",
170 self.expect("p text_list",
177 # check access-by-index
178 self.expect("frame variable text_list[0]",
179 substrs = ['goofy']);
180 self.expect("frame variable text_list[3]",
183 # but check that expression does not rely on us
184 self.expect("expression text_list[0]", matching=False, error=True,
187 # check that MightHaveChildren() gets it right
188 self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!")