diff --git a/lldb/include/lldb/Host/ProcessLaunchInfo.h b/lldb/include/lldb/Host/ProcessLaunchInfo.h --- a/lldb/include/lldb/Host/ProcessLaunchInfo.h +++ b/lldb/include/lldb/Host/ProcessLaunchInfo.h @@ -159,14 +159,12 @@ m_scripted_process_class_name = name; } - lldb_private::StructuredData::DictionarySP - GetScriptedProcessDictionarySP() const { - return m_scripted_process_dictionary_sp; + std::string GetScriptedProcessDictionary() const { + return m_scripted_process_dict; } - void SetScriptedProcessDictionarySP( - lldb_private::StructuredData::DictionarySP dictionary_sp) { - m_scripted_process_dictionary_sp = dictionary_sp; + void SetScriptedProcessDictionary(std::string dict) { + m_scripted_process_dict = dict; } protected: @@ -186,9 +184,9 @@ lldb::ListenerSP m_hijack_listener_sp; std::string m_scripted_process_class_name; // The name of the class that will // manage a scripted process. - StructuredData::DictionarySP - m_scripted_process_dictionary_sp; // A dictionary that holds key/value - // pairs passed to the scripted process. + std::string + m_scripted_process_dict; // A serialized dictionary that holds key/value + // pairs passed to the scripted process. }; } diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp --- a/lldb/source/API/SBLaunchInfo.cpp +++ b/lldb/source/API/SBLaunchInfo.cpp @@ -367,12 +367,9 @@ lldb::SBStructuredData SBLaunchInfo::GetScriptedProcessDictionary() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBStructuredData, SBLaunchInfo, GetScriptedProcessDictionary); - - lldb_private::StructuredData::DictionarySP dict_sp = - m_opaque_sp->GetScriptedProcessDictionarySP(); - SBStructuredData data; - data.m_impl_up->SetObjectSP(dict_sp); + data.m_impl_up->SetObjectSP( + StructuredData::ParseJSON(m_opaque_sp->GetScriptedProcessDictionary())); return LLDB_RECORD_RESULT(data); } @@ -387,11 +384,7 @@ if (error.Fail()) return; - StructuredData::DictionarySP dict_sp; - llvm::json::OStream s(stream.ref().AsRawOstream()); - dict_sp->Serialize(s); - - m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp); + m_opaque_sp->SetScriptedProcessDictionary(stream.GetData()); } namespace lldb_private { diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -190,8 +190,16 @@ m_options.launch_info.SetProcessPluginName("ScriptedProcess"); m_options.launch_info.SetScriptedProcessClassName( m_class_options.GetName()); - m_options.launch_info.SetScriptedProcessDictionarySP( - m_class_options.GetStructuredData()); + const StructuredData::DictionarySP dict_sp = + m_class_options.GetStructuredData(); + + if (dict_sp) { + StreamString stream; + llvm::json::OStream s(stream.AsRawOstream()); + dict_sp->Serialize(s); + m_options.launch_info.SetScriptedProcessDictionary(stream.GetData()); + } + target->SetProcessLaunchInfo(m_options.launch_info); } diff --git a/lldb/source/Host/common/ProcessLaunchInfo.cpp b/lldb/source/Host/common/ProcessLaunchInfo.cpp --- a/lldb/source/Host/common/ProcessLaunchInfo.cpp +++ b/lldb/source/Host/common/ProcessLaunchInfo.cpp @@ -32,7 +32,7 @@ : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0), m_file_actions(), m_pty(new PseudoTerminal), m_monitor_callback(nullptr), m_listener_sp(), m_hijack_listener_sp(), m_scripted_process_class_name(), - m_scripted_process_dictionary_sp() {} + m_scripted_process_dict() {} ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec, const FileSpec &stdout_file_spec, @@ -43,7 +43,7 @@ m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0), m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr), m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp(), - m_scripted_process_class_name(), m_scripted_process_dictionary_sp() { + m_scripted_process_class_name(), m_scripted_process_dict() { if (stdin_file_spec) { FileAction file_action; const bool read = true; @@ -173,7 +173,7 @@ m_listener_sp.reset(); m_hijack_listener_sp.reset(); m_scripted_process_class_name.clear(); - m_scripted_process_dictionary_sp.reset(); + m_scripted_process_dict.clear(); } void ProcessLaunchInfo::SetMonitorProcessCallback( diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h @@ -25,6 +25,8 @@ public: ScriptedProcessInfo(const ProcessLaunchInfo &launch_info) { m_class_name = launch_info.GetScriptedProcessClassName(); + m_args_sp = + StructuredData::ParseJSON(launch_info.GetScriptedProcessDictionary()); } std::string GetClassName() const { return m_class_name; } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2930,8 +2930,8 @@ default_launch_info.SetProcessPluginName("ScriptedProcess"); default_launch_info.SetScriptedProcessClassName( launch_info.GetScriptedProcessClassName()); - default_launch_info.SetScriptedProcessDictionarySP( - launch_info.GetScriptedProcessDictionarySP()); + default_launch_info.SetScriptedProcessDictionary( + launch_info.GetScriptedProcessDictionary()); SetProcessLaunchInfo(launch_info); }