brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · c8d0b09 Raw
88 lines · python
1"""2Test lldb data formatter subsystem.3"""4 5 6import lldb7from lldbsuite.test.lldbtest import *8import lldbsuite.test.lldbutil as lldbutil9 10 11class DataFormatterHexCapsTestCase(TestBase):12    def setUp(self):13        # Call super's setUp().14        TestBase.setUp(self)15        # Find the line number to break at.16        self.line = line_number("main.cpp", "// Set break point at this line.")17 18    def test_with_run_command(self):19        """Test that that file and class static variables display correctly."""20        self.build()21        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)22 23        lldbutil.run_break_set_by_file_and_line(24            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True25        )26 27        self.runCmd("run", RUN_SUCCEEDED)28 29        # The stop reason of the thread should be breakpoint.30        self.expect(31            "thread list",32            STOPPED_DUE_TO_BREAKPOINT,33            substrs=["stopped", "stop reason = breakpoint"],34        )35 36        # This is the function to remove the custom formats in order to have a37        # clean slate for the next test case.38        def cleanup():39            self.runCmd("type format delete hex", check=False)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.runCmd("type format add -f uppercase int")46 47        self.expect(48            "frame variable mine",49            substrs=["mine = ", "first = 0x001122AA", "second = 0x1122BB44"],50        )51 52        self.runCmd("type format add -f hex int")53 54        self.expect(55            "frame variable mine",56            substrs=["mine = ", "first = 0x001122aa", "second = 0x1122bb44"],57        )58 59        self.runCmd("type format delete int")60 61        self.runCmd('type summary add -s "${var.first%X} and ${var.second%x}" foo')62 63        self.expect(64            "frame variable mine", substrs=["(foo) mine = 0x001122AA and 0x1122bb44"]65        )66 67        self.runCmd('type summary add -s "${var.first%X} and ${var.second%X}" foo')68        self.runCmd("next")69        self.runCmd("next")70        self.expect(71            "frame variable mine", substrs=["(foo) mine = 0xAABBCCDD and 0x1122BB44"]72        )73 74        self.runCmd('type summary add -s "${var.first%x} and ${var.second%X}" foo')75        self.expect(76            "frame variable mine", substrs=["(foo) mine = 0xaabbccdd and 0x1122BB44"]77        )78        self.runCmd("next")79        self.runCmd("next")80        self.runCmd('type summary add -s "${var.first%x} and ${var.second%x}" foo')81        self.expect(82            "frame variable mine", substrs=["(foo) mine = 0xaabbccdd and 0xff00ff00"]83        )84        self.runCmd('type summary add -s "${var.first%X} and ${var.second%X}" foo')85        self.expect(86            "frame variable mine", substrs=["(foo) mine = 0xAABBCCDD and 0xFF00FF00"]87        )88