Fix steppers duplication when a breakpoint was hit during the step
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Tue, 18 Jul 2017 11:35:55 +0000 (14:35 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 13 Nov 2017 19:22:40 +0000 (22:22 +0300)
src/debug/netcoredbg/commands.cpp
src/debug/netcoredbg/main.cpp

index 1d36e5f..20e4226 100644 (file)
@@ -51,7 +51,6 @@ HRESULT PrintBreakpoint(ULONG32 id, std::string &output);
 // Debug events
 int GetLastStoppedThreadId();
 void WaitProcessExited();
-HRESULT DisableAllBreakpointsAndSteppers(ICorDebugProcess *pProcess);
 
 static int ParseInt(const std::string &s, bool &ok)
 {
index 196d80a..20513f1 100644 (file)
@@ -164,6 +164,23 @@ std::string EscapeMIValue(const std::string &str)
     return s;
 }
 
+static HRESULT DisableAllSteppersInAppDomain(ICorDebugAppDomain *pAppDomain)
+{
+    HRESULT Status;
+    ToRelease<ICorDebugStepperEnum> steppers;
+    IfFailRet(pAppDomain->EnumerateSteppers(&steppers));
+
+    ICorDebugStepper *curStepper;
+    ULONG steppersFetched;
+    while (SUCCEEDED(steppers->Next(1, &curStepper, &steppersFetched)) && steppersFetched == 1)
+    {
+        ToRelease<ICorDebugStepper> pStepper(curStepper);
+        pStepper->Deactivate();
+    }
+
+    return S_OK;
+}
+
 static HRESULT DisableAllBreakpointsAndSteppersInAppDomain(ICorDebugAppDomain *pAppDomain)
 {
     HRESULT Status;
@@ -183,17 +200,7 @@ static HRESULT DisableAllBreakpointsAndSteppersInAppDomain(ICorDebugAppDomain *p
     // FIXME: Delete all or Release all?
     DeleteAllBreakpoints();
 
-    ToRelease<ICorDebugStepperEnum> steppers;
-    if (SUCCEEDED(pAppDomain->EnumerateSteppers(&steppers)))
-    {
-        ICorDebugStepper *curStepper;
-        ULONG steppersFetched;
-        while (SUCCEEDED(steppers->Next(1, &curStepper, &steppersFetched)) && steppersFetched == 1)
-        {
-            ToRelease<ICorDebugStepper> pStepper(curStepper);
-            pStepper->Deactivate();
-        }
-    }
+    DisableAllSteppersInAppDomain(pAppDomain);
 
     return S_OK;
 }
@@ -345,6 +352,9 @@ public:
 
             SetLastStoppedThread(pThread);
 
+            // If we do not ignore the breakpoint then remove any active steppers - we'll create a new one when needed
+            DisableAllSteppersInAppDomain(pAppDomain);
+
             return S_OK;
         }