Index: lldb/examples/python/scripted_process/scripted_process.py =================================================================== --- lldb/examples/python/scripted_process/scripted_process.py +++ lldb/examples/python/scripted_process/scripted_process.py @@ -163,6 +163,14 @@ """ return lldb.SBError() + def attach(self): + """ Simulate the scripted process attach. + + Returns: + lldb.SBError: An `lldb.SBError` with error code 0. + """ + return lldb.SBError() + def resume(self): """ Simulate the scripted process resume. Index: lldb/include/lldb/Host/ProcessLaunchInfo.h =================================================================== --- lldb/include/lldb/Host/ProcessLaunchInfo.h +++ lldb/include/lldb/Host/ProcessLaunchInfo.h @@ -20,7 +20,6 @@ #include "lldb/Host/PseudoTerminal.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/ProcessInfo.h" -#include "lldb/Utility/StructuredData.h" namespace lldb_private { @@ -144,28 +143,6 @@ return m_flags.Test(lldb::eLaunchFlagDetachOnError); } - bool IsScriptedProcess() const { - return !m_scripted_process_class_name.empty(); - } - - std::string GetScriptedProcessClassName() const { - return m_scripted_process_class_name; - } - - void SetScriptedProcessClassName(std::string name) { - m_scripted_process_class_name = name; - } - - lldb_private::StructuredData::DictionarySP - GetScriptedProcessDictionarySP() const { - return m_scripted_process_dictionary_sp; - } - - void SetScriptedProcessDictionarySP( - lldb_private::StructuredData::DictionarySP dictionary_sp) { - m_scripted_process_dictionary_sp = dictionary_sp; - } - protected: FileSpec m_working_dir; std::string m_plugin_name; @@ -179,11 +156,6 @@ // meaning to the upper levels of lldb. lldb::ListenerSP m_listener_sp; 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. }; } Index: lldb/include/lldb/Interpreter/ScriptedMetadata.h =================================================================== --- lldb/include/lldb/Interpreter/ScriptedMetadata.h +++ lldb/include/lldb/Interpreter/ScriptedMetadata.h @@ -12,7 +12,7 @@ #include "OptionGroupPythonClassWithDict.h" #include "lldb/Host/Host.h" -#include "lldb/Host/ProcessLaunchInfo.h" +#include "lldb/Utility/ProcessInfo.h" #include "lldb/Utility/StructuredData.h" namespace lldb_private { @@ -22,9 +22,12 @@ StructuredData::DictionarySP dict_sp) : m_class_name(class_name.data()), m_args_sp(dict_sp) {} - ScriptedMetadata(const ProcessLaunchInfo &launch_info) { - m_class_name = launch_info.GetScriptedProcessClassName(); - m_args_sp = launch_info.GetScriptedProcessDictionarySP(); + ScriptedMetadata(const ProcessInfo &process_info) { + lldb::ScriptedMetadataSP metadata_sp = process_info.GetScriptedMetadata(); + if (metadata_sp) { + m_class_name = metadata_sp->GetClassName(); + m_args_sp = metadata_sp->GetArgsSP(); + } } ScriptedMetadata(const OptionGroupPythonClassWithDict &option_group) { @@ -33,6 +36,8 @@ m_args_sp = opt_group.GetStructuredData(); } + explicit operator bool() const { return !m_class_name.empty(); } + llvm::StringRef GetClassName() const { return m_class_name; } StructuredData::DictionarySP GetArgsSP() const { return m_args_sp; } Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h =================================================================== --- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h +++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h @@ -30,6 +30,8 @@ virtual StructuredData::DictionarySP GetCapabilities() { return {}; } + virtual Status Attach() { return Status("ScriptedProcess did not attach"); } + virtual Status Launch() { return Status("ScriptedProcess did not launch"); } virtual Status Resume() { return Status("ScriptedProcess did not resume"); } Index: lldb/include/lldb/Target/Process.h =================================================================== --- lldb/include/lldb/Target/Process.h +++ lldb/include/lldb/Target/Process.h @@ -192,28 +192,6 @@ lldb::ListenerSP GetListenerForProcess(Debugger &debugger); - bool IsScriptedProcess() const { - return !m_scripted_process_class_name.empty(); - } - - std::string GetScriptedProcessClassName() const { - return m_scripted_process_class_name; - } - - void SetScriptedProcessClassName(std::string name) { - m_scripted_process_class_name = name; - } - - lldb_private::StructuredData::DictionarySP - GetScriptedProcessDictionarySP() const { - return m_scripted_process_dictionary_sp; - } - - void SetScriptedProcessDictionarySP( - lldb_private::StructuredData::DictionarySP dictionary_sp) { - m_scripted_process_dictionary_sp = dictionary_sp; - } - protected: lldb::ListenerSP m_listener_sp; lldb::ListenerSP m_hijack_listener_sp; @@ -231,11 +209,6 @@ false; // Use an async attach where we start the attach and return // immediately (used by GUI programs with --waitfor so they can // call SBProcess::Stop() to cancel attach) - 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. }; // This class tracks the Modification state of the process. Things that can Index: lldb/include/lldb/Target/Target.h =================================================================== --- lldb/include/lldb/Target/Target.h +++ lldb/include/lldb/Target/Target.h @@ -1428,6 +1428,8 @@ return *m_frame_recognizer_manager_up; } + void SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info); + /// Add a signal for the target. This will get copied over to the process /// if the signal exists on that target. Only the values with Yes and No are /// set, Calculate values will be ignored. Index: lldb/include/lldb/Utility/ProcessInfo.h =================================================================== --- lldb/include/lldb/Utility/ProcessInfo.h +++ lldb/include/lldb/Utility/ProcessInfo.h @@ -14,6 +14,7 @@ #include "lldb/Utility/Environment.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/NameMatches.h" +#include "lldb/Utility/StructuredData.h" #include namespace lldb_private { @@ -86,6 +87,16 @@ Environment &GetEnvironment() { return m_environment; } const Environment &GetEnvironment() const { return m_environment; } + bool IsScriptedProcess() const; + + lldb::ScriptedMetadataSP GetScriptedMetadata() const { + return m_scripted_metadata_sp; + } + + void SetScriptedMetadata(lldb::ScriptedMetadataSP metadata_sp) { + m_scripted_metadata_sp = metadata_sp; + } + protected: FileSpec m_executable; std::string m_arg0; // argv[0] if supported. If empty, then use m_executable. @@ -97,6 +108,7 @@ uint32_t m_gid = UINT32_MAX; ArchSpec m_arch; lldb::pid_t m_pid = LLDB_INVALID_PROCESS_ID; + lldb::ScriptedMetadataSP m_scripted_metadata_sp = nullptr; }; // ProcessInstanceInfo Index: lldb/include/lldb/lldb-forward.h =================================================================== --- lldb/include/lldb/lldb-forward.h +++ lldb/include/lldb/lldb-forward.h @@ -181,6 +181,7 @@ class Scalar; class ScriptInterpreter; class ScriptInterpreterLocker; +class ScriptedMetadata; class ScriptedPlatformInterface; class ScriptedProcessInterface; class ScriptedThreadInterface; @@ -380,6 +381,7 @@ typedef std::shared_ptr ScriptSummaryFormatSP; typedef std::shared_ptr ScriptInterpreterSP; +typedef std::shared_ptr ScriptedMetadataSP; typedef std::unique_ptr ScriptedPlatformInterfaceUP; typedef std::unique_ptr Index: lldb/source/API/SBAttachInfo.cpp =================================================================== --- lldb/source/API/SBAttachInfo.cpp +++ lldb/source/API/SBAttachInfo.cpp @@ -11,6 +11,7 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBStructuredData.h" +#include "lldb/Interpreter/ScriptedMetadata.h" #include "lldb/Target/Process.h" #include "lldb/Utility/Instrumentation.h" @@ -256,25 +257,37 @@ const char *SBAttachInfo::GetScriptedProcessClassName() const { LLDB_INSTRUMENT_VA(this); + ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata(); + + if (!metadata_sp || !*metadata_sp) + return nullptr; + // Constify this string so that it is saved in the string pool. Otherwise it // would be freed when this function goes out of scope. - ConstString class_name(m_opaque_sp->GetScriptedProcessClassName().c_str()); + ConstString class_name(metadata_sp->GetClassName().data()); return class_name.AsCString(); } void SBAttachInfo::SetScriptedProcessClassName(const char *class_name) { LLDB_INSTRUMENT_VA(this, class_name); + ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata(); + + if (!metadata_sp) + metadata_sp = std::make_shared(class_name, nullptr); - m_opaque_sp->SetScriptedProcessClassName(class_name); + m_opaque_sp->SetScriptedMetadata(metadata_sp); } lldb::SBStructuredData SBAttachInfo::GetScriptedProcessDictionary() const { LLDB_INSTRUMENT_VA(this); - lldb_private::StructuredData::DictionarySP dict_sp = - m_opaque_sp->GetScriptedProcessDictionarySP(); + ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata(); SBStructuredData data; + if (!metadata_sp) + return data; + + lldb_private::StructuredData::DictionarySP dict_sp = metadata_sp->GetArgsSP(); data.m_impl_up->SetObjectSP(dict_sp); return data; @@ -295,5 +308,10 @@ if (!dict_sp || dict_sp->GetType() == lldb::eStructuredDataTypeInvalid) return; - m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp); + ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata(); + + if (!metadata_sp) + metadata_sp = std::make_shared("", dict_sp); + + m_opaque_sp->SetScriptedMetadata(metadata_sp); } Index: lldb/source/API/SBLaunchInfo.cpp =================================================================== --- lldb/source/API/SBLaunchInfo.cpp +++ lldb/source/API/SBLaunchInfo.cpp @@ -17,6 +17,7 @@ #include "lldb/API/SBStructuredData.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Host/ProcessLaunchInfo.h" +#include "lldb/Interpreter/ScriptedMetadata.h" using namespace lldb; using namespace lldb_private; @@ -331,25 +332,37 @@ const char *SBLaunchInfo::GetScriptedProcessClassName() const { LLDB_INSTRUMENT_VA(this); + ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata(); + + if (!metadata_sp || !*metadata_sp) + return nullptr; + // Constify this string so that it is saved in the string pool. Otherwise it // would be freed when this function goes out of scope. - ConstString class_name(m_opaque_sp->GetScriptedProcessClassName().c_str()); + ConstString class_name(metadata_sp->GetClassName().data()); return class_name.AsCString(); } void SBLaunchInfo::SetScriptedProcessClassName(const char *class_name) { LLDB_INSTRUMENT_VA(this, class_name); + ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata(); + + if (!metadata_sp) + metadata_sp = std::make_shared(class_name, nullptr); - m_opaque_sp->SetScriptedProcessClassName(class_name); + m_opaque_sp->SetScriptedMetadata(metadata_sp); } lldb::SBStructuredData SBLaunchInfo::GetScriptedProcessDictionary() const { LLDB_INSTRUMENT_VA(this); - lldb_private::StructuredData::DictionarySP dict_sp = - m_opaque_sp->GetScriptedProcessDictionarySP(); + ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata(); SBStructuredData data; + if (!metadata_sp) + return data; + + lldb_private::StructuredData::DictionarySP dict_sp = metadata_sp->GetArgsSP(); data.m_impl_up->SetObjectSP(dict_sp); return data; @@ -370,5 +383,10 @@ if (!dict_sp || dict_sp->GetType() == lldb::eStructuredDataTypeInvalid) return; - m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp); + ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata(); + + if (!metadata_sp) + metadata_sp = std::make_shared("", dict_sp); + + m_opaque_sp->SetScriptedMetadata(metadata_sp); } Index: lldb/source/API/SBTarget.cpp =================================================================== --- lldb/source/API/SBTarget.cpp +++ lldb/source/API/SBTarget.cpp @@ -434,7 +434,8 @@ if (target_sp) { ProcessAttachInfo &attach_info = sb_attach_info.ref(); - if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) { + if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid() && + !attach_info.IsScriptedProcess()) { PlatformSP platform_sp = target_sp->GetPlatform(); // See if we can pre-verify if a process exists or not if (platform_sp && platform_sp->IsConnected()) { Index: lldb/source/Commands/CommandObjectPlatform.cpp =================================================================== --- lldb/source/Commands/CommandObjectPlatform.cpp +++ lldb/source/Commands/CommandObjectPlatform.cpp @@ -1188,10 +1188,9 @@ if (!m_class_options.GetName().empty()) { m_options.launch_info.SetProcessPluginName("ScriptedProcess"); - m_options.launch_info.SetScriptedProcessClassName( - m_class_options.GetName()); - m_options.launch_info.SetScriptedProcessDictionarySP( - m_class_options.GetStructuredData()); + ScriptedMetadataSP metadata_sp = std::make_shared( + m_class_options.GetName(), m_class_options.GetStructuredData()); + m_options.launch_info.SetScriptedMetadata(metadata_sp); target->SetProcessLaunchInfo(m_options.launch_info); } @@ -1608,10 +1607,9 @@ if (!m_class_options.GetName().empty()) { m_options.attach_info.SetProcessPluginName("ScriptedProcess"); - m_options.attach_info.SetScriptedProcessClassName( - m_class_options.GetName()); - m_options.attach_info.SetScriptedProcessDictionarySP( - m_class_options.GetStructuredData()); + ScriptedMetadataSP metadata_sp = std::make_shared( + m_class_options.GetName(), m_class_options.GetStructuredData()); + m_options.attach_info.SetScriptedMetadata(metadata_sp); } Status err; Index: lldb/source/Commands/CommandObjectProcess.cpp =================================================================== --- lldb/source/Commands/CommandObjectProcess.cpp +++ lldb/source/Commands/CommandObjectProcess.cpp @@ -200,10 +200,9 @@ if (!m_class_options.GetName().empty()) { m_options.launch_info.SetProcessPluginName("ScriptedProcess"); - m_options.launch_info.SetScriptedProcessClassName( - m_class_options.GetName()); - m_options.launch_info.SetScriptedProcessDictionarySP( - m_class_options.GetStructuredData()); + ScriptedMetadataSP metadata_sp = std::make_shared( + m_class_options.GetName(), m_class_options.GetStructuredData()); + m_options.launch_info.SetScriptedMetadata(metadata_sp); target->SetProcessLaunchInfo(m_options.launch_info); } @@ -355,10 +354,9 @@ if (!m_class_options.GetName().empty()) { m_options.attach_info.SetProcessPluginName("ScriptedProcess"); - m_options.attach_info.SetScriptedProcessClassName( - m_class_options.GetName()); - m_options.attach_info.SetScriptedProcessDictionarySP( - m_class_options.GetStructuredData()); + ScriptedMetadataSP metadata_sp = std::make_shared( + m_class_options.GetName(), m_class_options.GetStructuredData()); + m_options.attach_info.SetScriptedMetadata(metadata_sp); } // Record the old executable module, we want to issue a warning if the Index: lldb/source/Host/common/ProcessLaunchInfo.cpp =================================================================== --- lldb/source/Host/common/ProcessLaunchInfo.cpp +++ lldb/source/Host/common/ProcessLaunchInfo.cpp @@ -32,8 +32,7 @@ ProcessLaunchInfo::ProcessLaunchInfo() : 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_listener_sp(), m_hijack_listener_sp() {} ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec, const FileSpec &stdout_file_spec, @@ -41,8 +40,7 @@ const FileSpec &working_directory, uint32_t launch_flags) : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(launch_flags), - m_file_actions(), m_pty(new PseudoTerminal), - m_scripted_process_class_name(), m_scripted_process_dictionary_sp() { + m_file_actions(), m_pty(new PseudoTerminal) { if (stdin_file_spec) { FileAction file_action; const bool read = true; @@ -171,8 +169,6 @@ m_resume_count = 0; m_listener_sp.reset(); m_hijack_listener_sp.reset(); - m_scripted_process_class_name.clear(); - m_scripted_process_dictionary_sp.reset(); } void ProcessLaunchInfo::NoOpMonitorCallback(lldb::pid_t pid, int signal, Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h =================================================================== --- lldb/source/Plugins/Process/scripted/ScriptedProcess.h +++ lldb/source/Plugins/Process/scripted/ScriptedProcess.h @@ -51,6 +51,15 @@ Status DoResume() override; + Status DoAttachToProcessWithID(lldb::pid_t pid, + const ProcessAttachInfo &attach_info) override; + + Status + DoAttachToProcessWithName(const char *process_name, + const ProcessAttachInfo &attach_info) override; + + void DidAttach(ArchSpec &process_arch) override; + Status DoDestroy() override; void RefreshStateAfterStop() override; @@ -90,6 +99,8 @@ Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override; + Status DoAttach(); + private: friend class ScriptedThread; Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp =================================================================== --- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp +++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp @@ -198,6 +198,36 @@ return error; } +Status ScriptedProcess::DoAttach() { + Status error = GetInterface().Attach(); + SetPrivateState(eStateRunning); + + if (error.Fail()) + return error; + + SetPrivateState(eStateStopped); + // NOTE: We need to set the PID before finishing to attach otherwise we will + // hit an assert when calling the attach completion handler. + DidLaunch(); + + return {}; +} + +Status +ScriptedProcess::DoAttachToProcessWithID(lldb::pid_t pid, + const ProcessAttachInfo &attach_info) { + return DoAttach(); +} + +Status ScriptedProcess::DoAttachToProcessWithName( + const char *process_name, const ProcessAttachInfo &attach_info) { + return DoAttach(); +} + +void ScriptedProcess::DidAttach(ArchSpec &process_arch) { + process_arch = GetArchitecture(); +} + Status ScriptedProcess::DoStop() { Log *log = GetLog(LLDBLog::Process); Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -31,6 +31,8 @@ StructuredData::DictionarySP GetCapabilities() override; + Status Attach() override; + Status Launch() override; Status Resume() override; Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -67,6 +67,10 @@ return dict; } +Status ScriptedProcessPythonInterface::Attach() { + return GetStatusFromMethod("attach"); +} + Status ScriptedProcessPythonInterface::Launch() { return GetStatusFromMethod("launch"); } Index: lldb/source/Target/Target.cpp =================================================================== --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -3080,6 +3080,17 @@ void Target::ClearAllLoadedSections() { m_section_load_history.Clear(); } +void Target::SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info) { + if (process_info.IsScriptedProcess()) { + // Only copy scripted process launch options. + ProcessLaunchInfo &default_launch_info = const_cast( + GetGlobalProperties().GetProcessLaunchInfo()); + default_launch_info.SetProcessPluginName("ScriptedProcess"); + default_launch_info.SetScriptedMetadata(process_info.GetScriptedMetadata()); + SetProcessLaunchInfo(default_launch_info); + } +} + Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) { m_stats.SetLaunchOrAttachTime(); Status error; @@ -3109,19 +3120,7 @@ launch_info.GetFlags().Set(eLaunchFlagDebug); - if (launch_info.IsScriptedProcess()) { - // Only copy scripted process launch options. - ProcessLaunchInfo &default_launch_info = const_cast( - GetGlobalProperties().GetProcessLaunchInfo()); - - default_launch_info.SetProcessPluginName("ScriptedProcess"); - default_launch_info.SetScriptedProcessClassName( - launch_info.GetScriptedProcessClassName()); - default_launch_info.SetScriptedProcessDictionarySP( - launch_info.GetScriptedProcessDictionarySP()); - - SetProcessLaunchInfo(launch_info); - } + SaveScriptedLaunchInfo(launch_info); // Get the value of synchronous execution here. If you wait till after you // have started to run, then you could have hit a breakpoint, whose command @@ -3334,11 +3333,12 @@ Status error; if (state != eStateConnected && platform_sp != nullptr && - platform_sp->CanDebugProcess()) { + platform_sp->CanDebugProcess() && !attach_info.IsScriptedProcess()) { SetPlatform(platform_sp); process_sp = platform_sp->Attach(attach_info, GetDebugger(), this, error); } else { if (state != eStateConnected) { + SaveScriptedLaunchInfo(attach_info); const char *plugin_name = attach_info.GetProcessPluginName(); process_sp = CreateProcess(attach_info.GetListenerForProcess(GetDebugger()), Index: lldb/source/Utility/ProcessInfo.cpp =================================================================== --- lldb/source/Utility/ProcessInfo.cpp +++ lldb/source/Utility/ProcessInfo.cpp @@ -8,6 +8,7 @@ #include "lldb/Utility/ProcessInfo.h" +#include "lldb/Interpreter/ScriptedMetadata.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" @@ -36,6 +37,7 @@ m_gid = UINT32_MAX; m_arch.Clear(); m_pid = LLDB_INVALID_PROCESS_ID; + m_scripted_metadata_sp.reset(); } const char *ProcessInfo::GetName() const { @@ -109,6 +111,10 @@ } } +bool ProcessInfo::IsScriptedProcess() const { + return m_scripted_metadata_sp && *m_scripted_metadata_sp; +} + void ProcessInstanceInfo::Dump(Stream &s, UserIDResolver &resolver) const { if (m_pid != LLDB_INVALID_PROCESS_ID) s.Printf(" pid = %" PRIu64 "\n", m_pid); Index: lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py =================================================================== --- lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py +++ lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py @@ -137,8 +137,14 @@ target_1 = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target_1, VALID_TARGET) + + # We still need to specify a PID when attaching even for scripted processes + attach_info = lldb.SBAttachInfo(42) + attach_info.SetProcessPluginName("ScriptedProcess") + attach_info.SetScriptedProcessClassName("dummy_scripted_process.DummyScriptedProcess") + error = lldb.SBError() - process_1 = target_1.Launch(launch_info, error) + process_1 = target_1.Attach(attach_info, error) self.assertTrue(process_1 and process_1.IsValid(), PROCESS_IS_VALID) self.assertEqual(process_1.GetProcessID(), 42) self.assertEqual(process_1.GetNumThreads(), 1)