Report number of available frames and use levels instead of high frame index
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Wed, 24 Jan 2018 20:47:05 +0000 (23:47 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Wed, 24 Jan 2018 20:47:05 +0000 (23:47 +0300)
src/debug/netcoredbg/debugger.h
src/debug/netcoredbg/frames.cpp
src/debug/netcoredbg/manageddebugger.cpp
src/debug/netcoredbg/manageddebugger.h
src/debug/netcoredbg/miprotocol.cpp

index 80b7c15..fd8fe4e 100644 (file)
@@ -41,7 +41,7 @@ public:
     virtual HRESULT GetThreads(std::vector<Thread> &threads) = 0;
     virtual HRESULT SetBreakpoints(std::string filename, const std::vector<int> &lines, std::vector<Breakpoint> &breakpoints) = 0;
     virtual void InsertExceptionBreakpoint(const std::string &name, Breakpoint &breakpoint) = 0;
-    virtual HRESULT GetStackTrace(int threadId, int lowFrame, int highFrame, std::vector<StackFrame> &stackFrames) = 0;
+    virtual HRESULT GetStackTrace(int threadId, int startFrame, int levels, std::vector<StackFrame> &stackFrames, int &totalFrames) = 0;
     virtual HRESULT StepCommand(int threadId, StepType stepType) = 0;
     virtual HRESULT GetScopes(uint64_t frameId, std::vector<Scope> &scopes) = 0;
     virtual HRESULT GetVariables(uint32_t variablesReference, VariablesFilter filter, int start, int count, std::vector<Variable> &variables) = 0;
index 31aaa95..2d74803 100644 (file)
@@ -387,7 +387,7 @@ static const char *GetInternalTypeName(CorDebugInternalFrameType frameType)
     }
 }
 
-HRESULT ManagedDebugger::GetStackTrace(ICorDebugThread *pThread, int lowFrame, int highFrame, std::vector<StackFrame> &stackFrames)
+HRESULT ManagedDebugger::GetStackTrace(ICorDebugThread *pThread, int startFrame, int levels, std::vector<StackFrame> &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;
 }
index 812f209..a1aba3c 100644 (file)
@@ -794,14 +794,14 @@ HRESULT ManagedDebugger::GetThreads(std::vector<Thread> &threads)
     return GetThreadsState(m_pProcess, threads);
 }
 
-HRESULT ManagedDebugger::GetStackTrace(int threadId, int lowFrame, int highFrame, std::vector<StackFrame> &stackFrames)
+HRESULT ManagedDebugger::GetStackTrace(int threadId, int startFrame, int levels, std::vector<StackFrame> &stackFrames, int &totalFrames)
 {
     HRESULT Status;
     if (!m_pProcess)
         return E_FAIL;
     ToRelease<ICorDebugThread> 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)
index 9f5c9f8..58f55e0 100644 (file)
@@ -371,7 +371,7 @@ private:
 
     HRESULT SetupStep(ICorDebugThread *pThread, StepType stepType);
 
-    HRESULT GetStackTrace(ICorDebugThread *pThread, int lowFrame, int highFrame, std::vector<StackFrame> &stackFrames);
+    HRESULT GetStackTrace(ICorDebugThread *pThread, int startFrame, int levels, std::vector<StackFrame> &stackFrames, int &totalFrames);
     HRESULT GetFrameLocation(ICorDebugFrame *pFrame, int threadId, uint32_t level, StackFrame &stackFrame);
 
     HRESULT RunProcess(std::string fileExec, std::vector<std::string> execArgs);
@@ -402,7 +402,7 @@ public:
     HRESULT GetThreads(std::vector<Thread> &threads) override;
     HRESULT SetBreakpoints(std::string filename, const std::vector<int> &lines, std::vector<Breakpoint> &breakpoints) override;
     void InsertExceptionBreakpoint(const std::string &name, Breakpoint &breakpoint) override;
-    HRESULT GetStackTrace(int threadId, int lowFrame, int highFrame, std::vector<StackFrame> &stackFrames) override;
+    HRESULT GetStackTrace(int threadId, int startFrame, int levels, std::vector<StackFrame> &stackFrames, int &totalFrames) override;
     HRESULT StepCommand(int threadId, StepType stepType) override;
     HRESULT GetScopes(uint64_t frameId, std::vector<Scope> &scopes) override;
     HRESULT GetVariables(uint32_t variablesReference, VariablesFilter filter, int start, int count, std::vector<Variable> &variables) override;
index 7d785eb..c5052b7 100644 (file)
@@ -219,8 +219,9 @@ HRESULT MIProtocol::PrintFrames(int threadId, std::string &output, int lowFrame,
     HRESULT Status;
     std::stringstream ss;
 
+    int totalFrames = 0;
     std::vector<StackFrame> stackFrames;
-    IfFailRet(m_debugger->GetStackTrace(threadId, lowFrame, highFrame, stackFrames));
+    IfFailRet(m_debugger->GetStackTrace(threadId, lowFrame, highFrame - lowFrame, stackFrames, totalFrames));
 
     int currentFrame = lowFrame;