[Lldb-commits] [PATCH] D148153: [lldb] Fix assertion when ScriptedProcess have no pid after launch

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 12 16:09:07 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9cbdfcdb4cf7: [lldb] Fix assertion when ScriptedProcess have no pid after launch (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148153/new/

https://reviews.llvm.org/D148153

Files:
  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


Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h
===================================================================
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ 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;
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===================================================================
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ 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();
 }
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
@@ -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.
Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===================================================================
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ 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
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148153.513004.patch
Type: text/x-patch
Size: 2220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230412/69fb432c/attachment-0001.bin>


More information about the lldb-commits mailing list