Fix terminated event
authorAlexander Aksenov <a.aksenov@samsung.com>
Mon, 18 Jun 2018 16:00:06 +0000 (19:00 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Mon, 18 Jun 2018 16:05:35 +0000 (19:05 +0300)
Issue:
When application is finished, VSCode still hangs like it is debugging the
process. That happens because VSCode doesn't emit Disconnect when Exit
message is received and Terminated is never sent.

Now it is sent:
- on Disconnect when application is supposed to be detached;
- on application finish, together with exit event.

Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
src/debug/netcoredbg/manageddebugger.cpp

index 6652cc9c4f3c514510e2a9bd14f36abc5f4c9cbc..0865ee7efd2281e5eaf07894ae726da8b6ad4a0f 100644 (file)
@@ -422,6 +422,7 @@ public:
             m_debugger.m_evaluator.NotifyEvalComplete(nullptr, nullptr);
             m_debugger.m_protocol->EmitExitedEvent(ExitedEvent(0));
             m_debugger.NotifyProcessExited();
+            m_debugger.m_protocol->EmitTerminatedEvent();
             return S_OK;
         }
 
@@ -718,13 +719,14 @@ HRESULT ManagedDebugger::Disconnect(DisconnectAction action)
     }
 
     if (!terminate)
-        return DetachFromProcess();
-
-    HRESULT Status = TerminateProcess();
-    if (SUCCEEDED(Status))
-        m_protocol->EmitTerminatedEvent();
+    {
+        HRESULT Status = DetachFromProcess();
+        if (SUCCEEDED(Status))
+            m_protocol->EmitTerminatedEvent();
+        return Status;
+    }
 
-    return Status;
+    return TerminateProcess();
 }
 
 HRESULT ManagedDebugger::SetupStep(ICorDebugThread *pThread, Debugger::StepType stepType)