[Lldb-commits] [PATCH] D109695: [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 16 02:06:24 PDT 2021
mgorny updated this revision to Diff 372883.
mgorny retitled this revision from "[lldb] [Process/gdb-remote] Add x31 AArch64 register for gdbserver" to "[lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver".
mgorny edited the summary of this revision.
Herald added a subscriber: jeroen.dobbelaere.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109695/new/
https://reviews.llvm.org/D109695
Files:
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===================================================================
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@
["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",
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -581,8 +581,12 @@
// We have to make a temporary ABI here, and not use the GetABI because
// this code gets called in DidAttach, when the target architecture
// (and consequently the ABI we'll get from the process) may be wrong.
- if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use))
+ if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use)) {
abi_sp->AugmentRegisterInfo(reg_info);
+ // AugmentRegisterInfo() can modify alt_name
+ if (reg_info.alt_name)
+ alt_name.SetCString(reg_info.alt_name);
+ }
m_register_info_sp->AddRegister(reg_info, reg_name, alt_name, set_name);
} else {
@@ -4554,8 +4558,12 @@
reg_num_remote = reg_info.kinds[eRegisterKindProcessPlugin] + 1;
++reg_num_local;
reg_info.name = reg_name.AsCString();
- if (abi_sp)
+ if (abi_sp) {
abi_sp->AugmentRegisterInfo(reg_info);
+ // AugmentRegisterInfo() can modify alt_name
+ if (reg_info.alt_name)
+ alt_name.SetCString(reg_info.alt_name);
+ }
dyn_reg_info.AddRegister(reg_info, reg_name, alt_name, set_name);
return true; // Keep iterating through all "reg" elements
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
===================================================================
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -31,6 +31,8 @@
uint32_t GetGenericNum(llvm::StringRef name) override;
+ void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+
using lldb_private::MCBasedABI::MCBasedABI;
};
#endif
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===================================================================
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -52,6 +52,7 @@
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 @@
.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";
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109695.372883.patch
Type: text/x-patch
Size: 3681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210916/7d2a58c9/attachment.bin>
More information about the lldb-commits
mailing list