Fix deltas apply in case process running.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Tue, 7 Jun 2022 14:53:16 +0000 (17:53 +0300)
committerAlexander Soldatov/Platform Lab /SRR/Staff Engineer/Samsung Electronics <soldatov.a@samsung.com>
Tue, 7 Jun 2022 14:54:41 +0000 (17:54 +0300)
src/debugger/manageddebugger.cpp

index cf7e1374c29204a945a77dd5f9e0193047165b26..1f802631da39ee99c15726e9d38c13112c35718a 100644 (file)
@@ -1332,10 +1332,20 @@ HRESULT ManagedDebugger::HotReloadApplyDeltas(const std::string &dllFileName, co
     if (!m_iCorProcess)
         return E_FAIL;
 
+    // Deltas can be applied only on stopped debuggee process. For Hot Reload scenario we temporary stop it and continue after deltas applied.
     HRESULT Status;
+    BOOL procRunning = FALSE;
+    IfFailRet(m_iCorProcess->IsRunning(&procRunning));
+    if (procRunning == TRUE)
+        IfFailRet(m_iCorProcess->Stop(0));
+
     IfFailRet(ApplyMetadataAndILDeltas(m_sharedModules.get(), dllFileName, deltaMD, deltaIL));
+    IfFailRet(ApplyPdbDelta(dllFileName, deltaPDB));
+
+    if (procRunning == TRUE)
+        IfFailRet(m_iCorProcess->Continue(0));
 
-    return ApplyPdbDelta(dllFileName, deltaPDB);
+    return S_OK;
 }
 
 } // namespace netcoredbg