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 PrintArrayTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
17 def test_print_array(self):
18 """Test that expr -Z works"""
20 self.printarray_data_formatter_commands()
23 # Call super's setUp().
25 # Find the line number to break at.
26 self.line = line_number('main.cpp', 'break here')
28 def printarray_data_formatter_commands(self):
29 """Test that expr -Z works"""
30 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
32 lldbutil.run_break_set_by_file_and_line(
33 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
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 synth clear', check=False)
49 # Execute the cleanup function during test case tear down.
50 self.addTearDownHook(cleanup)
53 'expr --element-count 3 -- data',
58 self.expect('expr data', substrs=['int *', '$', '0x'])
60 'expr -f binary --element-count 0 -- data',
66 'expr -f hex --element-count 3 -- data',
75 'expr -f binary --element-count 2 -- data',
84 self.expect('parray 3 data', substrs=['[0] = 1', '[1] = 3', '[2] = 5'])
86 'parray `1 + 1 + 1` data',
92 'parray `data[1]` data',
107 'parray/x `data[1]` data',
116 # check error conditions
118 'expr --element-count 10 -- 123',
120 substrs=['expression cannot be used with --element-count as it does not refer to a pointer'])
122 'expr --element-count 10 -- (void*)123',
124 substrs=['expression cannot be used with --element-count as it refers to a pointer to void'])
125 self.expect('parray data', error=True, substrs=[
126 "invalid element count 'data'"])
130 substrs=["invalid element count 'data'"])
131 self.expect('parray', error=True, substrs=[
132 'Not enough arguments provided'])