mgorny updated this revision to Diff 369042.
mgorny retitled this revision from "[lldb] [DynamicRegisterInfo] Fix mistaken 
reg type when calculating offsets" to "[lldb] DynamicRegisterInfo: fix wrong 
regnos in Dump()".
mgorny edited the summary of this revision.
mgorny added a comment.

So I've given it some thought and found a simple fix.


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

https://reviews.llvm.org/D108768

Files:
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp


Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -775,7 +775,12 @@
     if (m_regs[i].value_regs) {
       s.Printf(", value_regs = [ ");
       for (size_t j = 0; m_regs[i].value_regs[j] != LLDB_INVALID_REGNUM; ++j) {
-        s.Printf("%s ", m_regs[m_regs[i].value_regs[j]].name);
+        const RegisterInfo *value_reg = GetRegisterInfo(
+            eRegisterKindProcessPlugin, m_regs[i].value_regs[j]);
+        if (value_reg)
+          s.Printf("%s ", value_reg->name);
+        else
+          s.Printf("(%d) ", m_regs[i].value_regs[j]);
       }
       s.Printf("]");
     }
@@ -783,7 +788,12 @@
       s.Printf(", invalidate_regs = [ ");
       for (size_t j = 0; m_regs[i].invalidate_regs[j] != LLDB_INVALID_REGNUM;
            ++j) {
-        s.Printf("%s ", m_regs[m_regs[i].invalidate_regs[j]].name);
+        const RegisterInfo *invalidate_reg = GetRegisterInfo(
+            eRegisterKindProcessPlugin, m_regs[i].invalidate_regs[j]);
+        if (invalidate_reg)
+          s.Printf("%s ", invalidate_reg->name);
+        else
+          s.Printf("(%d) ", m_regs[i].invalidate_regs[j]);
       }
       s.Printf("]");
     }


Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -775,7 +775,12 @@
     if (m_regs[i].value_regs) {
       s.Printf(", value_regs = [ ");
       for (size_t j = 0; m_regs[i].value_regs[j] != LLDB_INVALID_REGNUM; ++j) {
-        s.Printf("%s ", m_regs[m_regs[i].value_regs[j]].name);
+        const RegisterInfo *value_reg = GetRegisterInfo(
+            eRegisterKindProcessPlugin, m_regs[i].value_regs[j]);
+        if (value_reg)
+          s.Printf("%s ", value_reg->name);
+        else
+          s.Printf("(%d) ", m_regs[i].value_regs[j]);
       }
       s.Printf("]");
     }
@@ -783,7 +788,12 @@
       s.Printf(", invalidate_regs = [ ");
       for (size_t j = 0; m_regs[i].invalidate_regs[j] != LLDB_INVALID_REGNUM;
            ++j) {
-        s.Printf("%s ", m_regs[m_regs[i].invalidate_regs[j]].name);
+        const RegisterInfo *invalidate_reg = GetRegisterInfo(
+            eRegisterKindProcessPlugin, m_regs[i].invalidate_regs[j]);
+        if (invalidate_reg)
+          s.Printf("%s ", invalidate_reg->name);
+        else
+          s.Printf("(%d) ", m_regs[i].invalidate_regs[j]);
       }
       s.Printf("]");
     }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PAT... Michał Górny via Phabricator via lldb-commits

Reply via email to