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
15 class StdListDataFormatterTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
20 # Call super's setUp().
22 # Find the line numbers to break at for the different tests.
23 self.line = line_number('main.cpp', '// Set break point at this line.')
24 self.optional_line = line_number('main.cpp', '// Optional break point at this line.')
25 self.final_line = line_number('main.cpp', '// Set final break point at this line.')
27 @skipIfWindows # libstdcpp not ported to Windows
28 def test_with_run_command(self):
29 """Test that that file and class static variables display correctly."""
31 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
33 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
35 self.runCmd("run", RUN_SUCCEEDED)
37 # The stop reason of the thread should be breakpoint.
38 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
40 'stop reason = breakpoint'])
42 # This is the function to remove the custom formats in order to have a
43 # clean slate for the next test case.
45 self.runCmd('type format clear', check=False)
46 self.runCmd('type summary clear', check=False)
47 self.runCmd('type filter clear', check=False)
48 self.runCmd('type synth clear', check=False)
49 self.runCmd("settings set target.max-children-count 256", check=False)
51 # Execute the cleanup function during test case tear down.
52 self.addTearDownHook(cleanup)
54 self.runCmd("frame variable numbers_list --show-types")
56 self.runCmd("type format add -f hex int")
58 self.expect("frame variable numbers_list --raw", matching=False,
61 self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False,
65 self.expect("frame variable numbers_list",
69 self.expect("p numbers_list",
75 self.expect("frame variable numbers_list",
80 self.runCmd("n");self.runCmd("n");self.runCmd("n");
82 self.expect("frame variable numbers_list",
93 self.runCmd("n");self.runCmd("n");
95 self.expect("frame variable numbers_list",
107 self.expect("p numbers_list",
119 # check access-by-index
120 self.expect("frame variable numbers_list[0]",
121 substrs = ['0x12345678']);
122 self.expect("frame variable numbers_list[1]",
123 substrs = ['0x11223344']);
125 # but check that expression does not rely on us
126 self.expect("expression numbers_list[0]", matching=False, error=True,
127 substrs = ['0x12345678'])
129 # check that MightHaveChildren() gets it right
130 self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!")
134 self.expect("frame variable numbers_list",
138 self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
140 self.expect("frame variable numbers_list",
147 self.runCmd("type format delete int")
151 self.expect("frame variable text_list",
155 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.final_line, num_expected_locations=-1)
157 self.runCmd("c", RUN_SUCCEEDED)
159 # The stop reason of the thread should be breakpoint.
160 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
161 substrs = ['stopped',
162 'stop reason = breakpoint'])
164 self.expect("frame variable text_list",
171 self.expect("p text_list",
178 # check access-by-index
179 self.expect("frame variable text_list[0]",
180 substrs = ['goofy']);
181 self.expect("frame variable text_list[3]",
184 # but check that expression does not rely on us
185 self.expect("expression text_list[0]", matching=False, error=True,
188 # check that MightHaveChildren() gets it right
189 self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!")