From: Michał Górny Date: Sat, 1 Oct 2022 16:59:28 +0000 (+0200) Subject: [lldb] [gdb-remote] Move ReadPacketWithOutputSupport() to client X-Git-Tag: upstream/17.0.6~31780 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6c24c161900a035f5ea7193f4816b6d192d6ac8;p=platform%2Fupstream%2Fllvm.git [lldb] [gdb-remote] Move ReadPacketWithOutputSupport() to client Move ReadPacketWithOutputSupport() from GDBRemoteCommunication to GDBRemoteClientBase. This function is client-specific and moving it there simplifies followup patches that split communication into separate thread. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D135028 --- diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp index ae85dbc..394b625 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp @@ -195,6 +195,23 @@ GDBRemoteClientBase::SendPacketAndWaitForResponse( } GDBRemoteCommunication::PacketResult +GDBRemoteClientBase::ReadPacketWithOutputSupport( + StringExtractorGDBRemote &response, Timeout timeout, + bool sync_on_timeout, + llvm::function_ref output_callback) { + auto result = ReadPacket(response, timeout, sync_on_timeout); + while (result == PacketResult::Success && response.IsNormalResponse() && + response.PeekChar() == 'O') { + response.GetChar(); + std::string output; + if (response.GetHexByteString(output)) + output_callback(output); + result = ReadPacket(response, timeout, sync_on_timeout); + } + return result; +} + +GDBRemoteCommunication::PacketResult GDBRemoteClientBase::SendPacketAndReceiveResponseWithOutputSupport( llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout, diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h index 4dd67a2..b47fee7 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h @@ -58,6 +58,11 @@ public: llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout = std::chrono::seconds(0)); + PacketResult ReadPacketWithOutputSupport( + StringExtractorGDBRemote &response, Timeout timeout, + bool sync_on_timeout, + llvm::function_ref output_callback); + PacketResult SendPacketAndReceiveResponseWithOutputSupport( llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout, diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index b67cd7e..7daf003 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -221,23 +221,6 @@ GDBRemoteCommunication::PacketResult GDBRemoteCommunication::GetAck() { } GDBRemoteCommunication::PacketResult -GDBRemoteCommunication::ReadPacketWithOutputSupport( - StringExtractorGDBRemote &response, Timeout timeout, - bool sync_on_timeout, - llvm::function_ref output_callback) { - auto result = ReadPacket(response, timeout, sync_on_timeout); - while (result == PacketResult::Success && response.IsNormalResponse() && - response.PeekChar() == 'O') { - response.GetChar(); - std::string output; - if (response.GetHexByteString(output)) - output_callback(output); - result = ReadPacket(response, timeout, sync_on_timeout); - } - return result; -} - -GDBRemoteCommunication::PacketResult GDBRemoteCommunication::ReadPacket(StringExtractorGDBRemote &response, Timeout timeout, bool sync_on_timeout) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index 9e17d6c..4e59bd5 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -190,11 +190,6 @@ protected: PacketResult ReadPacket(StringExtractorGDBRemote &response, Timeout timeout, bool sync_on_timeout); - PacketResult ReadPacketWithOutputSupport( - StringExtractorGDBRemote &response, Timeout timeout, - bool sync_on_timeout, - llvm::function_ref output_callback); - PacketResult WaitForPacketNoLock(StringExtractorGDBRemote &response, Timeout timeout, bool sync_on_timeout);