diff --git a/lldb/examples/python/scripted_process/crashlog_scripted_process.py b/lldb/examples/python/scripted_process/crashlog_scripted_process.py --- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py +++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py @@ -100,9 +100,6 @@ # from it. return self.loaded_images - def get_process_id(self) -> int: - return self.pid - def should_stop(self) -> bool: return True diff --git a/lldb/examples/python/scripted_process/scripted_process.py b/lldb/examples/python/scripted_process/scripted_process.py --- a/lldb/examples/python/scripted_process/scripted_process.py +++ b/lldb/examples/python/scripted_process/scripted_process.py @@ -47,6 +47,7 @@ self.loaded_images = [] self.metadata = {} self.capabilities = {} + self.pid = 42 def get_capabilities(self): """ Get a dictionary containing the process capabilities. @@ -138,7 +139,7 @@ Returns: int: The scripted process identifier. """ - return 0 + return self.pid def launch(self): """ Simulate the scripted process launch. 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 @@ -47,6 +47,8 @@ Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override; + void DidLaunch() override; + void DidResume() override; Status DoResume() override; diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp @@ -168,7 +168,10 @@ return {}; } +void ScriptedProcess::DidLaunch() { m_pid = GetInterface().GetProcessID(); } + void ScriptedProcess::DidResume() { + // Update the PID again, in case the user provided a placeholder pid at launch m_pid = GetInterface().GetProcessID(); GetLoadedDynamicLibrariesInfos(); }