================
@@ -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)")
----------------
wangleiat wrote:

I'm not sure why this is happening, but these registers are indeed being 
modified on the LoongArch system. It's too late today, so I'll analyze the 
issue tomorrow.
```
Process 3442462 stopped                                                         
            
* thread #1, name = 'a.out', stop reason = breakpoint 1.1                       
            
    frame #0: 0x0000555555554784 a.out`main(argc=1, argv=0x00007ffffffef918) at 
lsx.c:13:10 
   10   }                                                                       
            
   11                                                                           
            
   12   int main(int argc, char *argv[]) {                                      
            
-> 13     return 0;                                                             
            
   14   }                                                                       
            
(lldb) register read vr0                                                        
            
     vr0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00}
(lldb) p write_lsx_regs(1)                                                      
            
(lldb) register read vr0                                                        
            
     vr0 = {0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 
0x01 0x01 0x01}
(lldb)                                                                          
            
```

https://github.com/llvm/llvm-project/pull/120664
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to