2 Test lldb data formatter subsystem.
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
12 class SkipSummaryDataFormatterTestCase(TestBase):
14 mydir = TestBase.compute_mydir(__file__)
18 bugnumber="llvm.org/pr20548 fails to build on lab.llvm.org buildbot")
21 bugnumber="llvm.org/pr24462, Data formatters have problems on Windows")
22 def test_with_run_command(self):
23 """Test data formatter commands."""
25 self.data_formatter_commands()
28 # Call super's setUp().
30 # Find the line number to break at.
31 self.line = line_number('main.cpp', '// Set break point at this line.')
33 def data_formatter_commands(self):
34 """Test that that file and class static variables display correctly."""
35 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
37 #import lldbsuite.test.lldbutil as lldbutil
38 lldbutil.run_break_set_by_file_and_line(
39 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
41 self.runCmd("run", RUN_SUCCEEDED)
43 # The stop reason of the thread should be breakpoint.
44 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
46 'stop reason = breakpoint'])
48 # This is the function to remove the custom formats in order to have a
49 # clean slate for the next test case.
51 self.runCmd('type format clear', check=False)
52 self.runCmd('type summary clear', check=False)
54 # Execute the cleanup function during test case tear down.
55 self.addTearDownHook(cleanup)
57 # Setup the summaries for this scenario
58 #self.runCmd("type summary add --summary-string \"${var._M_dataplus._M_p}\" std::string")
60 "type summary add --summary-string \"Level 1\" \"DeepData_1\"")
62 "type summary add --summary-string \"Level 2\" \"DeepData_2\" -e")
64 "type summary add --summary-string \"Level 3\" \"DeepData_3\"")
66 "type summary add --summary-string \"Level 4\" \"DeepData_4\"")
68 "type summary add --summary-string \"Level 5\" \"DeepData_5\"")
70 # Default case, just print out summaries
71 self.expect('frame variable',
72 substrs=['(DeepData_1) data1 = Level 1',
73 '(DeepData_2) data2 = Level 2 {',
80 # Skip the default (should be 1) levels of summaries
81 self.expect('frame variable --no-summary-depth',
82 substrs=['(DeepData_1) data1 = {',
85 '(DeepData_2) data2 = {',
92 # Now skip 2 levels of summaries
93 self.expect('frame variable --no-summary-depth=2',
94 substrs=['(DeepData_1) data1 = {',
97 '(DeepData_2) data2 = {',
105 # Check that no "Level 3" comes out
107 'frame variable data1.m_child1 --no-summary-depth=2',
111 # Now expand a pointer with 2 level of skipped summaries
112 self.expect('frame variable data1.m_child1 --no-summary-depth=2',
113 substrs=['(DeepData_2 *) data1.m_child1 = 0x'])
115 # Deref and expand said pointer
116 self.expect('frame variable *data1.m_child1 --no-summary-depth=2',
117 substrs=['(DeepData_2) *data1.m_child1 = {',
123 # Expand an expression, skipping 2 layers of summaries
125 'frame variable data1.m_child1->m_child2 --no-summary-depth=2',
127 '(DeepData_3) data1.m_child1->m_child2 = {',
129 'm_child1 = Level 5',
130 'm_child2 = Level 5',
131 'm_child3 = Level 5',
134 # Expand same expression, skipping only 1 layer of summaries
136 'frame variable data1.m_child1->m_child2 --no-summary-depth=1',
138 '(DeepData_3) data1.m_child1->m_child2 = {',
141 'm_child2 = Level 4',
144 # Bad debugging info on SnowLeopard gcc (Apple Inc. build 5666).
145 # Skip the following tests if the condition is met.
146 if self.getCompiler().endswith('gcc') and not self.getCompiler().endswith('llvm-gcc'):
148 gcc_version_output = system(
149 [[lldbutil.which(self.getCompiler()), "-v"]])[1]
150 #print("my output:", gcc_version_output)
151 for line in gcc_version_output.split(os.linesep):
152 m = re.search('\(Apple Inc\. build ([0-9]+)\)', line)
153 #print("line:", line)
155 gcc_build = int(m.group(1))
156 #print("gcc build:", gcc_build)
157 if gcc_build >= 5666:
158 # rdar://problem/9804600"
160 "rdar://problem/9804600 wrong namespace for std::string in debug info")
162 # Expand same expression, skipping 3 layers of summaries
164 'frame variable data1.m_child1->m_child2 --show-types --no-summary-depth=3',
166 '(DeepData_3) data1.m_child1->m_child2 = {',
167 'm_some_text = "Just a test"',
169 'm_some_text = "Just a test"'])
171 # Change summary and expand, first without --no-summary-depth then with
174 "type summary add --summary-string \"${var.m_some_text}\" DeepData_5")
176 self.expect('fr var data2.m_child4.m_child2.m_child2', substrs=[
177 '(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"'])
180 'fr var data2.m_child4.m_child2.m_child2 --no-summary-depth',
182 '(DeepData_5) data2.m_child4.m_child2.m_child2 = {',
183 'm_some_text = "Just a test"',