diff options
author | Walter Erquinigo <werquinigo@nvidia.com> | 2025-09-18 10:40:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-18 10:40:55 -0400 |
commit | 4f72abd8404efa3de32188429d5f079ad12264e3 (patch) | |
tree | 4181488bf275a38b9e3ea7223aa70f0639052096 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | |
parent | 31e43e2fb8634f35a70699f636c49c9d2451e81c (diff) | |
download | llvm-4f72abd8404efa3de32188429d5f079ad12264e3.zip llvm-4f72abd8404efa3de32188429d5f079ad12264e3.tar.gz llvm-4f72abd8404efa3de32188429d5f079ad12264e3.tar.bz2 |
[LLDB] Add support for the structured data plugins in lldb-server (#159457)
The LLDB client has support for structured data plugins, but lldb-server
doesn't have corresponding support for it. This patch adds the missing
functionality in LLGS for servers to register their supported plugins
and send corresponding async messages.
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index e3202d6..2f62415 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -147,6 +147,9 @@ void GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers() { StringExtractorGDBRemote::eServerPacketType_QSetWorkingDir, &GDBRemoteCommunicationServerLLGS::Handle_QSetWorkingDir); RegisterMemberFunctionHandler( + StringExtractorGDBRemote::eServerPacketType_qStructuredDataPlugins, + &GDBRemoteCommunicationServerLLGS::Handle_qStructuredDataPlugins); + RegisterMemberFunctionHandler( StringExtractorGDBRemote::eServerPacketType_qsThreadInfo, &GDBRemoteCommunicationServerLLGS::Handle_qsThreadInfo); RegisterMemberFunctionHandler( @@ -1246,6 +1249,19 @@ Status GDBRemoteCommunicationServerLLGS::InitializeConnection( } GDBRemoteCommunication::PacketResult +GDBRemoteCommunicationServerLLGS::SendStructuredDataPacket( + const llvm::json::Value &value) { + std::string json_string; + raw_string_ostream os(json_string); + os << value; + + StreamGDBRemote escaped_response; + escaped_response.PutCString("JSON-async:"); + escaped_response.PutEscapedBytes(json_string.c_str(), json_string.size()); + return SendPacketNoLock(escaped_response.GetString()); +} + +GDBRemoteCommunication::PacketResult GDBRemoteCommunicationServerLLGS::SendONotification(const char *buffer, uint32_t len) { if ((buffer == nullptr) || (len == 0)) { @@ -1437,6 +1453,21 @@ GDBRemoteCommunicationServerLLGS::Handle_jLLDBTraceGetBinaryData( } GDBRemoteCommunication::PacketResult +GDBRemoteCommunicationServerLLGS::Handle_qStructuredDataPlugins( + StringExtractorGDBRemote &packet) { + // Fail if we don't have a current process. + if (!m_current_process || + (m_current_process->GetID() == LLDB_INVALID_PROCESS_ID)) + return SendErrorResponse(68); + + std::vector<std::string> structured_data_plugins = + m_current_process->GetStructuredDataPlugins(); + + return SendJSONResponse( + llvm::json::Value(llvm::json::Array(structured_data_plugins))); +} + +GDBRemoteCommunication::PacketResult GDBRemoteCommunicationServerLLGS::Handle_qProcessInfo( StringExtractorGDBRemote &packet) { // Fail if we don't have a current process. |