2 Test lldb data formatter subsystem.
5 from __future__ import print_function
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
17 class PrintArrayTestCase(TestBase):
19 mydir = TestBase.compute_mydir(__file__)
21 def test_print_array(self):
22 """Test that expr -Z works"""
24 self.printarray_data_formatter_commands()
27 # Call super's setUp().
29 # Find the line number to break at.
30 self.line = line_number('main.cpp', 'break here')
32 def printarray_data_formatter_commands(self):
33 """Test that expr -Z works"""
34 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
36 lldbutil.run_break_set_by_file_and_line(
37 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
39 self.runCmd("run", RUN_SUCCEEDED)
41 # The stop reason of the thread should be breakpoint.
42 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
44 'stop reason = breakpoint'])
46 # This is the function to remove the custom formats in order to have a
47 # clean slate for the next test case.
49 self.runCmd('type format clear', check=False)
50 self.runCmd('type summary clear', check=False)
51 self.runCmd('type synth clear', check=False)
53 # Execute the cleanup function during test case tear down.
54 self.addTearDownHook(cleanup)
57 'expr --element-count 3 -- data',
62 self.expect('expr data', substrs=['int *', '$', '0x'])
64 'expr -f binary --element-count 0 -- data',
70 'expr -f hex --element-count 3 -- data',
79 'expr -f binary --element-count 2 -- data',
88 self.expect('parray 3 data', substrs=['[0] = 1', '[1] = 3', '[2] = 5'])
90 'parray `1 + 1 + 1` data',
96 'parray `data[1]` data',
111 'parray/x `data[1]` data',
120 # check error conditions
122 'expr --element-count 10 -- 123',
124 substrs=['expression cannot be used with --element-count as it does not refer to a pointer'])
126 'expr --element-count 10 -- (void*)123',
128 substrs=['expression cannot be used with --element-count as it refers to a pointer to void'])
129 self.expect('parray data', error=True, substrs=[
130 "invalid element count 'data'"])
134 substrs=["invalid element count 'data'"])
135 self.expect('parray', error=True, substrs=[
136 'Not enough arguments provided'])