From f4ceab706689b20b413bbcb1f7865415101460e6 Mon Sep 17 00:00:00 2001 From: Igor Kulaychuk Date: Wed, 24 Jan 2018 23:47:05 +0300 Subject: [PATCH] Report number of available frames and use levels instead of high frame index --- src/debug/netcoredbg/debugger.h | 2 +- src/debug/netcoredbg/frames.cpp | 10 ++++++---- src/debug/netcoredbg/manageddebugger.cpp | 4 ++-- src/debug/netcoredbg/manageddebugger.h | 4 ++-- src/debug/netcoredbg/miprotocol.cpp | 3 ++- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/debug/netcoredbg/debugger.h b/src/debug/netcoredbg/debugger.h index 80b7c15..fd8fe4e 100644 --- a/src/debug/netcoredbg/debugger.h +++ b/src/debug/netcoredbg/debugger.h @@ -41,7 +41,7 @@ public: virtual HRESULT GetThreads(std::vector &threads) = 0; virtual HRESULT SetBreakpoints(std::string filename, const std::vector &lines, std::vector &breakpoints) = 0; virtual void InsertExceptionBreakpoint(const std::string &name, Breakpoint &breakpoint) = 0; - virtual HRESULT GetStackTrace(int threadId, int lowFrame, int highFrame, std::vector &stackFrames) = 0; + virtual HRESULT GetStackTrace(int threadId, int startFrame, int levels, std::vector &stackFrames, int &totalFrames) = 0; virtual HRESULT StepCommand(int threadId, StepType stepType) = 0; virtual HRESULT GetScopes(uint64_t frameId, std::vector &scopes) = 0; virtual HRESULT GetVariables(uint32_t variablesReference, VariablesFilter filter, int start, int count, std::vector &variables) = 0; diff --git a/src/debug/netcoredbg/frames.cpp b/src/debug/netcoredbg/frames.cpp index 31aaa95..2d74803 100644 --- a/src/debug/netcoredbg/frames.cpp +++ b/src/debug/netcoredbg/frames.cpp @@ -387,7 +387,7 @@ static const char *GetInternalTypeName(CorDebugInternalFrameType frameType) } } -HRESULT ManagedDebugger::GetStackTrace(ICorDebugThread *pThread, int lowFrame, int highFrame, std::vector &stackFrames) +HRESULT ManagedDebugger::GetStackTrace(ICorDebugThread *pThread, int startFrame, int levels, std::vector &stackFrames, int &totalFrames) { HRESULT Status; std::stringstream ss; @@ -405,10 +405,10 @@ HRESULT ManagedDebugger::GetStackTrace(ICorDebugThread *pThread, int lowFrame, i { currentFrame++; - if (currentFrame < lowFrame) + if (currentFrame < startFrame) + return S_OK; + if (levels != 0 && currentFrame >= (startFrame + levels)) return S_OK; - if (currentFrame > highFrame) - return S_OK; // Todo implement fast break mechanism switch(frameType) { @@ -450,5 +450,7 @@ HRESULT ManagedDebugger::GetStackTrace(ICorDebugThread *pThread, int lowFrame, i return S_OK; })); + totalFrames = currentFrame + 1; + return S_OK; } diff --git a/src/debug/netcoredbg/manageddebugger.cpp b/src/debug/netcoredbg/manageddebugger.cpp index 812f209..a1aba3c 100644 --- a/src/debug/netcoredbg/manageddebugger.cpp +++ b/src/debug/netcoredbg/manageddebugger.cpp @@ -794,14 +794,14 @@ HRESULT ManagedDebugger::GetThreads(std::vector &threads) return GetThreadsState(m_pProcess, threads); } -HRESULT ManagedDebugger::GetStackTrace(int threadId, int lowFrame, int highFrame, std::vector &stackFrames) +HRESULT ManagedDebugger::GetStackTrace(int threadId, int startFrame, int levels, std::vector &stackFrames, int &totalFrames) { HRESULT Status; if (!m_pProcess) return E_FAIL; ToRelease pThread; IfFailRet(m_pProcess->GetThread(threadId, &pThread)); - return GetStackTrace(pThread, lowFrame, highFrame, stackFrames); + return GetStackTrace(pThread, startFrame, levels, stackFrames, totalFrames); } VOID ManagedDebugger::StartupCallback(IUnknown *pCordb, PVOID parameter, HRESULT hr) diff --git a/src/debug/netcoredbg/manageddebugger.h b/src/debug/netcoredbg/manageddebugger.h index 9f5c9f8..58f55e0 100644 --- a/src/debug/netcoredbg/manageddebugger.h +++ b/src/debug/netcoredbg/manageddebugger.h @@ -371,7 +371,7 @@ private: HRESULT SetupStep(ICorDebugThread *pThread, StepType stepType); - HRESULT GetStackTrace(ICorDebugThread *pThread, int lowFrame, int highFrame, std::vector &stackFrames); + HRESULT GetStackTrace(ICorDebugThread *pThread, int startFrame, int levels, std::vector &stackFrames, int &totalFrames); HRESULT GetFrameLocation(ICorDebugFrame *pFrame, int threadId, uint32_t level, StackFrame &stackFrame); HRESULT RunProcess(std::string fileExec, std::vector execArgs); @@ -402,7 +402,7 @@ public: HRESULT GetThreads(std::vector &threads) override; HRESULT SetBreakpoints(std::string filename, const std::vector &lines, std::vector &breakpoints) override; void InsertExceptionBreakpoint(const std::string &name, Breakpoint &breakpoint) override; - HRESULT GetStackTrace(int threadId, int lowFrame, int highFrame, std::vector &stackFrames) override; + HRESULT GetStackTrace(int threadId, int startFrame, int levels, std::vector &stackFrames, int &totalFrames) override; HRESULT StepCommand(int threadId, StepType stepType) override; HRESULT GetScopes(uint64_t frameId, std::vector &scopes) override; HRESULT GetVariables(uint32_t variablesReference, VariablesFilter filter, int start, int count, std::vector &variables) override; diff --git a/src/debug/netcoredbg/miprotocol.cpp b/src/debug/netcoredbg/miprotocol.cpp index 7d785eb..c5052b7 100644 --- a/src/debug/netcoredbg/miprotocol.cpp +++ b/src/debug/netcoredbg/miprotocol.cpp @@ -219,8 +219,9 @@ HRESULT MIProtocol::PrintFrames(int threadId, std::string &output, int lowFrame, HRESULT Status; std::stringstream ss; + int totalFrames = 0; std::vector stackFrames; - IfFailRet(m_debugger->GetStackTrace(threadId, lowFrame, highFrame, stackFrames)); + IfFailRet(m_debugger->GetStackTrace(threadId, lowFrame, highFrame - lowFrame, stackFrames, totalFrames)); int currentFrame = lowFrame; -- 2.7.4