[Lldb-commits] [PATCH] D55631: Delay replacing the process till after we've finalized it

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 17 17:52:26 PST 2018

This revision was automatically updated to reflect the committed changes.
Closed by commit rL349435: Call DeleteCurrentProcess before we replace the old process. (authored by jingham, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:





Index: lldb/trunk/source/Target/Target.cpp
--- lldb/trunk/source/Target/Target.cpp
+++ lldb/trunk/source/Target/Target.cpp
@@ -2864,22 +2864,15 @@
       log->Printf("Target::%s asking the platform to debug the process",
-    // Get a weak pointer to the previous process if we have one
-    ProcessWP process_wp;
-    if (m_process_sp)
-      process_wp = m_process_sp;
+    // If there was a previous process, delete it before we make the new one.
+    // One subtle point, we delete the process before we release the reference
+    // to m_process_sp.  That way even if we are the last owner, the process
+    // will get Finalized before it gets destroyed.
+    DeleteCurrentProcess();
     m_process_sp =
         GetPlatform()->DebugProcess(launch_info, debugger, this, error);
-    // Cleanup the old process since someone might still have a strong
-    // reference to this process and we would like to allow it to cleanup as
-    // much as it can without the object being destroyed. We try to lock the
-    // shared pointer and if that works, then someone else still has a strong
-    // reference to the process.
-    ProcessSP old_process_sp(process_wp.lock());
-    if (old_process_sp)
-      old_process_sp->Finalize();
   } else {
     if (log)
       log->Printf("Target::%s the platform doesn't know how to debug a "

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55631.178575.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20181218/78f3fc26/attachment.bin>

More information about the lldb-commits mailing list