Remove the last manually constructed packet from gdb-remote register context + small refactor
Summary:
The tricky part here was that the exisiting implementation of WriteAllRegisters was expecting
hex-encoded data (as that was what the first implementation I replaced was using, but here we had
binary data to begin with. I thought the read/write register functions would be more useful if
they handled the hex-encoding themselves (all the other client functions provide the responses in
a more-or-less digested form). The read functions return a DataBuffer, so they can allocate as
much memory as they need to, while the write functions functions take an llvm::ArrayRef, as that
can be constructed from pretty much anything.
Reviewers: clayborg
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D23659
llvm-svn: 279232
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index 54e7079..eeeecb5 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -10,6 +10,8 @@
#ifndef liblldb_GDBRemoteCommunicationClient_h_
#define liblldb_GDBRemoteCommunicationClient_h_
+#include "GDBRemoteClientBase.h"
+
// C Includes
// C++ Includes
#include <chrono>
@@ -24,8 +26,6 @@
#include "lldb/Core/StructuredData.h"
#include "lldb/Target/Process.h"
-#include "GDBRemoteClientBase.h"
-
namespace lldb_private {
namespace process_gdb_remote {
@@ -485,23 +485,20 @@
bool
CalculateMD5 (const FileSpec& file_spec, uint64_t &high, uint64_t &low);
-
- bool
+ lldb::DataBufferSP
ReadRegister(lldb::tid_t tid,
- uint32_t reg_num, // Must be the eRegisterKindProcessPlugin register number, to be sent to the remote
- StringExtractorGDBRemote &response);
+ uint32_t reg_num); // Must be the eRegisterKindProcessPlugin register number
- bool
- ReadAllRegisters (lldb::tid_t tid,
- StringExtractorGDBRemote &response);
+ lldb::DataBufferSP
+ ReadAllRegisters(lldb::tid_t tid);
bool
WriteRegister(lldb::tid_t tid, uint32_t reg_num, // eRegisterKindProcessPlugin register number
- llvm::StringRef data);
+ llvm::ArrayRef<uint8_t> data);
bool
- WriteAllRegisters(lldb::tid_t tid, llvm::StringRef data);
+ WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data);
bool
SaveRegisterState(lldb::tid_t tid, uint32_t &save_id);