[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
Thu Sep 23 08:22:16 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6fbed33d4a7d: [lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs (authored by mgorny).
Herald added a project: LLDB.
Changed prior to commit:
https://reviews.llvm.org/D110027?vs=373814&id=374567#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110027/new/
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
@@ -4591,13 +4591,35 @@
// ABI is also potentially incorrect.
ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use);
+ std::map<uint32_t, uint32_t> remote_to_local_map;
uint32_t remote_regnum = 0;
+ for (auto it : llvm::enumerate(registers)) {
+ RemoteRegisterInfo &remote_reg_info = it.value();
+
+ // 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] = it.index();
+
+ remote_regnum = remote_reg_info.regnum_remote + 1;
+ }
+
for (auto it : llvm::enumerate(registers)) {
uint32_t local_regnum = it.index();
RemoteRegisterInfo &remote_reg_info = it.value();
- // 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;
+
+ auto proc_to_lldb = [&remote_to_local_map](uint32_t process_regnum) {
+ auto lldb_regit = remote_to_local_map.find(process_regnum);
+ return lldb_regit != remote_to_local_map.end() ? lldb_regit->second
+ : LLDB_INVALID_REGNUM;
+ };
+
+ llvm::transform(remote_reg_info.value_regs,
+ remote_reg_info.value_regs.begin(), proc_to_lldb);
+ llvm::transform(remote_reg_info.invalidate_regs,
+ remote_reg_info.invalidate_regs.begin(), proc_to_lldb);
auto regs_with_sentinel = [](std::vector<uint32_t> &vec) -> uint32_t * {
if (!vec.empty()) {
@@ -4612,7 +4634,8 @@
remote_reg_info.byte_size, remote_reg_info.byte_offset,
remote_reg_info.encoding, remote_reg_info.format,
{remote_reg_info.regnum_ehframe, remote_reg_info.regnum_dwarf,
- remote_reg_info.regnum_generic, remote_regnum++, local_regnum},
+ remote_reg_info.regnum_generic, remote_reg_info.regnum_remote,
+ local_regnum},
regs_with_sentinel(remote_reg_info.value_regs),
regs_with_sentinel(remote_reg_info.invalidate_regs),
!remote_reg_info.dwarf_opcode_bytes.empty()
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
@@ -253,7 +253,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 {
@@ -384,7 +384,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
@@ -405,7 +405,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
@@ -665,9 +665,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.374567.patch
Type: text/x-patch
Size: 4680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210923/38941c94/attachment.bin>
More information about the lldb-commits
mailing list