[Lldb-commits] [PATCH] D110027: [lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sat Sep 18 13:49:27 PDT 2021
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
mgorny requested review of this revision.
Switch the gdb-remote client logic to use local (LLDB) register numbers
in value_regs/invalidate_regs rather than remote regnos. This involves
translating regnos received from lldb-server.
https://reviews.llvm.org/D110027
Files:
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
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
@@ -4680,10 +4680,29 @@
uint32_t local_regnum = 0;
uint32_t remote_regnum = 0;
+ std::map<uint32_t, uint32_t> remote_to_local_map;
for (RemoteRegisterInfo& remote_reg_info : registers) {
- // Use remote regnum if available, previous remote regnum + 1 when not.
- if (remote_reg_info.regnum_remote != LLDB_INVALID_REGNUM)
- remote_regnum = remote_reg_info.regnum_remote;
+ // Assign successive remote regnums if missing.
+ if (remote_reg_info.regnum_remote == LLDB_INVALID_REGNUM)
+ remote_reg_info.regnum_remote = remote_regnum;
+
+ // Create a mapping from remote to local regnos.
+ remote_to_local_map[remote_reg_info.regnum_remote] = local_regnum++;
+
+ remote_regnum = remote_reg_info.regnum_remote + 1;
+ }
+
+ local_regnum = 0;
+ for (RemoteRegisterInfo& remote_reg_info : registers) {
+ // Translate value_regs and invalidate_regs to local regnums
+ for (uint32_t &x : remote_reg_info.value_regs) {
+ if (x != LLDB_INVALID_REGNUM)
+ x = remote_to_local_map[x];
+ }
+ for (uint32_t &x : remote_reg_info.invalidate_regs) {
+ if (x != LLDB_INVALID_REGNUM)
+ x = remote_to_local_map[x];
+ }
struct RegisterInfo reg_info{
remote_reg_info.name.AsCString(),
@@ -4695,7 +4714,7 @@
{ remote_reg_info.regnum_ehframe,
remote_reg_info.regnum_dwarf,
remote_reg_info.regnum_generic,
- remote_regnum++,
+ remote_reg_info.regnum_remote,
local_regnum++ },
remote_reg_info.value_regs.data(),
remote_reg_info.invalidate_regs.data(),
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -254,7 +254,7 @@
// We have a valid primordial register as our constituent. Grab the
// corresponding register info.
const RegisterInfo *prim_reg_info =
- GetRegisterInfo(eRegisterKindProcessPlugin, prim_reg);
+ GetRegisterInfo(eRegisterKindLLDB, prim_reg);
if (prim_reg_info == nullptr)
success = false;
else {
@@ -401,7 +401,7 @@
// We have a valid primordial register as our constituent. Grab the
// corresponding register info.
const RegisterInfo *value_reg_info =
- GetRegisterInfo(eRegisterKindProcessPlugin, reg);
+ GetRegisterInfo(eRegisterKindLLDB, reg);
if (value_reg_info == nullptr)
success = false;
else
@@ -422,7 +422,7 @@
reg != LLDB_INVALID_REGNUM;
reg = reg_info->invalidate_regs[++idx])
SetRegisterIsValid(ConvertRegisterKindToRegisterNumber(
- eRegisterKindProcessPlugin, reg),
+ eRegisterKindLLDB, reg),
false);
}
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -655,9 +655,7 @@
if (reg.byte_offset == LLDB_INVALID_INDEX32) {
uint32_t value_regnum = reg.value_regs[0];
if (value_regnum != LLDB_INVALID_INDEX32)
- reg.byte_offset =
- GetRegisterInfoAtIndex(remote_to_local_regnum_map[value_regnum])
- ->byte_offset;
+ reg.byte_offset = GetRegisterInfoAtIndex(value_regnum)->byte_offset;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110027.373434.patch
Type: text/x-patch
Size: 4082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210918/9a19a6f5/attachment.bin>
More information about the lldb-commits
mailing list