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 StdVBoolDataFormatterTestCase(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    @add_test_categories(["libstdcxx"])
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)
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 format clear', check=False)
41            self.runCmd('type summary clear', check=False)
42            self.runCmd('type filter clear', check=False)
43            self.runCmd('type synth clear', check=False)
44            self.runCmd(
45                "settings set target.max-children-count 256",
46                check=False)
47
48        # Execute the cleanup function during test case tear down.
49        self.addTearDownHook(cleanup)
50
51        self.expect(
52            "frame variable vBool",
53            substrs=[
54                'size=49',
55                '[0] = false',
56                '[1] = true',
57                '[18] = false',
58                '[27] = true',
59                '[36] = false',
60                '[47] = true',
61                '[48] = true'])
62
63        self.expect(
64            "expr vBool",
65            substrs=[
66                'size=49',
67                '[0] = false',
68                '[1] = true',
69                '[18] = false',
70                '[27] = true',
71                '[36] = false',
72                '[47] = true',
73                '[48] = true'])
74