[Lldb-commits] [PATCH] D68301: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationClient
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 1 14:28:45 PDT 2019
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, vsk, jasonmolenda, clayborg.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
This patch replaces the LLDB's JSON implementation with the one from
LLVM in GDBRemoteCommunicationClient.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D68301
Files:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -23,7 +23,6 @@
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/JSON.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
@@ -35,14 +34,16 @@
#include "lldb/Utility/StringExtractorGDBRemote.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/JSON.h"
#if defined(HAVE_LIBCOMPRESSION)
#include <compression.h>
#endif
using namespace lldb;
-using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
+using namespace lldb_private;
+using namespace llvm;
using namespace std::chrono;
// GDBRemoteCommunicationClient constructor
@@ -3612,18 +3613,16 @@
if (!m_supports_jModulesInfo)
return llvm::None;
- JSONArray::SP module_array_sp = std::make_shared<JSONArray>();
+ json::Array module_array;
for (const FileSpec &module_file_spec : module_file_specs) {
- JSONObject::SP module_sp = std::make_shared<JSONObject>();
- module_array_sp->AppendObject(module_sp);
- module_sp->SetObject(
- "file", std::make_shared<JSONString>(module_file_spec.GetPath(false)));
- module_sp->SetObject("triple",
- std::make_shared<JSONString>(triple.getTriple()));
+ module_array.push_back(
+ json::Object{{"file", module_file_spec.GetPath(false)},
+ {"triple", triple.getTriple()}});
}
StreamString unescaped_payload;
unescaped_payload.PutCString("jModulesInfo:");
- module_array_sp->Write(unescaped_payload);
+ unescaped_payload.AsRawOstream() << std::move(module_array);
+
StreamGDBRemote payload;
payload.PutEscapedBytes(unescaped_payload.GetString().data(),
unescaped_payload.GetSize());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68301.222710.patch
Type: text/x-patch
Size: 2089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191001/5e0dd25d/attachment.bin>
More information about the lldb-commits
mailing list