aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Process
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-10-02 18:02:29 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-10-02 18:02:29 +0000
commit75f80cd66ddc72039673437799620d432c1eee19 (patch)
tree689ce7f88f8b651b78174b16390ad980a75e9db0 /source/Plugins/Process
parentf501edc3696b4b5d02c95d912def2f4bf5a8ea5d (diff)
downloadlldb-75f80cd66ddc72039673437799620d432c1eee19.tar.gz
[JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerPlatform
This patch replaces the LLDB's JSON implementation with the one from LLVM in GDBRemoteCommunicationServerPlatform. Differential revision: https://reviews.llvm.org/D68302 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Plugins/Process')
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index 83370bd2e..25cebbba8 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -18,6 +18,7 @@
#include <thread>
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/JSON.h"
#include "llvm/Support/Threading.h"
#include "lldb/Host/Config.h"
@@ -28,7 +29,6 @@
#include "lldb/Target/Platform.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/GDBRemote.h"
-#include "lldb/Utility/JSON.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StructuredData.h"
@@ -37,8 +37,8 @@
#include "lldb/Utility/StringExtractorGDBRemote.h"
using namespace lldb;
-using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
+using namespace lldb_private;
// GDBRemoteCommunicationServerPlatform constructor
GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(
@@ -215,22 +215,21 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer(
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerPlatform::Handle_qQueryGDBServer(
StringExtractorGDBRemote &packet) {
+ namespace json = llvm::json;
+
if (m_pending_gdb_server.pid == LLDB_INVALID_PROCESS_ID)
return SendErrorResponse(4);
- JSONObject::SP server_sp = std::make_shared<JSONObject>();
- server_sp->SetObject("port",
- std::make_shared<JSONNumber>(m_pending_gdb_server.port));
+ json::Object server{{"port", m_pending_gdb_server.port}};
+
if (!m_pending_gdb_server.socket_name.empty())
- server_sp->SetObject(
- "socket_name",
- std::make_shared<JSONString>(m_pending_gdb_server.socket_name.c_str()));
+ server.try_emplace("socket_name", m_pending_gdb_server.socket_name);
- JSONArray server_list;
- server_list.AppendObject(server_sp);
+ json::Array server_list;
+ server_list.push_back(std::move(server));
StreamGDBRemote response;
- server_list.Write(response);
+ response.AsRawOstream() << std::move(server_list);
StreamGDBRemote escaped_response;
escaped_response.PutEscapedBytes(response.GetString().data(),