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 StdVectorDataFormatterTestCase(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 # empty vectors (and storage pointers SHOULD BOTH BE NULL..)
54 self.expect("frame variable numbers",
55 substrs=['numbers = size=0'])
60 self.expect("frame variable numbers",
61 substrs=['numbers = size=1',
68 self.expect("frame variable numbers",
69 substrs=['numbers = size=4',
76 self.expect("p numbers",
77 substrs=['$', 'size=4',
84 # check access to synthetic children
86 "type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect")
87 self.expect('frame variable numbers',
88 substrs=['item 0 is 1'])
91 "type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect")
94 self.expect('frame variable numbers',
95 substrs=['item 0 is 1'])
97 self.runCmd("type summary delete std::int_vect")
98 self.runCmd("type summary delete int_vect")
103 self.expect("frame variable numbers",
104 substrs=['numbers = size=7',
114 self.expect("p numbers",
115 substrs=['$', 'size=7',
125 # check access-by-index
126 self.expect("frame variable numbers[0]",
128 self.expect("frame variable numbers[1]",
130 self.expect("frame variable numbers[2]",
132 self.expect("frame variable numbers[3]",
135 # but check that expression does not rely on us
136 # (when expression gets to call into STL code correctly, we will have to find
137 # another way to check this)
138 self.expect("expression numbers[6]", matching=False, error=True,
141 # check that MightHaveChildren() gets it right
143 self.frame().FindVariable("numbers").MightHaveChildren(),
144 "numbers.MightHaveChildren() says False for non empty!")
146 # clear out the vector and see that we do the right thing once again
149 self.expect("frame variable numbers",
150 substrs=['numbers = size=0'])
155 self.expect("frame variable numbers",
156 substrs=['numbers = size=1',
160 # check if we can display strings
163 self.expect("frame variable strings",
168 self.expect("p strings",
173 # test summaries based on synthetic children
175 "type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e")
176 self.expect("frame variable strings",
177 substrs=['vector has 3 items',
182 self.expect("p strings",
183 substrs=['vector has 3 items',
190 self.expect("frame variable strings",
191 substrs=['vector has 4 items'])
193 # check access-by-index
194 self.expect("frame variable strings[0]",
196 self.expect("frame variable strings[1]",
199 # but check that expression does not rely on us
200 # (when expression gets to call into STL code correctly, we will have to find
201 # another way to check this)
202 self.expect("expression strings[0]", matching=False, error=True,
205 # check that MightHaveChildren() gets it right
207 self.frame().FindVariable("strings").MightHaveChildren(),
208 "strings.MightHaveChildren() says False for non empty!")
212 self.expect("frame variable strings",
213 substrs=['vector has 0 items'])