[Lldb-commits] [PATCH] D68304: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerCommon
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 1 14:42:41 PDT 2019
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, aprantl, vsk.
Herald added a project: LLDB.
This patch replaces the LLDB's JSON implementation with the one from
LLVM in GDBRemoteCommunicationServerCommon.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D68304
Files:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -30,11 +30,12 @@
#include "lldb/Target/Platform.h"
#include "lldb/Utility/Endian.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"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Support/JSON.h"
#include "ProcessGDBRemoteLog.h"
#include "lldb/Utility/StringExtractorGDBRemote.h"
@@ -43,11 +44,11 @@
#include "lldb/Host/android/HostInfoAndroid.h"
#endif
-#include "llvm/ADT/StringSwitch.h"
using namespace lldb;
-using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
+using namespace lldb_private;
+using namespace llvm;
#ifdef __ANDROID__
const static uint32_t g_default_packet_timeout_sec = 20; // seconds
@@ -1130,7 +1131,7 @@
if (!packet_array)
return SendErrorResponse(2);
- JSONArray::SP response_array_sp = std::make_shared<JSONArray>();
+ json::Array response_array;
for (size_t i = 0; i < packet_array->GetSize(); ++i) {
StructuredData::Dictionary *query =
packet_array->GetItemAtIndex(i)->GetAsDictionary();
@@ -1148,27 +1149,22 @@
const auto file_offset = matched_module_spec.GetObjectOffset();
const auto file_size = matched_module_spec.GetObjectSize();
const auto uuid_str = matched_module_spec.GetUUID().GetAsString("");
-
if (uuid_str.empty())
continue;
-
- JSONObject::SP response = std::make_shared<JSONObject>();
- response_array_sp->AppendObject(response);
- response->SetObject("uuid", std::make_shared<JSONString>(uuid_str));
- response->SetObject(
- "triple",
- std::make_shared<JSONString>(
- matched_module_spec.GetArchitecture().GetTriple().getTriple()));
- response->SetObject("file_path",
- std::make_shared<JSONString>(
- matched_module_spec.GetFileSpec().GetPath()));
- response->SetObject("file_offset",
- std::make_shared<JSONNumber>(file_offset));
- response->SetObject("file_size", std::make_shared<JSONNumber>(file_size));
+ const auto triple_str =
+ matched_module_spec.GetArchitecture().GetTriple().getTriple();
+ const auto file_path = matched_module_spec.GetFileSpec().GetPath();
+
+ json::Object response{{"uuid", uuid_str},
+ {"triple", triple_str},
+ {"file_path", file_path},
+ {"file_offset", static_cast<int64_t>(file_offset)},
+ {"file_size", static_cast<int64_t>(file_size)}};
+ response_array.push_back(std::move(response));
}
StreamString response;
- response_array_sp->Write(response);
+ response.AsRawOstream() << std::move(response_array);
StreamGDBRemote escaped_response;
escaped_response.PutEscapedBytes(response.GetString().data(),
response.GetSize());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68304.222715.patch
Type: text/x-patch
Size: 3286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191001/35932450/attachment.bin>
More information about the lldb-commits
mailing list