From 7b9e555de3e8d6611aa2d50ddbb91ebe77380022 Mon Sep 17 00:00:00 2001 From: Igor Kulaychuk Date: Tue, 18 Jul 2017 14:35:55 +0300 Subject: [PATCH] Fix steppers duplication when a breakpoint was hit during the step --- src/debug/netcoredbg/commands.cpp | 1 - src/debug/netcoredbg/main.cpp | 32 +++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/debug/netcoredbg/commands.cpp b/src/debug/netcoredbg/commands.cpp index 1d36e5f..20e4226 100644 --- a/src/debug/netcoredbg/commands.cpp +++ b/src/debug/netcoredbg/commands.cpp @@ -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) { diff --git a/src/debug/netcoredbg/main.cpp b/src/debug/netcoredbg/main.cpp index 196d80a..20513f1 100644 --- a/src/debug/netcoredbg/main.cpp +++ b/src/debug/netcoredbg/main.cpp @@ -164,6 +164,23 @@ std::string EscapeMIValue(const std::string &str) return s; } +static HRESULT DisableAllSteppersInAppDomain(ICorDebugAppDomain *pAppDomain) +{ + HRESULT Status; + ToRelease steppers; + IfFailRet(pAppDomain->EnumerateSteppers(&steppers)); + + ICorDebugStepper *curStepper; + ULONG steppersFetched; + while (SUCCEEDED(steppers->Next(1, &curStepper, &steppersFetched)) && steppersFetched == 1) + { + ToRelease 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 steppers; - if (SUCCEEDED(pAppDomain->EnumerateSteppers(&steppers))) - { - ICorDebugStepper *curStepper; - ULONG steppersFetched; - while (SUCCEEDED(steppers->Next(1, &curStepper, &steppersFetched)) && steppersFetched == 1) - { - ToRelease 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; } -- 2.7.4