aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
diff options
context:
space:
mode:
authorMichał Górny <mgorny@moritz.systems>2021-10-20 21:28:25 +0200
committerMichał Górny <mgorny@moritz.systems>2021-10-26 12:45:45 +0200
commitf279e50fd0f0035e0205f4d36e7e5a8e0112fc24 (patch)
tree6cd93ad536dd183d811710762b4e6ca60aee1313 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
parent9f8872779a8556d408e5fc88d4edd3eb50b2a24e (diff)
downloadllvm-f279e50fd0f0035e0205f4d36e7e5a8e0112fc24.zip
llvm-f279e50fd0f0035e0205f4d36e7e5a8e0112fc24.tar.gz
llvm-f279e50fd0f0035e0205f4d36e7e5a8e0112fc24.tar.bz2
[lldb] [Communication] Add a WriteAll() method that resumes writing
Add a Communication::WriteAll() that resumes Write() if the initial call did not write all data. Use it in GDBRemoteCommunication when sending packets in order to fix handling partial writes (i.e. just resume/retry them rather than erring out). This fixes LLDB failures when writing large packets to a pty. Differential Revision: https://reviews.llvm.org/D112169
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index adc8d6f..ae2141d 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -101,7 +101,7 @@ size_t GDBRemoteCommunication::SendAck() {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
ConnectionStatus status = eConnectionStatusSuccess;
char ch = '+';
- const size_t bytes_written = Write(&ch, 1, status, nullptr);
+ const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
return bytes_written;
@@ -111,7 +111,7 @@ size_t GDBRemoteCommunication::SendNack() {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
ConnectionStatus status = eConnectionStatusSuccess;
char ch = '-';
- const size_t bytes_written = Write(&ch, 1, status, nullptr);
+ const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
return bytes_written;
@@ -137,7 +137,7 @@ GDBRemoteCommunication::SendRawPacketNoLock(llvm::StringRef packet,
ConnectionStatus status = eConnectionStatusSuccess;
const char *packet_data = packet.data();
const size_t packet_length = packet.size();
- size_t bytes_written = Write(packet_data, packet_length, status, nullptr);
+ size_t bytes_written = WriteAll(packet_data, packet_length, status, nullptr);
if (log) {
size_t binary_start_offset = 0;
if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) ==