[mlir][PDLL] Allow (and ignore) `-D` tablegen macros. (#124166)
[llvm-project.git] / lldb / test / API / linux / aarch64 / fpmr / TestAArch64LinuxFPMR.py
blob7f8dc811c5df367b7aa5ce1677cb914e1b525ff9
1 """
2 Test lldb's ability to read and write the AArch64 FPMR register.
3 """
5 import lldb
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.")
24 self.build()
25 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
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,
34 self.runCmd("run", RUN_SUCCEEDED)
36 if self.process().GetState() == lldb.eStateExited:
37 self.fail("Test program failed to run.")
39 self.expect(
40 "thread list",
41 STOPPED_DUE_TO_BREAKPOINT,
42 substrs=["stopped", "stop reason = breakpoint"],
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}",
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
58 # inverted.
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")
76 self.expect(
77 "register read --all",
78 substrs=[
79 "Floating Point Mode Register",
80 f"fpmr = {self.EXPECTED_FPMR:#018x}",
83 self.expect("register read fpmr", substrs=self.EXPECTED_FPMR_FIELDS)