From: Kirill Frolov Date: Thu, 1 Oct 2020 12:04:03 +0000 (+0300) Subject: Fix a bug: no stop at Debugger.Break() call. X-Git-Tag: submit/tizen/20210120.035625~15^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=704bbb483e60143f84d5231b81e59d53ff60c95e;p=sdk%2Ftools%2Fnetcoredbg.git Fix a bug: no stop at Debugger.Break() call. This commit fixes issue #264. It is expected, if the program running under debuggers control, call to System.Diagnostics.Debugger.Break() should stop the program (as if the breakpoint is set). --- diff --git a/src/debug/netcoredbg/cliprotocol.cpp b/src/debug/netcoredbg/cliprotocol.cpp index e42b20d..80132ee 100644 --- a/src/debug/netcoredbg/cliprotocol.cpp +++ b/src/debug/netcoredbg/cliprotocol.cpp @@ -287,6 +287,12 @@ void CLIProtocol::EmitStoppedEvent(StoppedEvent event) int(event.threadId), frameLocation.c_str()); break; } + case StopBreak: + { + printf("\nstopped, reason: Debugger.Break, thread id: %i, stopped threads: all, frame={%s\n}\n", + int(event.threadId), frameLocation.c_str()); + break; + } default: return; } diff --git a/src/debug/netcoredbg/manageddebugger.cpp b/src/debug/netcoredbg/manageddebugger.cpp index 402a6f0..2473fb2 100644 --- a/src/debug/netcoredbg/manageddebugger.cpp +++ b/src/debug/netcoredbg/manageddebugger.cpp @@ -596,7 +596,22 @@ public: /* [in] */ ICorDebugThread *thread) { LogFuncEntry(); - return E_NOTIMPL; + ThreadId threadId(getThreadId(thread)); + + m_debugger.SetLastStoppedThread(thread); + + StoppedEvent event(StopBreak, threadId); + + ToRelease pFrame; + if (SUCCEEDED(thread->GetActiveFrame(&pFrame)) && pFrame != nullptr) + { + StackFrame stackFrame; + if (m_debugger.GetFrameLocation(pFrame, threadId, FrameLevel{0}, stackFrame) == S_OK) + event.frame = stackFrame; + } + + m_debugger.m_protocol->EmitStoppedEvent(event); + return S_OK; } virtual HRESULT STDMETHODCALLTYPE Exception( diff --git a/src/debug/netcoredbg/miprotocol.cpp b/src/debug/netcoredbg/miprotocol.cpp index f9776eb..b916c32 100644 --- a/src/debug/netcoredbg/miprotocol.cpp +++ b/src/debug/netcoredbg/miprotocol.cpp @@ -553,6 +553,12 @@ void MIProtocol::EmitStoppedEvent(StoppedEvent event) int(event.threadId), frameLocation.c_str()); break; } + case StopBreak: + { + MIProtocol::Printf("*stopped,reason=\"Debugger.Break\",thread-id=\"%i\",stopped-threads=\"all\",frame={%s}\n", + int(event.threadId), frameLocation.c_str()); + break; + } default: return; } diff --git a/src/debug/netcoredbg/protocol.h b/src/debug/netcoredbg/protocol.h index c8a132c..2148598 100644 --- a/src/debug/netcoredbg/protocol.h +++ b/src/debug/netcoredbg/protocol.h @@ -247,7 +247,8 @@ enum StopReason StopBreakpoint, StopException, StopPause, - StopEntry + StopEntry, + StopBreak }; struct StoppedEvent diff --git a/src/debug/netcoredbg/vscodeprotocol.cpp b/src/debug/netcoredbg/vscodeprotocol.cpp index cddca70..db79734 100644 --- a/src/debug/netcoredbg/vscodeprotocol.cpp +++ b/src/debug/netcoredbg/vscodeprotocol.cpp @@ -158,6 +158,9 @@ void VSCodeProtocol::EmitStoppedEvent(StoppedEvent event) case StopEntry: body["reason"] = "entry"; break; + case StopBreak: + body["reason"] = "Debugger.Break"; + break; } body["description"] = event.description;