From 5a9f7dc771f7a75ec501fb06bb985fdd76cd0f9b Mon Sep 17 00:00:00 2001 From: Igor Kulaychuk Date: Thu, 18 Jan 2018 00:58:14 +0300 Subject: [PATCH] Refactor all evaluation related functions into separate Evaluator class --- src/debug/netcoredbg/debugger.h | 176 +++++++++++++++++++++++++++++-------- src/debug/netcoredbg/expr.cpp | 45 +++++----- src/debug/netcoredbg/expr.h | 1 - src/debug/netcoredbg/main.cpp | 23 +++-- src/debug/netcoredbg/valuewalk.cpp | 105 +++++++++++----------- src/debug/netcoredbg/valuewalk.h | 27 ------ src/debug/netcoredbg/variables.cpp | 47 +++++----- 7 files changed, 257 insertions(+), 167 deletions(-) delete mode 100644 src/debug/netcoredbg/valuewalk.h diff --git a/src/debug/netcoredbg/debugger.h b/src/debug/netcoredbg/debugger.h index a0d031d..4f7d4bf 100644 --- a/src/debug/netcoredbg/debugger.h +++ b/src/debug/netcoredbg/debugger.h @@ -7,10 +7,135 @@ #include #include #include +#include class ManagedCallback; class Protocol; +struct Member; + +enum ValueKind +{ + ValueIsScope, + ValueIsClass, + ValueIsVariable +}; + +class Evaluator +{ +public: + + typedef std::function WalkMembersCallback; + typedef std::function WalkStackVarsCallback; + +private: + + ToRelease m_pRunClassConstructor; + ToRelease m_pGetTypeHandle; + + std::mutex m_evalMutex; + std::unordered_map< DWORD, std::promise< std::unique_ptr> > > m_evalResults; + + HRESULT FollowNested(ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + const std::string &methodClass, + const std::vector &parts, + ICorDebugValue **ppResult); + HRESULT FollowFields(ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + ICorDebugValue *pValue, + ValueKind valueKind, + const std::vector &parts, + int nextPart, + ICorDebugValue **ppResult); + HRESULT GetFieldOrPropertyWithName(ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + ICorDebugValue *pInputValue, + ValueKind valueKind, + const std::string &name, + ICorDebugValue **ppResultValue); + + HRESULT WaitEvalResult(ICorDebugThread *pThread, + ICorDebugEval *pEval, + ICorDebugValue **ppEvalResult); + + HRESULT EvalObjectNoConstructor( + ICorDebugThread *pThread, + ICorDebugType *pType, + ICorDebugValue **ppEvalResult); + + std::future< std::unique_ptr> > RunEval( + ICorDebugThread *pThread, + ICorDebugEval *pEval); + + HRESULT WalkMembers( + ICorDebugValue *pInputValue, + ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + ICorDebugType *pTypeCast, + WalkMembersCallback cb); + + HRESULT HandleSpecialLocalVar( + const std::string &localName, + ICorDebugValue *pLocalValue, + ICorDebugILFrame *pILFrame, + std::unordered_set &locals, + WalkStackVarsCallback cb); + + HRESULT HandleSpecialThisParam( + ICorDebugValue *pThisValue, + ICorDebugILFrame *pILFrame, + std::unordered_set &locals, + WalkStackVarsCallback cb); + + HRESULT GetLiteralValue( + ICorDebugThread *pThread, + ICorDebugType *pType, + ICorDebugModule *pModule, + PCCOR_SIGNATURE pSignatureBlob, + ULONG sigBlobLength, + UVCP_CONSTANT pRawValue, + ULONG rawValueLength, + ICorDebugValue **ppLiteralValue); + +public: + + HRESULT RunClassConstructor(ICorDebugThread *pThread, ICorDebugValue *pValue); + + HRESULT EvalFunction( + ICorDebugThread *pThread, + ICorDebugFunction *pFunc, + ICorDebugType *pType, // may be nullptr + ICorDebugValue *pArgValue, // may be nullptr + ICorDebugValue **ppEvalResult); + + HRESULT EvalExpr(ICorDebugThread *pThread, + ICorDebugFrame *pFrame, + const std::string &expression, + ICorDebugValue **ppResult); + + bool IsEvalRunning(); + + // Should be called by ICorDebugManagedCallback + void NotifyEvalComplete(ICorDebugThread *pThread, ICorDebugEval *pEval); + + HRESULT ObjectToString( + ICorDebugThread *pThread, + ICorDebugValue *pValue, + std::function cb + ); + + HRESULT WalkMembers( + ICorDebugValue *pValue, + ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + WalkMembersCallback cb); + + HRESULT WalkStackVars(ICorDebugFrame *pFrame, WalkStackVarsCallback cb); + + void Cleanup(); +}; + class Debugger { public: @@ -22,6 +147,7 @@ public: private: friend class ManagedCallback; + Evaluator m_evaluator; Protocol *m_protocol; ManagedCallback *m_managedCallback; ICorDebug *m_pDebug; @@ -38,13 +164,6 @@ private: DWORD m_processId; std::string m_clrPath; - enum ValueKind - { - ValueIsScope, - ValueIsClass, - ValueIsVariable - }; - struct VariableReference { uint32_t variablesReference; // key @@ -117,7 +236,7 @@ private: void DeleteAllBreakpoints(); HRESULT ResolveBreakpointInModule(ICorDebugModule *pModule, ManagedBreakpoint &bp); - HRESULT Debugger::ResolveBreakpoint(ManagedBreakpoint &bp); + HRESULT ResolveBreakpoint(ManagedBreakpoint &bp); HRESULT CheckNoProcess(); @@ -131,33 +250,20 @@ private: HRESULT GetStackVariables(uint64_t frameId, ICorDebugThread *pThread, ICorDebugFrame *pFrame, int start, int count, std::vector &variables); HRESULT GetChildren(VariableReference &ref, ICorDebugThread *pThread, ICorDebugFrame *pFrame, int start, int count, std::vector &variables); - HRESULT EvalExpr(ICorDebugThread *pThread, - ICorDebugFrame *pFrame, - const std::string &expression, - ICorDebugValue **ppResult); - HRESULT FollowNested(ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - const std::string &methodClass, - const std::vector &parts, - ICorDebugValue **ppResult); - HRESULT FollowFields(ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - ICorDebugValue *pValue, - ValueKind valueKind, - const std::vector &parts, - int nextPart, - ICorDebugValue **ppResult); - HRESULT GetFieldOrPropertyWithName(ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - ICorDebugValue *pInputValue, - ValueKind valueKind, - const std::string &name, - ICorDebugValue **ppResultValue); - - ToRelease m_pRunClassConstructor; - ToRelease m_pGetTypeHandle; - HRESULT RunClassConstructor(ICorDebugThread *pThread, ICorDebugValue *pValue); - + HRESULT FetchFieldsAndProperties( + ICorDebugValue *pInputValue, + ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + std::vector &members, + bool fetchOnlyStatic, + bool &hasStaticMembers, + int childStart, + int childEnd); + + HRESULT GetNumChild( + ICorDebugValue *pValue, + unsigned int &numchild, + bool static_members = false); public: Debugger(); ~Debugger(); diff --git a/src/debug/netcoredbg/expr.cpp b/src/debug/netcoredbg/expr.cpp index 88e0b80..59765df 100644 --- a/src/debug/netcoredbg/expr.cpp +++ b/src/debug/netcoredbg/expr.cpp @@ -17,7 +17,6 @@ #include "debugger.h" #include "typeprinter.h" #include "modules.h" -#include "valuewalk.h" #include "valueprint.h" #include "expr.h" @@ -52,12 +51,12 @@ static HRESULT ParseIndices(const std::string &s, std::vector &indices) return S_OK; } -HRESULT Debugger::GetFieldOrPropertyWithName(ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - ICorDebugValue *pInputValue, - ValueKind valueKind, - const std::string &name, - ICorDebugValue **ppResultValue) +HRESULT Evaluator::GetFieldOrPropertyWithName(ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + ICorDebugValue *pInputValue, + ValueKind valueKind, + const std::string &name, + ICorDebugValue **ppResultValue) { HRESULT Status; @@ -150,13 +149,13 @@ static mdTypeDef GetTypeTokenForName(IMetaDataImport *pMD, mdTypeDef tkEnclosing return typeToken; } -HRESULT Debugger::FollowFields(ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - ICorDebugValue *pValue, - ValueKind valueKind, - const std::vector &parts, - int nextPart, - ICorDebugValue **ppResult) +HRESULT Evaluator::FollowFields(ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + ICorDebugValue *pValue, + ValueKind valueKind, + const std::vector &parts, + int nextPart, + ICorDebugValue **ppResult) { HRESULT Status; @@ -504,11 +503,11 @@ HRESULT FindType(const std::vector &parts, return S_OK; } -HRESULT Debugger::FollowNested(ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - const std::string &methodClass, - const std::vector &parts, - ICorDebugValue **ppResult) +HRESULT Evaluator::FollowNested(ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + const std::string &methodClass, + const std::vector &parts, + ICorDebugValue **ppResult) { HRESULT Status; @@ -539,10 +538,10 @@ HRESULT Debugger::FollowNested(ICorDebugThread *pThread, return E_FAIL; } -HRESULT Debugger::EvalExpr(ICorDebugThread *pThread, - ICorDebugFrame *pFrame, - const std::string &expression, - ICorDebugValue **ppResult) +HRESULT Evaluator::EvalExpr(ICorDebugThread *pThread, + ICorDebugFrame *pFrame, + const std::string &expression, + ICorDebugValue **ppResult) { HRESULT Status; diff --git a/src/debug/netcoredbg/expr.h b/src/debug/netcoredbg/expr.h index 184d1f3..619f520 100644 --- a/src/debug/netcoredbg/expr.h +++ b/src/debug/netcoredbg/expr.h @@ -3,4 +3,3 @@ // See the LICENSE file in the project root for more information. HRESULT GetType(const std::string &typeName, ICorDebugThread *pThread, ICorDebugType **ppType); -HRESULT EvalExpr(ICorDebugThread *pThread, ICorDebugFrame *pFrame, const std::string &expression, ICorDebugValue **ppResult); diff --git a/src/debug/netcoredbg/main.cpp b/src/debug/netcoredbg/main.cpp index 676ba38..29a1f90 100644 --- a/src/debug/netcoredbg/main.cpp +++ b/src/debug/netcoredbg/main.cpp @@ -19,7 +19,6 @@ #include "typeprinter.h" #include "debugger.h" #include "modules.h" -#include "valuewalk.h" #include "frames.h" #define __in @@ -326,7 +325,7 @@ public: /* [in] */ ICorDebugThread *pThread, /* [in] */ ICorDebugBreakpoint *pBreakpoint) { - if (IsEvalRunning()) + if (m_debugger->m_evaluator.IsEvalRunning()) { pAppDomain->Continue(0); return S_OK; @@ -418,7 +417,8 @@ public: m_debugger->m_protocol->EmitStoppedEvent(event); }; - if (FAILED(pThread->GetCurrentException(&pExceptionValue)) || FAILED(ObjectToString(pThread, pExceptionValue, emitFunc))) + if (FAILED(pThread->GetCurrentException(&pExceptionValue)) || + FAILED(m_debugger->m_evaluator.ObjectToString(pThread, pExceptionValue, emitFunc))) { emitFunc(details); } @@ -440,7 +440,7 @@ public: /* [in] */ ICorDebugThread *pThread, /* [in] */ ICorDebugEval *pEval) { - NotifyEvalComplete(pThread, pEval); + m_debugger->m_evaluator.NotifyEvalComplete(pThread, pEval); return S_OK; } @@ -449,7 +449,7 @@ public: /* [in] */ ICorDebugThread *pThread, /* [in] */ ICorDebugEval *pEval) { - NotifyEvalComplete(pThread, pEval); + m_debugger->m_evaluator.NotifyEvalComplete(pThread, pEval); return S_OK; } @@ -465,7 +465,7 @@ public: virtual HRESULT STDMETHODCALLTYPE ExitProcess( /* [in] */ ICorDebugProcess *pProcess) { - NotifyEvalComplete(nullptr, nullptr); + m_debugger->m_evaluator.NotifyEvalComplete(nullptr, nullptr); m_debugger->m_protocol->EmitExitedEvent(ExitedEvent(0)); NotifyProcessExited(); return S_OK; @@ -486,7 +486,7 @@ public: /* [in] */ ICorDebugAppDomain *pAppDomain, /* [in] */ ICorDebugThread *thread) { - NotifyEvalComplete(thread, nullptr); + m_debugger->m_evaluator.NotifyEvalComplete(thread, nullptr); DWORD threadId = 0; thread->GetID(&threadId); m_debugger->m_protocol->EmitThreadEvent(ThreadEvent(ThreadExited, threadId)); @@ -942,13 +942,18 @@ HRESULT Debugger::TerminateProcess() return S_OK; } -void Debugger::Cleanup() +void Evaluator::Cleanup() { - Modules::CleanupAllModules(); if (m_pRunClassConstructor) m_pRunClassConstructor->Release(); if (m_pGetTypeHandle) m_pGetTypeHandle->Release(); +} + +void Debugger::Cleanup() +{ + Modules::CleanupAllModules(); + m_evaluator.Cleanup(); m_protocol->Cleanup(); // TODO: Cleanup libcoreclr.so instance } diff --git a/src/debug/netcoredbg/valuewalk.cpp b/src/debug/netcoredbg/valuewalk.cpp index e87e42e..fbca7f2 100644 --- a/src/debug/netcoredbg/valuewalk.cpp +++ b/src/debug/netcoredbg/valuewalk.cpp @@ -13,26 +13,22 @@ #include #include #include -#include #include #include "cputil.h" #include "modules.h" #include "typeprinter.h" -#include "valuewalk.h" #include "valueprint.h" #include "expr.h" +#include "debugger.h" -static std::mutex g_evalMutex; -static std::unordered_map< DWORD, std::promise< std::unique_ptr> > > g_evalResults; - -void NotifyEvalComplete(ICorDebugThread *pThread, ICorDebugEval *pEval) +void Evaluator::NotifyEvalComplete(ICorDebugThread *pThread, ICorDebugEval *pEval) { - std::lock_guard lock(g_evalMutex); + std::lock_guard lock(m_evalMutex); if (!pThread) { - g_evalResults.clear(); + m_evalResults.clear(); return; } @@ -45,23 +41,23 @@ void NotifyEvalComplete(ICorDebugThread *pThread, ICorDebugEval *pEval) pEval->GetResult(&(*ppEvalResult)); } - auto it = g_evalResults.find(threadId); + auto it = m_evalResults.find(threadId); - if (it == g_evalResults.end()) + if (it == m_evalResults.end()) return; it->second.set_value(std::move(ppEvalResult)); - g_evalResults.erase(it); + m_evalResults.erase(it); } -bool IsEvalRunning() +bool Evaluator::IsEvalRunning() { - std::lock_guard lock(g_evalMutex); - return !g_evalResults.empty(); + std::lock_guard lock(m_evalMutex); + return !m_evalResults.empty(); } -std::future< std::unique_ptr> > RunEval( +std::future< std::unique_ptr> > Evaluator::RunEval( ICorDebugThread *pThread, ICorDebugEval *pEval) { @@ -75,20 +71,20 @@ std::future< std::unique_ptr> > RunEval( if (FAILED(pThread->GetProcess(&pProcess))) return f; - std::lock_guard lock(g_evalMutex); + std::lock_guard lock(m_evalMutex); - if (!g_evalResults.insert(std::make_pair(threadId, std::move(p))).second) + if (!m_evalResults.insert(std::make_pair(threadId, std::move(p))).second) return f; // Already running eval? The future will throw broken promise if (FAILED(pProcess->Continue(0))) - g_evalResults.erase(threadId); + m_evalResults.erase(threadId); return f; } -static HRESULT WaitEvalResult(ICorDebugThread *pThread, - ICorDebugEval *pEval, - ICorDebugValue **ppEvalResult) +HRESULT Evaluator::WaitEvalResult(ICorDebugThread *pThread, + ICorDebugEval *pEval, + ICorDebugValue **ppEvalResult) { try { @@ -105,7 +101,7 @@ static HRESULT WaitEvalResult(ICorDebugThread *pThread, return S_OK; } -HRESULT EvalFunction( +HRESULT Evaluator::EvalFunction( ICorDebugThread *pThread, ICorDebugFunction *pFunc, ICorDebugType *pType, // may be nullptr @@ -147,7 +143,7 @@ HRESULT EvalFunction( return WaitEvalResult(pThread, pEval, ppEvalResult); } -HRESULT EvalObjectNoConstructor( +HRESULT Evaluator::EvalObjectNoConstructor( ICorDebugThread *pThread, ICorDebugType *pType, ICorDebugValue **ppEvalResult) @@ -230,7 +226,7 @@ static HRESULT FindMethod(ICorDebugType *pType, WCHAR *methodName, ICorDebugFunc return E_FAIL; } -HRESULT ObjectToString( +HRESULT Evaluator::ObjectToString( ICorDebugThread *pThread, ICorDebugValue *pValue, std::function cb @@ -337,14 +333,15 @@ static std::string IndiciesToStr(const std::vector &ind, const std::vec return ss.str(); } -static HRESULT GetLiteralValue(ICorDebugThread *pThread, - ICorDebugType *pType, - ICorDebugModule *pModule, - PCCOR_SIGNATURE pSignatureBlob, - ULONG sigBlobLength, - UVCP_CONSTANT pRawValue, - ULONG rawValueLength, - ICorDebugValue **ppLiteralValue) +HRESULT Evaluator::GetLiteralValue( + ICorDebugThread *pThread, + ICorDebugType *pType, + ICorDebugModule *pModule, + PCCOR_SIGNATURE pSignatureBlob, + ULONG sigBlobLength, + UVCP_CONSTANT pRawValue, + ULONG rawValueLength, + ICorDebugValue **ppLiteralValue) { HRESULT Status = S_OK; @@ -495,11 +492,12 @@ static HRESULT GetLiteralValue(ICorDebugThread *pThread, return S_OK; } -static HRESULT WalkMembers(ICorDebugValue *pInputValue, - ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - ICorDebugType *pTypeCast, - WalkMembersCallback cb) +HRESULT Evaluator::WalkMembers( + ICorDebugValue *pInputValue, + ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + ICorDebugType *pTypeCast, + WalkMembersCallback cb) { HRESULT Status = S_OK; @@ -715,19 +713,21 @@ static HRESULT WalkMembers(ICorDebugValue *pInputValue, return S_OK; } -HRESULT WalkMembers(ICorDebugValue *pValue, - ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - WalkMembersCallback cb) +HRESULT Evaluator::WalkMembers( + ICorDebugValue *pValue, + ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + WalkMembersCallback cb) { return WalkMembers(pValue, pThread, pILFrame, nullptr, cb); } -static HRESULT HandleSpecialLocalVar(const std::string &localName, - ICorDebugValue *pLocalValue, - ICorDebugILFrame *pILFrame, - std::unordered_set &locals, - WalkStackVarsCallback cb) +HRESULT Evaluator::HandleSpecialLocalVar( + const std::string &localName, + ICorDebugValue *pLocalValue, + ICorDebugILFrame *pILFrame, + std::unordered_set &locals, + WalkStackVarsCallback cb) { static const std::string captureName = "CS$<>"; @@ -758,10 +758,11 @@ static HRESULT HandleSpecialLocalVar(const std::string &localName, return S_OK; } -static HRESULT HandleSpecialThisParam(ICorDebugValue *pThisValue, - ICorDebugILFrame *pILFrame, - std::unordered_set &locals, - WalkStackVarsCallback cb) +HRESULT Evaluator::HandleSpecialThisParam( + ICorDebugValue *pThisValue, + ICorDebugILFrame *pILFrame, + std::unordered_set &locals, + WalkStackVarsCallback cb) { static const std::string displayClass = "<>c__DisplayClass"; static const std::string hideClass = "<>c"; @@ -804,7 +805,7 @@ static HRESULT HandleSpecialThisParam(ICorDebugValue *pThisValue, return S_OK; } -HRESULT WalkStackVars(ICorDebugFrame *pFrame, WalkStackVarsCallback cb) +HRESULT Evaluator::WalkStackVars(ICorDebugFrame *pFrame, WalkStackVarsCallback cb) { HRESULT Status; @@ -919,4 +920,4 @@ HRESULT WalkStackVars(ICorDebugFrame *pFrame, WalkStackVarsCallback cb) } return S_OK; -} \ No newline at end of file +} diff --git a/src/debug/netcoredbg/valuewalk.h b/src/debug/netcoredbg/valuewalk.h deleted file mode 100644 index 766497b..0000000 --- a/src/debug/netcoredbg/valuewalk.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2017 Samsung Electronics Co., LTD -// Distributed under the MIT License. -// See the LICENSE file in the project root for more information. - -typedef std::function WalkMembersCallback; -typedef std::function WalkStackVarsCallback; -HRESULT WalkMembers(ICorDebugValue *pValue, ICorDebugThread *pThread, ICorDebugILFrame *pILFrame, WalkMembersCallback cb); -HRESULT WalkStackVars(ICorDebugFrame *pFrame, WalkStackVarsCallback cb); -HRESULT EvalFunction( - ICorDebugThread *pThread, - ICorDebugFunction *pFunc, - ICorDebugType *pType, // may be nullptr - ICorDebugValue *pArgValue, // may be nullptr - ICorDebugValue **ppEvalResult); - -HRESULT EvalObjectNoConstructor( - ICorDebugThread *pThread, - ICorDebugType *pType, - ICorDebugValue **ppEvalResult); - -bool IsEvalRunning(); -void NotifyEvalComplete(ICorDebugThread *pThread, ICorDebugEval *pEval); -HRESULT ObjectToString( - ICorDebugThread *pThread, - ICorDebugValue *pValue, - std::function cb -); diff --git a/src/debug/netcoredbg/variables.cpp b/src/debug/netcoredbg/variables.cpp index e245efb..841998f 100644 --- a/src/debug/netcoredbg/variables.cpp +++ b/src/debug/netcoredbg/variables.cpp @@ -17,15 +17,15 @@ #include "debugger.h" #include "typeprinter.h" #include "modules.h" -#include "valuewalk.h" #include "valueprint.h" #include "expr.h" #include "frames.h" -HRESULT GetNumChild(ICorDebugValue *pValue, - unsigned int &numchild, - bool static_members = false) +HRESULT Debugger::GetNumChild( + ICorDebugValue *pValue, + unsigned int &numchild, + bool static_members) { HRESULT Status = S_OK; numchild = 0; @@ -33,7 +33,7 @@ HRESULT GetNumChild(ICorDebugValue *pValue, ULONG numstatic = 0; ULONG numinstance = 0; - IfFailRet(WalkMembers(pValue, nullptr, nullptr, [&numstatic, &numinstance]( + IfFailRet(m_evaluator.WalkMembers(pValue, nullptr, nullptr, [&numstatic, &numinstance]( mdMethodDef, ICorDebugModule *, ICorDebugType *, @@ -93,7 +93,7 @@ static HRESULT FindFunction(ICorDebugModule *pModule, return pModule->GetFunctionFromToken(methodDef, ppFunction); } -HRESULT Debugger::RunClassConstructor(ICorDebugThread *pThread, ICorDebugValue *pValue) +HRESULT Evaluator::RunClassConstructor(ICorDebugThread *pThread, ICorDebugValue *pValue) { HRESULT Status; @@ -157,14 +157,15 @@ private: Member(const Member &that) = delete; }; -static HRESULT FetchFieldsAndProperties(ICorDebugValue *pInputValue, - ICorDebugThread *pThread, - ICorDebugILFrame *pILFrame, - std::vector &members, - bool fetchOnlyStatic, - bool &hasStaticMembers, - int childStart, - int childEnd) +HRESULT Debugger::FetchFieldsAndProperties( + ICorDebugValue *pInputValue, + ICorDebugThread *pThread, + ICorDebugILFrame *pILFrame, + std::vector &members, + bool fetchOnlyStatic, + bool &hasStaticMembers, + int childStart, + int childEnd) { hasStaticMembers = false; HRESULT Status; @@ -174,7 +175,7 @@ static HRESULT FetchFieldsAndProperties(ICorDebugValue *pInputValue, int currentIndex = -1; - IfFailRet(WalkMembers(pInputValue, pThread, pILFrame, [&]( + IfFailRet(m_evaluator.WalkMembers(pInputValue, pThread, pILFrame, [&]( mdMethodDef mdGetter, ICorDebugModule *pModule, ICorDebugType *pType, @@ -205,7 +206,7 @@ static HRESULT FetchFieldsAndProperties(ICorDebugValue *pInputValue, { ToRelease pFunc; if (SUCCEEDED(pModule->GetFunctionFromToken(mdGetter, &pFunc))) - EvalFunction(pThread, pFunc, pType, is_static ? nullptr : pInputValue, &pResultValue); + m_evaluator.EvalFunction(pThread, pFunc, pType, is_static ? nullptr : pInputValue, &pResultValue); } else { @@ -299,7 +300,10 @@ HRESULT Debugger::GetStackVariables(uint64_t frameId, ICorDebugThread *pThread, } } - IfFailRet(WalkStackVars(pFrame, [&](ICorDebugILFrame *pILFrame, ICorDebugValue *pValue, const std::string &name) -> HRESULT + IfFailRet(m_evaluator.WalkStackVars(pFrame, [&]( + ICorDebugILFrame *pILFrame, + ICorDebugValue *pValue, + const std::string &name) -> HRESULT { ++currentIndex; if (currentIndex < start || (count != 0 && currentIndex >= start + count)) @@ -335,7 +339,10 @@ HRESULT Debugger::GetScopes(uint64_t frameId, std::vector &scopes) if (SUCCEEDED(pThread->GetCurrentException(&pExceptionValue)) && pExceptionValue != nullptr) namedVariables++; - IfFailRet(WalkStackVars(pFrame, [&](ICorDebugILFrame *pILFrame, ICorDebugValue *pValue, const std::string &name) -> HRESULT + IfFailRet(m_evaluator.WalkStackVars(pFrame, [&]( + ICorDebugILFrame *pILFrame, + ICorDebugValue *pValue, + const std::string &name) -> HRESULT { namedVariables++; return S_OK; @@ -419,7 +426,7 @@ HRESULT Debugger::GetChildren(VariableReference &ref, bool staticsInRange = start < ref.namedVariables && (count == 0 || start + count >= ref.namedVariables); if (staticsInRange) { - RunClassConstructor(pThread, ref.value); + m_evaluator.RunClassConstructor(pThread, ref.value); Variable var; var.name = "Static members"; @@ -443,7 +450,7 @@ HRESULT Debugger::Evaluate(uint64_t frameId, const std::string &expression, Vari IfFailRet(GetFrameAt(pThread, stackFrame.GetLevel(), &pFrame)); ToRelease pResultValue; - IfFailRet(EvalExpr(pThread, pFrame, expression, &pResultValue)); + IfFailRet(m_evaluator.EvalExpr(pThread, pFrame, expression, &pResultValue)); variable.evaluateName = expression; -- 2.7.4