[lldb] [llvm] [LLDB][LoongArch] Add LSX and LASX register definitions and operations (PR #120664)

David Spickett via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 03:10:36 PST 2025


================
@@ -0,0 +1,66 @@
+"""
+Test lldb's ability to read and write the LoongArch LASX registers.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LoongArch64LinuxRegisters(TestBase):
+    NO_DEBUG_INFO_TESTCASE = True
+
+    def make_lasx_value(self, n):
+        return "{" + " ".join(["0x{:02x}".format(n)] * 32) + "}" 
+
+    def check_lasx_values(self, value_offset):
+        for i in range(32):
+            self.expect(
+                "register read xr{}".format(i),
+                substrs=[self.make_lasx_value(i + value_offset)],
+            )
+
+    def lasx_registers_impl(self):
+        self.build()
+        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+
+        lldbutil.run_break_set_by_file_and_line(
+            self,
+            "main.c",
+            line_number("main.c", "// Set break point at this line."),
+            num_expected_locations=1,
+        )
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        if self.process().GetState() == lldb.eStateExited:
+            self.fail("Test program failed to run.")
+
+        self.expect(
+            "thread list",
+            STOPPED_DUE_TO_BREAKPOINT,
+            substrs=["stopped", "stop reason = breakpoint"],
+        )
+
+        self.check_lasx_values(0)
+        self.runCmd("expression write_lasx_regs(2)")
----------------
DavidSpickett wrote:

If the tests you've written pass, which I assume they do, you'll have fixed this now.

It's very fiddly so don't be surprised this happened :) Got me several times in the past too. I'm working on something less brittle for AArch64 Linux, so hopefully we can share best practices at some point.

https://github.com/llvm/llvm-project/pull/120664


More information about the llvm-commits mailing list