[Lldb-commits] [PATCH] D19305: Use Process Plugin register indices when communicating with remote

Francis Ricci via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 19 18:06:26 PDT 2016


fjricci created this revision.
fjricci added reviewers: jasonmolenda, clayborg.
fjricci added subscribers: sas, lldb-commits.

eRegisterKindProcessPlugin is used to store the register
indices used by the remote, and eRegisterKindLLDB is used
to store the internal lldb register indices. However, we're currently
using the lldb indices instead of the process plugin indices
when sending p/P packets. This will break if the remote uses
non-contiguous register indices.

http://reviews.llvm.org/D19305

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

Index: source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -198,10 +198,11 @@
 GDBRemoteRegisterContext::GetPrimordialRegister(const RegisterInfo *reg_info,
                                                 GDBRemoteCommunicationClient &gdb_comm)
 {
-    const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+    const uint32_t lldb_reg = reg_info->kinds[eRegisterKindLLDB];
+    const uint32_t remote_reg = reg_info->kinds[eRegisterKindProcessPlugin];
     StringExtractorGDBRemote response;
-    if (gdb_comm.ReadRegister(m_thread.GetProtocolID(), reg, response))
-        return PrivateSetRegisterValue (reg, response);
+    if (gdb_comm.ReadRegister(m_thread.GetProtocolID(), remote_reg, response))
+        return PrivateSetRegisterValue (lldb_reg, response);
     return false;
 }
 
@@ -316,7 +317,7 @@
     StreamString packet;
     StringExtractorGDBRemote response;
     const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
-    packet.Printf ("P%x=", reg);
+    packet.Printf ("P%x=", reg_info->kinds[eRegisterKindProcessPlugin]);
     packet.PutBytesAsRawHex8 (m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size),
                               reg_info->byte_size,
                               endian::InlHostByteOrder(),
@@ -813,7 +814,7 @@
                             if (restore_src)
                             {
                                 StreamString packet;
-                                packet.Printf ("P%x=", reg);
+                                packet.Printf ("P%x=", reg_info->kinds[eRegisterKindProcessPlugin]);
                                 packet.PutBytesAsRawHex8 (restore_src,
                                                           reg_byte_size,
                                                           endian::InlHostByteOrder(),
@@ -836,7 +837,7 @@
                                 if (write_reg)
                                 {
                                     StreamString packet;
-                                    packet.Printf ("P%x=", reg);
+                                    packet.Printf ("P%x=", reg_info->kinds[eRegisterKindProcessPlugin]);
                                     packet.PutBytesAsRawHex8 (restore_src,
                                                               reg_byte_size,
                                                               endian::InlHostByteOrder(),
@@ -894,7 +895,7 @@
                         continue;
                     }
                     StreamString packet;
-                    packet.Printf ("P%x=", reg_info->kinds[eRegisterKindLLDB]);
+                    packet.Printf ("P%x=", reg_info->kinds[eRegisterKindProcessPlugin]);
                     packet.PutBytesAsRawHex8 (data_sp->GetBytes() + reg_info->byte_offset, reg_info->byte_size, endian::InlHostByteOrder(), endian::InlHostByteOrder());
                     if (thread_suffix_supported)
                         packet.Printf (";thread:%4.4" PRIx64 ";", m_thread.GetProtocolID());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19305.54303.patch
Type: text/x-patch
Size: 3202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160420/88b24559/attachment.bin>


More information about the lldb-commits mailing list