[Lldb-commits] [lldb] 47d5754 - [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver

Michał Górny via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 16 04:13:57 PDT 2021


Author: Michał Górny
Date: 2021-09-16T13:13:47+02:00
New Revision: 47d57547f43c6cf9404268b8a4c2f75c402615c2

URL: https://github.com/llvm/llvm-project/commit/47d57547f43c6cf9404268b8a4c2f75c402615c2
DIFF: https://github.com/llvm/llvm-project/commit/47d57547f43c6cf9404268b8a4c2f75c402615c2.diff

LOG: [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver

Alias the "sp" register to "x31" on AArch64 if one is present and does
not have the alt_name.  This is the case when connecting to gdbserver.

Differential Revision: https://reviews.llvm.org/D109695

Added: 
    

Modified: 
    lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
    lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
    lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 619c45dc12ec..66a38ab6e3e9 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -52,6 +52,7 @@ std::string ABIAArch64::GetMCName(std::string reg) {
   MapRegisterName(reg, "x30", "lr");
   return reg;
 }
+
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch<uint32_t>(name)
       .Case("pc", LLDB_REGNUM_GENERIC_PC)
@@ -69,3 +70,11 @@ uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
       .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
       .Default(LLDB_INVALID_REGNUM);
 }
+
+void ABIAArch64::AugmentRegisterInfo(lldb_private::RegisterInfo &info) {
+  lldb_private::MCBasedABI::AugmentRegisterInfo(info);
+
+  // GDB sends x31 as "sp".  Add the "x31" alt_name for convenience.
+  if (!strcmp(info.name, "sp") && !info.alt_name)
+    info.alt_name = "x31";
+}

diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
index 41bbf5cfdeb9..13dcfdd4c6d7 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -31,6 +31,8 @@ class ABIAArch64: public lldb_private::MCBasedABI {
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
+  void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+
   using lldb_private::MCBasedABI::MCBasedABI;
 };
 #endif

diff  --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 13d780428613..5d307fc1e3d4 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@ def haltReason(self):
                    ["x0 = 0x0807060504030201"])
         self.match("register read x1",
                    ["x1 = 0x1817161514131211"])
+        self.match("register read x29",
+                   ["x29 = 0x3837363534333231"])
+        self.match("register read x30",
+                   ["x30 = 0x4847464544434241"])
+        self.match("register read x31",
+                   ["sp = 0x5857565554535251"])
         self.match("register read sp",
                    ["sp = 0x5857565554535251"])
         self.match("register read pc",


        


More information about the lldb-commits mailing list