summaryrefslogtreecommitdiff
path: root/lldb/examples
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2023-04-12 16:00:07 -0700
committerMed Ismail Bennani <medismail.bennani@gmail.com>2023-04-12 16:04:22 -0700
commit9cbdfcdb4cf75bdb4f7061276ff89929c2b157a1 (patch)
treee96245de4cfd2cb66edd52e25b79ce9092062dd8 /lldb/examples
parentfd2cafbdc480920bcf4eb598788a906ec1f63c41 (diff)
downloadllvm-9cbdfcdb4cf75bdb4f7061276ff89929c2b157a1.tar.gz
[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@gmail.com>
Diffstat (limited to 'lldb/examples')
-rw-r--r--lldb/examples/python/scripted_process/crashlog_scripted_process.py3
-rw-r--r--lldb/examples/python/scripted_process/scripted_process.py3
2 files changed, 2 insertions, 4 deletions
diff --git a/lldb/examples/python/scripted_process/crashlog_scripted_process.py b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
index b8c05717bb3a..236853e826c5 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 @@ class CrashLogScriptedProcess(ScriptedProcess):
# 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 044aee133880..e4d25214da76 100644
--- a/lldb/examples/python/scripted_process/scripted_process.py
+++ b/lldb/examples/python/scripted_process/scripted_process.py
@@ -47,6 +47,7 @@ class ScriptedProcess(metaclass=ABCMeta):
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 @@ class ScriptedProcess(metaclass=ABCMeta):
Returns:
int: The scripted process identifier.
"""
- return 0
+ return self.pid
def launch(self):
""" Simulate the scripted process launch.