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
16 class SkipSummaryDataFormatterTestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
22 bugnumber="llvm.org/pr20548 fails to build on lab.llvm.org buildbot")
25 bugnumber="llvm.org/pr24462, Data formatters have problems on Windows")
26 def test_with_run_command(self):
27 """Test data formatter commands."""
29 self.data_formatter_commands()
32 # Call super's setUp().
34 # Find the line number to break at.
35 self.line = line_number('main.cpp', '// Set break point at this line.')
37 def data_formatter_commands(self):
38 """Test that that file and class static variables display correctly."""
39 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
41 #import lldbsuite.test.lldbutil as lldbutil
42 lldbutil.run_break_set_by_file_and_line(
43 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
45 self.runCmd("run", RUN_SUCCEEDED)
47 # The stop reason of the thread should be breakpoint.
48 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
50 'stop reason = breakpoint'])
52 # This is the function to remove the custom formats in order to have a
53 # clean slate for the next test case.
55 self.runCmd('type format clear', check=False)
56 self.runCmd('type summary clear', check=False)
58 # Execute the cleanup function during test case tear down.
59 self.addTearDownHook(cleanup)
61 # Setup the summaries for this scenario
62 #self.runCmd("type summary add --summary-string \"${var._M_dataplus._M_p}\" std::string")
64 "type summary add --summary-string \"Level 1\" \"DeepData_1\"")
66 "type summary add --summary-string \"Level 2\" \"DeepData_2\" -e")
68 "type summary add --summary-string \"Level 3\" \"DeepData_3\"")
70 "type summary add --summary-string \"Level 4\" \"DeepData_4\"")
72 "type summary add --summary-string \"Level 5\" \"DeepData_5\"")
74 # Default case, just print out summaries
75 self.expect('frame variable',
76 substrs=['(DeepData_1) data1 = Level 1',
77 '(DeepData_2) data2 = Level 2 {',
84 # Skip the default (should be 1) levels of summaries
85 self.expect('frame variable --no-summary-depth',
86 substrs=['(DeepData_1) data1 = {',
89 '(DeepData_2) data2 = {',
96 # Now skip 2 levels of summaries
97 self.expect('frame variable --no-summary-depth=2',
98 substrs=['(DeepData_1) data1 = {',
101 '(DeepData_2) data2 = {',
109 # Check that no "Level 3" comes out
111 'frame variable data1.m_child1 --no-summary-depth=2',
115 # Now expand a pointer with 2 level of skipped summaries
116 self.expect('frame variable data1.m_child1 --no-summary-depth=2',
117 substrs=['(DeepData_2 *) data1.m_child1 = 0x'])
119 # Deref and expand said pointer
120 self.expect('frame variable *data1.m_child1 --no-summary-depth=2',
121 substrs=['(DeepData_2) *data1.m_child1 = {',
127 # Expand an expression, skipping 2 layers of summaries
129 'frame variable data1.m_child1->m_child2 --no-summary-depth=2',
131 '(DeepData_3) data1.m_child1->m_child2 = {',
133 'm_child1 = Level 5',
134 'm_child2 = Level 5',
135 'm_child3 = Level 5',
138 # Expand same expression, skipping only 1 layer of summaries
140 'frame variable data1.m_child1->m_child2 --no-summary-depth=1',
142 '(DeepData_3) data1.m_child1->m_child2 = {',
145 'm_child2 = Level 4',
148 # Bad debugging info on SnowLeopard gcc (Apple Inc. build 5666).
149 # Skip the following tests if the condition is met.
150 if self.getCompiler().endswith('gcc') and not self.getCompiler().endswith('llvm-gcc'):
152 gcc_version_output = system(
153 [[lldbutil.which(self.getCompiler()), "-v"]])[1]
154 #print("my output:", gcc_version_output)
155 for line in gcc_version_output.split(os.linesep):
156 m = re.search('\(Apple Inc\. build ([0-9]+)\)', line)
157 #print("line:", line)
159 gcc_build = int(m.group(1))
160 #print("gcc build:", gcc_build)
161 if gcc_build >= 5666:
162 # rdar://problem/9804600"
164 "rdar://problem/9804600 wrong namespace for std::string in debug info")
166 # Expand same expression, skipping 3 layers of summaries
168 'frame variable data1.m_child1->m_child2 --show-types --no-summary-depth=3',
170 '(DeepData_3) data1.m_child1->m_child2 = {',
171 'm_some_text = "Just a test"',
173 'm_some_text = "Just a test"'])
175 # Expand within a standard string (might depend on the implementation
176 # of the C++ stdlib you use)
178 'frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=2',
180 '(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {',
182 '_M_dataplus = (_M_p = "Just a test")'])
184 # Repeat the above, but only skip 1 level of summaries
186 'frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=1',
188 '(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {',
189 'm_some_text = "Just a test"',
192 # Change summary and expand, first without --no-summary-depth then with
195 "type summary add --summary-string \"${var.m_some_text}\" DeepData_5")
197 self.expect('fr var data2.m_child4.m_child2.m_child2', substrs=[
198 '(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"'])
201 'fr var data2.m_child4.m_child2.m_child2 --no-summary-depth',
203 '(DeepData_5) data2.m_child4.m_child2.m_child2 = {',
204 'm_some_text = "Just a test"',