[Lldb-commits] [PATCH] Fix -gdb-exit to detach if was attached or destroy otherwise (MI)

Ilia K ki.stfu at gmail.com
Thu Mar 12 10:23:17 PDT 2015


================
Comment at: tools/lldb-mi/MICmdCmdMiscellanous.cpp:87-91
@@ -86,3 +86,7 @@
     CMICmnLLDBDebugger::Instance().GetDriver().SetExitApplicationFlag(true);
-    const lldb::SBError sbErr = m_rLLDBDebugSessionInfo.GetProcess().Detach();
+    lldb::SBProcess sbProcess = m_rLLDBDebugSessionInfo.GetProcess();
+    if (!sbProcess.IsValid())
+        return MIstatus::success;
+
+    const lldb::SBError sbErr = sbProcess.GetShouldDetach() ? sbProcess.Detach() : sbProcess.Destroy();
     // Do not check for sbErr.Fail() here, m_lldbProcess is likely !IsValid()
----------------
clayborg wrote:
> Remove this and always call sbProcess.Destroy(). We will need to modify the internal plug-ins to "do the right thing" when destroy is called.
Please, look at Process::Finalize:
```
 823 void
 824 Process::Finalize()
 825 {
 826     switch (GetPrivateState())
 827     {
 828         case eStateConnected:
 829         case eStateAttaching:
 830         case eStateLaunching:
 831         case eStateStopped:
 832         case eStateRunning:
 833         case eStateStepping:
 834         case eStateCrashed:
 835         case eStateSuspended:
 836             if (GetShouldDetach())
 837             {
 838                 // FIXME: This will have to be a process setting:
 839                 bool keep_stopped = false;
 840                 Detach(keep_stopped);
 841             }
 842             else
 843                 Destroy();
 844             break;
 845 
 846         case eStateInvalid:
 847         case eStateUnloaded:
 848         case eStateDetached:
 849         case eStateExited:
 850             break;
 851     }
```
Seems that Destroy() should be called if not GetShouldDetach(). Right?

http://reviews.llvm.org/D8298

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the lldb-commits mailing list