Use Process Plugin register indices when communicating with remote

Summary:
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.

Reviewers: jasonmolenda, clayborg

Subscribers: lldb-commits, sas

Differential Revision: http://reviews.llvm.org/D19305

llvm-svn: 267466
This commit is contained in:
Francis Ricci 2016-04-25 20:59:11 +00:00
parent abe2d016cf
commit 39f1189acb
2 changed files with 9 additions and 8 deletions

View File

@ -527,7 +527,7 @@ public:
bool bool
ReadRegister(lldb::tid_t tid, ReadRegister(lldb::tid_t tid,
uint32_t reg_num, uint32_t reg_num, // Must be the eRegisterKindProcessPlugin register number, to be sent to the remote
StringExtractorGDBRemote &response); StringExtractorGDBRemote &response);
bool bool

View File

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