[Lldb-commits] [lldb] 9cbdfcd - [lldb] Fix assertion when ScriptedProcess have no pid after launch
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 12 16:09:06 PDT 2023
Author: Med Ismail Bennani
Date: 2023-04-12T16:04:22-07:00
New Revision: 9cbdfcdb4cf75bdb4f7061276ff89929c2b157a1
URL: https://github.com/llvm/llvm-project/commit/9cbdfcdb4cf75bdb4f7061276ff89929c2b157a1
DIFF: https://github.com/llvm/llvm-project/commit/9cbdfcdb4cf75bdb4f7061276ff89929c2b157a1.diff
LOG: [lldb] Fix assertion when ScriptedProcess have no pid after launch
This patch should fix an assertion that causes some test failures:
https://ci.swift.org/view/LLDB/job/llvm-org-lldb-release-debuginfo/3587/console
This was caused by the changes introduces in `88f409194d5a` where we
replaced `DidLaunch` by `DidResume` in the `ScriptedProcess` class.
However, by the time we resume the process, the pid should be already
set. To address this, this patch brings back `DidLaunch` which will
initialize the ScriptedProcess pid with a placeholder value. That value
will be updated in `DidResume` to the final pid.
Note, this 2 stage PID initialization is necessary sometimes, when the
scripted process gets stopped at entry (launch) and gets assigned an
object that contains the PID value. In this case, we need to update the
PID when we resume the process after we've stopped at entry.
This also replaces the default scripted process id to an arbitrary
number (42) since the current value (0) is considered invalid.
Differential Revision: https://reviews.llvm.org/D148153
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Added:
Modified:
lldb/examples/python/scripted_process/crashlog_scripted_process.py
lldb/examples/python/scripted_process/scripted_process.py
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
Removed:
################################################################################
diff --git a/lldb/examples/python/scripted_process/crashlog_scripted_process.py b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
index b8c05717bb3a9..236853e826c56 100644
--- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -100,9 +100,6 @@ def get_loaded_images(self):
# 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
index 044aee1338808..e4d25214da766 100644
--- a/lldb/examples/python/scripted_process/scripted_process.py
+++ b/lldb/examples/python/scripted_process/scripted_process.py
@@ -47,6 +47,7 @@ def __init__(self, exe_ctx, args):
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 @@ def get_process_id(self):
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.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 999edd8f8db71..23ff8811e3fd7 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -168,7 +168,10 @@ Status ScriptedProcess::DoLaunch(Module *exe_module,
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();
}
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
index 856e05c901ed5..60f42cbaf7f2c 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -47,6 +47,8 @@ class ScriptedProcess : public Process {
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
+ void DidLaunch() override;
+
void DidResume() override;
Status DoResume() override;
More information about the lldb-commits
mailing list