mgorny updated this revision to Diff 373538.
mgorny marked 2 inline comments as done.
mgorny added a comment.
Rebase. Apply suggested changes.
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
@@ -4596,20 +4596,46 @@
// 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;
+
+ for (uint32_t &x : remote_reg_info.value_regs) {
+ std::map<uint32_t, uint32_t>::iterator x_lldb =
+ remote_to_local_map.find(x);
+ x = x_lldb != remote_to_local_map.end() ? x_lldb->second
+ : LLDB_INVALID_REGNUM;
+ }
+
+ for (uint32_t &x : remote_reg_info.invalidate_regs) {
+ std::map<uint32_t, uint32_t>::iterator x_lldb =
+ remote_to_local_map.find(x);
+ x = x_lldb != remote_to_local_map.end() ? x_lldb->second
+ : LLDB_INVALID_REGNUM;
+ }
struct RegisterInfo reg_info {
remote_reg_info.name.AsCString(), remote_reg_info.alt_name.AsCString(),
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},
remote_reg_info.value_regs.data(),
remote_reg_info.invalidate_regs.data(),
remote_reg_info.dwarf_opcode_bytes.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
@@ -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;
}
}
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits