[Lldb-commits] [PATCH] D77043: Fix process gdb-remote usage of value_regs/invalidate_regs

Muhammad Omair Javaid via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 17 17:17:39 PDT 2020


omjavaid updated this revision to Diff 271534.
omjavaid added a comment.

This patch is now independent of SVE register support and is only a requirement for the case of where remote stub utilizes xml register description and sends register nos which are not consecutively placed.

This patch ensures eRegisterKindProcessPlugin is used while referring to value_regs/invalidate_regs. This is needed because remote stubs may send target xml packets with stub specific register numbering scheme. Thus value_regs and invalidate_regs may have been populated based on a foreign register numbering scheme. We fix this by converting value_reg/invalidate_reg number to lldb register number before querying appropriate register info.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77043/new/

https://reviews.llvm.org/D77043

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp


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
@@ -242,11 +242,15 @@
       // Index of the primordial register.
       bool success = true;
       for (uint32_t idx = 0; success; ++idx) {
-        const uint32_t prim_reg = reg_info->value_regs[idx];
+        uint32_t prim_reg = reg_info->value_regs[idx];
         if (prim_reg == LLDB_INVALID_REGNUM)
           break;
         // We have a valid primordial register as our constituent. Grab the
         // corresponding register info.
+        uint32_t regnum = ConvertRegisterKindToRegisterNumber(
+            eRegisterKindProcessPlugin, prim_reg);
+        if (regnum != LLDB_INVALID_REGNUM)
+          prim_reg = regnum;
         const RegisterInfo *prim_reg_info = GetRegisterInfoAtIndex(prim_reg);
         if (prim_reg_info == nullptr)
           success = false;
@@ -375,11 +379,15 @@
           // Invalidate this composite register first.
 
           for (uint32_t idx = 0; success; ++idx) {
-            const uint32_t reg = reg_info->value_regs[idx];
+            uint32_t reg = reg_info->value_regs[idx];
             if (reg == LLDB_INVALID_REGNUM)
               break;
             // We have a valid primordial register as our constituent. Grab the
             // corresponding register info.
+            uint32_t lldb_regnum = ConvertRegisterKindToRegisterNumber(
+                eRegisterKindProcessPlugin, reg);
+            if (lldb_regnum != LLDB_INVALID_REGNUM)
+              reg = lldb_regnum;
             const RegisterInfo *value_reg_info = GetRegisterInfoAtIndex(reg);
             if (value_reg_info == nullptr)
               success = false;
@@ -397,6 +405,10 @@
           for (uint32_t idx = 0, reg = reg_info->invalidate_regs[0];
                reg != LLDB_INVALID_REGNUM;
                reg = reg_info->invalidate_regs[++idx]) {
+            uint32_t lldb_regnum = ConvertRegisterKindToRegisterNumber(
+                eRegisterKindProcessPlugin, reg);
+            if (lldb_regnum != LLDB_INVALID_REGNUM)
+              reg = lldb_regnum;
             SetRegisterIsValid(reg, false);
           }
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77043.271534.patch
Type: text/x-patch
Size: 2345 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200618/170de2c3/attachment-0001.bin>


More information about the lldb-commits mailing list