30
30
#include " lldb/Target/Platform.h"
31
31
#include " lldb/Utility/Endian.h"
32
32
#include " lldb/Utility/GDBRemote.h"
33
- #include " lldb/Utility/JSON.h"
34
33
#include " lldb/Utility/Log.h"
35
34
#include " lldb/Utility/StreamString.h"
36
35
#include " lldb/Utility/StructuredData.h"
36
+ #include " llvm/ADT/StringSwitch.h"
37
37
#include " llvm/ADT/Triple.h"
38
+ #include " llvm/Support/JSON.h"
38
39
39
40
#include " ProcessGDBRemoteLog.h"
40
41
#include " lldb/Utility/StringExtractorGDBRemote.h"
43
44
#include " lldb/Host/android/HostInfoAndroid.h"
44
45
#endif
45
46
46
- #include " llvm/ADT/StringSwitch.h"
47
47
48
48
using namespace lldb ;
49
- using namespace lldb_private ;
50
49
using namespace lldb_private ::process_gdb_remote;
50
+ using namespace lldb_private ;
51
51
52
52
#ifdef __ANDROID__
53
53
const static uint32_t g_default_packet_timeout_sec = 20 ; // seconds
@@ -1120,6 +1120,8 @@ GDBRemoteCommunicationServerCommon::Handle_qModuleInfo(
1120
1120
GDBRemoteCommunication::PacketResult
1121
1121
GDBRemoteCommunicationServerCommon::Handle_jModulesInfo (
1122
1122
StringExtractorGDBRemote &packet) {
1123
+ namespace json = llvm::json;
1124
+
1123
1125
packet.SetFilePos (::strlen (" jModulesInfo:" ));
1124
1126
1125
1127
StructuredData::ObjectSP object_sp = StructuredData::ParseJSON (packet.Peek ());
@@ -1130,7 +1132,7 @@ GDBRemoteCommunicationServerCommon::Handle_jModulesInfo(
1130
1132
if (!packet_array)
1131
1133
return SendErrorResponse (2 );
1132
1134
1133
- JSONArray::SP response_array_sp = std::make_shared<JSONArray>() ;
1135
+ json::Array response_array ;
1134
1136
for (size_t i = 0 ; i < packet_array->GetSize (); ++i) {
1135
1137
StructuredData::Dictionary *query =
1136
1138
packet_array->GetItemAtIndex (i)->GetAsDictionary ();
@@ -1148,27 +1150,22 @@ GDBRemoteCommunicationServerCommon::Handle_jModulesInfo(
1148
1150
const auto file_offset = matched_module_spec.GetObjectOffset ();
1149
1151
const auto file_size = matched_module_spec.GetObjectSize ();
1150
1152
const auto uuid_str = matched_module_spec.GetUUID ().GetAsString (" " );
1151
-
1152
1153
if (uuid_str.empty ())
1153
1154
continue ;
1154
-
1155
- JSONObject::SP response = std::make_shared<JSONObject>();
1156
- response_array_sp->AppendObject (response);
1157
- response->SetObject (" uuid" , std::make_shared<JSONString>(uuid_str));
1158
- response->SetObject (
1159
- " triple" ,
1160
- std::make_shared<JSONString>(
1161
- matched_module_spec.GetArchitecture ().GetTriple ().getTriple ()));
1162
- response->SetObject (" file_path" ,
1163
- std::make_shared<JSONString>(
1164
- matched_module_spec.GetFileSpec ().GetPath ()));
1165
- response->SetObject (" file_offset" ,
1166
- std::make_shared<JSONNumber>(file_offset));
1167
- response->SetObject (" file_size" , std::make_shared<JSONNumber>(file_size));
1155
+ const auto triple_str =
1156
+ matched_module_spec.GetArchitecture ().GetTriple ().getTriple ();
1157
+ const auto file_path = matched_module_spec.GetFileSpec ().GetPath ();
1158
+
1159
+ json::Object response{{" uuid" , uuid_str},
1160
+ {" triple" , triple_str},
1161
+ {" file_path" , file_path},
1162
+ {" file_offset" , static_cast <int64_t >(file_offset)},
1163
+ {" file_size" , static_cast <int64_t >(file_size)}};
1164
+ response_array.push_back (std::move (response));
1168
1165
}
1169
1166
1170
1167
StreamString response;
1171
- response_array_sp-> Write ( response);
1168
+ response. AsRawOstream () << std::move (response_array );
1172
1169
StreamGDBRemote escaped_response;
1173
1170
escaped_response.PutEscapedBytes (response.GetString ().data (),
1174
1171
response.GetSize ());
0 commit comments