[Lldb-commits] [lldb] 12504f5 - Revert "[lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs"

Michał Górny via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 23 09:17:14 PDT 2021


Author: Michał Górny
Date: 2021-09-23T18:17:09+02:00
New Revision: 12504f50729a338fb37c1c1863e7125b607e11d7

URL: https://github.com/llvm/llvm-project/commit/12504f50729a338fb37c1c1863e7125b607e11d7
DIFF: https://github.com/llvm/llvm-project/commit/12504f50729a338fb37c1c1863e7125b607e11d7.diff

LOG: Revert "[lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs"

This reverts commit 6fbed33d4a7de2229c40e6318f223092d3a23848.
The prerequisite commit is causing regressions.

Added: 
    

Modified: 
    lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
    lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
    lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index 721a03745c3ef..2755e5f93d5ad 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -665,7 +665,9 @@ void DynamicRegisterInfo::ConfigureOffsets() {
       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(value_regnum)->byte_offset;
+          reg.byte_offset =
+              GetRegisterInfoAtIndex(remote_to_local_regnum_map[value_regnum])
+                  ->byte_offset;
       }
     }
 

diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 92a5227a9a3a8..df5d052d2e33b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -253,7 +253,7 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const RegisterInfo *reg_info) {
         // We have a valid primordial register as our constituent. Grab the
         // corresponding register info.
         const RegisterInfo *prim_reg_info =
-            GetRegisterInfo(eRegisterKindLLDB, prim_reg);
+            GetRegisterInfo(eRegisterKindProcessPlugin, prim_reg);
         if (prim_reg_info == nullptr)
           success = false;
         else {
@@ -384,7 +384,7 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const RegisterInfo *reg_info,
             // We have a valid primordial register as our constituent. Grab the
             // corresponding register info.
             const RegisterInfo *value_reg_info =
-                GetRegisterInfo(eRegisterKindLLDB, reg);
+                GetRegisterInfo(eRegisterKindProcessPlugin, reg);
             if (value_reg_info == nullptr)
               success = false;
             else
@@ -405,7 +405,7 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const RegisterInfo *reg_info,
                reg != LLDB_INVALID_REGNUM;
                reg = reg_info->invalidate_regs[++idx])
             SetRegisterIsValid(ConvertRegisterKindToRegisterNumber(
-                                   eRegisterKindLLDB, reg),
+                                   eRegisterKindProcessPlugin, reg),
                                false);
         }
 

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index eec0c55e75bed..5b49c0c2c652a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4591,35 +4591,13 @@ void ProcessGDBRemote::AddRemoteRegisters(
   // 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();
-
-    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);
+    // 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 regs_with_sentinel = [](std::vector<uint32_t> &vec) -> uint32_t * {
       if (!vec.empty()) {
@@ -4634,8 +4612,7 @@ void ProcessGDBRemote::AddRemoteRegisters(
           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_reg_info.regnum_remote,
-           local_regnum},
+           remote_reg_info.regnum_generic, remote_regnum++, 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()


        


More information about the lldb-commits mailing list