Author: Michał Górny Date: 2022-08-23T15:49:16+02:00 New Revision: 03b8f79048bfc32ade0404df3d3931266a06dc92
URL: https://github.com/llvm/llvm-project/commit/03b8f79048bfc32ade0404df3d3931266a06dc92 DIFF: https://github.com/llvm/llvm-project/commit/03b8f79048bfc32ade0404df3d3931266a06dc92.diff LOG: [lldb] [gdb-remote] Use Communication::WriteAll() over Write() Replace the uses of Communication::Write() with WriteAll() to avoid partial writes. None of the call sites actually accounted for that possibility and even if it is unlikely to actually happen, there doesn't seem to be any real harm from using WriteAll() instead. Ideally, we'd remove Write() from the public API. However, that would change the API of SBCommunication. The alternative would be to alias it to WriteAll(). Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D132395 Added: Modified: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 34753d5f8128a..bc9ccad29afb1 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -2441,7 +2441,7 @@ GDBRemoteCommunicationServerLLGS::Handle_I(StringExtractorGDBRemote &packet) { // remote host ConnectionStatus status; Status error; - m_stdio_communication.Write(tmp, read, status, &error); + m_stdio_communication.WriteAll(tmp, read, status, &error); if (error.Fail()) { return SendErrorResponse(0x15); } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index fbc7ab9180e77..37272d3afabd3 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2880,7 +2880,7 @@ size_t ProcessGDBRemote::PutSTDIN(const char *src, size_t src_len, Status &error) { if (m_stdio_communication.IsConnected()) { ConnectionStatus status; - m_stdio_communication.Write(src, src_len, status, nullptr); + m_stdio_communication.WriteAll(src, src_len, status, nullptr); } else if (m_stdin_forward) { m_gdb_comm.SendStdinNotification(src, src_len); } diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp index 4289a8393808f..7b17ec98a5cb4 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp @@ -39,7 +39,7 @@ class GDBRemoteCommunicationTest : public GDBRemoteTest { bool Write(llvm::StringRef packet) { ConnectionStatus status; - return server.Write(packet.data(), packet.size(), status, nullptr) == + return server.WriteAll(packet.data(), packet.size(), status, nullptr) == packet.size(); } }; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits