2 Test lldb's ability to read and write the AArch64 FPMR register.
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import lldbutil
11 class AArch64LinuxFPMR(TestBase
):
12 NO_DEBUG_INFO_TESTCASE
= True
14 # The value set by the inferior.
15 EXPECTED_FPMR
= (0b101010 << 32) |
0b101
16 EXPECTED_FPMR_FIELDS
= ["LSCALE2 = 42", "F8S1 = FP8_E4M3 | 0x4"]
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.")
25 self
.runCmd("file " + self
.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET
)
27 lldbutil
.run_break_set_by_file_and_line(
30 line_number("main.c", "// Set break point at this line."),
31 num_expected_locations
=1,
34 self
.runCmd("run", RUN_SUCCEEDED
)
36 if self
.process().GetState() == lldb
.eStateExited
:
37 self
.fail("Test program failed to run.")
41 STOPPED_DUE_TO_BREAKPOINT
,
42 substrs
=["stopped", "stop reason = breakpoint"],
45 # This has been set by the program.
47 "register read --all",
49 "Floating Point Mode Register",
50 f
"fpmr = {self.EXPECTED_FPMR:#018x}",
54 if self
.hasXMLSupport():
55 self
.expect("register read fpmr", substrs
=self
.EXPECTED_FPMR_FIELDS
)
57 # Write a value for the program to find. Same fields but with bit values
59 new_fpmr
= (0b010101 << 32) |
0b010
60 self
.runCmd(f
"register write fpmr {new_fpmr:#x}")
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}"])
66 # 0 means the program found the new value in the sysreg as expected.
67 self
.expect("continue", substrs
=["exited with status = 0"])
69 @skipIfLLVMTargetMissing("AArch64")
70 def test_fpmr_register_core(self
):
71 if not self
.isAArch64FPMR():
72 self
.skipTest("FPMR must be present.")
74 self
.runCmd("target create --core corefile")
77 "register read --all",
79 "Floating Point Mode Register",
80 f
"fpmr = {self.EXPECTED_FPMR:#018x}",
83 self
.expect("register read fpmr", substrs
=self
.EXPECTED_FPMR_FIELDS
)