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 StdListDataFormatterTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
18 # Call super's setUp().
20 # Find the line numbers to break at for the different tests.
21 self.line = line_number('main.cpp', '// Set break point at this line.')
22 self.optional_line = line_number(
23 'main.cpp', '// Optional break point at this line.')
24 self.final_line = line_number(
25 'main.cpp', '// Set final break point at this line.')
27 @add_test_categories(["libstdcxx"])
28 def test_with_run_command(self):
29 """Test that that file and class static variables display correctly."""
31 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
33 lldbutil.run_break_set_by_file_and_line(
34 self, "main.cpp", self.line, num_expected_locations=-1)
36 self.runCmd("run", RUN_SUCCEEDED)
38 # The stop reason of the thread should be breakpoint.
39 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
41 'stop reason = breakpoint'])
43 # This is the function to remove the custom formats in order to have a
44 # clean slate for the next test case.
46 self.runCmd('type format clear', check=False)
47 self.runCmd('type summary clear', check=False)
48 self.runCmd('type filter clear', check=False)
49 self.runCmd('type synth clear', check=False)
51 "settings set target.max-children-count 256",
54 # Execute the cleanup function during test case tear down.
55 self.addTearDownHook(cleanup)
57 self.runCmd("frame variable numbers_list --show-types")
59 self.runCmd("type format add -f hex int")
61 self.expect("frame variable numbers_list --raw", matching=False,
65 "frame variable &numbers_list._M_impl._M_node --raw",
71 self.expect("frame variable numbers_list",
75 self.expect("p numbers_list",
81 self.expect("frame variable numbers_list",
90 self.expect("frame variable numbers_list",
104 self.expect("frame variable numbers_list",
116 self.expect("p numbers_list",
128 # check access-by-index
129 self.expect("frame variable numbers_list[0]",
130 substrs=['0x12345678'])
131 self.expect("frame variable numbers_list[1]",
132 substrs=['0x11223344'])
134 # but check that expression does not rely on us
135 self.expect("expression numbers_list[0]", matching=False, error=True,
136 substrs=['0x12345678'])
138 # check that MightHaveChildren() gets it right
140 self.frame().FindVariable("numbers_list").MightHaveChildren(),
141 "numbers_list.MightHaveChildren() says False for non empty!")
145 self.expect("frame variable numbers_list",
154 self.expect("frame variable numbers_list",
161 self.runCmd("type format delete int")
165 self.expect("frame variable text_list",
169 lldbutil.run_break_set_by_file_and_line(
170 self, "main.cpp", self.final_line, num_expected_locations=-1)
172 self.runCmd("c", RUN_SUCCEEDED)
174 # The stop reason of the thread should be breakpoint.
175 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
177 'stop reason = breakpoint'])
179 self.expect("frame variable text_list",
186 self.expect("p text_list",
193 # check access-by-index
194 self.expect("frame variable text_list[0]",
196 self.expect("frame variable text_list[3]",
199 # but check that expression does not rely on us
200 self.expect("expression text_list[0]", matching=False, error=True,
203 # check that MightHaveChildren() gets it right
205 self.frame().FindVariable("text_list").MightHaveChildren(),
206 "text_list.MightHaveChildren() says False for non empty!")