1"""
2Test lldb data formatter subsystem.
3"""
4
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13class CompactVectorsFormattingTestCase(TestBase):
14
15    def setUp(self):
16        # Call super's setUp().
17        TestBase.setUp(self)
18        # Find the line number to break at.
19        self.line = line_number('main.cpp', '// Set break point at this line.')
20
21    @skipUnlessDarwin
22    def test_with_run_command(self):
23        """Test that that file and class static variables display correctly."""
24        self.build()
25        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
26
27        lldbutil.run_break_set_by_file_and_line(
28            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
29
30        self.runCmd("run", RUN_SUCCEEDED)
31
32        # The stop reason of the thread should be breakpoint.
33        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
34                    substrs=['stopped',
35                             'stop reason = breakpoint'])
36
37        # This is the function to remove the custom formats in order to have a
38        # clean slate for the next test case.
39        def cleanup():
40            self.runCmd('type summary clear', check=False)
41
42        # Execute the cleanup function during test case tear down.
43        self.addTearDownHook(cleanup)
44
45        self.expect(
46            'frame variable',
47            substrs=[
48                '(vFloat) valueFL = (1.25, 0, 0.25, 0)',
49                '(vDouble) valueDL = (1.25, 2.25)',
50                '(int16_t[8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)',
51                '(int32_t[4]) valueI32 = (1, 0, 4, 0)',
52                '(vUInt8) valueU8 = (0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)',
53                '(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)',
54                '(vUInt32) valueU32 = (1, 2, 3, 4)',
55                '(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)',
56                '(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)',
57                '(vSInt32) valueS32 = (4, 3, 2, 1)',
58                '(vBool32) valueBool32 = (0, 1, 0, 1)',
59            ])
60