brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 7f8dc81 Raw
84 lines · python
1"""2Test lldb's ability to read and write the AArch64 FPMR register.3"""4 5import lldb6from lldbsuite.test.decorators import *7from lldbsuite.test.lldbtest import *8from lldbsuite.test import lldbutil9 10 11class AArch64LinuxFPMR(TestBase):12    NO_DEBUG_INFO_TESTCASE = True13 14    # The value set by the inferior.15    EXPECTED_FPMR = (0b101010 << 32) | 0b10116    EXPECTED_FPMR_FIELDS = ["LSCALE2 = 42", "F8S1 = FP8_E4M3 | 0x4"]17 18    @skipUnlessArch("aarch64")19    @skipUnlessPlatform(["linux"])20    def test_fpmr_register_live(self):21        if not self.isAArch64FPMR():22            self.skipTest("FPMR must be present.")23 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,29            "main.c",30            line_number("main.c", "// Set break point at this line."),31            num_expected_locations=1,32        )33 34        self.runCmd("run", RUN_SUCCEEDED)35 36        if self.process().GetState() == lldb.eStateExited:37            self.fail("Test program failed to run.")38 39        self.expect(40            "thread list",41            STOPPED_DUE_TO_BREAKPOINT,42            substrs=["stopped", "stop reason = breakpoint"],43        )44 45        # This has been set by the program.46        self.expect(47            "register read --all",48            substrs=[49                "Floating Point Mode Register",50                f"fpmr = {self.EXPECTED_FPMR:#018x}",51            ],52        )53 54        if self.hasXMLSupport():55            self.expect("register read fpmr", substrs=self.EXPECTED_FPMR_FIELDS)56 57        # Write a value for the program to find. Same fields but with bit values58        # inverted.59        new_fpmr = (0b010101 << 32) | 0b01060        self.runCmd(f"register write fpmr {new_fpmr:#x}")61 62        # This value should be saved and restored after expressions.63        self.runCmd("p expr_func()")64        self.expect("register read fpmr", substrs=[f"fpmr = {new_fpmr:#018x}"])65 66        # 0 means the program found the new value in the sysreg as expected.67        self.expect("continue", substrs=["exited with status = 0"])68 69    @skipIfLLVMTargetMissing("AArch64")70    def test_fpmr_register_core(self):71        if not self.isAArch64FPMR():72            self.skipTest("FPMR must be present.")73 74        self.runCmd("target create --core corefile")75 76        self.expect(77            "register read --all",78            substrs=[79                "Floating Point Mode Register",80                f"fpmr = {self.EXPECTED_FPMR:#018x}",81            ],82        )83        self.expect("register read fpmr", substrs=self.EXPECTED_FPMR_FIELDS)84