[Lldb-commits] [PATCH] D112045: [lldb/API] Fix SBLaunchInfo::SetScriptedProcessDictionary

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 18 18:12:50 PDT 2021


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.bennani at 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);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112045.380559.patch
Type: text/x-patch
Size: 1163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211019/725eba74/attachment.bin>


More information about the lldb-commits mailing list