mib created this revision.
mib added a reviewer: JDevlieghere.
mib added a project: LLDB.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

The previous implementation of `SBLaunchInfo::SetScriptedProcessDictionary`
didn't actually parse the SBStructuredData's JSON and set it into the
opaque_ptr `StructuredData::Dictionary`.

This patch fixes that.

Signed-off-by: Med Ismail Bennani <medismail.benn...@gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112045

Files:
  lldb/source/API/SBLaunchInfo.cpp


Index: lldb/source/API/SBLaunchInfo.cpp
===================================================================
--- lldb/source/API/SBLaunchInfo.cpp
+++ lldb/source/API/SBLaunchInfo.cpp
@@ -377,19 +377,25 @@
   return LLDB_RECORD_RESULT(data);
 }
 
-void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) {
+void SBLaunchInfo::SetScriptedProcessDictionary(
+    lldb::SBStructuredData sb_dict) {
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary,
-                     (lldb::SBStructuredData), dict);
+                     (lldb::SBStructuredData), sb_dict);
 
   SBStream stream;
-  SBError error = dict.GetAsJSON(stream);
+  SBError error = sb_dict.GetAsJSON(stream);
 
   if (error.Fail())
     return;
 
-  StructuredData::DictionarySP dict_sp;
-  llvm::json::OStream s(stream.ref().AsRawOstream());
-  dict_sp->Serialize(s);
+  StructuredData::ObjectSP obj_sp =
+      StructuredData::ParseJSON(std::string(stream.GetData()));
+  if (!obj_sp)
+    return;
+
+  StructuredData::DictionarySP dict_sp(obj_sp->GetAsDictionary());
+  if (!dict_sp)
+    return;
 
   m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp);
 }


Index: lldb/source/API/SBLaunchInfo.cpp
===================================================================
--- lldb/source/API/SBLaunchInfo.cpp
+++ lldb/source/API/SBLaunchInfo.cpp
@@ -377,19 +377,25 @@
   return LLDB_RECORD_RESULT(data);
 }
 
-void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) {
+void SBLaunchInfo::SetScriptedProcessDictionary(
+    lldb::SBStructuredData sb_dict) {
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary,
-                     (lldb::SBStructuredData), dict);
+                     (lldb::SBStructuredData), sb_dict);
 
   SBStream stream;
-  SBError error = dict.GetAsJSON(stream);
+  SBError error = sb_dict.GetAsJSON(stream);
 
   if (error.Fail())
     return;
 
-  StructuredData::DictionarySP dict_sp;
-  llvm::json::OStream s(stream.ref().AsRawOstream());
-  dict_sp->Serialize(s);
+  StructuredData::ObjectSP obj_sp =
+      StructuredData::ParseJSON(std::string(stream.GetData()));
+  if (!obj_sp)
+    return;
+
+  StructuredData::DictionarySP dict_sp(obj_sp->GetAsDictionary());
+  if (!dict_sp)
+    return;
 
   m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp);
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to