From 46acad49d4650cf3cc774ae7f48d03981e914525 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Wed, 27 Jan 2021 18:02:54 -0300 Subject: [PATCH 01/64] Implementing mscordbi on mono to support icordebug --- src/mono/CMakeLists.txt | 1 + src/mono/dbi/CMakeLists.txt | 221 ++ src/mono/dbi/cordb-appdomain.cpp | 292 +++ src/mono/dbi/cordb-appdomain.h | 98 + src/mono/dbi/cordb-assembly.cpp | 335 +++ src/mono/dbi/cordb-assembly.h | 112 + src/mono/dbi/cordb-blocking-obj.cpp | 62 + src/mono/dbi/cordb-blocking-obj.h | 27 + src/mono/dbi/cordb-breakpoint.cpp | 86 + src/mono/dbi/cordb-breakpoint.h | 30 + src/mono/dbi/cordb-chain.cpp | 164 ++ src/mono/dbi/cordb-chain.h | 62 + src/mono/dbi/cordb-class.cpp | 84 + src/mono/dbi/cordb-class.h | 35 + src/mono/dbi/cordb-code.cpp | 123 ++ src/mono/dbi/cordb-code.h | 43 + src/mono/dbi/cordb-eval.cpp | 232 ++ src/mono/dbi/cordb-eval.h | 65 + src/mono/dbi/cordb-frame.cpp | 475 ++++ src/mono/dbi/cordb-frame.h | 134 ++ src/mono/dbi/cordb-function.cpp | 179 ++ src/mono/dbi/cordb-function.h | 52 + src/mono/dbi/cordb-process.cpp | 453 ++++ src/mono/dbi/cordb-process.h | 152 ++ src/mono/dbi/cordb-register.cpp | 69 + src/mono/dbi/cordb-register.h | 39 + src/mono/dbi/cordb-stepper.cpp | 124 ++ src/mono/dbi/cordb-stepper.h | 37 + src/mono/dbi/cordb-symbol.cpp | 2752 ++++++++++++++++++++++++ src/mono/dbi/cordb-symbol.h | 671 ++++++ src/mono/dbi/cordb-thread.cpp | 266 +++ src/mono/dbi/cordb-thread.h | 77 + src/mono/dbi/cordb-type.cpp | 162 ++ src/mono/dbi/cordb-type.h | 54 + src/mono/dbi/cordb-value.cpp | 1079 ++++++++++ src/mono/dbi/cordb-value.h | 232 ++ src/mono/dbi/cordb.cpp | 663 ++++++ src/mono/dbi/cordb.h | 206 ++ src/mono/mono/mini/debugger-agent.c | 37 +- src/mono/mono/mini/debugger-protocol.h | 3 +- 40 files changed, 9976 insertions(+), 12 deletions(-) create mode 100644 src/mono/dbi/CMakeLists.txt create mode 100644 src/mono/dbi/cordb-appdomain.cpp create mode 100644 src/mono/dbi/cordb-appdomain.h create mode 100644 src/mono/dbi/cordb-assembly.cpp create mode 100644 src/mono/dbi/cordb-assembly.h create mode 100644 src/mono/dbi/cordb-blocking-obj.cpp create mode 100644 src/mono/dbi/cordb-blocking-obj.h create mode 100644 src/mono/dbi/cordb-breakpoint.cpp create mode 100644 src/mono/dbi/cordb-breakpoint.h create mode 100644 src/mono/dbi/cordb-chain.cpp create mode 100644 src/mono/dbi/cordb-chain.h create mode 100644 src/mono/dbi/cordb-class.cpp create mode 100644 src/mono/dbi/cordb-class.h create mode 100644 src/mono/dbi/cordb-code.cpp create mode 100644 src/mono/dbi/cordb-code.h create mode 100644 src/mono/dbi/cordb-eval.cpp create mode 100644 src/mono/dbi/cordb-eval.h create mode 100644 src/mono/dbi/cordb-frame.cpp create mode 100644 src/mono/dbi/cordb-frame.h create mode 100644 src/mono/dbi/cordb-function.cpp create mode 100644 src/mono/dbi/cordb-function.h create mode 100644 src/mono/dbi/cordb-process.cpp create mode 100644 src/mono/dbi/cordb-process.h create mode 100644 src/mono/dbi/cordb-register.cpp create mode 100644 src/mono/dbi/cordb-register.h create mode 100644 src/mono/dbi/cordb-stepper.cpp create mode 100644 src/mono/dbi/cordb-stepper.h create mode 100644 src/mono/dbi/cordb-symbol.cpp create mode 100644 src/mono/dbi/cordb-symbol.h create mode 100644 src/mono/dbi/cordb-thread.cpp create mode 100644 src/mono/dbi/cordb-thread.h create mode 100644 src/mono/dbi/cordb-type.cpp create mode 100644 src/mono/dbi/cordb-type.h create mode 100644 src/mono/dbi/cordb-value.cpp create mode 100644 src/mono/dbi/cordb-value.h create mode 100644 src/mono/dbi/cordb.cpp create mode 100644 src/mono/dbi/cordb.h diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 69b00b3b333ed0..c1a08024f38f97 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -683,6 +683,7 @@ endif() ### End of OS specific checks add_subdirectory(mono) +add_subdirectory(dbi) configure_file(cmake/config.h.in config.h) configure_file(cmake/eglib-config.h.cmake.in mono/eglib/eglib-config.h) # TODO: eglib-config.h is not needed, we're using hardcoded eglib-config.hw diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt new file mode 100644 index 00000000000000..ad169aaf4a993d --- /dev/null +++ b/src/mono/dbi/CMakeLists.txt @@ -0,0 +1,221 @@ +project(mscordbi) + + +include_directories( + ${PROJECT_BINARY_DIR}/ + ${PROJECT_BINARY_DIR}/../.. + ${PROJECT_BINARY_DIR}/../mono/eglib + ${CMAKE_CURRENT_SOURCE_DIR}/../.. + ${CMAKE_CURRENT_BINARY_DIR}/../ + ${PROJECT_SOURCE_DIR}/../mono/mini/ + ${PROJECT_SOURCE_DIR}/../ + ${PROJECT_SOURCE_DIR}/../mono/eglib + ${PROJECT_SOURCE_DIR}/../dbi + ${PROJECT_SOURCE_DIR}/../../coreclr/md/enc + ${PROJECT_SOURCE_DIR}/../../coreclr/inc + ${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/inc + ${PROJECT_SOURCE_DIR}/../../coreclr/md/inc + ${PROJECT_SOURCE_DIR}/../../coreclr/md/compiler) + + +include(../mono/eglib/CMakeLists.txt) + + +set(UTILCODE_COMMON_SOURCES_BASE + clrhost_nodependencies.cpp + ccomprc.cpp + ex.cpp + sbuffer.cpp + sstring_com.cpp + fstring.cpp + namespaceutil.cpp + makepath.cpp + splitpath.cpp + clrconfig.cpp + configuration.cpp + collections.cpp + posterror.cpp + fstream.cpp + clrhelpers.cpp + stgpool.cpp + stgpooli.cpp + stgpoolreadonly.cpp + utsem.cpp + peinformation.cpp + check.cpp + log.cpp + arraylist.cpp + bitvector.cpp + comex.cpp + guidfromname.cpp + memorypool.cpp + iallocator.cpp + loaderheap.cpp + outstring.cpp + ilformatter.cpp + opinfo.cpp + corimage.cpp + format1.cpp + prettyprintsig.cpp + regutil.cpp + sha1.cpp + sigbuilder.cpp + sigparser.cpp + sstring.cpp + util_nodependencies.cpp + utilmessagebox.cpp + safewrap.cpp + clrhost.cpp + cycletimer.cpp + md5.cpp + util.cpp + stresslog.cpp + debug.cpp + pedecoder.cpp + winfix.cpp + longfilepathwrappers.cpp + yieldprocessornormalized.cpp + hostimpl.cpp +) + +set(MDRUNTIMERW_SOURCES_BASE + md/enc/liteweightstgdbrw.cpp + md/enc/metamodelenc.cpp + md/enc/metamodelrw.cpp + md/enc/peparse.cpp + md/enc/rwutil.cpp + md/enc/stgio.cpp + md/enc/stgtiggerstorage.cpp + md/enc/stgtiggerstream.cpp + md/enc/mdinternalrw.cpp + md/enc/pdbheap.cpp + md/compiler/importhelper.cpp + md/runtime/metamodel.cpp + md/runtime/mdcolumndescriptors.cpp + md/runtime/recordpool.cpp + md/runtime/mdfileformat.cpp +) + +set(MDRUNTIMERW_HEADERS_BASE + inc/corhdr.h + inc/metadata.h + inc/mdfileformat.h + inc/pedecoder.h + inc/pedecoder.inl + inc/posterror.h + inc/sstring.h + inc/sstring.inl + md/compiler/importhelper.h + md/compiler/regmeta.h + md/hotdata/hotdataformat.h + md/inc/liteweightstgdb.h + md/inc/mdinternalrw.h + md/inc/mdlog.h + md/inc/metadatahash.h + md/inc/metamodel.h + md/inc/metamodelro.h + md/inc/metamodelrw.h + md/inc/pdbheap.h + md/inc/portablepdbmdds.h + md/inc/portablepdbmdi.h + md/inc/rwutil.h + md/inc/stgio.h + md/inc/stgtiggerstorage.h + md/inc/stgtiggerstream.h + md/inc/streamutil.h + md/runtime/mdinternalro.h + inc/debugmacros.h +) + +set(mscorbi_sources_base + cordb.cpp + cordb.h + cordb-appdomain.cpp + cordb-appdomain.h + cordb-assembly.cpp + cordb-assembly.h + cordb-blocking-obj.cpp + cordb-blocking-obj.h + cordb-breakpoint.cpp + cordb-breakpoint.h + cordb-chain.cpp + cordb-chain.h + cordb-class.cpp + cordb-class.h + cordb-code.cpp + cordb-code.h + cordb-eval.cpp + cordb-eval.h + cordb-frame.cpp + cordb-frame.h + cordb-function.cpp + cordb-function.h + cordb-process.cpp + cordb-process.h + cordb-register.cpp + cordb-register.h + cordb-stepper.cpp + cordb-stepper.h + cordb-symbol.cpp + cordb-symbol.h + cordb-thread.cpp + cordb-thread.h + cordb-type.cpp + cordb-type.h + cordb-value.cpp + cordb-value.h +) + +if(HOST_WIN32) +set(OS_LIBS bcrypt.lib Mswsock.lib ws2_32.lib psapi.lib version.lib advapi32.lib winmm.lib kernel32.lib) +endif() + + +if(HOST_WIN32) + list(APPEND UTILCODE_COMMON_SOURCES_BASE + dacutil.cpp + dlwrap.cpp + securitywrapper.cpp + securityutil.cpp + stacktrace.cpp + ) +endif(HOST_WIN32) + +addprefix(mscorbi_sources ../dbi/ "${mscorbi_sources_base}") +addprefix(UTILCODE_COMMON_SOURCES ${PROJECT_SOURCE_DIR}/../../coreclr/utilcode/ "${UTILCODE_COMMON_SOURCES_BASE}") +addprefix(MDRUNTIMERW_SOURCES ${PROJECT_SOURCE_DIR}/../../coreclr/ "${MDRUNTIMERW_SOURCES_BASE}") +addprefix(MDRUNTIMERW_HEADERS ${PROJECT_SOURCE_DIR}/../../coreclr/ "${MDRUNTIMERW_HEADERS_BASE}") +addprefix(eglib_sources ../mono/eglib/ "${eglib_sources}") + +add_library(mscordbi SHARED "${eglib_sources};${mscorbi_sources};${PROJECT_SOURCE_DIR}/../mono/mini/debugger-protocol.c;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/xcordebug_i.cpp;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/cordebug_i.cpp") + +add_library(mdruntimerw-dbi STATIC "${MDRUNTIMERW_SOURCES};${MDRUNTIMERW_HEADERS}") +add_library(utilcode STATIC "${UTILCODE_COMMON_SOURCES}") + + +target_link_libraries(mscordbi mdruntimerw-dbi utilcode ${OS_LIBS}) + +set(TARGET_AMD64 1) +add_compile_definitions(TARGET_AMD64) +add_compile_definitions(DBI_COMPONENT) +add_compile_definitions(HOST_WINDOWS) +add_compile_definitions(HOST_64BIT) +add_compile_definitions(FEATURE_COMINTEROP) +add_compile_definitions(SELF_NO_HOST) + + +target_precompile_headers(mdruntimerw-dbi PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/md/enc/stdafx.h) +target_precompile_headers(utilcode PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/utilcode/stdafx.h) + + +if(HOST_WIN32) +target_compile_definitions(utilcode PRIVATE _CRTIMP=) +endif(HOST_WIN32) + +SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER}) +SET_TARGET_PROPERTIES(mdruntimerw-dbi PROPERTIES LINKER_LANGUAGE CXX) +SET_TARGET_PROPERTIES(utilcode PROPERTIES LINKER_LANGUAGE CXX) + +set_target_properties(mdruntimerw-dbi PROPERTIES DBI_COMPONENT TRUE) + +set_source_files_properties(${PROJECT_SOURCE_DIR}/../mono/mini/debugger-protocol.c PROPERTIES LANGUAGE CXX) diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp new file mode 100644 index 00000000000000..531be2075866f3 --- /dev/null +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -0,0 +1,292 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-APPDOMAIN.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbAppDomain::CordbAppDomain(Connection *conn, ICorDebugProcess *ppProcess) + : CordbBaseMono(conn) { + pProcess = ppProcess; + g_ptr_array_add(((CordbProcess *)(ppProcess))->appdomains, this); +} + +HRESULT CordbAppDomain::Stop(/* [in] */ DWORD dwTimeoutIgnored) { + DEBUG_PRINTF(1, "CordbAppDomain - Stop - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::Continue(/* [in] */ BOOL fIsOutOfBand) { + DEBUG_PRINTF(1, "CordbAppDomain - Continue - NOT IMPLEMENTED\n"); + + pProcess->Continue(fIsOutOfBand); + return S_OK; +} + +HRESULT CordbAppDomain::IsRunning(/* [out] */ BOOL *pbRunning) { + DEBUG_PRINTF(1, "CordbAppDomain - IsRunning - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::HasQueuedCallbacks(/* [in] */ ICorDebugThread *pThread, + /* [out] */ BOOL *pbQueued) { + DEBUG_PRINTF(1, "CordbAppDomain - HasQueuedCallbacks - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT +CordbAppDomain::EnumerateThreads(/* [out] */ ICorDebugThreadEnum **ppThreads) { + DEBUG_PRINTF(1, "CordbAppDomain - EnumerateThreads - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::SetAllThreadsDebugState( + /* [in] */ CorDebugThreadState state, /* [in] */ + ICorDebugThread *pExceptThisThread) { + DEBUG_PRINTF(1, + "CordbAppDomain - SetAllThreadsDebugState - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::Detach(void) { + DEBUG_PRINTF(1, "CordbAppDomain - Detach - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::Terminate(/* [in] */ UINT exitCode) { + DEBUG_PRINTF(1, "CordbAppDomain - Terminate - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::CanCommitChanges( + /* [in] */ ULONG cSnapshots, /* [size_is][in] */ + ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + ICorDebugErrorInfoEnum **pError) { + DEBUG_PRINTF(1, "CordbAppDomain - CanCommitChanges - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::CommitChanges( + /* [in] */ ULONG cSnapshots, /* [size_is][in] */ + ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + ICorDebugErrorInfoEnum **pError) { + DEBUG_PRINTF(1, "CordbAppDomain - CommitChanges - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::QueryInterface( + /* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { + if (id == IID_ICorDebugAppDomain) { + *ppInterface = (ICorDebugAppDomain *)this; + } else if (id == IID_ICorDebugAppDomain2) { + *ppInterface = (ICorDebugAppDomain2 *)this; + } else if (id == IID_ICorDebugAppDomain3) { + *ppInterface = (ICorDebugAppDomain3 *)this; + } else if (id == IID_ICorDebugAppDomain4) { + *ppInterface = (ICorDebugAppDomain4 *)this; + } else if (id == IID_ICorDebugController) + *ppInterface = (ICorDebugController *)(ICorDebugAppDomain *)this; + else if (id == IID_IUnknown) + *ppInterface = (IUnknown *)(ICorDebugAppDomain *)this; + else { + DEBUG_PRINTF(1, "CordbAppDomain - QueryInterface - E_NOTIMPL\n"); + + *ppInterface = NULL; + return E_NOINTERFACE; + } + return S_OK; +} + +ULONG CordbAppDomain::AddRef(void) { return S_OK; } + +ULONG CordbAppDomain::Release(void) { return S_OK; } + +HRESULT CordbAppDomain::GetProcess( + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "CordbAppDomain - GetProcess - NOT IMPLEMENTED\n"); + + *ppProcess = pProcess; + return S_OK; +} + +HRESULT CordbAppDomain::EnumerateAssemblies( + /* [out] */ ICorDebugAssemblyEnum **ppAssemblies) { + DEBUG_PRINTF(1, "CordbAppDomain - EnumerateAssemblies - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::GetModuleFromMetaDataInterface( + /* [in] */ IUnknown *pIMetaData, /* [out] */ + ICorDebugModule **ppModule) { + DEBUG_PRINTF( + 1, "CordbAppDomain - GetModuleFromMetaDataInterface - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::EnumerateBreakpoints( + /* [out] */ ICorDebugBreakpointEnum **ppBreakpoints) { + DEBUG_PRINTF(1, "CordbAppDomain - EnumerateBreakpoints - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::EnumerateSteppers( + /* [out] */ ICorDebugStepperEnum **ppSteppers) { + DEBUG_PRINTF(1, "CordbAppDomain - EnumerateSteppers - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::IsAttached(/* [out] */ BOOL *pbAttached) { + DEBUG_PRINTF(1, "CordbAppDomain - IsAttached - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT +CordbAppDomain::GetName(/* [in] */ ULONG32 cchName, + /* [out] */ ULONG32 *pcchName, + /* [length_is][size_is][out] */ WCHAR szName[]) { + DEBUG_PRINTF(1, "CordbAppDomain - GetName - IMPLEMENTED\n"); + if (cchName < strlen("DefaultDomain")) { + *pcchName = strlen("DefaultDomain") + 1; + return S_OK; + } + wcscpy(szName, L"DefaultDomain"); + + return S_OK; +} + +HRESULT CordbAppDomain::GetObject(/* [out] */ ICorDebugValue **ppObject) { + DEBUG_PRINTF(1, "CordbAppDomain - GetObject - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::Attach(void) { + DEBUG_PRINTF(1, "CordbAppDomain - Attach - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::GetID(/* [out] */ ULONG32 *pId) { + *pId = 0; + DEBUG_PRINTF(1, "CordbAppDomain - GetID - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::GetArrayOrPointerType( + /* [in] */ CorElementType elementType, /* [in] */ ULONG32 nRank, + /* [in] */ + ICorDebugType *pTypeArg, /* [out] */ ICorDebugType **ppType) { + DEBUG_PRINTF(1, "CordbAppDomain - GetArrayOrPointerType - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::GetFunctionPointerType( + /* [in] */ ULONG32 nTypeArgs, /* [size_is][in] */ + ICorDebugType *ppTypeArgs[], /* [out] */ + ICorDebugType **ppType) { + DEBUG_PRINTF(1, + "CordbAppDomain - GetFunctionPointerType - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::GetCachedWinRTTypesForIIDs( + /* [in] */ ULONG32 cReqTypes, /* [size_is][in] */ + GUID *iidsToResolve, /* [out] */ + ICorDebugTypeEnum **ppTypesEnum) { + DEBUG_PRINTF( + 1, "CordbAppDomain - GetCachedWinRTTypesForIIDs - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAppDomain::GetCachedWinRTTypes( + /* [out] */ ICorDebugGuidToTypeEnum **ppGuidToTypeEnum) { + DEBUG_PRINTF(1, "CordbAppDomain - GetCachedWinRTTypes - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT +CordbAppDomain::GetObjectForCCW(/* [in] */ CORDB_ADDRESS ccwPointer, /* [out] */ + ICorDebugValue **ppManagedObject) { + DEBUG_PRINTF(1, "CordbAppDomain - GetObjectForCCW - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, + ICorDebugAppDomain *values[], + ULONG *pceltFetched) { + DEBUG_PRINTF(1, "CordbAppDomainEnum - Next - NOT IMPLEMENTED\n"); + *pceltFetched = celt; + for (int i = 0; i < celt; i++) { + if (current_pos >= pProcess->appdomains->len) { + *pceltFetched = 0; + return S_FALSE; + } + CordbAppDomain *appdomain = + (CordbAppDomain *)g_ptr_array_index(pProcess->appdomains, current_pos); + appdomain->QueryInterface(IID_ICorDebugAppDomain, + (void **)values + current_pos); + current_pos++; + } + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Skip(ULONG celt) { + DEBUG_PRINTF(1, "CordbAppDomainEnum - Skip - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Reset(void) { + current_pos = 0; + DEBUG_PRINTF(1, "CordbAppDomainEnum - Reset - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Clone(ICorDebugEnum **ppEnum) { + DEBUG_PRINTF(1, "CordbAppDomainEnum - Clone - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::GetCount(ULONG *pcelt) { + DEBUG_PRINTF(1, "CordbAppDomainEnum - GetCount - IMPLEMENTED\n"); + *pcelt = pProcess->appdomains->len; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbAppDomainEnum::QueryInterface(REFIID id, void **pInterface) { + if (id == IID_IUnknown) + *pInterface = + static_cast(static_cast(this)); + else if (id == IID_ICorDebugAppDomainEnum) + *pInterface = static_cast(this); + else if (id == IID_ICorDebugEnum) + *pInterface = static_cast(this); + else { + DEBUG_PRINTF(1, "CordbAppDomain - QueryInterface - NOT IMPLEMENTED\n"); + return E_NOINTERFACE; + } + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbAppDomainEnum::AddRef(void) { return 1; } + +ULONG STDMETHODCALLTYPE CordbAppDomainEnum::Release(void) { return 1; } + +CordbAppDomainEnum::CordbAppDomainEnum(Connection *conn, + CordbProcess *ppProcess) + : CordbBaseMono(conn) { + current_pos = 0; + this->pProcess = ppProcess; +} diff --git a/src/mono/dbi/cordb-appdomain.h b/src/mono/dbi/cordb-appdomain.h new file mode 100644 index 00000000000000..a1a360d87f27aa --- /dev/null +++ b/src/mono/dbi/cordb-appdomain.h @@ -0,0 +1,98 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-APPDOMAIN.H +// + +#ifndef __MONO_DEBUGGER_CORDB_APPDOMAIN_H__ +#define __MONO_DEBUGGER_CORDB_APPDOMAIN_H__ + +#include + +class CordbAppDomain : public CordbBaseMono, + public ICorDebugAppDomain, + public ICorDebugAppDomain2, + public ICorDebugAppDomain3, + public ICorDebugAppDomain4 { +public: + CordbAppDomain(Connection *conn, ICorDebugProcess *ppProcess); + ICorDebugProcess *pProcess; + HRESULT STDMETHODCALLTYPE Stop(/* [in] */ DWORD dwTimeoutIgnored); + HRESULT STDMETHODCALLTYPE Continue(/* [in] */ BOOL fIsOutOfBand); + HRESULT STDMETHODCALLTYPE IsRunning(/* [out] */ BOOL *pbRunning); + HRESULT STDMETHODCALLTYPE HasQueuedCallbacks( + /* [in] */ ICorDebugThread *pThread, /* [out] */ BOOL *pbQueued); + HRESULT STDMETHODCALLTYPE + EnumerateThreads(/* [out] */ ICorDebugThreadEnum **ppThreads); + HRESULT STDMETHODCALLTYPE + SetAllThreadsDebugState(/* [in] */ CorDebugThreadState state, /* [in] */ + ICorDebugThread *pExceptThisThread); + HRESULT STDMETHODCALLTYPE Detach(void); + HRESULT STDMETHODCALLTYPE Terminate(/* [in] */ UINT exitCode); + HRESULT STDMETHODCALLTYPE + CanCommitChanges(/* [in] */ ULONG cSnapshots, /* [size_is][in] */ + ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + ICorDebugErrorInfoEnum **pError); + HRESULT STDMETHODCALLTYPE + CommitChanges(/* [in] */ ULONG cSnapshots, /* [size_is][in] */ + ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + ICorDebugErrorInfoEnum **pError); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE + GetProcess(/* [out] */ ICorDebugProcess **ppProcess); + HRESULT STDMETHODCALLTYPE + EnumerateAssemblies(/* [out] */ ICorDebugAssemblyEnum **ppAssemblies); + HRESULT STDMETHODCALLTYPE GetModuleFromMetaDataInterface( + /* [in] */ IUnknown *pIMetaData, /* [out] */ ICorDebugModule **ppModule); + HRESULT STDMETHODCALLTYPE + EnumerateBreakpoints(/* [out] */ ICorDebugBreakpointEnum **ppBreakpoints); + HRESULT STDMETHODCALLTYPE + EnumerateSteppers(/* [out] */ ICorDebugStepperEnum **ppSteppers); + HRESULT STDMETHODCALLTYPE IsAttached(/* [out] */ BOOL *pbAttached); + HRESULT STDMETHODCALLTYPE + GetName(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, + /* [length_is][size_is][out] */ WCHAR szName[]); + HRESULT STDMETHODCALLTYPE GetObject(/* [out] */ ICorDebugValue **ppObject); + HRESULT STDMETHODCALLTYPE Attach(void); + HRESULT STDMETHODCALLTYPE GetID(/* [out] */ ULONG32 *pId); + HRESULT STDMETHODCALLTYPE GetArrayOrPointerType( + /* [in] */ CorElementType elementType, /* [in] */ ULONG32 nRank, + /* [in] */ ICorDebugType *pTypeArg, /* [out] */ + ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE + GetFunctionPointerType(/* [in] */ ULONG32 nTypeArgs, /* [size_is][in] */ + ICorDebugType *ppTypeArgs[], /* [out] */ + ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE + GetCachedWinRTTypesForIIDs(/* [in] */ ULONG32 cReqTypes, /* [size_is][in] */ + GUID *iidsToResolve, /* [out] */ + ICorDebugTypeEnum **ppTypesEnum); + HRESULT STDMETHODCALLTYPE + GetCachedWinRTTypes(/* [out] */ ICorDebugGuidToTypeEnum **ppGuidToTypeEnum); + HRESULT STDMETHODCALLTYPE + GetObjectForCCW(/* [in] */ CORDB_ADDRESS ccwPointer, /* [out] */ + ICorDebugValue **ppManagedObject); +}; + +class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum { + int current_pos; + CordbProcess *pProcess; + +public: + CordbAppDomainEnum(Connection *conn, CordbProcess *ppProcess); + HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugAppDomain *values[], + ULONG *pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum **ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG *pcelt); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp new file mode 100644 index 00000000000000..c1b5535ef4cf9e --- /dev/null +++ b/src/mono/dbi/cordb-assembly.cpp @@ -0,0 +1,335 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-ASSEMBLY.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbAssembly::CordbAssembly(Connection *conn, CordbProcess *process, + CordbAppDomain *appDomain, int id_assembly) + : CordbBaseMono(conn) { + pProcess = process; + pAppDomain = appDomain; + id = id_assembly; +} + +HRESULT CordbAssembly::IsFullyTrusted(/* [out] */ BOOL *pbFullyTrusted) { + *pbFullyTrusted = true; + DEBUG_PRINTF(1, "CorDebugAssembly - IsFullyTrusted - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAssembly::GetAppDomain( + /* [out] */ ICorDebugAppDomain **ppAppDomain) { + DEBUG_PRINTF(1, "CorDebugAssembly - GetAppDomain - IMPLEMENTED\n"); + *ppAppDomain = static_cast(pAppDomain); + return S_OK; +} + +HRESULT CordbAssembly::EnumerateModules( + /* [out] */ ICorDebugModuleEnum **ppModules) { + DEBUG_PRINTF(1, "CorDebugAssembly - EnumerateModules - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAssembly::GetCodeBase( + /* [in] */ ULONG32 cchName, + /* [out] */ ULONG32 *pcchName, + /* [length_is][size_is][out] */ WCHAR szName[]) { + DEBUG_PRINTF(1, "CorDebugAssembly - GetCodeBase - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAssembly::GetName( + /* [in] */ ULONG32 cchName, + /* [out] */ ULONG32 *pcchName, + /* [length_is][size_is][out] */ WCHAR szName[]) { + DEBUG_PRINTF(1, "CorDebugAssembly - GetName - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbAssembly::QueryInterface( + /* [in] */ REFIID id, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { + if (id == IID_ICorDebugAssembly) + *ppInterface = static_cast(this); + else if (id == IID_ICorDebugAssembly2) + *ppInterface = static_cast(this); + else if (id == IID_IUnknown) + *ppInterface = + static_cast(static_cast(this)); + else { + DEBUG_PRINTF(1, "CordbAssembly - QueryInterface - E_NOTIMPL\n"); + + *ppInterface = NULL; + return E_NOINTERFACE; + } + + return S_OK; +} + +ULONG CordbAssembly::AddRef(void) { return S_OK; } + +ULONG CordbAssembly::Release(void) { return S_OK; } + +CordbModule::CordbModule(Connection *conn, CordbProcess *process, + CordbAssembly *assembly, int id_assembly) + : CordbBaseMono(conn) { + pProcess = process; + pCordbSymbol = NULL; + pAssembly = assembly; + id = id_assembly; + dwFlags = 0; +} + +HRESULT CordbModule::QueryInterface(REFIID id, void **pInterface) { + if (id == IID_ICorDebugModule) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugModule2) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugModule3) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugModule4) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = static_cast(static_cast(this)); + } else { + DEBUG_PRINTF(1, "CordbModule - QueryInterface - E_NOTIMPL\n"); + + *pInterface = NULL; + return E_NOINTERFACE; + } + return S_OK; +} + +ULONG CordbModule::AddRef(void) { return S_OK; } + +ULONG CordbModule::Release(void) { return S_OK; } + +HRESULT CordbModule::IsMappedLayout( + /* [out] */ BOOL *pIsMapped) { + *pIsMapped = FALSE; + DEBUG_PRINTF(1, "CordbModule - IsMappedLayout - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::CreateReaderForInMemorySymbols( + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppObj) { + DEBUG_PRINTF( + 1, "CordbModule - CreateReaderForInMemorySymbols - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::SetJMCStatus( + /* [in] */ BOOL bIsJustMyCode, + /* [in] */ ULONG32 cTokens, + /* [size_is][in] */ mdToken pTokens[]) { + DEBUG_PRINTF(1, "CordbModule - SetJMCStatus - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::ApplyChanges( + /* [in] */ ULONG cbMetadata, + /* [size_is][in] */ BYTE pbMetadata[], + /* [in] */ ULONG cbIL, + /* [size_is][in] */ BYTE pbIL[]) { + DEBUG_PRINTF(1, "CordbModule - ApplyChanges - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::SetJITCompilerFlags( + /* [in] */ DWORD dwFlags) { + this->dwFlags = dwFlags; + DEBUG_PRINTF(1, "CordbModule - SetJITCompilerFlags - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetJITCompilerFlags( + /* [out] */ DWORD *pdwFlags) { + *pdwFlags = dwFlags; + DEBUG_PRINTF(1, "CordbModule - GetJITCompilerFlags - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::ResolveAssembly( + /* [in] */ mdToken tkAssemblyRef, + /* [out] */ ICorDebugAssembly **ppAssembly) { + DEBUG_PRINTF(1, "CordbModule - ResolveAssembly - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetProcess( + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "CordbModule - GetProcess - NOT IMPLEMENTED\n"); + // *ppProcess = pProcess; + return S_OK; +} + +HRESULT CordbModule::GetBaseAddress( + /* [out] */ CORDB_ADDRESS *pAddress) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, id); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, + &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + assembly_metadata_blob = m_dbgprot_decode_byte_array( + bAnswer->buf, &bAnswer->buf, bAnswer->end, &assembly_metadata_len); + + DEBUG_PRINTF(1, "CordbModule - GetBaseAddress\n"); + + *pAddress = (CORDB_ADDRESS)assembly_metadata_blob; + return S_OK; +} + +HRESULT CordbModule::GetName( + /* [in] */ ULONG32 cchName, + /* [out] */ ULONG32 *pcchName, + /* [length_is][size_is][out] */ WCHAR szName[]) { + DEBUG_PRINTF(1, "CordbModule - GetName - IMPLEMENTED\n"); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, id); + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + char *assembly_name = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + DEBUG_PRINTF(1, "CordbModule - assembly_name - %d - %s\n", id, assembly_name); + + if (cchName < strlen(assembly_name) + 1) { + *pcchName = strlen(assembly_name) + 1; + g_free(assembly_name); + return S_OK; + } + mbstowcs(szName, assembly_name, strlen(assembly_name) + 1); + *pcchName = strlen(assembly_name) + 1; + g_free(assembly_name); + return S_OK; +} + +HRESULT CordbModule::EnableJITDebugging( + /* [in] */ BOOL bTrackJITInfo, + /* [in] */ BOOL bAllowJitOpts) { + DEBUG_PRINTF(1, "CordbModule - EnableJITDebugging - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::EnableClassLoadCallbacks( + /* [in] */ BOOL bClassLoadCallbacks) { + DEBUG_PRINTF(1, "CordbModule - EnableClassLoadCallbacks - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetFunctionFromToken( + /* [in] */ mdMethodDef methodDef, + /* [out] */ ICorDebugFunction **ppFunction) { + // check in a cache before talk to mono runtime to get info + DEBUG_PRINTF(1, "CordbModule - GetFunctionFromToken - IMPLEMENTED\n"); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, id); + m_dbgprot_buffer_add_int(&localbuf, methodDef); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, + MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + int id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + CordbFunction *func = NULL; + func = pProcess->cordb->findFunction(id); + if (func == NULL) { + func = new CordbFunction(conn, methodDef, id, this); + g_ptr_array_add(pProcess->cordb->functions, func); + } + *ppFunction = func; + return S_OK; +} + +HRESULT CordbModule::GetFunctionFromRVA( + /* [in] */ CORDB_ADDRESS rva, + /* [out] */ ICorDebugFunction **ppFunction) { + DEBUG_PRINTF(1, "CordbModule - GetFunctionFromRVA - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetClassFromToken( + /* [in] */ mdTypeDef typeDef, + /* [out] */ ICorDebugClass **ppClass) { + CordbClass *pClass = new CordbClass(conn, typeDef, id); + *ppClass = static_cast(pClass); + return S_OK; +} + +HRESULT CordbModule::CreateBreakpoint( + /* [out] */ ICorDebugModuleBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, "CordbModule - CreateBreakpoint - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetEditAndContinueSnapshot( + /* [out] */ ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot) { + DEBUG_PRINTF(1, + "CordbModule - GetEditAndContinueSnapshot - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetMetaDataInterface( + /* [in] */ REFIID riid, + /* [out] */ IUnknown **ppObj) { + if (pCordbSymbol == NULL) + pCordbSymbol = new RegMeta(pAssembly, this); + pCordbSymbol->QueryInterface(riid, (void **)ppObj); + DEBUG_PRINTF(1, "CordbModule - GetMetaDataInterface - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetToken( + /* [out] */ mdModule *pToken) { + DEBUG_PRINTF(1, "CordbModule - GetToken - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::IsDynamic( + /* [out] */ BOOL *pDynamic) { + DEBUG_PRINTF(1, "CordbModule - IsDynamic - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetGlobalVariableValue( + /* [in] */ mdFieldDef fieldDef, + /* [out] */ ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbModule - GetGlobalVariableValue - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbModule::GetSize( + /* [out] */ ULONG32 *pcBytes) { + DEBUG_PRINTF(1, "CordbModule - GetSize -IMPLEMENTED\n"); + *pcBytes = assembly_metadata_len; + return S_OK; +} + +HRESULT CordbModule::IsInMemory( + /* [out] */ BOOL *pInMemory) { + DEBUG_PRINTF(1, "CordbModule - IsInMemory - IMPLEMENTED\n"); + return S_OK; +} diff --git a/src/mono/dbi/cordb-assembly.h b/src/mono/dbi/cordb-assembly.h new file mode 100644 index 00000000000000..7f917195db64c5 --- /dev/null +++ b/src/mono/dbi/cordb-assembly.h @@ -0,0 +1,112 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-ASSEMBLY.H +// + +#ifndef __MONO_DEBUGGER_CORDB_ASSEMBLY_H__ +#define __MONO_DEBUGGER_CORDB_ASSEMBLY_H__ + +#include + +class CordbModule : public CordbBaseMono, + public ICorDebugModule, + public ICorDebugModule2, + public ICorDebugModule3, + public ICorDebugModule4 { +public: + int id; // id on mono side; + CordbProcess *pProcess; + RegMeta *pCordbSymbol; + CordbAssembly *pAssembly; + guint8 *assembly_metadata_blob; + guint32 assembly_metadata_len; + unsigned long dwFlags; + + CordbModule(Connection *conn, CordbProcess *process, CordbAssembly *assembly, + int id_assembly); + + HRESULT CordbModule::QueryInterface(REFIID id, void **pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE IsMappedLayout(/* [out] */ BOOL *pIsMapped); + HRESULT STDMETHODCALLTYPE CreateReaderForInMemorySymbols( + /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObj); + HRESULT STDMETHODCALLTYPE + SetJMCStatus(/* [in] */ BOOL bIsJustMyCode, + /* [in] */ ULONG32 cTokens, /* [size_is][in] */ + mdToken pTokens[]); + HRESULT STDMETHODCALLTYPE + ApplyChanges(/* [in] */ ULONG cbMetadata, + /* [size_is][in] */ BYTE pbMetadata[], /* [in] */ + ULONG cbIL, /* [size_is][in] */ BYTE pbIL[]); + HRESULT STDMETHODCALLTYPE SetJITCompilerFlags(/* [in] */ DWORD dwFlags); + HRESULT STDMETHODCALLTYPE GetJITCompilerFlags(/* [out] */ DWORD *pdwFlags); + HRESULT STDMETHODCALLTYPE + ResolveAssembly(/* [in] */ mdToken tkAssemblyRef, /* [out] */ + ICorDebugAssembly **ppAssembly); + HRESULT STDMETHODCALLTYPE + GetProcess(/* [out] */ ICorDebugProcess **ppProcess); + HRESULT STDMETHODCALLTYPE GetBaseAddress(/* [out] */ CORDB_ADDRESS *pAddress); + HRESULT STDMETHODCALLTYPE + GetAssembly(/* [out] */ ICorDebugAssembly **ppAssembly); + HRESULT STDMETHODCALLTYPE + GetName(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, + /* [length_is][size_is][out] */ WCHAR szName[]); + HRESULT STDMETHODCALLTYPE EnableJITDebugging(/* [in] */ BOOL bTrackJITInfo, + /* [in] */ BOOL bAllowJitOpts); + HRESULT STDMETHODCALLTYPE + EnableClassLoadCallbacks(/* [in] */ BOOL bClassLoadCallbacks); + HRESULT STDMETHODCALLTYPE + GetFunctionFromToken(/* [in] */ mdMethodDef methodDef, /* [out] */ + ICorDebugFunction **ppFunction); + HRESULT STDMETHODCALLTYPE + GetFunctionFromRVA(/* [in] */ CORDB_ADDRESS rva, /* [out] */ + ICorDebugFunction **ppFunction); + HRESULT STDMETHODCALLTYPE GetClassFromToken( + /* [in] */ mdTypeDef typeDef, /* [out] */ ICorDebugClass **ppClass); + HRESULT STDMETHODCALLTYPE + CreateBreakpoint(/* [out] */ ICorDebugModuleBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetEditAndContinueSnapshot( + /* [out] */ ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot); + HRESULT STDMETHODCALLTYPE GetMetaDataInterface(/* [in] */ REFIID riid, + /* [out] */ IUnknown **ppObj); + HRESULT STDMETHODCALLTYPE GetToken(/* [out] */ mdModule *pToken); + HRESULT STDMETHODCALLTYPE IsDynamic(/* [out] */ BOOL *pDynamic); + HRESULT STDMETHODCALLTYPE + GetGlobalVariableValue(/* [in] */ mdFieldDef fieldDef, /* [out] */ + ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetSize(/* [out] */ ULONG32 *pcBytes); + HRESULT STDMETHODCALLTYPE IsInMemory(/* [out] */ BOOL *pInMemory); +}; + +class CordbAssembly : public CordbBaseMono, + public ICorDebugAssembly, + public ICorDebugAssembly2 { +public: + CordbProcess *pProcess; + CordbAppDomain *pAppDomain; + int id; + CordbAssembly(Connection *conn, CordbProcess *process, + CordbAppDomain *appDomain, int id_assembly); + HRESULT STDMETHODCALLTYPE IsFullyTrusted(/* [out] */ BOOL *pbFullyTrusted); + HRESULT STDMETHODCALLTYPE + GetProcess(/* [out] */ ICorDebugProcess **ppProcess); + HRESULT STDMETHODCALLTYPE + GetAppDomain(/* [out] */ ICorDebugAppDomain **ppAppDomain); + HRESULT STDMETHODCALLTYPE + EnumerateModules(/* [out] */ ICorDebugModuleEnum **ppModules); + HRESULT STDMETHODCALLTYPE + GetCodeBase(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, + /* [length_is][size_is][out] */ WCHAR szName[]); + HRESULT STDMETHODCALLTYPE + GetName(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, + /* [length_is][size_is][out] */ WCHAR szName[]); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-blocking-obj.cpp b/src/mono/dbi/cordb-blocking-obj.cpp new file mode 100644 index 00000000000000..6d2b5a7318247e --- /dev/null +++ b/src/mono/dbi/cordb-blocking-obj.cpp @@ -0,0 +1,62 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-BLOCKING-OBJ.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbBlockingObjectEnum::CordbBlockingObjectEnum(Connection *conn) + : CordbBaseMono(conn) {} + +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Next( + ULONG celt, CorDebugBlockingObject values[], ULONG *pceltFetched) { + DEBUG_PRINTF(1, "CordbBlockingObjectEnum - Next - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Skip(ULONG celt) { + DEBUG_PRINTF(1, "CordbBlockingObjectEnum - Skip - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Reset(void) { + DEBUG_PRINTF(1, "CordbBlockingObjectEnum - Reset - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbBlockingObjectEnum::Clone(ICorDebugEnum **ppEnum) { + DEBUG_PRINTF(1, "CordbBlockingObjectEnum - Clone - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::GetCount(ULONG *pcelt) { + pcelt = 0; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbBlockingObjectEnum::QueryInterface(REFIID riid, void **ppvObject) { + DEBUG_PRINTF(1, + "CordbBlockingObjectEnum - QueryInterface - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +ULONG STDMETHODCALLTYPE CordbBlockingObjectEnum::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbBlockingObjectEnum::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-blocking-obj.h b/src/mono/dbi/cordb-blocking-obj.h new file mode 100644 index 00000000000000..4e8b7ebd2d9544 --- /dev/null +++ b/src/mono/dbi/cordb-blocking-obj.h @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-BLOCKING-OBJ.H +// + +#ifndef __MONO_DEBUGGER_CORDB_BLOCKING_OBJ_H__ +#define __MONO_DEBUGGER_CORDB_BLOCKING_OBJ_H__ + +#include + +class CordbBlockingObjectEnum : public CordbBaseMono, + public ICorDebugBlockingObjectEnum { +public: + CordbBlockingObjectEnum(Connection *conn); + HRESULT STDMETHODCALLTYPE Next(ULONG celt, CorDebugBlockingObject values[], + ULONG *pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum **ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG *pcelt); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-breakpoint.cpp b/src/mono/dbi/cordb-breakpoint.cpp new file mode 100644 index 00000000000000..7555837a029e74 --- /dev/null +++ b/src/mono/dbi/cordb-breakpoint.cpp @@ -0,0 +1,86 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-BREAKPOINT.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbFunctionBreakpoint::CordbFunctionBreakpoint(Connection *conn, + CordbCode *code, + ULONG32 offset) + : CordbBaseMono(conn) { + this->code = code; + this->offset = offset; +} + +HRESULT __stdcall CordbFunctionBreakpoint::GetFunction( + ICorDebugFunction **ppFunction) { + *ppFunction = static_cast(code->func); + DEBUG_PRINTF(1, "CordbFunctionBreakpoint - GetFunction - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbFunctionBreakpoint::GetOffset(ULONG32 *pnOffset) { + DEBUG_PRINTF(1, "CordbFunctionBreakpoint - GetOffset - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunctionBreakpoint::Activate(BOOL bActive) { + if (bActive) { + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_BREAKPOINT); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_LOCATION_ONLY); + m_dbgprot_buffer_add_id(&sendbuf, this->code->func->id); + m_dbgprot_buffer_add_long(&sendbuf, offset); + conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + DEBUG_PRINTF(1, "CordbFunctionBreakpoint - Activate\n"); + } else { + DEBUG_PRINTF( + 1, "CordbFunctionBreakpoint - Activate - FALSE - NOT IMPLEMENTED\n"); + } + return S_OK; +} + +HRESULT __stdcall CordbFunctionBreakpoint::IsActive(BOOL *pbActive) { + DEBUG_PRINTF(1, "CordbFunctionBreakpoint - IsActive - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunctionBreakpoint::QueryInterface(REFIID id, + void **pInterface) { + DEBUG_PRINTF(1, "CordbFunctionBreakpoint - QueryInterface - IMPLEMENTED\n"); + + if (id == IID_ICorDebugFunctionBreakpoint) { + *pInterface = static_cast(this); + } else { + // Not looking for a function breakpoint? See if the base class handles + // this interface. (issue 143976) + DEBUG_PRINTF(1, + "return CordbBreakpoint::QueryInterface(id, pInterface);\n"); + + // return CordbBreakpoint::QueryInterface(id, pInterface); + } + return S_OK; +} + +ULONG __stdcall CordbFunctionBreakpoint::AddRef(void) { return 0; } + +auto __stdcall CordbFunctionBreakpoint::Release(void) -> ULONG { return 0; } diff --git a/src/mono/dbi/cordb-breakpoint.h b/src/mono/dbi/cordb-breakpoint.h new file mode 100644 index 00000000000000..fed152f6a8d0ec --- /dev/null +++ b/src/mono/dbi/cordb-breakpoint.h @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-BREAKPOINT.H +// + +#ifndef __MONO_DEBUGGER_CORDB_BREAKPOINT_H__ +#define __MONO_DEBUGGER_CORDB_BREAKPOINT_H__ + +#include + +class CordbFunctionBreakpoint : public CordbBaseMono, + public ICorDebugFunctionBreakpoint { +public: + CordbCode *code; + ULONG32 offset; + CordbFunctionBreakpoint(Connection *conn, CordbCode *code, ULONG32 offset); + HRESULT STDMETHODCALLTYPE + GetFunction(/* [out] */ ICorDebugFunction **ppFunction); + HRESULT STDMETHODCALLTYPE GetOffset(/* [out] */ ULONG32 *pnOffset); + HRESULT STDMETHODCALLTYPE Activate(/* [in] */ BOOL bActive); + HRESULT STDMETHODCALLTYPE IsActive(/* [out] */ BOOL *pbActive); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-chain.cpp b/src/mono/dbi/cordb-chain.cpp new file mode 100644 index 00000000000000..a8e4e582ff3d96 --- /dev/null +++ b/src/mono/dbi/cordb-chain.cpp @@ -0,0 +1,164 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-CHAIN.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +HRESULT __stdcall CordbChainEnum::Next(ULONG celt, ICorDebugChain *chains[], + ULONG *pceltFetched) { + DEBUG_PRINTF(1, "CordbChainEnum - Next - IMPLEMENTED\n"); + + chains[0] = new CordbChain(conn, thread, CHAIN_PROCESS_START, false); + chains[1] = new CordbChain(conn, thread, CHAIN_ENTER_MANAGED, true); + *pceltFetched = celt; + return S_OK; +} + +CordbChainEnum::CordbChainEnum(Connection *conn, CordbThread *thread) + : CordbBaseMono(conn) { + this->thread = thread; +} + +HRESULT __stdcall CordbChainEnum::QueryInterface(REFIID id, void **pInterface) { + DEBUG_PRINTF(1, "CordbChainEnum - QueryInterface - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbChainEnum::Skip(ULONG celt) { + DEBUG_PRINTF(1, "CordbChainEnum - Skip - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +ULONG STDMETHODCALLTYPE CordbChainEnum::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbChainEnum::Release(void) { return 0; } + +HRESULT STDMETHODCALLTYPE CordbChainEnum::Reset(void) { + DEBUG_PRINTF(1, "CordbChainEnum - Reset - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbChainEnum::Clone( + /* [out] */ ICorDebugEnum **ppEnum) { + DEBUG_PRINTF(1, "CordbChainEnum - Clone - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbChainEnum::GetCount( + /* [out] */ ULONG *pcelt) { + DEBUG_PRINTF(1, "CordbChainEnum - GetCount - IMPLEMENTED\n"); + + *pcelt = 2; + return S_OK; +} + +CordbChain::CordbChain(Connection *conn, CordbThread *thread, + CorDebugChainReason chain_reason, bool is_managed) + : CordbBaseMono(conn) { + this->thread = thread; + this->chain_reason = chain_reason; + this->is_managed = is_managed; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetThread(/* [out] */ ICorDebugThread **ppThread) { + *ppThread = static_cast(thread); + DEBUG_PRINTF(1, "CordbChain - GetThread - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbChain::GetStackRange( + /* [out] */ CORDB_ADDRESS *pStart, /* [out] */ CORDB_ADDRESS *pEnd) { + DEBUG_PRINTF(1, "CordbChain - GetStackRange - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetContext(/* [out] */ ICorDebugContext **ppContext) { + DEBUG_PRINTF(1, "CordbChain - GetContext - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetCaller(/* [out] */ ICorDebugChain **ppChain) { + DEBUG_PRINTF(1, "CordbChain - GetCaller - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetCallee(/* [out] */ ICorDebugChain **ppChain) { + DEBUG_PRINTF(1, "CordbChain - GetCallee - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetPrevious(/* [out] */ ICorDebugChain **ppChain) { + DEBUG_PRINTF(1, "CordbChain - GetPrevious - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetNext(/* [out] */ ICorDebugChain **ppChain) { + DEBUG_PRINTF(1, "CordbChain - GetNext - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbChain::IsManaged(/* [out] */ BOOL *pManaged) { + DEBUG_PRINTF(1, "CordbChain - IsManaged - IMPLEMENTED\n"); + *pManaged = is_managed; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::EnumerateFrames(/* [out] */ ICorDebugFrameEnum **ppFrames) { + *ppFrames = new CordbFrameEnum(conn, thread); + DEBUG_PRINTF(1, "CordbChain - EnumerateFrames - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetActiveFrame(/* [out] */ ICorDebugFrame **ppFrame) { + DEBUG_PRINTF(1, "CordbChain - GetActiveFrame - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetRegisterSet(/* [out] */ ICorDebugRegisterSet **ppRegisters) { + DEBUG_PRINTF(1, "CordbChain - GetRegisterSet - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::GetReason(/* [out] */ CorDebugChainReason *pReason) { + *pReason = chain_reason; + DEBUG_PRINTF(1, "CordbChain - GetReason - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbChain::QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { + DEBUG_PRINTF(1, "CordbChain - QueryInterface - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +ULONG STDMETHODCALLTYPE CordbChain::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbChain::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-chain.h b/src/mono/dbi/cordb-chain.h new file mode 100644 index 00000000000000..06c19d4a0c900b --- /dev/null +++ b/src/mono/dbi/cordb-chain.h @@ -0,0 +1,62 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-CHAIN.H +// + +#ifndef __MONO_DEBUGGER_CORDB_CHAIN_H__ +#define __MONO_DEBUGGER_CORDB_CHAIN_H__ + +#include + +class CordbChainEnum : public CordbBaseMono, public ICorDebugChainEnum { +public: + CordbThread *thread; + CordbChainEnum(Connection *conn, CordbThread *thread); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE Skip(/* [in] */ ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(/* [out] */ ICorDebugEnum **ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(/* [out] */ ULONG *pcelt); + HRESULT STDMETHODCALLTYPE + Next(/* [in] */ ULONG celt, + /* [length_is][size_is][out] */ ICorDebugChain *chains[], + /* [out] */ ULONG *pceltFetched); +}; + +class CordbChain : public CordbBaseMono, public ICorDebugChain { +public: + CordbThread *thread; + CorDebugChainReason chain_reason; + bool is_managed; + CordbChain(Connection *conn, CordbThread *thread, + CorDebugChainReason chain_reason, bool is_managed); + HRESULT STDMETHODCALLTYPE GetThread(/* [out] */ ICorDebugThread **ppThread); + HRESULT STDMETHODCALLTYPE GetStackRange(/* [out] */ CORDB_ADDRESS *pStart, + /* [out] */ CORDB_ADDRESS *pEnd); + HRESULT STDMETHODCALLTYPE + GetContext(/* [out] */ ICorDebugContext **ppContext); + HRESULT STDMETHODCALLTYPE GetCaller(/* [out] */ ICorDebugChain **ppChain); + HRESULT STDMETHODCALLTYPE GetCallee(/* [out] */ ICorDebugChain **ppChain); + HRESULT STDMETHODCALLTYPE GetPrevious(/* [out] */ ICorDebugChain **ppChain); + HRESULT STDMETHODCALLTYPE GetNext(/* [out] */ ICorDebugChain **ppChain); + HRESULT STDMETHODCALLTYPE IsManaged(/* [out] */ BOOL *pManaged); + HRESULT STDMETHODCALLTYPE + EnumerateFrames(/* [out] */ ICorDebugFrameEnum **ppFrames); + HRESULT STDMETHODCALLTYPE + GetActiveFrame(/* [out] */ ICorDebugFrame **ppFrame); + HRESULT STDMETHODCALLTYPE + GetRegisterSet(/* [out] */ ICorDebugRegisterSet **ppRegisters); + HRESULT STDMETHODCALLTYPE GetReason(/* [out] */ CorDebugChainReason *pReason); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-class.cpp b/src/mono/dbi/cordb-class.cpp new file mode 100644 index 00000000000000..1d71775b39c7eb --- /dev/null +++ b/src/mono/dbi/cordb-class.cpp @@ -0,0 +1,84 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-CLASS.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbClass::CordbClass(Connection *conn, mdToken token, int module_id) + : CordbBaseMono(conn) { + this->token = token; + this->module_id = module_id; +} + +HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule **pModule) { + DEBUG_PRINTF(1, "CordbClass - GetModule - IMPLEMENTED - %d\n", module_id); + if (pModule) { + *pModule = (ICorDebugModule *)g_hash_table_lookup( + conn->ppCordb->modules, GINT_TO_POINTER(module_id)); + } + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbClass::GetToken(mdTypeDef *pTypeDef) { + DEBUG_PRINTF(1, "CordbClass - GetToken - IMPLEMENTED - %d\n", module_id); + *pTypeDef = token; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbClass::GetStaticFieldValue( + mdFieldDef fieldDef, ICorDebugFrame *pFrame, ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbClass - GetStaticFieldValue - NOT IMPLEMENTED - %d\n", + fieldDef); + CordbContent content_value; + content_value.booleanValue = 0; + CordbValue *value = + new CordbValue(conn, ELEMENT_TYPE_BOOLEAN, content_value, 1); + *ppValue = static_cast(value); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbClass::QueryInterface(REFIID id, + void **pInterface) { + if (id == IID_ICorDebugClass) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugClass2) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = static_cast(static_cast(this)); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbClass::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbClass::Release(void) { return 0; } + +HRESULT STDMETHODCALLTYPE CordbClass::GetParameterizedType( + CorElementType elementType, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], + ICorDebugType **ppType) { + DEBUG_PRINTF(1, "CordbClass - GetParameterizedType - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbClass::SetJMCStatus(BOOL bIsJustMyCode) { + DEBUG_PRINTF(1, "CordbClass - SetJMCStatus - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} diff --git a/src/mono/dbi/cordb-class.h b/src/mono/dbi/cordb-class.h new file mode 100644 index 00000000000000..4098bad7073bda --- /dev/null +++ b/src/mono/dbi/cordb-class.h @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-CLASS.H +// + +#ifndef __MONO_DEBUGGER_CORDB_CLASS_H__ +#define __MONO_DEBUGGER_CORDB_CLASS_H__ + +#include + +class CordbClass : public CordbBaseMono, + public ICorDebugClass, + public ICorDebugClass2 { + mdToken token; + +public: + int module_id; + CordbClass(Connection *conn, mdToken token, int module_id); + HRESULT STDMETHODCALLTYPE GetModule(ICorDebugModule **pModule); + HRESULT STDMETHODCALLTYPE GetToken(mdTypeDef *pTypeDef); + HRESULT STDMETHODCALLTYPE GetStaticFieldValue(mdFieldDef fieldDef, + ICorDebugFrame *pFrame, + ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE GetParameterizedType(CorElementType elementType, + ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[], + ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE SetJMCStatus(BOOL bIsJustMyCode); +}; + +#endif diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp new file mode 100644 index 00000000000000..22c284d3b7abc8 --- /dev/null +++ b/src/mono/dbi/cordb-code.cpp @@ -0,0 +1,123 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-CODE.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbCode::CordbCode(Connection *conn, CordbFunction *func) + : CordbBaseMono(conn) { + this->func = func; +} + +HRESULT __stdcall CordbCode::IsIL(BOOL *pbIL) { + DEBUG_PRINTF(1, "CordbCode - IsIL - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbCode::GetFunction(ICorDebugFunction **ppFunction) { + DEBUG_PRINTF(1, "CordbCode - GetFunction - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbCode::GetAddress(CORDB_ADDRESS *pStart) { + DEBUG_PRINTF(1, "CordbCode - GetAddress - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbCode::GetSize(ULONG32 *pcBytes) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + + m_dbgprot_buffer_add_id(&localbuf, this->func->id); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + int code_size = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + *pcBytes = code_size; + DEBUG_PRINTF(1, "CordbCode - GetSize - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbCode::CreateBreakpoint( + ULONG32 offset, ICorDebugFunctionBreakpoint **ppBreakpoint) { + // add it in a list to not recreate a already created breakpoint + CordbFunctionBreakpoint *bp = new CordbFunctionBreakpoint(conn, this, offset); + *ppBreakpoint = static_cast(bp); + g_ptr_array_add(this->func->module->pProcess->cordb->breakpoints, bp); + DEBUG_PRINTF(1, "CordbCode - CreateBreakpoint - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbCode::GetCode(ULONG32 startOffset, ULONG32 endOffset, + ULONG32 cBufferAlloc, BYTE buffer[], + ULONG32 *pcBufferSize) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + + m_dbgprot_buffer_add_id(&localbuf, this->func->id); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + guint8 *code = m_dbgprot_decode_byte_array(bAnswer->buf, &bAnswer->buf, + bAnswer->end, pcBufferSize); + + memcpy(buffer, code, *pcBufferSize); + DEBUG_PRINTF(1, "CordbCode - GetCode - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbCode::GetVersionNumber(ULONG32 *nVersion) { + *nVersion = 1; + DEBUG_PRINTF(1, "CordbCode - GetVersionNumber - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbCode::GetILToNativeMapping( + ULONG32 cMap, ULONG32 *pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) { + DEBUG_PRINTF(1, "CordbCode - GetILToNativeMapping - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbCode::GetEnCRemapSequencePoints(ULONG32 cMap, + ULONG32 *pcMap, + ULONG32 offsets[]) { + DEBUG_PRINTF(1, "CordbCode - GetEnCRemapSequencePoints - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbCode::QueryInterface(REFIID id, void **pInterface) { + if (id == IID_ICorDebugCode) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = static_cast(static_cast(this)); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + return S_OK; +} + +ULONG __stdcall CordbCode::AddRef(void) { return 0; } + +ULONG __stdcall CordbCode::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-code.h b/src/mono/dbi/cordb-code.h new file mode 100644 index 00000000000000..7e7cdecf63c451 --- /dev/null +++ b/src/mono/dbi/cordb-code.h @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-CODE.H +// + +#ifndef __MONO_DEBUGGER_CORDB_CODE_H__ +#define __MONO_DEBUGGER_CORDB_CODE_H__ + +#include + +class CordbCode : public CordbBaseMono, public ICorDebugCode { +public: + CordbFunction *func; + CordbCode(Connection *conn, CordbFunction *func); + HRESULT STDMETHODCALLTYPE IsIL(/* [out] */ BOOL *pbIL); + HRESULT STDMETHODCALLTYPE + GetFunction(/* [out] */ ICorDebugFunction **ppFunction); + HRESULT STDMETHODCALLTYPE GetAddress(/* [out] */ CORDB_ADDRESS *pStart); + HRESULT STDMETHODCALLTYPE GetSize(/* [out] */ ULONG32 *pcBytes); + HRESULT STDMETHODCALLTYPE + CreateBreakpoint(/* [in] */ ULONG32 offset, /* [out] */ + ICorDebugFunctionBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetCode( + /* [in] */ ULONG32 startOffset, /* [in] */ ULONG32 endOffset, /* [in] */ + ULONG32 cBufferAlloc, /* [length_is][size_is][out] */ BYTE buffer[], + /* [out] */ ULONG32 *pcBufferSize); + HRESULT STDMETHODCALLTYPE GetVersionNumber(/* [out] */ ULONG32 *nVersion); + HRESULT STDMETHODCALLTYPE + GetILToNativeMapping(/* [in] */ ULONG32 cMap, /* [out] */ ULONG32 *pcMap, + /* [length_is][size_is][out] */ + COR_DEBUG_IL_TO_NATIVE_MAP map[]); + HRESULT STDMETHODCALLTYPE + GetEnCRemapSequencePoints(/* [in] */ ULONG32 cMap, /* [out] */ ULONG32 *pcMap, + /* [length_is][size_is][out] */ ULONG32 offsets[]); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp new file mode 100644 index 00000000000000..65594522b11ca0 --- /dev/null +++ b/src/mono/dbi/cordb-eval.cpp @@ -0,0 +1,232 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-EVAL.CPP +// + +#include +#include +#include +#include +#include +#include + +#include "stdafx.h" +#include "corerror.h" +#include "rwutil.h" + +CordbEval::CordbEval(Connection *conn, CordbThread *thread) + : CordbBaseMono(conn) { + this->thread = thread; + ppValue = NULL; + cmdId = -1; + //send a suspend because after the eval icordebug will send a resume + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SUSPEND, &localbuf); + m_dbgprot_buffer_free(&localbuf); +} + +HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( + ICorDebugFunction *pFunction, ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]) { + DEBUG_PRINTF(1, "CordbEval - CallParameterizedFunction - IMPLEMENTED\n"); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); + m_dbgprot_buffer_add_int(&localbuf, 1); + m_dbgprot_buffer_add_int(&localbuf, ((CordbFunction *)pFunction)->id); + m_dbgprot_buffer_add_int(&localbuf, nArgs); + for (int i = 0; i < nArgs; i++) { + CorElementType ty; + ppArgs[i]->GetType(&ty); + CordbContent *cc; + ppArgs[i]->GetAddress((CORDB_ADDRESS *)&cc); + m_dbgprot_buffer_add_byte(&localbuf, ty); + switch (ty) { + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_I1: + case MONO_TYPE_U1: + m_dbgprot_buffer_add_int(&localbuf, cc->booleanValue); + break; + case MONO_TYPE_CHAR: + case MONO_TYPE_I2: + case MONO_TYPE_U2: + m_dbgprot_buffer_add_int(&localbuf, cc->charValue); + break; + case MONO_TYPE_I4: + case MONO_TYPE_U4: + case MONO_TYPE_R4: + m_dbgprot_buffer_add_int(&localbuf, cc->intValue); + break; + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_R8: + m_dbgprot_buffer_add_long(&localbuf, cc->longValue); + break; + case MONO_TYPE_CLASS: + case MONO_TYPE_SZARRAY: + case MONO_TYPE_STRING: + m_dbgprot_buffer_add_id(&localbuf, cc->intValue); + break; + } + } + cmdId = conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_INVOKE_METHOD, &localbuf); + m_dbgprot_buffer_free(&localbuf); + g_ptr_array_add(conn->pending_eval, this); + return S_OK; +} + +void CordbEval::EvalComplete(MdbgProtBuffer *bAnswer) { + + m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + CordbObjectValue::CreateCordbValue(conn, bAnswer, &ppValue); + conn->ppCordb->pCallback->EvalComplete( + static_cast( + g_ptr_array_index(thread->ppProcess->appdomains, 0)), + static_cast(thread), + static_cast(this)); +} + +HRESULT STDMETHODCALLTYPE +CordbEval::CreateValueForType(ICorDebugType *pType, ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbEval - CreateValueForType - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedObject( + ICorDebugFunction *pConstructor, ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]) { + DEBUG_PRINTF(1, "CordbEval - NewParameterizedObject - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedObjectNoConstructor( + ICorDebugClass *pClass, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[]) { + DEBUG_PRINTF( + 1, "CordbEval - NewParameterizedObjectNoConstructor - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbEval::NewParameterizedArray(ICorDebugType *pElementType, ULONG32 rank, + ULONG32 dims[], ULONG32 lowBounds[]) { + DEBUG_PRINTF(1, "CordbEval - NewParameterizedArray - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, + UINT uiLength) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + int domainId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + LPSTR szString; + UTF8STR(string, szString); + + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, domainId); + m_dbgprot_buffer_add_string(&localbuf, szString); + this->cmdId = conn->send_event(MDBGPROT_CMD_SET_APPDOMAIN, MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); + g_ptr_array_add(conn->pending_eval, this); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbEval::RudeAbort(void) { + DEBUG_PRINTF(1, "CordbEval - RudeAbort - NOT IMPLEMENTED\n"); + return S_OK; +} + +ULONG CordbEval::AddRef(void) { return 1; } + +ULONG CordbEval::Release(void) { return 1; } + +HRESULT +CordbEval::QueryInterface(REFIID id, + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { + if (id == IID_ICorDebugEval) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugEval2) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = static_cast(static_cast(this)); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbEval::CallFunction(ICorDebugFunction *pFunction, + ULONG32 nArgs, + ICorDebugValue *ppArgs[]) { + DEBUG_PRINTF(1, "CordbEval - CallFunction - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::NewObject(ICorDebugFunction *pConstructor, + ULONG32 nArgs, + ICorDebugValue *ppArgs[]) { + DEBUG_PRINTF(1, "CordbEval - NewObject - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbEval::NewObjectNoConstructor(ICorDebugClass *pClass) { + DEBUG_PRINTF(1, "CordbEval - NewObjectNoConstructor - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::NewString(LPCWSTR string) { + DEBUG_PRINTF(1, "CordbEval - NewString - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::NewArray(CorElementType elementType, + ICorDebugClass *pElementClass, + ULONG32 rank, ULONG32 dims[], + ULONG32 lowBounds[]) { + DEBUG_PRINTF(1, "CordbEval - NewArray - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::IsActive(BOOL *pbActive) { + DEBUG_PRINTF(1, "CordbEval - IsActive - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::Abort(void) { + DEBUG_PRINTF(1, "CordbEval - Abort - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbEval::GetResult(ICorDebugValue **ppResult) { + *ppResult = ppValue; + DEBUG_PRINTF(1, "CordbEval - GetResult - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbEval::GetThread(ICorDebugThread **ppThread) { + DEBUG_PRINTF(1, "CordbEval - GetThread - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbEval::CreateValue(CorElementType elementType, + ICorDebugClass *pElementClass, + ICorDebugValue **ppValue) { + CordbContent content_value; + content_value.booleanValue = 0; + CordbValue *value = + new CordbValue(conn, elementType, content_value, + convert_mono_type_2_icordbg_size(elementType)); + DEBUG_PRINTF(1, "CordbEval - CreateValue - IMPLEMENTED\n"); + value->QueryInterface(IID_ICorDebugValue, (void **)ppValue); + return S_OK; +} diff --git a/src/mono/dbi/cordb-eval.h b/src/mono/dbi/cordb-eval.h new file mode 100644 index 00000000000000..17e9daf11a390d --- /dev/null +++ b/src/mono/dbi/cordb-eval.h @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-EVAL.H +// + +#ifndef __MONO_DEBUGGER_CORDB_EVAL_H__ +#define __MONO_DEBUGGER_CORDB_EVAL_H__ + +#include + +class CordbEval : public CordbBaseMono, + public ICorDebugEval, + public ICorDebugEval2 { + CordbThread *thread; + ICorDebugValue *ppValue; + +public: + int cmdId; + CordbEval(Connection *conn, CordbThread *thread); + void EvalComplete(MdbgProtBuffer *bAnswer); + + virtual HRESULT STDMETHODCALLTYPE CallParameterizedFunction( + ICorDebugFunction *pFunction, ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]); + virtual HRESULT STDMETHODCALLTYPE NewParameterizedObject( + ICorDebugFunction *pConstructor, ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]); + virtual HRESULT STDMETHODCALLTYPE NewParameterizedObjectNoConstructor( + ICorDebugClass *pClass, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[]); + virtual HRESULT STDMETHODCALLTYPE CallFunction(ICorDebugFunction *pFunction, + ULONG32 nArgs, + ICorDebugValue *ppArgs[]); + virtual HRESULT STDMETHODCALLTYPE NewObject(ICorDebugFunction *pConstructor, + ULONG32 nArgs, + ICorDebugValue *ppArgs[]); + virtual HRESULT STDMETHODCALLTYPE + NewObjectNoConstructor(ICorDebugClass *pClass); + virtual HRESULT STDMETHODCALLTYPE NewString(LPCWSTR string); + virtual HRESULT STDMETHODCALLTYPE NewArray(CorElementType elementType, + ICorDebugClass *pElementClass, + ULONG32 rank, ULONG32 dims[], + ULONG32 lowBounds[]); + virtual HRESULT STDMETHODCALLTYPE IsActive(BOOL *pbActive); + virtual HRESULT STDMETHODCALLTYPE Abort(void); + virtual HRESULT STDMETHODCALLTYPE GetResult(ICorDebugValue **ppResult); + virtual HRESULT STDMETHODCALLTYPE GetThread(ICorDebugThread **ppThread); + virtual HRESULT STDMETHODCALLTYPE CreateValue(CorElementType elementType, + ICorDebugClass *pElementClass, + ICorDebugValue **ppValue); + virtual HRESULT STDMETHODCALLTYPE + CreateValueForType(ICorDebugType *pType, ICorDebugValue **ppValue); + virtual HRESULT STDMETHODCALLTYPE + NewParameterizedArray(ICorDebugType *pElementType, ULONG32 rank, + ULONG32 dims[], ULONG32 lowBounds[]); + virtual HRESULT STDMETHODCALLTYPE NewStringWithLength(LPCWSTR string, + UINT uiLength); + virtual HRESULT STDMETHODCALLTYPE RudeAbort(void); + HRESULT QueryInterface(REFIID riid, + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject); + ULONG AddRef(void); + ULONG Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp new file mode 100644 index 00000000000000..ab4ca46359ff35 --- /dev/null +++ b/src/mono/dbi/cordb-frame.cpp @@ -0,0 +1,475 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-FRAME.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbFrameEnum::CordbFrameEnum(Connection *conn, CordbThread *thread) + : CordbBaseMono(conn) { + this->thread = thread; +} + +HRESULT STDMETHODCALLTYPE CordbFrameEnum::Next(ULONG celt, + ICorDebugFrame *frames[], + ULONG *pceltFetched) { + for (int i = 0; i < nframes; i++) { + frames[i] = this->frames[i]; + } + DEBUG_PRINTF(1, "CordbFrameEnum - Next - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbFrameEnum::Skip(ULONG celt) { + DEBUG_PRINTF(1, "CordbFrameEnum - Skip - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbFrameEnum::Reset(void) { + DEBUG_PRINTF(1, "CordbFrameEnum - Reset - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbFrameEnum::Clone(ICorDebugEnum **ppEnum) { + DEBUG_PRINTF(1, "CordbFrameEnum - Clone - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG *pcelt) { + DEBUG_PRINTF(1, "CordbFrameEnum - GetCount - IMPLEMENTED\n"); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); + m_dbgprot_buffer_add_int(&localbuf, 0); + m_dbgprot_buffer_add_int(&localbuf, -1); + + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + nframes = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + frames = (CordbNativeFrame **)malloc(sizeof(CordbNativeFrame *) * nframes); + + for (int i = 0; i < nframes; i++) { + int frameid = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int methodId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int il_offset = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int flags = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + CordbNativeFrame *frame = + new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, thread); + frames[i] = frame; + } + + if (!thread->registerset) + thread->registerset = new CordbRegisteSet(conn, 0, 0); + + *pcelt = nframes; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbFrameEnum::QueryInterface(REFIID riid, + void **ppvObject) { + DEBUG_PRINTF(1, "CordbFrameEnum - QueryInterface - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +ULONG STDMETHODCALLTYPE CordbFrameEnum::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbFrameEnum::Release(void) { return 0; } + +CordbJITILFrame::CordbJITILFrame(Connection *conn, int frameid, int methodId, + int il_offset, int flags, CordbThread *thread) + : CordbBaseMono(conn) { + this->frameid = frameid; + this->methodId = methodId; + this->il_offset = il_offset; + this->flags = flags; + this->thread = thread; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetChain( + /* [out] */ ICorDebugChain **ppChain) { + DEBUG_PRINTF(1, "CordbFrame - GetChain - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCode( + /* [out] */ ICorDebugCode **ppCode) { + DEBUG_PRINTF(1, "CordbFrame - GetCode - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunction( + /* [out] */ ICorDebugFunction **ppFunction) { + CordbFunction *func = thread->ppProcess->cordb->findFunction(methodId); + if (!func) { + func = new CordbFunction(conn, 0, methodId, NULL); + g_ptr_array_add(thread->ppProcess->cordb->functions, func); + } + + *ppFunction = static_cast(func); + DEBUG_PRINTF(1, "CordbFrame - GetFunction\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunctionToken( + /* [out] */ mdMethodDef *pToken) { + DEBUG_PRINTF(1, "CordbFrame - GetFunctionToken - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackRange( + /* [out] */ CORDB_ADDRESS *pStart, + /* [out] */ CORDB_ADDRESS *pEnd) { + *pStart = 4096; + *pEnd = 8192; + DEBUG_PRINTF(1, + "CordbFrame - GetStackRange - NOT IMPLEMENTED - we need id?\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCaller( + /* [out] */ ICorDebugFrame **ppFrame) { + DEBUG_PRINTF(1, "CordbFrame - GetCaller - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCallee( + /* [out] */ ICorDebugFrame **ppFrame) { + DEBUG_PRINTF(1, "CordbFrame - GetCallee - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::CreateStepper( + /* [out] */ ICorDebugStepper **ppStepper) { + DEBUG_PRINTF(1, "CordbFrame - CreateStepper - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::QueryInterface( + /* [in] */ REFIID id, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { + if (id == IID_ICorDebugILFrame) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugILFrame2) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugILFrame3) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugILFrame4) { + *pInterface = static_cast(this); + } else { + *pInterface = NULL; + + DEBUG_PRINTF(1, "CordbFrame - QueryInterface - E_NOTIMPL\n"); + + return E_NOINTERFACE; + } + DEBUG_PRINTF(1, "CordbFrame - QueryInterface - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::RemapFunction(ULONG32 newILOffset) { + DEBUG_PRINTF(1, "CordbFrame - RemapFunction - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum) { + DEBUG_PRINTF(1, "CordbFrame - EnumerateTypeParameters - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetReturnValueForILOffset( + ULONG32 ILoffset, ICorDebugValue **ppReturnValue) { + DEBUG_PRINTF(1, "CordbFrame - GetReturnValueForILOffset - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariablesEx( + ILCodeKind flags, ICorDebugValueEnum **ppValueEnum) { + DEBUG_PRINTF(1, "CordbFrame - EnumerateLocalVariablesEx - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariableEx( + ILCodeKind flags, DWORD dwIndex, ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbFrame - GetLocalVariableEx - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCodeEx(ILCodeKind flags, + ICorDebugCode **ppCode) { + if (flags == ILCODE_REJIT_IL) { + *ppCode = NULL; + } else { + CordbCode *code = new CordbCode(conn, NULL); + *ppCode = static_cast(code); + } + DEBUG_PRINTF(1, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n"); + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbJITILFrame::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbJITILFrame::Release(void) { return 0; } + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetIP( + /* [out] */ ULONG32 *pnOffset, + /* [out] */ CorDebugMappingResult *pMappingResult) { + *pnOffset = il_offset; + *pMappingResult = MAPPING_EXACT; + DEBUG_PRINTF(1, "CordbFrame - GetIP - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::SetIP( + /* [in] */ ULONG32 nOffset) { + DEBUG_PRINTF(1, "CordbFrame - SetIP - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariables( + /* [out] */ ICorDebugValueEnum **ppValueEnum) { + DEBUG_PRINTF(1, "CordbFrame - EnumerateLocalVariables - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariable( + /* [in] */ DWORD dwIndex, + /* [out] */ ICorDebugValue **ppValue) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); + m_dbgprot_buffer_add_id(&localbuf, frameid); + m_dbgprot_buffer_add_int(&localbuf, 1); + m_dbgprot_buffer_add_int(&localbuf, dwIndex); + + int cmdId = conn->send_event(MDBGPROT_CMD_SET_STACK_FRAME, MDBGPROT_CMD_STACK_FRAME_GET_VALUES, + &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + return CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateArguments( + /* [out] */ ICorDebugValueEnum **ppValueEnum) { + DEBUG_PRINTF(1, "CordbFrame - EnumerateArguments - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetArgument( + /* [in] */ DWORD dwIndex, + /* [out] */ ICorDebugValue **ppValue) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); + m_dbgprot_buffer_add_id(&localbuf, frameid); + + m_dbgprot_buffer_add_int(&localbuf, dwIndex); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_STACK_FRAME, + MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + DEBUG_PRINTF(1, "CordbFrame - GetArgument - IMPLEMENTED - dwIndex - %d\n", + dwIndex); + return CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackDepth( + /* [out] */ ULONG32 *pDepth) { + DEBUG_PRINTF(1, "CordbFrame - GetStackDepth - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackValue( + /* [in] */ DWORD dwIndex, + /* [out] */ ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbFrame - GetStackValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::CanSetIP( + /* [in] */ ULONG32 nOffset) { + DEBUG_PRINTF(1, "CordbFrame - CanSetIP - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +CordbNativeFrame::CordbNativeFrame(Connection *conn, int frameid, int methodId, + int il_offset, int flags, + CordbThread *thread) + : CordbBaseMono(conn) { + m_JITILFrame = + new CordbJITILFrame(conn, frameid, methodId, il_offset, flags, thread); + this->thread = thread; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetIP(ULONG32 *pnOffset) { + DEBUG_PRINTF(1, "CordbNativeFrame - GetIP - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::SetIP(ULONG32 nOffset) { + DEBUG_PRINTF(1, "CordbNativeFrame - SetIP - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbNativeFrame::GetRegisterSet(ICorDebugRegisterSet **ppRegisters) { + return thread->GetRegisterSet(ppRegisters); +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterValue( + CorDebugRegister reg, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, + "CordbNativeFrame - GetLocalRegisterValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalDoubleRegisterValue( + CorDebugRegister highWordReg, CorDebugRegister lowWordReg, ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { + DEBUG_PRINTF( + 1, "CordbNativeFrame - GetLocalDoubleRegisterValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalMemoryValue( + CORDB_ADDRESS address, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbNativeFrame - GetLocalMemoryValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterMemoryValue( + CorDebugRegister highWordReg, CORDB_ADDRESS lowWordAddress, ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { + DEBUG_PRINTF( + 1, "CordbNativeFrame - GetLocalRegisterMemoryValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalMemoryRegisterValue( + CORDB_ADDRESS highWordAddress, CorDebugRegister lowWordRegister, + ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { + DEBUG_PRINTF( + 1, "CordbNativeFrame - GetLocalMemoryRegisterValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::CanSetIP(ULONG32 nOffset) { + DEBUG_PRINTF(1, "CordbNativeFrame - CanSetIP - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetChain(ICorDebugChain **ppChain) { + DEBUG_PRINTF(1, "CordbNativeFrame - GetChain - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCode(ICorDebugCode **ppCode) { + CordbCode *code = new CordbCode(conn, NULL); + *ppCode = static_cast(code); + DEBUG_PRINTF(1, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbNativeFrame::GetFunction(ICorDebugFunction **ppFunction) { + return m_JITILFrame->GetFunction(ppFunction); +} + +HRESULT STDMETHODCALLTYPE +CordbNativeFrame::GetFunctionToken(mdMethodDef *pToken) { + DEBUG_PRINTF(1, "CordbNativeFrame - GetFunctionToken - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetStackRange(CORDB_ADDRESS *pStart, + CORDB_ADDRESS *pEnd) { + return m_JITILFrame->GetStackRange(pStart, pEnd); +} + +HRESULT STDMETHODCALLTYPE +CordbNativeFrame::GetCaller(ICorDebugFrame **ppFrame) { + DEBUG_PRINTF(1, "CordbNativeFrame - GetCaller - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbNativeFrame::GetCallee(ICorDebugFrame **ppFrame) { + DEBUG_PRINTF(1, "CordbNativeFrame - GetCallee - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbNativeFrame::CreateStepper(ICorDebugStepper **ppStepper) { + DEBUG_PRINTF(1, "CordbNativeFrame - CreateStepper - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::QueryInterface(REFIID id, + void **pInterface) { + if (id == IID_ICorDebugFrame) { + *pInterface = static_cast( + static_cast(this)); + } else if (id == IID_ICorDebugNativeFrame) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugNativeFrame2) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = + static_cast(static_cast(this)); + } else { + // might be searching for an IL Frame. delegate that search to the + // JITILFrame + if (m_JITILFrame != NULL) { + return m_JITILFrame->QueryInterface(id, pInterface); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + } + + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbNativeFrame::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbNativeFrame::Release(void) { return 0; } + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsChild(BOOL *pIsChild) { + DEBUG_PRINTF(1, "CordbNativeFrame - IsChild - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsMatchingParentFrame( + ICorDebugNativeFrame2 *pPotentialParentFrame, BOOL *pIsParent) { + DEBUG_PRINTF(1, + "CordbNativeFrame - IsMatchingParentFrame - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbNativeFrame::GetStackParameterSize(ULONG32 *pSize) { + DEBUG_PRINTF(1, + "CordbNativeFrame - GetStackParameterSize - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} diff --git a/src/mono/dbi/cordb-frame.h b/src/mono/dbi/cordb-frame.h new file mode 100644 index 00000000000000..1eeab440f8e9c2 --- /dev/null +++ b/src/mono/dbi/cordb-frame.h @@ -0,0 +1,134 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-FRAME.H +// + +#ifndef __MONO_DEBUGGER_CORDB_FRAME_H__ +#define __MONO_DEBUGGER_CORDB_FRAME_H__ + +#include + +class CordbJITILFrame : public CordbBaseMono, + public ICorDebugILFrame, + public ICorDebugILFrame2, + public ICorDebugILFrame3, + public ICorDebugILFrame4 { +public: + int frameid; + int methodId; + int il_offset; + int flags; + CordbThread *thread; + CordbJITILFrame(Connection *conn, int frameid, int methodId, int il_offset, + int flags, CordbThread *thread); + HRESULT STDMETHODCALLTYPE GetChain(/* [out] */ ICorDebugChain **ppChain); + HRESULT STDMETHODCALLTYPE GetCode(/* [out] */ ICorDebugCode **ppCode); + HRESULT STDMETHODCALLTYPE + GetFunction(/* [out] */ ICorDebugFunction **ppFunction); + HRESULT STDMETHODCALLTYPE GetFunctionToken(/* [out] */ mdMethodDef *pToken); + HRESULT STDMETHODCALLTYPE GetStackRange(/* [out] */ CORDB_ADDRESS *pStart, + /* [out] */ CORDB_ADDRESS *pEnd); + HRESULT STDMETHODCALLTYPE GetCaller(/* [out] */ ICorDebugFrame **ppFrame); + HRESULT STDMETHODCALLTYPE GetCallee(/* [out] */ ICorDebugFrame **ppFrame); + HRESULT STDMETHODCALLTYPE + CreateStepper(/* [out] */ ICorDebugStepper **ppStepper); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE + GetIP(/* [out] */ ULONG32 *pnOffset, + /* [out] */ CorDebugMappingResult *pMappingResult); + HRESULT STDMETHODCALLTYPE SetIP(/* [in] */ ULONG32 nOffset); + HRESULT STDMETHODCALLTYPE + EnumerateLocalVariables(/* [out] */ ICorDebugValueEnum **ppValueEnum); + HRESULT STDMETHODCALLTYPE GetLocalVariable( + /* [in] */ DWORD dwIndex, /* [out] */ ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE + EnumerateArguments(/* [out] */ ICorDebugValueEnum **ppValueEnum); + HRESULT STDMETHODCALLTYPE GetArgument(/* [in] */ DWORD dwIndex, + /* [out] */ ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetStackDepth(/* [out] */ ULONG32 *pDepth); + HRESULT STDMETHODCALLTYPE GetStackValue(/* [in] */ DWORD dwIndex, + /* [out] */ ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE CanSetIP(/* [in] */ ULONG32 nOffset); + HRESULT STDMETHODCALLTYPE RemapFunction(ULONG32 newILOffset); + HRESULT STDMETHODCALLTYPE + EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum); + HRESULT STDMETHODCALLTYPE + GetReturnValueForILOffset(ULONG32 ILoffset, ICorDebugValue **ppReturnValue); + HRESULT STDMETHODCALLTYPE + EnumerateLocalVariablesEx(ILCodeKind flags, ICorDebugValueEnum **ppValueEnum); + HRESULT STDMETHODCALLTYPE GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, + ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetCodeEx(ILCodeKind flags, ICorDebugCode **ppCode); +}; + +class CordbNativeFrame : public CordbBaseMono, + public ICorDebugNativeFrame, + public ICorDebugNativeFrame2 { + CordbJITILFrame *m_JITILFrame; + +public: + CordbThread *thread; + CordbNativeFrame(Connection *conn, int frameid, int methodId, int il_offset, + int flags, CordbThread *thread); + HRESULT STDMETHODCALLTYPE GetIP(ULONG32 *pnOffset); + HRESULT STDMETHODCALLTYPE SetIP(ULONG32 nOffset); + HRESULT STDMETHODCALLTYPE GetRegisterSet(ICorDebugRegisterSet **ppRegisters); + HRESULT STDMETHODCALLTYPE GetLocalRegisterValue(CorDebugRegister reg, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetLocalDoubleRegisterValue( + CorDebugRegister highWordReg, CorDebugRegister lowWordReg, + ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetLocalMemoryValue(CORDB_ADDRESS address, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetLocalRegisterMemoryValue( + CorDebugRegister highWordReg, CORDB_ADDRESS lowWordAddress, + ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetLocalMemoryRegisterValue( + CORDB_ADDRESS highWordAddress, CorDebugRegister lowWordRegister, + ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE CanSetIP(ULONG32 nOffset); + HRESULT STDMETHODCALLTYPE GetChain(ICorDebugChain **ppChain); + HRESULT STDMETHODCALLTYPE GetCode(ICorDebugCode **ppCode); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction **ppFunction); + HRESULT STDMETHODCALLTYPE GetFunctionToken(mdMethodDef *pToken); + HRESULT STDMETHODCALLTYPE GetStackRange(CORDB_ADDRESS *pStart, + CORDB_ADDRESS *pEnd); + HRESULT STDMETHODCALLTYPE GetCaller(ICorDebugFrame **ppFrame); + HRESULT STDMETHODCALLTYPE GetCallee(ICorDebugFrame **ppFrame); + HRESULT STDMETHODCALLTYPE CreateStepper(ICorDebugStepper **ppStepper); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE IsChild(BOOL *pIsChild); + HRESULT STDMETHODCALLTYPE IsMatchingParentFrame( + ICorDebugNativeFrame2 *pPotentialParentFrame, BOOL *pIsParent); + HRESULT STDMETHODCALLTYPE GetStackParameterSize(ULONG32 *pSize); +}; + +class CordbFrameEnum : public CordbBaseMono, public ICorDebugFrameEnum { +public: + CordbThread *thread; + int nframes; + CordbNativeFrame **frames; + CordbFrameEnum(Connection *conn, CordbThread *thread); + HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugFrame *frames[], + ULONG *pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum **ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG *pcelt); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-function.cpp b/src/mono/dbi/cordb-function.cpp new file mode 100644 index 00000000000000..43be2d53755a05 --- /dev/null +++ b/src/mono/dbi/cordb-function.cpp @@ -0,0 +1,179 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-FUNCTION.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbFunction::CordbFunction(Connection *conn, mdToken token, int id, + CordbModule *module) + : CordbBaseMono(conn) { + this->token = token; + this->id = id; + code = NULL; + this->module = module; +} + +HRESULT __stdcall CordbFunction::QueryInterface(REFIID id, void **pInterface) { + if (id == IID_ICorDebugFunction) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugFunction2) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugFunction3) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugFunction4) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = + static_cast(static_cast(this)); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + + return S_OK; +} + +ULONG __stdcall CordbFunction::AddRef(void) { return 0; } + +ULONG __stdcall CordbFunction::Release(void) { return 0; } + +HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule **ppModule) { + if (module == NULL) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, id); + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + DEBUG_PRINTF( + 1, "CordbFunction - GetModule - IMPLEMENTED - ENTREI NO 0.1 - %d\n", + id); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + + int module_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + DEBUG_PRINTF( + 1, "CordbFunction - GetModule - IMPLEMENTED - ENTREI NO 0.2 - %d\n", + module_id); + + module = (CordbModule *)g_hash_table_lookup(conn->ppCordb->modules, + GINT_TO_POINTER(module_id)); + } + + *ppModule = static_cast(this->module); + DEBUG_PRINTF(1, "CordbFunction - GetModule - IMPLEMENTED - %p\n", + this->module); + + if (!*ppModule) + return S_FALSE; + return S_OK; +} + +HRESULT __stdcall CordbFunction::GetClass(ICorDebugClass **ppClass) { + DEBUG_PRINTF(1, "CordbFunction - GetClass - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunction::GetToken(mdMethodDef *pMethodDef) { + if (this->token == 0) { + DEBUG_PRINTF( + 1, "CordbFunction - GetToken - IMPLEMENTED - ENTREI NO 0 - %d\n", id); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, id); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_TOKEN, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + DEBUG_PRINTF( + 1, "CordbFunction - GetToken - IMPLEMENTED - ENTREI NO 0.1 - %d\n", id); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + + this->token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + } + *pMethodDef = this->token; + DEBUG_PRINTF(1, "CordbFunction - GetToken - IMPLEMENTED - %d\n", *pMethodDef); + return S_OK; +} + +HRESULT __stdcall CordbFunction::GetILCode(ICorDebugCode **ppCode) { + if (code == NULL) + code = new CordbCode(conn, this); + *ppCode = static_cast(code); + DEBUG_PRINTF(1, "CordbFunction - GetILCode - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbFunction::GetNativeCode(ICorDebugCode **ppCode) { + *ppCode = static_cast(code); + DEBUG_PRINTF(1, "CordbFunction - GetNativeCode - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbFunction::CreateBreakpoint( + ICorDebugFunctionBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, "CordbFunction - CreateBreakpoint - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunction::GetLocalVarSigToken(mdSignature *pmdSig) { + DEBUG_PRINTF(1, "CordbFunction - GetLocalVarSigToken - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunction::GetCurrentVersionNumber( + ULONG32 *pnCurrentVersion) { + *pnCurrentVersion = 1; + DEBUG_PRINTF(1, "CordbFunction - GetCurrentVersionNumber - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbFunction::SetJMCStatus(BOOL bIsJustMyCode) { + DEBUG_PRINTF(1, "CordbFunction - SetJMCStatus - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunction::GetJMCStatus(BOOL *pbIsJustMyCode) { + DEBUG_PRINTF(1, "CordbFunction - GetJMCStatus - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunction::EnumerateNativeCode( + ICorDebugCodeEnum **ppCodeEnum) { + DEBUG_PRINTF(1, "CordbFunction - EnumerateNativeCode - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunction::GetVersionNumber(ULONG32 *pnVersion) { + *pnVersion = 1; + DEBUG_PRINTF(1, "CordbFunction - GetVersionNumber - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT __stdcall CordbFunction::GetActiveReJitRequestILCode( + ICorDebugILCode **ppReJitedILCode) { + DEBUG_PRINTF( + 1, "CordbFunction - GetActiveReJitRequestILCode - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbFunction::CreateNativeBreakpoint( + ICorDebugFunctionBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, "CordbFunction - CreateNativeBreakpoint - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} diff --git a/src/mono/dbi/cordb-function.h b/src/mono/dbi/cordb-function.h new file mode 100644 index 00000000000000..be0a5bbba4ddd4 --- /dev/null +++ b/src/mono/dbi/cordb-function.h @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-FUNCTION.H +// + +#ifndef __MONO_DEBUGGER_CORDB_FUNCTION_H__ +#define __MONO_DEBUGGER_CORDB_FUNCTION_H__ + +#include +#include + +class CordbFunction : public CordbBaseMono, + public ICorDebugFunction, + public ICorDebugFunction2, + public ICorDebugFunction3, + public ICorDebugFunction4 { +public: + int id; + mdToken token; + CordbCode *code; + CordbModule *module; + + CordbFunction(Connection *conn, mdToken token, int id, CordbModule *module); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE GetModule(/* [out] */ ICorDebugModule **ppModule); + HRESULT STDMETHODCALLTYPE GetClass(/* [out] */ ICorDebugClass **ppClass); + HRESULT STDMETHODCALLTYPE GetToken(/* [out] */ mdMethodDef *pMethodDef); + HRESULT STDMETHODCALLTYPE GetILCode(/* [out] */ ICorDebugCode **ppCode); + HRESULT STDMETHODCALLTYPE GetNativeCode(/* [out] */ ICorDebugCode **ppCode); + HRESULT STDMETHODCALLTYPE + CreateBreakpoint(/* [out] */ ICorDebugFunctionBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE + GetLocalVarSigToken(/* [out] */ mdSignature *pmdSig); + HRESULT STDMETHODCALLTYPE + GetCurrentVersionNumber(/* [out] */ ULONG32 *pnCurrentVersion); + HRESULT STDMETHODCALLTYPE SetJMCStatus(/* [in] */ BOOL bIsJustMyCode); + HRESULT STDMETHODCALLTYPE GetJMCStatus(/* [out] */ BOOL *pbIsJustMyCode); + HRESULT STDMETHODCALLTYPE + EnumerateNativeCode(/* [out] */ ICorDebugCodeEnum **ppCodeEnum); + HRESULT STDMETHODCALLTYPE GetVersionNumber(/* [out] */ ULONG32 *pnVersion); + HRESULT STDMETHODCALLTYPE + GetActiveReJitRequestILCode(ICorDebugILCode **ppReJitedILCode); + HRESULT STDMETHODCALLTYPE + CreateNativeBreakpoint(ICorDebugFunctionBreakpoint **ppBreakpoint); +}; + +#endif diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp new file mode 100644 index 00000000000000..05d6b750e75e9f --- /dev/null +++ b/src/mono/dbi/cordb-process.cpp @@ -0,0 +1,453 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-PROCESS.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbProcess::CordbProcess() : CordbBaseMono(NULL) { + suspended = false; + appdomains = g_ptr_array_new(); +} + +HRESULT CordbProcess::EnumerateLoaderHeapMemoryRegions( + /* [out] */ ICorDebugMemoryRangeEnum **ppRanges) { + DEBUG_PRINTF( + 1, "CordbProcess - EnumerateLoaderHeapMemoryRegions - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnableGCNotificationEvents(BOOL fEnable) { + DEBUG_PRINTF(1, + "CordbProcess - EnableGCNotificationEvents - NOT IMPLEMENTED\n"); + + return S_OK; +} + +HRESULT CordbProcess::EnableExceptionCallbacksOutsideOfMyCode( + /* [in] */ BOOL enableExceptionsOutsideOfJMC) { + DEBUG_PRINTF(1, "CordbProcess - EnableExceptionCallbacksOutsideOfMyCode - " + "NOT IMPLEMENTED\n"); + + return S_OK; +} + +HRESULT CordbProcess::SetWriteableMetadataUpdateMode( + WriteableMetadataUpdateMode flags) { + DEBUG_PRINTF( + 1, "CordbProcess - SetWriteableMetadataUpdateMode - NOT IMPLEMENTED\n"); + + return S_OK; +} + +HRESULT CordbProcess::GetGCHeapInformation( + /* [out] */ COR_HEAPINFO *pHeapInfo) { + DEBUG_PRINTF(1, "CordbProcess - GetGCHeapInformation - NOT IMPLEMENTED\n"); + + return S_OK; +} + +HRESULT CordbProcess::EnumerateHeap( + /* [out] */ ICorDebugHeapEnum **ppObjects) { + DEBUG_PRINTF(1, "CordbProcess - EnumerateHeap - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnumerateHeapRegions( + /* [out] */ ICorDebugHeapSegmentEnum **ppRegions) { + DEBUG_PRINTF(1, "CordbProcess - EnumerateHeapRegions - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetObject( + /* [in] */ CORDB_ADDRESS addr, + /* [out] */ ICorDebugObjectValue **pObject) { + DEBUG_PRINTF(1, "CordbProcess - GetObject - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnumerateGCReferences( + /* [in] */ BOOL enumerateWeakReferences, + /* [out] */ ICorDebugGCReferenceEnum **ppEnum) { + DEBUG_PRINTF(1, "CordbProcess - EnumerateGCReferences - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnumerateHandles( + /* [in] */ CorGCReferenceType types, + /* [out] */ ICorDebugGCReferenceEnum **ppEnum) { + DEBUG_PRINTF(1, "CordbProcess - EnumerateHandles - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetTypeID( + /* [in] */ CORDB_ADDRESS obj, + /* [out] */ COR_TYPEID *pId) { + DEBUG_PRINTF(1, "CordbProcess - GetTypeID - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetTypeForTypeID( + /* [in] */ COR_TYPEID id, + /* [out] */ ICorDebugType **ppType) { + DEBUG_PRINTF(1, "CordbProcess - GetTypeForTypeID - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetArrayLayout( + /* [in] */ COR_TYPEID id, + /* [out] */ COR_ARRAY_LAYOUT *pLayout) { + DEBUG_PRINTF(1, "CordbProcess - GetArrayLayout - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetTypeLayout( + /* [in] */ COR_TYPEID id, + /* [out] */ COR_TYPE_LAYOUT *pLayout) { + DEBUG_PRINTF(1, "CordbProcess - GetTypeLayout - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetTypeFields( + /* [in] */ COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], + ULONG32 *pceltNeeded) { + DEBUG_PRINTF(1, "CordbProcess - GetTypeFields - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnableNGENPolicy( + /* [in] */ CorDebugNGENPolicy ePolicy) { + DEBUG_PRINTF(1, "CordbProcess - EnableNGENPolicy - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::Filter( + /* [size_is][length_is][in] */ const BYTE pRecord[], + /* [in] */ DWORD countBytes, + /* [in] */ CorDebugRecordFormat format, + /* [in] */ DWORD dwFlags, + /* [in] */ DWORD dwThreadId, + /* [in] */ ICorDebugManagedCallback *pCallback, + /* [out][in] */ CORDB_CONTINUE_STATUS *pContinueStatus) { + DEBUG_PRINTF(1, "CordbProcess - Filter - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::ProcessStateChanged( + /* [in] */ CorDebugStateChange eChange) { + DEBUG_PRINTF(1, "CordbProcess - ProcessStateChanged - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::SetEnableCustomNotification(ICorDebugClass *pClass, + BOOL fEnable) { + DEBUG_PRINTF( + 1, "CordbProcess - SetEnableCustomNotification - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetID( + /* [out] */ DWORD *pdwProcessId) { + DEBUG_PRINTF(1, "CordbProcess - GetID - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetHandle( + /* [out] */ HPROCESS *phProcessHandle) { + DEBUG_PRINTF(1, "CordbProcess - GetHandle - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetThread( + /* [in] */ DWORD dwThreadId, + /* [out] */ ICorDebugThread **ppThread) { + DEBUG_PRINTF(1, "CordbProcess - GetThread - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnumerateObjects( + /* [out] */ ICorDebugObjectEnum **ppObjects) { + DEBUG_PRINTF(1, "CordbProcess - EnumerateObjects - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::IsTransitionStub( + /* [in] */ CORDB_ADDRESS address, + /* [out] */ BOOL *pbTransitionStub) { + DEBUG_PRINTF(1, "CordbProcess - IsTransitionStub - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::IsOSSuspended( + /* [in] */ DWORD threadID, + /* [out] */ BOOL *pbSuspended) { + DEBUG_PRINTF(1, "CordbProcess - IsOSSuspended - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetThreadContext( + /* [in] */ DWORD threadID, + /* [in] */ ULONG32 contextSize, + /* [size_is][length_is][out][in] */ BYTE context[]) { + DEBUG_PRINTF(1, "CordbProcess - GetThreadContext - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::SetThreadContext( + /* [in] */ DWORD threadID, + /* [in] */ ULONG32 contextSize, + /* [size_is][length_is][in] */ BYTE context[]) { + DEBUG_PRINTF(1, "CordbProcess - SetThreadContext - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::ReadMemory( + /* [in] */ CORDB_ADDRESS address, + /* [in] */ DWORD size, + /* [length_is][size_is][out] */ BYTE buffer[], + /* [out] */ SIZE_T *read) { + memcpy(buffer, (void *)address, size); + if (read != NULL) + *read = size; + DEBUG_PRINTF(1, "CordbProcess - ReadMemory - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::WriteMemory( + /* [in] */ CORDB_ADDRESS address, + /* [in] */ DWORD size, + /* [size_is][in] */ BYTE buffer[], + /* [out] */ SIZE_T *written) { + DEBUG_PRINTF(1, "CordbProcess - WriteMemory - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::ClearCurrentException( + /* [in] */ DWORD threadID) { + DEBUG_PRINTF(1, "CordbProcess - ClearCurrentException - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnableLogMessages( + /* [in] */ BOOL fOnOff) { + DEBUG_PRINTF(1, "CordbProcess - EnableLogMessages - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::ModifyLogSwitch( + /* [annotation][in] */ + _In_ WCHAR *pLogSwitchName, + /* [in] */ LONG lLevel) { + DEBUG_PRINTF(1, "CordbProcess - ModifyLogSwitch - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnumerateAppDomains( + /* [out] */ ICorDebugAppDomainEnum **ppAppDomains) { + *ppAppDomains = new CordbAppDomainEnum(conn, this); + DEBUG_PRINTF(1, "CordbProcess - EnumerateAppDomains - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetObject( + /* [out] */ ICorDebugValue **ppObject) { + DEBUG_PRINTF(1, "CordbProcess - GetObject - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::ThreadForFiberCookie( + /* [in] */ DWORD fiberCookie, + /* [out] */ ICorDebugThread **ppThread) { + DEBUG_PRINTF(1, "CordbProcess - ThreadForFiberCookie - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetHelperThreadID( + /* [out] */ DWORD *pThreadID) { + DEBUG_PRINTF(1, "GetHelperThreadID - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetThreadForTaskID( + /* [in] */ TASKID taskid, + /* [out] */ ICorDebugThread2 **ppThread) { + DEBUG_PRINTF(1, "CordbProcess - GetHelperThreadID - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetVersion( + /* [out] */ COR_VERSION *version) { + DEBUG_PRINTF(1, "CordbProcess - GetVersion - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::SetUnmanagedBreakpoint( + /* [in] */ CORDB_ADDRESS address, + /* [in] */ ULONG32 bufsize, + /* [length_is][size_is][out] */ BYTE buffer[], + /* [out] */ ULONG32 *bufLen) { + DEBUG_PRINTF(1, "CordbProcess - SetUnmanagedBreakpoint - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::ClearUnmanagedBreakpoint( + /* [in] */ CORDB_ADDRESS address) { + DEBUG_PRINTF(1, + "CordbProcess - ClearUnmanagedBreakpoint - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::SetDesiredNGENCompilerFlags( + /* [in] */ DWORD pdwFlags) { + DEBUG_PRINTF( + 1, "CordbProcess - SetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetDesiredNGENCompilerFlags( + /* [out] */ DWORD *pdwFlags) { + DEBUG_PRINTF( + 1, "CordbProcess - GetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::GetReferenceValueFromGCHandle( + /* [in] */ UINT_PTR handle, + /* [out] */ ICorDebugReferenceValue **pOutValue) { + DEBUG_PRINTF( + 1, "CordbProcess - GetReferenceValueFromGCHandle - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::QueryInterface( + /* [in] */ REFIID id, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { + if (id == IID_ICorDebugProcess) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugController) { + *pInterface = static_cast( + static_cast(this)); + } else if (id == IID_ICorDebugProcess2) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugProcess3) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugProcess4) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugProcess5) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugProcess7) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugProcess8) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugProcess10) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugProcess11) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = + static_cast(static_cast(this)); + } + + else { + DEBUG_PRINTF(1, "CordbProcess - QueryInterface - E_NOTIMPL\n"); + + *pInterface = NULL; + return E_NOINTERFACE; + } + + return S_OK; +} + +ULONG CordbProcess::AddRef(void) { return S_OK; } + +ULONG CordbProcess::Release(void) { return S_OK; } + +HRESULT CordbProcess::Stop( + /* [in] */ DWORD dwTimeoutIgnored) { + DEBUG_PRINTF(1, "CordbProcess - Stop - IMPLEMENTED\n"); + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, 128); + conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SUSPEND, &sendbuf); + suspended = true; + return S_OK; +} + +HRESULT CordbProcess::Continue( + /* [in] */ BOOL fIsOutOfBand) { + DEBUG_PRINTF(1, "CordbProcess - Continue - IMPLEMENTED\n"); + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, 128); + conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_RESUME, &sendbuf); + return S_OK; +} + +HRESULT CordbProcess::IsRunning( + /* [out] */ BOOL *pbRunning) { + *pbRunning = true; + DEBUG_PRINTF(1, "CordbProcess - IsRunning - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::HasQueuedCallbacks( + /* [in] */ ICorDebugThread *pThread, + /* [out] */ BOOL *pbQueued) { + // conn->process_packet_from_queue(); + *pbQueued = false; + DEBUG_PRINTF(1, "CordbProcess - HasQueuedCallbacks - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::EnumerateThreads( + /* [out] */ ICorDebugThreadEnum **ppThreads) { + DEBUG_PRINTF(1, "CordbProcess - EnumerateThreads - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::SetAllThreadsDebugState( + /* [in] */ CorDebugThreadState state, + /* [in] */ ICorDebugThread *pExceptThisThread) { + DEBUG_PRINTF(1, "CordbProcess - SetAllThreadsDebugState - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::Detach(void) { + DEBUG_PRINTF(1, "CordbProcess - Detach - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::Terminate( + /* [in] */ UINT exitCode) { + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, 128); + m_dbgprot_buffer_add_int(&sendbuf, -1); + conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_EXIT, &sendbuf); + return S_OK; +} + +HRESULT CordbProcess::CanCommitChanges( + /* [in] */ ULONG cSnapshots, + /* [size_is][in] */ ICorDebugEditAndContinueSnapshot *pSnapshots[], + /* [out] */ ICorDebugErrorInfoEnum **pError) { + DEBUG_PRINTF(1, "CordbProcess - CanCommitChanges - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT CordbProcess::CommitChanges( + /* [in] */ ULONG cSnapshots, + /* [size_is][in] */ ICorDebugEditAndContinueSnapshot *pSnapshots[], + /* [out] */ ICorDebugErrorInfoEnum **pError) { + DEBUG_PRINTF(1, "CordbProcess - CommitChanges - NOT IMPLEMENTED\n"); + return S_OK; +} diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h new file mode 100644 index 00000000000000..ffc499c8165c46 --- /dev/null +++ b/src/mono/dbi/cordb-process.h @@ -0,0 +1,152 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-PROCESS.H +// + +#ifndef __MONO_DEBUGGER_CORDB_PROCESS_H__ +#define __MONO_DEBUGGER_CORDB_PROCESS_H__ + +#include + +class CordbProcess : public CordbBaseMono, + public ICorDebugProcess, + public ICorDebugProcess2, + public ICorDebugProcess3, + public ICorDebugProcess4, + public ICorDebugProcess5, + public ICorDebugProcess7, + public ICorDebugProcess8, + public ICorDebugProcess10, + public ICorDebugProcess11 { +public: + GPtrArray *appdomains; + int suspended; + Cordb *cordb; + CordbProcess(); + HRESULT STDMETHODCALLTYPE EnumerateLoaderHeapMemoryRegions( + /* [out] */ ICorDebugMemoryRangeEnum **ppRanges); + HRESULT STDMETHODCALLTYPE EnableGCNotificationEvents(BOOL fEnable); + HRESULT STDMETHODCALLTYPE EnableExceptionCallbacksOutsideOfMyCode( + /* [in] */ BOOL enableExceptionsOutsideOfJMC); + HRESULT STDMETHODCALLTYPE + SetWriteableMetadataUpdateMode(WriteableMetadataUpdateMode flags); + HRESULT STDMETHODCALLTYPE + GetGCHeapInformation(/* [out] */ COR_HEAPINFO *pHeapInfo); + HRESULT STDMETHODCALLTYPE + EnumerateHeap(/* [out] */ ICorDebugHeapEnum **ppObjects); + HRESULT STDMETHODCALLTYPE + EnumerateHeapRegions(/* [out] */ ICorDebugHeapSegmentEnum **ppRegions); + HRESULT STDMETHODCALLTYPE + GetObject(/* [in] */ CORDB_ADDRESS addr, + /* [out] */ ICorDebugObjectValue **pObject); + HRESULT STDMETHODCALLTYPE + EnumerateGCReferences(/* [in] */ BOOL enumerateWeakReferences, /* [out] */ + ICorDebugGCReferenceEnum **ppEnum); + HRESULT STDMETHODCALLTYPE + EnumerateHandles(/* [in] */ CorGCReferenceType types, /* [out] */ + ICorDebugGCReferenceEnum **ppEnum); + HRESULT STDMETHODCALLTYPE GetTypeID(/* [in] */ CORDB_ADDRESS obj, + /* [out] */ COR_TYPEID *pId); + HRESULT STDMETHODCALLTYPE GetTypeForTypeID( + /* [in] */ COR_TYPEID id, /* [out] */ ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE GetArrayLayout( + /* [in] */ COR_TYPEID id, /* [out] */ COR_ARRAY_LAYOUT *pLayout); + HRESULT STDMETHODCALLTYPE GetTypeLayout(/* [in] */ COR_TYPEID id, + /* [out] */ COR_TYPE_LAYOUT *pLayout); + HRESULT STDMETHODCALLTYPE GetTypeFields(/* [in] */ COR_TYPEID id, + ULONG32 celt, COR_FIELD fields[], + ULONG32 *pceltNeeded); + HRESULT STDMETHODCALLTYPE + EnableNGENPolicy(/* [in] */ CorDebugNGENPolicy ePolicy); + HRESULT STDMETHODCALLTYPE + Filter(/* [size_is][length_is][in] */ const BYTE pRecord[], + /* [in] */ DWORD countBytes, + /* [in] */ CorDebugRecordFormat format, /* [in] */ + DWORD dwFlags, /* [in] */ DWORD dwThreadId, + /* [in] */ ICorDebugManagedCallback *pCallback, + /* [out][in] */ + CORDB_CONTINUE_STATUS *pContinueStatus); + HRESULT STDMETHODCALLTYPE + ProcessStateChanged(/* [in] */ CorDebugStateChange eChange); + HRESULT STDMETHODCALLTYPE SetEnableCustomNotification(ICorDebugClass *pClass, + BOOL fEnable); + HRESULT STDMETHODCALLTYPE GetID(/* [out] */ DWORD *pdwProcessId); + HRESULT STDMETHODCALLTYPE GetHandle(/* [out] */ HPROCESS *phProcessHandle); + HRESULT STDMETHODCALLTYPE GetThread(/* [in] */ DWORD dwThreadId, + /* [out] */ ICorDebugThread **ppThread); + HRESULT STDMETHODCALLTYPE + EnumerateObjects(/* [out] */ ICorDebugObjectEnum **ppObjects); + HRESULT STDMETHODCALLTYPE IsTransitionStub( + /* [in] */ CORDB_ADDRESS address, /* [out] */ BOOL *pbTransitionStub); + HRESULT STDMETHODCALLTYPE IsOSSuspended(/* [in] */ DWORD threadID, + /* [out] */ BOOL *pbSuspended); + HRESULT STDMETHODCALLTYPE + GetThreadContext(/* [in] */ DWORD threadID, /* [in] */ ULONG32 contextSize, + /* [size_is][length_is][out][in] */ BYTE context[]); + HRESULT STDMETHODCALLTYPE + SetThreadContext(/* [in] */ DWORD threadID, /* [in] */ ULONG32 contextSize, + /* [size_is][length_is][in] */ BYTE context[]); + HRESULT STDMETHODCALLTYPE + ReadMemory(/* [in] */ CORDB_ADDRESS address, /* [in] */ DWORD size, + /* [length_is][size_is][out] */ BYTE buffer[], /* [out] */ + SIZE_T *read); + HRESULT STDMETHODCALLTYPE + WriteMemory(/* [in] */ CORDB_ADDRESS address, + /* [in] */ DWORD size, /* [size_is][in] */ + BYTE buffer[], /* [out] */ SIZE_T *written); + HRESULT STDMETHODCALLTYPE ClearCurrentException(/* [in] */ DWORD threadID); + HRESULT STDMETHODCALLTYPE EnableLogMessages(/* [in] */ BOOL fOnOff); + HRESULT STDMETHODCALLTYPE + ModifyLogSwitch(/* [annotation][in] */ _In_ WCHAR *pLogSwitchName, + /* [in] */ LONG lLevel); + HRESULT STDMETHODCALLTYPE + EnumerateAppDomains(/* [out] */ ICorDebugAppDomainEnum **ppAppDomains); + HRESULT STDMETHODCALLTYPE GetObject(/* [out] */ ICorDebugValue **ppObject); + HRESULT STDMETHODCALLTYPE ThreadForFiberCookie( + /* [in] */ DWORD fiberCookie, /* [out] */ ICorDebugThread **ppThread); + HRESULT STDMETHODCALLTYPE GetHelperThreadID(/* [out] */ DWORD *pThreadID); + HRESULT STDMETHODCALLTYPE GetThreadForTaskID( + /* [in] */ TASKID taskid, /* [out] */ ICorDebugThread2 **ppThread); + HRESULT STDMETHODCALLTYPE GetVersion(/* [out] */ COR_VERSION *version); + HRESULT STDMETHODCALLTYPE SetUnmanagedBreakpoint( + /* [in] */ CORDB_ADDRESS address, /* [in] */ ULONG32 bufsize, + /* [length_is][size_is][out] */ BYTE buffer[], + /* [out] */ ULONG32 *bufLen); + HRESULT STDMETHODCALLTYPE + ClearUnmanagedBreakpoint(/* [in] */ CORDB_ADDRESS address); + HRESULT STDMETHODCALLTYPE + SetDesiredNGENCompilerFlags(/* [in] */ DWORD pdwFlags); + HRESULT STDMETHODCALLTYPE + GetDesiredNGENCompilerFlags(/* [out] */ DWORD *pdwFlags); + HRESULT STDMETHODCALLTYPE + GetReferenceValueFromGCHandle(/* [in] */ UINT_PTR handle, /* [out] */ + ICorDebugReferenceValue **pOutValue); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE Stop(/* [in] */ DWORD dwTimeoutIgnored); + HRESULT STDMETHODCALLTYPE Continue(/* [in] */ BOOL fIsOutOfBand); + HRESULT STDMETHODCALLTYPE IsRunning(/* [out] */ BOOL *pbRunning); + HRESULT STDMETHODCALLTYPE HasQueuedCallbacks( + /* [in] */ ICorDebugThread *pThread, /* [out] */ BOOL *pbQueued); + HRESULT STDMETHODCALLTYPE + EnumerateThreads(/* [out] */ ICorDebugThreadEnum **ppThreads); + HRESULT STDMETHODCALLTYPE + SetAllThreadsDebugState(/* [in] */ CorDebugThreadState state, /* [in] */ + ICorDebugThread *pExceptThisThread); + HRESULT STDMETHODCALLTYPE Detach(void); + HRESULT STDMETHODCALLTYPE Terminate(/* [in] */ UINT exitCode); + HRESULT STDMETHODCALLTYPE + CanCommitChanges(/* [in] */ ULONG cSnapshots, /* [size_is][in] */ + ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + ICorDebugErrorInfoEnum **pError); + HRESULT STDMETHODCALLTYPE + CommitChanges(/* [in] */ ULONG cSnapshots, /* [size_is][in] */ + ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + ICorDebugErrorInfoEnum **pError); +}; + +#endif diff --git a/src/mono/dbi/cordb-register.cpp b/src/mono/dbi/cordb-register.cpp new file mode 100644 index 00000000000000..c2c9d87cbf86a3 --- /dev/null +++ b/src/mono/dbi/cordb-register.cpp @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-REGISTER.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +HRESULT __stdcall CordbRegisteSet::GetRegistersAvailable(ULONG64 *pAvailable) { + DEBUG_PRINTF(1, + "CordbRegisteSet - GetRegistersAvailable - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +CordbRegisteSet::CordbRegisteSet(Connection *conn, guint8 *ctx, guint32 ctx_len) + : CordbBaseMono(conn) { + this->ctx = ctx; + this->ctx_len = ctx_len; +} + +HRESULT __stdcall CordbRegisteSet::QueryInterface(REFIID id, + void **pInterface) { + DEBUG_PRINTF(1, "CordbRegisteSet - QueryInterface - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT __stdcall CordbRegisteSet::GetRegisters(ULONG64 mask, ULONG32 regCount, + CORDB_REGISTER regBuffer[]) { + DEBUG_PRINTF(1, "CordbRegisteSet - GetRegisters - NOT IMPLEMENTED"); + return E_NOTIMPL; +} + +ULONG __stdcall CordbRegisteSet::Release(void) { return 0; } + +ULONG __stdcall CordbRegisteSet::AddRef(void) { return 0; } + +HRESULT STDMETHODCALLTYPE CordbRegisteSet::SetRegisters( + /* [in] */ ULONG64 mask, + /* [in] */ ULONG32 regCount, + /* [size_is][in] */ CORDB_REGISTER regBuffer[]) { + DEBUG_PRINTF(1, "CordbRegisteSet - SetRegisters - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbRegisteSet::GetThreadContext( + /* [in] */ ULONG32 contextSize, + /* [size_is][length_is][out][in] */ BYTE context[]) { + DEBUG_PRINTF(1, "CordbRegisteSet - GetThreadContext - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbRegisteSet::SetThreadContext( + /* [in] */ ULONG32 contextSize, + /* [size_is][length_is][in] */ BYTE context[]) { + DEBUG_PRINTF(1, "CordbRegisteSet - SetThreadContext - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} diff --git a/src/mono/dbi/cordb-register.h b/src/mono/dbi/cordb-register.h new file mode 100644 index 00000000000000..e8460227a76209 --- /dev/null +++ b/src/mono/dbi/cordb-register.h @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-REGISTER.H +// + +#ifndef __MONO_DEBUGGER_CORDB_REGISTER_H__ +#define __MONO_DEBUGGER_CORDB_REGISTER_H__ + +#include + +class CordbRegisteSet : public CordbBaseMono, public ICorDebugRegisterSet { + guint8 *ctx; + guint32 ctx_len; + +public: + CordbRegisteSet(Connection *conn, guint8 *ctx, guint32 ctx_len); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE + GetRegistersAvailable(/* [out] */ ULONG64 *pAvailable); + HRESULT STDMETHODCALLTYPE + GetRegisters(/* [in] */ ULONG64 mask, /* [in] */ ULONG32 regCount, + /* [length_is][size_is][out] */ CORDB_REGISTER regBuffer[]); + HRESULT STDMETHODCALLTYPE SetRegisters( + /* [in] */ ULONG64 mask, /* [in] */ ULONG32 regCount, /* [size_is][in] */ + CORDB_REGISTER regBuffer[]); + HRESULT STDMETHODCALLTYPE GetThreadContext( + /* [in] */ ULONG32 contextSize, /* [size_is][length_is][out][in] */ + BYTE context[]); + HRESULT STDMETHODCALLTYPE SetThreadContext( + /* [in] */ ULONG32 contextSize, /* [size_is][length_is][in] */ + BYTE context[]); +}; + +#endif diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp new file mode 100644 index 00000000000000..d0e369d5eb44b2 --- /dev/null +++ b/src/mono/dbi/cordb-stepper.cpp @@ -0,0 +1,124 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-STEPPER.CPP +// + +#include +#include + +#include +#include +#include +#include +#include + +using namespace std; + +CordbStepper::CordbStepper(Connection *conn, CordbThread *thread) + : CordbBaseMono(conn) { + this->thread = thread; + hasStepped = false; + isComplete = false; +} + +HRESULT STDMETHODCALLTYPE CordbStepper::IsActive(BOOL *pbActive) { + DEBUG_PRINTF(1, "CordbStepper - IsActive - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbStepper::Deactivate(void) { + DEBUG_PRINTF(1, "CordbStepper - Deactivate - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbStepper::SetInterceptMask(CorDebugIntercept mask) { + DEBUG_PRINTF(1, "CordbStepper - SetInterceptMask - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbStepper::SetUnmappedStopMask(CorDebugUnmappedStop mask) { + DEBUG_PRINTF(1, "CordbStepper - SetUnmappedStopMask - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbStepper::Step(BOOL bStepIn) { + DEBUG_PRINTF(1, "CordbStepper - Step - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, + COR_DEBUG_STEP_RANGE ranges[], + ULONG32 cRangeCount) { + isComplete = false; + hasStepped = true; + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); + + m_dbgprot_buffer_add_id(&sendbuf, thread->thread_id); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); + m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO : MDBGPROT_STEP_DEPTH_OVER); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); + + conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + + DEBUG_PRINTF(1, "CordbStepper - StepRange - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { + isComplete = false; + hasStepped = true; + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); + + m_dbgprot_buffer_add_id(&sendbuf, thread->thread_id); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_DEPTH_OUT); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); + + conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + + DEBUG_PRINTF(1, "CordbStepper - StepOut - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbStepper::SetRangeIL(BOOL bIL) { + DEBUG_PRINTF(1, "CordbStepper - SetRangeIL - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbStepper::QueryInterface(REFIID riid, + void **ppvObject) { + DEBUG_PRINTF(1, "CordbStepper - QueryInterface - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +ULONG STDMETHODCALLTYPE CordbStepper::AddRef(void) { + DEBUG_PRINTF(1, "CordbStepper - AddRef - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +ULONG STDMETHODCALLTYPE CordbStepper::Release(void) { + DEBUG_PRINTF(1, "CordbStepper - Release - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbStepper::SetJMC(BOOL fIsJMCStepper) { + DEBUG_PRINTF(1, "CordbStepper - SetJMC - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} diff --git a/src/mono/dbi/cordb-stepper.h b/src/mono/dbi/cordb-stepper.h new file mode 100644 index 00000000000000..20f85af03d239e --- /dev/null +++ b/src/mono/dbi/cordb-stepper.h @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-STEPPER.H +// + +#ifndef __MONO_DEBUGGER_CORDB_STEPPER_H__ +#define __MONO_DEBUGGER_CORDB_STEPPER_H__ + +#include + +class CordbStepper : public CordbBaseMono, + public ICorDebugStepper, + public ICorDebugStepper2 { + CordbThread *thread; + boolean hasStepped; + +public: + boolean isComplete; + CordbStepper(Connection *conn, CordbThread *thread); + HRESULT STDMETHODCALLTYPE IsActive(BOOL *pbActive); + HRESULT STDMETHODCALLTYPE Deactivate(void); + HRESULT STDMETHODCALLTYPE SetInterceptMask(CorDebugIntercept mask); + HRESULT STDMETHODCALLTYPE SetUnmappedStopMask(CorDebugUnmappedStop mask); + HRESULT STDMETHODCALLTYPE Step(BOOL bStepIn); + HRESULT STDMETHODCALLTYPE StepRange(BOOL bStepIn, + COR_DEBUG_STEP_RANGE ranges[], + ULONG32 cRangeCount); + HRESULT STDMETHODCALLTYPE StepOut(void); + HRESULT STDMETHODCALLTYPE SetRangeIL(BOOL bIL); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE SetJMC(BOOL fIsJMCStepper); +}; + +#endif diff --git a/src/mono/dbi/cordb-symbol.cpp b/src/mono/dbi/cordb-symbol.cpp new file mode 100644 index 00000000000000..d076bbf364d848 --- /dev/null +++ b/src/mono/dbi/cordb-symbol.cpp @@ -0,0 +1,2752 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-SYMBOL.CPP +// + +#include + +#include "stdafx.h" +#include "corerror.h" +#include "rwutil.h" +#include "mdlog.h" +#include "switches.h" +#include "posterror.h" +#include "stgio.h" +#include "sstring.h" + +#include "mdinternalrw.h" +#include "importhelper.h" + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +using namespace std; + +RegMeta::RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule) { + module_id = -1; + pCordbAssembly = cordbAssembly; + this->cordbModule = cordbModule; + parameters = g_hash_table_new(NULL, NULL); + token_id = 0; + + m_pStgdb = new CLiteWeightStgdbRW(); + ULONG32 pcchName = 0; + cordbModule->GetName(0, &pcchName, NULL); + + wchar_t *full_path; + full_path = (wchar_t *)malloc(sizeof(wchar_t) * pcchName); + cordbModule->GetName(pcchName, &pcchName, full_path); + + m_pStgdb->OpenForRead(full_path, NULL, 0, 0); +} + +HRESULT RegMeta::EnumGenericParams( + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tkOwner, // [IN] TypeDef or MethodDef whose generic parameters are + // requested + mdGenericParam rTokens[], // [OUT] Put GenericParams here. + ULONG cMaxTokens, // [IN] Max GenericParams to put. + ULONG *pcTokens) { + HRESULT hr = S_OK; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart; + ULONG ridEnd; + HENUMInternal *pEnum; + GenericParamRec *pRec; + ULONG index; + CMiniMdRW *pMiniMd = NULL; + + pMiniMd = &(m_pStgdb->m_MiniMd); + + // See if this version of the metadata can do Generics + if (!pMiniMd->SupportsGenerics()) { + if (pcTokens) + *pcTokens = 0; + hr = S_FALSE; + goto ErrExit; + } + + _ASSERTE(TypeFromToken(tkOwner) == mdtTypeDef || + TypeFromToken(tkOwner) == mdtMethodDef); + + if (*ppmdEnum == 0) { + // instantiating a new ENUM + + //@todo GENERICS: review this. Are we expecting a sorted table or not? + if (pMiniMd->IsSorted(TBL_GenericParam)) { + if (TypeFromToken(tkOwner) == mdtTypeDef) { + IfFailGo(pMiniMd->getGenericParamsForTypeDef(RidFromToken(tkOwner), + &ridEnd, &ridStart)); + } else { + IfFailGo(pMiniMd->getGenericParamsForMethodDef(RidFromToken(tkOwner), + &ridEnd, &ridStart)); + } + + IfFailGo(HENUMInternal::CreateSimpleEnum(mdtGenericParam, ridStart, + ridEnd, &pEnum)); + } else { + // table is not sorted so we have to create dynamic array + // create the dynamic enumerator + // + ridStart = 1; + ridEnd = pMiniMd->getCountGenericParams() + 1; + + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtGenericParam, &pEnum)); + + for (index = ridStart; index < ridEnd; index++) { + IfFailGo(pMiniMd->GetGenericParamRecord(index, &pRec)); + if (tkOwner == pMiniMd->getOwnerOfGenericParam(pRec)) { + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(index, mdtGenericParam))); + } + } + } + + // set the output parameter + *ppmdEnum = pEnum; + } else { + pEnum = *ppmdEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMaxTokens, rTokens, pcTokens); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} + +HRESULT RegMeta::GetGenericParamProps( // S_OK or error. + mdGenericParam rd, // [IN] The type parameter + ULONG *pulSequence, // [OUT] Parameter sequence number + DWORD *pdwAttr, // [OUT] Type parameter flags (for future use) + mdToken *ptOwner, // [OUT] The owner (TypeDef or MethodDef) + DWORD *reserved, // [OUT] The kind (TypeDef/Ref/Spec, for future use) + __out_ecount_opt(cchName) LPWSTR szName, // [OUT] The name + ULONG cchName, // [IN] Size of name buffer + ULONG *pchName) // [OUT] Actual size of name +{ + HRESULT hr = NOERROR; + + BEGIN_ENTRYPOINT_NOTHROW; + + GenericParamRec *pGenericParamRec; + CMiniMdRW *pMiniMd = NULL; + RID ridRD = RidFromToken(rd); + + pMiniMd = &(m_pStgdb->m_MiniMd); + + // See if this version of the metadata can do Generics + if (!pMiniMd->SupportsGenerics()) + IfFailGo(CLDB_E_INCOMPATIBLE); + + if ((TypeFromToken(rd) == mdtGenericParam) && (ridRD != 0)) { + IfFailGo( + pMiniMd->GetGenericParamRecord(RidFromToken(rd), &pGenericParamRec)); + + if (pulSequence) + *pulSequence = pMiniMd->getNumberOfGenericParam(pGenericParamRec); + if (pdwAttr) + *pdwAttr = pMiniMd->getFlagsOfGenericParam(pGenericParamRec); + if (ptOwner) + *ptOwner = pMiniMd->getOwnerOfGenericParam(pGenericParamRec); + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not + // rewritten with S_OK + if (pchName || szName) + IfFailGo(pMiniMd->getNameOfGenericParam(pGenericParamRec, szName, cchName, + pchName)); + } else + hr = META_E_BAD_INPUT_PARAMETER; + +ErrExit: + + return hr; +} // [OUT] Put size of name (wide chars) here. + +HRESULT RegMeta::GetMethodSpecProps( + mdMethodSpec mi, // [IN] The method instantiation + mdToken *tkParent, // [OUT] MethodDef or MemberRef + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob) { + + HRESULT hr = NOERROR; + + MethodSpecRec *pMethodSpecRec; + CMiniMdRW *pMiniMd = NULL; + + pMiniMd = &(m_pStgdb->m_MiniMd); + + // See if this version of the metadata can do Generics + if (!pMiniMd->SupportsGenerics()) + IfFailGo(CLDB_E_INCOMPATIBLE); + + _ASSERTE(TypeFromToken(mi) == mdtMethodSpec && RidFromToken(mi)); + + IfFailGo(pMiniMd->GetMethodSpecRecord(RidFromToken(mi), &pMethodSpecRec)); + + if (tkParent) + *tkParent = pMiniMd->getMethodOfMethodSpec(pMethodSpecRec); + + if (ppvSigBlob || pcbSigBlob) { + // caller wants signature information + PCCOR_SIGNATURE pvSigTmp; + ULONG cbSig; + IfFailGo(pMiniMd->getInstantiationOfMethodSpec(pMethodSpecRec, &pvSigTmp, + &cbSig)); + if (ppvSigBlob) + *ppvSigBlob = pvSigTmp; + if (pcbSigBlob) + *pcbSigBlob = cbSig; + } + +ErrExit: + + return hr; +} // [OUT] actual size of signature blob + +HRESULT RegMeta::EnumGenericParamConstraints( + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdGenericParam tk, // [IN] GenericParam whose constraints are requested + mdGenericParamConstraint + rGenericParamConstraints[], // [OUT] Put GenericParamConstraints here. + ULONG cMax, // [IN] Max GenericParamConstraints to put. + ULONG *pcGenericParamConstraints) { + DEBUG_PRINTF(1, + "CordbSymbol - EnumGenericParamConstraints - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] Put # put here. + +HRESULT RegMeta::GetGenericParamConstraintProps( // S_OK or error. + mdGenericParamConstraint gpc, // [IN] GenericParamConstraint + mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained + mdToken *ptkConstraintType) { + DEBUG_PRINTF( + 1, "CordbSymbol - GetGenericParamConstraintProps - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] TypeDef/Ref/Spec constraint + +HRESULT RegMeta::GetPEKind( // S_OK or error. + DWORD *pdwPEKind, // [OUT] The kind of PE (0 - not a PE) + DWORD *pdwMachine) { + HRESULT hr = NOERROR; + MAPPINGTYPE mt = MTYPE_NOMAPPING; + + if (m_pStgdb->m_pStgIO != NULL) + mt = m_pStgdb->m_pStgIO->GetMemoryMappedType(); + + hr = m_pStgdb->GetPEKind(mt, pdwPEKind, pdwMachine); + return hr; +} // [OUT] Machine as defined in NT header + +HRESULT RegMeta::GetVersionString( // S_OK or error. + _Out_writes_to_opt_(ccBufSize, *pccBufSize) + LPWSTR pwzBuf, // [OUT] Put version string here. + DWORD cchBufSize, // [IN] size of the buffer, in wide chars + DWORD *pchBufSize) { + HRESULT hr = NOERROR; + + DWORD cch; // Length of WideChar string. + LPCSTR pVer; // Pointer to version string. + + if (m_pStgdb->m_pvMd != NULL) { + // For convenience, get a pointer to the version string. + // @todo: get from alternate locations when there is no STOREAGESIGNATURE. + pVer = reinterpret_cast( + reinterpret_cast(m_pStgdb->m_pvMd)->pVersion); + // Attempt to convert into caller's buffer. + cch = WszMultiByteToWideChar(CP_UTF8, 0, pVer, -1, pwzBuf, cchBufSize); + // Did the string fit? + if (cch == 0) { + // No, didn't fit. Find out space required. + cch = WszMultiByteToWideChar(CP_UTF8, 0, pVer, -1, pwzBuf, 0); + // NUL terminate string. + if (cchBufSize > 0) + pwzBuf[cchBufSize - 1] = W('\0'); + // Truncation return code. + hr = CLDB_S_TRUNCATION; + } + } else { + // No string. + if (cchBufSize > 0) + *pwzBuf = W('\0'); + cch = 0; + } + + if (pchBufSize) + *pchBufSize = cch; + + return hr; +} // [OUT] Size of the version string, wide chars, including terminating nul. + +HRESULT RegMeta::EnumMethodSpecs( + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tk, // [IN] MethodDef or MemberRef whose MethodSpecs are requested + mdMethodSpec rMethodSpecs[], // [OUT] Put MethodSpecs here. + ULONG cMax, // [IN] Max tokens to put. + ULONG *pcMethodSpecs) { + DEBUG_PRINTF(1, "CordbSymbol - EnumMethodSpecs - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] Put actual count here. + +HRESULT RegMeta::GetAssemblyProps( // S_OK or error. + mdAssembly mda, // [IN] The Assembly for which to get the properties. + const void **ppbPublicKey, // [OUT] Pointer to the public key. + ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. + ULONG *pulHashAlgId, // [OUT] Hash Algorithm. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. + DWORD *pdwAssemblyFlags) { + HRESULT hr = S_OK; + + BEGIN_ENTRYPOINT_NOTHROW; + + AssemblyRec *pRecord; + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + _ASSERTE(TypeFromToken(mda) == mdtAssembly && RidFromToken(mda)); + IfFailGo(pMiniMd->GetAssemblyRecord(RidFromToken(mda), &pRecord)); + + if (ppbPublicKey != NULL) { + IfFailGo(pMiniMd->getPublicKeyOfAssembly( + pRecord, (const BYTE **)ppbPublicKey, pcbPublicKey)); + } + if (pulHashAlgId) + *pulHashAlgId = pMiniMd->getHashAlgIdOfAssembly(pRecord); + if (pMetaData) { + pMetaData->usMajorVersion = pMiniMd->getMajorVersionOfAssembly(pRecord); + pMetaData->usMinorVersion = pMiniMd->getMinorVersionOfAssembly(pRecord); + pMetaData->usBuildNumber = pMiniMd->getBuildNumberOfAssembly(pRecord); + pMetaData->usRevisionNumber = pMiniMd->getRevisionNumberOfAssembly(pRecord); + IfFailGo(pMiniMd->getLocaleOfAssembly(pRecord, pMetaData->szLocale, + pMetaData->cbLocale, + &pMetaData->cbLocale)); + pMetaData->ulProcessor = 0; + pMetaData->ulOS = 0; + } + if (pdwAssemblyFlags) { + *pdwAssemblyFlags = pMiniMd->getFlagsOfAssembly(pRecord); + + // Turn on the afPublicKey if PublicKey blob is not empty + DWORD cbPublicKey; + const BYTE *pbPublicKey; + IfFailGo( + pMiniMd->getPublicKeyOfAssembly(pRecord, &pbPublicKey, &cbPublicKey)); + if (cbPublicKey != 0) + *pdwAssemblyFlags |= afPublicKey; + } + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szName || pchName) + IfFailGo(pMiniMd->getNameOfAssembly(pRecord, szName, cchName, pchName)); +ErrExit: + + return hr; +} // [OUT] Flags. + +HRESULT RegMeta::GetAssemblyRefProps( // S_OK or error. + mdAssemblyRef mdar, // [IN] The AssemblyRef for which to get the properties. + const void * + *ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token. + ULONG * + pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or token. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. + const void **ppbHashValue, // [OUT] Hash blob. + ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob. + DWORD *pdwAssemblyRefFlags) { + HRESULT hr = S_OK; + + BEGIN_ENTRYPOINT_NOTHROW; + + AssemblyRefRec *pRecord; + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + _ASSERTE(TypeFromToken(mdar) == mdtAssemblyRef && RidFromToken(mdar)); + IfFailGo(pMiniMd->GetAssemblyRefRecord(RidFromToken(mdar), &pRecord)); + + if (ppbPublicKeyOrToken != NULL) { + IfFailGo(pMiniMd->getPublicKeyOrTokenOfAssemblyRef( + pRecord, (const BYTE **)ppbPublicKeyOrToken, pcbPublicKeyOrToken)); + } + if (pMetaData) { + pMetaData->usMajorVersion = pMiniMd->getMajorVersionOfAssemblyRef(pRecord); + pMetaData->usMinorVersion = pMiniMd->getMinorVersionOfAssemblyRef(pRecord); + pMetaData->usBuildNumber = pMiniMd->getBuildNumberOfAssemblyRef(pRecord); + pMetaData->usRevisionNumber = + pMiniMd->getRevisionNumberOfAssemblyRef(pRecord); + IfFailGo(pMiniMd->getLocaleOfAssemblyRef(pRecord, pMetaData->szLocale, + pMetaData->cbLocale, + &pMetaData->cbLocale)); + pMetaData->ulProcessor = 0; + pMetaData->ulOS = 0; + } + if (ppbHashValue != NULL) { + IfFailGo(pMiniMd->getHashValueOfAssemblyRef( + pRecord, (const BYTE **)ppbHashValue, pcbHashValue)); + } + if (pdwAssemblyRefFlags) + *pdwAssemblyRefFlags = pMiniMd->getFlagsOfAssemblyRef(pRecord); + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szName || pchName) + IfFailGo(pMiniMd->getNameOfAssemblyRef(pRecord, szName, cchName, pchName)); +ErrExit: + + return hr; +} // [OUT] Flags. + +HRESULT RegMeta::GetFileProps( // S_OK or error. + mdFile mdf, // [IN] The File for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob. + ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob. + DWORD *pdwFileFlags) { + DEBUG_PRINTF(1, "CordbSymbol - GetFileProps - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] Flags. + +HRESULT RegMeta::GetExportedTypeProps( // S_OK or error. + mdExportedType + mdct, // [IN] The ExportedType for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + mdToken + *ptkImplementation, // [OUT] mdFile or mdAssemblyRef or mdExportedType. + mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file. + DWORD *pdwExportedTypeFlags) { + HRESULT hr = S_OK; // A result. + + ExportedTypeRec *pRecord; // The exported type. + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + int bTruncation = 0; // Was there name truncation? + + _ASSERTE(TypeFromToken(mdct) == mdtExportedType && RidFromToken(mdct)); + IfFailGo(pMiniMd->GetExportedTypeRecord(RidFromToken(mdct), &pRecord)); + + if (szName || pchName) { + LPCSTR szTypeNamespace; + LPCSTR szTypeName; + + IfFailGo( + pMiniMd->getTypeNamespaceOfExportedType(pRecord, &szTypeNamespace)); + PREFIX_ASSUME(szTypeNamespace != NULL); + MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzTypeNamespace, szTypeNamespace); + IfNullGo(wzTypeNamespace); + + IfFailGo(pMiniMd->getTypeNameOfExportedType(pRecord, &szTypeName)); + _ASSERTE(*szTypeName); + MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzTypeName, szTypeName); + IfNullGo(wzTypeName); + + if (szName) + bTruncation = + !(ns::MakePath(szName, cchName, wzTypeNamespace, wzTypeName)); + if (pchName) { + if (bTruncation || !szName) + *pchName = ns::GetFullLength(wzTypeNamespace, wzTypeName); + else + *pchName = (ULONG)(wcslen(szName) + 1); + } + } + if (ptkImplementation) + *ptkImplementation = pMiniMd->getImplementationOfExportedType(pRecord); + if (ptkTypeDef) + *ptkTypeDef = pMiniMd->getTypeDefIdOfExportedType(pRecord); + if (pdwExportedTypeFlags) + *pdwExportedTypeFlags = pMiniMd->getFlagsOfExportedType(pRecord); + + if (bTruncation && hr == S_OK) { + if ((szName != NULL) && (cchName > 0)) { + // null-terminate the truncated output string + szName[cchName - 1] = W('\0'); + } + hr = CLDB_S_TRUNCATION; + } + +ErrExit: + + return hr; +} // [OUT] Flags. + +HRESULT RegMeta::GetManifestResourceProps( // S_OK or error. + mdManifestResource + mdmr, // [IN] The ManifestResource for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides + // the ManifestResource. + DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within + // the file. + DWORD *pdwResourceFlags) { + DEBUG_PRINTF(1, "CordbSymbol - GetManifestResourceProps - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] Flags. + +HRESULT RegMeta::EnumAssemblyRefs( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdAssemblyRef rAssemblyRefs[], // [OUT] Put AssemblyRefs here. + ULONG cMax, // [IN] Max AssemblyRefs to put. + ULONG *pcTokens) { + DEBUG_PRINTF(1, "CordbSymbol - EnumAssemblyRefs - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] Put # put here. + +HRESULT RegMeta::EnumFiles( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdFile rFiles[], // [OUT] Put Files here. + ULONG cMax, // [IN] Max Files to put. + ULONG *pcTokens) { + HRESULT hr = NOERROR; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + HENUMInternal *pEnum; + + if (*ppmdEnum == 0) { + // instantiate a new ENUM. + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + // create the enumerator. + IfFailGo(HENUMInternal::CreateSimpleEnum( + mdtFile, 1, pMiniMd->getCountFiles() + 1, &pEnum)); + + // set the output parameter. + *ppmdEnum = pEnum; + } else + pEnum = *ppmdEnum; + + // we can only fill the minimum of what the caller asked for or what we have + // left. + IfFailGo(HENUMInternal::EnumWithCount(pEnum, cMax, rFiles, pcTokens)); +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} // [OUT] Put # put here. + +HRESULT RegMeta::EnumExportedTypes( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdExportedType rExportedTypes[], // [OUT] Put ExportedTypes here. + ULONG cMax, // [IN] Max ExportedTypes to put. + ULONG *pcTokens) { + HRESULT hr = NOERROR; + + BEGIN_ENTRYPOINT_NOTHROW; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + HENUMInternal *pEnum; + + if (*ppmdEnum == 0) { + // instantiate a new ENUM. + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + if (pMiniMd->HasDelete()) { + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtExportedType, &pEnum)); + + // add all Types to the dynamic array if name is not _Delete + for (ULONG index = 1; index <= pMiniMd->getCountExportedTypes(); + index++) { + ExportedTypeRec *pRec; + IfFailGo(pMiniMd->GetExportedTypeRecord(index, &pRec)); + LPCSTR szTypeName; + IfFailGo(pMiniMd->getTypeNameOfExportedType(pRec, &szTypeName)); + if (IsDeletedName(szTypeName)) { + continue; + } + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(index, mdtExportedType))); + } + } else { + // create the enumerator. + IfFailGo(HENUMInternal::CreateSimpleEnum( + mdtExportedType, 1, pMiniMd->getCountExportedTypes() + 1, &pEnum)); + } + + // set the output parameter. + *ppmdEnum = pEnum; + } else + pEnum = *ppmdEnum; + + // we can only fill the minimum of what the caller asked for or what we have + // left. + IfFailGo(HENUMInternal::EnumWithCount(pEnum, cMax, rExportedTypes, pcTokens)); +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} // [OUT] Put # put here. + +HRESULT RegMeta::EnumManifestResources( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdManifestResource + rManifestResources[], // [OUT] Put ManifestResources here. + ULONG cMax, // [IN] Max Resources to put. + ULONG *pcTokens) { + DEBUG_PRINTF(1, "CordbSymbol - EnumManifestResources - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] Put # put here. + +HRESULT RegMeta::FindExportedTypeByName( // S_OK or error + LPCWSTR szName, // [IN] Name of the ExportedType. + mdToken mdtExportedType, // [IN] ExportedType for the enclosing class. + mdExportedType *ptkExportedType) { + DEBUG_PRINTF(1, "CordbSymbol - FindExportedTypeByName - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] Put the ExportedType token here. + +HRESULT RegMeta::FindManifestResourceByName( // S_OK or error + LPCWSTR szName, // [IN] Name of the ManifestResource. + mdManifestResource *ptkManifestResource) { + DEBUG_PRINTF(1, + "CordbSymbol - FindManifestResourceByName - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] Put the ManifestResource token here. + +HRESULT RegMeta::FindAssembliesByName( // S_OK or error + LPCWSTR szAppBase, // [IN] optional - can be NULL + LPCWSTR szPrivateBin, // [IN] optional - can be NULL + LPCWSTR szAssemblyName, // [IN] required - this is the assembly you are + // requesting + IUnknown *ppIUnk[], // [OUT] put IMetaDataAssemblyImport pointers here + ULONG cMax, // [IN] The max number to put + ULONG *pcAssemblies) { + DEBUG_PRINTF(1, "CordbSymbol - FindAssembliesByName - NOT IMPLEMENTED\n"); + return S_OK; +} // [OUT] The number of assemblies returned. + +// IUnknown methods +HRESULT RegMeta::QueryInterface(REFIID riid, LPVOID *ppUnk) { + HRESULT hr = S_OK; + int fIsInterfaceRW = false; + *ppUnk = 0; + if (riid == IID_IUnknown) { + *ppUnk = (IUnknown *)(IMetaDataImport2 *)this; + } else if (riid == IID_IMDCommon) { + *ppUnk = (IMDCommon *)this; + } else if (riid == IID_IMetaDataImport) { + *ppUnk = (IMetaDataImport2 *)this; + } else if (riid == IID_IMetaDataImport2) { + *ppUnk = (IMetaDataImport2 *)this; + } else if (riid == IID_IMetaDataAssemblyImport) { + *ppUnk = (IMetaDataAssemblyImport *)this; + } else { + IfFailGo(E_NOINTERFACE); + } +ErrExit: + return hr; +} + +ULONG RegMeta::AddRef() { return S_OK; } + +ULONG RegMeta::Release() { return S_OK; } + +// IMetaDataImport functions +void RegMeta::CloseEnum(HCORENUM hEnum) { + BEGIN_CLEANUP_ENTRYPOINT; + // No need to lock this function. + HENUMInternal *pmdEnum = reinterpret_cast(hEnum); + + if (pmdEnum == NULL) + return; + + HENUMInternal::DestroyEnum(pmdEnum); + END_CLEANUP_ENTRYPOINT; +} + +HRESULT RegMeta::CountEnum(HCORENUM hEnum, ULONG *pulCount) { + HENUMInternal *pmdEnum = reinterpret_cast(hEnum); + HRESULT hr = S_OK; + + // No need to lock this function. + + _ASSERTE(pulCount); + + if (pmdEnum == NULL) { + *pulCount = 0; + goto ErrExit; + } + + if (pmdEnum->m_tkKind == (TBL_MethodImpl << 24)) { + // Number of tokens must always be a multiple of 2. + _ASSERTE(!(pmdEnum->m_ulCount % 2)); + // There are two entries in the Enumerator for each MethodImpl. + *pulCount = pmdEnum->m_ulCount / 2; + } else + *pulCount = pmdEnum->m_ulCount; +ErrExit: + return hr; +} + +HRESULT RegMeta::ResetEnum(HCORENUM hEnum, ULONG ulPos) { + DEBUG_PRINTF(1, "CordbSymbol - ResetEnum - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumTypeDefs(HCORENUM *phEnum, mdTypeDef rTypeDefs[], + ULONG cMax, ULONG *pcTypeDefs) { + HRESULT hr = S_OK; + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + HENUMInternal *pEnum; + if (*phEnum == NULL) { + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + HENUMInternal::CreateDynamicArrayEnum(mdtTypeDef, &pEnum); + for (ULONG index = 2; index <= pMiniMd->getCountTypeDefs(); index++) { + TypeDefRec *pRec; + pMiniMd->GetTypeDefRecord(index, &pRec); + LPCSTR szTypeDefName; + pMiniMd->getNameOfTypeDef(pRec, &szTypeDefName); + if (IsDeletedName(szTypeDefName)) + continue; + HENUMInternal::AddElementToEnum(pEnum, TokenFromRid(index, mdtTypeDef)); + } + *ppmdEnum = pEnum; + } else { + pEnum = *ppmdEnum; + } + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rTypeDefs, pcTypeDefs); + return hr; +} + +HRESULT RegMeta::EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td, + mdInterfaceImpl rImpls[], ULONG cMax, + ULONG *pcImpls) { + HRESULT hr = S_OK; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart; + ULONG ridEnd; + HENUMInternal *pEnum; + InterfaceImplRec *pRec; + ULONG index; + + _ASSERTE(TypeFromToken(td) == mdtTypeDef); + + if (*ppmdEnum == 0) { + // instantiating a new ENUM + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + if (pMiniMd->IsSorted(TBL_InterfaceImpl)) { + IfFailGo(pMiniMd->getInterfaceImplsForTypeDef(RidFromToken(td), &ridEnd, + &ridStart)); + IfFailGo(HENUMInternal::CreateSimpleEnum(mdtInterfaceImpl, ridStart, + ridEnd, &pEnum)); + } else { + // table is not sorted so we have to create dynmaic array + // create the dynamic enumerator + // + ridStart = 1; + ridEnd = pMiniMd->getCountInterfaceImpls() + 1; + + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtInterfaceImpl, &pEnum)); + + for (index = ridStart; index < ridEnd; index++) { + IfFailGo(pMiniMd->GetInterfaceImplRecord(index, &pRec)); + if (td == pMiniMd->getClassOfInterfaceImpl(pRec)) { + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(index, mdtInterfaceImpl))); + } + } + } + + // set the output parameter + *ppmdEnum = pEnum; + } else { + pEnum = *ppmdEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rImpls, pcImpls); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} + +HRESULT RegMeta::EnumTypeRefs(HCORENUM *phEnum, mdTypeRef rTypeRefs[], + ULONG cMax, ULONG *pcTypeRefs) { + DEBUG_PRINTF(1, "CordbSymbol - EnumTypeRefs - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::FindTypeDefByName( // S_OK or error. + LPCWSTR wzTypeDef, // [IN] Name of the Type. + mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class. + mdTypeDef *ptd) // [OUT] Put the TypeDef token here. +{ + HRESULT hr = S_OK; + if (wzTypeDef == NULL) + IfFailGo(E_INVALIDARG); + PREFIX_ASSUME(wzTypeDef != NULL); + LPSTR szTypeDef; + UTF8STR(wzTypeDef, szTypeDef); + LPCSTR szNamespace; + LPCSTR szName; + + _ASSERTE(ptd); + _ASSERTE(TypeFromToken(tkEnclosingClass) == mdtTypeDef || + TypeFromToken(tkEnclosingClass) == mdtTypeRef || + IsNilToken(tkEnclosingClass)); + + // initialize output parameter + *ptd = mdTypeDefNil; + + ns::SplitInline(szTypeDef, szNamespace, szName); + hr = ImportHelper::FindTypeDefByName(&(m_pStgdb->m_MiniMd), szNamespace, + szName, tkEnclosingClass, ptd); +ErrExit: + return hr; +} + +HRESULT RegMeta::GetScopeProps( // S_OK or error. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] Put the name here. + ULONG cchName, // [IN] Size of name buffer in wide chars. + ULONG *pchName, // [OUT] Put size of name (wide chars) here. + GUID *pmvid) // [OUT, OPTIONAL] Put MVID here. +{ + HRESULT hr = S_OK; + + BEGIN_ENTRYPOINT_NOTHROW; + + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + ModuleRec *pModuleRec; + + // there is only one module record + IfFailGo(pMiniMd->GetModuleRecord(1, &pModuleRec)); + + if (pmvid != NULL) { + IfFailGo(pMiniMd->getMvidOfModule(pModuleRec, pmvid)); + } + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szName || pchName) + IfFailGo(pMiniMd->getNameOfModule(pModuleRec, szName, cchName, pchName)); +ErrExit: + return hr; +} + +HRESULT RegMeta::GetModuleFromScope( // S_OK. + mdModule *pmd) // [OUT] Put mdModule token here. +{ + DEBUG_PRINTF(1, "CordbSymbol - GetModuleFromScope - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetTypeDefProps( // S_OK or error. + mdTypeDef td, // [IN] TypeDef token for inquiry. + __out_ecount_part_opt(cchTypeDef, *pchTypeDef) + LPWSTR szTypeDef, // [OUT] Put name here. + ULONG cchTypeDef, // [IN] size of name buffer in wide chars. + ULONG *pchTypeDef, // [OUT] put size of name (wide chars) here. + DWORD *pdwTypeDefFlags, // [OUT] Put flags here. + mdToken *ptkExtends) // [OUT] Put base class TypeDef/TypeRef here. +{ + HRESULT hr = S_OK; + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + TypeDefRec *pTypeDefRec; + BOOL fTruncation = FALSE; + + if (TypeFromToken(td) != mdtTypeDef) { + hr = S_FALSE; + goto ErrExit; + } + if (td == mdTypeDefNil) { + // Backward compatibility with CLR 2.0 implementation + if (pdwTypeDefFlags != NULL) + *pdwTypeDefFlags = 0; + if (ptkExtends != NULL) + *ptkExtends = mdTypeRefNil; + if (pchTypeDef != NULL) + *pchTypeDef = 1; + if ((szTypeDef != NULL) && (cchTypeDef > 0)) + szTypeDef[0] = 0; + + hr = S_OK; + goto ErrExit; + } + + pMiniMd->GetTypeDefRecord(RidFromToken(td), &pTypeDefRec); + + if ((szTypeDef != NULL) || (pchTypeDef != NULL)) { + LPCSTR szNamespace; + LPCSTR szName; + + pMiniMd->getNamespaceOfTypeDef(pTypeDefRec, &szNamespace); + MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzNamespace, szNamespace); + IfNullGo(wzNamespace); + + pMiniMd->getNameOfTypeDef(pTypeDefRec, &szName); + MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzName, szName); + + if (szTypeDef != NULL) { + fTruncation = !(ns::MakePath(szTypeDef, cchTypeDef, wzNamespace, wzName)); + } + if (pchTypeDef != NULL) { + if (fTruncation || (szTypeDef == NULL)) { + *pchTypeDef = ns::GetFullLength(wzNamespace, wzName); + } else { + *pchTypeDef = (ULONG)(wcslen(szTypeDef) + 1); + } + } + } + if (pdwTypeDefFlags != NULL) { + // caller wants type flags + *pdwTypeDefFlags = pMiniMd->getFlagsOfTypeDef(pTypeDefRec); + } + if (ptkExtends != NULL) { + *ptkExtends = pMiniMd->getExtendsOfTypeDef(pTypeDefRec); + + // take care of the 0 case + if (RidFromToken(*ptkExtends) == 0) { + *ptkExtends = mdTypeRefNil; + } + } + + if (fTruncation && (hr == S_OK)) { + if ((szTypeDef != NULL) && (cchTypeDef > 0)) { + // null-terminate the truncated output string + szTypeDef[cchTypeDef - 1] = W('\0'); + } + hr = CLDB_S_TRUNCATION; + } + +ErrExit: + return hr; +} + +HRESULT RegMeta::GetInterfaceImplProps( // S_OK or error. + mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. + mdTypeDef *pClass, // [OUT] Put implementing class token here. + mdToken *ptkIface) // [OUT] Put implemented interface token here. +{ + HRESULT hr = S_OK; + + CMiniMdRW *pMiniMd = NULL; + InterfaceImplRec *pIIRec = NULL; + + _ASSERTE(TypeFromToken(iiImpl) == mdtInterfaceImpl); + + pMiniMd = &(m_pStgdb->m_MiniMd); + IfFailGo(pMiniMd->GetInterfaceImplRecord(RidFromToken(iiImpl), &pIIRec)); + + if (pClass) { + *pClass = pMiniMd->getClassOfInterfaceImpl(pIIRec); + } + if (ptkIface) { + *ptkIface = pMiniMd->getInterfaceOfInterfaceImpl(pIIRec); + } + +ErrExit: + return hr; +} + +HRESULT RegMeta::GetTypeRefProps( // S_OK or error. + mdTypeRef tr, // [IN] TypeRef token. + mdToken * + ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or AssemblyRef. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szTypeRef, // [OUT] Name of the TypeRef. + ULONG cchTypeRef, // [IN] Size of buffer. + ULONG *pchTypeRef) // [OUT] Size of Name. +{ + HRESULT hr = S_OK; + CMiniMdRW *pMiniMd; + TypeRefRec *pTypeRefRec; + BOOL fTruncation = FALSE; // Was there name truncation? + + if (TypeFromToken(tr) != mdtTypeRef) { + hr = S_FALSE; + goto ErrExit; + } + if (tr == mdTypeRefNil) { + // Backward compatibility with CLR 2.0 implementation + if (ptkResolutionScope != NULL) + *ptkResolutionScope = mdTokenNil; + if (pchTypeRef != NULL) + *pchTypeRef = 1; + if ((szTypeRef != NULL) && (cchTypeRef > 0)) + szTypeRef[0] = 0; + + hr = S_OK; + goto ErrExit; + } + + pMiniMd = &(m_pStgdb->m_MiniMd); + IfFailGo(pMiniMd->GetTypeRefRecord(RidFromToken(tr), &pTypeRefRec)); + + if (ptkResolutionScope != NULL) { + *ptkResolutionScope = pMiniMd->getResolutionScopeOfTypeRef(pTypeRefRec); + } + + if ((szTypeRef != NULL) || (pchTypeRef != NULL)) { + LPCSTR szNamespace; + LPCSTR szName; + + IfFailGo(pMiniMd->getNamespaceOfTypeRef(pTypeRefRec, &szNamespace)); + MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzNamespace, szNamespace); + IfNullGo(wzNamespace); + + IfFailGo(pMiniMd->getNameOfTypeRef(pTypeRefRec, &szName)); + MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzName, szName); + IfNullGo(wzName); + + if (szTypeRef != NULL) { + fTruncation = !(ns::MakePath(szTypeRef, cchTypeRef, wzNamespace, wzName)); + } + if (pchTypeRef != NULL) { + if (fTruncation || (szTypeRef == NULL)) { + *pchTypeRef = ns::GetFullLength(wzNamespace, wzName); + } else { + *pchTypeRef = (ULONG)(wcslen(szTypeRef) + 1); + } + } + } + if (fTruncation && (hr == S_OK)) { + if ((szTypeRef != NULL) && (cchTypeRef > 0)) { + // null-terminate the truncated output string + szTypeRef[cchTypeRef - 1] = W('\0'); + } + hr = CLDB_S_TRUNCATION; + } + +ErrExit: + return hr; +} + +HRESULT RegMeta::ResolveTypeRef(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, + mdTypeDef *ptd) { + DEBUG_PRINTF(1, "CordbSymbol - ResolveTypeRef - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumMembers( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + mdToken rMembers[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumMembers - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumMembersWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdToken rMembers[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumMembersWithName - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumMethods( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdMethodDef rMethods[], // [OUT] Put MethodDefs here. + ULONG cMax, // [IN] Max MethodDefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + HRESULT hr = NOERROR; + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart; + ULONG ridEnd; + TypeDefRec *pRec; + HENUMInternal *pEnum = *ppmdEnum; + + if (pEnum == 0) { + // instantiating a new ENUM + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + // Check for mdTypeDefNil (representing ). + // If so, this will map it to its token. + // + if (IsGlobalMethodParentTk(td)) { + td = COR_GLOBAL_PARENT_TOKEN; + } + + IfFailGo(m_pStgdb->m_MiniMd.GetTypeDefRecord(RidFromToken(td), &pRec)); + ridStart = m_pStgdb->m_MiniMd.getMethodListOfTypeDef(pRec); + IfFailGo(m_pStgdb->m_MiniMd.getEndMethodListOfTypeDef(RidFromToken(td), + &ridEnd)); + + if (pMiniMd->HasIndirectTable(TBL_Method) || pMiniMd->HasDelete()) { + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtMethodDef, &pEnum)); + + // add all methods to the dynamic array + for (ULONG index = ridStart; index < ridEnd; index++) { + if (pMiniMd->HasDelete()) { + MethodRec *pMethRec; + RID rid; + IfFailGo(pMiniMd->GetMethodRid(index, &rid)); + IfFailGo(pMiniMd->GetMethodRecord(rid, &pMethRec)); + LPCSTR szMethodName; + IfFailGo(pMiniMd->getNameOfMethod(pMethRec, &szMethodName)); + if (IsMdRTSpecialName(pMethRec->GetFlags()) && + IsDeletedName(szMethodName)) { + continue; + } + } + RID rid; + IfFailGo(pMiniMd->GetMethodRid(index, &rid)); + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(rid, mdtMethodDef))); + } + } else { + IfFailGo(HENUMInternal::CreateSimpleEnum(mdtMethodDef, ridStart, ridEnd, + &pEnum)); + } + + // set the output parameter + *ppmdEnum = pEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rMethods, pcTokens); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + END_ENTRYPOINT_NOTHROW; + + return hr; +} + +HRESULT RegMeta::EnumMethodsWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdMethodDef rMethods[], // [OU] Put MethodDefs here. + ULONG cMax, // [IN] Max MethodDefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumMethodsWithName - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumFields( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdFieldDef rFields[], // [OUT] Put FieldDefs here. + ULONG cMax, // [IN] Max FieldDefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + HRESULT hr = NOERROR; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart; + ULONG ridEnd; + TypeDefRec *pRec; + HENUMInternal *pEnum = *ppmdEnum; + + if (pEnum == NULL) { + // instantiating a new ENUM + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + // Check for mdTypeDefNil (representing ). + // If so, this will map it to its token. + // + if (IsGlobalMethodParentTk(td)) { + td = COR_GLOBAL_PARENT_TOKEN; + } + + IfFailGo(m_pStgdb->m_MiniMd.GetTypeDefRecord(RidFromToken(td), &pRec)); + ridStart = m_pStgdb->m_MiniMd.getFieldListOfTypeDef(pRec); + IfFailGo( + m_pStgdb->m_MiniMd.getEndFieldListOfTypeDef(RidFromToken(td), &ridEnd)); + + if (pMiniMd->HasIndirectTable(TBL_Field) || pMiniMd->HasDelete()) { + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtFieldDef, &pEnum)); + + // add all methods to the dynamic array + for (ULONG index = ridStart; index < ridEnd; index++) { + if (pMiniMd->HasDelete()) { + FieldRec *pFieldRec; + RID rid; + IfFailGo(pMiniMd->GetFieldRid(index, &rid)); + IfFailGo(pMiniMd->GetFieldRecord(rid, &pFieldRec)); + LPCUTF8 szFieldName; + IfFailGo(pMiniMd->getNameOfField(pFieldRec, &szFieldName)); + if (IsFdRTSpecialName(pFieldRec->GetFlags()) && + IsDeletedName(szFieldName)) { + continue; + } + } + RID rid; + IfFailGo(pMiniMd->GetFieldRid(index, &rid)); + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(rid, mdtFieldDef))); + } + } else { + IfFailGo(HENUMInternal::CreateSimpleEnum(mdtFieldDef, ridStart, ridEnd, + &pEnum)); + } + + // set the output parameter + *ppmdEnum = pEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rFields, pcTokens); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + END_ENTRYPOINT_NOTHROW; + + return hr; +} + +HRESULT RegMeta::EnumFieldsWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdFieldDef rFields[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + HRESULT hr = NOERROR; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart; + ULONG ridEnd; + ULONG index; + TypeDefRec *pRec; + FieldRec *pField; + HENUMInternal *pEnum = *ppmdEnum; + LPUTF8 szNameUtf8; + UTF8STR(szName, szNameUtf8); + LPCUTF8 szNameUtf8Tmp; + + if (pEnum == 0) { + // instantiating a new ENUM + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + // Check for mdTypeDefNil (representing ). + // If so, this will map it to its token. + // + if (IsGlobalMethodParentTk(cl)) { + cl = COR_GLOBAL_PARENT_TOKEN; + } + + // create the enumerator + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtMethodDef, &pEnum)); + + // get the range of field rids given a typedef + IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(cl), &pRec)); + ridStart = m_pStgdb->m_MiniMd.getFieldListOfTypeDef(pRec); + IfFailGo( + m_pStgdb->m_MiniMd.getEndFieldListOfTypeDef(RidFromToken(cl), &ridEnd)); + + for (index = ridStart; index < ridEnd; index++) { + if (szNameUtf8 == NULL) { + RID rid; + IfFailGo(pMiniMd->GetFieldRid(index, &rid)); + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(rid, mdtFieldDef))); + } else { + RID rid; + IfFailGo(pMiniMd->GetFieldRid(index, &rid)); + IfFailGo(pMiniMd->GetFieldRecord(rid, &pField)); + IfFailGo(pMiniMd->getNameOfField(pField, &szNameUtf8Tmp)); + if (strcmp(szNameUtf8Tmp, szNameUtf8) == 0) { + IfFailGo(pMiniMd->GetFieldRid(index, &rid)); + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(rid, mdtFieldDef))); + } + } + } + + // set the output parameter + *ppmdEnum = pEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rFields, pcTokens); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} + +HRESULT RegMeta::EnumParams( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdMethodDef mb, // [IN] MethodDef to scope the enumeration. + mdParamDef rParams[], // [OUT] Put ParamDefs here. + ULONG cMax, // [IN] Max ParamDefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + HRESULT hr = NOERROR; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart; + ULONG ridEnd; + MethodRec *pRec; + HENUMInternal *pEnum = *ppmdEnum; + + if (pEnum == 0) { + // instantiating a new ENUM + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + IfFailGo(m_pStgdb->m_MiniMd.GetMethodRecord(RidFromToken(mb), &pRec)); + ridStart = m_pStgdb->m_MiniMd.getParamListOfMethod(pRec); + IfFailGo( + m_pStgdb->m_MiniMd.getEndParamListOfMethod(RidFromToken(mb), &ridEnd)); + + if (pMiniMd->HasIndirectTable(TBL_Param)) { + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtParamDef, &pEnum)); + + // add all methods to the dynamic array + for (ULONG index = ridStart; index < ridEnd; index++) { + RID rid; + IfFailGo(pMiniMd->GetParamRid(index, &rid)); + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(rid, mdtParamDef))); + } + } else { + IfFailGo(HENUMInternal::CreateSimpleEnum(mdtParamDef, ridStart, ridEnd, + &pEnum)); + } + + // set the output parameter + *ppmdEnum = pEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rParams, pcTokens); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} + +HRESULT RegMeta::EnumMemberRefs( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tkParent, // [IN] Parent token to scope the enumeration. + mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here. + ULONG cMax, // [IN] Max MemberRefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumMemberRefs - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumMethodImpls( // S_OK, S_FALSE, or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdToken rMethodBody[], // [OUT] Put Method Body tokens here. + mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here. + ULONG cMax, // [IN] Max tokens to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumMethodImpls - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumPermissionSets( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tk, // [IN] if !NIL, token to scope the enumeration. + DWORD dwActions, // [IN] if !0, return only these actions. + mdPermission rPermission[], // [OUT] Put Permissions here. + ULONG cMax, // [IN] Max Permissions to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumPermissionSets - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::FindMember( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdToken *pmb) // [OUT] matching memberdef +{ + DEBUG_PRINTF(1, "CordbSymbol - FindMember - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::FindMethod( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdMethodDef *pmb) // [OUT] matching memberdef +{ + DEBUG_PRINTF(1, "CordbSymbol - FindMethod - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::FindField( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdFieldDef *pmb) // [OUT] matching memberdef +{ + DEBUG_PRINTF(1, "CordbSymbol - FindField - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::FindMemberRef( + mdTypeRef td, // [IN] given typeRef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdMemberRef *pmr) // [OUT] matching memberref +{ + DEBUG_PRINTF(1, "CordbSymbol - FindMemberRef - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetMethodProps( + mdMethodDef mb, // The method for which to get props. + mdTypeDef *pClass, // Put method's class here. + __out_ecount_part_opt(cchMethod, *pchMethod) + LPWSTR szMethod, // Put method's name here. + ULONG cchMethod, // Size of szMethod buffer in wide chars. + ULONG *pchMethod, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + ULONG *pulCodeRVA, // [OUT] codeRVA + DWORD *pdwImplFlags) // [OUT] Impl. Flags +{ + HRESULT hr = NOERROR; + BEGIN_ENTRYPOINT_NOTHROW; + + MethodRec *pMethodRec; + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + _ASSERTE(TypeFromToken(mb) == mdtMethodDef); + + IfFailGo(pMiniMd->GetMethodRecord(RidFromToken(mb), &pMethodRec)); + + if (pClass) { + // caller wants parent typedef + IfFailGo(pMiniMd->FindParentOfMethodHelper(mb, pClass)); + + if (IsGlobalMethodParentToken(*pClass)) { + // If the parent of Method is the , return mdTypeDefNil instead. + *pClass = mdTypeDefNil; + } + } + if (ppvSigBlob || pcbSigBlob) { + // caller wants signature information + PCCOR_SIGNATURE pvSigTmp; + ULONG cbSig; + IfFailGo(pMiniMd->getSignatureOfMethod(pMethodRec, &pvSigTmp, &cbSig)); + if (ppvSigBlob) + *ppvSigBlob = pvSigTmp; + if (pcbSigBlob) + *pcbSigBlob = cbSig; + } + if (pdwAttr) { + *pdwAttr = pMiniMd->getFlagsOfMethod(pMethodRec); + } + if (pulCodeRVA) { + *pulCodeRVA = pMiniMd->getRVAOfMethod(pMethodRec); + } + if (pdwImplFlags) { + *pdwImplFlags = (DWORD)pMiniMd->getImplFlagsOfMethod(pMethodRec); + } + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szMethod || pchMethod) { + IfFailGo( + pMiniMd->getNameOfMethod(pMethodRec, szMethod, cchMethod, pchMethod)); + } + +ErrExit: + + return hr; +} + +HRESULT RegMeta::GetMemberRefProps( // S_OK or error. + mdMemberRef mr, // [IN] given memberref + mdToken *ptk, // [OUT] Put classref or classdef here. + __out_ecount_part_opt(cchMember, *pchMember) + LPWSTR szMember, // [OUT] buffer to fill for member's name + ULONG cchMember, // [IN] the count of char of szMember + ULONG *pchMember, // [OUT] actual count of char in member name + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value + ULONG *pbSig) // [OUT] actual size of signature blob +{ + HRESULT hr = NOERROR; + + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + MemberRefRec *pMemberRefRec; + + _ASSERTE(TypeFromToken(mr) == mdtMemberRef); + + IfFailGo(pMiniMd->GetMemberRefRecord(RidFromToken(mr), &pMemberRefRec)); + + if (ptk) { + *ptk = pMiniMd->getClassOfMemberRef(pMemberRefRec); + if (IsGlobalMethodParentToken(*ptk)) { + // If the parent of MemberRef is the , return mdTypeDefNil + // instead. + *ptk = mdTypeDefNil; + } + } + if (ppvSigBlob || pbSig) { + // caller wants signature information + PCCOR_SIGNATURE pvSigTmp; + ULONG cbSig; + IfFailGo( + pMiniMd->getSignatureOfMemberRef(pMemberRefRec, &pvSigTmp, &cbSig)); + if (ppvSigBlob) + *ppvSigBlob = pvSigTmp; + if (pbSig) + *pbSig = cbSig; + } + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szMember || pchMember) { + IfFailGo(pMiniMd->getNameOfMemberRef(pMemberRefRec, szMember, cchMember, + pchMember)); + } + +ErrExit: + + return hr; +} + +HRESULT RegMeta::EnumProperties( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdProperty rProperties[], // [OUT] Put Properties here. + ULONG cMax, // [IN] Max properties to put. + ULONG *pcProperties) // [OUT] Put # put here. +{ + HRESULT hr = NOERROR; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart = 0; + ULONG ridEnd = 0; + ULONG ridMax = 0; + HENUMInternal *pEnum = *ppmdEnum; + + if (IsNilToken(td)) { + if (pcProperties) + *pcProperties = 0; + hr = S_FALSE; + goto ErrExit; + } + + _ASSERTE(TypeFromToken(td) == mdtTypeDef); + + if (pEnum == 0) { + // instantiating a new ENUM + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + RID ridPropertyMap; + PropertyMapRec *pPropertyMapRec; + + // get the starting/ending rid of properties of this typedef + IfFailGo(pMiniMd->FindPropertyMapFor(RidFromToken(td), &ridPropertyMap)); + if (!InvalidRid(ridPropertyMap)) { + IfFailGo(m_pStgdb->m_MiniMd.GetPropertyMapRecord(ridPropertyMap, + &pPropertyMapRec)); + ridStart = pMiniMd->getPropertyListOfPropertyMap(pPropertyMapRec); + IfFailGo( + pMiniMd->getEndPropertyListOfPropertyMap(ridPropertyMap, &ridEnd)); + ridMax = pMiniMd->getCountPropertys() + 1; + if (ridStart == 0) + ridStart = 1; + if (ridEnd > ridMax) + ridEnd = ridMax; + if (ridStart > ridEnd) + ridStart = ridEnd; + } + + if (pMiniMd->HasIndirectTable(TBL_Property) || pMiniMd->HasDelete()) { + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtProperty, &pEnum)); + + // add all methods to the dynamic array + for (ULONG index = ridStart; index < ridEnd; index++) { + if (pMiniMd->HasDelete()) { + PropertyRec *pRec; + RID rid; + IfFailGo(pMiniMd->GetPropertyRid(index, &rid)); + IfFailGo(pMiniMd->GetPropertyRecord(rid, &pRec)); + LPCUTF8 szPropertyName; + IfFailGo(pMiniMd->getNameOfProperty(pRec, &szPropertyName)); + if (IsPrRTSpecialName(pRec->GetPropFlags()) && + IsDeletedName(szPropertyName)) { + continue; + } + } + RID rid; + IfFailGo(pMiniMd->GetPropertyRid(index, &rid)); + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(rid, mdtProperty))); + } + } else { + IfFailGo(HENUMInternal::CreateSimpleEnum(mdtProperty, ridStart, ridEnd, + &pEnum)); + } + + // set the output parameter + *ppmdEnum = pEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rProperties, pcProperties); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} + +HRESULT RegMeta::EnumEvents( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdEvent rEvents[], // [OUT] Put events here. + ULONG cMax, // [IN] Max events to put. + ULONG *pcEvents) // [OUT] Put # put here. +{ + HRESULT hr = NOERROR; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart = 0; + ULONG ridEnd = 0; + ULONG ridMax = 0; + HENUMInternal *pEnum = *ppmdEnum; + + _ASSERTE(TypeFromToken(td) == mdtTypeDef); + + if (pEnum == 0) { + // instantiating a new ENUM + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + RID ridEventMap; + EventMapRec *pEventMapRec; + + // get the starting/ending rid of properties of this typedef + IfFailGo(pMiniMd->FindEventMapFor(RidFromToken(td), &ridEventMap)); + if (!InvalidRid(ridEventMap)) { + IfFailGo(pMiniMd->GetEventMapRecord(ridEventMap, &pEventMapRec)); + ridStart = pMiniMd->getEventListOfEventMap(pEventMapRec); + IfFailGo(pMiniMd->getEndEventListOfEventMap(ridEventMap, &ridEnd)); + ridMax = pMiniMd->getCountEvents() + 1; + if (ridStart == 0) + ridStart = 1; + if (ridEnd > ridMax) + ridEnd = ridMax; + if (ridStart > ridEnd) + ridStart = ridEnd; + } + + if (pMiniMd->HasIndirectTable(TBL_Event) || pMiniMd->HasDelete()) { + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtEvent, &pEnum)); + + // add all methods to the dynamic array + for (ULONG index = ridStart; index < ridEnd; index++) { + if (pMiniMd->HasDelete()) { + EventRec *pRec; + RID rid; + IfFailGo(pMiniMd->GetEventRid(index, &rid)); + IfFailGo(pMiniMd->GetEventRecord(rid, &pRec)); + LPCSTR szEventName; + IfFailGo(pMiniMd->getNameOfEvent(pRec, &szEventName)); + if (IsEvRTSpecialName(pRec->GetEventFlags()) && + IsDeletedName(szEventName)) { + continue; + } + } + RID rid; + IfFailGo(pMiniMd->GetEventRid(index, &rid)); + IfFailGo(HENUMInternal::AddElementToEnum(pEnum, + TokenFromRid(rid, mdtEvent))); + } + } else { + IfFailGo( + HENUMInternal::CreateSimpleEnum(mdtEvent, ridStart, ridEnd, &pEnum)); + } + + // set the output parameter + *ppmdEnum = pEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rEvents, pcEvents); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} + +HRESULT RegMeta::GetEventProps( // S_OK, S_FALSE, or error. + mdEvent ev, // [IN] event token + mdTypeDef *pClass, // [OUT] typedef containing the event declarion. + LPCWSTR szEvent, // [OUT] Event name + ULONG cchEvent, // [IN] the count of wchar of szEvent + ULONG *pchEvent, // [OUT] actual count of wchar for event's name + DWORD *pdwEventFlags, // [OUT] Event flags. + mdToken *ptkEventType, // [OUT] EventType class + mdMethodDef *pmdAddOn, // [OUT] AddOn method of the event + mdMethodDef *pmdRemoveOn, // [OUT] RemoveOn method of the event + mdMethodDef *pmdFire, // [OUT] Fire method of the event + mdMethodDef rmdOtherMethod[], // [OUT] other method of the event + ULONG cMax, // [IN] size of rmdOtherMethod + ULONG *pcOtherMethod) // [OUT] total number of other method of this event +{ + HRESULT hr = NOERROR; + + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + EventRec *pRec; + HENUMInternal hEnum; + + _ASSERTE(TypeFromToken(ev) == mdtEvent); + + HENUMInternal::ZeroEnum(&hEnum); + IfFailGo(pMiniMd->GetEventRecord(RidFromToken(ev), &pRec)); + + if (pClass) { + // find the event map entry corresponding to this event + IfFailGo(pMiniMd->FindParentOfEventHelper(ev, pClass)); + } + if (pdwEventFlags) { + *pdwEventFlags = pMiniMd->getEventFlagsOfEvent(pRec); + } + if (ptkEventType) { + *ptkEventType = pMiniMd->getEventTypeOfEvent(pRec); + } + { + MethodSemanticsRec *pSemantics; + RID ridCur; + ULONG cCurOtherMethod = 0; + ULONG ulSemantics; + mdMethodDef tkMethod; + + // initialize output parameters + if (pmdAddOn) + *pmdAddOn = mdMethodDefNil; + if (pmdRemoveOn) + *pmdRemoveOn = mdMethodDefNil; + if (pmdFire) + *pmdFire = mdMethodDefNil; + + IfFailGo(pMiniMd->FindMethodSemanticsHelper(ev, &hEnum)); + while (HENUMInternal::EnumNext(&hEnum, (mdToken *)&ridCur)) { + IfFailGo(pMiniMd->GetMethodSemanticsRecord(ridCur, &pSemantics)); + ulSemantics = pMiniMd->getSemanticOfMethodSemantics(pSemantics); + tkMethod = TokenFromRid(pMiniMd->getMethodOfMethodSemantics(pSemantics), + mdtMethodDef); + switch (ulSemantics) { + case msAddOn: + if (pmdAddOn) + *pmdAddOn = tkMethod; + break; + case msRemoveOn: + if (pmdRemoveOn) + *pmdRemoveOn = tkMethod; + break; + case msFire: + if (pmdFire) + *pmdFire = tkMethod; + break; + case msOther: + if (cCurOtherMethod < cMax) + rmdOtherMethod[cCurOtherMethod] = tkMethod; + cCurOtherMethod++; + break; + default: + _ASSERTE(!"BadKind!"); + } + } + + // set the output parameter + if (pcOtherMethod) + *pcOtherMethod = cCurOtherMethod; + } + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szEvent || pchEvent) { + IfFailGo( + pMiniMd->getNameOfEvent(pRec, (LPWSTR)szEvent, cchEvent, pchEvent)); + } + +ErrExit: + HENUMInternal::ClearEnum(&hEnum); + + return hr; +} + +HRESULT RegMeta::EnumMethodSemantics( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdMethodDef mb, // [IN] MethodDef to scope the enumeration. + mdToken rEventProp[], // [OUT] Put Event/Property here. + ULONG cMax, // [IN] Max properties to put. + ULONG *pcEventProp) // [OUT] Put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumMethodSemantics - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetMethodSemantics( // S_OK, S_FALSE, or error. + mdMethodDef mb, // [IN] method token + mdToken tkEventProp, // [IN] event/property token. + DWORD * + pdwSemanticsFlags) // [OUT] the role flags for the method/propevent pair +{ + DEBUG_PRINTF(1, "CordbSymbol - GetMethodSemantics - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetClassLayout( + mdTypeDef td, // [IN] give typedef + DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16 + COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array + ULONG cMax, // [IN] size of the array + ULONG *pcFieldOffset, // [OUT] needed array size + ULONG *pulClassSize) // [OUT] the size of the class +{ + HRESULT hr = NOERROR; + + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + ClassLayoutRec *pRec; + RID ridClassLayout; + int bLayout = 0; // Was any layout information found? + + _ASSERTE(TypeFromToken(td) == mdtTypeDef); + + IfFailGo(pMiniMd->FindClassLayoutHelper(td, &ridClassLayout)); + + if (InvalidRid(ridClassLayout)) { + // Nothing specified - return default values of 0. + if (pdwPackSize) + *pdwPackSize = 0; + if (pulClassSize) + *pulClassSize = 0; + } else { + IfFailGo( + pMiniMd->GetClassLayoutRecord(RidFromToken(ridClassLayout), &pRec)); + if (pdwPackSize) + *pdwPackSize = pMiniMd->getPackingSizeOfClassLayout(pRec); + if (pulClassSize) + *pulClassSize = pMiniMd->getClassSizeOfClassLayout(pRec); + bLayout = 1; + } + + // fill the layout array + if (rFieldOffset || pcFieldOffset) { + ULONG iFieldOffset = 0; + ULONG ridFieldStart; + ULONG ridFieldEnd; + ULONG ridFieldLayout; + ULONG ulOffset; + TypeDefRec *pTypeDefRec; + FieldLayoutRec *pLayout2Rec; + mdFieldDef fd; + + // record for this typedef in TypeDef Table + IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(td), &pTypeDefRec)); + + // find the starting and end field for this typedef + ridFieldStart = pMiniMd->getFieldListOfTypeDef(pTypeDefRec); + IfFailGo(pMiniMd->getEndFieldListOfTypeDef(RidFromToken(td), &ridFieldEnd)); + + // loop through the field table + + for (; ridFieldStart < ridFieldEnd; ridFieldStart++) { + // Calculate the field token. + RID rid; + IfFailGo(pMiniMd->GetFieldRid(ridFieldStart, &rid)); + fd = TokenFromRid(rid, mdtFieldDef); + + // Calculate the FieldLayout rid for the current field. + IfFailGo(pMiniMd->FindFieldLayoutHelper(fd, &ridFieldLayout)); + + // Calculate the offset. + if (InvalidRid(ridFieldLayout)) + ulOffset = (ULONG)-1; + else { + // get the FieldLayout record. + IfFailGo(pMiniMd->GetFieldLayoutRecord(ridFieldLayout, &pLayout2Rec)); + ulOffset = pMiniMd->getOffSetOfFieldLayout(pLayout2Rec); + bLayout = 1; + } + + // fill in the field layout if output buffer still has space. + if (cMax > iFieldOffset && rFieldOffset) { + rFieldOffset[iFieldOffset].ridOfField = fd; + rFieldOffset[iFieldOffset].ulOffset = ulOffset; + } + + // advance the index to the buffer. + iFieldOffset++; + } + + if (bLayout && pcFieldOffset) + *pcFieldOffset = iFieldOffset; + } + + if (!bLayout) + hr = CLDB_E_RECORD_NOTFOUND; + +ErrExit: + + return hr; +} + +HRESULT RegMeta::GetFieldMarshal( + mdToken tk, // [IN] given a field's memberdef + PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field + ULONG *pcbNativeType) // [OUT] the count of bytes of *ppvNativeType +{ + DEBUG_PRINTF(1, "CordbSymbol - GetFieldMarshal - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetRVA( // S_OK or error. + mdToken tk, // Member for which to set offset + ULONG *pulCodeRVA, // The offset + DWORD *pdwImplFlags) // the implementation flags +{ + DEBUG_PRINTF(1, "CordbSymbol - GetRVA - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetPermissionSetProps( + mdPermission pm, // [IN] the permission token. + DWORD *pdwAction, // [OUT] CorDeclSecurity. + void const **ppvPermission, // [OUT] permission blob. + ULONG *pcbPermission) // [OUT] count of bytes of pvPermission. +{ + DEBUG_PRINTF(1, "CordbSymbol - GetPermissionSetProps - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetSigFromToken( // S_OK or error. + mdSignature mdSig, // [IN] Signature token. + PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. + ULONG *pcbSig) // [OUT] return size of signature. +{ + HRESULT hr = NOERROR; + + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + StandAloneSigRec *pRec; + + _ASSERTE(TypeFromToken(mdSig) == mdtSignature); + _ASSERTE(ppvSig && pcbSig); + + IfFailGo(pMiniMd->GetStandAloneSigRecord(RidFromToken(mdSig), &pRec)); + IfFailGo(pMiniMd->getSignatureOfStandAloneSig(pRec, ppvSig, pcbSig)); + +ErrExit: + + return hr; +} + +HRESULT RegMeta::GetModuleRefProps( // S_OK or error. + mdModuleRef mur, // [IN] moduleref token. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] buffer to fill with the moduleref name. + ULONG cchName, // [IN] size of szName in wide characters. + ULONG *pchName) // [OUT] actual count of characters in the name. +{ + DEBUG_PRINTF(1, "CordbSymbol - GetModuleRefProps - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumModuleRefs( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. + ULONG cmax, // [IN] max memberrefs to put. + ULONG *pcModuleRefs) // [OUT] put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumModuleRefs - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetTypeSpecFromToken( // S_OK or error. + mdTypeSpec typespec, // [IN] TypeSpec token. + PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature + ULONG *pcbSig) // [OUT] return size of signature. +{ + HRESULT hr = NOERROR; + + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + TypeSpecRec *pRec = NULL; + + _ASSERTE(TypeFromToken(typespec) == mdtTypeSpec); + _ASSERTE(ppvSig && pcbSig); + + IfFailGo(pMiniMd->GetTypeSpecRecord(RidFromToken(typespec), &pRec)); + IfFailGo(pMiniMd->getSignatureOfTypeSpec(pRec, ppvSig, pcbSig)); + +ErrExit: + + return hr; +} + +HRESULT RegMeta::GetNameFromToken( // Not Recommended! May be removed! + mdToken tk, // [IN] Token to get name from. Must have a name. + MDUTF8CSTR *pszUtf8NamePtr) // [OUT] Return pointer to UTF8 name in heap. +{ + DEBUG_PRINTF(1, "CordbSymbol - GetNameFromToken - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumUnresolvedMethods( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken rMethods[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens) // [OUT] Put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumUnresolvedMethods - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetUserString( // S_OK or error. + mdString stk, // [IN] String token. + __out_ecount_opt(cchStringSize) LPWSTR wszString, // [OUT] Copy of string. + ULONG cchStringSize, // [IN] Max chars of room in szString. + ULONG *pcchStringSize) // [OUT] How many chars in actual string. +{ + HRESULT hr = S_OK; + ULONG cchStringSize_Dummy; + MetaData::DataBlob userString; + + // Get the string data. + IfFailGo(m_pStgdb->m_MiniMd.GetUserString(RidFromToken(stk), &userString)); + // Want to get whole characters, followed by byte to indicate whether there + // are extended characters (>= 0x80). + if ((userString.GetSize() % sizeof(WCHAR)) == 0) { + Debug_ReportError( + "User strings should have 1 byte terminator (either 0x00 or 0x80)."); + IfFailGo(CLDB_E_FILE_CORRUPT); + } + + // Strip off the last byte. + if (!userString.TruncateBySize(1)) { + Debug_ReportInternalError( + "There's a bug, because previous % 2 check didn't return 0."); + IfFailGo(METADATA_E_INTERNAL_ERROR); + } + + // Convert bytes to characters. + if (pcchStringSize == NULL) { + pcchStringSize = &cchStringSize_Dummy; + } + *pcchStringSize = userString.GetSize() / sizeof(WCHAR); + + // Copy the string back to the caller. + if ((wszString != NULL) && (cchStringSize > 0)) { + ULONG cbStringSize = cchStringSize * sizeof(WCHAR); + memcpy(wszString, userString.GetDataPointer(), + min(userString.GetSize(), cbStringSize)); + if (cbStringSize < userString.GetSize()) { + if ((wszString != NULL) && (cchStringSize > 0)) { + // null-terminate the truncated output string + wszString[cchStringSize - 1] = W('\0'); + } + + hr = CLDB_S_TRUNCATION; + } + } + +ErrExit: + return hr; +} + +HRESULT RegMeta::GetPinvokeMap( // S_OK or error. + mdToken tk, // [IN] FieldDef or MethodDef. + DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. + __out_ecount_part_opt(cchImportName, *pchImportName) + LPWSTR szImportName, // [OUT] Import name. + ULONG cchImportName, // [IN] Size of the name buffer. + ULONG *pchImportName, // [OUT] Actual number of characters stored. + mdModuleRef *pmrImportDLL) // [OUT] ModuleRef token for the target DLL. +{ + DEBUG_PRINTF(1, "CordbSymbol - GetPinvokeMap - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumSignatures( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdSignature rSignatures[], // [OUT] put signatures here. + ULONG cmax, // [IN] max signatures to put. + ULONG *pcSignatures) // [OUT] put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumSignatures - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumTypeSpecs( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. + ULONG cmax, // [IN] max TypeSpecs to put. + ULONG *pcTypeSpecs) // [OUT] put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumTypeSpecs - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumUserStrings( // S_OK or error. + HCORENUM *phEnum, // [IN/OUT] pointer to the enum. + mdString rStrings[], // [OUT] put Strings here. + ULONG cmax, // [IN] max Strings to put. + ULONG *pcStrings) // [OUT] put # put here. +{ + DEBUG_PRINTF(1, "CordbSymbol - EnumUserStrings - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetParamForMethodIndex( // S_OK or error. + mdMethodDef md, // [IN] Method token. + ULONG ulParamSeq, // [IN] Parameter sequence. + mdParamDef *ppd) // [IN] Put Param token here. +{ + DEBUG_PRINTF(1, "CordbSymbol - GetParamForMethodIndex - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::EnumCustomAttributes( // S_OK or error. + HCORENUM *phEnum, // [IN, OUT] COR enumerator. + mdToken tk, // [IN] Token to scope the enumeration, 0 for all. + mdToken tkType, // [IN] Type of interest, 0 for all. + mdCustomAttribute + rCustomAttributes[], // [OUT] Put custom attribute tokens here. + ULONG cMax, // [IN] Size of rCustomAttributes. + ULONG + *pcCustomAttributes) // [OUT, OPTIONAL] Put count of token values here. +{ + HRESULT hr = S_OK; + + HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); + ULONG ridStart; + ULONG ridEnd; + HENUMInternal *pEnum = *ppmdEnum; + CustomAttributeRec *pRec; + ULONG index; + + if (pEnum == 0) { + // instantiating a new ENUM + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + CLookUpHash *pHashTable = pMiniMd->m_pLookUpHashs[TBL_CustomAttribute]; + + // Does caller want all custom Values? + if (IsNilToken(tk)) { + IfFailGo(HENUMInternal::CreateSimpleEnum( + mdtCustomAttribute, 1, pMiniMd->getCountCustomAttributes() + 1, + &pEnum)); + } else { + // Scope by some object. + if (pMiniMd->IsSorted(TBL_CustomAttribute)) { + // Get CustomAttributes for the object. + IfFailGo(pMiniMd->getCustomAttributeForToken(tk, &ridEnd, &ridStart)); + + if (IsNilToken(tkType)) { + // Simple enumerator for object's entire list. + IfFailGo(HENUMInternal::CreateSimpleEnum(mdtCustomAttribute, ridStart, + ridEnd, &pEnum)); + } else { + // Dynamic enumerator for subsetted list. + + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtCustomAttribute, + &pEnum)); + + for (index = ridStart; index < ridEnd; index++) { + IfFailGo(pMiniMd->GetCustomAttributeRecord(index, &pRec)); + if (tkType == pMiniMd->getTypeOfCustomAttribute(pRec)) { + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(index, mdtCustomAttribute))); + } + } + } + } else { + + if (pHashTable) { + // table is not sorted but hash is built + // We want to create dynmaic array to hold the dynamic enumerator. + TOKENHASHENTRY *p; + ULONG iHash; + int pos; + mdToken tkParentTmp; + mdToken tkTypeTmp; + + // Hash the data. + iHash = pMiniMd->HashCustomAttribute(tk); + + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtCustomAttribute, + &pEnum)); + + // Go through every entry in the hash chain looking for ours. + for (p = pHashTable->FindFirst(iHash, pos); p; + p = pHashTable->FindNext(pos)) { + + CustomAttributeRec *pCustomAttribute; + IfFailGo(pMiniMd->GetCustomAttributeRecord(RidFromToken(p->tok), + &pCustomAttribute)); + tkParentTmp = pMiniMd->getParentOfCustomAttribute(pCustomAttribute); + tkTypeTmp = pMiniMd->getTypeOfCustomAttribute(pCustomAttribute); + if (tkParentTmp == tk) { + if (IsNilToken(tkType) || tkType == tkTypeTmp) { + // compare the blob value + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(p->tok, mdtCustomAttribute))); + } + } + } + } else { + + // table is not sorted and hash is not built so we have to create + // dynmaic array create the dynamic enumerator and loop through CA + // table linearly + // + ridStart = 1; + ridEnd = pMiniMd->getCountCustomAttributes() + 1; + + IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtCustomAttribute, + &pEnum)); + + for (index = ridStart; index < ridEnd; index++) { + IfFailGo(pMiniMd->GetCustomAttributeRecord(index, &pRec)); + if (tk == pMiniMd->getParentOfCustomAttribute(pRec) && + (tkType == pMiniMd->getTypeOfCustomAttribute(pRec) || + IsNilToken(tkType))) { + IfFailGo(HENUMInternal::AddElementToEnum( + pEnum, TokenFromRid(index, mdtCustomAttribute))); + } + } + } + } + } + + // set the output parameter + *ppmdEnum = pEnum; + } + + // fill the output token buffer + hr = HENUMInternal::EnumWithCount(pEnum, cMax, rCustomAttributes, + pcCustomAttributes); + +ErrExit: + HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); + + return hr; +} + +HRESULT RegMeta::GetCustomAttributeProps( // S_OK or error. + mdCustomAttribute cv, // [IN] CustomAttribute token. + mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. + mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. + void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. + ULONG *pcbSize) // [OUT, OPTIONAL] Put size of date here. +{ + HRESULT hr = S_OK; // A result. + + CMiniMdRW *pMiniMd; + + _ASSERTE(TypeFromToken(cv) == mdtCustomAttribute); + + pMiniMd = &(m_pStgdb->m_MiniMd); + CustomAttributeRec *pCustomAttributeRec; // The custom value record. + + IfFailGo(pMiniMd->GetCustomAttributeRecord(RidFromToken(cv), + &pCustomAttributeRec)); + + if (ptkObj) + *ptkObj = pMiniMd->getParentOfCustomAttribute(pCustomAttributeRec); + + if (ptkType) + *ptkType = pMiniMd->getTypeOfCustomAttribute(pCustomAttributeRec); + + if (ppBlob != NULL) { + IfFailGo(pMiniMd->getValueOfCustomAttribute( + pCustomAttributeRec, (const BYTE **)ppBlob, pcbSize)); + } + +ErrExit: + + return hr; +} + +HRESULT RegMeta::FindTypeRef( + mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. + LPCWSTR szName, // [IN] TypeRef Name. + mdTypeRef *ptr) // [OUT] matching TypeRef. +{ + DEBUG_PRINTF(1, "CordbSymbol - FindTypeRef - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetMemberProps( + mdToken mb, // The member for which to get props. + mdTypeDef *pClass, // Put member's class here. + __out_ecount_part_opt(cchMember, *pchMember) + LPWSTR szMember, // Put member's name here. + ULONG cchMember, // Size of szMember buffer in wide chars. + ULONG *pchMember, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + ULONG *pulCodeRVA, // [OUT] codeRVA + DWORD *pdwImplFlags, // [OUT] Impl. Flags + DWORD + *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* + UVCP_CONSTANT *ppValue, // [OUT] constant value + ULONG * + pcchValue) // [OUT] size of constant string in chars, 0 for non-strings. +{ + DEBUG_PRINTF(1, "CordbSymbol - GetMemberProps - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::GetFieldProps( + mdFieldDef fd, // The field for which to get props. + mdTypeDef *pClass, // Put field's class here. + __out_ecount_part_opt(cchField, *pchField) + LPWSTR szField, // Put field's name here. + ULONG cchField, // Size of szField buffer in wide chars. + ULONG *pchField, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + DWORD + *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* + UVCP_CONSTANT *ppValue, // [OUT] constant value + ULONG + *pchValue) // [OUT] size of constant string in chars, 0 for non-strings. +{ + HRESULT hr = NOERROR; + + BEGIN_ENTRYPOINT_NOTHROW; + + FieldRec *pFieldRec; + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + _ASSERTE(TypeFromToken(fd) == mdtFieldDef); + + IfFailGo(pMiniMd->GetFieldRecord(RidFromToken(fd), &pFieldRec)); + + if (pClass) { + // caller wants parent typedef + IfFailGo(pMiniMd->FindParentOfFieldHelper(fd, pClass)); + + if (IsGlobalMethodParentToken(*pClass)) { + // If the parent of Field is the , return mdTypeDefNil instead. + *pClass = mdTypeDefNil; + } + } + if (ppvSigBlob || pcbSigBlob) { + // caller wants signature information + PCCOR_SIGNATURE pvSigTmp; + ULONG cbSig; + IfFailGo(pMiniMd->getSignatureOfField(pFieldRec, &pvSigTmp, &cbSig)); + if (ppvSigBlob) + *ppvSigBlob = pvSigTmp; + if (pcbSigBlob) + *pcbSigBlob = cbSig; + } + if (pdwAttr) { + *pdwAttr = pMiniMd->getFlagsOfField(pFieldRec); + } + if (pdwCPlusTypeFlag || ppValue || pchValue) { + // get the constant value + ULONG cbValue; + RID rid; + IfFailGo(pMiniMd->FindConstantHelper(fd, &rid)); + + if (pchValue) + *pchValue = 0; + + if (InvalidRid(rid)) { + // There is no constant value associate with it + if (pdwCPlusTypeFlag) + *pdwCPlusTypeFlag = ELEMENT_TYPE_VOID; + + if (ppValue) + *ppValue = NULL; + } else { + ConstantRec *pConstantRec; + IfFailGo(m_pStgdb->m_MiniMd.GetConstantRecord(rid, &pConstantRec)); + DWORD dwType; + + // get the type of constant value + dwType = pMiniMd->getTypeOfConstant(pConstantRec); + if (pdwCPlusTypeFlag) + *pdwCPlusTypeFlag = dwType; + + // get the value blob + if (ppValue != NULL) { + IfFailGo(pMiniMd->getValueOfConstant(pConstantRec, + (const BYTE **)ppValue, &cbValue)); + if (pchValue && dwType == ELEMENT_TYPE_STRING) + *pchValue = cbValue / sizeof(WCHAR); + } + } + } + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szField || pchField) { + IfFailGo(pMiniMd->getNameOfField(pFieldRec, szField, cchField, pchField)); + } + +ErrExit: + + return hr; +} + +HRESULT RegMeta::GetPropertyProps( // S_OK, S_FALSE, or error. + mdProperty prop, // [IN] property token + mdTypeDef *pClass, // [OUT] typedef containing the property declarion. + LPCWSTR szProperty, // [OUT] Property name + ULONG cchProperty, // [IN] the count of wchar of szProperty + ULONG *pchProperty, // [OUT] actual count of wchar for property name + DWORD *pdwPropFlags, // [OUT] property flags. + PCCOR_SIGNATURE + *ppvSig, // [OUT] property type. pointing to meta data internal blob + ULONG *pbSig, // [OUT] count of bytes in *ppvSig + DWORD + *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* + UVCP_CONSTANT *ppDefaultValue, // [OUT] constant value + ULONG *pchDefaultValue, // [OUT] size of constant string in chars, 0 for + // non-strings. + mdMethodDef *pmdSetter, // [OUT] setter method of the property + mdMethodDef *pmdGetter, // [OUT] getter method of the property + mdMethodDef rmdOtherMethod[], // [OUT] other method of the property + ULONG cMax, // [IN] size of rmdOtherMethod + ULONG *pcOtherMethod) // [OUT] total number of other method of this property +{ + HRESULT hr = NOERROR; + + CMiniMdRW *pMiniMd; + PropertyRec *pRec; + HENUMInternal hEnum; + + _ASSERTE(TypeFromToken(prop) == mdtProperty); + + pMiniMd = &(m_pStgdb->m_MiniMd); + + HENUMInternal::ZeroEnum(&hEnum); + IfFailGo(pMiniMd->GetPropertyRecord(RidFromToken(prop), &pRec)); + + if (pClass) { + // find the property map entry corresponding to this property + IfFailGo(pMiniMd->FindParentOfPropertyHelper(prop, pClass)); + } + if (pdwPropFlags) { + *pdwPropFlags = pMiniMd->getPropFlagsOfProperty(pRec); + } + if (ppvSig || pbSig) { + // caller wants the signature + // + ULONG cbSig; + PCCOR_SIGNATURE pvSig; + IfFailGo(pMiniMd->getTypeOfProperty(pRec, &pvSig, &cbSig)); + if (ppvSig) { + *ppvSig = pvSig; + } + if (pbSig) { + *pbSig = cbSig; + } + } + if (pdwCPlusTypeFlag || ppDefaultValue || pchDefaultValue) { + // get the constant value + ULONG cbValue; + RID rid; + IfFailGo(pMiniMd->FindConstantHelper(prop, &rid)); + + if (pchDefaultValue) + *pchDefaultValue = 0; + + if (InvalidRid(rid)) { + // There is no constant value associate with it + if (pdwCPlusTypeFlag) + *pdwCPlusTypeFlag = ELEMENT_TYPE_VOID; + + if (ppDefaultValue) + *ppDefaultValue = NULL; + } else { + ConstantRec *pConstantRec; + IfFailGo(m_pStgdb->m_MiniMd.GetConstantRecord(rid, &pConstantRec)); + DWORD dwType; + + // get the type of constant value + dwType = pMiniMd->getTypeOfConstant(pConstantRec); + if (pdwCPlusTypeFlag) + *pdwCPlusTypeFlag = dwType; + + // get the value blob + if (ppDefaultValue != NULL) { + IfFailGo(pMiniMd->getValueOfConstant( + pConstantRec, (const BYTE **)ppDefaultValue, &cbValue)); + if (pchDefaultValue && dwType == ELEMENT_TYPE_STRING) + *pchDefaultValue = cbValue / sizeof(WCHAR); + } + } + } + { + MethodSemanticsRec *pSemantics; + RID ridCur; + ULONG cCurOtherMethod = 0; + ULONG ulSemantics; + mdMethodDef tkMethod; + + // initialize output parameters + if (pmdSetter) + *pmdSetter = mdMethodDefNil; + if (pmdGetter) + *pmdGetter = mdMethodDefNil; + + IfFailGo(pMiniMd->FindMethodSemanticsHelper(prop, &hEnum)); + while (HENUMInternal::EnumNext(&hEnum, (mdToken *)&ridCur)) { + IfFailGo(pMiniMd->GetMethodSemanticsRecord(ridCur, &pSemantics)); + ulSemantics = pMiniMd->getSemanticOfMethodSemantics(pSemantics); + tkMethod = TokenFromRid(pMiniMd->getMethodOfMethodSemantics(pSemantics), + mdtMethodDef); + switch (ulSemantics) { + case msSetter: + if (pmdSetter) + *pmdSetter = tkMethod; + break; + case msGetter: + if (pmdGetter) + *pmdGetter = tkMethod; + break; + case msOther: + if (cCurOtherMethod < cMax) + rmdOtherMethod[cCurOtherMethod] = tkMethod; + cCurOtherMethod++; + break; + default: + _ASSERTE(!"BadKind!"); + } + } + + // set the output parameter + if (pcOtherMethod) + *pcOtherMethod = cCurOtherMethod; + } + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szProperty || pchProperty) { + IfFailGo(pMiniMd->getNameOfProperty(pRec, (LPWSTR)szProperty, cchProperty, + pchProperty)); + } + +ErrExit: + HENUMInternal::ClearEnum(&hEnum); + return hr; +} + +HRESULT RegMeta::GetParamProps( // S_OK or error. + mdParamDef pd, // [IN]The Parameter. + mdMethodDef *pmd, // [OUT] Parent Method token. + ULONG *pulSequence, // [OUT] Parameter sequence. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] Put name here. + ULONG cchName, // [OUT] Size of name buffer. + ULONG *pchName, // [OUT] Put actual size of name here. + DWORD *pdwAttr, // [OUT] Put flags here. + DWORD * + pdwCPlusTypeFlag, // [OUT] Flag for value type. selected ELEMENT_TYPE_*. + UVCP_CONSTANT *ppValue, // [OUT] Constant value. + ULONG + *pchValue) // [OUT] size of constant string in chars, 0 for non-strings. +{ + HRESULT hr = NOERROR; + + ParamRec *pParamRec; + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + _ASSERTE(TypeFromToken(pd) == mdtParamDef); + + IfFailGo(pMiniMd->GetParamRecord(RidFromToken(pd), &pParamRec)); + + if (pmd) { + IfFailGo(pMiniMd->FindParentOfParamHelper(pd, pmd)); + _ASSERTE(TypeFromToken(*pmd) == mdtMethodDef); + } + if (pulSequence) + *pulSequence = pMiniMd->getSequenceOfParam(pParamRec); + if (pdwAttr) { + *pdwAttr = pMiniMd->getFlagsOfParam(pParamRec); + } + if (pdwCPlusTypeFlag || ppValue || pchValue) { + // get the constant value + ULONG cbValue; + RID rid; + IfFailGo(pMiniMd->FindConstantHelper(pd, &rid)); + + if (pchValue) + *pchValue = 0; + + if (InvalidRid(rid)) { + // There is no constant value associate with it + if (pdwCPlusTypeFlag) + *pdwCPlusTypeFlag = ELEMENT_TYPE_VOID; + + if (ppValue) + *ppValue = NULL; + } else { + ConstantRec *pConstantRec; + IfFailGo(m_pStgdb->m_MiniMd.GetConstantRecord(rid, &pConstantRec)); + DWORD dwType; + + // get the type of constant value + dwType = pMiniMd->getTypeOfConstant(pConstantRec); + if (pdwCPlusTypeFlag) + *pdwCPlusTypeFlag = dwType; + + // get the value blob + if (ppValue != NULL) { + IfFailGo(pMiniMd->getValueOfConstant(pConstantRec, + (const BYTE **)ppValue, &cbValue)); + if (pchValue && dwType == ELEMENT_TYPE_STRING) + *pchValue = cbValue / sizeof(WCHAR); + } + } + } + // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten + // with S_OK + if (szName || pchName) + IfFailGo(pMiniMd->getNameOfParam(pParamRec, szName, cchName, pchName)); + +ErrExit: + + return hr; +} + +HRESULT RegMeta::GetAssemblyFromScope(mdAssembly *ptkAssembly) { + HRESULT hr = NOERROR; + CMiniMdRW *pMiniMd = NULL; + + _ASSERTE(ptkAssembly); + + pMiniMd = &(m_pStgdb->m_MiniMd); + if (pMiniMd->getCountAssemblys()) { + *ptkAssembly = TokenFromRid(1, mdtAssembly); + } else { + IfFailGo(CLDB_E_RECORD_NOTFOUND); + } +ErrExit: + END_ENTRYPOINT_NOTHROW; + return hr; +} + +HRESULT RegMeta::GetCustomAttributeByName( // S_OK or error. + mdToken tkObj, // [IN] Object with Custom Attribute. + LPCWSTR wzName, // [IN] Name of desired Custom Attribute. + const void **ppData, // [OUT] Put pointer to data here. + ULONG *pcbData) // [OUT] Put size of data here. +{ + HRESULT hr; // A result. + + LPUTF8 szName; // Name in UFT8. + int iLen; // A length. + CMiniMdRW *pMiniMd = NULL; + + pMiniMd = &(m_pStgdb->m_MiniMd); + + iLen = WszWideCharToMultiByte(CP_UTF8, 0, wzName, -1, NULL, 0, 0, 0); + szName = (LPUTF8)_alloca(iLen); + VERIFY(WszWideCharToMultiByte(CP_UTF8, 0, wzName, -1, szName, iLen, 0, 0)); + + hr = ImportHelper::GetCustomAttributeByName(pMiniMd, tkObj, szName, ppData, + pcbData); + + return hr; +} + +BOOL RegMeta::IsValidToken( // True or False. + mdToken tk) // [IN] Given token. +{ + BOOL fRet = FALSE; + HRESULT hr = S_OK; + + // If acquiring the lock failed... + IfFailGo(hr); + + fRet = m_pStgdb->m_MiniMd._IsValidToken(tk); + +ErrExit: + return fRet; +} + +HRESULT RegMeta::GetNestedClassProps( // S_OK or error. + mdTypeDef tdNestedClass, // [IN] NestedClass token. + mdTypeDef *ptdEnclosingClass) // [OUT] EnclosingClass token. +{ + HRESULT hr = NOERROR; + + BEGIN_ENTRYPOINT_NOTHROW; + + NestedClassRec *pRecord; + ULONG iRecord; + CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); + + // If not a typedef -- return error. + if (TypeFromToken(tdNestedClass) != mdtTypeDef) { + IfFailGo(META_E_INVALID_TOKEN_TYPE); // PostError(META_E_INVALID_TOKEN_TYPE, + // tdNestedClass)); + } + + _ASSERTE(TypeFromToken(tdNestedClass) && !IsNilToken(tdNestedClass) && + ptdEnclosingClass); + + IfFailGo(pMiniMd->FindNestedClassHelper(tdNestedClass, &iRecord)); + + if (InvalidRid(iRecord)) { + hr = CLDB_E_RECORD_NOTFOUND; + goto ErrExit; + } + + IfFailGo(pMiniMd->GetNestedClassRecord(iRecord, &pRecord)); + + _ASSERTE(tdNestedClass == pMiniMd->getNestedClassOfNestedClass(pRecord)); + *ptdEnclosingClass = pMiniMd->getEnclosingClassOfNestedClass(pRecord); + +ErrExit: + return hr; +} + +HRESULT RegMeta::GetNativeCallConvFromSig( // S_OK or error. + void const *pvSig, // [IN] Pointer to signature. + ULONG cbSig, // [IN] Count of signature bytes. + ULONG *pCallConv) // [OUT] Put calling conv here (see CorPinvokemap). +{ + DEBUG_PRINTF(1, "CordbSymbol - GetNativeCallConvFromSig - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT RegMeta::IsGlobal( // S_OK or error. + mdToken pd, // [IN] Type, Field, or Method token. + int *pbGlobal) // [OUT] Put 1 if global, 0 otherwise. + +{ + DEBUG_PRINTF(1, "CordbSymbol - IsGlobal - NOT IMPLEMENTED\n"); + return S_OK; +} diff --git a/src/mono/dbi/cordb-symbol.h b/src/mono/dbi/cordb-symbol.h new file mode 100644 index 00000000000000..bd330ec94a3130 --- /dev/null +++ b/src/mono/dbi/cordb-symbol.h @@ -0,0 +1,671 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-SYMBOL.H +// + +#ifndef __MONO_DEBUGGER_CORDB_SYMBOL_H__ +#define __MONO_DEBUGGER_CORDB_SYMBOL_H__ + +#include +#include + +#define COR_GLOBAL_PARENT_TOKEN TokenFromRid(1, mdtTypeDef) + +class CLiteWeightStgdbRW; + +class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { + int token_id; + GHashTable *parameters; + CordbAssembly *pCordbAssembly; + CordbModule *cordbModule; + CLiteWeightStgdbRW *m_pStgdb; + int module_id; + +public: + RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule); + + inline int IsGlobalMethodParentTk(mdTypeDef td) { + return (td == mdTypeDefNil || td == mdTokenNil); + } + + int inline IsGlobalMethodParent(mdTypeDef *ptd) { + if (IsGlobalMethodParentTk(*ptd)) { + *ptd = COR_GLOBAL_PARENT_TOKEN; + return (true); + } + return (false); + } + + int inline IsGlobalMethodParentToken(mdTypeDef td) { + return (td == COR_GLOBAL_PARENT_TOKEN); + } + + STDMETHOD(EnumGenericParams) + (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken + tk, // [IN] TypeDef or MethodDef whose generic parameters are requested + mdGenericParam rGenericParams[], // [OUT] Put GenericParams here. + ULONG cMax, // [IN] Max GenericParams to put. + ULONG *pcGenericParams); + + STDMETHOD(GetGenericParamProps) + ( // S_OK or error. + mdGenericParam gp, // [IN] GenericParam + ULONG *pulParamSeq, // [OUT] Index of the type parameter + DWORD *pdwParamFlags, // [OUT] Flags, for future use (e.g. variance) + mdToken *ptOwner, // [OUT] Owner (TypeDef or MethodDef) + DWORD *reserved, // [OUT] For future use (e.g. non-type parameters) + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR wzname, // [OUT] Put name here + ULONG cchName, // [IN] Size of buffer + ULONG *pchName); // [OUT] Put size of name (wide chars) here. + + STDMETHOD(GetMethodSpecProps) + (mdMethodSpec mi, // [IN] The method instantiation + mdToken *tkParent, // [OUT] MethodDef or MemberRef + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob); // [OUT] actual size of signature blob + + STDMETHOD(EnumGenericParamConstraints) + (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdGenericParam tk, // [IN] GenericParam whose constraints are requested + mdGenericParamConstraint + rGenericParamConstraints[], // [OUT] Put GenericParamConstraints here. + ULONG cMax, // [IN] Max GenericParamConstraints to put. + ULONG *pcGenericParamConstraints); // [OUT] Put # put here. + + STDMETHOD(GetGenericParamConstraintProps) + ( // S_OK or error. + mdGenericParamConstraint gpc, // [IN] GenericParamConstraint + mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained + mdToken *ptkConstraintType); // [OUT] TypeDef/Ref/Spec constraint + + STDMETHOD(GetPEKind) + ( // S_OK or error. + DWORD *pdwPEKind, // [OUT] The kind of PE (0 - not a PE) + DWORD *pdwMAchine); // [OUT] Machine as defined in NT header + + STDMETHOD(GetVersionString) + ( // S_OK or error. + _Out_writes_to_opt_(ccBufSize, *pccBufSize) + LPWSTR pwzBuf, // [OUT] Put version string here. + DWORD ccBufSize, // [IN] size of the buffer, in wide chars + DWORD *pccBufSize); // [OUT] Size of the version string, wide chars, + // including terminating nul. + + STDMETHOD(EnumMethodSpecs) + (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tk, // [IN] MethodDef or MemberRef whose MethodSpecs are requested + mdMethodSpec rMethodSpecs[], // [OUT] Put MethodSpecs here. + ULONG cMax, // [IN] Max tokens to put. + ULONG *pcMethodSpecs); // [OUT] Put actual count here. + + STDMETHOD(GetAssemblyProps) + ( // S_OK or error. + mdAssembly mda, // [IN] The Assembly for which to get the properties. + const void **ppbPublicKey, // [OUT] Pointer to the public key. + ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. + ULONG *pulHashAlgId, // [OUT] Hash Algorithm. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. + DWORD *pdwAssemblyFlags); // [OUT] Flags. + + STDMETHOD(GetAssemblyRefProps) + ( // S_OK or error. + mdAssemblyRef + mdar, // [IN] The AssemblyRef for which to get the properties. + const void * + *ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token. + ULONG *pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or + // token. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. + const void **ppbHashValue, // [OUT] Hash blob. + ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob. + DWORD *pdwAssemblyRefFlags); // [OUT] Flags. + + STDMETHOD(GetFileProps) + ( // S_OK or error. + mdFile mdf, // [IN] The File for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob. + ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob. + DWORD *pdwFileFlags); // [OUT] Flags. + + STDMETHOD(GetExportedTypeProps) + ( // S_OK or error. + mdExportedType + mdct, // [IN] The ExportedType for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + mdToken * + ptkImplementation, // [OUT] mdFile or mdAssemblyRef or mdExportedType. + mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file. + DWORD *pdwExportedTypeFlags); // [OUT] Flags. + + STDMETHOD(GetManifestResourceProps) + ( // S_OK or error. + mdManifestResource + mdmr, // [IN] The ManifestResource for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides + // the ManifestResource. + DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within + // the file. + DWORD *pdwResourceFlags); // [OUT] Flags. + + STDMETHOD(EnumAssemblyRefs) + ( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdAssemblyRef rAssemblyRefs[], // [OUT] Put AssemblyRefs here. + ULONG cMax, // [IN] Max AssemblyRefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + STDMETHOD(EnumFiles) + ( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdFile rFiles[], // [OUT] Put Files here. + ULONG cMax, // [IN] Max Files to put. + ULONG *pcTokens); // [OUT] Put # put here. + + STDMETHOD(EnumExportedTypes) + ( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdExportedType rExportedTypes[], // [OUT] Put ExportedTypes here. + ULONG cMax, // [IN] Max ExportedTypes to put. + ULONG *pcTokens); // [OUT] Put # put here. + + STDMETHOD(EnumManifestResources) + ( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdManifestResource + rManifestResources[], // [OUT] Put ManifestResources here. + ULONG cMax, // [IN] Max Resources to put. + ULONG *pcTokens); // [OUT] Put # put here. + + STDMETHOD(GetAssemblyFromScope) + ( // S_OK or error + mdAssembly *ptkAssembly); + + STDMETHOD(FindExportedTypeByName) + ( // S_OK or error + LPCWSTR szName, // [IN] Name of the ExportedType. + mdToken mdtExportedType, // [IN] ExportedType for the enclosing class. + mdExportedType + *ptkExportedType); // [OUT] Put the ExportedType token here. + + STDMETHOD(FindManifestResourceByName) + ( // S_OK or error + LPCWSTR szName, // [IN] Name of the ManifestResource. + mdManifestResource + *ptkManifestResource); // [OUT] Put the ManifestResource token here. + + STDMETHOD(FindAssembliesByName) + ( // S_OK or error + LPCWSTR szAppBase, // [IN] optional - can be NULL + LPCWSTR szPrivateBin, // [IN] optional - can be NULL + LPCWSTR szAssemblyName, // [IN] required - this is the assembly you are + // requesting + IUnknown *ppIUnk[], // [OUT] put IMetaDataAssemblyImport pointers here + ULONG cMax, // [IN] The max number to put + ULONG *pcAssemblies); // [OUT] The number of assemblies returned. + + // IUnknown methods + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppvObj); + + ULONG STDMETHODCALLTYPE AddRef(); + ULONG STDMETHODCALLTYPE Release(); + + // IMetaDataImport functions + + void STDMETHODCALLTYPE CloseEnum(HCORENUM hEnum); + HRESULT STDMETHODCALLTYPE CountEnum(HCORENUM hEnum, ULONG *pulCount); + HRESULT STDMETHODCALLTYPE ResetEnum(HCORENUM hEnum, ULONG ulPos); + HRESULT STDMETHODCALLTYPE EnumTypeDefs(HCORENUM *phEnum, + mdTypeDef rTypeDefs[], ULONG cMax, + ULONG *pcTypeDefs); + HRESULT STDMETHODCALLTYPE EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td, + mdInterfaceImpl rImpls[], + ULONG cMax, ULONG *pcImpls); + HRESULT STDMETHODCALLTYPE EnumTypeRefs(HCORENUM *phEnum, + mdTypeRef rTypeRefs[], ULONG cMax, + ULONG *pcTypeRefs); + + HRESULT STDMETHODCALLTYPE FindTypeDefByName( // S_OK or error. + LPCWSTR szTypeDef, // [IN] Name of the Type. + mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class. + mdTypeDef *ptd); // [OUT] Put the TypeDef token here. + + HRESULT STDMETHODCALLTYPE GetScopeProps( // S_OK or error. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] Put the name here. + ULONG cchName, // [IN] Size of name buffer in wide chars. + ULONG *pchName, // [OUT] Put size of name (wide chars) here. + GUID *pmvid); // [OUT, OPTIONAL] Put MVID here. + + HRESULT STDMETHODCALLTYPE GetModuleFromScope( // S_OK. + mdModule *pmd); // [OUT] Put mdModule token here. + + HRESULT STDMETHODCALLTYPE GetTypeDefProps( // S_OK or error. + mdTypeDef td, // [IN] TypeDef token for inquiry. + __out_ecount_part_opt(cchTypeDef, *pchTypeDef) + LPWSTR szTypeDef, // [OUT] Put name here. + ULONG cchTypeDef, // [IN] size of name buffer in wide chars. + ULONG *pchTypeDef, // [OUT] put size of name (wide chars) here. + DWORD *pdwTypeDefFlags, // [OUT] Put flags here. + mdToken *ptkExtends); // [OUT] Put base class TypeDef/TypeRef here. + + HRESULT STDMETHODCALLTYPE GetInterfaceImplProps( // S_OK or error. + mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. + mdTypeDef *pClass, // [OUT] Put implementing class token here. + mdToken *ptkIface); // [OUT] Put implemented interface token here. + + HRESULT STDMETHODCALLTYPE GetTypeRefProps( // S_OK or error. + mdTypeRef tr, // [IN] TypeRef token. + mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or + // AssemblyRef. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] Name of the TypeRef. + ULONG cchName, // [IN] Size of buffer. + ULONG *pchName); // [OUT] Size of Name. + + HRESULT STDMETHODCALLTYPE ResolveTypeRef(mdTypeRef tr, REFIID riid, + IUnknown **ppIScope, mdTypeDef *ptd); + + HRESULT STDMETHODCALLTYPE EnumMembers( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + mdToken rMembers[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMembersWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdToken rMembers[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMethods( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + mdMethodDef rMethods[], // [OUT] Put MethodDefs here. + ULONG cMax, // [IN] Max MethodDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMethodsWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdMethodDef rMethods[], // [OU] Put MethodDefs here. + ULONG cMax, // [IN] Max MethodDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumFields( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + mdFieldDef rFields[], // [OUT] Put FieldDefs here. + ULONG cMax, // [IN] Max FieldDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumFieldsWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdFieldDef rFields[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumParams( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdMethodDef mb, // [IN] MethodDef to scope the enumeration. + mdParamDef rParams[], // [OUT] Put ParamDefs here. + ULONG cMax, // [IN] Max ParamDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMemberRefs( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tkParent, // [IN] Parent token to scope the enumeration. + mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here. + ULONG cMax, // [IN] Max MemberRefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMethodImpls( // S_OK, S_FALSE, or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdToken rMethodBody[], // [OUT] Put Method Body tokens here. + mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here. + ULONG cMax, // [IN] Max tokens to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumPermissionSets( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tk, // [IN] if !NIL, token to scope the enumeration. + DWORD dwActions, // [IN] if !0, return only these actions. + mdPermission rPermission[], // [OUT] Put Permissions here. + ULONG cMax, // [IN] Max Permissions to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE FindMember( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdToken *pmb); // [OUT] matching memberdef + + HRESULT STDMETHODCALLTYPE FindMethod( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdMethodDef *pmb); // [OUT] matching memberdef + + HRESULT STDMETHODCALLTYPE FindField( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdFieldDef *pmb); // [OUT] matching memberdef + + HRESULT STDMETHODCALLTYPE FindMemberRef( + mdTypeRef td, // [IN] given typeRef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdMemberRef *pmr); // [OUT] matching memberref + + HRESULT STDMETHODCALLTYPE GetMethodProps( + mdMethodDef mb, // The method for which to get props. + mdTypeDef *pClass, // Put method's class here. + __out_ecount_part_opt(cchMethod, *pchMethod) + LPWSTR szMethod, // Put method's name here. + ULONG cchMethod, // Size of szMethod buffer in wide chars. + ULONG *pchMethod, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + ULONG *pulCodeRVA, // [OUT] codeRVA + DWORD *pdwImplFlags); // [OUT] Impl. Flags + + HRESULT STDMETHODCALLTYPE GetMemberRefProps( // S_OK or error. + mdMemberRef mr, // [IN] given memberref + mdToken *ptk, // [OUT] Put classref or classdef here. + __out_ecount_part_opt(cchMember, *pchMember) + LPWSTR szMember, // [OUT] buffer to fill for member's name + ULONG cchMember, // [IN] the count of char of szMember + ULONG *pchMember, // [OUT] actual count of char in member name + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value + ULONG *pbSig); // [OUT] actual size of signature blob + + HRESULT STDMETHODCALLTYPE EnumProperties( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdProperty rProperties[], // [OUT] Put Properties here. + ULONG cMax, // [IN] Max properties to put. + ULONG *pcProperties); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumEvents( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdEvent rEvents[], // [OUT] Put events here. + ULONG cMax, // [IN] Max events to put. + ULONG *pcEvents); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE GetEventProps( // S_OK, S_FALSE, or error. + mdEvent ev, // [IN] event token + mdTypeDef *pClass, // [OUT] typedef containing the event declarion. + LPCWSTR szEvent, // [OUT] Event name + ULONG cchEvent, // [IN] the count of wchar of szEvent + ULONG *pchEvent, // [OUT] actual count of wchar for event's name + DWORD *pdwEventFlags, // [OUT] Event flags. + mdToken *ptkEventType, // [OUT] EventType class + mdMethodDef *pmdAddOn, // [OUT] AddOn method of the event + mdMethodDef *pmdRemoveOn, // [OUT] RemoveOn method of the event + mdMethodDef *pmdFire, // [OUT] Fire method of the event + mdMethodDef rmdOtherMethod[], // [OUT] other method of the event + ULONG cMax, // [IN] size of rmdOtherMethod + ULONG *pcOtherMethod); // [OUT] total number of other method of this event + + HRESULT STDMETHODCALLTYPE EnumMethodSemantics( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdMethodDef mb, // [IN] MethodDef to scope the enumeration. + mdToken rEventProp[], // [OUT] Put Event/Property here. + ULONG cMax, // [IN] Max properties to put. + ULONG *pcEventProp); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE GetMethodSemantics( // S_OK, S_FALSE, or error. + mdMethodDef mb, // [IN] method token + mdToken tkEventProp, // [IN] event/property token. + DWORD *pdwSemanticsFlags); // [OUT] the role flags for the + // method/propevent pair + + HRESULT STDMETHODCALLTYPE + GetClassLayout(mdTypeDef td, // [IN] give typedef + DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16 + COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array + ULONG cMax, // [IN] size of the array + ULONG *pcFieldOffset, // [OUT] needed array size + ULONG *pulClassSize); // [OUT] the size of the class + + HRESULT STDMETHODCALLTYPE GetFieldMarshal( + mdToken tk, // [IN] given a field's memberdef + PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field + ULONG *pcbNativeType); // [OUT] the count of bytes of *ppvNativeType + + HRESULT STDMETHODCALLTYPE GetRVA( // S_OK or error. + mdToken tk, // Member for which to set offset + ULONG *pulCodeRVA, // The offset + DWORD *pdwImplFlags); // the implementation flags + + HRESULT STDMETHODCALLTYPE GetPermissionSetProps( + mdPermission pm, // [IN] the permission token. + DWORD *pdwAction, // [OUT] CorDeclSecurity. + void const **ppvPermission, // [OUT] permission blob. + ULONG *pcbPermission); // [OUT] count of bytes of pvPermission. + + HRESULT STDMETHODCALLTYPE GetSigFromToken( // S_OK or error. + mdSignature mdSig, // [IN] Signature token. + PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. + ULONG *pcbSig); // [OUT] return size of signature. + + HRESULT STDMETHODCALLTYPE GetModuleRefProps( // S_OK or error. + mdModuleRef mur, // [IN] moduleref token. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] buffer to fill with the moduleref name. + ULONG cchName, // [IN] size of szName in wide characters. + ULONG *pchName); // [OUT] actual count of characters in the name. + + HRESULT STDMETHODCALLTYPE EnumModuleRefs( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. + ULONG cmax, // [IN] max memberrefs to put. + ULONG *pcModuleRefs); // [OUT] put # put here. + + HRESULT STDMETHODCALLTYPE GetTypeSpecFromToken( // S_OK or error. + mdTypeSpec typespec, // [IN] TypeSpec token. + PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature + ULONG *pcbSig); // [OUT] return size of signature. + + HRESULT STDMETHODCALLTYPE + GetNameFromToken( // Not Recommended! May be removed! + mdToken tk, // [IN] Token to get name from. Must have a name. + MDUTF8CSTR *pszUtf8NamePtr); // [OUT] Return pointer to UTF8 name in heap. + + HRESULT STDMETHODCALLTYPE EnumUnresolvedMethods( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken rMethods[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE GetUserString( // S_OK or error. + mdString stk, // [IN] String token. + __out_ecount_part_opt(cchString, *pchString) + LPWSTR szString, // [OUT] Copy of string. + ULONG cchString, // [IN] Max chars of room in szString. + ULONG *pchString); // [OUT] How many chars in actual string. + + HRESULT STDMETHODCALLTYPE GetPinvokeMap( // S_OK or error. + mdToken tk, // [IN] FieldDef or MethodDef. + DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. + __out_ecount_part_opt(cchImportName, *pchImportName) + LPWSTR szImportName, // [OUT] Import name. + ULONG cchImportName, // [IN] Size of the name buffer. + ULONG *pchImportName, // [OUT] Actual number of characters stored. + mdModuleRef *pmrImportDLL); // [OUT] ModuleRef token for the target DLL. + + HRESULT STDMETHODCALLTYPE EnumSignatures( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdSignature rSignatures[], // [OUT] put signatures here. + ULONG cmax, // [IN] max signatures to put. + ULONG *pcSignatures); // [OUT] put # put here. + + HRESULT STDMETHODCALLTYPE EnumTypeSpecs( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. + ULONG cmax, // [IN] max TypeSpecs to put. + ULONG *pcTypeSpecs); // [OUT] put # put here. + + HRESULT STDMETHODCALLTYPE EnumUserStrings( // S_OK or error. + HCORENUM *phEnum, // [IN/OUT] pointer to the enum. + mdString rStrings[], // [OUT] put Strings here. + ULONG cmax, // [IN] max Strings to put. + ULONG *pcStrings); // [OUT] put # put here. + + HRESULT STDMETHODCALLTYPE GetParamForMethodIndex( // S_OK or error. + mdMethodDef md, // [IN] Method token. + ULONG ulParamSeq, // [IN] Parameter sequence. + mdParamDef *ppd); // [IN] Put Param token here. + + HRESULT STDMETHODCALLTYPE EnumCustomAttributes( // S_OK or error. + HCORENUM *phEnum, // [IN, OUT] COR enumerator. + mdToken tk, // [IN] Token to scope the enumeration, 0 for all. + mdToken tkType, // [IN] Type of interest, 0 for all. + mdCustomAttribute + rCustomAttributes[], // [OUT] Put custom attribute tokens here. + ULONG cMax, // [IN] Size of rCustomAttributes. + ULONG *pcCustomAttributes); // [OUT, OPTIONAL] Put count of token values + // here. + + HRESULT STDMETHODCALLTYPE GetCustomAttributeProps( // S_OK or error. + mdCustomAttribute cv, // [IN] CustomAttribute token. + mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. + mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. + void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. + ULONG *pcbSize); // [OUT, OPTIONAL] Put size of date here. + + HRESULT STDMETHODCALLTYPE FindTypeRef( + mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. + LPCWSTR szName, // [IN] TypeRef Name. + mdTypeRef *ptr); // [OUT] matching TypeRef. + + HRESULT STDMETHODCALLTYPE GetMemberProps( + mdToken mb, // The member for which to get props. + mdTypeDef *pClass, // Put member's class here. + __out_ecount_part_opt(cchMember, *pchMember) + LPWSTR szMember, // Put member's name here. + ULONG cchMember, // Size of szMember buffer in wide chars. + ULONG *pchMember, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + ULONG *pulCodeRVA, // [OUT] codeRVA + DWORD *pdwImplFlags, // [OUT] Impl. Flags + DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected + // ELEMENT_TYPE_* + UVCP_CONSTANT *ppValue, // [OUT] constant value + ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for + // non-strings. + + HRESULT STDMETHODCALLTYPE GetFieldProps( + mdFieldDef mb, // The field for which to get props. + mdTypeDef *pClass, // Put field's class here. + __out_ecount_part_opt(cchField, *pchField) + LPWSTR szField, // Put field's name here. + ULONG cchField, // Size of szField buffer in wide chars. + ULONG *pchField, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected + // ELEMENT_TYPE_* + UVCP_CONSTANT *ppValue, // [OUT] constant value + ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for + // non-strings. + + HRESULT STDMETHODCALLTYPE GetPropertyProps( // S_OK, S_FALSE, or error. + mdProperty prop, // [IN] property token + mdTypeDef *pClass, // [OUT] typedef containing the property declarion. + LPCWSTR szProperty, // [OUT] Property name + ULONG cchProperty, // [IN] the count of wchar of szProperty + ULONG *pchProperty, // [OUT] actual count of wchar for property name + DWORD *pdwPropFlags, // [OUT] property flags. + PCCOR_SIGNATURE + *ppvSig, // [OUT] property type. pointing to meta data internal blob + ULONG *pbSig, // [OUT] count of bytes in *ppvSig + DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected + // ELEMENT_TYPE_* + UVCP_CONSTANT *ppDefaultValue, // [OUT] constant value + ULONG *pcchDefaultValue, // [OUT] size of constant string in chars, 0 for + // non-strings. + mdMethodDef *pmdSetter, // [OUT] setter method of the property + mdMethodDef *pmdGetter, // [OUT] getter method of the property + mdMethodDef rmdOtherMethod[], // [OUT] other method of the property + ULONG cMax, // [IN] size of rmdOtherMethod + ULONG * + pcOtherMethod); // [OUT] total number of other method of this property + + HRESULT STDMETHODCALLTYPE GetParamProps( // S_OK or error. + mdParamDef tk, // [IN]The Parameter. + mdMethodDef *pmd, // [OUT] Parent Method token. + ULONG *pulSequence, // [OUT] Parameter sequence. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] Put name here. + ULONG cchName, // [OUT] Size of name buffer. + ULONG *pchName, // [OUT] Put actual size of name here. + DWORD *pdwAttr, // [OUT] Put flags here. + DWORD *pdwCPlusTypeFlag, // [OUT] Flag for value type. selected + // ELEMENT_TYPE_*. + UVCP_CONSTANT *ppValue, // [OUT] Constant value. + ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for + // non-strings. + + HRESULT STDMETHODCALLTYPE GetCustomAttributeByName( // S_OK or error. + mdToken tkObj, // [IN] Object with Custom Attribute. + LPCWSTR szName, // [IN] Name of desired Custom Attribute. + const void **ppData, // [OUT] Put pointer to data here. + ULONG *pcbData); // [OUT] Put size of data here. + + BOOL STDMETHODCALLTYPE IsValidToken( // True or False. + mdToken tk); // [IN] Given token. + + HRESULT STDMETHODCALLTYPE GetNestedClassProps( // S_OK or error. + mdTypeDef tdNestedClass, // [IN] NestedClass token. + mdTypeDef *ptdEnclosingClass); // [OUT] EnclosingClass token. + + HRESULT STDMETHODCALLTYPE GetNativeCallConvFromSig( // S_OK or error. + void const *pvSig, // [IN] Pointer to signature. + ULONG cbSig, // [IN] Count of signature bytes. + ULONG *pCallConv); // [OUT] Put calling conv here (see CorPinvokemap). + + HRESULT STDMETHODCALLTYPE IsGlobal( // S_OK or error. + mdToken pd, // [IN] Type, Field, or Method token. + int *pbGlobal); // [OUT] Put 1 if global, 0 otherwise. +}; + +#endif diff --git a/src/mono/dbi/cordb-thread.cpp b/src/mono/dbi/cordb-thread.cpp new file mode 100644 index 00000000000000..d699afc60c4a93 --- /dev/null +++ b/src/mono/dbi/cordb-thread.cpp @@ -0,0 +1,266 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-THREAD.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbThread::CordbThread(Connection *conn, CordbProcess *ppProcess, + long thread_id) + : CordbBaseMono(conn) { + this->ppProcess = ppProcess; + this->thread_id = thread_id; + stepper = NULL; + registerset = NULL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::HasUnhandledException(void) { + DEBUG_PRINTF(1, "CordbThread - HasUnhandledException - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetBlockingObjects( + /* [out] */ ICorDebugBlockingObjectEnum **ppBlockingObjectEnum) { + DEBUG_PRINTF(1, "CordbThread - GetBlockingObjects - IMPLEMENTED\n"); + CordbBlockingObjectEnum *blockingObject = new CordbBlockingObjectEnum(conn); + *ppBlockingObjectEnum = + static_cast(blockingObject); + + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentCustomDebuggerNotification( + /* [out] */ ICorDebugValue **ppNotificationObject) { + DEBUG_PRINTF( + 1, + "CordbThread - GetCurrentCustomDebuggerNotification - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::CreateStackWalk( + /* [out] */ ICorDebugStackWalk **ppStackWalk) { + DEBUG_PRINTF(1, "CordbThread - CreateStackWalk - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetActiveInternalFrames( + /* [in] */ ULONG32 cInternalFrames, + /* [out] */ ULONG32 *pcInternalFrames, + /* [length_is][size_is][out][in] */ + ICorDebugInternalFrame2 *ppInternalFrames[]) { + DEBUG_PRINTF(1, "CordbThread - GetActiveInternalFrames - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFunctions( + /* [in] */ ULONG32 cFunctions, + /* [out] */ ULONG32 *pcFunctions, + /* [length_is][size_is][out][in] */ COR_ACTIVE_FUNCTION pFunctions[]) { + DEBUG_PRINTF(1, "CordbThread - GetActiveFunctions - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetConnectionID( + /* [out] */ CONNID *pdwConnectionId) { + DEBUG_PRINTF(1, "CordbThread - GetConnectionID - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetTaskID( + /* [out] */ TASKID *pTaskId) { + DEBUG_PRINTF(1, "CordbThread - GetTaskID - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetVolatileOSThreadID( + /* [out] */ DWORD *pdwTid) { + DEBUG_PRINTF(1, "CordbThread - GetVolatileOSThreadID - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::InterceptCurrentException( + + /* [in] */ ICorDebugFrame *pFrame) { + DEBUG_PRINTF(1, + "CordbThread - InterceptCurrentException - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetProcess( + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "CordbThread - GetProcess - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetID( + /* [out] */ DWORD *pdwThreadId) { + *pdwThreadId = thread_id; + DEBUG_PRINTF(1, "CordbThread - GetID - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetHandle( + /* [out] */ HTHREAD *phThreadHandle) { + DEBUG_PRINTF(1, "CordbThread - GetHandle - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetAppDomain( + /* [out] */ ICorDebugAppDomain **ppAppDomain) { + *ppAppDomain = + static_cast(this->conn->pCorDebugAppDomain); + DEBUG_PRINTF(1, "CordbThread - GetAppDomain - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::SetDebugState( + /* [in] */ CorDebugThreadState state) { + DEBUG_PRINTF(1, "CordbThread - SetDebugState - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetDebugState( + /* [out] */ CorDebugThreadState *pState) { + DEBUG_PRINTF(1, "CordbThread - GetDebugState - NOT IMPLEMENTED - %p\n", this); + *pState = THREAD_RUN; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetUserState( + /* [out] */ CorDebugUserState *pState) { + DEBUG_PRINTF(1, "CordbThread - GetUserState - NOT IMPLEMENTED - %p\n", this); + + *pState = (CorDebugUserState)0; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentException( + /* [out] */ ICorDebugValue **ppExceptionObject) { + DEBUG_PRINTF(1, "CordbThread - GetCurrentException - IMPLEMENTED\n"); + + return S_FALSE; +} + +HRESULT STDMETHODCALLTYPE CordbThread::ClearCurrentException(void) { + DEBUG_PRINTF(1, "CordbThread - ClearCurrentException - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::CreateStepper( + /* [out] */ ICorDebugStepper **ppStepper) { + CordbStepper *stepper = new CordbStepper(conn, this); + this->stepper = stepper; + *ppStepper = static_cast(stepper); + + DEBUG_PRINTF(1, "CordbThread - CreateStepper - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::EnumerateChains( + /* [out] */ ICorDebugChainEnum **ppChains) { + CordbChainEnum *pChains = new CordbChainEnum(conn, this); + *ppChains = static_cast(pChains); + DEBUG_PRINTF(1, "CordbThread - EnumerateChains - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetActiveChain( + /* [out] */ ICorDebugChain **ppChain) { + DEBUG_PRINTF(1, "CordbThread - GetActiveChain - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFrame( + /* [out] */ ICorDebugFrame **ppFrame) { + DEBUG_PRINTF(1, "CordbThread - GetActiveFrame - IMPLEMENTED\n"); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, thread_id); + m_dbgprot_buffer_add_int(&localbuf, 0); + m_dbgprot_buffer_add_int(&localbuf, -1); + + int cmdId = this->conn->send_event(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, + &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + int nframes = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + if (nframes > 0) { + int frameid = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int methodId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int il_offset = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int flags = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + CordbNativeFrame *frame = + new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, this); + *ppFrame = static_cast(frame); + } + registerset = new CordbRegisteSet(conn, 0, 0); + + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetRegisterSet( + /* [out] */ ICorDebugRegisterSet **ppRegisters) { + DEBUG_PRINTF(1, "CordbThread - GetRegisterSet - IMPLEMENTED\n"); + + if (!registerset) + registerset = new CordbRegisteSet(conn, 0, 0); + + *ppRegisters = static_cast(registerset); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::CreateEval( + /* [out] */ ICorDebugEval **ppEval) { + DEBUG_PRINTF(1, "CordbThread - CreateEval - IMPLEMENTED\n"); + CordbEval *eval = new CordbEval(this->conn, this); + eval->QueryInterface(IID_ICorDebugEval, (void **)ppEval); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbThread::GetObject( + /* [out] */ ICorDebugValue **ppObject) { + DEBUG_PRINTF(1, "CordbThread - GetObject - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbThread::QueryInterface( + /* [in] */ REFIID id, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { + if (id == IID_ICorDebugThread) { + *ppInterface = static_cast(this); + } else if (id == IID_ICorDebugThread2) { + *ppInterface = static_cast(this); + } else if (id == IID_ICorDebugThread3) { + *ppInterface = static_cast(this); + } else if (id == IID_ICorDebugThread4) { + *ppInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *ppInterface = + static_cast(static_cast(this)); + } else { + *ppInterface = NULL; + return E_NOINTERFACE; + } + DEBUG_PRINTF(1, "CordbThread - QueryInterface - IMPLEMENTED\n"); + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbThread::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbThread::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-thread.h b/src/mono/dbi/cordb-thread.h new file mode 100644 index 00000000000000..0273549691edfe --- /dev/null +++ b/src/mono/dbi/cordb-thread.h @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-THREAD.H +// + +#ifndef __MONO_DEBUGGER_CORDB_THREAD_H__ +#define __MONO_DEBUGGER_CORDB_THREAD_H__ + +#include + +class CordbThread : public CordbBaseMono, + public ICorDebugThread, + public ICorDebugThread2, + public ICorDebugThread3, + public ICorDebugThread4 { +public: + long thread_id; + CordbProcess *ppProcess; + CordbStepper *stepper; + CordbRegisteSet *registerset; + CordbThread(Connection *conn, CordbProcess *ppProcess, long thread_id); + HRESULT STDMETHODCALLTYPE HasUnhandledException(void); + HRESULT STDMETHODCALLTYPE GetBlockingObjects( + /* [out] */ ICorDebugBlockingObjectEnum **ppBlockingObjectEnum); + HRESULT STDMETHODCALLTYPE GetCurrentCustomDebuggerNotification( + /* [out] */ ICorDebugValue **ppNotificationObject); + HRESULT STDMETHODCALLTYPE + CreateStackWalk(/* [out] */ ICorDebugStackWalk **ppStackWalk); + HRESULT STDMETHODCALLTYPE + GetActiveInternalFrames(/* [in] */ ULONG32 cInternalFrames, /* [out] */ + ULONG32 *pcInternalFrames, + /* [length_is][size_is][out][in] */ + ICorDebugInternalFrame2 *ppInternalFrames[]); + HRESULT STDMETHODCALLTYPE GetActiveFunctions( + /* [in] */ ULONG32 cFunctions, /* [out] */ ULONG32 *pcFunctions, + /* [length_is][size_is][out][in] */ + COR_ACTIVE_FUNCTION pFunctions[]); + HRESULT STDMETHODCALLTYPE + GetConnectionID(/* [out] */ CONNID *pdwConnectionId); + HRESULT STDMETHODCALLTYPE GetTaskID(/* [out] */ TASKID *pTaskId); + HRESULT STDMETHODCALLTYPE GetVolatileOSThreadID(/* [out] */ DWORD *pdwTid); + HRESULT STDMETHODCALLTYPE + InterceptCurrentException(/* [in] */ ICorDebugFrame *pFrame); + HRESULT STDMETHODCALLTYPE + GetProcess(/* [out] */ ICorDebugProcess **ppProcess); + HRESULT STDMETHODCALLTYPE GetID(/* [out] */ DWORD *pdwThreadId); + HRESULT STDMETHODCALLTYPE GetHandle(/* [out] */ HTHREAD *phThreadHandle); + HRESULT STDMETHODCALLTYPE + GetAppDomain(/* [out] */ ICorDebugAppDomain **ppAppDomain); + HRESULT STDMETHODCALLTYPE SetDebugState(/* [in] */ CorDebugThreadState state); + HRESULT STDMETHODCALLTYPE + GetDebugState(/* [out] */ CorDebugThreadState *pState); + HRESULT STDMETHODCALLTYPE GetUserState(/* [out] */ CorDebugUserState *pState); + HRESULT STDMETHODCALLTYPE + GetCurrentException(/* [out] */ ICorDebugValue **ppExceptionObject); + HRESULT STDMETHODCALLTYPE ClearCurrentException(void); + HRESULT STDMETHODCALLTYPE + CreateStepper(/* [out] */ ICorDebugStepper **ppStepper); + HRESULT STDMETHODCALLTYPE + EnumerateChains(/* [out] */ ICorDebugChainEnum **ppChains); + HRESULT STDMETHODCALLTYPE + GetActiveChain(/* [out] */ ICorDebugChain **ppChain); + HRESULT STDMETHODCALLTYPE + GetActiveFrame(/* [out] */ ICorDebugFrame **ppFrame); + HRESULT STDMETHODCALLTYPE + GetRegisterSet(/* [out] */ ICorDebugRegisterSet **ppRegisters); + HRESULT STDMETHODCALLTYPE CreateEval(/* [out] */ ICorDebugEval **ppEval); + HRESULT STDMETHODCALLTYPE GetObject(/* [out] */ ICorDebugValue **ppObject); + HRESULT STDMETHODCALLTYPE + QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-type.cpp b/src/mono/dbi/cordb-type.cpp new file mode 100644 index 00000000000000..9e5e83c686b036 --- /dev/null +++ b/src/mono/dbi/cordb-type.cpp @@ -0,0 +1,162 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-TYPE.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbType::CordbType(CorElementType type, CordbClass *klass, + CordbType *typeParameter) + : CordbBaseMono(conn) { + this->klass = klass; + this->type = type; + this->typeParameter = typeParameter; +} + +HRESULT STDMETHODCALLTYPE CordbType::GetType(CorElementType *ty) { + *ty = type; + DEBUG_PRINTF(1, "CordbType - GetType - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbType::GetClass(ICorDebugClass **ppClass) { + DEBUG_PRINTF(1, "CordbType - GetClass - IMPLEMENTED\n"); + if (!klass) { + DEBUG_PRINTF(1, "CordbType - GetClass - SEM CLASSE\n"); + return S_OK; + } + *ppClass = static_cast(klass); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbType::EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum) { + CordbTypeEnum *tp = new CordbTypeEnum(conn, typeParameter); + *ppTyParEnum = static_cast(tp); + + DEBUG_PRINTF(1, "CordbType - EnumerateTypeParameters - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbType::GetFirstTypeParameter(ICorDebugType **value) { + DEBUG_PRINTF(1, "CordbType - GetFirstTypeParameter - IMPLEMENTED\n"); + *value = static_cast(typeParameter); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbType::GetBase(ICorDebugType **pBase) { + DEBUG_PRINTF(1, "CordbType - GetBase - IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbType::GetStaticFieldValue( + mdFieldDef fieldDef, ICorDebugFrame *pFrame, ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbType - GetStaticFieldValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbType::GetRank(ULONG32 *pnRank) { + DEBUG_PRINTF(1, "CordbType - GetRank - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbType::QueryInterface(REFIID id, + void **pInterface) { + if (id == IID_ICorDebugType) + *pInterface = static_cast(this); + else if (id == IID_ICorDebugType2) + *pInterface = static_cast(this); + else if (id == IID_IUnknown) + *pInterface = static_cast(static_cast(this)); + else { + *pInterface = NULL; + return E_NOINTERFACE; + } + + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbType::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbType::Release(void) { return 0; } + +HRESULT STDMETHODCALLTYPE CordbType::GetTypeID(COR_TYPEID *id) { + DEBUG_PRINTF(1, "CordbType - GetTypeID - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +CordbTypeEnum::CordbTypeEnum(Connection *conn, CordbType *type) + : CordbBaseMono(conn) { + this->type = type; +} + +HRESULT STDMETHODCALLTYPE CordbTypeEnum::Next(ULONG celt, + ICorDebugType *values[], + ULONG *pceltFetched) { + *pceltFetched = celt; + if (type != NULL) + values[0] = type; + DEBUG_PRINTF(1, "CordbTypeEnum - Next - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbTypeEnum::Skip(ULONG celt) { + DEBUG_PRINTF(1, "CordbTypeEnum - Skip - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbTypeEnum::Reset(void) { + DEBUG_PRINTF(1, "CordbTypeEnum - Reset - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbTypeEnum::Clone(ICorDebugEnum **ppEnum) { + DEBUG_PRINTF(1, "CordbTypeEnum - Clone - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbTypeEnum::GetCount(ULONG *pcelt) { + if (type != NULL) + *pcelt = 1; + else + *pcelt = 0; + DEBUG_PRINTF(1, "CordbTypeEnum - GetCount - IMPLEMENTED - %d\n", *pcelt); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbTypeEnum::QueryInterface(REFIID id, + void **pInterface) { + if (id == IID_ICorDebugEnum) + *pInterface = static_cast(this); + else if (id == IID_ICorDebugTypeEnum) + *pInterface = static_cast(this); + else if (id == IID_IUnknown) + *pInterface = + static_cast(static_cast(this)); + else { + DEBUG_PRINTF(1, "CordbTypeEnum - QueryInterface - E_NOTIMPL\n"); + *pInterface = NULL; + return E_NOINTERFACE; + } + + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbTypeEnum::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbTypeEnum::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-type.h b/src/mono/dbi/cordb-type.h new file mode 100644 index 00000000000000..660a7ac388698b --- /dev/null +++ b/src/mono/dbi/cordb-type.h @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-TYPE.H +// + +#ifndef __MONO_DEBUGGER_CORDB_TYPE_H__ +#define __MONO_DEBUGGER_CORDB_TYPE_H__ + +#include + +class CordbType : public CordbBaseMono, + public ICorDebugType, + public ICorDebugType2 { + CorElementType type; + CordbClass *klass; + CordbType *typeParameter; + +public: + CordbType(CorElementType type, CordbClass *klass = NULL, + CordbType *typeParameter = NULL); + HRESULT STDMETHODCALLTYPE GetType(CorElementType *ty); + HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass **ppClass); + HRESULT STDMETHODCALLTYPE + EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum); + HRESULT STDMETHODCALLTYPE GetFirstTypeParameter(ICorDebugType **value); + HRESULT STDMETHODCALLTYPE GetBase(ICorDebugType **pBase); + HRESULT STDMETHODCALLTYPE GetStaticFieldValue(mdFieldDef fieldDef, + ICorDebugFrame *pFrame, + ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetRank(ULONG32 *pnRank); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE GetTypeID(COR_TYPEID *id); +}; + +class CordbTypeEnum : public CordbBaseMono, public ICorDebugTypeEnum { + CordbType *type; + +public: + CordbTypeEnum(Connection *conn, CordbType *type); + virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugType *values[], + ULONG *pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum **ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG *pcelt); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); +}; + +#endif diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp new file mode 100644 index 00000000000000..28974d3a26bc11 --- /dev/null +++ b/src/mono/dbi/cordb-value.cpp @@ -0,0 +1,1079 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-VALUE.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +CordbValue::CordbValue(Connection *conn, CorElementType type, + CordbContent value, int size) + : CordbBaseMono(conn) { + this->type = type; + this->value = value; + this->size = size; + this->conn = conn; +} + +HRESULT STDMETHODCALLTYPE CordbValue::GetType(CorElementType *pType) { + *pType = type; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbValue::GetSize(ULONG32 *pSize) { + *pSize = size; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbValue::GetAddress(CORDB_ADDRESS *pAddress) { + *pAddress = (CORDB_ADDRESS)&value; + DEBUG_PRINTF(1, "CordbValue - GetAddress - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, "CordbValue - CreateBreakpoint - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbValue::QueryInterface(REFIID id, + void **pInterface) { + if (id == IID_ICorDebugValue) { + *pInterface = static_cast( + static_cast(this)); + } else if (id == IID_ICorDebugValue2) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugValue3) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugGenericValue) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = + static_cast(static_cast(this)); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbValue::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbValue::Release(void) { return 0; } + +HRESULT STDMETHODCALLTYPE CordbValue::GetExactType(ICorDebugType **ppType) { + DEBUG_PRINTF(1, "CordbValue - GetExactType - IMPLEMENTED\n"); + CordbType *tp = new CordbType(type); + *ppType = static_cast(tp); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbValue::GetSize64(ULONG64 *pSize) { + DEBUG_PRINTF(1, "CordbValue - GetSize64 - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbValue::GetValue(void *pTo) { + DEBUG_PRINTF(1, "CordbValue - GetValue - IMPLEMENTED\n"); + memcpy(pTo, &value, size); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbValue::SetValue(void *pFrom) { + memcpy(&value, pFrom, size); + DEBUG_PRINTF(1, "CordbValue - SetValue - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetType(CorElementType *pType) { + DEBUG_PRINTF(1, "CordbReferenceValue - GetType - IMPLEMENTED\n"); + *pType = type; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize(ULONG32 *pSize) { + DEBUG_PRINTF(1, "CordbReferenceValue - GetSize - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::GetAddress(CORDB_ADDRESS *pAddress) { + *pAddress = (CORDB_ADDRESS)&object_id; + DEBUG_PRINTF(1, "CordbReferenceValue - GetAddress - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, "CordbReferenceValue - CreateBreakpoint - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::QueryInterface(REFIID id, void **pInterface) { + if (id == IID_ICorDebugValue) { + *pInterface = static_cast( + static_cast(this)); + } else if (id == IID_ICorDebugValue2) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugValue3) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugReferenceValue) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = + static_cast(static_cast(this)); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbReferenceValue::AddRef(void) { return 1; } + +ULONG STDMETHODCALLTYPE CordbReferenceValue::Release(void) { return 1; } + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::GetExactType(ICorDebugType **ppType) { + DEBUG_PRINTF(1, "CordbReferenceValue - GetExactType - IMPLEMENTED - %d\n", + type); + if (cordbtype) { + DEBUG_PRINTF(1, + "CordbReferenceValue - GetExactType - IMPLEMENTED - %d - " + "tinha cordbtype\n", + type); + *ppType = static_cast(cordbtype); + return S_OK; + } + if (klass != NULL) { + DEBUG_PRINTF( + 1, + "CordbReferenceValue - GetExactType - IMPLEMENTED - %d - tinha klass\n", + type); + cordbtype = new CordbType(type, klass); + *ppType = static_cast(cordbtype); + return S_OK; + } + if (type == ELEMENT_TYPE_CLASS && object_id != -1) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, object_id); + + int cmdId = conn->send_event(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_TYPE, + &localbuf); + m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + int type_id = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, type_id); + + cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + bAnswer = conn->get_answer(cmdId); + char *namespace_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + char *class_name_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + char *class_fullname_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int assembly_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int module_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + type_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id2 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, + "CordbReferenceValue - GetExactType - IMPLEMENTED - 1.0 - %d " + "- %d - %d - %d\n", + type_id, token, assembly_id, module_id); + klass = new CordbClass(conn, token, assembly_id); + cordbtype = new CordbType(type, klass); + *ppType = static_cast(cordbtype); + return S_OK; + } + if (type == ELEMENT_TYPE_SZARRAY && object_id != -1) { + CordbClass *klass = NULL; + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, object_id); + + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); + m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + int type_id = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "ELEMENT_TYPE_SZARRAY - %d\n", type_id); + int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + if (type_id == ELEMENT_TYPE_CLASS) { + int klass_id = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, klass_id); + + cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + bAnswer = conn->get_answer(cmdId); + char *namespace_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + char *class_name_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + char *class_fullname_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int assembly_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int module_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id3 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id2 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF( + 1, + "CordbReferenceValue - GetExactType - IMPLEMENTED - 1.1 - %d - %d\n", + klass_id, token); + klass = new CordbClass(conn, token, module_id); + } + + cordbtype = new CordbType(type, NULL, + new CordbType((CorElementType)type_id, klass)); + *ppType = static_cast(cordbtype); + DEBUG_PRINTF(1, "CordbReferenceValue - GetExactType - IMPLEMENTED\n"); + + return S_OK; + } + CordbType *tp = new CordbType(type); + *ppType = static_cast(tp); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize64(ULONG64 *pSize) { + DEBUG_PRINTF(1, "CordbReferenceValue - GetSize64 - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetValue(void *pTo) { + DEBUG_PRINTF(1, "CordbReferenceValue - GetValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(void *pFrom) { + DEBUG_PRINTF(1, "CordbReferenceValue - SetValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::IsNull(/* [out] */ BOOL *pbNull) { + if (object_id == -1) + *pbNull = true; + DEBUG_PRINTF(1, "CordbReferenceValue - IsNull - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::GetValue(/* [out] */ CORDB_ADDRESS *pValue) { + if (object_id == -1) + *pValue = NULL; + else + *pValue = (CORDB_ADDRESS)&object_id; + DEBUG_PRINTF(1, "CordbReferenceValue - GetValue - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::SetValue(/* [in] */ CORDB_ADDRESS value) { + DEBUG_PRINTF( + 1, "CordbReferenceValue - SetValue CORDB_ADDRESS - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::Dereference(/* [out] */ ICorDebugValue **ppValue) { + if (object_id == -1) + return CORDBG_E_BAD_REFERENCE_VALUE; + if (type == ELEMENT_TYPE_SZARRAY || type == ELEMENT_TYPE_ARRAY) { + CordbArrayValue *objectValue = + new CordbArrayValue(conn, cordbtype, object_id, klass); + objectValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); + } else { + CordbObjectValue *objectValue = + new CordbObjectValue(conn, type, object_id, klass); + objectValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); + } + DEBUG_PRINTF(1, "CordbReferenceValue - Dereference - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbReferenceValue::DereferenceStrong(/* [out] */ ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, + "CordbReferenceValue - DereferenceStrong - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +CordbReferenceValue::CordbReferenceValue(Connection *conn, CorElementType type, + int object_id, CordbClass *klass, + CordbType *cordbtype) + : CordbBaseMono(conn) { + this->type = type; + this->object_id = object_id; + this->conn = conn; + this->klass = klass; + this->cordbtype = cordbtype; +} + +CordbObjectValue::CordbObjectValue(Connection *conn, CorElementType type, + int object_id, CordbClass *klass) + : CordbBaseMono(conn) { + this->type = type; + this->object_id = object_id; + this->klass = klass; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetType(CorElementType *pType) { + DEBUG_PRINTF(1, "CordbObjectValue - GetType - IMPLEMENTED\n"); + *pType = type; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize(ULONG32 *pSize) { + DEBUG_PRINTF(1, "CordbObjectValue - GetSize - NOT IMPLEMENTED\n"); + *pSize = 10; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::GetAddress(CORDB_ADDRESS *pAddress) { + *pAddress = (CORDB_ADDRESS)&object_id; + DEBUG_PRINTF(1, "CordbObjectValue - GetAddress - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, "CordbObjectValue - CreateBreakpoint - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +ULONG STDMETHODCALLTYPE CordbObjectValue::AddRef(void) { return 1; } + +ULONG STDMETHODCALLTYPE CordbObjectValue::Release(void) { return 1; } + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::GetExactType(ICorDebugType **ppType) { + DEBUG_PRINTF(1, "CordbObjectValue - GetExactType - IMPLEMENTED\n"); + CordbType *tp = new CordbType(type, klass); + *ppType = static_cast(tp); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize64(ULONG64 *pSize) { + DEBUG_PRINTF(1, "CordbObjectValue - GetSize64 - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetValue(void *pTo) { + DEBUG_PRINTF(1, "CordbObjectValue - GetValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::SetValue(void *pFrom) { + DEBUG_PRINTF(1, "CordbObjectValue - SetValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethodAndType( + mdMemberRef memberRef, ICorDebugFunction **ppFunction, + ICorDebugType **ppType) { + DEBUG_PRINTF( + 1, "CordbObjectValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32 *pcchString) { + if (object_id == -1) + return S_OK; + if (type == ELEMENT_TYPE_STRING) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, object_id); + + int cmdId = conn->send_event(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_LENGTH, + &localbuf); + m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + *pcchString = m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); + return S_OK; + } + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, + ULONG32 *pcchString, + WCHAR szString[]) { + if (object_id == -1) + return S_OK; + if (type == ELEMENT_TYPE_STRING) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, object_id); + + int cmdId = conn->send_event(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_VALUE, + &localbuf); + m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + *pcchString = cchString; + int use_utf16 = + m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + if (use_utf16) { + DEBUG_PRINTF( + 1, "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n"); + } else { + char *value = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "CordbObjectValue - GetString - %s\n", value); + if (cchString >= strlen(value)) { + mbstowcs(szString, value, strlen(value) + 1); + *pcchString = strlen(value); + } + } + return S_OK; + } + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateHandle( + CorDebugHandleType type, ICorDebugHandleValue **ppHandle) { + DEBUG_PRINTF(1, "CordbObjectValue - CreateHandle - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetThreadOwningMonitorLock( + ICorDebugThread **ppThread, DWORD *pAcquisitionCount) { + DEBUG_PRINTF( + 1, "CordbObjectValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum) { + DEBUG_PRINTF( + 1, "CordbObjectValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::EnumerateExceptionCallStack( + ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum) { + DEBUG_PRINTF( + 1, "CordbObjectValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetCachedInterfaceTypes( + BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum) { + DEBUG_PRINTF( + 1, "CordbObjectValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetCachedInterfacePointers( + BOOL bIInspectableOnly, ULONG32 celt, ULONG32 *pcEltFetched, + CORDB_ADDRESS *ptrs) { + DEBUG_PRINTF( + 1, "CordbObjectValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::GetTarget(ICorDebugReferenceValue **ppObject) { + DEBUG_PRINTF(1, "CordbObjectValue - GetTarget - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::GetFunction(ICorDebugFunction **ppFunction) { + DEBUG_PRINTF(1, "CordbObjectValue - GetFunction - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::GetClass(/* [out] */ ICorDebugClass **ppClass) { + DEBUG_PRINTF(1, "CordbObjectValue - GetClass - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue( + ICorDebugClass *pClass, mdFieldDef fieldDef, ICorDebugValue **ppValue) { + + DEBUG_PRINTF(1, "CordbObjectValue - GetFieldValue - IMPLEMENTED - %d - %d\n", + fieldDef, object_id); + if (object_id == -1) + return S_FALSE; + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_int(&localbuf, fieldDef); + + int cmdId = conn->send_event(MDBGPROT_CMD_SET_OBJECT_REF, + MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket *received_reply_packet = + conn->get_answer_with_error(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *bAnswer = received_reply_packet->buf; + + return CreateCordbValue(conn, bAnswer, ppValue); +} + +HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAnswer, + ICorDebugValue **ppValue) { + CorElementType type = (CorElementType)m_dbgprot_decode_byte( + bAnswer->buf, &bAnswer->buf, bAnswer->end); + + DEBUG_PRINTF(1, "CreateCordbValue type - %x\n", type); + CordbContent value; + switch (type) { + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_I1: + case MONO_TYPE_U1: + value.booleanValue = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "bool value - %d\n", value.booleanValue); + break; + case MONO_TYPE_CHAR: + case MONO_TYPE_I2: + case MONO_TYPE_U2: + value.charValue = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "char value - %c\n", value.charValue); + break; + case MONO_TYPE_I4: + case MONO_TYPE_U4: + case MONO_TYPE_R4: + value.intValue = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "int value - %d\n", value.intValue); + break; + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_R8: + value.longValue = + m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); + break; + case MONO_TYPE_CLASS: + case MONO_TYPE_SZARRAY: + case MONO_TYPE_STRING: { + int object_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + CordbReferenceValue *refValue = + new CordbReferenceValue(conn, type, object_id); + refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); + return S_OK; + } + case MDBGPROT_VALUE_TYPE_ID_NULL: { + CorElementType type = (CorElementType)m_dbgprot_decode_byte( + bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "NULL value - type - %d\n", type); + if (type == MONO_TYPE_CLASS || type == MONO_TYPE_STRING) { + int klass_id = (CorElementType)m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, + bAnswer->end); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, klass_id); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + bAnswer = conn->get_answer(cmdId); + char *namespace_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + char *class_name_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + char *class_fullname_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int assembly_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int module_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id2 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + CordbClass *klass = new CordbClass(conn, token, module_id); + CordbReferenceValue *refValue = + new CordbReferenceValue(conn, type, -1, klass); + refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); + } + if (type == MONO_TYPE_SZARRAY) { + DEBUG_PRINTF(1, "NULL value - MONO_TYPE_SZARRAY\n"); + CordbClass *klass = NULL; + int type_id = + m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + if (type_id == ELEMENT_TYPE_CLASS) { + DEBUG_PRINTF(1, + "NULL value - MONO_TYPE_SZARRAY - ELEMENT_TYPE_CLASS\n"); + int klass_id = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, klass_id); + + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + bAnswer = conn->get_answer(cmdId); + char *namespace_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + char *class_name_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + char *class_fullname_str = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int assembly_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int module_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id3 = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id2 = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "CreateCordbValue - IMPLEMENTED - 1.1 - %d - %d\n", + klass_id, token); + klass = new CordbClass(conn, token, module_id); + } + CordbType *cordbtype = new CordbType( + type, NULL, new CordbType((CorElementType)type_id, klass)); + CordbReferenceValue *refValue = + new CordbReferenceValue(conn, type, -1, klass, cordbtype); + refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); + } + return S_OK; + } + default: + DEBUG_PRINTF(1, "default value - %d\n", type); + return S_FALSE; + } + + *ppValue = new CordbValue(conn, type, value, + convert_mono_type_2_icordbg_size(type)); // + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethod( + mdMemberRef memberRef, ICorDebugFunction **ppFunction) { + DEBUG_PRINTF(1, "CordbObjectValue - GetVirtualMethod - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::GetContext(ICorDebugContext **ppContext) { + DEBUG_PRINTF(1, "CordbObjectValue - GetContext - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::IsValueClass(BOOL *pbIsValueClass) { + DEBUG_PRINTF(1, "CordbObjectValue - IsValueClass - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::GetManagedCopy(IUnknown **ppObject) { + DEBUG_PRINTF(1, "CordbObjectValue - GetManagedCopy - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbObjectValue::SetFromManagedCopy(IUnknown *pObject) { + DEBUG_PRINTF(1, "CordbObjectValue - SetFromManagedCopy - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::IsValid(BOOL *pbValid) { + DEBUG_PRINTF(1, "CordbObjectValue - IsValid - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateRelocBreakpoint( + ICorDebugValueBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, + "CordbObjectValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::QueryInterface(REFIID id, + void **pInterface) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - IMPLEMENTED - %d\n", + type); + if (id == IID_ICorDebugValue) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - IID_ICorDebugValue - " + "IMPLEMENTED\n"); + *pInterface = static_cast( + static_cast(this)); + } else if (id == IID_ICorDebugValue2) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - IID_ICorDebugValue2 - " + "IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugValue3) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - IID_ICorDebugValue3 - " + "IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugObjectValue) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " + "IID_ICorDebugObjectValue - IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugObjectValue2) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " + "IID_ICorDebugObjectValue2 - IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugGenericValue) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " + "IID_ICorDebugGenericValue - IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugHeapValue) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " + "IID_ICorDebugHeapValue - IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugHeapValue2) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " + "IID_ICorDebugHeapValue2 - IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugHeapValue3) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " + "IID_ICorDebugHeapValue3 - IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else if ((id == IID_ICorDebugStringValue) && + (type == ELEMENT_TYPE_STRING)) { + DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " + "IID_ICorDebugStringValue - IMPLEMENTED\n"); + *pInterface = static_cast(this); + } else /*if (id == IID_ICorDebugExceptionObjectValue && m_fIsExceptionObject) + { + *pInterface = + static_cast(static_cast(this)); + } + else if (id == IID_ICorDebugComObjectValue && m_fIsRcw) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugDelegateObjectValue && m_fIsDelegate) + { + *pInterface = static_cast(this); + } + else*/ + if (id == IID_IUnknown) { + DEBUG_PRINTF( + 1, "CordbObjectValue - QueryInterface - IID_IUnknown - IMPLEMENTED\n"); + *pInterface = + static_cast(static_cast(this)); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + return S_OK; +} + +CordbArrayValue::CordbArrayValue(Connection *conn, CordbType *type, + int object_id, CordbClass *klass) + : CordbBaseMono(conn) { + this->type = type; + this->object_id = object_id; + this->klass = klass; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetClass(ICorDebugClass **ppClass) { + DEBUG_PRINTF(1, "CordbArrayValue - GetClass - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetFieldValue( + ICorDebugClass *pClass, mdFieldDef fieldDef, ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbArrayValue - GetFieldValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethod( + mdMemberRef memberRef, ICorDebugFunction **ppFunction) { + DEBUG_PRINTF(1, "CordbArrayValue - GetVirtualMethod - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::GetContext(ICorDebugContext **ppContext) { + DEBUG_PRINTF(1, "CordbArrayValue - GetContext - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::IsValueClass(BOOL *pbIsValueClass) { + DEBUG_PRINTF(1, "CordbArrayValue - IsValueClass - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetManagedCopy(IUnknown **ppObject) { + DEBUG_PRINTF(1, "CordbArrayValue - GetManagedCopy - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::SetFromManagedCopy(IUnknown *pObject) { + DEBUG_PRINTF(1, "CordbArrayValue - SetFromManagedCopy - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetType(CorElementType *pType) { + DEBUG_PRINTF(1, "CordbArrayValue - GetType - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize(ULONG32 *pSize) { + DEBUG_PRINTF(1, "CordbArrayValue - GetSize - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetAddress(CORDB_ADDRESS *pAddress) { + *pAddress = (CORDB_ADDRESS)&object_id; + DEBUG_PRINTF(1, "CordbArrayValue - GetAddress - IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, "CordbArrayValue - CreateBreakpoint - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::QueryInterface(REFIID id, + void **pInterface) { + if (id == IID_ICorDebugValue) { + *pInterface = + static_cast(static_cast(this)); + } else if (id == IID_ICorDebugValue2) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugValue3) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugArrayValue) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugGenericValue) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugHeapValue2) { + *pInterface = static_cast(this); + } else if (id == IID_ICorDebugHeapValue3) { + *pInterface = static_cast(this); + } else if (id == IID_IUnknown) { + *pInterface = + static_cast(static_cast(this)); + } else { + *pInterface = NULL; + return E_NOINTERFACE; + } + + return S_OK; +} + +ULONG STDMETHODCALLTYPE CordbArrayValue::AddRef(void) { return 0; } + +ULONG STDMETHODCALLTYPE CordbArrayValue::Release(void) { return 0; } + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethodAndType( + mdMemberRef memberRef, ICorDebugFunction **ppFunction, + ICorDebugType **ppType) { + DEBUG_PRINTF(1, + "CordbArrayValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetValue(void *pTo) { + DEBUG_PRINTF(1, "CordbArrayValue - GetValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::SetValue(void *pFrom) { + DEBUG_PRINTF(1, "CordbArrayValue - SetValue - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetLength(ULONG32 *pcchString) { + DEBUG_PRINTF(1, "CordbArrayValue - GetLength - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetString(ULONG32 cchString, + ULONG32 *pcchString, + WCHAR szString[]) { + DEBUG_PRINTF(1, "CordbArrayValue - GetString - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::IsValid(BOOL *pbValid) { + DEBUG_PRINTF(1, "CordbArrayValue - IsValid - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateRelocBreakpoint( + ICorDebugValueBreakpoint **ppBreakpoint) { + DEBUG_PRINTF(1, + "CordbArrayValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::GetExactType(ICorDebugType **ppType) { + *ppType = static_cast(type); + DEBUG_PRINTF(1, "CordbArrayValue - GetExactType - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize64(ULONG64 *pSize) { + DEBUG_PRINTF(1, "CordbArrayValue - GetSize64 - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateHandle( + CorDebugHandleType type, ICorDebugHandleValue **ppHandle) { + DEBUG_PRINTF(1, "CordbArrayValue - CreateHandle - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetThreadOwningMonitorLock( + ICorDebugThread **ppThread, DWORD *pAcquisitionCount) { + DEBUG_PRINTF( + 1, "CordbArrayValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum) { + DEBUG_PRINTF(1, + "CordbArrayValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::EnumerateExceptionCallStack( + ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum) { + DEBUG_PRINTF( + 1, "CordbArrayValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCachedInterfaceTypes( + BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum) { + DEBUG_PRINTF(1, + "CordbArrayValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCachedInterfacePointers( + BOOL bIInspectableOnly, ULONG32 celt, ULONG32 *pcEltFetched, + CORDB_ADDRESS *ptrs) { + DEBUG_PRINTF( + 1, "CordbArrayValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::GetTarget(ICorDebugReferenceValue **ppObject) { + DEBUG_PRINTF(1, "CordbArrayValue - GetTarget - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::GetFunction(ICorDebugFunction **ppFunction) { + DEBUG_PRINTF(1, "CordbArrayValue - GetFunction - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::GetElementType(CorElementType *pType) { + DEBUG_PRINTF(1, "CordbArrayValue - GetElementType - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetRank(ULONG32 *pnRank) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, object_id); + + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "CordbArrayValue - GetRank - IMPLEMENTED - %d\n", rank); + *pnRank = rank; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCount(ULONG32 *pnCount) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, object_id); + + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + count = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + DEBUG_PRINTF(1, "CordbArrayValue - GetCount - IMPLEMENTED - %d\n", count); + *pnCount = count; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetDimensions(ULONG32 cdim, + ULONG32 dims[]) { + DEBUG_PRINTF(1, "CordbArrayValue - GetDimensions - IMPLEMENTED\n"); + dims[0] = count; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE +CordbArrayValue::HasBaseIndicies(BOOL *pbHasBaseIndicies) { + DEBUG_PRINTF(1, "CordbArrayValue - HasBaseIndicies - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetBaseIndicies(ULONG32 cdim, + ULONG32 indicies[]) { + DEBUG_PRINTF(1, "CordbArrayValue - GetBaseIndicies - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement( + ULONG32 cdim, ULONG32 indices[], ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbArrayValue - GetElement - IMPLEMENTED - %d - %d\n", + cdim, indices[0]); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_int(&localbuf, indices[cdim - 1]); + m_dbgprot_buffer_add_int(&localbuf, 1); + + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); + m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElementAtPosition( + ULONG32 nPosition, ICorDebugValue **ppValue) { + DEBUG_PRINTF(1, "CordbArrayValue - GetElementAtPosition - NOT IMPLEMENTED\n"); + return E_NOTIMPL; +} diff --git a/src/mono/dbi/cordb-value.h b/src/mono/dbi/cordb-value.h new file mode 100644 index 00000000000000..a4dba5596ba8dc --- /dev/null +++ b/src/mono/dbi/cordb-value.h @@ -0,0 +1,232 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-VALUE.H +// + +#ifndef __MONO_DEBUGGER_CORDB_VALUE_H__ +#define __MONO_DEBUGGER_CORDB_VALUE_H__ + +#include +#include + +union CordbContent { + gint16 charValue; + gint8 booleanValue; + gint32 intValue; + gint64 longValue; + void *pointerValue; +}; + +class CordbValue : public CordbBaseMono, + public ICorDebugValue2, + public ICorDebugValue3, + public ICorDebugGenericValue { + CorElementType type; + CordbContent value; + int size; + Connection *conn; + +public: + CordbValue(Connection *conn, CorElementType type, CordbContent value, + int size); + HRESULT STDMETHODCALLTYPE GetType(CorElementType *pType); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32 *pSize); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS *pAddress); + HRESULT STDMETHODCALLTYPE + CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE GetSize64(ULONG64 *pSize); + HRESULT STDMETHODCALLTYPE GetValue(void *pTo); + HRESULT STDMETHODCALLTYPE SetValue(void *pFrom); +}; + +class CordbReferenceValue : public CordbBaseMono, + public ICorDebugReferenceValue, + public ICorDebugValue2, + public ICorDebugValue3, + public ICorDebugGenericValue { + CorElementType type; + int object_id; + Connection *conn; + CordbClass *klass; + CordbType *cordbtype; + +public: + CordbReferenceValue(Connection *conn, CorElementType type, int object_id, + CordbClass *klass = NULL, CordbType *cordbtype = NULL); + HRESULT STDMETHODCALLTYPE GetType(CorElementType *pType); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32 *pSize); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS *pAddress); + HRESULT STDMETHODCALLTYPE + CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE GetSize64(ULONG64 *pSize); + HRESULT STDMETHODCALLTYPE GetValue(void *pTo); + HRESULT STDMETHODCALLTYPE SetValue(void *pFrom); + HRESULT STDMETHODCALLTYPE IsNull(BOOL *pbNull); + HRESULT STDMETHODCALLTYPE GetValue(CORDB_ADDRESS *pValue); + HRESULT STDMETHODCALLTYPE SetValue(CORDB_ADDRESS value); + HRESULT STDMETHODCALLTYPE Dereference(ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE DereferenceStrong(ICorDebugValue **ppValue); +}; + +class CordbObjectValue : public CordbBaseMono, + public ICorDebugObjectValue, + public ICorDebugObjectValue2, + public ICorDebugGenericValue, + public ICorDebugStringValue, + public ICorDebugValue2, + public ICorDebugValue3, + public ICorDebugHeapValue2, + public ICorDebugHeapValue3, + public ICorDebugExceptionObjectValue, + public ICorDebugComObjectValue, + public ICorDebugDelegateObjectValue { + CorElementType type; + int object_id; + CordbClass *klass; + +public: + CordbObjectValue(Connection *conn, CorElementType type, int object_id, + CordbClass *klass); + HRESULT STDMETHODCALLTYPE GetClass(/* [out] */ ICorDebugClass **ppClass); + HRESULT STDMETHODCALLTYPE GetFieldValue(ICorDebugClass *pClass, + mdFieldDef fieldDef, + ICorDebugValue **ppValue); + + static HRESULT CreateCordbValue(Connection *conn, MdbgProtBuffer *bAnswer, + ICorDebugValue **ppValue); + + HRESULT STDMETHODCALLTYPE GetVirtualMethod(mdMemberRef memberRef, + ICorDebugFunction **ppFunction); + HRESULT STDMETHODCALLTYPE GetContext(ICorDebugContext **ppContext); + HRESULT STDMETHODCALLTYPE IsValueClass(BOOL *pbIsValueClass); + HRESULT STDMETHODCALLTYPE GetManagedCopy(IUnknown **ppObject); + HRESULT STDMETHODCALLTYPE SetFromManagedCopy(IUnknown *pObject); + HRESULT STDMETHODCALLTYPE IsValid(BOOL *pbValid); + HRESULT STDMETHODCALLTYPE + CreateRelocBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetType(CorElementType *pType); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32 *pSize); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS *pAddress); + HRESULT STDMETHODCALLTYPE + CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE GetSize64(ULONG64 *pSize); + HRESULT STDMETHODCALLTYPE GetValue(void *pTo); + HRESULT STDMETHODCALLTYPE SetValue(void *pFrom); + HRESULT STDMETHODCALLTYPE + GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction **ppFunction, + ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE GetLength(ULONG32 *pcchString); + HRESULT STDMETHODCALLTYPE GetString(ULONG32 cchString, ULONG32 *pcchString, + WCHAR szString[]); + HRESULT STDMETHODCALLTYPE CreateHandle(CorDebugHandleType type, + ICorDebugHandleValue **ppHandle); + HRESULT STDMETHODCALLTYPE GetThreadOwningMonitorLock( + ICorDebugThread **ppThread, DWORD *pAcquisitionCount); + HRESULT STDMETHODCALLTYPE + GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum); + HRESULT STDMETHODCALLTYPE EnumerateExceptionCallStack( + ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum); + HRESULT STDMETHODCALLTYPE GetCachedInterfaceTypes( + BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum); + HRESULT STDMETHODCALLTYPE GetCachedInterfacePointers(BOOL bIInspectableOnly, + ULONG32 celt, + ULONG32 *pcEltFetched, + CORDB_ADDRESS *ptrs); + HRESULT STDMETHODCALLTYPE GetTarget(ICorDebugReferenceValue **ppObject); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction **ppFunction); +}; + +class CordbArrayValue : public CordbBaseMono, + public ICorDebugObjectValue, + public ICorDebugObjectValue2, + public ICorDebugGenericValue, + public ICorDebugStringValue, + public ICorDebugValue2, + public ICorDebugValue3, + public ICorDebugHeapValue2, + public ICorDebugHeapValue3, + public ICorDebugExceptionObjectValue, + public ICorDebugComObjectValue, + public ICorDebugDelegateObjectValue, + public ICorDebugArrayValue { + CordbType *type; + int object_id; + CordbClass *klass; + int count; + +public: + CordbArrayValue(Connection *conn, CordbType *type, int object_id, + CordbClass *klass); + HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass **ppClass); + HRESULT STDMETHODCALLTYPE GetFieldValue(ICorDebugClass *pClass, + mdFieldDef fieldDef, + ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetVirtualMethod(mdMemberRef memberRef, + ICorDebugFunction **ppFunction); + HRESULT STDMETHODCALLTYPE GetContext(ICorDebugContext **ppContext); + HRESULT STDMETHODCALLTYPE IsValueClass(BOOL *pbIsValueClass); + HRESULT STDMETHODCALLTYPE GetManagedCopy(IUnknown **ppObject); + HRESULT STDMETHODCALLTYPE SetFromManagedCopy(IUnknown *pObject); + HRESULT STDMETHODCALLTYPE GetType(CorElementType *pType); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32 *pSize); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS *pAddress); + HRESULT STDMETHODCALLTYPE + CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void); + ULONG STDMETHODCALLTYPE Release(void); + HRESULT STDMETHODCALLTYPE + GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction **ppFunction, + ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE GetValue(void *pTo); + HRESULT STDMETHODCALLTYPE SetValue(void *pFrom); + HRESULT STDMETHODCALLTYPE GetLength(ULONG32 *pcchString); + HRESULT STDMETHODCALLTYPE GetString(ULONG32 cchString, ULONG32 *pcchString, + WCHAR szString[]); + HRESULT STDMETHODCALLTYPE IsValid(BOOL *pbValid); + HRESULT STDMETHODCALLTYPE + CreateRelocBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType **ppType); + HRESULT STDMETHODCALLTYPE GetSize64(ULONG64 *pSize); + HRESULT STDMETHODCALLTYPE CreateHandle(CorDebugHandleType type, + ICorDebugHandleValue **ppHandle); + HRESULT STDMETHODCALLTYPE GetThreadOwningMonitorLock( + ICorDebugThread **ppThread, DWORD *pAcquisitionCount); + HRESULT STDMETHODCALLTYPE + GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum); + HRESULT STDMETHODCALLTYPE EnumerateExceptionCallStack( + ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum); + HRESULT STDMETHODCALLTYPE GetCachedInterfaceTypes( + BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum); + HRESULT STDMETHODCALLTYPE GetCachedInterfacePointers(BOOL bIInspectableOnly, + ULONG32 celt, + ULONG32 *pcEltFetched, + CORDB_ADDRESS *ptrs); + HRESULT STDMETHODCALLTYPE GetTarget(ICorDebugReferenceValue **ppObject); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction **ppFunction); + + HRESULT STDMETHODCALLTYPE GetElementType(CorElementType *pType); + HRESULT STDMETHODCALLTYPE GetRank(ULONG32 *pnRank); + HRESULT STDMETHODCALLTYPE GetCount(ULONG32 *pnCount); + HRESULT STDMETHODCALLTYPE GetDimensions(ULONG32 cdim, ULONG32 dims[]); + HRESULT STDMETHODCALLTYPE HasBaseIndicies(BOOL *pbHasBaseIndicies); + HRESULT STDMETHODCALLTYPE GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]); + HRESULT STDMETHODCALLTYPE GetElement(ULONG32 cdim, ULONG32 indices[], + ICorDebugValue **ppValue); + HRESULT STDMETHODCALLTYPE GetElementAtPosition(ULONG32 nPosition, + ICorDebugValue **ppValue); +}; +#endif diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp new file mode 100644 index 00000000000000..41bdd990f23663 --- /dev/null +++ b/src/mono/dbi/cordb.cpp @@ -0,0 +1,663 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB.CPP +// + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int convert_mono_type_2_icordbg_size(int type) { + switch (type) { + case MONO_TYPE_VOID: + return 0; + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_I1: + case MONO_TYPE_U1: + return 1; + break; + case MONO_TYPE_CHAR: + case MONO_TYPE_I2: + case MONO_TYPE_U2: + return 2; + case MONO_TYPE_I4: + case MONO_TYPE_U4: + case MONO_TYPE_R4: + return 4; + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_R8: + return 8; + } + return 0; +} + +MONO_API HRESULT CoreCLRCreateCordbObjectEx(int iDebuggerVersion, DWORD pid, + LPCWSTR lpApplicationGroupId, + HMODULE hmodTargetCLR, + void **ppCordb) { + DEBUG_PRINTF(1, "CoreCLRCreateCordbObjectEx \n"); + *ppCordb = new Cordb(); + return S_OK; +} + +static void receive_thread(Connection *c) { c->receive(); } + +static void debugger_thread(void *ppProcess) { + Connection *connection = new Connection((CordbProcess *)ppProcess, + ((CordbProcess *)ppProcess)->cordb); + ((CordbProcess *)ppProcess)->SetConnection(connection); + connection->start_connection(); + connection->transport_handshake(); + connection->loop_send_receive(); + connection->close_connection(); +} + +HRESULT Cordb::Initialize(void) { + DEBUG_PRINTF(1, "Cordb - Initialize - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT Cordb::Terminate(void) { + DEBUG_PRINTF(1, "Cordb - Terminate - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT Cordb::SetManagedHandler( + /* [in] */ ICorDebugManagedCallback *pCallback) { + DEBUG_PRINTF(1, "Cordb - SetManagedHandler - IMPLEMENTED\n"); + this->pCallback = pCallback; + this->pCallback->AddRef(); + + return S_OK; +} + +HRESULT Cordb::SetUnmanagedHandler( + /* [in] */ ICorDebugUnmanagedCallback *pCallback) { + DEBUG_PRINTF(1, "Cordb - SetUnmanagedHandler - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT Cordb::CreateProcess( + /* [in] */ LPCWSTR lpApplicationName, + /* [in] */ LPWSTR lpCommandLine, + /* [in] */ LPSECURITY_ATTRIBUTES lpProcessAttributes, + /* [in] */ LPSECURITY_ATTRIBUTES lpThreadAttributes, + /* [in] */ BOOL bInheritHandles, + /* [in] */ DWORD dwCreationFlags, + /* [in] */ PVOID lpEnvironment, + /* [in] */ LPCWSTR lpCurrentDirectory, + /* [in] */ LPSTARTUPINFOW lpStartupInfo, + /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, + /* [in] */ CorDebugCreateProcessFlags debuggingFlags, + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "Cordb - CreateProcess - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT Cordb::DebugActiveProcess( + /* [in] */ DWORD id, + /* [in] */ BOOL win32Attach, + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "Cordb - DebugActiveProcess - IMPLEMENTED\n"); + *ppProcess = new CordbProcess(); + ((CordbProcess *)*ppProcess)->cordb = this; + + DWORD thread_id; + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)debugger_thread, + ((CordbProcess *)*ppProcess), 0, &thread_id); + return S_OK; +} + +HRESULT Cordb::EnumerateProcesses( + /* [out] */ ICorDebugProcessEnum **ppProcess) { + DEBUG_PRINTF(1, "Cordb - EnumerateProcesses - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT Cordb::GetProcess( + /* [in] */ DWORD dwProcessId, + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "Cordb - GetProcess - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT Cordb::CanLaunchOrAttach( + /* [in] */ DWORD dwProcessId, + /* [in] */ BOOL win32DebuggingEnabled) { + DEBUG_PRINTF(1, "Cordb - CanLaunchOrAttach - NOT IMPLEMENTED\n"); + return S_OK; +} + +Cordb::Cordb() { + pCallback = NULL; + breakpoints = g_ptr_array_new(); + threads = g_ptr_array_new(); + functions = g_ptr_array_new(); + modules = g_hash_table_new(NULL, NULL); +} + +CordbFunction *Cordb::findFunction(int id) { + int i = 0; + while (i < functions->len) { + CordbFunction *function = (CordbFunction *)g_ptr_array_index(functions, i); + if (function->id == id) { + return function; + } + i++; + } + return NULL; +} + +CordbFunction *Cordb::findFunctionByToken(int token) { + int i = 0; + while (i < functions->len) { + CordbFunction *function = (CordbFunction *)g_ptr_array_index(functions, i); + if (function->token == token) { + return function; + } + i++; + } + return NULL; +} + +HRESULT Cordb::QueryInterface( + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) { + DEBUG_PRINTF(1, "Cordb - QueryInterface - NOT IMPLEMENTED\n"); + return S_OK; +} + +ULONG Cordb::AddRef(void) { return S_OK; } + +ULONG Cordb::Release(void) { return S_OK; } + +HRESULT Cordb::CreateProcessEx( + /* [in] */ ICorDebugRemoteTarget *pRemoteTarget, + /* [in] */ LPCWSTR lpApplicationName, + /* [annotation][in] */ + _In_ LPWSTR lpCommandLine, + /* [in] */ LPSECURITY_ATTRIBUTES lpProcessAttributes, + /* [in] */ LPSECURITY_ATTRIBUTES lpThreadAttributes, + /* [in] */ BOOL bInheritHandles, + /* [in] */ DWORD dwCreationFlags, + /* [in] */ PVOID lpEnvironment, + /* [in] */ LPCWSTR lpCurrentDirectory, + /* [in] */ LPSTARTUPINFOW lpStartupInfo, + /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, + /* [in] */ CorDebugCreateProcessFlags debuggingFlags, + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "Cordb - CreateProcessEx - NOT IMPLEMENTED\n"); + return S_OK; +} + +HRESULT Cordb::DebugActiveProcessEx( + /* [in] */ ICorDebugRemoteTarget *pRemoteTarget, + /* [in] */ DWORD dwProcessId, + /* [in] */ BOOL fWin32Attach, + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "Cordb - DebugActiveProcessEx - NOT IMPLEMENTED\n"); + return S_OK; +} + +Connection::Connection(CordbProcess *proc, Cordb *cordb) { + ppProcess = proc; + ppCordb = cordb; + pCorDebugAppDomain = NULL; + received_replies = g_hash_table_new(NULL, NULL); + received_packets_to_process = g_ptr_array_new(); + is_answer_pending = false; + pending_eval = g_ptr_array_new(); +} + +CordbThread *Connection::findThread(GPtrArray *threads, long thread_id) { + int i = 0; + while (i < threads->len) { + CordbThread *thread = (CordbThread *)g_ptr_array_index(threads, i); + if (thread->thread_id == thread_id) { + return thread; + } + i++; + } + return NULL; +} + +void Connection::receive() { + while (true) { + MdbgProtBuffer recvbuf_header; + m_dbgprot_buffer_init(&recvbuf_header, HEADER_LENGTH); + + int iResult = + recv(connect_socket, (char *)recvbuf_header.buf, HEADER_LENGTH, 0); + + if (iResult == -1) + break; + while (iResult == 0) { + DEBUG_PRINTF(1, + "[dbg] transport_recv () sleep returned %d, expected %d.\n", + iResult, HEADER_LENGTH); + iResult = recv(connect_socket, (char *)recvbuf_header.buf, HEADER_LENGTH, 0); + Sleep(1000); + } + + MdbgProtHeader header; + MdbgProtBuffer *recvbuf = new MdbgProtBuffer(); + m_dbgprot_decode_command_header(&recvbuf_header, &header); + + m_dbgprot_buffer_init(recvbuf, header.len - HEADER_LENGTH); + + if (header.len < HEADER_LENGTH) { + return; + } + + if (header.len - HEADER_LENGTH != 0) { + iResult = recv(connect_socket, (char *)recvbuf->buf, + header.len - HEADER_LENGTH, 0); + int totalRead = iResult; + while (totalRead < header.len - HEADER_LENGTH) { + iResult = recv(connect_socket, (char *)recvbuf->buf + totalRead, + (header.len - HEADER_LENGTH) - totalRead, 0); + totalRead += iResult; + } + } + + dbg_lock(); + if (header.flags == REPLY_PACKET) { + DEBUG_PRINTF( + 1, "header->id - %d - header->error - %d - header->error_2 - %d\n", + header.id, header.error, header.error_2); + ReceivedReplyPacket *rp = + (ReceivedReplyPacket *)g_malloc0(sizeof(ReceivedReplyPacket)); + rp->error = header.error; + rp->error_2 = header.error_2; + rp->buf = recvbuf; + g_hash_table_insert(received_replies, (gpointer)(gssize)(header.id), rp); + } else { + g_ptr_array_add(received_packets_to_process, recvbuf); + } + dbg_unlock(); + } +} + +MdbgProtBuffer *Connection::get_answer(int cmdId) { + ReceivedReplyPacket *ret = NULL; + while (ret == NULL) { + dbg_lock(); + ret = (ReceivedReplyPacket *)g_hash_table_lookup(received_replies, + (gpointer)(gssize)(cmdId)); + dbg_unlock(); + } + return ret->buf; +} + +ReceivedReplyPacket *Connection::get_answer_with_error(int cmdId) { + ReceivedReplyPacket *ret = NULL; + while (ret == NULL) { + dbg_lock(); + ret = (ReceivedReplyPacket *)g_hash_table_lookup(received_replies, + (gpointer)(gssize)(cmdId)); + dbg_unlock(); + } + return ret; +} + +void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { + int spolicy = m_dbgprot_decode_byte(recvbuf->buf, &recvbuf->buf, recvbuf->end); + int nevents = m_dbgprot_decode_int(recvbuf->buf, &recvbuf->buf, recvbuf->end); + + for (int i = 0; i < nevents; ++i) { + + int kind = m_dbgprot_decode_byte(recvbuf->buf, &recvbuf->buf, recvbuf->end); + int req_id = m_dbgprot_decode_int(recvbuf->buf, &recvbuf->buf, recvbuf->end); + + MdbgProtEventKind etype = (MdbgProtEventKind)kind; + + long thread_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + + DEBUG_PRINTF(1, "Received %d %d events %s, suspend=%d\n", i, nevents, + m_dbgprot_event_to_string(etype), etype); + + switch (etype) { + case MDBGPROT_EVENT_KIND_VM_START: { + ppProcess->suspended = true; + ppCordb->pCallback->CreateProcess( + static_cast(ppProcess)); + } break; + case MDBGPROT_EVENT_KIND_THREAD_START: { + DEBUG_PRINTF(1, "criei a thread certinha pelo MDBGPROT_EVENT_KIND_THREAD_START\n"); + CordbThread *thread = new CordbThread(this, ppProcess, thread_id); + g_ptr_array_add(ppCordb->threads, thread); + ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); + } break; + case MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE: { + + } break; + case MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD: { + // all the callbacks call a resume, in this case that we are faking 2 + // callbacks without receive command, we should not send the continue + int assembly_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + if (pCorDebugAppDomain == NULL) { + pCorDebugAppDomain = new CordbAppDomain( + this, static_cast(ppProcess)); + ppProcess->Stop(false); + ppCordb->pCallback->CreateAppDomain( + static_cast(ppProcess), pCorDebugAppDomain); + } + DEBUG_PRINTF(1, "Recebi assembly load - %d\n", assembly_id); + ICorDebugAssembly *pAssembly = + new CordbAssembly(this, ppProcess, pCorDebugAppDomain, assembly_id); + ppProcess->Stop(false); + ppCordb->pCallback->LoadAssembly(pCorDebugAppDomain, pAssembly); + + ppProcess->suspended = true; + ICorDebugModule *pModule = new CordbModule( + this, ppProcess, (CordbAssembly *)pAssembly, assembly_id); + g_hash_table_insert(ppCordb->modules, GINT_TO_POINTER(assembly_id), + pModule); + ppCordb->pCallback->LoadModule(pCorDebugAppDomain, pModule); + } break; + case MDBGPROT_EVENT_KIND_BREAKPOINT: { + int method_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + long offset = m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); + CordbThread *thread = findThread(ppCordb->threads, thread_id); + if (thread == NULL) { + DEBUG_PRINTF(1, "criei a thread errada pelo MDBGPROT_EVENT_KIND_BREAKPOINT\n"); + thread = new CordbThread(this, ppProcess, thread_id); + g_ptr_array_add(ppCordb->threads, thread); + ppProcess->Stop(false); + ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); + } + int i = 0; + CordbFunctionBreakpoint *breakpoint; + while (i < ppCordb->breakpoints->len) { + breakpoint = (CordbFunctionBreakpoint *)g_ptr_array_index( + ppCordb->breakpoints, i); + if (breakpoint->offset == offset && + breakpoint->code->func->id == method_id) { + ppCordb->pCallback->Breakpoint( + pCorDebugAppDomain, thread, + static_cast(breakpoint)); + break; + } + i++; + } + } break; + case MDBGPROT_EVENT_KIND_STEP: { + int method_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + long offset = m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); + + DEBUG_PRINTF(1, "MDBGPROT_EVENT_KIND_STEP - %d - %d - %d\n", thread_id, method_id, + offset); + + CordbThread *thread = findThread(ppCordb->threads, thread_id); + if (thread == NULL) { + DEBUG_PRINTF(1, "criei a thread errada pelo MDBGPROT_EVENT_KIND_STEP\n"); + thread = new CordbThread(this, ppProcess, thread_id); + g_ptr_array_add(ppCordb->threads, thread); + ppProcess->Stop(false); + ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); + } + ppProcess->suspended = true; + if (!thread->stepper->isComplete) { + ppProcess->Stop(false); + ppCordb->pCallback->StepComplete(pCorDebugAppDomain, thread, + thread->stepper, STEP_NORMAL); + } + thread->stepper->isComplete = true; + } break; + } + } + // m_dbgprot_buffer_free(&recvbuf); +} + +int Connection::process_packet(bool is_answer) { + if (!is_answer) + process_packet_from_queue(); + return 1; +} + +void Connection::process_packet_from_queue() { + int i = 0; + while (i < received_packets_to_process->len) { + MdbgProtBuffer *req = (MdbgProtBuffer *)g_ptr_array_index(received_packets_to_process, i); + process_packet_internal(req); + dbg_lock(); + g_ptr_array_remove_index_fast(received_packets_to_process, i); + dbg_unlock(); + delete req; + i--; + } + while (i < pending_eval->len) { + CordbEval *eval = (CordbEval *)g_ptr_array_index(pending_eval, i); + MdbgProtBuffer *recvbuf = get_answer(eval->cmdId); + eval->EvalComplete(recvbuf); + dbg_lock(); + g_ptr_array_remove_index_fast(pending_eval, i); + dbg_unlock(); + i--; + } +} + +void Connection::loop_send_receive() { + DWORD thread_id; + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)receive_thread, this, 0, + &thread_id); + + // machine.EnableEvents(EventType.AssemblyLoad, EventType.ThreadStart, + // EventType.ThreadDeath, EventType.AppDomainUnload, EventType.UserBreak, + // EventType.UserLog); + enable_event(MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD); + enable_event(MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE); + enable_event(MDBGPROT_EVENT_KIND_THREAD_START); + enable_event(MDBGPROT_EVENT_KIND_THREAD_DEATH); + enable_event(MDBGPROT_EVENT_KIND_APPDOMAIN_UNLOAD); + enable_event(MDBGPROT_EVENT_KIND_USER_BREAK); + enable_event(MDBGPROT_EVENT_KIND_USER_LOG); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_int(&localbuf, MAJOR_VERSION); + m_dbgprot_buffer_add_int(&localbuf, MINOR_VERSION); + int cmdId = send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SET_PROTOCOL_VERSION, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + m_dbgprot_buffer_init(&localbuf, 128); + cmdId = send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_VERSION, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + MdbgProtBuffer *bAnswer = get_answer(cmdId); + char *vm_version = + m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int major_version = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int minor_version = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + + DEBUG_PRINTF(1, + "[dbg] Protocol version %d.%d, server protocol version %d.%d.\n", + MAJOR_VERSION, MINOR_VERSION, major_version, minor_version); + + int iResult = 0; + // Receive until the peer closes the connection + do { + iResult = process_packet(); + Sleep(100); + } while (iResult >= 0); +} + +void Connection::enable_event(MdbgProtEventKind eventKind) { + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, eventKind); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 0); // modifiers + send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); +} + +void Connection::close_connection() { + closesocket(connect_socket); + WSACleanup(); +} + +void Connection::start_connection() { + DEBUG_PRINTF(1, "Start Connection\n"); + + WSADATA wsaData; + connect_socket = INVALID_SOCKET; + struct addrinfo *result = NULL, *ptr = NULL, hints; + int iResult; + + // Initialize Winsock + iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); + if (iResult != 0) { + return; + } + + ZeroMemory(&hints, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + DEBUG_PRINTF(1, "Listening to 127.0.0.1:1003\n"); + + // Resolve the server address and port + iResult = getaddrinfo("127.0.0.1", "1003", &hints, &result); + if (iResult != 0) { + WSACleanup(); + return; + } + + // Attempt to connect to an address until one succeeds + for (ptr = result; ptr != NULL; ptr = ptr->ai_next) { + + // Create a SOCKET for connecting to server + connect_socket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); + + if (connect_socket == INVALID_SOCKET) { + WSACleanup(); + return; + } + + int flag = 1; + if (setsockopt(connect_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, + sizeof(int))) + continue; + + iResult = bind(connect_socket, ptr->ai_addr, (int)ptr->ai_addrlen); + if (iResult == -1) + continue; + + iResult = listen(connect_socket, 16); + if (iResult == -1) + continue; + + break; + } + + connect_socket = accept(connect_socket, NULL, NULL); + if (connect_socket == -1) + exit(1); + + DEBUG_PRINTF(1, "Accepted connection from client.\n"); + + freeaddrinfo(result); + + if (connect_socket == INVALID_SOCKET) { + WSACleanup(); + return; + } +} + +void Connection::transport_handshake() { + int buflen = 128; + + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, buflen); + + MdbgProtBuffer recvbuf; + m_dbgprot_buffer_init(&recvbuf, buflen); + + int iResult; + iResult = recv(connect_socket, (char *)recvbuf.buf, buflen, 0); + + // Send an initial buffer + m_dbgprot_buffer_add_data(&sendbuf, (guint8 *)"DWP-Handshake", 13); + send_packet(sendbuf); +} + +void Connection::send_packet(MdbgProtBuffer &sendbuf) { + int iResult = + send(connect_socket, (const char *)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf), 0); + if (iResult == SOCKET_ERROR) { + WSACleanup(); + return; + } +} + +void Connection::receive_packet(MdbgProtBuffer &recvbuf, int len) { + m_dbgprot_buffer_init(&recvbuf, len); + int iResult; + iResult = recv(connect_socket, (char *)recvbuf.buf, len, 0); +} + +void Connection::receive_header(MdbgProtHeader *header) { + MdbgProtBuffer recvbuf; + m_dbgprot_buffer_init(&recvbuf, 11); + int iResult; + iResult = recv(connect_socket, (char *)recvbuf.buf, 11, 0); + m_dbgprot_decode_command_header(&recvbuf, header); +} + +int Connection::send_event(int cmd_set, int cmd, MdbgProtBuffer *sendbuf) { + MdbgProtBuffer outbuf; + int ret = m_dbgprot_buffer_add_command_header(sendbuf, cmd_set, cmd, &outbuf); + send_packet(outbuf); + return ret; +} + +MONO_API HRESULT CoreCLRCreateCordbObject(int iDebuggerVersion, DWORD pid, + HMODULE hmodTargetCLR, + void **ppCordb) { + DEBUG_PRINTF(1, "CoreCLRCreateCordbObject \n"); + *ppCordb = new Cordb(); + return S_OK; +} + +MONO_API HRESULT CreateCordbObject(int iDebuggerVersion, void **ppCordb) { + DEBUG_PRINTF(1, "CreateCordbObject \n"); + *ppCordb = new Cordb(); + return S_OK; +} + +HRESULT CordbModule::GetAssembly( + /* [out] */ ICorDebugAssembly **ppAssembly) { + DEBUG_PRINTF(1, "CordbModule - GetAssembly\n"); + *ppAssembly = static_cast(pAssembly); + return S_OK; +} + +HRESULT CordbAssembly::GetProcess( + /* [out] */ ICorDebugProcess **ppProcess) { + DEBUG_PRINTF(1, "CorDebugAssembly - GetProcess\n"); + *ppProcess = static_cast(pProcess); + return S_OK; +} + +CordbBaseMono::CordbBaseMono(Connection *conn) { this->conn = conn; } + +void CordbBaseMono::SetConnection(Connection *conn) { this->conn = conn; } diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h new file mode 100644 index 00000000000000..130e850b034062 --- /dev/null +++ b/src/mono/dbi/cordb.h @@ -0,0 +1,206 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB.H +// + +#ifndef __MONO_DEBUGGER_CORDB_H__ +#define __MONO_DEBUGGER_CORDB_H__ + +#include "cor.h" +#include "cordebug.h" +#include "corhdr.h" +#include "xcordebug.h" + +#include +#include +#include +#include +#include +#include + +#include + +#ifdef HOST_WIN32 +#include +#include +#endif + +#define MAJOR_VERSION 3 +#define MINOR_VERSION 0 + +#define return_if_nok(error) \ + do { \ + if (!is_ok((error))) \ + return S_FALSE; \ + } while (0) + +#define dbg_lock() mono_os_mutex_lock(&debug_mutex.m); +#define dbg_unlock() mono_os_mutex_unlock(&debug_mutex.m); +static MonoCoopMutex debug_mutex; + +class Cordb; +class CordbProcess; +class CordbAppDomain; +class CordbAssembly; +class CordbCode; +class CordbThread; +class CordbFunction; +class CordbStepper; +class RegMeta; +class CordbRegisteSet; +class CordbClass; + +typedef struct ReceivedReplyPacket { + int error; + int error_2; + MdbgProtBuffer *buf; +} ReceivedReplyPacket; + +int convert_mono_type_2_icordbg_size(int type); + +class Cordb : public ICorDebug, public ICorDebugRemote { +public: + GPtrArray *breakpoints; + GPtrArray *threads; + GPtrArray *functions; + GHashTable *modules; + + ICorDebugManagedCallback *pCallback; + Cordb(); + + CordbFunction *findFunction(int id); + CordbFunction *findFunctionByToken(int token); + HRESULT Initialize(void); + + HRESULT Terminate(void); + + HRESULT SetManagedHandler( + /* [in] */ ICorDebugManagedCallback *pCallback); + + HRESULT SetUnmanagedHandler( + /* [in] */ ICorDebugUnmanagedCallback *pCallback); + + HRESULT CreateProcess( + /* [in] */ LPCWSTR lpApplicationName, + /* [in] */ LPWSTR lpCommandLine, + /* [in] */ LPSECURITY_ATTRIBUTES lpProcessAttributes, + /* [in] */ LPSECURITY_ATTRIBUTES lpThreadAttributes, + /* [in] */ BOOL bInheritHandles, + /* [in] */ DWORD dwCreationFlags, + /* [in] */ PVOID lpEnvironment, + /* [in] */ LPCWSTR lpCurrentDirectory, + /* [in] */ LPSTARTUPINFOW lpStartupInfo, + /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, + /* [in] */ CorDebugCreateProcessFlags debuggingFlags, + /* [out] */ ICorDebugProcess **ppProcess); + + HRESULT DebugActiveProcess( + /* [in] */ DWORD id, + /* [in] */ BOOL win32Attach, + /* [out] */ ICorDebugProcess **ppProcess); + HRESULT EnumerateProcesses( + /* [out] */ ICorDebugProcessEnum **ppProcess); + + HRESULT GetProcess( + /* [in] */ DWORD dwProcessId, + /* [out] */ ICorDebugProcess **ppProcess); + + HRESULT CanLaunchOrAttach( + /* [in] */ DWORD dwProcessId, + /* [in] */ BOOL win32DebuggingEnabled); + HRESULT QueryInterface( + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject); + + ULONG AddRef(void); + ULONG Release(void); + HRESULT CreateProcessEx( + /* [in] */ ICorDebugRemoteTarget *pRemoteTarget, + /* [in] */ LPCWSTR lpApplicationName, + /* [annotation][in] */ + _In_ LPWSTR lpCommandLine, + /* [in] */ LPSECURITY_ATTRIBUTES lpProcessAttributes, + /* [in] */ LPSECURITY_ATTRIBUTES lpThreadAttributes, + /* [in] */ BOOL bInheritHandles, + /* [in] */ DWORD dwCreationFlags, + /* [in] */ PVOID lpEnvironment, + /* [in] */ LPCWSTR lpCurrentDirectory, + /* [in] */ LPSTARTUPINFOW lpStartupInfo, + /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, + /* [in] */ CorDebugCreateProcessFlags debuggingFlags, + /* [out] */ ICorDebugProcess **ppProcess); + + HRESULT DebugActiveProcessEx( + /* [in] */ ICorDebugRemoteTarget *pRemoteTarget, + /* [in] */ DWORD dwProcessId, + /* [in] */ BOOL fWin32Attach, + /* [out] */ ICorDebugProcess **ppProcess); +}; + +class Connection { + SOCKET connect_socket; + bool is_answer_pending; + +public: + CordbProcess *ppProcess; + Cordb *ppCordb; + CordbAppDomain *pCorDebugAppDomain; + GHashTable *received_replies; + GPtrArray *pending_eval; + GPtrArray *received_packets_to_process; + Connection(CordbProcess *proc, Cordb *cordb); + void loop_send_receive(); + void process_packet_internal(MdbgProtBuffer *recvbuf); + void process_packet_from_queue(); + void enable_event(MdbgProtEventKind eventKind); + void close_connection(); + void start_connection(); + void transport_handshake(); + void receive(); + void send_packet(MdbgProtBuffer &sendbuf); + void receive_packet(MdbgProtBuffer &b, int len); + void receive_header(MdbgProtHeader *header); + int send_event(int cmd_set, int cmd, MdbgProtBuffer *sendbuf); + int process_packet(bool is_answer = false); + MdbgProtBuffer *get_answer(int cmdId); + ReceivedReplyPacket *get_answer_with_error(int cmdId); + CordbThread *findThread(GPtrArray *threads, long thread_id); +}; + +class CordbBaseMono { +protected: + Connection *conn; + +public: + CordbBaseMono(Connection *conn); + void SetConnection(Connection *conn); +}; + +static int log_level = 10; +static FILE *log_file = fopen("c:\\thays\\example.txt", "a+"); + +#define DEBUG(level, s) \ + do { \ + if (G_UNLIKELY((level) <= log_level)) { \ + s; \ + fflush(log_file); \ + } \ + } while (0) +#define DEBUG_PRINTF(level, ...) \ + do { \ + if (G_UNLIKELY((level) <= log_level)) { \ + fprintf(log_file, __VA_ARGS__); \ + fflush(log_file); \ + } \ + } while (0) + +#define CHECK_ERROR_RETURN_FALSE(localbuf) \ + do { \ + if (localbuf->error > 0 || localbuf->error_2 > 0) { \ + DEBUG_PRINTF(1, "retornando erro\n"); \ + return S_FALSE; \ + } \ + } while (0) + +#endif diff --git a/src/mono/mono/mini/debugger-agent.c b/src/mono/mono/mini/debugger-agent.c index b99451a1e7f074..10c8b9d8eda167 100644 --- a/src/mono/mono/mini/debugger-agent.c +++ b/src/mono/mono/mini/debugger-agent.c @@ -5328,7 +5328,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, /* Fall through */ handle_vtype: case MONO_TYPE_VALUETYPE: - if (type == MONO_TYPE_OBJECT) { + if (type == MONO_TYPE_OBJECT || type == MONO_TYPE_STRING) { /* Boxed vtype */ int objid = decode_objid (buf, &buf, limit); ErrorCode err; @@ -6733,15 +6733,13 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) tls->pending_invoke->endp = tls->pending_invoke->p + (end - p); tls->pending_invoke->suspend_count = suspend_count; tls->pending_invoke->nmethods = nmethods; - if (!CHECK_PROTOCOL_VERSION (3, 0)) { //on icordbg they send a resume after calling an invoke method - if (flags & INVOKE_FLAG_SINGLE_THREADED) { - resume_thread(THREAD_TO_INTERNAL(thread)); - } - else { - count = suspend_count; - for (i = 0; i < count; ++i) - resume_vm(); - } + if (flags & INVOKE_FLAG_SINGLE_THREADED) { + resume_thread(THREAD_TO_INTERNAL(thread)); + } + else { + count = suspend_count; + for (i = 0; i < count; ++i) + resume_vm(); } break; } @@ -7215,6 +7213,12 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mono_error_cleanup (error); return ERR_INVALID_OBJECT; } + + if (CHECK_PROTOCOL_VERSION(3, 0)) { + buffer_add_byte(buf, 1); + buffer_add_byte(buf, MONO_TYPE_STRING); + } + buffer_add_objid (buf, (MonoObject*)o); break; } @@ -8724,6 +8728,18 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) buffer_add_long (buf, (long)mono_stopwatch_elapsed_ms (&tls->step_time)); break; } + case MDBGPROT_CMD_THREAD_GET_APPDOMAIN: { + DebuggerTlsData* tls; + mono_loader_lock (); + tls = (DebuggerTlsData*)mono_g_hash_table_lookup (thread_to_tls, thread); + mono_loader_unlock (); + if (tls == NULL) + return ERR_UNLOADED; + if (tls->frame_count <= 0) + return ERR_UNLOADED; + buffer_add_domainid (buf, tls->frames[0]->de.domain); + break; + } default: return ERR_NOT_IMPLEMENTED; } @@ -9455,7 +9471,6 @@ command_set_to_string (CommandSet command_set) } static const char* vm_cmds_str [] = { - "", "VERSION", "ALL_THREADS", "SUSPEND", diff --git a/src/mono/mono/mini/debugger-protocol.h b/src/mono/mono/mini/debugger-protocol.h index fbf42f54857626..e7a69657ed4a53 100644 --- a/src/mono/mono/mini/debugger-protocol.h +++ b/src/mono/mono/mini/debugger-protocol.h @@ -109,7 +109,8 @@ typedef enum { MDBGPROT_CMD_THREAD_GET_ID = 5, MDBGPROT_CMD_THREAD_GET_TID = 6, MDBGPROT_CMD_THREAD_SET_IP = 7, - MDBGPROT_CMD_THREAD_ELAPSED_TIME = 8 + MDBGPROT_CMD_THREAD_ELAPSED_TIME = 8, + MDBGPROT_CMD_THREAD_GET_APPDOMAIN = 9 } MdbgProtCmdThread; typedef enum { From 086f05173c8b8149227cf65738f4c0117addcc51 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Thu, 28 Jan 2021 13:47:45 -0300 Subject: [PATCH 02/64] Fix eval, fix step and cancel step, remove suspend status on mscordbi --- src/mono/dbi/CMakeLists.txt | 23 +++++----- src/mono/dbi/cordb-eval.cpp | 7 +-- src/mono/dbi/cordb-stepper.cpp | 20 +++++++-- src/mono/dbi/cordb-stepper.h | 1 + src/mono/dbi/cordb.cpp | 69 ++++++++++++++--------------- src/mono/mono/mini/debugger-agent.c | 2 +- 6 files changed, 64 insertions(+), 58 deletions(-) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index ad169aaf4a993d..44236ad1318fbd 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -188,30 +188,29 @@ addprefix(MDRUNTIMERW_HEADERS ${PROJECT_SOURCE_DIR}/../../coreclr/ "${MDRUNTIMER addprefix(eglib_sources ../mono/eglib/ "${eglib_sources}") add_library(mscordbi SHARED "${eglib_sources};${mscorbi_sources};${PROJECT_SOURCE_DIR}/../mono/mini/debugger-protocol.c;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/xcordebug_i.cpp;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/cordebug_i.cpp") - add_library(mdruntimerw-dbi STATIC "${MDRUNTIMERW_SOURCES};${MDRUNTIMERW_HEADERS}") add_library(utilcode STATIC "${UTILCODE_COMMON_SOURCES}") target_link_libraries(mscordbi mdruntimerw-dbi utilcode ${OS_LIBS}) - -set(TARGET_AMD64 1) -add_compile_definitions(TARGET_AMD64) -add_compile_definitions(DBI_COMPONENT) -add_compile_definitions(HOST_WINDOWS) -add_compile_definitions(HOST_64BIT) -add_compile_definitions(FEATURE_COMINTEROP) -add_compile_definitions(SELF_NO_HOST) - - target_precompile_headers(mdruntimerw-dbi PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/md/enc/stdafx.h) target_precompile_headers(utilcode PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/utilcode/stdafx.h) +if(HOST_AMD64) + add_compile_definitions(TARGET_AMD64) + add_compile_definitions(HOST_64BIT) +endif(HOST_AMD64) if(HOST_WIN32) -target_compile_definitions(utilcode PRIVATE _CRTIMP=) + add_compile_definitions(HOST_WINDOWS) + target_compile_definitions(utilcode PRIVATE _CRTIMP=) endif(HOST_WIN32) +add_compile_definitions(DBI_COMPONENT) +add_compile_definitions(FEATURE_COMINTEROP) +add_compile_definitions(SELF_NO_HOST) + + SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER}) SET_TARGET_PROPERTIES(mdruntimerw-dbi PROPERTIES LINKER_LANGUAGE CXX) SET_TARGET_PROPERTIES(utilcode PROPERTIES LINKER_LANGUAGE CXX) diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index 65594522b11ca0..3dca0ebb8afd9e 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -20,16 +20,12 @@ CordbEval::CordbEval(Connection *conn, CordbThread *thread) this->thread = thread; ppValue = NULL; cmdId = -1; - //send a suspend because after the eval icordebug will send a resume - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SUSPEND, &localbuf); - m_dbgprot_buffer_free(&localbuf); } HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( ICorDebugFunction *pFunction, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]) { + this->thread->ppProcess->Stop(false); DEBUG_PRINTF(1, "CordbEval - CallParameterizedFunction - IMPLEMENTED\n"); MdbgProtBuffer localbuf; @@ -118,6 +114,7 @@ CordbEval::NewParameterizedArray(ICorDebugType *pElementType, ULONG32 rank, HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, UINT uiLength) { + this->thread->ppProcess->Stop(false); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index d0e369d5eb44b2..088a0c3608a130 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -20,6 +20,7 @@ CordbStepper::CordbStepper(Connection *conn, CordbThread *thread) this->thread = thread; hasStepped = false; isComplete = false; + eventId = -1; } HRESULT STDMETHODCALLTYPE CordbStepper::IsActive(BOOL *pbActive) { @@ -28,8 +29,14 @@ HRESULT STDMETHODCALLTYPE CordbStepper::IsActive(BOOL *pbActive) { } HRESULT STDMETHODCALLTYPE CordbStepper::Deactivate(void) { - DEBUG_PRINTF(1, "CordbStepper - Deactivate - NOT IMPLEMENTED\n"); - return E_NOTIMPL; + DEBUG_PRINTF(1, "CordbStepper - Deactivate - IMPLEMENTED\n"); + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); + m_dbgprot_buffer_add_int(&sendbuf, eventId); + conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_CLEAR, &sendbuf); + return S_OK; } HRESULT STDMETHODCALLTYPE @@ -67,8 +74,10 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO : MDBGPROT_STEP_DEPTH_OVER); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); + MdbgProtBuffer* bAnswer = conn->get_answer(cmdId); + eventId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); DEBUG_PRINTF(1, "CordbStepper - StepRange - IMPLEMENTED\n"); return S_OK; @@ -90,8 +99,11 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_DEPTH_OUT); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + m_dbgprot_buffer_free(&sendbuf); + MdbgProtBuffer* bAnswer = conn->get_answer(cmdId); DEBUG_PRINTF(1, "CordbStepper - StepOut - IMPLEMENTED\n"); return S_OK; diff --git a/src/mono/dbi/cordb-stepper.h b/src/mono/dbi/cordb-stepper.h index 20f85af03d239e..1285a8776b2ea4 100644 --- a/src/mono/dbi/cordb-stepper.h +++ b/src/mono/dbi/cordb-stepper.h @@ -14,6 +14,7 @@ class CordbStepper : public CordbBaseMono, public ICorDebugStepper2 { CordbThread *thread; boolean hasStepped; + int eventId; public: boolean isComplete; diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 41bdd990f23663..6c3c0eabea567b 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -243,8 +243,10 @@ void Connection::receive() { int iResult = recv(connect_socket, (char *)recvbuf_header.buf, HEADER_LENGTH, 0); - if (iResult == -1) - break; + if (iResult == -1) { + ppCordb->pCallback->ExitProcess(static_cast(ppProcess)); + break; + } while (iResult == 0) { DEBUG_PRINTF(1, "[dbg] transport_recv () sleep returned %d, expected %d.\n", @@ -333,42 +335,44 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { switch (etype) { case MDBGPROT_EVENT_KIND_VM_START: { ppProcess->suspended = true; - ppCordb->pCallback->CreateProcess( - static_cast(ppProcess)); - } break; + ppCordb->pCallback->CreateProcess(static_cast(ppProcess)); + } + break; + case MDBGPROT_EVENT_KIND_VM_DEATH: { + ppCordb->pCallback->ExitProcess(static_cast(ppProcess)); + } + break; case MDBGPROT_EVENT_KIND_THREAD_START: { DEBUG_PRINTF(1, "criei a thread certinha pelo MDBGPROT_EVENT_KIND_THREAD_START\n"); CordbThread *thread = new CordbThread(this, ppProcess, thread_id); g_ptr_array_add(ppCordb->threads, thread); ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); - } break; + } + break; case MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE: { - } break; + } + break; case MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD: { // all the callbacks call a resume, in this case that we are faking 2 // callbacks without receive command, we should not send the continue int assembly_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); if (pCorDebugAppDomain == NULL) { - pCorDebugAppDomain = new CordbAppDomain( - this, static_cast(ppProcess)); + pCorDebugAppDomain = new CordbAppDomain(this, static_cast(ppProcess)); ppProcess->Stop(false); - ppCordb->pCallback->CreateAppDomain( - static_cast(ppProcess), pCorDebugAppDomain); + ppCordb->pCallback->CreateAppDomain(static_cast(ppProcess), pCorDebugAppDomain); } DEBUG_PRINTF(1, "Recebi assembly load - %d\n", assembly_id); - ICorDebugAssembly *pAssembly = - new CordbAssembly(this, ppProcess, pCorDebugAppDomain, assembly_id); + ICorDebugAssembly *pAssembly = new CordbAssembly(this, ppProcess, pCorDebugAppDomain, assembly_id); ppProcess->Stop(false); ppCordb->pCallback->LoadAssembly(pCorDebugAppDomain, pAssembly); ppProcess->suspended = true; - ICorDebugModule *pModule = new CordbModule( - this, ppProcess, (CordbAssembly *)pAssembly, assembly_id); - g_hash_table_insert(ppCordb->modules, GINT_TO_POINTER(assembly_id), - pModule); + ICorDebugModule *pModule = new CordbModule(this, ppProcess, (CordbAssembly *)pAssembly, assembly_id); + g_hash_table_insert(ppCordb->modules, GINT_TO_POINTER(assembly_id), pModule); ppCordb->pCallback->LoadModule(pCorDebugAppDomain, pModule); - } break; + } + break; case MDBGPROT_EVENT_KIND_BREAKPOINT: { int method_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); long offset = m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); @@ -383,18 +387,15 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { int i = 0; CordbFunctionBreakpoint *breakpoint; while (i < ppCordb->breakpoints->len) { - breakpoint = (CordbFunctionBreakpoint *)g_ptr_array_index( - ppCordb->breakpoints, i); - if (breakpoint->offset == offset && - breakpoint->code->func->id == method_id) { - ppCordb->pCallback->Breakpoint( - pCorDebugAppDomain, thread, - static_cast(breakpoint)); + breakpoint = (CordbFunctionBreakpoint *)g_ptr_array_index(ppCordb->breakpoints, i); + if (breakpoint->offset == offset && breakpoint->code->func->id == method_id) { + ppCordb->pCallback->Breakpoint(pCorDebugAppDomain, thread, static_cast(breakpoint)); break; } i++; } - } break; + } + break; case MDBGPROT_EVENT_KIND_STEP: { int method_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); long offset = m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); @@ -410,14 +411,9 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { ppProcess->Stop(false); ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); } - ppProcess->suspended = true; - if (!thread->stepper->isComplete) { - ppProcess->Stop(false); - ppCordb->pCallback->StepComplete(pCorDebugAppDomain, thread, - thread->stepper, STEP_NORMAL); - } - thread->stepper->isComplete = true; - } break; + ppCordb->pCallback->StepComplete(pCorDebugAppDomain, thread, thread->stepper, STEP_NORMAL); + } + break; } } // m_dbgprot_buffer_free(&recvbuf); @@ -442,8 +438,8 @@ void Connection::process_packet_from_queue() { } while (i < pending_eval->len) { CordbEval *eval = (CordbEval *)g_ptr_array_index(pending_eval, i); - MdbgProtBuffer *recvbuf = get_answer(eval->cmdId); - eval->EvalComplete(recvbuf); + ReceivedReplyPacket *recvbuf = get_answer_with_error(eval->cmdId); + eval->EvalComplete(recvbuf->buf); dbg_lock(); g_ptr_array_remove_index_fast(pending_eval, i); dbg_unlock(); @@ -466,6 +462,7 @@ void Connection::loop_send_receive() { enable_event(MDBGPROT_EVENT_KIND_APPDOMAIN_UNLOAD); enable_event(MDBGPROT_EVENT_KIND_USER_BREAK); enable_event(MDBGPROT_EVENT_KIND_USER_LOG); + enable_event(MDBGPROT_EVENT_KIND_VM_DEATH); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); diff --git a/src/mono/mono/mini/debugger-agent.c b/src/mono/mono/mini/debugger-agent.c index 10c8b9d8eda167..720821794d4e3a 100644 --- a/src/mono/mono/mini/debugger-agent.c +++ b/src/mono/mono/mini/debugger-agent.c @@ -5353,7 +5353,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, handle_ref: default: if (MONO_TYPE_IS_REFERENCE (t)) { - if (type == MONO_TYPE_OBJECT) { + if (type == MONO_TYPE_OBJECT || type == MONO_TYPE_STRING) { int objid = decode_objid (buf, &buf, limit); ErrorCode err; MonoObject *obj; From 7baa9d30c4cd3c5b3a671a086fadc61b0dc674be Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Fri, 29 Jan 2021 14:05:00 -0300 Subject: [PATCH 03/64] Using log from coreclr as mscordbi does --- src/mono/dbi/cordb-appdomain.cpp | 94 +++--- src/mono/dbi/cordb-assembly.cpp | 98 ++++--- src/mono/dbi/cordb-blocking-obj.cpp | 16 +- src/mono/dbi/cordb-breakpoint.cpp | 24 +- src/mono/dbi/cordb-chain.cpp | 46 +-- src/mono/dbi/cordb-class.cpp | 14 +- src/mono/dbi/cordb-code.cpp | 33 ++- src/mono/dbi/cordb-eval.cpp | 104 ++++--- src/mono/dbi/cordb-frame.cpp | 157 +++++----- src/mono/dbi/cordb-function.cpp | 67 +++-- src/mono/dbi/cordb-process.cpp | 171 ++++++----- src/mono/dbi/cordb-register.cpp | 19 +- src/mono/dbi/cordb-stepper.cpp | 44 +-- src/mono/dbi/cordb-symbol.cpp | 155 ++++++---- src/mono/dbi/cordb-symbol.h | 8 +- src/mono/dbi/cordb-thread.cpp | 99 ++++--- src/mono/dbi/cordb-type.cpp | 32 ++- src/mono/dbi/cordb-value.cpp | 426 ++++++++++++++-------------- 18 files changed, 901 insertions(+), 706 deletions(-) diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp index 531be2075866f3..701b9dfdb986fb 100644 --- a/src/mono/dbi/cordb-appdomain.cpp +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -25,49 +25,54 @@ CordbAppDomain::CordbAppDomain(Connection *conn, ICorDebugProcess *ppProcess) } HRESULT CordbAppDomain::Stop(/* [in] */ DWORD dwTimeoutIgnored) { - DEBUG_PRINTF(1, "CordbAppDomain - Stop - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Stop - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::Continue(/* [in] */ BOOL fIsOutOfBand) { - DEBUG_PRINTF(1, "CordbAppDomain - Continue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - Continue - NOT IMPLEMENTED\n")); pProcess->Continue(fIsOutOfBand); return S_OK; } HRESULT CordbAppDomain::IsRunning(/* [out] */ BOOL *pbRunning) { - DEBUG_PRINTF(1, "CordbAppDomain - IsRunning - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - IsRunning - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::HasQueuedCallbacks(/* [in] */ ICorDebugThread *pThread, /* [out] */ BOOL *pbQueued) { - DEBUG_PRINTF(1, "CordbAppDomain - HasQueuedCallbacks - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - HasQueuedCallbacks - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::EnumerateThreads(/* [out] */ ICorDebugThreadEnum **ppThreads) { - DEBUG_PRINTF(1, "CordbAppDomain - EnumerateThreads - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - EnumerateThreads - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::SetAllThreadsDebugState( /* [in] */ CorDebugThreadState state, /* [in] */ ICorDebugThread *pExceptThisThread) { - DEBUG_PRINTF(1, - "CordbAppDomain - SetAllThreadsDebugState - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::Detach(void) { - DEBUG_PRINTF(1, "CordbAppDomain - Detach - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Detach - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::Terminate(/* [in] */ UINT exitCode) { - DEBUG_PRINTF(1, "CordbAppDomain - Terminate - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - Terminate - NOT IMPLEMENTED\n")); return S_OK; } @@ -75,7 +80,8 @@ HRESULT CordbAppDomain::CanCommitChanges( /* [in] */ ULONG cSnapshots, /* [size_is][in] */ ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ ICorDebugErrorInfoEnum **pError) { - DEBUG_PRINTF(1, "CordbAppDomain - CanCommitChanges - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - CanCommitChanges - NOT IMPLEMENTED\n")); return S_OK; } @@ -83,7 +89,8 @@ HRESULT CordbAppDomain::CommitChanges( /* [in] */ ULONG cSnapshots, /* [size_is][in] */ ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ ICorDebugErrorInfoEnum **pError) { - DEBUG_PRINTF(1, "CordbAppDomain - CommitChanges - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - CommitChanges - NOT IMPLEMENTED\n")); return S_OK; } @@ -103,8 +110,6 @@ HRESULT CordbAppDomain::QueryInterface( else if (id == IID_IUnknown) *ppInterface = (IUnknown *)(ICorDebugAppDomain *)this; else { - DEBUG_PRINTF(1, "CordbAppDomain - QueryInterface - E_NOTIMPL\n"); - *ppInterface = NULL; return E_NOINTERFACE; } @@ -117,7 +122,8 @@ ULONG CordbAppDomain::Release(void) { return S_OK; } HRESULT CordbAppDomain::GetProcess( /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "CordbAppDomain - GetProcess - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - GetProcess - NOT IMPLEMENTED\n")); *ppProcess = pProcess; return S_OK; @@ -125,32 +131,36 @@ HRESULT CordbAppDomain::GetProcess( HRESULT CordbAppDomain::EnumerateAssemblies( /* [out] */ ICorDebugAssemblyEnum **ppAssemblies) { - DEBUG_PRINTF(1, "CordbAppDomain - EnumerateAssemblies - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - EnumerateAssemblies - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::GetModuleFromMetaDataInterface( /* [in] */ IUnknown *pIMetaData, /* [out] */ ICorDebugModule **ppModule) { - DEBUG_PRINTF( - 1, "CordbAppDomain - GetModuleFromMetaDataInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - GetModuleFromMetaDataInterface - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::EnumerateBreakpoints( /* [out] */ ICorDebugBreakpointEnum **ppBreakpoints) { - DEBUG_PRINTF(1, "CordbAppDomain - EnumerateBreakpoints - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - EnumerateBreakpoints - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::EnumerateSteppers( /* [out] */ ICorDebugStepperEnum **ppSteppers) { - DEBUG_PRINTF(1, "CordbAppDomain - EnumerateSteppers - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - EnumerateSteppers - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::IsAttached(/* [out] */ BOOL *pbAttached) { - DEBUG_PRINTF(1, "CordbAppDomain - IsAttached - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - IsAttached - NOT IMPLEMENTED\n")); return S_OK; } @@ -158,7 +168,7 @@ HRESULT CordbAppDomain::GetName(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, /* [length_is][size_is][out] */ WCHAR szName[]) { - DEBUG_PRINTF(1, "CordbAppDomain - GetName - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetName - IMPLEMENTED\n")); if (cchName < strlen("DefaultDomain")) { *pcchName = strlen("DefaultDomain") + 1; return S_OK; @@ -169,18 +179,19 @@ CordbAppDomain::GetName(/* [in] */ ULONG32 cchName, } HRESULT CordbAppDomain::GetObject(/* [out] */ ICorDebugValue **ppObject) { - DEBUG_PRINTF(1, "CordbAppDomain - GetObject - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - GetObject - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::Attach(void) { - DEBUG_PRINTF(1, "CordbAppDomain - Attach - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Attach - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::GetID(/* [out] */ ULONG32 *pId) { *pId = 0; - DEBUG_PRINTF(1, "CordbAppDomain - GetID - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetID - IMPLEMENTED\n")); return S_OK; } @@ -188,7 +199,8 @@ HRESULT CordbAppDomain::GetArrayOrPointerType( /* [in] */ CorElementType elementType, /* [in] */ ULONG32 nRank, /* [in] */ ICorDebugType *pTypeArg, /* [out] */ ICorDebugType **ppType) { - DEBUG_PRINTF(1, "CordbAppDomain - GetArrayOrPointerType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - GetArrayOrPointerType - NOT IMPLEMENTED\n")); return S_OK; } @@ -196,8 +208,8 @@ HRESULT CordbAppDomain::GetFunctionPointerType( /* [in] */ ULONG32 nTypeArgs, /* [size_is][in] */ ICorDebugType *ppTypeArgs[], /* [out] */ ICorDebugType **ppType) { - DEBUG_PRINTF(1, - "CordbAppDomain - GetFunctionPointerType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - GetFunctionPointerType - NOT IMPLEMENTED\n")); return S_OK; } @@ -205,28 +217,31 @@ HRESULT CordbAppDomain::GetCachedWinRTTypesForIIDs( /* [in] */ ULONG32 cReqTypes, /* [size_is][in] */ GUID *iidsToResolve, /* [out] */ ICorDebugTypeEnum **ppTypesEnum) { - DEBUG_PRINTF( - 1, "CordbAppDomain - GetCachedWinRTTypesForIIDs - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - GetCachedWinRTTypesForIIDs - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::GetCachedWinRTTypes( /* [out] */ ICorDebugGuidToTypeEnum **ppGuidToTypeEnum) { - DEBUG_PRINTF(1, "CordbAppDomain - GetCachedWinRTTypes - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - GetCachedWinRTTypes - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::GetObjectForCCW(/* [in] */ CORDB_ADDRESS ccwPointer, /* [out] */ ICorDebugValue **ppManagedObject) { - DEBUG_PRINTF(1, "CordbAppDomain - GetObjectForCCW - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - GetObjectForCCW - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, ICorDebugAppDomain *values[], ULONG *pceltFetched) { - DEBUG_PRINTF(1, "CordbAppDomainEnum - Next - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomainEnum - Next - NOT IMPLEMENTED\n")); *pceltFetched = celt; for (int i = 0; i < celt; i++) { if (current_pos >= pProcess->appdomains->len) { @@ -243,23 +258,27 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, } HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Skip(ULONG celt) { - DEBUG_PRINTF(1, "CordbAppDomainEnum - Skip - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomainEnum - Skip - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Reset(void) { current_pos = 0; - DEBUG_PRINTF(1, "CordbAppDomainEnum - Reset - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomainEnum - Reset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Clone(ICorDebugEnum **ppEnum) { - DEBUG_PRINTF(1, "CordbAppDomainEnum - Clone - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomainEnum - Clone - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::GetCount(ULONG *pcelt) { - DEBUG_PRINTF(1, "CordbAppDomainEnum - GetCount - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbAppDomainEnum - GetCount - IMPLEMENTED\n")); *pcelt = pProcess->appdomains->len; return S_OK; } @@ -274,7 +293,8 @@ CordbAppDomainEnum::QueryInterface(REFIID id, void **pInterface) { else if (id == IID_ICorDebugEnum) *pInterface = static_cast(this); else { - DEBUG_PRINTF(1, "CordbAppDomain - QueryInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbAppDomain - QueryInterface - NOT IMPLEMENTED\n")); return E_NOINTERFACE; } return S_OK; diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index c1b5535ef4cf9e..527f261430d740 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -27,20 +27,23 @@ CordbAssembly::CordbAssembly(Connection *conn, CordbProcess *process, HRESULT CordbAssembly::IsFullyTrusted(/* [out] */ BOOL *pbFullyTrusted) { *pbFullyTrusted = true; - DEBUG_PRINTF(1, "CorDebugAssembly - IsFullyTrusted - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CorDebugAssembly - IsFullyTrusted - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAssembly::GetAppDomain( /* [out] */ ICorDebugAppDomain **ppAppDomain) { - DEBUG_PRINTF(1, "CorDebugAssembly - GetAppDomain - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CorDebugAssembly - GetAppDomain - IMPLEMENTED\n")); *ppAppDomain = static_cast(pAppDomain); return S_OK; } HRESULT CordbAssembly::EnumerateModules( /* [out] */ ICorDebugModuleEnum **ppModules) { - DEBUG_PRINTF(1, "CorDebugAssembly - EnumerateModules - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CorDebugAssembly - EnumerateModules - NOT IMPLEMENTED\n")); return S_OK; } @@ -48,7 +51,8 @@ HRESULT CordbAssembly::GetCodeBase( /* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, /* [length_is][size_is][out] */ WCHAR szName[]) { - DEBUG_PRINTF(1, "CorDebugAssembly - GetCodeBase - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CorDebugAssembly - GetCodeBase - NOT IMPLEMENTED\n")); return S_OK; } @@ -56,7 +60,8 @@ HRESULT CordbAssembly::GetName( /* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, /* [length_is][size_is][out] */ WCHAR szName[]) { - DEBUG_PRINTF(1, "CorDebugAssembly - GetName - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CorDebugAssembly - GetName - NOT IMPLEMENTED\n")); return S_OK; } @@ -71,8 +76,6 @@ HRESULT CordbAssembly::QueryInterface( *ppInterface = static_cast(static_cast(this)); else { - DEBUG_PRINTF(1, "CordbAssembly - QueryInterface - E_NOTIMPL\n"); - *ppInterface = NULL; return E_NOINTERFACE; } @@ -106,8 +109,6 @@ HRESULT CordbModule::QueryInterface(REFIID id, void **pInterface) { } else if (id == IID_IUnknown) { *pInterface = static_cast(static_cast(this)); } else { - DEBUG_PRINTF(1, "CordbModule - QueryInterface - E_NOTIMPL\n"); - *pInterface = NULL; return E_NOINTERFACE; } @@ -121,15 +122,16 @@ ULONG CordbModule::Release(void) { return S_OK; } HRESULT CordbModule::IsMappedLayout( /* [out] */ BOOL *pIsMapped) { *pIsMapped = FALSE; - DEBUG_PRINTF(1, "CordbModule - IsMappedLayout - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbModule - IsMappedLayout - IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::CreateReaderForInMemorySymbols( /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObj) { - DEBUG_PRINTF( - 1, "CordbModule - CreateReaderForInMemorySymbols - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - CreateReaderForInMemorySymbols - NOT IMPLEMENTED\n")); return S_OK; } @@ -137,7 +139,8 @@ HRESULT CordbModule::SetJMCStatus( /* [in] */ BOOL bIsJustMyCode, /* [in] */ ULONG32 cTokens, /* [size_is][in] */ mdToken pTokens[]) { - DEBUG_PRINTF(1, "CordbModule - SetJMCStatus - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - SetJMCStatus - NOT IMPLEMENTED\n")); return S_OK; } @@ -146,34 +149,39 @@ HRESULT CordbModule::ApplyChanges( /* [size_is][in] */ BYTE pbMetadata[], /* [in] */ ULONG cbIL, /* [size_is][in] */ BYTE pbIL[]) { - DEBUG_PRINTF(1, "CordbModule - ApplyChanges - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - ApplyChanges - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::SetJITCompilerFlags( /* [in] */ DWORD dwFlags) { this->dwFlags = dwFlags; - DEBUG_PRINTF(1, "CordbModule - SetJITCompilerFlags - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - SetJITCompilerFlags - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::GetJITCompilerFlags( /* [out] */ DWORD *pdwFlags) { *pdwFlags = dwFlags; - DEBUG_PRINTF(1, "CordbModule - GetJITCompilerFlags - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - GetJITCompilerFlags - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::ResolveAssembly( /* [in] */ mdToken tkAssemblyRef, /* [out] */ ICorDebugAssembly **ppAssembly) { - DEBUG_PRINTF(1, "CordbModule - ResolveAssembly - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - ResolveAssembly - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::GetProcess( /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "CordbModule - GetProcess - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - GetProcess - NOT IMPLEMENTED\n")); // *ppProcess = pProcess; return S_OK; } @@ -183,15 +191,17 @@ HRESULT CordbModule::GetBaseAddress( MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, - &localbuf); + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, + MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); assembly_metadata_blob = m_dbgprot_decode_byte_array( bAnswer->buf, &bAnswer->buf, bAnswer->end, &assembly_metadata_len); - DEBUG_PRINTF(1, "CordbModule - GetBaseAddress\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbModule - GetBaseAddress - IMPLEMENTED\n")); *pAddress = (CORDB_ADDRESS)assembly_metadata_blob; return S_OK; @@ -201,20 +211,18 @@ HRESULT CordbModule::GetName( /* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, /* [length_is][size_is][out] */ WCHAR szName[]) { - DEBUG_PRINTF(1, "CordbModule - GetName - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetName - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, id); - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, + MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); char *assembly_name = m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "CordbModule - assembly_name - %d - %s\n", id, assembly_name); - if (cchName < strlen(assembly_name) + 1) { *pcchName = strlen(assembly_name) + 1; g_free(assembly_name); @@ -229,13 +237,15 @@ HRESULT CordbModule::GetName( HRESULT CordbModule::EnableJITDebugging( /* [in] */ BOOL bTrackJITInfo, /* [in] */ BOOL bAllowJitOpts) { - DEBUG_PRINTF(1, "CordbModule - EnableJITDebugging - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - EnableJITDebugging - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::EnableClassLoadCallbacks( /* [in] */ BOOL bClassLoadCallbacks) { - DEBUG_PRINTF(1, "CordbModule - EnableClassLoadCallbacks - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - EnableClassLoadCallbacks - NOT IMPLEMENTED\n")); return S_OK; } @@ -243,13 +253,15 @@ HRESULT CordbModule::GetFunctionFromToken( /* [in] */ mdMethodDef methodDef, /* [out] */ ICorDebugFunction **ppFunction) { // check in a cache before talk to mono runtime to get info - DEBUG_PRINTF(1, "CordbModule - GetFunctionFromToken - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbModule - GetFunctionFromToken - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, id); m_dbgprot_buffer_add_int(&localbuf, methodDef); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, - MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, + MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); @@ -267,7 +279,8 @@ HRESULT CordbModule::GetFunctionFromToken( HRESULT CordbModule::GetFunctionFromRVA( /* [in] */ CORDB_ADDRESS rva, /* [out] */ ICorDebugFunction **ppFunction) { - DEBUG_PRINTF(1, "CordbModule - GetFunctionFromRVA - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - GetFunctionFromRVA - NOT IMPLEMENTED\n")); return S_OK; } @@ -281,14 +294,15 @@ HRESULT CordbModule::GetClassFromToken( HRESULT CordbModule::CreateBreakpoint( /* [out] */ ICorDebugModuleBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, "CordbModule - CreateBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - CreateBreakpoint - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::GetEditAndContinueSnapshot( /* [out] */ ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot) { - DEBUG_PRINTF(1, - "CordbModule - GetEditAndContinueSnapshot - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - GetEditAndContinueSnapshot - NOT IMPLEMENTED\n")); return S_OK; } @@ -298,38 +312,40 @@ HRESULT CordbModule::GetMetaDataInterface( if (pCordbSymbol == NULL) pCordbSymbol = new RegMeta(pAssembly, this); pCordbSymbol->QueryInterface(riid, (void **)ppObj); - DEBUG_PRINTF(1, "CordbModule - GetMetaDataInterface - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbModule - GetMetaDataInterface - IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::GetToken( /* [out] */ mdModule *pToken) { - DEBUG_PRINTF(1, "CordbModule - GetToken - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetToken - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::IsDynamic( /* [out] */ BOOL *pDynamic) { - DEBUG_PRINTF(1, "CordbModule - IsDynamic - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::GetGlobalVariableValue( /* [in] */ mdFieldDef fieldDef, /* [out] */ ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbModule - GetGlobalVariableValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbModule - GetGlobalVariableValue - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::GetSize( /* [out] */ ULONG32 *pcBytes) { - DEBUG_PRINTF(1, "CordbModule - GetSize -IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetSize -IMPLEMENTED\n")); *pcBytes = assembly_metadata_len; return S_OK; } HRESULT CordbModule::IsInMemory( /* [out] */ BOOL *pInMemory) { - DEBUG_PRINTF(1, "CordbModule - IsInMemory - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsInMemory - IMPLEMENTED\n")); return S_OK; } diff --git a/src/mono/dbi/cordb-blocking-obj.cpp b/src/mono/dbi/cordb-blocking-obj.cpp index 6d2b5a7318247e..ff24c951aec475 100644 --- a/src/mono/dbi/cordb-blocking-obj.cpp +++ b/src/mono/dbi/cordb-blocking-obj.cpp @@ -25,23 +25,27 @@ CordbBlockingObjectEnum::CordbBlockingObjectEnum(Connection *conn) HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Next( ULONG celt, CorDebugBlockingObject values[], ULONG *pceltFetched) { - DEBUG_PRINTF(1, "CordbBlockingObjectEnum - Next - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbBlockingObjectEnum - Next - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Skip(ULONG celt) { - DEBUG_PRINTF(1, "CordbBlockingObjectEnum - Skip - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbBlockingObjectEnum - Skip - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Reset(void) { - DEBUG_PRINTF(1, "CordbBlockingObjectEnum - Reset - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbBlockingObjectEnum - Reset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Clone(ICorDebugEnum **ppEnum) { - DEBUG_PRINTF(1, "CordbBlockingObjectEnum - Clone - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbBlockingObjectEnum - Clone - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -52,8 +56,8 @@ HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::GetCount(ULONG *pcelt) { HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::QueryInterface(REFIID riid, void **ppvObject) { - DEBUG_PRINTF(1, - "CordbBlockingObjectEnum - QueryInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbBlockingObjectEnum - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-breakpoint.cpp b/src/mono/dbi/cordb-breakpoint.cpp index 7555837a029e74..c33969ff8c0c0d 100644 --- a/src/mono/dbi/cordb-breakpoint.cpp +++ b/src/mono/dbi/cordb-breakpoint.cpp @@ -29,12 +29,14 @@ CordbFunctionBreakpoint::CordbFunctionBreakpoint(Connection *conn, HRESULT __stdcall CordbFunctionBreakpoint::GetFunction( ICorDebugFunction **ppFunction) { *ppFunction = static_cast(code->func); - DEBUG_PRINTF(1, "CordbFunctionBreakpoint - GetFunction - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbFunctionBreakpoint - GetFunction - IMPLEMENTED\n")); return S_OK; } HRESULT __stdcall CordbFunctionBreakpoint::GetOffset(ULONG32 *pnOffset) { - DEBUG_PRINTF(1, "CordbFunctionBreakpoint - GetOffset - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunctionBreakpoint - GetOffset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -49,33 +51,31 @@ HRESULT __stdcall CordbFunctionBreakpoint::Activate(BOOL bActive) { m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_LOCATION_ONLY); m_dbgprot_buffer_add_id(&sendbuf, this->code->func->id); m_dbgprot_buffer_add_long(&sendbuf, offset); - conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, + MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); - DEBUG_PRINTF(1, "CordbFunctionBreakpoint - Activate\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbFunctionBreakpoint - Activate - IMPLEMENTED\n")); } else { - DEBUG_PRINTF( - 1, "CordbFunctionBreakpoint - Activate - FALSE - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunctionBreakpoint - Activate - FALSE - NOT IMPLEMENTED\n")); } return S_OK; } HRESULT __stdcall CordbFunctionBreakpoint::IsActive(BOOL *pbActive) { - DEBUG_PRINTF(1, "CordbFunctionBreakpoint - IsActive - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunctionBreakpoint - IsActive - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbFunctionBreakpoint::QueryInterface(REFIID id, void **pInterface) { - DEBUG_PRINTF(1, "CordbFunctionBreakpoint - QueryInterface - IMPLEMENTED\n"); - if (id == IID_ICorDebugFunctionBreakpoint) { *pInterface = static_cast(this); } else { // Not looking for a function breakpoint? See if the base class handles // this interface. (issue 143976) - DEBUG_PRINTF(1, - "return CordbBreakpoint::QueryInterface(id, pInterface);\n"); - // return CordbBreakpoint::QueryInterface(id, pInterface); } return S_OK; diff --git a/src/mono/dbi/cordb-chain.cpp b/src/mono/dbi/cordb-chain.cpp index a8e4e582ff3d96..608a4a5e54edfb 100644 --- a/src/mono/dbi/cordb-chain.cpp +++ b/src/mono/dbi/cordb-chain.cpp @@ -23,7 +23,7 @@ using namespace std; HRESULT __stdcall CordbChainEnum::Next(ULONG celt, ICorDebugChain *chains[], ULONG *pceltFetched) { - DEBUG_PRINTF(1, "CordbChainEnum - Next - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Next - NOT IMPLEMENTED\n")); chains[0] = new CordbChain(conn, thread, CHAIN_PROCESS_START, false); chains[1] = new CordbChain(conn, thread, CHAIN_ENTER_MANAGED, true); @@ -37,12 +37,13 @@ CordbChainEnum::CordbChainEnum(Connection *conn, CordbThread *thread) } HRESULT __stdcall CordbChainEnum::QueryInterface(REFIID id, void **pInterface) { - DEBUG_PRINTF(1, "CordbChainEnum - QueryInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbChainEnum - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbChainEnum::Skip(ULONG celt) { - DEBUG_PRINTF(1, "CordbChainEnum - Skip - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Skip - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -51,19 +52,20 @@ ULONG STDMETHODCALLTYPE CordbChainEnum::AddRef(void) { return 0; } ULONG STDMETHODCALLTYPE CordbChainEnum::Release(void) { return 0; } HRESULT STDMETHODCALLTYPE CordbChainEnum::Reset(void) { - DEBUG_PRINTF(1, "CordbChainEnum - Reset - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Reset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChainEnum::Clone( /* [out] */ ICorDebugEnum **ppEnum) { - DEBUG_PRINTF(1, "CordbChainEnum - Clone - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Clone - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChainEnum::GetCount( /* [out] */ ULONG *pcelt) { - DEBUG_PRINTF(1, "CordbChainEnum - GetCount - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbChainEnum - GetCount - NOT IMPLEMENTED\n")); *pcelt = 2; return S_OK; @@ -80,48 +82,50 @@ CordbChain::CordbChain(Connection *conn, CordbThread *thread, HRESULT STDMETHODCALLTYPE CordbChain::GetThread(/* [out] */ ICorDebugThread **ppThread) { *ppThread = static_cast(thread); - DEBUG_PRINTF(1, "CordbChain - GetThread - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbChain - GetThread - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbChain::GetStackRange( /* [out] */ CORDB_ADDRESS *pStart, /* [out] */ CORDB_ADDRESS *pEnd) { - DEBUG_PRINTF(1, "CordbChain - GetStackRange - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbChain - GetStackRange - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChain::GetContext(/* [out] */ ICorDebugContext **ppContext) { - DEBUG_PRINTF(1, "CordbChain - GetContext - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetContext - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChain::GetCaller(/* [out] */ ICorDebugChain **ppChain) { - DEBUG_PRINTF(1, "CordbChain - GetCaller - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetCaller - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChain::GetCallee(/* [out] */ ICorDebugChain **ppChain) { - DEBUG_PRINTF(1, "CordbChain - GetCallee - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetCallee - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChain::GetPrevious(/* [out] */ ICorDebugChain **ppChain) { - DEBUG_PRINTF(1, "CordbChain - GetPrevious - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbChain - GetPrevious - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChain::GetNext(/* [out] */ ICorDebugChain **ppChain) { - DEBUG_PRINTF(1, "CordbChain - GetNext - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetNext - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChain::IsManaged(/* [out] */ BOOL *pManaged) { - DEBUG_PRINTF(1, "CordbChain - IsManaged - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbChain - IsManaged - IMPLEMENTED\n")); *pManaged = is_managed; return S_OK; } @@ -129,33 +133,37 @@ HRESULT STDMETHODCALLTYPE CordbChain::IsManaged(/* [out] */ BOOL *pManaged) { HRESULT STDMETHODCALLTYPE CordbChain::EnumerateFrames(/* [out] */ ICorDebugFrameEnum **ppFrames) { *ppFrames = new CordbFrameEnum(conn, thread); - DEBUG_PRINTF(1, "CordbChain - EnumerateFrames - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbChain - EnumerateFrames - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbChain::GetActiveFrame(/* [out] */ ICorDebugFrame **ppFrame) { - DEBUG_PRINTF(1, "CordbChain - GetActiveFrame - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbChain - GetActiveFrame - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChain::GetRegisterSet(/* [out] */ ICorDebugRegisterSet **ppRegisters) { - DEBUG_PRINTF(1, "CordbChain - GetRegisterSet - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbChain - GetRegisterSet - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbChain::GetReason(/* [out] */ CorDebugChainReason *pReason) { *pReason = chain_reason; - DEBUG_PRINTF(1, "CordbChain - GetReason - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbChain - GetReason - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbChain::QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { - DEBUG_PRINTF(1, "CordbChain - QueryInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbChain - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-class.cpp b/src/mono/dbi/cordb-class.cpp index 1d71775b39c7eb..36bd2d16afebc8 100644 --- a/src/mono/dbi/cordb-class.cpp +++ b/src/mono/dbi/cordb-class.cpp @@ -25,7 +25,7 @@ CordbClass::CordbClass(Connection *conn, mdToken token, int module_id) } HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule **pModule) { - DEBUG_PRINTF(1, "CordbClass - GetModule - IMPLEMENTED - %d\n", module_id); + LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetModule - IMPLEMENTED\n")); if (pModule) { *pModule = (ICorDebugModule *)g_hash_table_lookup( conn->ppCordb->modules, GINT_TO_POINTER(module_id)); @@ -34,15 +34,15 @@ HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule **pModule) { } HRESULT STDMETHODCALLTYPE CordbClass::GetToken(mdTypeDef *pTypeDef) { - DEBUG_PRINTF(1, "CordbClass - GetToken - IMPLEMENTED - %d\n", module_id); + LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetToken - IMPLEMENTED\n")); *pTypeDef = token; return S_OK; } HRESULT STDMETHODCALLTYPE CordbClass::GetStaticFieldValue( mdFieldDef fieldDef, ICorDebugFrame *pFrame, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbClass - GetStaticFieldValue - NOT IMPLEMENTED - %d\n", - fieldDef); + LOG((LF_CORDB, LL_INFO100000, + "CordbClass - GetStaticFieldValue - NOT IMPLEMENTED\n")); CordbContent content_value; content_value.booleanValue = 0; CordbValue *value = @@ -74,11 +74,13 @@ ULONG STDMETHODCALLTYPE CordbClass::Release(void) { return 0; } HRESULT STDMETHODCALLTYPE CordbClass::GetParameterizedType( CorElementType elementType, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], ICorDebugType **ppType) { - DEBUG_PRINTF(1, "CordbClass - GetParameterizedType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbClass - GetParameterizedType - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbClass::SetJMCStatus(BOOL bIsJustMyCode) { - DEBUG_PRINTF(1, "CordbClass - SetJMCStatus - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbClass - SetJMCStatus - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index 22c284d3b7abc8..85014c632d35d0 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -29,17 +29,17 @@ CordbCode::CordbCode(Connection *conn, CordbFunction *func) } HRESULT __stdcall CordbCode::IsIL(BOOL *pbIL) { - DEBUG_PRINTF(1, "CordbCode - IsIL - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbCode - IsIL - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbCode::GetFunction(ICorDebugFunction **ppFunction) { - DEBUG_PRINTF(1, "CordbCode - GetFunction - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetFunction - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbCode::GetAddress(CORDB_ADDRESS *pStart) { - DEBUG_PRINTF(1, "CordbCode - GetAddress - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetAddress - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -48,13 +48,15 @@ HRESULT __stdcall CordbCode::GetSize(ULONG32 *pcBytes) { m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, this->func->id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int code_size = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int code_size = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); *pcBytes = code_size; - DEBUG_PRINTF(1, "CordbCode - GetSize - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetSize - IMPLEMENTED\n")); return S_OK; } @@ -64,7 +66,8 @@ HRESULT __stdcall CordbCode::CreateBreakpoint( CordbFunctionBreakpoint *bp = new CordbFunctionBreakpoint(conn, this, offset); *ppBreakpoint = static_cast(bp); g_ptr_array_add(this->func->module->pProcess->cordb->breakpoints, bp); - DEBUG_PRINTF(1, "CordbCode - CreateBreakpoint - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbCode - CreateBreakpoint - IMPLEMENTED\n")); return S_OK; } @@ -75,34 +78,38 @@ HRESULT __stdcall CordbCode::GetCode(ULONG32 startOffset, ULONG32 endOffset, m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, this->func->id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); guint8 *code = m_dbgprot_decode_byte_array(bAnswer->buf, &bAnswer->buf, - bAnswer->end, pcBufferSize); + bAnswer->end, pcBufferSize); memcpy(buffer, code, *pcBufferSize); - DEBUG_PRINTF(1, "CordbCode - GetCode - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetCode - IMPLEMENTED\n")); return S_OK; } HRESULT __stdcall CordbCode::GetVersionNumber(ULONG32 *nVersion) { *nVersion = 1; - DEBUG_PRINTF(1, "CordbCode - GetVersionNumber - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbCode - GetVersionNumber - NOT IMPLEMENTED\n")); return S_OK; } HRESULT __stdcall CordbCode::GetILToNativeMapping( ULONG32 cMap, ULONG32 *pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) { - DEBUG_PRINTF(1, "CordbCode - GetILToNativeMapping - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbCode - GetILToNativeMapping - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbCode::GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32 *pcMap, ULONG32 offsets[]) { - DEBUG_PRINTF(1, "CordbCode - GetEnCRemapSequencePoints - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbCode - GetEnCRemapSequencePoints - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index 3dca0ebb8afd9e..e88201279dea78 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -11,9 +11,9 @@ #include #include -#include "stdafx.h" #include "corerror.h" #include "rwutil.h" +#include "stdafx.h" CordbEval::CordbEval(Connection *conn, CordbThread *thread) : CordbBaseMono(conn) { @@ -26,7 +26,8 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( ICorDebugFunction *pFunction, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]) { this->thread->ppProcess->Stop(false); - DEBUG_PRINTF(1, "CordbEval - CallParameterizedFunction - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbEval - CallParameterizedFunction - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); @@ -41,34 +42,35 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( ppArgs[i]->GetAddress((CORDB_ADDRESS *)&cc); m_dbgprot_buffer_add_byte(&localbuf, ty); switch (ty) { - case MONO_TYPE_BOOLEAN: - case MONO_TYPE_I1: - case MONO_TYPE_U1: - m_dbgprot_buffer_add_int(&localbuf, cc->booleanValue); - break; - case MONO_TYPE_CHAR: - case MONO_TYPE_I2: - case MONO_TYPE_U2: - m_dbgprot_buffer_add_int(&localbuf, cc->charValue); - break; - case MONO_TYPE_I4: - case MONO_TYPE_U4: - case MONO_TYPE_R4: - m_dbgprot_buffer_add_int(&localbuf, cc->intValue); - break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - case MONO_TYPE_R8: - m_dbgprot_buffer_add_long(&localbuf, cc->longValue); - break; - case MONO_TYPE_CLASS: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_STRING: - m_dbgprot_buffer_add_id(&localbuf, cc->intValue); - break; + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_I1: + case MONO_TYPE_U1: + m_dbgprot_buffer_add_int(&localbuf, cc->booleanValue); + break; + case MONO_TYPE_CHAR: + case MONO_TYPE_I2: + case MONO_TYPE_U2: + m_dbgprot_buffer_add_int(&localbuf, cc->charValue); + break; + case MONO_TYPE_I4: + case MONO_TYPE_U4: + case MONO_TYPE_R4: + m_dbgprot_buffer_add_int(&localbuf, cc->intValue); + break; + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_R8: + m_dbgprot_buffer_add_long(&localbuf, cc->longValue); + break; + case MONO_TYPE_CLASS: + case MONO_TYPE_SZARRAY: + case MONO_TYPE_STRING: + m_dbgprot_buffer_add_id(&localbuf, cc->intValue); + break; } } - cmdId = conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_INVOKE_METHOD, &localbuf); + cmdId = conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_INVOKE_METHOD, + &localbuf); m_dbgprot_buffer_free(&localbuf); g_ptr_array_add(conn->pending_eval, this); return S_OK; @@ -87,28 +89,31 @@ void CordbEval::EvalComplete(MdbgProtBuffer *bAnswer) { HRESULT STDMETHODCALLTYPE CordbEval::CreateValueForType(ICorDebugType *pType, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbEval - CreateValueForType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbEval - CreateValueForType - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedObject( ICorDebugFunction *pConstructor, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]) { - DEBUG_PRINTF(1, "CordbEval - NewParameterizedObject - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbEval - NewParameterizedObject - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedObjectNoConstructor( ICorDebugClass *pClass, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[]) { - DEBUG_PRINTF( - 1, "CordbEval - NewParameterizedObjectNoConstructor - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbEval - NewParameterizedObjectNoConstructor - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedArray(ICorDebugType *pElementType, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]) { - DEBUG_PRINTF(1, "CordbEval - NewParameterizedArray - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbEval - NewParameterizedArray - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -118,25 +123,28 @@ HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_THREAD, + MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); int domainId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - LPSTR szString; + LPSTR szString; UTF8STR(string, szString); m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, domainId); m_dbgprot_buffer_add_string(&localbuf, szString); - this->cmdId = conn->send_event(MDBGPROT_CMD_SET_APPDOMAIN, MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); + this->cmdId = + conn->send_event(MDBGPROT_CMD_SET_APPDOMAIN, + MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); g_ptr_array_add(conn->pending_eval, this); return S_OK; } HRESULT STDMETHODCALLTYPE CordbEval::RudeAbort(void) { - DEBUG_PRINTF(1, "CordbEval - RudeAbort - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbEval - RudeAbort - NOT IMPLEMENTED\n")); return S_OK; } @@ -164,25 +172,27 @@ CordbEval::QueryInterface(REFIID id, HRESULT STDMETHODCALLTYPE CordbEval::CallFunction(ICorDebugFunction *pFunction, ULONG32 nArgs, ICorDebugValue *ppArgs[]) { - DEBUG_PRINTF(1, "CordbEval - CallFunction - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbEval - CallFunction - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbEval::NewObject(ICorDebugFunction *pConstructor, ULONG32 nArgs, ICorDebugValue *ppArgs[]) { - DEBUG_PRINTF(1, "CordbEval - NewObject - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewObject - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbEval::NewObjectNoConstructor(ICorDebugClass *pClass) { - DEBUG_PRINTF(1, "CordbEval - NewObjectNoConstructor - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbEval - NewObjectNoConstructor - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbEval::NewString(LPCWSTR string) { - DEBUG_PRINTF(1, "CordbEval - NewString - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewString - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -190,28 +200,28 @@ HRESULT STDMETHODCALLTYPE CordbEval::NewArray(CorElementType elementType, ICorDebugClass *pElementClass, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]) { - DEBUG_PRINTF(1, "CordbEval - NewArray - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewArray - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbEval::IsActive(BOOL *pbActive) { - DEBUG_PRINTF(1, "CordbEval - IsActive - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbEval - IsActive - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbEval::Abort(void) { - DEBUG_PRINTF(1, "CordbEval - Abort - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbEval - Abort - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbEval::GetResult(ICorDebugValue **ppResult) { *ppResult = ppValue; - DEBUG_PRINTF(1, "CordbEval - GetResult - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbEval - GetResult - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbEval::GetThread(ICorDebugThread **ppThread) { - DEBUG_PRINTF(1, "CordbEval - GetThread - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbEval - GetThread - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -223,7 +233,7 @@ HRESULT STDMETHODCALLTYPE CordbEval::CreateValue(CorElementType elementType, CordbValue *value = new CordbValue(conn, elementType, content_value, convert_mono_type_2_icordbg_size(elementType)); - DEBUG_PRINTF(1, "CordbEval - CreateValue - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbEval - CreateValue - IMPLEMENTED\n")); value->QueryInterface(IID_ICorDebugValue, (void **)ppValue); return S_OK; } diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index ab4ca46359ff35..f0385636d41a99 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -29,35 +29,35 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::Next(ULONG celt, for (int i = 0; i < nframes; i++) { frames[i] = this->frames[i]; } - DEBUG_PRINTF(1, "CordbFrameEnum - Next - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - Next - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbFrameEnum::Skip(ULONG celt) { - DEBUG_PRINTF(1, "CordbFrameEnum - Skip - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - Skip - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbFrameEnum::Reset(void) { - DEBUG_PRINTF(1, "CordbFrameEnum - Reset - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - Reset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbFrameEnum::Clone(ICorDebugEnum **ppEnum) { - DEBUG_PRINTF(1, "CordbFrameEnum - Clone - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - Clone - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG *pcelt) { - DEBUG_PRINTF(1, "CordbFrameEnum - GetCount - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - GetCount - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); m_dbgprot_buffer_add_int(&localbuf, 0); m_dbgprot_buffer_add_int(&localbuf, -1); - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_THREAD, + MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); @@ -65,10 +65,14 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG *pcelt) { frames = (CordbNativeFrame **)malloc(sizeof(CordbNativeFrame *) * nframes); for (int i = 0; i < nframes; i++) { - int frameid = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int methodId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int il_offset = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int flags = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int frameid = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int methodId = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int il_offset = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int flags = + m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); CordbNativeFrame *frame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, thread); @@ -84,7 +88,8 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG *pcelt) { HRESULT STDMETHODCALLTYPE CordbFrameEnum::QueryInterface(REFIID riid, void **ppvObject) { - DEBUG_PRINTF(1, "CordbFrameEnum - QueryInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrameEnum - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -104,13 +109,13 @@ CordbJITILFrame::CordbJITILFrame(Connection *conn, int frameid, int methodId, HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetChain( /* [out] */ ICorDebugChain **ppChain) { - DEBUG_PRINTF(1, "CordbFrame - GetChain - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetChain - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCode( /* [out] */ ICorDebugCode **ppCode) { - DEBUG_PRINTF(1, "CordbFrame - GetCode - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCode - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -123,13 +128,14 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunction( } *ppFunction = static_cast(func); - DEBUG_PRINTF(1, "CordbFrame - GetFunction\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetFunction - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunctionToken( /* [out] */ mdMethodDef *pToken) { - DEBUG_PRINTF(1, "CordbFrame - GetFunctionToken - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - GetFunctionToken - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -138,26 +144,27 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackRange( /* [out] */ CORDB_ADDRESS *pEnd) { *pStart = 4096; *pEnd = 8192; - DEBUG_PRINTF(1, - "CordbFrame - GetStackRange - NOT IMPLEMENTED - we need id?\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - GetStackRange - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCaller( /* [out] */ ICorDebugFrame **ppFrame) { - DEBUG_PRINTF(1, "CordbFrame - GetCaller - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCaller - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCallee( /* [out] */ ICorDebugFrame **ppFrame) { - DEBUG_PRINTF(1, "CordbFrame - GetCallee - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCallee - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::CreateStepper( /* [out] */ ICorDebugStepper **ppStepper) { - DEBUG_PRINTF(1, "CordbFrame - CreateStepper - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - CreateStepper - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -174,41 +181,42 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::QueryInterface( *pInterface = static_cast(this); } else { *pInterface = NULL; - - DEBUG_PRINTF(1, "CordbFrame - QueryInterface - E_NOTIMPL\n"); - return E_NOINTERFACE; } - DEBUG_PRINTF(1, "CordbFrame - QueryInterface - IMPLEMENTED\n"); return S_OK; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::RemapFunction(ULONG32 newILOffset) { - DEBUG_PRINTF(1, "CordbFrame - RemapFunction - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - RemapFunction - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum) { - DEBUG_PRINTF(1, "CordbFrame - EnumerateTypeParameters - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - EnumerateTypeParameters - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetReturnValueForILOffset( ULONG32 ILoffset, ICorDebugValue **ppReturnValue) { - DEBUG_PRINTF(1, "CordbFrame - GetReturnValueForILOffset - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - GetReturnValueForILOffset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariablesEx( ILCodeKind flags, ICorDebugValueEnum **ppValueEnum) { - DEBUG_PRINTF(1, "CordbFrame - EnumerateLocalVariablesEx - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - EnumerateLocalVariablesEx - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariableEx( ILCodeKind flags, DWORD dwIndex, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbFrame - GetLocalVariableEx - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - GetLocalVariableEx - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -220,7 +228,8 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCodeEx(ILCodeKind flags, CordbCode *code = new CordbCode(conn, NULL); *ppCode = static_cast(code); } - DEBUG_PRINTF(1, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n")); return S_OK; } @@ -233,19 +242,20 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetIP( /* [out] */ CorDebugMappingResult *pMappingResult) { *pnOffset = il_offset; *pMappingResult = MAPPING_EXACT; - DEBUG_PRINTF(1, "CordbFrame - GetIP - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetIP - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::SetIP( /* [in] */ ULONG32 nOffset) { - DEBUG_PRINTF(1, "CordbFrame - SetIP - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - SetIP - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariables( /* [out] */ ICorDebugValueEnum **ppValueEnum) { - DEBUG_PRINTF(1, "CordbFrame - EnumerateLocalVariables - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - EnumerateLocalVariables - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -259,8 +269,8 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariable( m_dbgprot_buffer_add_int(&localbuf, 1); m_dbgprot_buffer_add_int(&localbuf, dwIndex); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_STACK_FRAME, MDBGPROT_CMD_STACK_FRAME_GET_VALUES, - &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_STACK_FRAME, + MDBGPROT_CMD_STACK_FRAME_GET_VALUES, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); @@ -269,7 +279,8 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariable( HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateArguments( /* [out] */ ICorDebugValueEnum **ppValueEnum) { - DEBUG_PRINTF(1, "CordbFrame - EnumerateArguments - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - EnumerateArguments - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -282,32 +293,34 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetArgument( m_dbgprot_buffer_add_id(&localbuf, frameid); m_dbgprot_buffer_add_int(&localbuf, dwIndex); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_STACK_FRAME, - MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_STACK_FRAME, + MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - DEBUG_PRINTF(1, "CordbFrame - GetArgument - IMPLEMENTED - dwIndex - %d\n", - dwIndex); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetArgument - IMPLEMENTED\n")); return CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackDepth( /* [out] */ ULONG32 *pDepth) { - DEBUG_PRINTF(1, "CordbFrame - GetStackDepth - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - GetStackDepth - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackValue( /* [in] */ DWORD dwIndex, /* [out] */ ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbFrame - GetStackValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFrame - GetStackValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::CanSetIP( /* [in] */ ULONG32 nOffset) { - DEBUG_PRINTF(1, "CordbFrame - CanSetIP - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - CanSetIP - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -321,12 +334,14 @@ CordbNativeFrame::CordbNativeFrame(Connection *conn, int frameid, int methodId, } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetIP(ULONG32 *pnOffset) { - DEBUG_PRINTF(1, "CordbNativeFrame - GetIP - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetIP - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::SetIP(ULONG32 nOffset) { - DEBUG_PRINTF(1, "CordbNativeFrame - SetIP - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - SetIP - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -338,56 +353,59 @@ CordbNativeFrame::GetRegisterSet(ICorDebugRegisterSet **ppRegisters) { HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterValue( CorDebugRegister reg, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, - "CordbNativeFrame - GetLocalRegisterValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetLocalRegisterValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalDoubleRegisterValue( CorDebugRegister highWordReg, CorDebugRegister lowWordReg, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { - DEBUG_PRINTF( - 1, "CordbNativeFrame - GetLocalDoubleRegisterValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetLocalDoubleRegisterValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalMemoryValue( CORDB_ADDRESS address, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbNativeFrame - GetLocalMemoryValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetLocalMemoryValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterMemoryValue( CorDebugRegister highWordReg, CORDB_ADDRESS lowWordAddress, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { - DEBUG_PRINTF( - 1, "CordbNativeFrame - GetLocalRegisterMemoryValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetLocalRegisterMemoryValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalMemoryRegisterValue( CORDB_ADDRESS highWordAddress, CorDebugRegister lowWordRegister, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { - DEBUG_PRINTF( - 1, "CordbNativeFrame - GetLocalMemoryRegisterValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetLocalMemoryRegisterValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::CanSetIP(ULONG32 nOffset) { - DEBUG_PRINTF(1, "CordbNativeFrame - CanSetIP - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - CanSetIP - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetChain(ICorDebugChain **ppChain) { - DEBUG_PRINTF(1, "CordbNativeFrame - GetChain - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetChain - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCode(ICorDebugCode **ppCode) { CordbCode *code = new CordbCode(conn, NULL); *ppCode = static_cast(code); - DEBUG_PRINTF(1, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n")); return S_OK; } @@ -398,7 +416,8 @@ CordbNativeFrame::GetFunction(ICorDebugFunction **ppFunction) { HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetFunctionToken(mdMethodDef *pToken) { - DEBUG_PRINTF(1, "CordbNativeFrame - GetFunctionToken - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetFunctionToken - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -409,19 +428,22 @@ HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetStackRange(CORDB_ADDRESS *pStart, HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCaller(ICorDebugFrame **ppFrame) { - DEBUG_PRINTF(1, "CordbNativeFrame - GetCaller - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetCaller - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCallee(ICorDebugFrame **ppFrame) { - DEBUG_PRINTF(1, "CordbNativeFrame - GetCallee - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetCallee - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::CreateStepper(ICorDebugStepper **ppStepper) { - DEBUG_PRINTF(1, "CordbNativeFrame - CreateStepper - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - CreateStepper - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -456,20 +478,21 @@ ULONG STDMETHODCALLTYPE CordbNativeFrame::AddRef(void) { return 0; } ULONG STDMETHODCALLTYPE CordbNativeFrame::Release(void) { return 0; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsChild(BOOL *pIsChild) { - DEBUG_PRINTF(1, "CordbNativeFrame - IsChild - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - IsChild - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsMatchingParentFrame( ICorDebugNativeFrame2 *pPotentialParentFrame, BOOL *pIsParent) { - DEBUG_PRINTF(1, - "CordbNativeFrame - IsMatchingParentFrame - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - IsMatchingParentFrame - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetStackParameterSize(ULONG32 *pSize) { - DEBUG_PRINTF(1, - "CordbNativeFrame - GetStackParameterSize - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbNativeFrame - GetStackParameterSize - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-function.cpp b/src/mono/dbi/cordb-function.cpp index 43be2d53755a05..1af5d678f37282 100644 --- a/src/mono/dbi/cordb-function.cpp +++ b/src/mono/dbi/cordb-function.cpp @@ -55,29 +55,20 @@ HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule **ppModule) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, id); - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); m_dbgprot_buffer_free(&localbuf); - DEBUG_PRINTF( - 1, "CordbFunction - GetModule - IMPLEMENTED - ENTREI NO 0.1 - %d\n", - id); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int module_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - - DEBUG_PRINTF( - 1, "CordbFunction - GetModule - IMPLEMENTED - ENTREI NO 0.2 - %d\n", - module_id); + int module_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); module = (CordbModule *)g_hash_table_lookup(conn->ppCordb->modules, GINT_TO_POINTER(module_id)); } *ppModule = static_cast(this->module); - DEBUG_PRINTF(1, "CordbFunction - GetModule - IMPLEMENTED - %p\n", - this->module); if (!*ppModule) return S_FALSE; @@ -85,29 +76,26 @@ HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule **ppModule) { } HRESULT __stdcall CordbFunction::GetClass(ICorDebugClass **ppClass) { - DEBUG_PRINTF(1, "CordbFunction - GetClass - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunction - GetClass - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbFunction::GetToken(mdMethodDef *pMethodDef) { if (this->token == 0) { - DEBUG_PRINTF( - 1, "CordbFunction - GetToken - IMPLEMENTED - ENTREI NO 0 - %d\n", id); + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetToken - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_TOKEN, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_TOKEN, &localbuf); m_dbgprot_buffer_free(&localbuf); - - DEBUG_PRINTF( - 1, "CordbFunction - GetToken - IMPLEMENTED - ENTREI NO 0.1 - %d\n", id); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - this->token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + this->token = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); } *pMethodDef = this->token; - DEBUG_PRINTF(1, "CordbFunction - GetToken - IMPLEMENTED - %d\n", *pMethodDef); return S_OK; } @@ -115,65 +103,74 @@ HRESULT __stdcall CordbFunction::GetILCode(ICorDebugCode **ppCode) { if (code == NULL) code = new CordbCode(conn, this); *ppCode = static_cast(code); - DEBUG_PRINTF(1, "CordbFunction - GetILCode - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetILCode - IMPLEMENTED\n")); return S_OK; } HRESULT __stdcall CordbFunction::GetNativeCode(ICorDebugCode **ppCode) { *ppCode = static_cast(code); - DEBUG_PRINTF(1, "CordbFunction - GetNativeCode - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbFunction - GetNativeCode - IMPLEMENTED\n")); return S_OK; } HRESULT __stdcall CordbFunction::CreateBreakpoint( ICorDebugFunctionBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, "CordbFunction - CreateBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunction - CreateBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbFunction::GetLocalVarSigToken(mdSignature *pmdSig) { - DEBUG_PRINTF(1, "CordbFunction - GetLocalVarSigToken - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunction - GetLocalVarSigToken - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbFunction::GetCurrentVersionNumber( ULONG32 *pnCurrentVersion) { *pnCurrentVersion = 1; - DEBUG_PRINTF(1, "CordbFunction - GetCurrentVersionNumber - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbFunction - GetCurrentVersionNumber - IMPLEMENTED\n")); return S_OK; } HRESULT __stdcall CordbFunction::SetJMCStatus(BOOL bIsJustMyCode) { - DEBUG_PRINTF(1, "CordbFunction - SetJMCStatus - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunction - SetJMCStatus - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbFunction::GetJMCStatus(BOOL *pbIsJustMyCode) { - DEBUG_PRINTF(1, "CordbFunction - GetJMCStatus - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunction - GetJMCStatus - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbFunction::EnumerateNativeCode( ICorDebugCodeEnum **ppCodeEnum) { - DEBUG_PRINTF(1, "CordbFunction - EnumerateNativeCode - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunction - EnumerateNativeCode - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbFunction::GetVersionNumber(ULONG32 *pnVersion) { *pnVersion = 1; - DEBUG_PRINTF(1, "CordbFunction - GetVersionNumber - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbFunction - GetVersionNumber - IMPLEMENTED\n")); return S_OK; } HRESULT __stdcall CordbFunction::GetActiveReJitRequestILCode( ICorDebugILCode **ppReJitedILCode) { - DEBUG_PRINTF( - 1, "CordbFunction - GetActiveReJitRequestILCode - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunction - GetActiveReJitRequestILCode - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbFunction::CreateNativeBreakpoint( ICorDebugFunctionBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, "CordbFunction - CreateNativeBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbFunction - CreateNativeBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index 05d6b750e75e9f..f9628d03e0e935 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -24,112 +24,125 @@ CordbProcess::CordbProcess() : CordbBaseMono(NULL) { HRESULT CordbProcess::EnumerateLoaderHeapMemoryRegions( /* [out] */ ICorDebugMemoryRangeEnum **ppRanges) { - DEBUG_PRINTF( - 1, "CordbProcess - EnumerateLoaderHeapMemoryRegions - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnumerateLoaderHeapMemoryRegions - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnableGCNotificationEvents(BOOL fEnable) { - DEBUG_PRINTF(1, - "CordbProcess - EnableGCNotificationEvents - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnableGCNotificationEvents - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnableExceptionCallbacksOutsideOfMyCode( /* [in] */ BOOL enableExceptionsOutsideOfJMC) { - DEBUG_PRINTF(1, "CordbProcess - EnableExceptionCallbacksOutsideOfMyCode - " - "NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnableExceptionCallbacksOutsideOfMyCode - " + "NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::SetWriteableMetadataUpdateMode( WriteableMetadataUpdateMode flags) { - DEBUG_PRINTF( - 1, "CordbProcess - SetWriteableMetadataUpdateMode - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - SetWriteableMetadataUpdateMode - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetGCHeapInformation( /* [out] */ COR_HEAPINFO *pHeapInfo) { - DEBUG_PRINTF(1, "CordbProcess - GetGCHeapInformation - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetGCHeapInformation - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnumerateHeap( /* [out] */ ICorDebugHeapEnum **ppObjects) { - DEBUG_PRINTF(1, "CordbProcess - EnumerateHeap - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnumerateHeap - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnumerateHeapRegions( /* [out] */ ICorDebugHeapSegmentEnum **ppRegions) { - DEBUG_PRINTF(1, "CordbProcess - EnumerateHeapRegions - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnumerateHeapRegions - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetObject( /* [in] */ CORDB_ADDRESS addr, /* [out] */ ICorDebugObjectValue **pObject) { - DEBUG_PRINTF(1, "CordbProcess - GetObject - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetObject - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnumerateGCReferences( /* [in] */ BOOL enumerateWeakReferences, /* [out] */ ICorDebugGCReferenceEnum **ppEnum) { - DEBUG_PRINTF(1, "CordbProcess - EnumerateGCReferences - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnumerateGCReferences - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnumerateHandles( /* [in] */ CorGCReferenceType types, /* [out] */ ICorDebugGCReferenceEnum **ppEnum) { - DEBUG_PRINTF(1, "CordbProcess - EnumerateHandles - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnumerateHandles - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetTypeID( /* [in] */ CORDB_ADDRESS obj, /* [out] */ COR_TYPEID *pId) { - DEBUG_PRINTF(1, "CordbProcess - GetTypeID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetTypeID - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetTypeForTypeID( /* [in] */ COR_TYPEID id, /* [out] */ ICorDebugType **ppType) { - DEBUG_PRINTF(1, "CordbProcess - GetTypeForTypeID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetTypeForTypeID - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetArrayLayout( /* [in] */ COR_TYPEID id, /* [out] */ COR_ARRAY_LAYOUT *pLayout) { - DEBUG_PRINTF(1, "CordbProcess - GetArrayLayout - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetArrayLayout - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetTypeLayout( /* [in] */ COR_TYPEID id, /* [out] */ COR_TYPE_LAYOUT *pLayout) { - DEBUG_PRINTF(1, "CordbProcess - GetTypeLayout - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetTypeLayout - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetTypeFields( /* [in] */ COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], ULONG32 *pceltNeeded) { - DEBUG_PRINTF(1, "CordbProcess - GetTypeFields - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetTypeFields - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnableNGENPolicy( /* [in] */ CorDebugNGENPolicy ePolicy) { - DEBUG_PRINTF(1, "CordbProcess - EnableNGENPolicy - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnableNGENPolicy - NOT IMPLEMENTED\n")); return S_OK; } @@ -141,59 +154,65 @@ HRESULT CordbProcess::Filter( /* [in] */ DWORD dwThreadId, /* [in] */ ICorDebugManagedCallback *pCallback, /* [out][in] */ CORDB_CONTINUE_STATUS *pContinueStatus) { - DEBUG_PRINTF(1, "CordbProcess - Filter - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - Filter - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::ProcessStateChanged( /* [in] */ CorDebugStateChange eChange) { - DEBUG_PRINTF(1, "CordbProcess - ProcessStateChanged - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - ProcessStateChanged - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::SetEnableCustomNotification(ICorDebugClass *pClass, BOOL fEnable) { - DEBUG_PRINTF( - 1, "CordbProcess - SetEnableCustomNotification - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - SetEnableCustomNotification - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetID( /* [out] */ DWORD *pdwProcessId) { - DEBUG_PRINTF(1, "CordbProcess - GetID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetID - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetHandle( /* [out] */ HPROCESS *phProcessHandle) { - DEBUG_PRINTF(1, "CordbProcess - GetHandle - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetHandle - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetThread( /* [in] */ DWORD dwThreadId, /* [out] */ ICorDebugThread **ppThread) { - DEBUG_PRINTF(1, "CordbProcess - GetThread - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetThread - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnumerateObjects( /* [out] */ ICorDebugObjectEnum **ppObjects) { - DEBUG_PRINTF(1, "CordbProcess - EnumerateObjects - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnumerateObjects - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::IsTransitionStub( /* [in] */ CORDB_ADDRESS address, /* [out] */ BOOL *pbTransitionStub) { - DEBUG_PRINTF(1, "CordbProcess - IsTransitionStub - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - IsTransitionStub - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::IsOSSuspended( /* [in] */ DWORD threadID, /* [out] */ BOOL *pbSuspended) { - DEBUG_PRINTF(1, "CordbProcess - IsOSSuspended - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - IsOSSuspended - NOT IMPLEMENTED\n")); return S_OK; } @@ -201,7 +220,8 @@ HRESULT CordbProcess::GetThreadContext( /* [in] */ DWORD threadID, /* [in] */ ULONG32 contextSize, /* [size_is][length_is][out][in] */ BYTE context[]) { - DEBUG_PRINTF(1, "CordbProcess - GetThreadContext - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetThreadContext - NOT IMPLEMENTED\n")); return S_OK; } @@ -209,7 +229,8 @@ HRESULT CordbProcess::SetThreadContext( /* [in] */ DWORD threadID, /* [in] */ ULONG32 contextSize, /* [size_is][length_is][in] */ BYTE context[]) { - DEBUG_PRINTF(1, "CordbProcess - SetThreadContext - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - SetThreadContext - NOT IMPLEMENTED\n")); return S_OK; } @@ -221,7 +242,7 @@ HRESULT CordbProcess::ReadMemory( memcpy(buffer, (void *)address, size); if (read != NULL) *read = size; - DEBUG_PRINTF(1, "CordbProcess - ReadMemory - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - ReadMemory - IMPLEMENTED\n")); return S_OK; } @@ -230,19 +251,22 @@ HRESULT CordbProcess::WriteMemory( /* [in] */ DWORD size, /* [size_is][in] */ BYTE buffer[], /* [out] */ SIZE_T *written) { - DEBUG_PRINTF(1, "CordbProcess - WriteMemory - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - WriteMemory - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::ClearCurrentException( /* [in] */ DWORD threadID) { - DEBUG_PRINTF(1, "CordbProcess - ClearCurrentException - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - ClearCurrentException - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnableLogMessages( /* [in] */ BOOL fOnOff) { - DEBUG_PRINTF(1, "CordbProcess - EnableLogMessages - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnableLogMessages - NOT IMPLEMENTED\n")); return S_OK; } @@ -250,46 +274,52 @@ HRESULT CordbProcess::ModifyLogSwitch( /* [annotation][in] */ _In_ WCHAR *pLogSwitchName, /* [in] */ LONG lLevel) { - DEBUG_PRINTF(1, "CordbProcess - ModifyLogSwitch - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - ModifyLogSwitch - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnumerateAppDomains( /* [out] */ ICorDebugAppDomainEnum **ppAppDomains) { *ppAppDomains = new CordbAppDomainEnum(conn, this); - DEBUG_PRINTF(1, "CordbProcess - EnumerateAppDomains - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbProcess - EnumerateAppDomains - IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetObject( /* [out] */ ICorDebugValue **ppObject) { - DEBUG_PRINTF(1, "CordbProcess - GetObject - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetObject - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::ThreadForFiberCookie( /* [in] */ DWORD fiberCookie, /* [out] */ ICorDebugThread **ppThread) { - DEBUG_PRINTF(1, "CordbProcess - ThreadForFiberCookie - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - ThreadForFiberCookie - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetHelperThreadID( /* [out] */ DWORD *pThreadID) { - DEBUG_PRINTF(1, "GetHelperThreadID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "GetHelperThreadID - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetThreadForTaskID( /* [in] */ TASKID taskid, /* [out] */ ICorDebugThread2 **ppThread) { - DEBUG_PRINTF(1, "CordbProcess - GetHelperThreadID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetHelperThreadID - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetVersion( /* [out] */ COR_VERSION *version) { - DEBUG_PRINTF(1, "CordbProcess - GetVersion - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetVersion - NOT IMPLEMENTED\n")); return S_OK; } @@ -298,36 +328,37 @@ HRESULT CordbProcess::SetUnmanagedBreakpoint( /* [in] */ ULONG32 bufsize, /* [length_is][size_is][out] */ BYTE buffer[], /* [out] */ ULONG32 *bufLen) { - DEBUG_PRINTF(1, "CordbProcess - SetUnmanagedBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - SetUnmanagedBreakpoint - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::ClearUnmanagedBreakpoint( /* [in] */ CORDB_ADDRESS address) { - DEBUG_PRINTF(1, - "CordbProcess - ClearUnmanagedBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - ClearUnmanagedBreakpoint - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::SetDesiredNGENCompilerFlags( /* [in] */ DWORD pdwFlags) { - DEBUG_PRINTF( - 1, "CordbProcess - SetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - SetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetDesiredNGENCompilerFlags( /* [out] */ DWORD *pdwFlags) { - DEBUG_PRINTF( - 1, "CordbProcess - GetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetReferenceValueFromGCHandle( /* [in] */ UINT_PTR handle, /* [out] */ ICorDebugReferenceValue **pOutValue) { - DEBUG_PRINTF( - 1, "CordbProcess - GetReferenceValueFromGCHandle - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - GetReferenceValueFromGCHandle - NOT IMPLEMENTED\n")); return S_OK; } @@ -361,8 +392,6 @@ HRESULT CordbProcess::QueryInterface( } else { - DEBUG_PRINTF(1, "CordbProcess - QueryInterface - E_NOTIMPL\n"); - *pInterface = NULL; return E_NOINTERFACE; } @@ -376,7 +405,7 @@ ULONG CordbProcess::Release(void) { return S_OK; } HRESULT CordbProcess::Stop( /* [in] */ DWORD dwTimeoutIgnored) { - DEBUG_PRINTF(1, "CordbProcess - Stop - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - Stop - IMPLEMENTED\n")); MdbgProtBuffer sendbuf; m_dbgprot_buffer_init(&sendbuf, 128); conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SUSPEND, &sendbuf); @@ -386,7 +415,7 @@ HRESULT CordbProcess::Stop( HRESULT CordbProcess::Continue( /* [in] */ BOOL fIsOutOfBand) { - DEBUG_PRINTF(1, "CordbProcess - Continue - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - Continue - IMPLEMENTED\n")); MdbgProtBuffer sendbuf; m_dbgprot_buffer_init(&sendbuf, 128); conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_RESUME, &sendbuf); @@ -396,7 +425,8 @@ HRESULT CordbProcess::Continue( HRESULT CordbProcess::IsRunning( /* [out] */ BOOL *pbRunning) { *pbRunning = true; - DEBUG_PRINTF(1, "CordbProcess - IsRunning - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - IsRunning - NOT IMPLEMENTED\n")); return S_OK; } @@ -405,42 +435,46 @@ HRESULT CordbProcess::HasQueuedCallbacks( /* [out] */ BOOL *pbQueued) { // conn->process_packet_from_queue(); *pbQueued = false; - DEBUG_PRINTF(1, "CordbProcess - HasQueuedCallbacks - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbProcess - HasQueuedCallbacks - IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::EnumerateThreads( /* [out] */ ICorDebugThreadEnum **ppThreads) { - DEBUG_PRINTF(1, "CordbProcess - EnumerateThreads - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnumerateThreads - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::SetAllThreadsDebugState( /* [in] */ CorDebugThreadState state, /* [in] */ ICorDebugThread *pExceptThisThread) { - DEBUG_PRINTF(1, "CordbProcess - SetAllThreadsDebugState - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::Detach(void) { - DEBUG_PRINTF(1, "CordbProcess - Detach - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - Detach - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::Terminate( /* [in] */ UINT exitCode) { - MdbgProtBuffer sendbuf; - m_dbgprot_buffer_init(&sendbuf, 128); - m_dbgprot_buffer_add_int(&sendbuf, -1); - conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_EXIT, &sendbuf); - return S_OK; + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, 128); + m_dbgprot_buffer_add_int(&sendbuf, -1); + conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_EXIT, &sendbuf); + return S_OK; } HRESULT CordbProcess::CanCommitChanges( /* [in] */ ULONG cSnapshots, /* [size_is][in] */ ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ ICorDebugErrorInfoEnum **pError) { - DEBUG_PRINTF(1, "CordbProcess - CanCommitChanges - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - CanCommitChanges - NOT IMPLEMENTED\n")); return S_OK; } @@ -448,6 +482,7 @@ HRESULT CordbProcess::CommitChanges( /* [in] */ ULONG cSnapshots, /* [size_is][in] */ ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ ICorDebugErrorInfoEnum **pError) { - DEBUG_PRINTF(1, "CordbProcess - CommitChanges - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - CommitChanges - NOT IMPLEMENTED\n")); return S_OK; } diff --git a/src/mono/dbi/cordb-register.cpp b/src/mono/dbi/cordb-register.cpp index c2c9d87cbf86a3..55c5fc6864b7bc 100644 --- a/src/mono/dbi/cordb-register.cpp +++ b/src/mono/dbi/cordb-register.cpp @@ -19,8 +19,8 @@ using namespace std; HRESULT __stdcall CordbRegisteSet::GetRegistersAvailable(ULONG64 *pAvailable) { - DEBUG_PRINTF(1, - "CordbRegisteSet - GetRegistersAvailable - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbRegisteSet - GetRegistersAvailable - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -32,13 +32,15 @@ CordbRegisteSet::CordbRegisteSet(Connection *conn, guint8 *ctx, guint32 ctx_len) HRESULT __stdcall CordbRegisteSet::QueryInterface(REFIID id, void **pInterface) { - DEBUG_PRINTF(1, "CordbRegisteSet - QueryInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbRegisteSet - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT __stdcall CordbRegisteSet::GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]) { - DEBUG_PRINTF(1, "CordbRegisteSet - GetRegisters - NOT IMPLEMENTED"); + LOG((LF_CORDB, LL_INFO100000, + "CordbRegisteSet - GetRegisters - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -50,20 +52,23 @@ HRESULT STDMETHODCALLTYPE CordbRegisteSet::SetRegisters( /* [in] */ ULONG64 mask, /* [in] */ ULONG32 regCount, /* [size_is][in] */ CORDB_REGISTER regBuffer[]) { - DEBUG_PRINTF(1, "CordbRegisteSet - SetRegisters - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbRegisteSet - SetRegisters - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbRegisteSet::GetThreadContext( /* [in] */ ULONG32 contextSize, /* [size_is][length_is][out][in] */ BYTE context[]) { - DEBUG_PRINTF(1, "CordbRegisteSet - GetThreadContext - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbRegisteSet - GetThreadContext - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbRegisteSet::SetThreadContext( /* [in] */ ULONG32 contextSize, /* [size_is][length_is][in] */ BYTE context[]) { - DEBUG_PRINTF(1, "CordbRegisteSet - SetThreadContext - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbRegisteSet - SetThreadContext - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index 088a0c3608a130..18f9552f026764 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -24,35 +24,38 @@ CordbStepper::CordbStepper(Connection *conn, CordbThread *thread) } HRESULT STDMETHODCALLTYPE CordbStepper::IsActive(BOOL *pbActive) { - DEBUG_PRINTF(1, "CordbStepper - IsActive - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - IsActive - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbStepper::Deactivate(void) { - DEBUG_PRINTF(1, "CordbStepper - Deactivate - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - Deactivate - IMPLEMENTED\n")); MdbgProtBuffer sendbuf; int buflen = 128; m_dbgprot_buffer_init(&sendbuf, buflen); m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); m_dbgprot_buffer_add_int(&sendbuf, eventId); - conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_CLEAR, &sendbuf); + conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, + MDBGPROT_CMD_EVENT_REQUEST_CLEAR, &sendbuf); return S_OK; } HRESULT STDMETHODCALLTYPE CordbStepper::SetInterceptMask(CorDebugIntercept mask) { - DEBUG_PRINTF(1, "CordbStepper - SetInterceptMask - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbStepper - SetInterceptMask - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbStepper::SetUnmappedStopMask(CorDebugUnmappedStop mask) { - DEBUG_PRINTF(1, "CordbStepper - SetUnmappedStopMask - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbStepper - SetUnmappedStopMask - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbStepper::Step(BOOL bStepIn) { - DEBUG_PRINTF(1, "CordbStepper - Step - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - Step - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -71,15 +74,17 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, m_dbgprot_buffer_add_id(&sendbuf, thread->thread_id); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); - m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO : MDBGPROT_STEP_DEPTH_OVER); + m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO + : MDBGPROT_STEP_DEPTH_OVER); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, + MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); - MdbgProtBuffer* bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); eventId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "CordbStepper - StepRange - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepRange - IMPLEMENTED\n")); return S_OK; } @@ -99,38 +104,41 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_DEPTH_OUT); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, + MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); m_dbgprot_buffer_free(&sendbuf); - MdbgProtBuffer* bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - DEBUG_PRINTF(1, "CordbStepper - StepOut - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepOut - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbStepper::SetRangeIL(BOOL bIL) { - DEBUG_PRINTF(1, "CordbStepper - SetRangeIL - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbStepper - SetRangeIL - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbStepper::QueryInterface(REFIID riid, void **ppvObject) { - DEBUG_PRINTF(1, "CordbStepper - QueryInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbStepper - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } ULONG STDMETHODCALLTYPE CordbStepper::AddRef(void) { - DEBUG_PRINTF(1, "CordbStepper - AddRef - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - AddRef - NOT IMPLEMENTED\n")); return E_NOTIMPL; } ULONG STDMETHODCALLTYPE CordbStepper::Release(void) { - DEBUG_PRINTF(1, "CordbStepper - Release - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - Release - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbStepper::SetJMC(BOOL fIsJMCStepper) { - DEBUG_PRINTF(1, "CordbStepper - SetJMC - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - SetJMC - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-symbol.cpp b/src/mono/dbi/cordb-symbol.cpp index d076bbf364d848..9922866ccfc826 100644 --- a/src/mono/dbi/cordb-symbol.cpp +++ b/src/mono/dbi/cordb-symbol.cpp @@ -6,30 +6,28 @@ #include -#include "stdafx.h" #include "corerror.h" -#include "rwutil.h" #include "mdlog.h" -#include "switches.h" #include "posterror.h" -#include "stgio.h" +#include "rwutil.h" #include "sstring.h" +#include "stdafx.h" +#include "stgio.h" +#include "switches.h" -#include "mdinternalrw.h" #include "importhelper.h" - +#include "mdinternalrw.h" #include -#include +#include #include -#include +#include +#include #include #include -#include -#include -#include - +#include +#include using namespace std; @@ -224,8 +222,8 @@ HRESULT RegMeta::EnumGenericParamConstraints( rGenericParamConstraints[], // [OUT] Put GenericParamConstraints here. ULONG cMax, // [IN] Max GenericParamConstraints to put. ULONG *pcGenericParamConstraints) { - DEBUG_PRINTF(1, - "CordbSymbol - EnumGenericParamConstraints - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumGenericParamConstraints - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] Put # put here. @@ -233,8 +231,8 @@ HRESULT RegMeta::GetGenericParamConstraintProps( // S_OK or error. mdGenericParamConstraint gpc, // [IN] GenericParamConstraint mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained mdToken *ptkConstraintType) { - DEBUG_PRINTF( - 1, "CordbSymbol - GetGenericParamConstraintProps - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetGenericParamConstraintProps - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] TypeDef/Ref/Spec constraint @@ -297,7 +295,8 @@ HRESULT RegMeta::EnumMethodSpecs( mdMethodSpec rMethodSpecs[], // [OUT] Put MethodSpecs here. ULONG cMax, // [IN] Max tokens to put. ULONG *pcMethodSpecs) { - DEBUG_PRINTF(1, "CordbSymbol - EnumMethodSpecs - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumMethodSpecs - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] Put actual count here. @@ -306,10 +305,10 @@ HRESULT RegMeta::GetAssemblyProps( // S_OK or error. const void **ppbPublicKey, // [OUT] Pointer to the public key. ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. ULONG *pulHashAlgId, // [OUT] Hash Algorithm. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. + _Out_writes_to_opt_(cchName, *pchName) LPWSTR + szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. DWORD *pdwAssemblyFlags) { HRESULT hr = S_OK; @@ -423,7 +422,8 @@ HRESULT RegMeta::GetFileProps( // S_OK or error. const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob. ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob. DWORD *pdwFileFlags) { - DEBUG_PRINTF(1, "CordbSymbol - GetFileProps - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetFileProps - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] Flags. @@ -504,7 +504,8 @@ HRESULT RegMeta::GetManifestResourceProps( // S_OK or error. DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within // the file. DWORD *pdwResourceFlags) { - DEBUG_PRINTF(1, "CordbSymbol - GetManifestResourceProps - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetManifestResourceProps - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] Flags. @@ -513,7 +514,8 @@ HRESULT RegMeta::EnumAssemblyRefs( // S_OK or error mdAssemblyRef rAssemblyRefs[], // [OUT] Put AssemblyRefs here. ULONG cMax, // [IN] Max AssemblyRefs to put. ULONG *pcTokens) { - DEBUG_PRINTF(1, "CordbSymbol - EnumAssemblyRefs - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumAssemblyRefs - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] Put # put here. @@ -607,7 +609,8 @@ HRESULT RegMeta::EnumManifestResources( // S_OK or error rManifestResources[], // [OUT] Put ManifestResources here. ULONG cMax, // [IN] Max Resources to put. ULONG *pcTokens) { - DEBUG_PRINTF(1, "CordbSymbol - EnumManifestResources - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumManifestResources - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] Put # put here. @@ -615,15 +618,16 @@ HRESULT RegMeta::FindExportedTypeByName( // S_OK or error LPCWSTR szName, // [IN] Name of the ExportedType. mdToken mdtExportedType, // [IN] ExportedType for the enclosing class. mdExportedType *ptkExportedType) { - DEBUG_PRINTF(1, "CordbSymbol - FindExportedTypeByName - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - FindExportedTypeByName - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] Put the ExportedType token here. HRESULT RegMeta::FindManifestResourceByName( // S_OK or error LPCWSTR szName, // [IN] Name of the ManifestResource. mdManifestResource *ptkManifestResource) { - DEBUG_PRINTF(1, - "CordbSymbol - FindManifestResourceByName - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - FindManifestResourceByName - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] Put the ManifestResource token here. @@ -635,7 +639,8 @@ HRESULT RegMeta::FindAssembliesByName( // S_OK or error IUnknown *ppIUnk[], // [OUT] put IMetaDataAssemblyImport pointers here ULONG cMax, // [IN] The max number to put ULONG *pcAssemblies) { - DEBUG_PRINTF(1, "CordbSymbol - FindAssembliesByName - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - FindAssembliesByName - NOT IMPLEMENTED\n")); return S_OK; } // [OUT] The number of assemblies returned. @@ -703,7 +708,7 @@ HRESULT RegMeta::CountEnum(HCORENUM hEnum, ULONG *pulCount) { } HRESULT RegMeta::ResetEnum(HCORENUM hEnum, ULONG ulPos) { - DEBUG_PRINTF(1, "CordbSymbol - ResetEnum - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbSymbol - ResetEnum - NOT IMPLEMENTED\n")); return S_OK; } @@ -789,7 +794,8 @@ HRESULT RegMeta::EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td, HRESULT RegMeta::EnumTypeRefs(HCORENUM *phEnum, mdTypeRef rTypeRefs[], ULONG cMax, ULONG *pcTypeRefs) { - DEBUG_PRINTF(1, "CordbSymbol - EnumTypeRefs - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumTypeRefs - NOT IMPLEMENTED\n")); return S_OK; } @@ -853,7 +859,8 @@ HRESULT RegMeta::GetScopeProps( // S_OK or error. HRESULT RegMeta::GetModuleFromScope( // S_OK. mdModule *pmd) // [OUT] Put mdModule token here. { - DEBUG_PRINTF(1, "CordbSymbol - GetModuleFromScope - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetModuleFromScope - NOT IMPLEMENTED\n")); return S_OK; } @@ -1040,7 +1047,8 @@ HRESULT RegMeta::GetTypeRefProps( // S_OK or error. HRESULT RegMeta::ResolveTypeRef(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, mdTypeDef *ptd) { - DEBUG_PRINTF(1, "CordbSymbol - ResolveTypeRef - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - ResolveTypeRef - NOT IMPLEMENTED\n")); return S_OK; } @@ -1051,7 +1059,8 @@ HRESULT RegMeta::EnumMembers( // S_OK, S_FALSE, or error. ULONG cMax, // [IN] Max MemberDefs to put. ULONG *pcTokens) // [OUT] Put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumMembers - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumMembers - NOT IMPLEMENTED\n")); return S_OK; } @@ -1063,7 +1072,8 @@ HRESULT RegMeta::EnumMembersWithName( // S_OK, S_FALSE, or error. ULONG cMax, // [IN] Max MemberDefs to put. ULONG *pcTokens) // [OUT] Put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumMembersWithName - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumMembersWithName - NOT IMPLEMENTED\n")); return S_OK; } @@ -1147,7 +1157,8 @@ HRESULT RegMeta::EnumMethodsWithName( // S_OK, S_FALSE, or error. ULONG cMax, // [IN] Max MethodDefs to put. ULONG *pcTokens) // [OUT] Put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumMethodsWithName - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumMethodsWithName - NOT IMPLEMENTED\n")); return S_OK; } @@ -1355,7 +1366,8 @@ HRESULT RegMeta::EnumMemberRefs( // S_OK, S_FALSE, or error. ULONG cMax, // [IN] Max MemberRefs to put. ULONG *pcTokens) // [OUT] Put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumMemberRefs - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumMemberRefs - NOT IMPLEMENTED\n")); return S_OK; } @@ -1367,7 +1379,8 @@ HRESULT RegMeta::EnumMethodImpls( // S_OK, S_FALSE, or error ULONG cMax, // [IN] Max tokens to put. ULONG *pcTokens) // [OUT] Put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumMethodImpls - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumMethodImpls - NOT IMPLEMENTED\n")); return S_OK; } @@ -1379,7 +1392,8 @@ HRESULT RegMeta::EnumPermissionSets( // S_OK, S_FALSE, or error. ULONG cMax, // [IN] Max Permissions to put. ULONG *pcTokens) // [OUT] Put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumPermissionSets - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumPermissionSets - NOT IMPLEMENTED\n")); return S_OK; } @@ -1390,7 +1404,8 @@ HRESULT RegMeta::FindMember( ULONG cbSigBlob, // [IN] count of bytes in the signature blob mdToken *pmb) // [OUT] matching memberdef { - DEBUG_PRINTF(1, "CordbSymbol - FindMember - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - FindMember - NOT IMPLEMENTED\n")); return S_OK; } @@ -1401,7 +1416,8 @@ HRESULT RegMeta::FindMethod( ULONG cbSigBlob, // [IN] count of bytes in the signature blob mdMethodDef *pmb) // [OUT] matching memberdef { - DEBUG_PRINTF(1, "CordbSymbol - FindMethod - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - FindMethod - NOT IMPLEMENTED\n")); return S_OK; } @@ -1412,7 +1428,7 @@ HRESULT RegMeta::FindField( ULONG cbSigBlob, // [IN] count of bytes in the signature blob mdFieldDef *pmb) // [OUT] matching memberdef { - DEBUG_PRINTF(1, "CordbSymbol - FindField - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbSymbol - FindField - NOT IMPLEMENTED\n")); return S_OK; } @@ -1423,7 +1439,8 @@ HRESULT RegMeta::FindMemberRef( ULONG cbSigBlob, // [IN] count of bytes in the signature blob mdMemberRef *pmr) // [OUT] matching memberref { - DEBUG_PRINTF(1, "CordbSymbol - FindMemberRef - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - FindMemberRef - NOT IMPLEMENTED\n")); return S_OK; } @@ -1809,7 +1826,8 @@ HRESULT RegMeta::EnumMethodSemantics( // S_OK, S_FALSE, or error. ULONG cMax, // [IN] Max properties to put. ULONG *pcEventProp) // [OUT] Put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumMethodSemantics - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumMethodSemantics - NOT IMPLEMENTED\n")); return S_OK; } @@ -1819,7 +1837,8 @@ HRESULT RegMeta::GetMethodSemantics( // S_OK, S_FALSE, or error. DWORD * pdwSemanticsFlags) // [OUT] the role flags for the method/propevent pair { - DEBUG_PRINTF(1, "CordbSymbol - GetMethodSemantics - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetMethodSemantics - NOT IMPLEMENTED\n")); return S_OK; } @@ -1924,7 +1943,8 @@ HRESULT RegMeta::GetFieldMarshal( PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field ULONG *pcbNativeType) // [OUT] the count of bytes of *ppvNativeType { - DEBUG_PRINTF(1, "CordbSymbol - GetFieldMarshal - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetFieldMarshal - NOT IMPLEMENTED\n")); return S_OK; } @@ -1933,7 +1953,7 @@ HRESULT RegMeta::GetRVA( // S_OK or error. ULONG *pulCodeRVA, // The offset DWORD *pdwImplFlags) // the implementation flags { - DEBUG_PRINTF(1, "CordbSymbol - GetRVA - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbSymbol - GetRVA - NOT IMPLEMENTED\n")); return S_OK; } @@ -1943,7 +1963,8 @@ HRESULT RegMeta::GetPermissionSetProps( void const **ppvPermission, // [OUT] permission blob. ULONG *pcbPermission) // [OUT] count of bytes of pvPermission. { - DEBUG_PRINTF(1, "CordbSymbol - GetPermissionSetProps - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetPermissionSetProps - NOT IMPLEMENTED\n")); return S_OK; } @@ -1975,7 +1996,8 @@ HRESULT RegMeta::GetModuleRefProps( // S_OK or error. ULONG cchName, // [IN] size of szName in wide characters. ULONG *pchName) // [OUT] actual count of characters in the name. { - DEBUG_PRINTF(1, "CordbSymbol - GetModuleRefProps - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetModuleRefProps - NOT IMPLEMENTED\n")); return S_OK; } @@ -1985,7 +2007,8 @@ HRESULT RegMeta::EnumModuleRefs( // S_OK or error. ULONG cmax, // [IN] max memberrefs to put. ULONG *pcModuleRefs) // [OUT] put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumModuleRefs - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumModuleRefs - NOT IMPLEMENTED\n")); return S_OK; } @@ -2014,7 +2037,8 @@ HRESULT RegMeta::GetNameFromToken( // Not Recommended! May be removed! mdToken tk, // [IN] Token to get name from. Must have a name. MDUTF8CSTR *pszUtf8NamePtr) // [OUT] Return pointer to UTF8 name in heap. { - DEBUG_PRINTF(1, "CordbSymbol - GetNameFromToken - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetNameFromToken - NOT IMPLEMENTED\n")); return S_OK; } @@ -2024,7 +2048,8 @@ HRESULT RegMeta::EnumUnresolvedMethods( // S_OK, S_FALSE, or error. ULONG cMax, // [IN] Max MemberDefs to put. ULONG *pcTokens) // [OUT] Put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumUnresolvedMethods - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumUnresolvedMethods - NOT IMPLEMENTED\n")); return S_OK; } @@ -2089,7 +2114,8 @@ HRESULT RegMeta::GetPinvokeMap( // S_OK or error. ULONG *pchImportName, // [OUT] Actual number of characters stored. mdModuleRef *pmrImportDLL) // [OUT] ModuleRef token for the target DLL. { - DEBUG_PRINTF(1, "CordbSymbol - GetPinvokeMap - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetPinvokeMap - NOT IMPLEMENTED\n")); return S_OK; } @@ -2099,7 +2125,8 @@ HRESULT RegMeta::EnumSignatures( // S_OK or error. ULONG cmax, // [IN] max signatures to put. ULONG *pcSignatures) // [OUT] put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumSignatures - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumSignatures - NOT IMPLEMENTED\n")); return S_OK; } @@ -2109,7 +2136,8 @@ HRESULT RegMeta::EnumTypeSpecs( // S_OK or error. ULONG cmax, // [IN] max TypeSpecs to put. ULONG *pcTypeSpecs) // [OUT] put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumTypeSpecs - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumTypeSpecs - NOT IMPLEMENTED\n")); return S_OK; } @@ -2119,7 +2147,8 @@ HRESULT RegMeta::EnumUserStrings( // S_OK or error. ULONG cmax, // [IN] max Strings to put. ULONG *pcStrings) // [OUT] put # put here. { - DEBUG_PRINTF(1, "CordbSymbol - EnumUserStrings - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - EnumUserStrings - NOT IMPLEMENTED\n")); return S_OK; } @@ -2128,7 +2157,8 @@ HRESULT RegMeta::GetParamForMethodIndex( // S_OK or error. ULONG ulParamSeq, // [IN] Parameter sequence. mdParamDef *ppd) // [IN] Put Param token here. { - DEBUG_PRINTF(1, "CordbSymbol - GetParamForMethodIndex - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetParamForMethodIndex - NOT IMPLEMENTED\n")); return S_OK; } @@ -2298,7 +2328,8 @@ HRESULT RegMeta::FindTypeRef( LPCWSTR szName, // [IN] TypeRef Name. mdTypeRef *ptr) // [OUT] matching TypeRef. { - DEBUG_PRINTF(1, "CordbSymbol - FindTypeRef - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - FindTypeRef - NOT IMPLEMENTED\n")); return S_OK; } @@ -2320,7 +2351,8 @@ HRESULT RegMeta::GetMemberProps( ULONG * pcchValue) // [OUT] size of constant string in chars, 0 for non-strings. { - DEBUG_PRINTF(1, "CordbSymbol - GetMemberProps - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetMemberProps - NOT IMPLEMENTED\n")); return S_OK; } @@ -2738,7 +2770,8 @@ HRESULT RegMeta::GetNativeCallConvFromSig( // S_OK or error. ULONG cbSig, // [IN] Count of signature bytes. ULONG *pCallConv) // [OUT] Put calling conv here (see CorPinvokemap). { - DEBUG_PRINTF(1, "CordbSymbol - GetNativeCallConvFromSig - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbSymbol - GetNativeCallConvFromSig - NOT IMPLEMENTED\n")); return S_OK; } @@ -2747,6 +2780,6 @@ HRESULT RegMeta::IsGlobal( // S_OK or error. int *pbGlobal) // [OUT] Put 1 if global, 0 otherwise. { - DEBUG_PRINTF(1, "CordbSymbol - IsGlobal - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbSymbol - IsGlobal - NOT IMPLEMENTED\n")); return S_OK; } diff --git a/src/mono/dbi/cordb-symbol.h b/src/mono/dbi/cordb-symbol.h index bd330ec94a3130..e06fe05d56bd6d 100644 --- a/src/mono/dbi/cordb-symbol.h +++ b/src/mono/dbi/cordb-symbol.h @@ -107,10 +107,10 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { const void **ppbPublicKey, // [OUT] Pointer to the public key. ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. ULONG *pulHashAlgId, // [OUT] Hash Algorithm. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. + _Out_writes_to_opt_(cchName, *pchName) LPWSTR + szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. DWORD *pdwAssemblyFlags); // [OUT] Flags. diff --git a/src/mono/dbi/cordb-thread.cpp b/src/mono/dbi/cordb-thread.cpp index d699afc60c4a93..4b992d36793483 100644 --- a/src/mono/dbi/cordb-thread.cpp +++ b/src/mono/dbi/cordb-thread.cpp @@ -30,13 +30,15 @@ CordbThread::CordbThread(Connection *conn, CordbProcess *ppProcess, } HRESULT STDMETHODCALLTYPE CordbThread::HasUnhandledException(void) { - DEBUG_PRINTF(1, "CordbThread - HasUnhandledException - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - HasUnhandledException - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetBlockingObjects( /* [out] */ ICorDebugBlockingObjectEnum **ppBlockingObjectEnum) { - DEBUG_PRINTF(1, "CordbThread - GetBlockingObjects - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbThread - GetBlockingObjects - IMPLEMENTED\n")); CordbBlockingObjectEnum *blockingObject = new CordbBlockingObjectEnum(conn); *ppBlockingObjectEnum = static_cast(blockingObject); @@ -46,15 +48,16 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetBlockingObjects( HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentCustomDebuggerNotification( /* [out] */ ICorDebugValue **ppNotificationObject) { - DEBUG_PRINTF( - 1, - "CordbThread - GetCurrentCustomDebuggerNotification - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetCurrentCustomDebuggerNotification - NOT " + "IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::CreateStackWalk( /* [out] */ ICorDebugStackWalk **ppStackWalk) { - DEBUG_PRINTF(1, "CordbThread - CreateStackWalk - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - CreateStackWalk - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -63,7 +66,8 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetActiveInternalFrames( /* [out] */ ULONG32 *pcInternalFrames, /* [length_is][size_is][out][in] */ ICorDebugInternalFrame2 *ppInternalFrames[]) { - DEBUG_PRINTF(1, "CordbThread - GetActiveInternalFrames - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetActiveInternalFrames - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -71,52 +75,56 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFunctions( /* [in] */ ULONG32 cFunctions, /* [out] */ ULONG32 *pcFunctions, /* [length_is][size_is][out][in] */ COR_ACTIVE_FUNCTION pFunctions[]) { - DEBUG_PRINTF(1, "CordbThread - GetActiveFunctions - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetActiveFunctions - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetConnectionID( /* [out] */ CONNID *pdwConnectionId) { - DEBUG_PRINTF(1, "CordbThread - GetConnectionID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetConnectionID - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetTaskID( /* [out] */ TASKID *pTaskId) { - DEBUG_PRINTF(1, "CordbThread - GetTaskID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetTaskID - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetVolatileOSThreadID( /* [out] */ DWORD *pdwTid) { - DEBUG_PRINTF(1, "CordbThread - GetVolatileOSThreadID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetVolatileOSThreadID - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::InterceptCurrentException( /* [in] */ ICorDebugFrame *pFrame) { - DEBUG_PRINTF(1, - "CordbThread - InterceptCurrentException - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - InterceptCurrentException - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetProcess( /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "CordbThread - GetProcess - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetProcess - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetID( /* [out] */ DWORD *pdwThreadId) { *pdwThreadId = thread_id; - DEBUG_PRINTF(1, "CordbThread - GetID - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetID - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbThread::GetHandle( /* [out] */ HTHREAD *phThreadHandle) { - DEBUG_PRINTF(1, "CordbThread - GetHandle - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetHandle - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -124,26 +132,29 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetAppDomain( /* [out] */ ICorDebugAppDomain **ppAppDomain) { *ppAppDomain = static_cast(this->conn->pCorDebugAppDomain); - DEBUG_PRINTF(1, "CordbThread - GetAppDomain - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetAppDomain - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbThread::SetDebugState( /* [in] */ CorDebugThreadState state) { - DEBUG_PRINTF(1, "CordbThread - SetDebugState - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - SetDebugState - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetDebugState( /* [out] */ CorDebugThreadState *pState) { - DEBUG_PRINTF(1, "CordbThread - GetDebugState - NOT IMPLEMENTED - %p\n", this); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetDebugState - NOT IMPLEMENTED\n")); *pState = THREAD_RUN; return S_OK; } HRESULT STDMETHODCALLTYPE CordbThread::GetUserState( /* [out] */ CorDebugUserState *pState) { - DEBUG_PRINTF(1, "CordbThread - GetUserState - NOT IMPLEMENTED - %p\n", this); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetUserState - NOT IMPLEMENTED\n")); *pState = (CorDebugUserState)0; return S_OK; @@ -151,13 +162,15 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetUserState( HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentException( /* [out] */ ICorDebugValue **ppExceptionObject) { - DEBUG_PRINTF(1, "CordbThread - GetCurrentException - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbThread - GetCurrentException - IMPLEMENTED\n")); return S_FALSE; } HRESULT STDMETHODCALLTYPE CordbThread::ClearCurrentException(void) { - DEBUG_PRINTF(1, "CordbThread - ClearCurrentException - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - ClearCurrentException - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -167,7 +180,8 @@ HRESULT STDMETHODCALLTYPE CordbThread::CreateStepper( this->stepper = stepper; *ppStepper = static_cast(stepper); - DEBUG_PRINTF(1, "CordbThread - CreateStepper - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbThread - CreateStepper - IMPLEMENTED\n")); return S_OK; } @@ -175,39 +189,46 @@ HRESULT STDMETHODCALLTYPE CordbThread::EnumerateChains( /* [out] */ ICorDebugChainEnum **ppChains) { CordbChainEnum *pChains = new CordbChainEnum(conn, this); *ppChains = static_cast(pChains); - DEBUG_PRINTF(1, "CordbThread - EnumerateChains - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbThread - EnumerateChains - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbThread::GetActiveChain( /* [out] */ ICorDebugChain **ppChain) { - DEBUG_PRINTF(1, "CordbThread - GetActiveChain - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetActiveChain - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFrame( /* [out] */ ICorDebugFrame **ppFrame) { - DEBUG_PRINTF(1, "CordbThread - GetActiveFrame - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbThread - GetActiveFrame - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, thread_id); m_dbgprot_buffer_add_int(&localbuf, 0); m_dbgprot_buffer_add_int(&localbuf, -1); - int cmdId = this->conn->send_event(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, - &localbuf); + int cmdId = this->conn->send_event( + MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); int nframes = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); if (nframes > 0) { - int frameid = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int methodId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int il_offset = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int flags = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); - CordbNativeFrame *frame = - new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, this); - *ppFrame = static_cast(frame); + int frameid = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int methodId = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int il_offset = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int flags = + m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + CordbNativeFrame *frame = + new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, this); + *ppFrame = static_cast(frame); } registerset = new CordbRegisteSet(conn, 0, 0); @@ -216,7 +237,8 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFrame( HRESULT STDMETHODCALLTYPE CordbThread::GetRegisterSet( /* [out] */ ICorDebugRegisterSet **ppRegisters) { - DEBUG_PRINTF(1, "CordbThread - GetRegisterSet - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbThread - GetRegisterSet - IMPLEMENTED\n")); if (!registerset) registerset = new CordbRegisteSet(conn, 0, 0); @@ -227,7 +249,7 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetRegisterSet( HRESULT STDMETHODCALLTYPE CordbThread::CreateEval( /* [out] */ ICorDebugEval **ppEval) { - DEBUG_PRINTF(1, "CordbThread - CreateEval - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - CreateEval - IMPLEMENTED\n")); CordbEval *eval = new CordbEval(this->conn, this); eval->QueryInterface(IID_ICorDebugEval, (void **)ppEval); return S_OK; @@ -235,7 +257,7 @@ HRESULT STDMETHODCALLTYPE CordbThread::CreateEval( HRESULT STDMETHODCALLTYPE CordbThread::GetObject( /* [out] */ ICorDebugValue **ppObject) { - DEBUG_PRINTF(1, "CordbThread - GetObject - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetObject - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -257,7 +279,6 @@ HRESULT STDMETHODCALLTYPE CordbThread::QueryInterface( *ppInterface = NULL; return E_NOINTERFACE; } - DEBUG_PRINTF(1, "CordbThread - QueryInterface - IMPLEMENTED\n"); return S_OK; } diff --git a/src/mono/dbi/cordb-type.cpp b/src/mono/dbi/cordb-type.cpp index 9e5e83c686b036..a01c971a54d0fd 100644 --- a/src/mono/dbi/cordb-type.cpp +++ b/src/mono/dbi/cordb-type.cpp @@ -29,14 +29,14 @@ CordbType::CordbType(CorElementType type, CordbClass *klass, HRESULT STDMETHODCALLTYPE CordbType::GetType(CorElementType *ty) { *ty = type; - DEBUG_PRINTF(1, "CordbType - GetType - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetType - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbType::GetClass(ICorDebugClass **ppClass) { - DEBUG_PRINTF(1, "CordbType - GetClass - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetClass - IMPLEMENTED\n")); if (!klass) { - DEBUG_PRINTF(1, "CordbType - GetClass - SEM CLASSE\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbType - GetClass - NO CLASS\n")); return S_OK; } *ppClass = static_cast(klass); @@ -48,30 +48,33 @@ CordbType::EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum) { CordbTypeEnum *tp = new CordbTypeEnum(conn, typeParameter); *ppTyParEnum = static_cast(tp); - DEBUG_PRINTF(1, "CordbType - EnumerateTypeParameters - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbType - EnumerateTypeParameters - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbType::GetFirstTypeParameter(ICorDebugType **value) { - DEBUG_PRINTF(1, "CordbType - GetFirstTypeParameter - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbType - GetFirstTypeParameter - IMPLEMENTED\n")); *value = static_cast(typeParameter); return S_OK; } HRESULT STDMETHODCALLTYPE CordbType::GetBase(ICorDebugType **pBase) { - DEBUG_PRINTF(1, "CordbType - GetBase - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetBase - IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbType::GetStaticFieldValue( mdFieldDef fieldDef, ICorDebugFrame *pFrame, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbType - GetStaticFieldValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbType - GetStaticFieldValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbType::GetRank(ULONG32 *pnRank) { - DEBUG_PRINTF(1, "CordbType - GetRank - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbType - GetRank - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -96,7 +99,7 @@ ULONG STDMETHODCALLTYPE CordbType::AddRef(void) { return 0; } ULONG STDMETHODCALLTYPE CordbType::Release(void) { return 0; } HRESULT STDMETHODCALLTYPE CordbType::GetTypeID(COR_TYPEID *id) { - DEBUG_PRINTF(1, "CordbType - GetTypeID - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbType - GetTypeID - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -111,22 +114,22 @@ HRESULT STDMETHODCALLTYPE CordbTypeEnum::Next(ULONG celt, *pceltFetched = celt; if (type != NULL) values[0] = type; - DEBUG_PRINTF(1, "CordbTypeEnum - Next - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbTypeEnum - Next - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbTypeEnum::Skip(ULONG celt) { - DEBUG_PRINTF(1, "CordbTypeEnum - Skip - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Skip - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbTypeEnum::Reset(void) { - DEBUG_PRINTF(1, "CordbTypeEnum - Reset - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Reset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbTypeEnum::Clone(ICorDebugEnum **ppEnum) { - DEBUG_PRINTF(1, "CordbTypeEnum - Clone - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Clone - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -135,7 +138,7 @@ HRESULT STDMETHODCALLTYPE CordbTypeEnum::GetCount(ULONG *pcelt) { *pcelt = 1; else *pcelt = 0; - DEBUG_PRINTF(1, "CordbTypeEnum - GetCount - IMPLEMENTED - %d\n", *pcelt); + LOG((LF_CORDB, LL_INFO1000000, "CordbTypeEnum - GetCount - IMPLEMENTED\n")); return S_OK; } @@ -149,7 +152,6 @@ HRESULT STDMETHODCALLTYPE CordbTypeEnum::QueryInterface(REFIID id, *pInterface = static_cast(static_cast(this)); else { - DEBUG_PRINTF(1, "CordbTypeEnum - QueryInterface - E_NOTIMPL\n"); *pInterface = NULL; return E_NOINTERFACE; } diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index 28974d3a26bc11..6359d4bc5a4374 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -40,13 +40,14 @@ HRESULT STDMETHODCALLTYPE CordbValue::GetSize(ULONG32 *pSize) { HRESULT STDMETHODCALLTYPE CordbValue::GetAddress(CORDB_ADDRESS *pAddress) { *pAddress = (CORDB_ADDRESS)&value; - DEBUG_PRINTF(1, "CordbValue - GetAddress - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetAddress - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, "CordbValue - CreateBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbValue - CreateBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -76,50 +77,54 @@ ULONG STDMETHODCALLTYPE CordbValue::AddRef(void) { return 0; } ULONG STDMETHODCALLTYPE CordbValue::Release(void) { return 0; } HRESULT STDMETHODCALLTYPE CordbValue::GetExactType(ICorDebugType **ppType) { - DEBUG_PRINTF(1, "CordbValue - GetExactType - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetExactType - IMPLEMENTED\n")); CordbType *tp = new CordbType(type); *ppType = static_cast(tp); return S_OK; } HRESULT STDMETHODCALLTYPE CordbValue::GetSize64(ULONG64 *pSize) { - DEBUG_PRINTF(1, "CordbValue - GetSize64 - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "CordbValue - GetSize64 - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbValue::GetValue(void *pTo) { - DEBUG_PRINTF(1, "CordbValue - GetValue - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetValue - IMPLEMENTED\n")); memcpy(pTo, &value, size); return S_OK; } HRESULT STDMETHODCALLTYPE CordbValue::SetValue(void *pFrom) { memcpy(&value, pFrom, size); - DEBUG_PRINTF(1, "CordbValue - SetValue - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbValue - SetValue - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetType(CorElementType *pType) { - DEBUG_PRINTF(1, "CordbReferenceValue - GetType - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbReferenceValue - GetType - IMPLEMENTED\n")); *pType = type; return S_OK; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize(ULONG32 *pSize) { - DEBUG_PRINTF(1, "CordbReferenceValue - GetSize - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbReferenceValue - GetSize - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetAddress(CORDB_ADDRESS *pAddress) { *pAddress = (CORDB_ADDRESS)&object_id; - DEBUG_PRINTF(1, "CordbReferenceValue - GetAddress - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbReferenceValue - GetAddress - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, "CordbReferenceValue - CreateBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbReferenceValue - CreateBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -150,21 +155,13 @@ ULONG STDMETHODCALLTYPE CordbReferenceValue::Release(void) { return 1; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType **ppType) { - DEBUG_PRINTF(1, "CordbReferenceValue - GetExactType - IMPLEMENTED - %d\n", - type); + LOG((LF_CORDB, LL_INFO1000000, + "CordbReferenceValue - GetExactType - IMPLEMENTED\n")); if (cordbtype) { - DEBUG_PRINTF(1, - "CordbReferenceValue - GetExactType - IMPLEMENTED - %d - " - "tinha cordbtype\n", - type); *ppType = static_cast(cordbtype); return S_OK; } if (klass != NULL) { - DEBUG_PRINTF( - 1, - "CordbReferenceValue - GetExactType - IMPLEMENTED - %d - tinha klass\n", - type); cordbtype = new CordbType(type, klass); *ppType = static_cast(cordbtype); return S_OK; @@ -174,16 +171,18 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, object_id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_TYPE, - &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_OBJECT_REF, + MDBGPROT_CMD_OBJECT_REF_GET_TYPE, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int type_id = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, type_id); - cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, + &localbuf); m_dbgprot_buffer_free(&localbuf); bAnswer = conn->get_answer(cmdId); char *namespace_str = @@ -194,14 +193,12 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); int assembly_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int module_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int module_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); type_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id2 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id2 = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, - "CordbReferenceValue - GetExactType - IMPLEMENTED - 1.0 - %d " - "- %d - %d - %d\n", - type_id, token, assembly_id, module_id); klass = new CordbClass(conn, token, assembly_id); cordbtype = new CordbType(type, klass); *ppType = static_cast(cordbtype); @@ -213,12 +210,12 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, object_id); - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, + MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int type_id = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "ELEMENT_TYPE_SZARRAY - %d\n", type_id); + int type_id = + m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); if (type_id == ELEMENT_TYPE_CLASS) { int klass_id = @@ -227,7 +224,8 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, klass_id); - cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, + MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); bAnswer = conn->get_answer(cmdId); char *namespace_str = @@ -240,21 +238,18 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); int module_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id3 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id2 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF( - 1, - "CordbReferenceValue - GetExactType - IMPLEMENTED - 1.1 - %d - %d\n", - klass_id, token); + int type_id3 = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id2 = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int token = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); klass = new CordbClass(conn, token, module_id); } cordbtype = new CordbType(type, NULL, new CordbType((CorElementType)type_id, klass)); *ppType = static_cast(cordbtype); - DEBUG_PRINTF(1, "CordbReferenceValue - GetExactType - IMPLEMENTED\n"); - return S_OK; } CordbType *tp = new CordbType(type); @@ -263,17 +258,20 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { } HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize64(ULONG64 *pSize) { - DEBUG_PRINTF(1, "CordbReferenceValue - GetSize64 - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbReferenceValue - GetSize64 - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetValue(void *pTo) { - DEBUG_PRINTF(1, "CordbReferenceValue - GetValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbReferenceValue - GetValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(void *pFrom) { - DEBUG_PRINTF(1, "CordbReferenceValue - SetValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbReferenceValue - SetValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -281,7 +279,8 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::IsNull(/* [out] */ BOOL *pbNull) { if (object_id == -1) *pbNull = true; - DEBUG_PRINTF(1, "CordbReferenceValue - IsNull - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbReferenceValue - IsNull - IMPLEMENTED\n")); return S_OK; } @@ -291,14 +290,15 @@ CordbReferenceValue::GetValue(/* [out] */ CORDB_ADDRESS *pValue) { *pValue = NULL; else *pValue = (CORDB_ADDRESS)&object_id; - DEBUG_PRINTF(1, "CordbReferenceValue - GetValue - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbReferenceValue - GetValue - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(/* [in] */ CORDB_ADDRESS value) { - DEBUG_PRINTF( - 1, "CordbReferenceValue - SetValue CORDB_ADDRESS - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbReferenceValue - SetValue CORDB_ADDRESS - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -315,14 +315,15 @@ CordbReferenceValue::Dereference(/* [out] */ ICorDebugValue **ppValue) { new CordbObjectValue(conn, type, object_id, klass); objectValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); } - DEBUG_PRINTF(1, "CordbReferenceValue - Dereference - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbReferenceValue - Dereference - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::DereferenceStrong(/* [out] */ ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, - "CordbReferenceValue - DereferenceStrong - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbReferenceValue - DereferenceStrong - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -346,13 +347,14 @@ CordbObjectValue::CordbObjectValue(Connection *conn, CorElementType type, } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetType(CorElementType *pType) { - DEBUG_PRINTF(1, "CordbObjectValue - GetType - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetType - IMPLEMENTED\n")); *pType = type; return S_OK; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize(ULONG32 *pSize) { - DEBUG_PRINTF(1, "CordbObjectValue - GetSize - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetSize - NOT IMPLEMENTED\n")); *pSize = 10; return S_OK; } @@ -360,13 +362,15 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize(ULONG32 *pSize) { HRESULT STDMETHODCALLTYPE CordbObjectValue::GetAddress(CORDB_ADDRESS *pAddress) { *pAddress = (CORDB_ADDRESS)&object_id; - DEBUG_PRINTF(1, "CordbObjectValue - GetAddress - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbObjectValue - GetAddress - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, "CordbObjectValue - CreateBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - CreateBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -376,32 +380,36 @@ ULONG STDMETHODCALLTYPE CordbObjectValue::Release(void) { return 1; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetExactType(ICorDebugType **ppType) { - DEBUG_PRINTF(1, "CordbObjectValue - GetExactType - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CordbObjectValue - GetExactType - IMPLEMENTED\n")); CordbType *tp = new CordbType(type, klass); *ppType = static_cast(tp); return S_OK; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize64(ULONG64 *pSize) { - DEBUG_PRINTF(1, "CordbObjectValue - GetSize64 - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetSize64 - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetValue(void *pTo) { - DEBUG_PRINTF(1, "CordbObjectValue - GetValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::SetValue(void *pFrom) { - DEBUG_PRINTF(1, "CordbObjectValue - SetValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - SetValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethodAndType( mdMemberRef memberRef, ICorDebugFunction **ppFunction, ICorDebugType **ppType) { - DEBUG_PRINTF( - 1, "CordbObjectValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -413,11 +421,12 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32 *pcchString) { m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, object_id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_LENGTH, - &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_STRING_REF, + MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - *pcchString = m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); + *pcchString = + m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); return S_OK; } return E_NOTIMPL; @@ -433,20 +442,21 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, object_id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_VALUE, - &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_STRING_REF, + MDBGPROT_CMD_STRING_REF_GET_VALUE, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); *pcchString = cchString; int use_utf16 = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); if (use_utf16) { - DEBUG_PRINTF( - 1, "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n")); } else { char *value = m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "CordbObjectValue - GetString - %s\n", value); + LOG((LF_CORDB, LL_INFO1000000, + "CordbObjectValue - GetString - IMPLEMENTED\n")); if (cchString >= strlen(value)) { mbstowcs(szString, value, strlen(value) + 1); *pcchString = strlen(value); @@ -459,69 +469,73 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateHandle( CorDebugHandleType type, ICorDebugHandleValue **ppHandle) { - DEBUG_PRINTF(1, "CordbObjectValue - CreateHandle - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - CreateHandle - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetThreadOwningMonitorLock( ICorDebugThread **ppThread, DWORD *pAcquisitionCount) { - DEBUG_PRINTF( - 1, "CordbObjectValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum) { - DEBUG_PRINTF( - 1, "CordbObjectValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::EnumerateExceptionCallStack( ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum) { - DEBUG_PRINTF( - 1, "CordbObjectValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetCachedInterfaceTypes( BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum) { - DEBUG_PRINTF( - 1, "CordbObjectValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetCachedInterfacePointers( BOOL bIInspectableOnly, ULONG32 celt, ULONG32 *pcEltFetched, CORDB_ADDRESS *ptrs) { - DEBUG_PRINTF( - 1, "CordbObjectValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetTarget(ICorDebugReferenceValue **ppObject) { - DEBUG_PRINTF(1, "CordbObjectValue - GetTarget - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetTarget - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFunction(ICorDebugFunction **ppFunction) { - DEBUG_PRINTF(1, "CordbObjectValue - GetFunction - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetFunction - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetClass(/* [out] */ ICorDebugClass **ppClass) { - DEBUG_PRINTF(1, "CordbObjectValue - GetClass - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetClass - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue( ICorDebugClass *pClass, mdFieldDef fieldDef, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbObjectValue - GetFieldValue - IMPLEMENTED - %d - %d\n", - fieldDef, object_id); + LOG((LF_CORDB, LL_INFO1000000, + "CordbObjectValue - GetFieldValue - IMPLEMENTED\n")); if (object_id == -1) return S_FALSE; @@ -530,8 +544,9 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue( m_dbgprot_buffer_add_id(&localbuf, object_id); m_dbgprot_buffer_add_int(&localbuf, fieldDef); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_OBJECT_REF, - MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); + int cmdId = + conn->send_event(MDBGPROT_CMD_SET_OBJECT_REF, + MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); m_dbgprot_buffer_free(&localbuf); ReceivedReplyPacket *received_reply_packet = @@ -542,12 +557,11 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue( return CreateCordbValue(conn, bAnswer, ppValue); } -HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAnswer, +HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, + MdbgProtBuffer *bAnswer, ICorDebugValue **ppValue) { CorElementType type = (CorElementType)m_dbgprot_decode_byte( bAnswer->buf, &bAnswer->buf, bAnswer->end); - - DEBUG_PRINTF(1, "CreateCordbValue type - %x\n", type); CordbContent value; switch (type) { case MONO_TYPE_BOOLEAN: @@ -555,21 +569,18 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAn case MONO_TYPE_U1: value.booleanValue = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "bool value - %d\n", value.booleanValue); break; case MONO_TYPE_CHAR: case MONO_TYPE_I2: case MONO_TYPE_U2: value.charValue = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "char value - %c\n", value.charValue); break; case MONO_TYPE_I4: case MONO_TYPE_U4: case MONO_TYPE_R4: value.intValue = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "int value - %d\n", value.intValue); break; case MONO_TYPE_I8: case MONO_TYPE_U8: @@ -580,7 +591,8 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAn case MONO_TYPE_CLASS: case MONO_TYPE_SZARRAY: case MONO_TYPE_STRING: { - int object_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int object_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); CordbReferenceValue *refValue = new CordbReferenceValue(conn, type, object_id); refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); @@ -589,15 +601,15 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAn case MDBGPROT_VALUE_TYPE_ID_NULL: { CorElementType type = (CorElementType)m_dbgprot_decode_byte( bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "NULL value - type - %d\n", type); if (type == MONO_TYPE_CLASS || type == MONO_TYPE_STRING) { - int klass_id = (CorElementType)m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, - bAnswer->end); + int klass_id = (CorElementType)m_dbgprot_decode_id( + bAnswer->buf, &bAnswer->buf, bAnswer->end); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, klass_id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, + MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); bAnswer = conn->get_answer(cmdId); char *namespace_str = @@ -610,9 +622,12 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAn m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); int module_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id2 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int type_id2 = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int token = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); CordbClass *klass = new CordbClass(conn, token, module_id); CordbReferenceValue *refValue = @@ -620,22 +635,18 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAn refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); } if (type == MONO_TYPE_SZARRAY) { - DEBUG_PRINTF(1, "NULL value - MONO_TYPE_SZARRAY\n"); CordbClass *klass = NULL; int type_id = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); if (type_id == ELEMENT_TYPE_CLASS) { - DEBUG_PRINTF(1, - "NULL value - MONO_TYPE_SZARRAY - ELEMENT_TYPE_CLASS\n"); int klass_id = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, klass_id); - - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, + MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); bAnswer = conn->get_answer(cmdId); char *namespace_str = @@ -652,9 +663,8 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAn m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); int type_id2 = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "CreateCordbValue - IMPLEMENTED - 1.1 - %d - %d\n", - klass_id, token); + int token = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); klass = new CordbClass(conn, token, module_id); } CordbType *cordbtype = new CordbType( @@ -666,7 +676,7 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAn return S_OK; } default: - DEBUG_PRINTF(1, "default value - %d\n", type); + LOG((LF_CORDB, LL_INFO100000, "default value - %d", type)); return S_FALSE; } @@ -677,108 +687,76 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAn HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethod( mdMemberRef memberRef, ICorDebugFunction **ppFunction) { - DEBUG_PRINTF(1, "CordbObjectValue - GetVirtualMethod - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetVirtualMethod - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetContext(ICorDebugContext **ppContext) { - DEBUG_PRINTF(1, "CordbObjectValue - GetContext - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetContext - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::IsValueClass(BOOL *pbIsValueClass) { - DEBUG_PRINTF(1, "CordbObjectValue - IsValueClass - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - IsValueClass - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetManagedCopy(IUnknown **ppObject) { - DEBUG_PRINTF(1, "CordbObjectValue - GetManagedCopy - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - GetManagedCopy - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::SetFromManagedCopy(IUnknown *pObject) { - DEBUG_PRINTF(1, "CordbObjectValue - SetFromManagedCopy - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - SetFromManagedCopy - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::IsValid(BOOL *pbValid) { - DEBUG_PRINTF(1, "CordbObjectValue - IsValid - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - IsValid - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateRelocBreakpoint( ICorDebugValueBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, - "CordbObjectValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbObjectValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbObjectValue::QueryInterface(REFIID id, void **pInterface) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - IMPLEMENTED - %d\n", - type); if (id == IID_ICorDebugValue) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - IID_ICorDebugValue - " - "IMPLEMENTED\n"); *pInterface = static_cast( static_cast(this)); } else if (id == IID_ICorDebugValue2) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - IID_ICorDebugValue2 - " - "IMPLEMENTED\n"); *pInterface = static_cast(this); } else if (id == IID_ICorDebugValue3) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - IID_ICorDebugValue3 - " - "IMPLEMENTED\n"); *pInterface = static_cast(this); } else if (id == IID_ICorDebugObjectValue) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " - "IID_ICorDebugObjectValue - IMPLEMENTED\n"); *pInterface = static_cast(this); } else if (id == IID_ICorDebugObjectValue2) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " - "IID_ICorDebugObjectValue2 - IMPLEMENTED\n"); *pInterface = static_cast(this); } else if (id == IID_ICorDebugGenericValue) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " - "IID_ICorDebugGenericValue - IMPLEMENTED\n"); *pInterface = static_cast(this); } else if (id == IID_ICorDebugHeapValue) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " - "IID_ICorDebugHeapValue - IMPLEMENTED\n"); *pInterface = static_cast(this); } else if (id == IID_ICorDebugHeapValue2) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " - "IID_ICorDebugHeapValue2 - IMPLEMENTED\n"); *pInterface = static_cast(this); } else if (id == IID_ICorDebugHeapValue3) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " - "IID_ICorDebugHeapValue3 - IMPLEMENTED\n"); *pInterface = static_cast(this); } else if ((id == IID_ICorDebugStringValue) && (type == ELEMENT_TYPE_STRING)) { - DEBUG_PRINTF(1, "CordbObjectValue - QueryInterface - " - "IID_ICorDebugStringValue - IMPLEMENTED\n"); *pInterface = static_cast(this); - } else /*if (id == IID_ICorDebugExceptionObjectValue && m_fIsExceptionObject) - { - *pInterface = - static_cast(static_cast(this)); - } - else if (id == IID_ICorDebugComObjectValue && m_fIsRcw) - { - *pInterface = static_cast(this); - } - else if (id == IID_ICorDebugDelegateObjectValue && m_fIsDelegate) - { - *pInterface = static_cast(this); - } - else*/ - if (id == IID_IUnknown) { - DEBUG_PRINTF( - 1, "CordbObjectValue - QueryInterface - IID_IUnknown - IMPLEMENTED\n"); + } else if (id == IID_IUnknown) { *pInterface = static_cast(static_cast(this)); } else { @@ -797,63 +775,74 @@ CordbArrayValue::CordbArrayValue(Connection *conn, CordbType *type, } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetClass(ICorDebugClass **ppClass) { - DEBUG_PRINTF(1, "CordbArrayValue - GetClass - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetClass - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetFieldValue( ICorDebugClass *pClass, mdFieldDef fieldDef, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbArrayValue - GetFieldValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetFieldValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethod( mdMemberRef memberRef, ICorDebugFunction **ppFunction) { - DEBUG_PRINTF(1, "CordbArrayValue - GetVirtualMethod - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetVirtualMethod - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetContext(ICorDebugContext **ppContext) { - DEBUG_PRINTF(1, "CordbArrayValue - GetContext - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetContext - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::IsValueClass(BOOL *pbIsValueClass) { - DEBUG_PRINTF(1, "CordbArrayValue - IsValueClass - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - IsValueClass - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetManagedCopy(IUnknown **ppObject) { - DEBUG_PRINTF(1, "CordbArrayValue - GetManagedCopy - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetManagedCopy - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::SetFromManagedCopy(IUnknown *pObject) { - DEBUG_PRINTF(1, "CordbArrayValue - SetFromManagedCopy - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - SetFromManagedCopy - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetType(CorElementType *pType) { - DEBUG_PRINTF(1, "CordbArrayValue - GetType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetType - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize(ULONG32 *pSize) { - DEBUG_PRINTF(1, "CordbArrayValue - GetSize - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetSize - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetAddress(CORDB_ADDRESS *pAddress) { *pAddress = (CORDB_ADDRESS)&object_id; - DEBUG_PRINTF(1, "CordbArrayValue - GetAddress - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetAddress - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, "CordbArrayValue - CreateBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - CreateBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -892,114 +881,125 @@ ULONG STDMETHODCALLTYPE CordbArrayValue::Release(void) { return 0; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethodAndType( mdMemberRef memberRef, ICorDebugFunction **ppFunction, ICorDebugType **ppType) { - DEBUG_PRINTF(1, - "CordbArrayValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetValue(void *pTo) { - DEBUG_PRINTF(1, "CordbArrayValue - GetValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::SetValue(void *pFrom) { - DEBUG_PRINTF(1, "CordbArrayValue - SetValue - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - SetValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetLength(ULONG32 *pcchString) { - DEBUG_PRINTF(1, "CordbArrayValue - GetLength - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetLength - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetString(ULONG32 cchString, ULONG32 *pcchString, WCHAR szString[]) { - DEBUG_PRINTF(1, "CordbArrayValue - GetString - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetString - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::IsValid(BOOL *pbValid) { - DEBUG_PRINTF(1, "CordbArrayValue - IsValid - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - IsValid - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateRelocBreakpoint( ICorDebugValueBreakpoint **ppBreakpoint) { - DEBUG_PRINTF(1, - "CordbArrayValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetExactType(ICorDebugType **ppType) { *ppType = static_cast(type); - DEBUG_PRINTF(1, "CordbArrayValue - GetExactType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetExactType - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize64(ULONG64 *pSize) { - DEBUG_PRINTF(1, "CordbArrayValue - GetSize64 - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetSize64 - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateHandle( CorDebugHandleType type, ICorDebugHandleValue **ppHandle) { - DEBUG_PRINTF(1, "CordbArrayValue - CreateHandle - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - CreateHandle - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetThreadOwningMonitorLock( ICorDebugThread **ppThread, DWORD *pAcquisitionCount) { - DEBUG_PRINTF( - 1, "CordbArrayValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum) { - DEBUG_PRINTF(1, - "CordbArrayValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::EnumerateExceptionCallStack( ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum) { - DEBUG_PRINTF( - 1, "CordbArrayValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCachedInterfaceTypes( BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum) { - DEBUG_PRINTF(1, - "CordbArrayValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCachedInterfacePointers( BOOL bIInspectableOnly, ULONG32 celt, ULONG32 *pcEltFetched, CORDB_ADDRESS *ptrs) { - DEBUG_PRINTF( - 1, "CordbArrayValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetTarget(ICorDebugReferenceValue **ppObject) { - DEBUG_PRINTF(1, "CordbArrayValue - GetTarget - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetTarget - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetFunction(ICorDebugFunction **ppFunction) { - DEBUG_PRINTF(1, "CordbArrayValue - GetFunction - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetFunction - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElementType(CorElementType *pType) { - DEBUG_PRINTF(1, "CordbArrayValue - GetElementType - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetElementType - NOT IMPLEMENTED\n")); return E_NOTIMPL; } @@ -1008,12 +1008,12 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetRank(ULONG32 *pnRank) { m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, object_id); - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, + MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "CordbArrayValue - GetRank - IMPLEMENTED - %d\n", rank); + LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetRank - IMPLEMENTED\n")); *pnRank = rank; return S_OK; } @@ -1023,40 +1023,43 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCount(ULONG32 *pnCount) { m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, object_id); - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, + MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); count = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, "CordbArrayValue - GetCount - IMPLEMENTED - %d\n", count); + LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetCount - IMPLEMENTED\n")); *pnCount = count; return S_OK; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetDimensions(ULONG32 cdim, ULONG32 dims[]) { - DEBUG_PRINTF(1, "CordbArrayValue - GetDimensions - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetDimensions - IMPLEMENTED\n")); dims[0] = count; return S_OK; } HRESULT STDMETHODCALLTYPE CordbArrayValue::HasBaseIndicies(BOOL *pbHasBaseIndicies) { - DEBUG_PRINTF(1, "CordbArrayValue - HasBaseIndicies - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - HasBaseIndicies - NOT IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]) { - DEBUG_PRINTF(1, "CordbArrayValue - GetBaseIndicies - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetBaseIndicies - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement( ULONG32 cdim, ULONG32 indices[], ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbArrayValue - GetElement - IMPLEMENTED - %d - %d\n", - cdim, indices[0]); + LOG((LF_CORDB, LL_INFO1000000, + "CordbArrayValue - GetElement - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); @@ -1064,8 +1067,8 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement( m_dbgprot_buffer_add_int(&localbuf, indices[cdim - 1]); m_dbgprot_buffer_add_int(&localbuf, 1); - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, + MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); @@ -1074,6 +1077,7 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement( HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElementAtPosition( ULONG32 nPosition, ICorDebugValue **ppValue) { - DEBUG_PRINTF(1, "CordbArrayValue - GetElementAtPosition - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "CordbArrayValue - GetElementAtPosition - NOT IMPLEMENTED\n")); return E_NOTIMPL; } From c6cd6e837e24e3bee83caf0e96525fa33829e0a8 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 2 Feb 2021 14:24:33 -0300 Subject: [PATCH 04/64] Missing files --- src/mono/dbi/cordb.cpp | 178 ++++++++++++++++++++++------------------- src/mono/dbi/cordb.h | 28 ++----- 2 files changed, 101 insertions(+), 105 deletions(-) diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 6c3c0eabea567b..459c61ea46d4e5 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -49,7 +49,7 @@ MONO_API HRESULT CoreCLRCreateCordbObjectEx(int iDebuggerVersion, DWORD pid, LPCWSTR lpApplicationGroupId, HMODULE hmodTargetCLR, void **ppCordb) { - DEBUG_PRINTF(1, "CoreCLRCreateCordbObjectEx \n"); + LOG((LF_CORDB, LL_INFO100000, "CoreCLRCreateCordbObjectEx\n")); *ppCordb = new Cordb(); return S_OK; } @@ -67,18 +67,18 @@ static void debugger_thread(void *ppProcess) { } HRESULT Cordb::Initialize(void) { - DEBUG_PRINTF(1, "Cordb - Initialize - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "Cordb - Initialize - NOT IMPLEMENTED\n")); return S_OK; } HRESULT Cordb::Terminate(void) { - DEBUG_PRINTF(1, "Cordb - Terminate - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "Cordb - Terminate - NOT IMPLEMENTED\n")); return S_OK; } HRESULT Cordb::SetManagedHandler( /* [in] */ ICorDebugManagedCallback *pCallback) { - DEBUG_PRINTF(1, "Cordb - SetManagedHandler - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "Cordb - SetManagedHandler - IMPLEMENTED\n")); this->pCallback = pCallback; this->pCallback->AddRef(); @@ -87,7 +87,8 @@ HRESULT Cordb::SetManagedHandler( HRESULT Cordb::SetUnmanagedHandler( /* [in] */ ICorDebugUnmanagedCallback *pCallback) { - DEBUG_PRINTF(1, "Cordb - SetUnmanagedHandler - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "Cordb - SetUnmanagedHandler - NOT IMPLEMENTED\n")); return S_OK; } @@ -104,7 +105,7 @@ HRESULT Cordb::CreateProcess( /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, /* [in] */ CorDebugCreateProcessFlags debuggingFlags, /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "Cordb - CreateProcess - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "Cordb - CreateProcess - NOT IMPLEMENTED\n")); return S_OK; } @@ -112,7 +113,7 @@ HRESULT Cordb::DebugActiveProcess( /* [in] */ DWORD id, /* [in] */ BOOL win32Attach, /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "Cordb - DebugActiveProcess - IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO1000000, "Cordb - DebugActiveProcess - IMPLEMENTED\n")); *ppProcess = new CordbProcess(); ((CordbProcess *)*ppProcess)->cordb = this; @@ -124,21 +125,23 @@ HRESULT Cordb::DebugActiveProcess( HRESULT Cordb::EnumerateProcesses( /* [out] */ ICorDebugProcessEnum **ppProcess) { - DEBUG_PRINTF(1, "Cordb - EnumerateProcesses - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "Cordb - EnumerateProcesses - NOT IMPLEMENTED\n")); return S_OK; } HRESULT Cordb::GetProcess( /* [in] */ DWORD dwProcessId, /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "Cordb - GetProcess - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "Cordb - GetProcess - NOT IMPLEMENTED\n")); return S_OK; } HRESULT Cordb::CanLaunchOrAttach( /* [in] */ DWORD dwProcessId, /* [in] */ BOOL win32DebuggingEnabled) { - DEBUG_PRINTF(1, "Cordb - CanLaunchOrAttach - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "Cordb - CanLaunchOrAttach - NOT IMPLEMENTED\n")); return S_OK; } @@ -148,6 +151,9 @@ Cordb::Cordb() { threads = g_ptr_array_new(); functions = g_ptr_array_new(); modules = g_hash_table_new(NULL, NULL); +#ifdef LOGGING + InitializeLogging(); +#endif } CordbFunction *Cordb::findFunction(int id) { @@ -177,7 +183,7 @@ CordbFunction *Cordb::findFunctionByToken(int token) { HRESULT Cordb::QueryInterface( /* [in] */ REFIID riid, /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) { - DEBUG_PRINTF(1, "Cordb - QueryInterface - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "Cordb - QueryInterface - NOT IMPLEMENTED\n")); return S_OK; } @@ -200,7 +206,7 @@ HRESULT Cordb::CreateProcessEx( /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, /* [in] */ CorDebugCreateProcessFlags debuggingFlags, /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "Cordb - CreateProcessEx - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, "Cordb - CreateProcessEx - NOT IMPLEMENTED\n")); return S_OK; } @@ -209,7 +215,8 @@ HRESULT Cordb::DebugActiveProcessEx( /* [in] */ DWORD dwProcessId, /* [in] */ BOOL fWin32Attach, /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "Cordb - DebugActiveProcessEx - NOT IMPLEMENTED\n"); + LOG((LF_CORDB, LL_INFO100000, + "Cordb - DebugActiveProcessEx - NOT IMPLEMENTED\n")); return S_OK; } @@ -244,14 +251,16 @@ void Connection::receive() { recv(connect_socket, (char *)recvbuf_header.buf, HEADER_LENGTH, 0); if (iResult == -1) { - ppCordb->pCallback->ExitProcess(static_cast(ppProcess)); - break; + ppCordb->pCallback->ExitProcess( + static_cast(ppProcess)); + break; } while (iResult == 0) { - DEBUG_PRINTF(1, - "[dbg] transport_recv () sleep returned %d, expected %d.\n", - iResult, HEADER_LENGTH); - iResult = recv(connect_socket, (char *)recvbuf_header.buf, HEADER_LENGTH, 0); + LOG((LF_CORDB, LL_INFO100000, + "transport_recv () sleep returned %d, expected %d.\n", iResult, + HEADER_LENGTH)); + iResult = + recv(connect_socket, (char *)recvbuf_header.buf, HEADER_LENGTH, 0); Sleep(1000); } @@ -278,9 +287,6 @@ void Connection::receive() { dbg_lock(); if (header.flags == REPLY_PACKET) { - DEBUG_PRINTF( - 1, "header->id - %d - header->error - %d - header->error_2 - %d\n", - header.id, header.error, header.error_2); ReceivedReplyPacket *rp = (ReceivedReplyPacket *)g_malloc0(sizeof(ReceivedReplyPacket)); rp->error = header.error; @@ -317,68 +323,73 @@ ReceivedReplyPacket *Connection::get_answer_with_error(int cmdId) { } void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { - int spolicy = m_dbgprot_decode_byte(recvbuf->buf, &recvbuf->buf, recvbuf->end); + int spolicy = + m_dbgprot_decode_byte(recvbuf->buf, &recvbuf->buf, recvbuf->end); int nevents = m_dbgprot_decode_int(recvbuf->buf, &recvbuf->buf, recvbuf->end); for (int i = 0; i < nevents; ++i) { int kind = m_dbgprot_decode_byte(recvbuf->buf, &recvbuf->buf, recvbuf->end); - int req_id = m_dbgprot_decode_int(recvbuf->buf, &recvbuf->buf, recvbuf->end); + int req_id = + m_dbgprot_decode_int(recvbuf->buf, &recvbuf->buf, recvbuf->end); MdbgProtEventKind etype = (MdbgProtEventKind)kind; - long thread_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + long thread_id = + m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); - DEBUG_PRINTF(1, "Received %d %d events %s, suspend=%d\n", i, nevents, - m_dbgprot_event_to_string(etype), etype); + LOG((LF_CORDB, LL_INFO100000, "Received %d %d events %s, suspend=%d\n", i, + nevents, m_dbgprot_event_to_string(etype), spolicy)); switch (etype) { case MDBGPROT_EVENT_KIND_VM_START: { ppProcess->suspended = true; - ppCordb->pCallback->CreateProcess(static_cast(ppProcess)); - } - break; + ppCordb->pCallback->CreateProcess( + static_cast(ppProcess)); + } break; case MDBGPROT_EVENT_KIND_VM_DEATH: { - ppCordb->pCallback->ExitProcess(static_cast(ppProcess)); - } - break; + ppCordb->pCallback->ExitProcess( + static_cast(ppProcess)); + } break; case MDBGPROT_EVENT_KIND_THREAD_START: { - DEBUG_PRINTF(1, "criei a thread certinha pelo MDBGPROT_EVENT_KIND_THREAD_START\n"); CordbThread *thread = new CordbThread(this, ppProcess, thread_id); g_ptr_array_add(ppCordb->threads, thread); ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); - } - break; + } break; case MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE: { - } - break; + } break; case MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD: { // all the callbacks call a resume, in this case that we are faking 2 // callbacks without receive command, we should not send the continue - int assembly_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + int assembly_id = + m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); if (pCorDebugAppDomain == NULL) { - pCorDebugAppDomain = new CordbAppDomain(this, static_cast(ppProcess)); + pCorDebugAppDomain = new CordbAppDomain( + this, static_cast(ppProcess)); ppProcess->Stop(false); - ppCordb->pCallback->CreateAppDomain(static_cast(ppProcess), pCorDebugAppDomain); + ppCordb->pCallback->CreateAppDomain( + static_cast(ppProcess), pCorDebugAppDomain); } - DEBUG_PRINTF(1, "Recebi assembly load - %d\n", assembly_id); - ICorDebugAssembly *pAssembly = new CordbAssembly(this, ppProcess, pCorDebugAppDomain, assembly_id); + ICorDebugAssembly *pAssembly = + new CordbAssembly(this, ppProcess, pCorDebugAppDomain, assembly_id); ppProcess->Stop(false); ppCordb->pCallback->LoadAssembly(pCorDebugAppDomain, pAssembly); ppProcess->suspended = true; - ICorDebugModule *pModule = new CordbModule(this, ppProcess, (CordbAssembly *)pAssembly, assembly_id); - g_hash_table_insert(ppCordb->modules, GINT_TO_POINTER(assembly_id), pModule); + ICorDebugModule *pModule = new CordbModule( + this, ppProcess, (CordbAssembly *)pAssembly, assembly_id); + g_hash_table_insert(ppCordb->modules, GINT_TO_POINTER(assembly_id), + pModule); ppCordb->pCallback->LoadModule(pCorDebugAppDomain, pModule); - } - break; + } break; case MDBGPROT_EVENT_KIND_BREAKPOINT: { - int method_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); - long offset = m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); + int method_id = + m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + long offset = + m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); CordbThread *thread = findThread(ppCordb->threads, thread_id); if (thread == NULL) { - DEBUG_PRINTF(1, "criei a thread errada pelo MDBGPROT_EVENT_KIND_BREAKPOINT\n"); thread = new CordbThread(this, ppProcess, thread_id); g_ptr_array_add(ppCordb->threads, thread); ppProcess->Stop(false); @@ -387,33 +398,33 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { int i = 0; CordbFunctionBreakpoint *breakpoint; while (i < ppCordb->breakpoints->len) { - breakpoint = (CordbFunctionBreakpoint *)g_ptr_array_index(ppCordb->breakpoints, i); - if (breakpoint->offset == offset && breakpoint->code->func->id == method_id) { - ppCordb->pCallback->Breakpoint(pCorDebugAppDomain, thread, static_cast(breakpoint)); + breakpoint = (CordbFunctionBreakpoint *)g_ptr_array_index( + ppCordb->breakpoints, i); + if (breakpoint->offset == offset && + breakpoint->code->func->id == method_id) { + ppCordb->pCallback->Breakpoint( + pCorDebugAppDomain, thread, + static_cast(breakpoint)); break; } i++; } - } - break; + } break; case MDBGPROT_EVENT_KIND_STEP: { - int method_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); - long offset = m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); - - DEBUG_PRINTF(1, "MDBGPROT_EVENT_KIND_STEP - %d - %d - %d\n", thread_id, method_id, - offset); - + int method_id = + m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + long offset = + m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); CordbThread *thread = findThread(ppCordb->threads, thread_id); if (thread == NULL) { - DEBUG_PRINTF(1, "criei a thread errada pelo MDBGPROT_EVENT_KIND_STEP\n"); thread = new CordbThread(this, ppProcess, thread_id); g_ptr_array_add(ppCordb->threads, thread); ppProcess->Stop(false); ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); } - ppCordb->pCallback->StepComplete(pCorDebugAppDomain, thread, thread->stepper, STEP_NORMAL); - } - break; + ppCordb->pCallback->StepComplete(pCorDebugAppDomain, thread, + thread->stepper, STEP_NORMAL); + } break; } } // m_dbgprot_buffer_free(&recvbuf); @@ -428,7 +439,8 @@ int Connection::process_packet(bool is_answer) { void Connection::process_packet_from_queue() { int i = 0; while (i < received_packets_to_process->len) { - MdbgProtBuffer *req = (MdbgProtBuffer *)g_ptr_array_index(received_packets_to_process, i); + MdbgProtBuffer *req = + (MdbgProtBuffer *)g_ptr_array_index(received_packets_to_process, i); process_packet_internal(req); dbg_lock(); g_ptr_array_remove_index_fast(received_packets_to_process, i); @@ -452,9 +464,6 @@ void Connection::loop_send_receive() { CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)receive_thread, this, 0, &thread_id); - // machine.EnableEvents(EventType.AssemblyLoad, EventType.ThreadStart, - // EventType.ThreadDeath, EventType.AppDomainUnload, EventType.UserBreak, - // EventType.UserLog); enable_event(MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD); enable_event(MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE); enable_event(MDBGPROT_EVENT_KIND_THREAD_START); @@ -468,7 +477,8 @@ void Connection::loop_send_receive() { m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_int(&localbuf, MAJOR_VERSION); m_dbgprot_buffer_add_int(&localbuf, MINOR_VERSION); - int cmdId = send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SET_PROTOCOL_VERSION, &localbuf); + int cmdId = send_event(MDBGPROT_CMD_SET_VM, + MDBGPROT_CMD_VM_SET_PROTOCOL_VERSION, &localbuf); m_dbgprot_buffer_free(&localbuf); m_dbgprot_buffer_init(&localbuf, 128); @@ -483,9 +493,9 @@ void Connection::loop_send_receive() { int minor_version = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - DEBUG_PRINTF(1, - "[dbg] Protocol version %d.%d, server protocol version %d.%d.\n", - MAJOR_VERSION, MINOR_VERSION, major_version, minor_version); + LOG((LF_CORDB, LL_INFO100000, + "Protocol version %d.%d, server protocol version %d.%d.\n", + MAJOR_VERSION, MINOR_VERSION, major_version, minor_version)); int iResult = 0; // Receive until the peer closes the connection @@ -502,7 +512,8 @@ void Connection::enable_event(MdbgProtEventKind eventKind) { m_dbgprot_buffer_add_byte(&sendbuf, eventKind); m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); m_dbgprot_buffer_add_byte(&sendbuf, 0); // modifiers - send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, + &sendbuf); m_dbgprot_buffer_free(&sendbuf); } @@ -512,7 +523,7 @@ void Connection::close_connection() { } void Connection::start_connection() { - DEBUG_PRINTF(1, "Start Connection\n"); + LOG((LF_CORDB, LL_INFO100000, "Start Connection\n")); WSADATA wsaData; connect_socket = INVALID_SOCKET; @@ -530,7 +541,7 @@ void Connection::start_connection() { hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; - DEBUG_PRINTF(1, "Listening to 127.0.0.1:1003\n"); + LOG((LF_CORDB, LL_INFO100000, "Listening to 127.0.0.1:1003\n")); // Resolve the server address and port iResult = getaddrinfo("127.0.0.1", "1003", &hints, &result); @@ -570,7 +581,7 @@ void Connection::start_connection() { if (connect_socket == -1) exit(1); - DEBUG_PRINTF(1, "Accepted connection from client.\n"); + LOG((LF_CORDB, LL_INFO100000, "Accepted connection from client.\n")); freeaddrinfo(result); @@ -598,8 +609,8 @@ void Connection::transport_handshake() { } void Connection::send_packet(MdbgProtBuffer &sendbuf) { - int iResult = - send(connect_socket, (const char *)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf), 0); + int iResult = send(connect_socket, (const char *)sendbuf.buf, + m_dbgprot_buffer_len(&sendbuf), 0); if (iResult == SOCKET_ERROR) { WSACleanup(); return; @@ -630,27 +641,28 @@ int Connection::send_event(int cmd_set, int cmd, MdbgProtBuffer *sendbuf) { MONO_API HRESULT CoreCLRCreateCordbObject(int iDebuggerVersion, DWORD pid, HMODULE hmodTargetCLR, void **ppCordb) { - DEBUG_PRINTF(1, "CoreCLRCreateCordbObject \n"); + LOG((LF_CORDB, LL_INFO100000, "CoreCLRCreateCordbObject\n")); *ppCordb = new Cordb(); return S_OK; } MONO_API HRESULT CreateCordbObject(int iDebuggerVersion, void **ppCordb) { - DEBUG_PRINTF(1, "CreateCordbObject \n"); + LOG((LF_CORDB, LL_INFO100000, "CreateCordbObject\n")); *ppCordb = new Cordb(); return S_OK; } HRESULT CordbModule::GetAssembly( /* [out] */ ICorDebugAssembly **ppAssembly) { - DEBUG_PRINTF(1, "CordbModule - GetAssembly\n"); + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetAssembly - IMPLEMENTED\n")); *ppAssembly = static_cast(pAssembly); return S_OK; } HRESULT CordbAssembly::GetProcess( /* [out] */ ICorDebugProcess **ppProcess) { - DEBUG_PRINTF(1, "CorDebugAssembly - GetProcess\n"); + LOG((LF_CORDB, LL_INFO1000000, + "CorDebugAssembly - GetProcess - IMPLEMENTED\n")); *ppProcess = static_cast(pProcess); return S_OK; } diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 130e850b034062..3cfef8b940a249 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -26,9 +26,6 @@ #include #endif -#define MAJOR_VERSION 3 -#define MINOR_VERSION 0 - #define return_if_nok(error) \ do { \ if (!is_ok((error))) \ @@ -39,6 +36,11 @@ #define dbg_unlock() mono_os_mutex_unlock(&debug_mutex.m); static MonoCoopMutex debug_mutex; +#ifdef _DEBUG +#define LOGGING +#include +#endif + class Cordb; class CordbProcess; class CordbAppDomain; @@ -177,28 +179,10 @@ class CordbBaseMono { void SetConnection(Connection *conn); }; -static int log_level = 10; -static FILE *log_file = fopen("c:\\thays\\example.txt", "a+"); - -#define DEBUG(level, s) \ - do { \ - if (G_UNLIKELY((level) <= log_level)) { \ - s; \ - fflush(log_file); \ - } \ - } while (0) -#define DEBUG_PRINTF(level, ...) \ - do { \ - if (G_UNLIKELY((level) <= log_level)) { \ - fprintf(log_file, __VA_ARGS__); \ - fflush(log_file); \ - } \ - } while (0) - #define CHECK_ERROR_RETURN_FALSE(localbuf) \ do { \ if (localbuf->error > 0 || localbuf->error_2 > 0) { \ - DEBUG_PRINTF(1, "retornando erro\n"); \ + LOG((LF_CORDB, LL_INFO100000, "ERROR RECEIVED\n")); \ return S_FALSE; \ } \ } while (0) From c5ce8181c35395a762d4fdfcebe2edb1b9cd31be Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Wed, 3 Feb 2021 18:18:46 -0300 Subject: [PATCH 05/64] Removing eglib from implementation --- src/mono/dbi/CMakeLists.txt | 6 +- src/mono/dbi/cordb-appdomain.cpp | 17 +-- src/mono/dbi/cordb-assembly.cpp | 9 +- src/mono/dbi/cordb-assembly.h | 4 +- src/mono/dbi/cordb-blocking-obj.cpp | 11 -- src/mono/dbi/cordb-breakpoint.cpp | 7 -- src/mono/dbi/cordb-chain.cpp | 9 -- src/mono/dbi/cordb-class.cpp | 12 +- src/mono/dbi/cordb-code.cpp | 16 +-- src/mono/dbi/cordb-eval.cpp | 39 +++--- src/mono/dbi/cordb-frame.cpp | 6 +- src/mono/dbi/cordb-function.cpp | 43 +++---- src/mono/dbi/cordb-function.h | 4 +- src/mono/dbi/cordb-process.cpp | 9 +- src/mono/dbi/cordb-process.h | 3 +- src/mono/dbi/cordb-register.cpp | 10 +- src/mono/dbi/cordb-register.h | 6 +- src/mono/dbi/cordb-stepper.cpp | 5 - src/mono/dbi/cordb-symbol.cpp | 13 +- src/mono/dbi/cordb-symbol.h | 1 - src/mono/dbi/cordb-thread.cpp | 3 - src/mono/dbi/cordb-type.cpp | 8 -- src/mono/dbi/cordb-value.cpp | 41 +++--- src/mono/dbi/cordb-value.h | 8 +- src/mono/dbi/cordb.cpp | 165 ++++++++++++++----------- src/mono/dbi/cordb.h | 42 ++++--- src/mono/mono/mini/debugger-protocol.c | 18 ++- src/mono/mono/mini/debugger-protocol.h | 2 +- 28 files changed, 222 insertions(+), 295 deletions(-) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 44236ad1318fbd..09182bbb71d8dc 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -4,12 +4,10 @@ project(mscordbi) include_directories( ${PROJECT_BINARY_DIR}/ ${PROJECT_BINARY_DIR}/../.. - ${PROJECT_BINARY_DIR}/../mono/eglib ${CMAKE_CURRENT_SOURCE_DIR}/../.. ${CMAKE_CURRENT_BINARY_DIR}/../ ${PROJECT_SOURCE_DIR}/../mono/mini/ ${PROJECT_SOURCE_DIR}/../ - ${PROJECT_SOURCE_DIR}/../mono/eglib ${PROJECT_SOURCE_DIR}/../dbi ${PROJECT_SOURCE_DIR}/../../coreclr/md/enc ${PROJECT_SOURCE_DIR}/../../coreclr/inc @@ -18,9 +16,6 @@ include_directories( ${PROJECT_SOURCE_DIR}/../../coreclr/md/compiler) -include(../mono/eglib/CMakeLists.txt) - - set(UTILCODE_COMMON_SOURCES_BASE clrhost_nodependencies.cpp ccomprc.cpp @@ -195,6 +190,7 @@ add_library(utilcode STATIC "${UTILCODE_COMMON_SOURCES}") target_link_libraries(mscordbi mdruntimerw-dbi utilcode ${OS_LIBS}) target_precompile_headers(mdruntimerw-dbi PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/md/enc/stdafx.h) target_precompile_headers(utilcode PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/utilcode/stdafx.h) +target_precompile_headers(mscordbi PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/utilcode/stdafx.h) if(HOST_AMD64) add_compile_definitions(TARGET_AMD64) diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp index 701b9dfdb986fb..263995aed01316 100644 --- a/src/mono/dbi/cordb-appdomain.cpp +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -4,16 +4,8 @@ // File: CORDB-APPDOMAIN.CPP // -#include -#include - #include -#include -#include -#include #include -#include -#include #include using namespace std; @@ -21,7 +13,7 @@ using namespace std; CordbAppDomain::CordbAppDomain(Connection *conn, ICorDebugProcess *ppProcess) : CordbBaseMono(conn) { pProcess = ppProcess; - g_ptr_array_add(((CordbProcess *)(ppProcess))->appdomains, this); + ((CordbProcess*)(ppProcess))->appdomains->Append(this); } HRESULT CordbAppDomain::Stop(/* [in] */ DWORD dwTimeoutIgnored) { @@ -244,12 +236,11 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, "CordbAppDomainEnum - Next - NOT IMPLEMENTED\n")); *pceltFetched = celt; for (int i = 0; i < celt; i++) { - if (current_pos >= pProcess->appdomains->len) { + if (current_pos >= pProcess->appdomains->GetCount()) { *pceltFetched = 0; return S_FALSE; } - CordbAppDomain *appdomain = - (CordbAppDomain *)g_ptr_array_index(pProcess->appdomains, current_pos); + CordbAppDomain* appdomain = (CordbAppDomain*)pProcess->appdomains->Get(current_pos); appdomain->QueryInterface(IID_ICorDebugAppDomain, (void **)values + current_pos); current_pos++; @@ -279,7 +270,7 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Clone(ICorDebugEnum **ppEnum) { HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::GetCount(ULONG *pcelt) { LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomainEnum - GetCount - IMPLEMENTED\n")); - *pcelt = pProcess->appdomains->len; + *pcelt = pProcess->appdomains->GetCount(); return S_OK; } diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 527f261430d740..cd618357028db3 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -4,9 +4,6 @@ // File: CORDB-ASSEMBLY.CPP // -#include -#include - #include #include #include @@ -225,12 +222,12 @@ HRESULT CordbModule::GetName( if (cchName < strlen(assembly_name) + 1) { *pcchName = strlen(assembly_name) + 1; - g_free(assembly_name); + free(assembly_name); return S_OK; } mbstowcs(szName, assembly_name, strlen(assembly_name) + 1); *pcchName = strlen(assembly_name) + 1; - g_free(assembly_name); + free(assembly_name); return S_OK; } @@ -270,7 +267,7 @@ HRESULT CordbModule::GetFunctionFromToken( func = pProcess->cordb->findFunction(id); if (func == NULL) { func = new CordbFunction(conn, methodDef, id, this); - g_ptr_array_add(pProcess->cordb->functions, func); + pProcess->cordb->functions->Append(func); } *ppFunction = func; return S_OK; diff --git a/src/mono/dbi/cordb-assembly.h b/src/mono/dbi/cordb-assembly.h index 7f917195db64c5..118b0b5c4a7e5f 100644 --- a/src/mono/dbi/cordb-assembly.h +++ b/src/mono/dbi/cordb-assembly.h @@ -19,8 +19,8 @@ class CordbModule : public CordbBaseMono, CordbProcess *pProcess; RegMeta *pCordbSymbol; CordbAssembly *pAssembly; - guint8 *assembly_metadata_blob; - guint32 assembly_metadata_len; + uint8_t *assembly_metadata_blob; + int32_t assembly_metadata_len; unsigned long dwFlags; CordbModule(Connection *conn, CordbProcess *process, CordbAssembly *assembly, diff --git a/src/mono/dbi/cordb-blocking-obj.cpp b/src/mono/dbi/cordb-blocking-obj.cpp index ff24c951aec475..fe1053073cb60a 100644 --- a/src/mono/dbi/cordb-blocking-obj.cpp +++ b/src/mono/dbi/cordb-blocking-obj.cpp @@ -4,18 +4,7 @@ // File: CORDB-BLOCKING-OBJ.CPP // -#include -#include - #include -#include -#include -#include -#include -#include -#include -#include -#include #include using namespace std; diff --git a/src/mono/dbi/cordb-breakpoint.cpp b/src/mono/dbi/cordb-breakpoint.cpp index c33969ff8c0c0d..f51eacc8470925 100644 --- a/src/mono/dbi/cordb-breakpoint.cpp +++ b/src/mono/dbi/cordb-breakpoint.cpp @@ -4,16 +4,9 @@ // File: CORDB-BREAKPOINT.CPP // -#include -#include - #include #include -#include #include -#include -#include -#include #include using namespace std; diff --git a/src/mono/dbi/cordb-chain.cpp b/src/mono/dbi/cordb-chain.cpp index 608a4a5e54edfb..73dab2bf02d3ed 100644 --- a/src/mono/dbi/cordb-chain.cpp +++ b/src/mono/dbi/cordb-chain.cpp @@ -4,19 +4,10 @@ // File: CORDB-CHAIN.CPP // -#include -#include - #include -#include #include -#include #include -#include -#include #include -#include -#include #include using namespace std; diff --git a/src/mono/dbi/cordb-class.cpp b/src/mono/dbi/cordb-class.cpp index 36bd2d16afebc8..64308718fe8874 100644 --- a/src/mono/dbi/cordb-class.cpp +++ b/src/mono/dbi/cordb-class.cpp @@ -4,18 +4,13 @@ // File: CORDB-CLASS.CPP // -#include -#include - #include #include -#include -#include -#include -#include #include #include +#include "cordb-assembly.h" + using namespace std; CordbClass::CordbClass(Connection *conn, mdToken token, int module_id) @@ -27,8 +22,7 @@ CordbClass::CordbClass(Connection *conn, mdToken token, int module_id) HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule **pModule) { LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetModule - IMPLEMENTED\n")); if (pModule) { - *pModule = (ICorDebugModule *)g_hash_table_lookup( - conn->ppCordb->modules, GINT_TO_POINTER(module_id)); + return conn->ppCordb->GetModule(module_id, pModule); } return S_OK; } diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index 85014c632d35d0..c2396f8b4ca54c 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -4,21 +4,11 @@ // File: CORDB-CODE.CPP // -#include -#include - #include #include -#include -#include #include -#include #include #include -#include -#include -#include -#include #include using namespace std; @@ -65,7 +55,7 @@ HRESULT __stdcall CordbCode::CreateBreakpoint( // add it in a list to not recreate a already created breakpoint CordbFunctionBreakpoint *bp = new CordbFunctionBreakpoint(conn, this, offset); *ppBreakpoint = static_cast(bp); - g_ptr_array_add(this->func->module->pProcess->cordb->breakpoints, bp); + conn->ppCordb->breakpoints->Append(bp); LOG((LF_CORDB, LL_INFO1000000, "CordbCode - CreateBreakpoint - IMPLEMENTED\n")); return S_OK; @@ -83,8 +73,8 @@ HRESULT __stdcall CordbCode::GetCode(ULONG32 startOffset, ULONG32 endOffset, m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - guint8 *code = m_dbgprot_decode_byte_array(bAnswer->buf, &bAnswer->buf, - bAnswer->end, pcBufferSize); + uint8_t *code = m_dbgprot_decode_byte_array(bAnswer->buf, &bAnswer->buf, + bAnswer->end, (int32_t*)pcBufferSize); memcpy(buffer, code, *pcBufferSize); LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetCode - IMPLEMENTED\n")); diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index e88201279dea78..800cd4a6a65d2d 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -12,6 +12,8 @@ #include #include "corerror.h" +#include "metamodel.h" +#include "metamodelpub.h" #include "rwutil.h" #include "stdafx.h" @@ -42,29 +44,29 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( ppArgs[i]->GetAddress((CORDB_ADDRESS *)&cc); m_dbgprot_buffer_add_byte(&localbuf, ty); switch (ty) { - case MONO_TYPE_BOOLEAN: - case MONO_TYPE_I1: - case MONO_TYPE_U1: + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: m_dbgprot_buffer_add_int(&localbuf, cc->booleanValue); break; - case MONO_TYPE_CHAR: - case MONO_TYPE_I2: - case MONO_TYPE_U2: + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: m_dbgprot_buffer_add_int(&localbuf, cc->charValue); break; - case MONO_TYPE_I4: - case MONO_TYPE_U4: - case MONO_TYPE_R4: + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: m_dbgprot_buffer_add_int(&localbuf, cc->intValue); break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - case MONO_TYPE_R8: + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: m_dbgprot_buffer_add_long(&localbuf, cc->longValue); break; - case MONO_TYPE_CLASS: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_STRING: + case ELEMENT_TYPE_CLASS: + case ELEMENT_TYPE_SZARRAY: + case ELEMENT_TYPE_STRING: m_dbgprot_buffer_add_id(&localbuf, cc->intValue); break; } @@ -72,7 +74,7 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( cmdId = conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_INVOKE_METHOD, &localbuf); m_dbgprot_buffer_free(&localbuf); - g_ptr_array_add(conn->pending_eval, this); + conn->pending_eval->Append(this); return S_OK; } @@ -81,8 +83,7 @@ void CordbEval::EvalComplete(MdbgProtBuffer *bAnswer) { m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); CordbObjectValue::CreateCordbValue(conn, bAnswer, &ppValue); conn->ppCordb->pCallback->EvalComplete( - static_cast( - g_ptr_array_index(thread->ppProcess->appdomains, 0)), + static_cast(thread->ppProcess->appdomains->Get(0)), static_cast(thread), static_cast(this)); } @@ -139,7 +140,7 @@ HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, this->cmdId = conn->send_event(MDBGPROT_CMD_SET_APPDOMAIN, MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); - g_ptr_array_add(conn->pending_eval, this); + conn->pending_eval->Append(this); return S_OK; } diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index f0385636d41a99..595963211685cc 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -4,15 +4,11 @@ // File: CORDB-FRAME.CPP // -#include -#include - #include #include #include #include #include -#include #include #include @@ -124,7 +120,7 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunction( CordbFunction *func = thread->ppProcess->cordb->findFunction(methodId); if (!func) { func = new CordbFunction(conn, 0, methodId, NULL); - g_ptr_array_add(thread->ppProcess->cordb->functions, func); + thread->ppProcess->cordb->functions->Append(func); } *ppFunction = static_cast(func); diff --git a/src/mono/dbi/cordb-function.cpp b/src/mono/dbi/cordb-function.cpp index 1af5d678f37282..9c9a7928f8b5f2 100644 --- a/src/mono/dbi/cordb-function.cpp +++ b/src/mono/dbi/cordb-function.cpp @@ -4,21 +4,14 @@ // File: CORDB-FUNCTION.CPP // -#include -#include - #include -#include #include -#include -#include -#include #include using namespace std; CordbFunction::CordbFunction(Connection *conn, mdToken token, int id, - CordbModule *module) + ICorDebugModule *module) : CordbBaseMono(conn) { this->token = token; this->id = id; @@ -50,29 +43,27 @@ ULONG __stdcall CordbFunction::AddRef(void) { return 0; } ULONG __stdcall CordbFunction::Release(void) { return 0; } -HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule **ppModule) { - if (module == NULL) { +HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule** ppModule) { MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); - m_dbgprot_buffer_free(&localbuf); + if (!module) { + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, id); + int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); + m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - - int module_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer* bAnswer = conn->get_answer(cmdId); - module = (CordbModule *)g_hash_table_lookup(conn->ppCordb->modules, - GINT_TO_POINTER(module_id)); - } + int module_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + conn->ppCordb->GetModule(module_id, &module); + } - *ppModule = static_cast(this->module); + if (!module) + return S_FALSE; - if (!*ppModule) - return S_FALSE; - return S_OK; + *ppModule = module; + return S_OK; } HRESULT __stdcall CordbFunction::GetClass(ICorDebugClass **ppClass) { diff --git a/src/mono/dbi/cordb-function.h b/src/mono/dbi/cordb-function.h index be0a5bbba4ddd4..5af4314d8d7b77 100644 --- a/src/mono/dbi/cordb-function.h +++ b/src/mono/dbi/cordb-function.h @@ -19,9 +19,9 @@ class CordbFunction : public CordbBaseMono, int id; mdToken token; CordbCode *code; - CordbModule *module; + ICorDebugModule *module; - CordbFunction(Connection *conn, mdToken token, int id, CordbModule *module); + CordbFunction(Connection *conn, mdToken token, int id, ICorDebugModule *module); HRESULT STDMETHODCALLTYPE QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index f9628d03e0e935..d820d72f248d8d 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -4,22 +4,15 @@ // File: CORDB-PROCESS.CPP // -#include -#include - #include -#include -#include #include -#include -#include #include using namespace std; CordbProcess::CordbProcess() : CordbBaseMono(NULL) { suspended = false; - appdomains = g_ptr_array_new(); + appdomains = new ArrayList(); } HRESULT CordbProcess::EnumerateLoaderHeapMemoryRegions( diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index ffc499c8165c46..c1275c216b3c00 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -7,6 +7,7 @@ #ifndef __MONO_DEBUGGER_CORDB_PROCESS_H__ #define __MONO_DEBUGGER_CORDB_PROCESS_H__ +#include #include class CordbProcess : public CordbBaseMono, @@ -20,7 +21,7 @@ class CordbProcess : public CordbBaseMono, public ICorDebugProcess10, public ICorDebugProcess11 { public: - GPtrArray *appdomains; + ArrayList *appdomains; int suspended; Cordb *cordb; CordbProcess(); diff --git a/src/mono/dbi/cordb-register.cpp b/src/mono/dbi/cordb-register.cpp index 55c5fc6864b7bc..dde7c4186e0002 100644 --- a/src/mono/dbi/cordb-register.cpp +++ b/src/mono/dbi/cordb-register.cpp @@ -4,16 +4,8 @@ // File: CORDB-REGISTER.CPP // -#include -#include - #include -#include -#include -#include #include -#include -#include #include using namespace std; @@ -24,7 +16,7 @@ HRESULT __stdcall CordbRegisteSet::GetRegistersAvailable(ULONG64 *pAvailable) { return E_NOTIMPL; } -CordbRegisteSet::CordbRegisteSet(Connection *conn, guint8 *ctx, guint32 ctx_len) +CordbRegisteSet::CordbRegisteSet(Connection *conn, uint8_t *ctx, uint32_t ctx_len) : CordbBaseMono(conn) { this->ctx = ctx; this->ctx_len = ctx_len; diff --git a/src/mono/dbi/cordb-register.h b/src/mono/dbi/cordb-register.h index e8460227a76209..2d0a4de0077491 100644 --- a/src/mono/dbi/cordb-register.h +++ b/src/mono/dbi/cordb-register.h @@ -10,11 +10,11 @@ #include class CordbRegisteSet : public CordbBaseMono, public ICorDebugRegisterSet { - guint8 *ctx; - guint32 ctx_len; + uint8_t *ctx; + uint32_t ctx_len; public: - CordbRegisteSet(Connection *conn, guint8 *ctx, guint32 ctx_len); + CordbRegisteSet(Connection *conn, uint8_t *ctx, uint32_t ctx_len); HRESULT STDMETHODCALLTYPE QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index 18f9552f026764..020ab778ec57ec 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -4,11 +4,7 @@ // File: CORDB-STEPPER.CPP // -#include -#include - #include -#include #include #include #include @@ -108,7 +104,6 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); - m_dbgprot_buffer_free(&sendbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepOut - IMPLEMENTED\n")); diff --git a/src/mono/dbi/cordb-symbol.cpp b/src/mono/dbi/cordb-symbol.cpp index 9922866ccfc826..b9fb8a18136c0a 100644 --- a/src/mono/dbi/cordb-symbol.cpp +++ b/src/mono/dbi/cordb-symbol.cpp @@ -4,29 +4,21 @@ // File: CORDB-SYMBOL.CPP // -#include - #include "corerror.h" #include "mdlog.h" #include "posterror.h" +#include "metamodel.h" +#include "metamodelpub.h" #include "rwutil.h" -#include "sstring.h" #include "stdafx.h" #include "stgio.h" -#include "switches.h" #include "importhelper.h" -#include "mdinternalrw.h" #include #include -#include -#include -#include -#include #include -#include #include using namespace std; @@ -35,7 +27,6 @@ RegMeta::RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule) { module_id = -1; pCordbAssembly = cordbAssembly; this->cordbModule = cordbModule; - parameters = g_hash_table_new(NULL, NULL); token_id = 0; m_pStgdb = new CLiteWeightStgdbRW(); diff --git a/src/mono/dbi/cordb-symbol.h b/src/mono/dbi/cordb-symbol.h index e06fe05d56bd6d..16b5ae06985074 100644 --- a/src/mono/dbi/cordb-symbol.h +++ b/src/mono/dbi/cordb-symbol.h @@ -16,7 +16,6 @@ class CLiteWeightStgdbRW; class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { int token_id; - GHashTable *parameters; CordbAssembly *pCordbAssembly; CordbModule *cordbModule; CLiteWeightStgdbRW *m_pStgdb; diff --git a/src/mono/dbi/cordb-thread.cpp b/src/mono/dbi/cordb-thread.cpp index 4b992d36793483..f9225beafcc8ea 100644 --- a/src/mono/dbi/cordb-thread.cpp +++ b/src/mono/dbi/cordb-thread.cpp @@ -4,9 +4,6 @@ // File: CORDB-THREAD.CPP // -#include -#include - #include #include #include diff --git a/src/mono/dbi/cordb-type.cpp b/src/mono/dbi/cordb-type.cpp index a01c971a54d0fd..0edf875a9dc44d 100644 --- a/src/mono/dbi/cordb-type.cpp +++ b/src/mono/dbi/cordb-type.cpp @@ -4,17 +4,9 @@ // File: CORDB-TYPE.CPP // -#include -#include - #include #include -#include -#include -#include -#include #include -#include #include using namespace std; diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index 6359d4bc5a4374..5135db0127f70c 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -4,15 +4,8 @@ // File: CORDB-VALUE.CPP // -#include -#include - #include #include -#include -#include -#include -#include #include #include #include @@ -564,33 +557,33 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, bAnswer->buf, &bAnswer->buf, bAnswer->end); CordbContent value; switch (type) { - case MONO_TYPE_BOOLEAN: - case MONO_TYPE_I1: - case MONO_TYPE_U1: + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: value.booleanValue = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); break; - case MONO_TYPE_CHAR: - case MONO_TYPE_I2: - case MONO_TYPE_U2: + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: value.charValue = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); break; - case MONO_TYPE_I4: - case MONO_TYPE_U4: - case MONO_TYPE_R4: + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: value.intValue = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - case MONO_TYPE_R8: + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: value.longValue = m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); break; - case MONO_TYPE_CLASS: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_STRING: { + case ELEMENT_TYPE_CLASS: + case ELEMENT_TYPE_SZARRAY: + case ELEMENT_TYPE_STRING: { int object_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); CordbReferenceValue *refValue = @@ -601,7 +594,7 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, case MDBGPROT_VALUE_TYPE_ID_NULL: { CorElementType type = (CorElementType)m_dbgprot_decode_byte( bAnswer->buf, &bAnswer->buf, bAnswer->end); - if (type == MONO_TYPE_CLASS || type == MONO_TYPE_STRING) { + if (type == ELEMENT_TYPE_CLASS || type == ELEMENT_TYPE_STRING) { int klass_id = (CorElementType)m_dbgprot_decode_id( bAnswer->buf, &bAnswer->buf, bAnswer->end); @@ -634,7 +627,7 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, new CordbReferenceValue(conn, type, -1, klass); refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); } - if (type == MONO_TYPE_SZARRAY) { + if (type == ELEMENT_TYPE_SZARRAY) { CordbClass *klass = NULL; int type_id = m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); diff --git a/src/mono/dbi/cordb-value.h b/src/mono/dbi/cordb-value.h index a4dba5596ba8dc..9eaa1633d353fe 100644 --- a/src/mono/dbi/cordb-value.h +++ b/src/mono/dbi/cordb-value.h @@ -11,10 +11,10 @@ #include union CordbContent { - gint16 charValue; - gint8 booleanValue; - gint32 intValue; - gint64 longValue; + int16_t charValue; + int8_t booleanValue; + int32_t intValue; + int64_t longValue; void *pointerValue; }; diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 459c61ea46d4e5..4f67472cfe398b 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -4,42 +4,47 @@ // File: CORDB.CPP // -#include -#include - #include #include #include #include #include -#include #include #include #include -#include #include #include +#ifndef HOST_WIN32 +#include +#include +#else +#include +#include +#endif + + + int convert_mono_type_2_icordbg_size(int type) { switch (type) { - case MONO_TYPE_VOID: + case ELEMENT_TYPE_VOID: return 0; - case MONO_TYPE_BOOLEAN: - case MONO_TYPE_I1: - case MONO_TYPE_U1: + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: return 1; break; - case MONO_TYPE_CHAR: - case MONO_TYPE_I2: - case MONO_TYPE_U2: + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: return 2; - case MONO_TYPE_I4: - case MONO_TYPE_U4: - case MONO_TYPE_R4: + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: return 4; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - case MONO_TYPE_R8: + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: return 8; } return 0; @@ -147,10 +152,10 @@ HRESULT Cordb::CanLaunchOrAttach( Cordb::Cordb() { pCallback = NULL; - breakpoints = g_ptr_array_new(); - threads = g_ptr_array_new(); - functions = g_ptr_array_new(); - modules = g_hash_table_new(NULL, NULL); + breakpoints = new ArrayList(); + threads = new ArrayList(); + functions = new ArrayList(); + modules = new ArrayList(); #ifdef LOGGING InitializeLogging(); #endif @@ -158,8 +163,8 @@ Cordb::Cordb() { CordbFunction *Cordb::findFunction(int id) { int i = 0; - while (i < functions->len) { - CordbFunction *function = (CordbFunction *)g_ptr_array_index(functions, i); + while (i < functions->GetCount()) { + CordbFunction *function = (CordbFunction *)functions->Get(i); if (function->id == id) { return function; } @@ -170,8 +175,8 @@ CordbFunction *Cordb::findFunction(int id) { CordbFunction *Cordb::findFunctionByToken(int token) { int i = 0; - while (i < functions->len) { - CordbFunction *function = (CordbFunction *)g_ptr_array_index(functions, i); + while (i < functions->GetCount()) { + CordbFunction *function = (CordbFunction*)functions->Get(i); if (function->token == token) { return function; } @@ -220,20 +225,32 @@ HRESULT Cordb::DebugActiveProcessEx( return S_OK; } +HRESULT Cordb::GetModule(int module_id, ICorDebugModule** pModule) +{ + for (int i = 0; i < modules->GetCount(); i++) { + CordbModule* module = (CordbModule*)modules->Get(i); + if (module->id == module_id) { + *pModule = module; + return S_OK; + } + } + return S_FALSE; +} + Connection::Connection(CordbProcess *proc, Cordb *cordb) { ppProcess = proc; ppCordb = cordb; pCorDebugAppDomain = NULL; - received_replies = g_hash_table_new(NULL, NULL); - received_packets_to_process = g_ptr_array_new(); + received_replies = new ArrayList(); + received_packets_to_process = new ArrayList(); is_answer_pending = false; - pending_eval = g_ptr_array_new(); + pending_eval = new ArrayList(); } -CordbThread *Connection::findThread(GPtrArray *threads, long thread_id) { +CordbThread *Connection::findThread(ArrayList *threads, long thread_id) { int i = 0; - while (i < threads->len) { - CordbThread *thread = (CordbThread *)g_ptr_array_index(threads, i); + while (i < threads->GetCount()) { + CordbThread *thread = (CordbThread *)threads->Get(i); if (thread->thread_id == thread_id) { return thread; } @@ -288,38 +305,45 @@ void Connection::receive() { dbg_lock(); if (header.flags == REPLY_PACKET) { ReceivedReplyPacket *rp = - (ReceivedReplyPacket *)g_malloc0(sizeof(ReceivedReplyPacket)); + (ReceivedReplyPacket *)malloc(sizeof(ReceivedReplyPacket)); rp->error = header.error; rp->error_2 = header.error_2; + rp->id = header.id; rp->buf = recvbuf; - g_hash_table_insert(received_replies, (gpointer)(gssize)(header.id), rp); + received_replies->Append(rp); } else { - g_ptr_array_add(received_packets_to_process, recvbuf); + received_packets_to_process->Append(recvbuf); } dbg_unlock(); } } MdbgProtBuffer *Connection::get_answer(int cmdId) { - ReceivedReplyPacket *ret = NULL; - while (ret == NULL) { + ReceivedReplyPacket * rrp = NULL; + while (rrp == NULL || rrp->id != cmdId) { dbg_lock(); - ret = (ReceivedReplyPacket *)g_hash_table_lookup(received_replies, - (gpointer)(gssize)(cmdId)); + for (int i = received_replies->GetCount() - 1; i >= 0; i--) { + rrp = (ReceivedReplyPacket*)received_replies->Get(i); + if (rrp->id == cmdId) + break; + } dbg_unlock(); } - return ret->buf; + return rrp->buf; } ReceivedReplyPacket *Connection::get_answer_with_error(int cmdId) { - ReceivedReplyPacket *ret = NULL; - while (ret == NULL) { + ReceivedReplyPacket * rrp = NULL; + while (rrp == NULL || rrp->id != cmdId) { dbg_lock(); - ret = (ReceivedReplyPacket *)g_hash_table_lookup(received_replies, - (gpointer)(gssize)(cmdId)); + for (int i = received_replies->GetCount() - 1; i >= 0; i--) { + rrp = (ReceivedReplyPacket*)received_replies->Get(i); + if (rrp->id == cmdId) + break; + } dbg_unlock(); } - return ret; + return rrp; } void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { @@ -353,7 +377,7 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { } break; case MDBGPROT_EVENT_KIND_THREAD_START: { CordbThread *thread = new CordbThread(this, ppProcess, thread_id); - g_ptr_array_add(ppCordb->threads, thread); + ppCordb->threads->Append(thread); ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); } break; case MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE: { @@ -379,8 +403,7 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { ppProcess->suspended = true; ICorDebugModule *pModule = new CordbModule( this, ppProcess, (CordbAssembly *)pAssembly, assembly_id); - g_hash_table_insert(ppCordb->modules, GINT_TO_POINTER(assembly_id), - pModule); + ppCordb->modules->Append(pModule); ppCordb->pCallback->LoadModule(pCorDebugAppDomain, pModule); } break; case MDBGPROT_EVENT_KIND_BREAKPOINT: { @@ -391,15 +414,14 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { CordbThread *thread = findThread(ppCordb->threads, thread_id); if (thread == NULL) { thread = new CordbThread(this, ppProcess, thread_id); - g_ptr_array_add(ppCordb->threads, thread); + ppCordb->threads->Append(thread); ppProcess->Stop(false); ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); } int i = 0; CordbFunctionBreakpoint *breakpoint; - while (i < ppCordb->breakpoints->len) { - breakpoint = (CordbFunctionBreakpoint *)g_ptr_array_index( - ppCordb->breakpoints, i); + while (i < ppCordb->breakpoints->GetCount()) { + breakpoint = (CordbFunctionBreakpoint*)ppCordb->breakpoints->Get(i); if (breakpoint->offset == offset && breakpoint->code->func->id == method_id) { ppCordb->pCallback->Breakpoint( @@ -418,7 +440,7 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { CordbThread *thread = findThread(ppCordb->threads, thread_id); if (thread == NULL) { thread = new CordbThread(this, ppProcess, thread_id); - g_ptr_array_add(ppCordb->threads, thread); + ppCordb->threads->Append(thread); ppProcess->Stop(false); ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); } @@ -438,23 +460,28 @@ int Connection::process_packet(bool is_answer) { void Connection::process_packet_from_queue() { int i = 0; - while (i < received_packets_to_process->len) { + while (i < received_packets_to_process->GetCount()) { MdbgProtBuffer *req = - (MdbgProtBuffer *)g_ptr_array_index(received_packets_to_process, i); - process_packet_internal(req); - dbg_lock(); - g_ptr_array_remove_index_fast(received_packets_to_process, i); - dbg_unlock(); - delete req; - i--; + (MdbgProtBuffer *)received_packets_to_process->Get(i); + if (req) { + process_packet_internal(req); + dbg_lock(); + received_packets_to_process->Set(i, NULL); + dbg_unlock(); + delete req; + } + i++; } - while (i < pending_eval->len) { - CordbEval *eval = (CordbEval *)g_ptr_array_index(pending_eval, i); - ReceivedReplyPacket *recvbuf = get_answer_with_error(eval->cmdId); - eval->EvalComplete(recvbuf->buf); - dbg_lock(); - g_ptr_array_remove_index_fast(pending_eval, i); - dbg_unlock(); + while (i < pending_eval->GetCount()) { + CordbEval *eval = (CordbEval *)pending_eval->Get(i); + if (eval) { + ReceivedReplyPacket* recvbuf = get_answer_with_error(eval->cmdId); + if (recvbuf) + eval->EvalComplete(recvbuf->buf); + dbg_lock(); + pending_eval->Set(i, NULL); + dbg_unlock(); + } i--; } } @@ -604,7 +631,7 @@ void Connection::transport_handshake() { iResult = recv(connect_socket, (char *)recvbuf.buf, buflen, 0); // Send an initial buffer - m_dbgprot_buffer_add_data(&sendbuf, (guint8 *)"DWP-Handshake", 13); + m_dbgprot_buffer_add_data(&sendbuf, (uint8_t *)"DWP-Handshake", 13); send_packet(sendbuf); } diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 3cfef8b940a249..96e500c232b015 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -12,14 +12,11 @@ #include "corhdr.h" #include "xcordebug.h" -#include -#include -#include #include -#include #include -#include +#include "arraylist.h" +#include "utsem.h" #ifdef HOST_WIN32 #include @@ -32,15 +29,24 @@ return S_FALSE; \ } while (0) -#define dbg_lock() mono_os_mutex_lock(&debug_mutex.m); + +static UTSemReadWrite* m_pSemReadWrite = new UTSemReadWrite(); + +#define dbg_lock() m_pSemReadWrite->LockRead(); +#define dbg_unlock() m_pSemReadWrite->UnlockRead(); + +/*#define dbg_lock() mono_os_mutex_lock(&debug_mutex.m); #define dbg_unlock() mono_os_mutex_unlock(&debug_mutex.m); -static MonoCoopMutex debug_mutex; +static MonoCoopMutex debug_mutex;*/ #ifdef _DEBUG #define LOGGING -#include +#include "stdafx.h" +#include "log.h" #endif +#include "arraylist.h" + class Cordb; class CordbProcess; class CordbAppDomain; @@ -56,6 +62,7 @@ class CordbClass; typedef struct ReceivedReplyPacket { int error; int error_2; + int id; MdbgProtBuffer *buf; } ReceivedReplyPacket; @@ -63,10 +70,10 @@ int convert_mono_type_2_icordbg_size(int type); class Cordb : public ICorDebug, public ICorDebugRemote { public: - GPtrArray *breakpoints; - GPtrArray *threads; - GPtrArray *functions; - GHashTable *modules; + ArrayList *breakpoints; + ArrayList *threads; + ArrayList *functions; + ArrayList *modules; ICorDebugManagedCallback *pCallback; Cordb(); @@ -138,19 +145,20 @@ class Cordb : public ICorDebug, public ICorDebugRemote { /* [in] */ DWORD dwProcessId, /* [in] */ BOOL fWin32Attach, /* [out] */ ICorDebugProcess **ppProcess); + HRESULT GetModule(int module_id, ICorDebugModule** pModule); }; class Connection { - SOCKET connect_socket; + int connect_socket; bool is_answer_pending; public: CordbProcess *ppProcess; Cordb *ppCordb; CordbAppDomain *pCorDebugAppDomain; - GHashTable *received_replies; - GPtrArray *pending_eval; - GPtrArray *received_packets_to_process; + ArrayList *received_replies; + ArrayList *pending_eval; + ArrayList *received_packets_to_process; Connection(CordbProcess *proc, Cordb *cordb); void loop_send_receive(); void process_packet_internal(MdbgProtBuffer *recvbuf); @@ -167,7 +175,7 @@ class Connection { int process_packet(bool is_answer = false); MdbgProtBuffer *get_answer(int cmdId); ReceivedReplyPacket *get_answer_with_error(int cmdId); - CordbThread *findThread(GPtrArray *threads, long thread_id); + CordbThread *findThread(ArrayList *threads, long thread_id); }; class CordbBaseMono { diff --git a/src/mono/mono/mini/debugger-protocol.c b/src/mono/mono/mini/debugger-protocol.c index b2aa17d2a34397..96734ca43b444b 100644 --- a/src/mono/mono/mini/debugger-protocol.c +++ b/src/mono/mono/mini/debugger-protocol.c @@ -1,8 +1,18 @@ #include "debugger-protocol.h" + +#ifdef DBI_COMPONENT +#define g_malloc malloc +#define g_free free +#define g_assert assert +#define g_realloc realloc +#define mono_atomic_inc_i32 InterlockedIncrement +#include "stdafx.h" +#else +#include #include -#include "glib.h" +#endif -static int packet_id = 0; +static LONG packet_id = 0; /* * Functions to decode protocol data @@ -96,7 +106,7 @@ m_dbgprot_decode_string (uint8_t *buf, uint8_t **endbuf, uint8_t *limit) } uint8_t* -m_dbgprot_decode_byte_array (uint8_t *buf, uint8_t **endbuf, uint8_t *limit, uint32_t *len) +m_dbgprot_decode_byte_array (uint8_t *buf, uint8_t **endbuf, uint8_t *limit, int32_t *len) { *len = m_dbgprot_decode_int (buf, &buf, limit); uint8_t* s; @@ -267,7 +277,7 @@ m_dbgprot_event_to_string (MdbgProtEventKind event) case MDBGPROT_EVENT_KIND_USER_LOG: return "USER_LOG"; case MDBGPROT_EVENT_KIND_CRASH: return "CRASH"; default: - g_assert_not_reached (); + g_assert ( 1 ); return ""; } } diff --git a/src/mono/mono/mini/debugger-protocol.h b/src/mono/mono/mini/debugger-protocol.h index e7a69657ed4a53..23c8fa8c3f0524 100644 --- a/src/mono/mono/mini/debugger-protocol.h +++ b/src/mono/mono/mini/debugger-protocol.h @@ -341,7 +341,7 @@ int m_dbgprot_decode_int (uint8_t *buf, uint8_t **endbuf, uint8_t *limit); int64_t m_dbgprot_decode_long (uint8_t *buf, uint8_t **endbuf, uint8_t *limit); int m_dbgprot_decode_id (uint8_t *buf, uint8_t **endbuf, uint8_t *limit); char* m_dbgprot_decode_string (uint8_t *buf, uint8_t **endbuf, uint8_t *limit); -uint8_t* m_dbgprot_decode_byte_array(uint8_t* buf, uint8_t** endbuf, uint8_t* limit, uint32_t* len); +uint8_t* m_dbgprot_decode_byte_array(uint8_t *buf, uint8_t **endbuf, uint8_t *limit, int32_t *len); /* * Functions to encode protocol data From b3629ff393d7cbb0dd00cecf9ef93a791a464e19 Mon Sep 17 00:00:00 2001 From: Thays Date: Fri, 5 Feb 2021 16:13:04 -0300 Subject: [PATCH 06/64] Compiling on Mac --- src/coreclr/CMakeLists.txt | 1 + src/coreclr/clrdefinitions.cmake | 2 - src/coreclr/pal/src/configure.cmake | 2 +- src/coreclr/pal/src/libunwind/configure.cmake | 2 +- src/coreclr/utilcode/ccomprc.cpp | 4 + src/mono/dbi/CMakeLists.txt | 219 ++++++------------ src/mono/dbi/cordb-appdomain.cpp | 2 +- src/mono/dbi/cordb-assembly.cpp | 9 +- src/mono/dbi/cordb-blocking-obj.cpp | 4 +- src/mono/dbi/cordb-eval.cpp | 2 + src/mono/dbi/cordb-process.cpp | 2 +- src/mono/dbi/cordb-stepper.h | 4 +- src/mono/dbi/cordb-symbol.cpp | 4 +- src/mono/dbi/cordb-type.cpp | 2 +- src/mono/dbi/cordb-type.h | 2 +- src/mono/dbi/cordb-value.cpp | 99 ++++---- src/mono/dbi/cordb.cpp | 102 ++------ src/mono/dbi/cordb.h | 8 +- src/mono/dbi/socket-dbi/CMakeLists.txt | 10 + src/mono/dbi/socket-dbi/socket.cpp | 94 ++++++++ src/mono/dbi/socket-dbi/socket.h | 19 ++ src/mono/mono/mini/debugger-protocol.c | 8 +- 22 files changed, 298 insertions(+), 303 deletions(-) create mode 100644 src/mono/dbi/socket-dbi/CMakeLists.txt create mode 100644 src/mono/dbi/socket-dbi/socket.cpp create mode 100644 src/mono/dbi/socket-dbi/socket.h diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 9c9ba76da063ea..0894588ed1075d 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -117,6 +117,7 @@ endif(CLR_CMAKE_HOST_WIN32) # - all clr specific compile definitions should be included in this file # - all clr specific feature variable should also be added in this file #---------------------------------- +include(clrfeatures.cmake) include(clrdefinitions.cmake) if(FEATURE_STANDALONE_GC) diff --git a/src/coreclr/clrdefinitions.cmake b/src/coreclr/clrdefinitions.cmake index 674246d8e02165..d7e43f32cb8fdb 100644 --- a/src/coreclr/clrdefinitions.cmake +++ b/src/coreclr/clrdefinitions.cmake @@ -1,5 +1,3 @@ -include(clrfeatures.cmake) - add_compile_definitions($<$>:DACCESS_COMPILE>) add_compile_definitions($<$>:CROSSGEN_COMPILE>) add_compile_definitions($<$>:CROSS_COMPILE>) diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index af9836c894db98..60b8a61d9c5ea7 100644 --- a/src/coreclr/pal/src/configure.cmake +++ b/src/coreclr/pal/src/configure.cmake @@ -1422,4 +1422,4 @@ check_prototype_definition( ${STATFS_INCLUDES} HAVE_NON_LEGACY_STATFS) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +configure_file(${CMAKE_CURRENT_LIST_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff --git a/src/coreclr/pal/src/libunwind/configure.cmake b/src/coreclr/pal/src/libunwind/configure.cmake index 8e9c00abfbeb9b..e721db79f403b1 100644 --- a/src/coreclr/pal/src/libunwind/configure.cmake +++ b/src/coreclr/pal/src/libunwind/configure.cmake @@ -69,7 +69,7 @@ int main(void) return result; }" HAVE_STDALIGN_ALIGNAS) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) +configure_file(${CMAKE_CURRENT_LIST_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) add_definitions(-DHAVE_CONFIG_H=1) configure_file(include/libunwind-common.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind-common.h) diff --git a/src/coreclr/utilcode/ccomprc.cpp b/src/coreclr/utilcode/ccomprc.cpp index 1b38edf419e8fb..bae729c5e4434d 100644 --- a/src/coreclr/utilcode/ccomprc.cpp +++ b/src/coreclr/utilcode/ccomprc.cpp @@ -489,6 +489,9 @@ HRESULT CCompRC::LoadString(ResourceCategory eCategory, UINT iResourceID, __out_ HRESULT CCompRC::LoadString(ResourceCategory eCategory, LocaleID langId, UINT iResourceID, __out_ecount(iMax) LPWSTR szBuffer, int iMax, int *pcwchUsed) { +#ifdef DBI_COMPONENT_MONO + return E_NOTIMPL; +#else CONTRACTL { GC_NOTRIGGER; @@ -535,6 +538,7 @@ HRESULT CCompRC::LoadString(ResourceCategory eCategory, LocaleID langId, UINT iR return LoadNativeStringResource(NATIVE_STRING_RESOURCE_TABLE(NATIVE_STRING_RESOURCE_NAME), iResourceID, szBuffer, iMax, pcwchUsed); #endif // HOST_WINDOWS +#endif } #ifndef DACCESS_COMPILE diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 09182bbb71d8dc..920f2dd08187b8 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -1,127 +1,28 @@ project(mscordbi) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CLR_DIR ${PROJECT_SOURCE_DIR}/../../coreclr) +set(VM_DIR ${PROJECT_SOURCE_DIR}/../../coreclr/vm) +set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR}) + +add_definitions(-DDBI_COMPONENT_MONO) include_directories( - ${PROJECT_BINARY_DIR}/ - ${PROJECT_BINARY_DIR}/../.. ${CMAKE_CURRENT_SOURCE_DIR}/../.. - ${CMAKE_CURRENT_BINARY_DIR}/../ - ${PROJECT_SOURCE_DIR}/../mono/mini/ + ${PROJECT_SOURCE_DIR}/../mono/mini/ ${PROJECT_SOURCE_DIR}/../ ${PROJECT_SOURCE_DIR}/../dbi + ${PROJECT_SOURCE_DIR}/../dbi/socket-dbi ${PROJECT_SOURCE_DIR}/../../coreclr/md/enc ${PROJECT_SOURCE_DIR}/../../coreclr/inc - ${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/inc ${PROJECT_SOURCE_DIR}/../../coreclr/md/inc ${PROJECT_SOURCE_DIR}/../../coreclr/md/compiler) - -set(UTILCODE_COMMON_SOURCES_BASE - clrhost_nodependencies.cpp - ccomprc.cpp - ex.cpp - sbuffer.cpp - sstring_com.cpp - fstring.cpp - namespaceutil.cpp - makepath.cpp - splitpath.cpp - clrconfig.cpp - configuration.cpp - collections.cpp - posterror.cpp - fstream.cpp - clrhelpers.cpp - stgpool.cpp - stgpooli.cpp - stgpoolreadonly.cpp - utsem.cpp - peinformation.cpp - check.cpp - log.cpp - arraylist.cpp - bitvector.cpp - comex.cpp - guidfromname.cpp - memorypool.cpp - iallocator.cpp - loaderheap.cpp - outstring.cpp - ilformatter.cpp - opinfo.cpp - corimage.cpp - format1.cpp - prettyprintsig.cpp - regutil.cpp - sha1.cpp - sigbuilder.cpp - sigparser.cpp - sstring.cpp - util_nodependencies.cpp - utilmessagebox.cpp - safewrap.cpp - clrhost.cpp - cycletimer.cpp - md5.cpp - util.cpp - stresslog.cpp - debug.cpp - pedecoder.cpp - winfix.cpp - longfilepathwrappers.cpp - yieldprocessornormalized.cpp - hostimpl.cpp -) - -set(MDRUNTIMERW_SOURCES_BASE - md/enc/liteweightstgdbrw.cpp - md/enc/metamodelenc.cpp - md/enc/metamodelrw.cpp - md/enc/peparse.cpp - md/enc/rwutil.cpp - md/enc/stgio.cpp - md/enc/stgtiggerstorage.cpp - md/enc/stgtiggerstream.cpp - md/enc/mdinternalrw.cpp - md/enc/pdbheap.cpp - md/compiler/importhelper.cpp - md/runtime/metamodel.cpp - md/runtime/mdcolumndescriptors.cpp - md/runtime/recordpool.cpp - md/runtime/mdfileformat.cpp -) - -set(MDRUNTIMERW_HEADERS_BASE - inc/corhdr.h - inc/metadata.h - inc/mdfileformat.h - inc/pedecoder.h - inc/pedecoder.inl - inc/posterror.h - inc/sstring.h - inc/sstring.inl - md/compiler/importhelper.h - md/compiler/regmeta.h - md/hotdata/hotdataformat.h - md/inc/liteweightstgdb.h - md/inc/mdinternalrw.h - md/inc/mdlog.h - md/inc/metadatahash.h - md/inc/metamodel.h - md/inc/metamodelro.h - md/inc/metamodelrw.h - md/inc/pdbheap.h - md/inc/portablepdbmdds.h - md/inc/portablepdbmdi.h - md/inc/rwutil.h - md/inc/stgio.h - md/inc/stgtiggerstorage.h - md/inc/stgtiggerstream.h - md/inc/streamutil.h - md/runtime/mdinternalro.h - inc/debugmacros.h -) - set(mscorbi_sources_base cordb.cpp cordb.h @@ -161,56 +62,74 @@ set(mscorbi_sources_base cordb-value.h ) -if(HOST_WIN32) + +if(HOST_DARWIN) +set(OS_LIBS "-framework CoreFoundation" "-framework Foundation") +elseif(HOST_LINUX) +set(OS_LIBS pthread m dl) +elseif(HOST_WIN32) set(OS_LIBS bcrypt.lib Mswsock.lib ws2_32.lib psapi.lib version.lib advapi32.lib winmm.lib kernel32.lib) endif() - -if(HOST_WIN32) - list(APPEND UTILCODE_COMMON_SOURCES_BASE - dacutil.cpp - dlwrap.cpp - securitywrapper.cpp - securityutil.cpp - stacktrace.cpp - ) -endif(HOST_WIN32) - addprefix(mscorbi_sources ../dbi/ "${mscorbi_sources_base}") -addprefix(UTILCODE_COMMON_SOURCES ${PROJECT_SOURCE_DIR}/../../coreclr/utilcode/ "${UTILCODE_COMMON_SOURCES_BASE}") -addprefix(MDRUNTIMERW_SOURCES ${PROJECT_SOURCE_DIR}/../../coreclr/ "${MDRUNTIMERW_SOURCES_BASE}") -addprefix(MDRUNTIMERW_HEADERS ${PROJECT_SOURCE_DIR}/../../coreclr/ "${MDRUNTIMERW_HEADERS_BASE}") -addprefix(eglib_sources ../mono/eglib/ "${eglib_sources}") +add_subdirectory(${PROJECT_SOURCE_DIR}/socket-dbi) -add_library(mscordbi SHARED "${eglib_sources};${mscorbi_sources};${PROJECT_SOURCE_DIR}/../mono/mini/debugger-protocol.c;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/xcordebug_i.cpp;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/cordebug_i.cpp") -add_library(mdruntimerw-dbi STATIC "${MDRUNTIMERW_SOURCES};${MDRUNTIMERW_HEADERS}") -add_library(utilcode STATIC "${UTILCODE_COMMON_SOURCES}") +include(${PROJECT_SOURCE_DIR}/../../../eng/native/configuretools.cmake) +include(${PROJECT_SOURCE_DIR}/../../../eng/native/configurepaths.cmake) +include(${PROJECT_SOURCE_DIR}/../../../eng/native/configureplatform.cmake) +include(${PROJECT_SOURCE_DIR}/../../../eng/native/configurecompiler.cmake) +if (CLR_CMAKE_HOST_UNIX) + include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc") + include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc/rt") + include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/src/safecrt") -target_link_libraries(mscordbi mdruntimerw-dbi utilcode ${OS_LIBS}) -target_precompile_headers(mdruntimerw-dbi PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/md/enc/stdafx.h) -target_precompile_headers(utilcode PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/utilcode/stdafx.h) -target_precompile_headers(mscordbi PRIVATE ${PROJECT_SOURCE_DIR}/../../coreclr/utilcode/stdafx.h) + append("-Wno-missing-prototypes" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) -if(HOST_AMD64) - add_compile_definitions(TARGET_AMD64) - add_compile_definitions(HOST_64BIT) -endif(HOST_AMD64) + include_directories("../../coreclr/pal/inc/rt/cpp") + add_compile_options(-nostdinc) +endif (CLR_CMAKE_HOST_UNIX) -if(HOST_WIN32) - add_compile_definitions(HOST_WINDOWS) - target_compile_definitions(utilcode PRIVATE _CRTIMP=) -endif(HOST_WIN32) +include_directories("../../coreclr/pal/prebuilt/inc") +include_directories("../../coreclr/nativeresources") -add_compile_definitions(DBI_COMPONENT) -add_compile_definitions(FEATURE_COMINTEROP) -add_compile_definitions(SELF_NO_HOST) +add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/nativeresources nativeresources) +add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/md/runtime md/runtime) +add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/md/compiler md/compiler) +include(${PROJECT_SOURCE_DIR}/../../coreclr/clrdefinitions.cmake) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/../) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/../inc/) +add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/md/enc md/enc) +add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/utilcode utilcode) +if (CLR_CMAKE_HOST_UNIX) + add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/palrt palrt) +endif (CLR_CMAKE_HOST_UNIX) -SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER}) -SET_TARGET_PROPERTIES(mdruntimerw-dbi PROPERTIES LINKER_LANGUAGE CXX) -SET_TARGET_PROPERTIES(utilcode PROPERTIES LINKER_LANGUAGE CXX) +append("-Wno-strict-prototypes -Wno-deprecated" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) -set_target_properties(mdruntimerw-dbi PROPERTIES DBI_COMPONENT TRUE) +add_library(mscordbi SHARED "${mscorbi_sources};${PROJECT_SOURCE_DIR}/../mono/mini/debugger-protocol.c;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/xcordebug_i.cpp;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/cordebug_i.cpp") + +#SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER}) set_source_files_properties(${PROJECT_SOURCE_DIR}/../mono/mini/debugger-protocol.c PROPERTIES LANGUAGE CXX) + +set(COREDBI_LIBRARIES + utilcodestaticnohost + mdruntime-dbi + mdcompiler-dbi + mdruntimerw-dbi + socket-dbi + ${OS_LIBS} +) + +if(CLR_CMAKE_HOST_UNIX) + list(APPEND COREDBI_LIBRARIES + coreclrpal + palrt + nativeresourcestring + ) +endif() + +target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ) diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp index 263995aed01316..09ad15f32dbbb2 100644 --- a/src/mono/dbi/cordb-appdomain.cpp +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -165,7 +165,7 @@ CordbAppDomain::GetName(/* [in] */ ULONG32 cchName, *pcchName = strlen("DefaultDomain") + 1; return S_OK; } - wcscpy(szName, L"DefaultDomain"); + wcscpy(szName, W("DefaultDomain")); return S_OK; } diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index cd618357028db3..991936e60035dd 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -225,8 +225,13 @@ HRESULT CordbModule::GetName( free(assembly_name); return S_OK; } - mbstowcs(szName, assembly_name, strlen(assembly_name) + 1); - *pcchName = strlen(assembly_name) + 1; + MultiByteToWideChar(CP_UTF8, + 0, + assembly_name, + -1, + szName, + cchName); + *pcchName = cchName; free(assembly_name); return S_OK; } diff --git a/src/mono/dbi/cordb-blocking-obj.cpp b/src/mono/dbi/cordb-blocking-obj.cpp index fe1053073cb60a..dc55147e5f3e62 100644 --- a/src/mono/dbi/cordb-blocking-obj.cpp +++ b/src/mono/dbi/cordb-blocking-obj.cpp @@ -4,10 +4,8 @@ // File: CORDB-BLOCKING-OBJ.CPP // -#include #include - -using namespace std; +#include CordbBlockingObjectEnum::CordbBlockingObjectEnum(Connection *conn) : CordbBaseMono(conn) {} diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index 800cd4a6a65d2d..55b1240d9ef29c 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -69,6 +69,8 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( case ELEMENT_TYPE_STRING: m_dbgprot_buffer_add_id(&localbuf, cc->intValue); break; + default: + return E_NOTIMPL; } } cmdId = conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_INVOKE_METHOD, diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index d820d72f248d8d..74e8c4a65fab0a 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -4,9 +4,9 @@ // File: CORDB-PROCESS.CPP // +#include #include #include -#include using namespace std; diff --git a/src/mono/dbi/cordb-stepper.h b/src/mono/dbi/cordb-stepper.h index 1285a8776b2ea4..77f7756ff8a239 100644 --- a/src/mono/dbi/cordb-stepper.h +++ b/src/mono/dbi/cordb-stepper.h @@ -13,11 +13,11 @@ class CordbStepper : public CordbBaseMono, public ICorDebugStepper, public ICorDebugStepper2 { CordbThread *thread; - boolean hasStepped; + bool hasStepped; int eventId; public: - boolean isComplete; + bool isComplete; CordbStepper(Connection *conn, CordbThread *thread); HRESULT STDMETHODCALLTYPE IsActive(BOOL *pbActive); HRESULT STDMETHODCALLTYPE Deactivate(void); diff --git a/src/mono/dbi/cordb-symbol.cpp b/src/mono/dbi/cordb-symbol.cpp index b9fb8a18136c0a..898de4c8c31cc2 100644 --- a/src/mono/dbi/cordb-symbol.cpp +++ b/src/mono/dbi/cordb-symbol.cpp @@ -33,8 +33,8 @@ RegMeta::RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule) { ULONG32 pcchName = 0; cordbModule->GetName(0, &pcchName, NULL); - wchar_t *full_path; - full_path = (wchar_t *)malloc(sizeof(wchar_t) * pcchName); + WCHAR *full_path; + full_path = (WCHAR *)malloc(sizeof(WCHAR) * pcchName); cordbModule->GetName(pcchName, &pcchName, full_path); m_pStgdb->OpenForRead(full_path, NULL, 0, 0); diff --git a/src/mono/dbi/cordb-type.cpp b/src/mono/dbi/cordb-type.cpp index 0edf875a9dc44d..c6bfc05d06b2e9 100644 --- a/src/mono/dbi/cordb-type.cpp +++ b/src/mono/dbi/cordb-type.cpp @@ -11,7 +11,7 @@ using namespace std; -CordbType::CordbType(CorElementType type, CordbClass *klass, +CordbType::CordbType(CorElementType type, Connection *conn, CordbClass *klass, CordbType *typeParameter) : CordbBaseMono(conn) { this->klass = klass; diff --git a/src/mono/dbi/cordb-type.h b/src/mono/dbi/cordb-type.h index 660a7ac388698b..15ce0232749d50 100644 --- a/src/mono/dbi/cordb-type.h +++ b/src/mono/dbi/cordb-type.h @@ -17,7 +17,7 @@ class CordbType : public CordbBaseMono, CordbType *typeParameter; public: - CordbType(CorElementType type, CordbClass *klass = NULL, + CordbType(CorElementType type, Connection *conn, CordbClass *klass = NULL, CordbType *typeParameter = NULL); HRESULT STDMETHODCALLTYPE GetType(CorElementType *ty); HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass **ppClass); diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index 5135db0127f70c..ec1ec1e9324bb6 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -71,7 +71,7 @@ ULONG STDMETHODCALLTYPE CordbValue::Release(void) { return 0; } HRESULT STDMETHODCALLTYPE CordbValue::GetExactType(ICorDebugType **ppType) { LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetExactType - IMPLEMENTED\n")); - CordbType *tp = new CordbType(type); + CordbType *tp = new CordbType(type, conn); *ppType = static_cast(tp); return S_OK; } @@ -155,7 +155,7 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { return S_OK; } if (klass != NULL) { - cordbtype = new CordbType(type, klass); + cordbtype = new CordbType(type, conn, klass); *ppType = static_cast(cordbtype); return S_OK; } @@ -193,7 +193,7 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); klass = new CordbClass(conn, token, assembly_id); - cordbtype = new CordbType(type, klass); + cordbtype = new CordbType(type, conn, klass); *ppType = static_cast(cordbtype); return S_OK; } @@ -240,12 +240,12 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { klass = new CordbClass(conn, token, module_id); } - cordbtype = new CordbType(type, NULL, - new CordbType((CorElementType)type_id, klass)); + cordbtype = new CordbType(type, conn, NULL, + new CordbType((CorElementType)type_id, conn, klass)); *ppType = static_cast(cordbtype); return S_OK; } - CordbType *tp = new CordbType(type); + CordbType *tp = new CordbType(type, conn); *ppType = static_cast(tp); return S_OK; } @@ -375,7 +375,7 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetExactType(ICorDebugType **ppType) { LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetExactType - IMPLEMENTED\n")); - CordbType *tp = new CordbType(type, klass); + CordbType *tp = new CordbType(type, conn, klass); *ppType = static_cast(tp); return S_OK; } @@ -451,8 +451,13 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetString - IMPLEMENTED\n")); if (cchString >= strlen(value)) { - mbstowcs(szString, value, strlen(value) + 1); - *pcchString = strlen(value); + MultiByteToWideChar(CP_UTF8, + 0, + value, + -1, + szString, + cchString); + *pcchString = cchString; } } return S_OK; @@ -556,42 +561,8 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, CorElementType type = (CorElementType)m_dbgprot_decode_byte( bAnswer->buf, &bAnswer->buf, bAnswer->end); CordbContent value; - switch (type) { - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_I1: - case ELEMENT_TYPE_U1: - value.booleanValue = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - break; - case ELEMENT_TYPE_CHAR: - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - value.charValue = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - break; - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - case ELEMENT_TYPE_R4: - value.intValue = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - break; - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - case ELEMENT_TYPE_R8: - value.longValue = - m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); - break; - case ELEMENT_TYPE_CLASS: - case ELEMENT_TYPE_SZARRAY: - case ELEMENT_TYPE_STRING: { - int object_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - CordbReferenceValue *refValue = - new CordbReferenceValue(conn, type, object_id); - refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); - return S_OK; - } - case MDBGPROT_VALUE_TYPE_ID_NULL: { + + if ((MdbgProtValueTypeId)type == MDBGPROT_VALUE_TYPE_ID_NULL) { CorElementType type = (CorElementType)m_dbgprot_decode_byte( bAnswer->buf, &bAnswer->buf, bAnswer->end); if (type == ELEMENT_TYPE_CLASS || type == ELEMENT_TYPE_STRING) { @@ -661,13 +632,49 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, klass = new CordbClass(conn, token, module_id); } CordbType *cordbtype = new CordbType( - type, NULL, new CordbType((CorElementType)type_id, klass)); + type, conn, NULL, new CordbType((CorElementType)type_id, conn, klass)); CordbReferenceValue *refValue = new CordbReferenceValue(conn, type, -1, klass, cordbtype); refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); } return S_OK; } + + switch (type) { + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + value.booleanValue = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + break; + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + value.charValue = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + break; + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: + value.intValue = + m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + break; + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: + value.longValue = + m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); + break; + case ELEMENT_TYPE_CLASS: + case ELEMENT_TYPE_SZARRAY: + case ELEMENT_TYPE_STRING: { + int object_id = + m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + CordbReferenceValue *refValue = + new CordbReferenceValue(conn, type, object_id); + refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); + return S_OK; + } default: LOG((LF_CORDB, LL_INFO100000, "default value - %d", type)); return S_FALSE; diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 4f67472cfe398b..1e838c817f45fe 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -14,16 +14,7 @@ #include #include #include - -#ifndef HOST_WIN32 -#include -#include -#else -#include -#include -#endif - - +#include int convert_mono_type_2_icordbg_size(int type) { switch (type) { @@ -265,7 +256,7 @@ void Connection::receive() { m_dbgprot_buffer_init(&recvbuf_header, HEADER_LENGTH); int iResult = - recv(connect_socket, (char *)recvbuf_header.buf, HEADER_LENGTH, 0); + connect_socket->Receive((char *)recvbuf_header.buf, HEADER_LENGTH); if (iResult == -1) { ppCordb->pCallback->ExitProcess( @@ -277,7 +268,7 @@ void Connection::receive() { "transport_recv () sleep returned %d, expected %d.\n", iResult, HEADER_LENGTH)); iResult = - recv(connect_socket, (char *)recvbuf_header.buf, HEADER_LENGTH, 0); + connect_socket->Receive((char *)recvbuf_header.buf, HEADER_LENGTH); Sleep(1000); } @@ -292,12 +283,12 @@ void Connection::receive() { } if (header.len - HEADER_LENGTH != 0) { - iResult = recv(connect_socket, (char *)recvbuf->buf, - header.len - HEADER_LENGTH, 0); + iResult = connect_socket->Receive((char *)recvbuf->buf, + header.len - HEADER_LENGTH); int totalRead = iResult; while (totalRead < header.len - HEADER_LENGTH) { - iResult = recv(connect_socket, (char *)recvbuf->buf + totalRead, - (header.len - HEADER_LENGTH) - totalRead, 0); + iResult = connect_socket->Receive((char *)recvbuf->buf + totalRead, + (header.len - HEADER_LENGTH) - totalRead); totalRead += iResult; } } @@ -447,6 +438,9 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { ppCordb->pCallback->StepComplete(pCorDebugAppDomain, thread, thread->stepper, STEP_NORMAL); } break; + default: { + LOG((LF_CORDB, LL_INFO100000, "Not implemented - %s\n", m_dbgprot_event_to_string(etype))); + } } } // m_dbgprot_buffer_free(&recvbuf); @@ -545,77 +539,21 @@ void Connection::enable_event(MdbgProtEventKind eventKind) { } void Connection::close_connection() { - closesocket(connect_socket); - WSACleanup(); + connect_socket->Close(); } void Connection::start_connection() { LOG((LF_CORDB, LL_INFO100000, "Start Connection\n")); - WSADATA wsaData; - connect_socket = INVALID_SOCKET; - struct addrinfo *result = NULL, *ptr = NULL, hints; - int iResult; - - // Initialize Winsock - iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); - if (iResult != 0) { - return; - } - - ZeroMemory(&hints, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; + connect_socket = new Socket(); LOG((LF_CORDB, LL_INFO100000, "Listening to 127.0.0.1:1003\n")); - // Resolve the server address and port - iResult = getaddrinfo("127.0.0.1", "1003", &hints, &result); - if (iResult != 0) { - WSACleanup(); - return; - } - - // Attempt to connect to an address until one succeeds - for (ptr = result; ptr != NULL; ptr = ptr->ai_next) { - - // Create a SOCKET for connecting to server - connect_socket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); - - if (connect_socket == INVALID_SOCKET) { - WSACleanup(); - return; - } - - int flag = 1; - if (setsockopt(connect_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, - sizeof(int))) - continue; - - iResult = bind(connect_socket, ptr->ai_addr, (int)ptr->ai_addrlen); - if (iResult == -1) - continue; - - iResult = listen(connect_socket, 16); - if (iResult == -1) - continue; - - break; - } - - connect_socket = accept(connect_socket, NULL, NULL); - if (connect_socket == -1) + int ret = connect_socket->OpenSocketAcceptConnection("127.0.0.1", "1003"); + if (ret == -1) exit(1); LOG((LF_CORDB, LL_INFO100000, "Accepted connection from client.\n")); - - freeaddrinfo(result); - - if (connect_socket == INVALID_SOCKET) { - WSACleanup(); - return; - } } void Connection::transport_handshake() { @@ -628,7 +566,7 @@ void Connection::transport_handshake() { m_dbgprot_buffer_init(&recvbuf, buflen); int iResult; - iResult = recv(connect_socket, (char *)recvbuf.buf, buflen, 0); + iResult = connect_socket->Receive((char *)recvbuf.buf, buflen); // Send an initial buffer m_dbgprot_buffer_add_data(&sendbuf, (uint8_t *)"DWP-Handshake", 13); @@ -636,10 +574,8 @@ void Connection::transport_handshake() { } void Connection::send_packet(MdbgProtBuffer &sendbuf) { - int iResult = send(connect_socket, (const char *)sendbuf.buf, - m_dbgprot_buffer_len(&sendbuf), 0); - if (iResult == SOCKET_ERROR) { - WSACleanup(); + int iResult = connect_socket->Send((const char *)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf)); + if (iResult == -1) { return; } } @@ -647,14 +583,14 @@ void Connection::send_packet(MdbgProtBuffer &sendbuf) { void Connection::receive_packet(MdbgProtBuffer &recvbuf, int len) { m_dbgprot_buffer_init(&recvbuf, len); int iResult; - iResult = recv(connect_socket, (char *)recvbuf.buf, len, 0); + iResult = connect_socket->Receive((char *)recvbuf.buf, len); } void Connection::receive_header(MdbgProtHeader *header) { MdbgProtBuffer recvbuf; m_dbgprot_buffer_init(&recvbuf, 11); int iResult; - iResult = recv(connect_socket, (char *)recvbuf.buf, 11, 0); + iResult = connect_socket->Receive((char *)recvbuf.buf, HEADER_LENGTH); m_dbgprot_decode_command_header(&recvbuf, header); } diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 96e500c232b015..18572738293f01 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -39,14 +39,14 @@ static UTSemReadWrite* m_pSemReadWrite = new UTSemReadWrite(); #define dbg_unlock() mono_os_mutex_unlock(&debug_mutex.m); static MonoCoopMutex debug_mutex;*/ -#ifdef _DEBUG #define LOGGING -#include "stdafx.h" #include "log.h" -#endif #include "arraylist.h" +#define CreateProcess CreateProcessW + +class Socket; class Cordb; class CordbProcess; class CordbAppDomain; @@ -149,7 +149,7 @@ class Cordb : public ICorDebug, public ICorDebugRemote { }; class Connection { - int connect_socket; + Socket *connect_socket; bool is_answer_pending; public: diff --git a/src/mono/dbi/socket-dbi/CMakeLists.txt b/src/mono/dbi/socket-dbi/CMakeLists.txt new file mode 100644 index 00000000000000..5e2a352ee67cd0 --- /dev/null +++ b/src/mono/dbi/socket-dbi/CMakeLists.txt @@ -0,0 +1,10 @@ +project(socket-dbi) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(socket_sources + socket.cpp + socket.h +) + +add_library(socket-dbi STATIC ${socket_sources}) diff --git a/src/mono/dbi/socket-dbi/socket.cpp b/src/mono/dbi/socket-dbi/socket.cpp new file mode 100644 index 00000000000000..9d954407cb43c2 --- /dev/null +++ b/src/mono/dbi/socket-dbi/socket.cpp @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: SOCKET.CPP +// + +#include "socket.h" + +#ifdef HOST_WIN32 +#include +#include +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + + +int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { + socketId = -1; + + struct addrinfo *result = NULL, *ptr = NULL, hints; + int iResult; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + // Resolve the server address and port + iResult = getaddrinfo(address, port, &hints, &result); + if (iResult != 0) { + return -1; + } + + // Attempt to connect to an address until one succeeds + for (ptr = result; ptr != NULL; ptr = ptr->ai_next) { + + // Create a SOCKET for connecting to server + socketId = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); + + if (socketId == -1) { + return socketId; + } + + int flag = 1; + if (setsockopt(socketId, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, + sizeof(int))) + continue; + + iResult = bind(socketId, ptr->ai_addr, (int)ptr->ai_addrlen); + if (iResult == -1) + continue; + + iResult = listen(socketId, 16); + if (iResult == -1) + continue; + + break; + } + + socketId = accept(socketId, NULL, NULL); + + freeaddrinfo(result); + + return socketId; +} + +int Socket::Receive(char *buff, int buflen) { + return recv(socketId, buff, buflen, 0); +} + +void Socket::Close() { +#ifdef HOST_WIN32 + closesocket (socketId); +#else + close (socketId); +#endif +} + +int Socket::Send(const char *buff, int buflen) { + return send(socketId, buff, buflen, 0); +} diff --git a/src/mono/dbi/socket-dbi/socket.h b/src/mono/dbi/socket-dbi/socket.h new file mode 100644 index 00000000000000..5b536e4b53c315 --- /dev/null +++ b/src/mono/dbi/socket-dbi/socket.h @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: SOCKET.H +// + +#ifndef __SOCKET_DBI_H__ +#define __SOCKET_DBI_H__ + +class Socket { + int socketId; +public: + int OpenSocketAcceptConnection(const char *address, const char *port); + void Close(); + int Receive(char *buff, int buflen); + int Send(const char *buff, int buflen); +}; + +#endif diff --git a/src/mono/mono/mini/debugger-protocol.c b/src/mono/mono/mini/debugger-protocol.c index 96734ca43b444b..9dd6d0583feb4e 100644 --- a/src/mono/mono/mini/debugger-protocol.c +++ b/src/mono/mono/mini/debugger-protocol.c @@ -1,18 +1,20 @@ #include "debugger-protocol.h" -#ifdef DBI_COMPONENT +#ifdef DBI_COMPONENT_MONO #define g_malloc malloc #define g_free free #define g_assert assert #define g_realloc realloc #define mono_atomic_inc_i32 InterlockedIncrement #include "stdafx.h" +static LONG packet_id = 0; #else #include #include +static int packet_id = 0; #endif -static LONG packet_id = 0; + /* * Functions to decode protocol data @@ -111,7 +113,7 @@ m_dbgprot_decode_byte_array (uint8_t *buf, uint8_t **endbuf, uint8_t *limit, int *len = m_dbgprot_decode_int (buf, &buf, limit); uint8_t* s; - if (len < 0) { + if (*len < 0) { *endbuf = buf; return NULL; } From d78b7a22cbb1a2e722bab44b9612df53bd5ed6c5 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Fri, 5 Feb 2021 19:04:05 -0300 Subject: [PATCH 07/64] Compiling and Working on windows. Changing what @lambdageek suggested about mono_atomic_inc_i32 --- src/mono/dbi/CMakeLists.txt | 7 ++-- src/mono/dbi/cordb-appdomain.cpp | 4 +-- src/mono/dbi/cordb-appdomain.h | 2 +- src/mono/dbi/cordb-assembly.cpp | 2 +- src/mono/dbi/cordb-eval.cpp | 2 +- src/mono/dbi/cordb-symbol.cpp | 2 -- src/mono/dbi/cordb-value.cpp | 2 +- src/mono/dbi/cordb.cpp | 16 ++++----- src/mono/dbi/cordb.h | 2 ++ src/mono/dbi/debugger-coreclr-compat.h | 25 +++++++++++++ src/mono/dbi/socket-dbi/socket.cpp | 6 ++-- src/mono/mono/mini/debugger-mono-compat.h | 21 +++++++++++ src/mono/mono/mini/debugger-protocol.c | 44 ++++++++++------------- src/mono/mono/mini/debugger-protocol.h | 12 +++---- 14 files changed, 93 insertions(+), 54 deletions(-) create mode 100644 src/mono/dbi/debugger-coreclr-compat.h create mode 100644 src/mono/mono/mini/debugger-mono-compat.h diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 920f2dd08187b8..c379a39f779197 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -9,12 +9,14 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CLR_DIR ${PROJECT_SOURCE_DIR}/../../coreclr) set(VM_DIR ${PROJECT_SOURCE_DIR}/../../coreclr/vm) set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR}) +set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") +set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") +set(CLR_CMAKE_HOST_ARCH ${CMAKE_GENERATOR_PLATFORM}) add_definitions(-DDBI_COMPONENT_MONO) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../.. - ${PROJECT_SOURCE_DIR}/../mono/mini/ ${PROJECT_SOURCE_DIR}/../ ${PROJECT_SOURCE_DIR}/../dbi ${PROJECT_SOURCE_DIR}/../dbi/socket-dbi @@ -105,10 +107,9 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/md/enc md/enc) add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/utilcode utilcode) if (CLR_CMAKE_HOST_UNIX) add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/palrt palrt) + append("-Wno-strict-prototypes -Wno-deprecated" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif (CLR_CMAKE_HOST_UNIX) -append("-Wno-strict-prototypes -Wno-deprecated" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) - add_library(mscordbi SHARED "${mscorbi_sources};${PROJECT_SOURCE_DIR}/../mono/mini/debugger-protocol.c;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/xcordebug_i.cpp;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/cordebug_i.cpp") #SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER}) diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp index 09ad15f32dbbb2..4f2c340b8502f7 100644 --- a/src/mono/dbi/cordb-appdomain.cpp +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -162,7 +162,7 @@ CordbAppDomain::GetName(/* [in] */ ULONG32 cchName, /* [length_is][size_is][out] */ WCHAR szName[]) { LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetName - IMPLEMENTED\n")); if (cchName < strlen("DefaultDomain")) { - *pcchName = strlen("DefaultDomain") + 1; + *pcchName = (ULONG32)strlen("DefaultDomain") + 1; return S_OK; } wcscpy(szName, W("DefaultDomain")); @@ -235,7 +235,7 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, LOG((LF_CORDB, LL_INFO100000, "CordbAppDomainEnum - Next - NOT IMPLEMENTED\n")); *pceltFetched = celt; - for (int i = 0; i < celt; i++) { + for (ULONG i = 0; i < celt; i++) { if (current_pos >= pProcess->appdomains->GetCount()) { *pceltFetched = 0; return S_FALSE; diff --git a/src/mono/dbi/cordb-appdomain.h b/src/mono/dbi/cordb-appdomain.h index a1a360d87f27aa..9a2b6fecf8237a 100644 --- a/src/mono/dbi/cordb-appdomain.h +++ b/src/mono/dbi/cordb-appdomain.h @@ -79,7 +79,7 @@ class CordbAppDomain : public CordbBaseMono, }; class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum { - int current_pos; + DWORD current_pos; CordbProcess *pProcess; public: diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 991936e60035dd..ef880e20847d29 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -221,7 +221,7 @@ HRESULT CordbModule::GetName( m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); if (cchName < strlen(assembly_name) + 1) { - *pcchName = strlen(assembly_name) + 1; + *pcchName = (ULONG32)strlen(assembly_name) + 1; free(assembly_name); return S_OK; } diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index 55b1240d9ef29c..763d89ae55421e 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -37,7 +37,7 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( m_dbgprot_buffer_add_int(&localbuf, 1); m_dbgprot_buffer_add_int(&localbuf, ((CordbFunction *)pFunction)->id); m_dbgprot_buffer_add_int(&localbuf, nArgs); - for (int i = 0; i < nArgs; i++) { + for (ULONG32 i = 0; i < nArgs; i++) { CorElementType ty; ppArgs[i]->GetType(&ty); CordbContent *cc; diff --git a/src/mono/dbi/cordb-symbol.cpp b/src/mono/dbi/cordb-symbol.cpp index 898de4c8c31cc2..07879332ea2d1d 100644 --- a/src/mono/dbi/cordb-symbol.cpp +++ b/src/mono/dbi/cordb-symbol.cpp @@ -5,8 +5,6 @@ // #include "corerror.h" -#include "mdlog.h" -#include "posterror.h" #include "metamodel.h" #include "metamodelpub.h" #include "rwutil.h" diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index ec1ec1e9324bb6..460150d8678a00 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -418,7 +418,7 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32 *pcchString) { MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - *pcchString = + *pcchString = (ULONG32) m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); return S_OK; } diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 1e838c817f45fe..050b449c188f2b 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -153,7 +153,7 @@ Cordb::Cordb() { } CordbFunction *Cordb::findFunction(int id) { - int i = 0; + DWORD i = 0; while (i < functions->GetCount()) { CordbFunction *function = (CordbFunction *)functions->Get(i); if (function->id == id) { @@ -165,7 +165,7 @@ CordbFunction *Cordb::findFunction(int id) { } CordbFunction *Cordb::findFunctionByToken(int token) { - int i = 0; + DWORD i = 0; while (i < functions->GetCount()) { CordbFunction *function = (CordbFunction*)functions->Get(i); if (function->token == token) { @@ -218,7 +218,7 @@ HRESULT Cordb::DebugActiveProcessEx( HRESULT Cordb::GetModule(int module_id, ICorDebugModule** pModule) { - for (int i = 0; i < modules->GetCount(); i++) { + for (DWORD i = 0; i < modules->GetCount(); i++) { CordbModule* module = (CordbModule*)modules->Get(i); if (module->id == module_id) { *pModule = module; @@ -239,7 +239,7 @@ Connection::Connection(CordbProcess *proc, Cordb *cordb) { } CordbThread *Connection::findThread(ArrayList *threads, long thread_id) { - int i = 0; + DWORD i = 0; while (i < threads->GetCount()) { CordbThread *thread = (CordbThread *)threads->Get(i); if (thread->thread_id == thread_id) { @@ -400,7 +400,7 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { case MDBGPROT_EVENT_KIND_BREAKPOINT: { int method_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); - long offset = + int64_t offset = m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); CordbThread *thread = findThread(ppCordb->threads, thread_id); if (thread == NULL) { @@ -409,7 +409,7 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { ppProcess->Stop(false); ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); } - int i = 0; + DWORD i = 0; CordbFunctionBreakpoint *breakpoint; while (i < ppCordb->breakpoints->GetCount()) { breakpoint = (CordbFunctionBreakpoint*)ppCordb->breakpoints->Get(i); @@ -426,7 +426,7 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { case MDBGPROT_EVENT_KIND_STEP: { int method_id = m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); - long offset = + int64_t offset = m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); CordbThread *thread = findThread(ppCordb->threads, thread_id); if (thread == NULL) { @@ -453,7 +453,7 @@ int Connection::process_packet(bool is_answer) { } void Connection::process_packet_from_queue() { - int i = 0; + DWORD i = 0; while (i < received_packets_to_process->GetCount()) { MdbgProtBuffer *req = (MdbgProtBuffer *)received_packets_to_process->Get(i); diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 18572738293f01..808e4e774d6ad3 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -39,8 +39,10 @@ static UTSemReadWrite* m_pSemReadWrite = new UTSemReadWrite(); #define dbg_unlock() mono_os_mutex_unlock(&debug_mutex.m); static MonoCoopMutex debug_mutex;*/ +#ifdef _DEBUG #define LOGGING #include "log.h" +#endif #include "arraylist.h" diff --git a/src/mono/dbi/debugger-coreclr-compat.h b/src/mono/dbi/debugger-coreclr-compat.h new file mode 100644 index 00000000000000..0d9f9654a621e8 --- /dev/null +++ b/src/mono/dbi/debugger-coreclr-compat.h @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: DEBUGGER-CORECLR-COMPAT.H +// + +#ifndef __DBG_CORECLR_MONO_COMPAT_H__ +#define __DBG_CORECLR_MONO_COMPAT_H__ + +#define g_malloc malloc +#define g_free free +#define g_assert assert +#define g_realloc realloc +#include "stdafx.h" + +static +inline +int32_t +dbg_rt_atomic_inc_int32_t (volatile int32_t *value) +{ + STATIC_CONTRACT_NOTHROW; + return static_cast(InterlockedIncrement ((volatile LONG *)(value))); +} + +#endif \ No newline at end of file diff --git a/src/mono/dbi/socket-dbi/socket.cpp b/src/mono/dbi/socket-dbi/socket.cpp index 9d954407cb43c2..9507fa58018a8f 100644 --- a/src/mono/dbi/socket-dbi/socket.cpp +++ b/src/mono/dbi/socket-dbi/socket.cpp @@ -6,7 +6,7 @@ #include "socket.h" -#ifdef HOST_WIN32 +#ifdef WIN32 #include #include #else @@ -74,7 +74,7 @@ int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { freeaddrinfo(result); - return socketId; + return 1; } int Socket::Receive(char *buff, int buflen) { @@ -82,7 +82,7 @@ int Socket::Receive(char *buff, int buflen) { } void Socket::Close() { -#ifdef HOST_WIN32 +#ifdef WIN32 closesocket (socketId); #else close (socketId); diff --git a/src/mono/mono/mini/debugger-mono-compat.h b/src/mono/mono/mini/debugger-mono-compat.h new file mode 100644 index 00000000000000..0492a71f3468cf --- /dev/null +++ b/src/mono/mono/mini/debugger-mono-compat.h @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: DEBUGGER-MONO-COMPAT.H +// + +#ifndef __DBG_MONO_MONO_COMPAT_H__ +#define __DBG_MONO_MONO_COMPAT_H__ + +#include +#include + +static +inline +int32_t +dbg_rt_atomic_inc_int32_t (volatile int32_t *value) +{ + return (int32_t)mono_atomic_inc_i32 ((volatile gint32 *)value); +} + +#endif \ No newline at end of file diff --git a/src/mono/mono/mini/debugger-protocol.c b/src/mono/mono/mini/debugger-protocol.c index 9dd6d0583feb4e..9294b49982b254 100644 --- a/src/mono/mono/mini/debugger-protocol.c +++ b/src/mono/mono/mini/debugger-protocol.c @@ -1,20 +1,12 @@ #include "debugger-protocol.h" #ifdef DBI_COMPONENT_MONO -#define g_malloc malloc -#define g_free free -#define g_assert assert -#define g_realloc realloc -#define mono_atomic_inc_i32 InterlockedIncrement -#include "stdafx.h" -static LONG packet_id = 0; +#include "debugger-coreclr-compat.h" #else -#include -#include -static int packet_id = 0; +#include "debugger-mono-compat.h" #endif - +static int32_t packet_id = 0; /* * Functions to decode protocol data @@ -22,16 +14,16 @@ static int packet_id = 0; int m_dbgprot_buffer_add_command_header (MdbgProtBuffer *data, int command_set, int command, MdbgProtBuffer *out) { - int id = mono_atomic_inc_i32 (&packet_id); + int id = dbg_rt_atomic_inc_int32_t ((volatile int32_t *)&packet_id); - int len = data->p - data->buf + HEADER_LENGTH; + uint32_t len = (uint32_t)(data->p - data->buf + HEADER_LENGTH); m_dbgprot_buffer_init (out, len); m_dbgprot_buffer_add_int (out, len); m_dbgprot_buffer_add_int (out, id); m_dbgprot_buffer_add_byte (out, 0); /* flags */ m_dbgprot_buffer_add_byte (out, command_set); m_dbgprot_buffer_add_byte (out, command); - m_dbgprot_buffer_add_data (out, data->buf, data->p - data->buf); + m_dbgprot_buffer_add_data (out, data->buf, (uint32_t) (data->p - data->buf)); return id; } @@ -133,26 +125,26 @@ m_dbgprot_decode_byte_array (uint8_t *buf, uint8_t **endbuf, uint8_t *limit, int */ void -m_dbgprot_buffer_init (MdbgProtBuffer *buf, int size) +m_dbgprot_buffer_init (MdbgProtBuffer *buf, uint32_t size) { buf->buf = (uint8_t *)g_malloc (size); buf->p = buf->buf; buf->end = buf->buf + size; } -int +uint32_t m_dbgprot_buffer_len (MdbgProtBuffer *buf) { - return buf->p - buf->buf; + return (uint32_t)(buf->p - buf->buf); } void -m_dbgprot_buffer_make_room (MdbgProtBuffer *buf, int size) +m_dbgprot_buffer_make_room (MdbgProtBuffer *buf, uint32_t size) { if (buf->end - buf->p < size) { - int new_size = buf->end - buf->buf + size + 32; + int64_t new_size = buf->end - buf->buf + size + 32; uint8_t *p = (uint8_t *)g_realloc (buf->buf, new_size); - size = buf->p - buf->buf; + size = (uint32_t) (buf->p - buf->buf); buf->buf = p; buf->p = p + size; buf->end = buf->buf + new_size; @@ -195,13 +187,13 @@ m_dbgprot_buffer_add_long (MdbgProtBuffer *buf, uint64_t l) } void -m_dbgprot_buffer_add_id (MdbgProtBuffer *buf, int id) +m_dbgprot_buffer_add_id (MdbgProtBuffer *buf, uint32_t id) { - m_dbgprot_buffer_add_int (buf, (uint64_t)id); + m_dbgprot_buffer_add_int (buf, id); } void -m_dbgprot_buffer_add_data (MdbgProtBuffer *buf, uint8_t *data, int len) +m_dbgprot_buffer_add_data (MdbgProtBuffer *buf, uint8_t *data, uint32_t len) { m_dbgprot_buffer_make_room (buf, len); memcpy (buf->p, data, len); @@ -209,7 +201,7 @@ m_dbgprot_buffer_add_data (MdbgProtBuffer *buf, uint8_t *data, int len) } void -m_dbgprot_buffer_add_utf16 (MdbgProtBuffer *buf, uint8_t *data, int len) +m_dbgprot_buffer_add_utf16 (MdbgProtBuffer *buf, uint8_t *data, uint32_t len) { #if G_BYTE_ORDER == G_LITTLE_ENDIAN m_dbgprot_buffer_make_room (buf, len); @@ -226,12 +218,12 @@ m_dbgprot_buffer_add_utf16 (MdbgProtBuffer *buf, uint8_t *data, int len) void m_dbgprot_buffer_add_string (MdbgProtBuffer *buf, const char *str) { - int len; + uint32_t len; if (str == NULL) { m_dbgprot_buffer_add_int (buf, 0); } else { - len = strlen (str); + len = (uint32_t) strlen (str); m_dbgprot_buffer_add_int (buf, len); m_dbgprot_buffer_add_data (buf, (uint8_t*)str, len); } diff --git a/src/mono/mono/mini/debugger-protocol.h b/src/mono/mono/mini/debugger-protocol.h index 23c8fa8c3f0524..1d2c9e871b70b2 100644 --- a/src/mono/mono/mini/debugger-protocol.h +++ b/src/mono/mono/mini/debugger-protocol.h @@ -347,16 +347,16 @@ uint8_t* m_dbgprot_decode_byte_array(uint8_t *buf, uint8_t **endbuf, uint8_t *li * Functions to encode protocol data */ -void m_dbgprot_buffer_init (MdbgProtBuffer *buf, int size); -int m_dbgprot_buffer_len (MdbgProtBuffer *buf); -void m_dbgprot_buffer_make_room (MdbgProtBuffer *buf, int size); +void m_dbgprot_buffer_init (MdbgProtBuffer *buf, uint32_t size); +uint32_t m_dbgprot_buffer_len (MdbgProtBuffer *buf); +void m_dbgprot_buffer_make_room (MdbgProtBuffer *buf, uint32_t size); void m_dbgprot_buffer_add_byte (MdbgProtBuffer *buf, uint8_t val); void m_dbgprot_buffer_add_short (MdbgProtBuffer *buf, uint32_t val); void m_dbgprot_buffer_add_int (MdbgProtBuffer *buf, uint32_t val); void m_dbgprot_buffer_add_long (MdbgProtBuffer *buf, uint64_t l); -void m_dbgprot_buffer_add_id (MdbgProtBuffer *buf, int id); -void m_dbgprot_buffer_add_data (MdbgProtBuffer *buf, uint8_t *data, int len); -void m_dbgprot_buffer_add_utf16 (MdbgProtBuffer *buf, uint8_t *data, int len); +void m_dbgprot_buffer_add_id (MdbgProtBuffer *buf, uint32_t id); +void m_dbgprot_buffer_add_data (MdbgProtBuffer *buf, uint8_t *data, uint32_t len); +void m_dbgprot_buffer_add_utf16 (MdbgProtBuffer *buf, uint8_t *data, uint32_t len); void m_dbgprot_buffer_add_string (MdbgProtBuffer *buf, const char *str); void m_dbgprot_buffer_add_byte_array (MdbgProtBuffer *buf, uint8_t *bytes, uint32_t arr_len); void m_dbgprot_buffer_add_buffer (MdbgProtBuffer *buf, MdbgProtBuffer *data); From 130866a2af9e566f3957854840874675f345793f Mon Sep 17 00:00:00 2001 From: Thays Date: Fri, 5 Feb 2021 19:17:41 -0300 Subject: [PATCH 08/64] Generating libmscordbi on mac --- src/mono/dbi/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index c379a39f779197..d24ef6a5048ef8 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -134,3 +134,4 @@ if(CLR_CMAKE_HOST_UNIX) endif() target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ) +install(TARGETS mscordbi DESTINATION lib) From 759501dcc1c7fb37a4b2d88c98372fba6bddfff5 Mon Sep 17 00:00:00 2001 From: Thays Date: Fri, 12 Feb 2021 13:41:37 -0300 Subject: [PATCH 09/64] Fix socket on mac --- src/mono/dbi/socket-dbi/socket.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mono/dbi/socket-dbi/socket.cpp b/src/mono/dbi/socket-dbi/socket.cpp index 9507fa58018a8f..ee902e8fed7839 100644 --- a/src/mono/dbi/socket-dbi/socket.cpp +++ b/src/mono/dbi/socket-dbi/socket.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #endif @@ -55,22 +57,23 @@ int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { } int flag = 1; - if (setsockopt(socketId, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, - sizeof(int))) - continue; + if (setsockopt(socketId, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof(int))) + continue; iResult = bind(socketId, ptr->ai_addr, (int)ptr->ai_addrlen); + int err = errno; if (iResult == -1) - continue; + continue; iResult = listen(socketId, 16); if (iResult == -1) - continue; + continue; break; } - socketId = accept(socketId, NULL, NULL); + if (iResult != -1) + socketId = accept(socketId, NULL, NULL); freeaddrinfo(result); From 74524ab879d1be6e0f2cff5fbf990d77df08eeda Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Fri, 19 Feb 2021 16:50:25 -0300 Subject: [PATCH 10/64] Counting references, deleting objects, removing unecessary properties, formating with cland-format, renaming properties to follow the used pattern. --- src/mono/dbi/cordb-appdomain.cpp | 117 +++--- src/mono/dbi/cordb-appdomain.h | 124 +++--- src/mono/dbi/cordb-assembly.cpp | 231 +++++----- src/mono/dbi/cordb-assembly.h | 149 +++---- src/mono/dbi/cordb-blocking-obj.cpp | 17 +- src/mono/dbi/cordb-blocking-obj.h | 19 +- src/mono/dbi/cordb-breakpoint.cpp | 25 +- src/mono/dbi/cordb-breakpoint.h | 27 +- src/mono/dbi/cordb-chain.cpp | 77 ++-- src/mono/dbi/cordb-chain.h | 78 ++-- src/mono/dbi/cordb-class.cpp | 24 +- src/mono/dbi/cordb-class.h | 30 +- src/mono/dbi/cordb-code.cpp | 34 +- src/mono/dbi/cordb-code.h | 49 ++- src/mono/dbi/cordb-eval.cpp | 68 +-- src/mono/dbi/cordb-eval.h | 73 ++-- src/mono/dbi/cordb-frame.cpp | 213 +++++----- src/mono/dbi/cordb-frame.h | 193 ++++----- src/mono/dbi/cordb-function.cpp | 95 +++-- src/mono/dbi/cordb-function.h | 60 +-- src/mono/dbi/cordb-process.cpp | 428 ++++++++++++------- src/mono/dbi/cordb-process.h | 237 ++++++----- src/mono/dbi/cordb-register.cpp | 49 +-- src/mono/dbi/cordb-register.h | 41 +- src/mono/dbi/cordb-stepper.cpp | 68 ++- src/mono/dbi/cordb-stepper.h | 36 +- src/mono/dbi/cordb-symbol.cpp | 17 +- src/mono/dbi/cordb-symbol.h | 383 +++++++++-------- src/mono/dbi/cordb-thread.cpp | 188 +++++---- src/mono/dbi/cordb-thread.h | 114 ++--- src/mono/dbi/cordb-type.cpp | 62 ++- src/mono/dbi/cordb-type.h | 57 +-- src/mono/dbi/cordb-value.cpp | 448 +++++++++++--------- src/mono/dbi/cordb-value.h | 278 ++++++------ src/mono/dbi/cordb.cpp | 561 +++++++++++-------------- src/mono/dbi/cordb.h | 227 +++++----- src/mono/dbi/debugger-coreclr-compat.h | 10 +- src/mono/dbi/socket-dbi/socket.cpp | 7 +- src/mono/dbi/socket-dbi/socket.h | 3 +- src/mono/mono/mini/debugger-protocol.c | 14 +- 40 files changed, 2504 insertions(+), 2427 deletions(-) diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp index 4f2c340b8502f7..e1b9e7cf5c9e21 100644 --- a/src/mono/dbi/cordb-appdomain.cpp +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -10,18 +10,18 @@ using namespace std; -CordbAppDomain::CordbAppDomain(Connection *conn, ICorDebugProcess *ppProcess) +CordbAppDomain::CordbAppDomain(Connection *conn, CordbProcess *ppProcess) : CordbBaseMono(conn) { pProcess = ppProcess; - ((CordbProcess*)(ppProcess))->appdomains->Append(this); + pProcess->AddAppDomain(this); } -HRESULT CordbAppDomain::Stop(/* [in] */ DWORD dwTimeoutIgnored) { +HRESULT CordbAppDomain::Stop(DWORD dwTimeoutIgnored) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Stop - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::Continue(/* [in] */ BOOL fIsOutOfBand) { +HRESULT CordbAppDomain::Continue(BOOL fIsOutOfBand) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Continue - NOT IMPLEMENTED\n")); @@ -29,29 +29,29 @@ HRESULT CordbAppDomain::Continue(/* [in] */ BOOL fIsOutOfBand) { return S_OK; } -HRESULT CordbAppDomain::IsRunning(/* [out] */ BOOL *pbRunning) { +HRESULT CordbAppDomain::IsRunning(BOOL *pbRunning) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - IsRunning - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::HasQueuedCallbacks(/* [in] */ ICorDebugThread *pThread, - /* [out] */ BOOL *pbQueued) { +HRESULT CordbAppDomain::HasQueuedCallbacks(ICorDebugThread *pThread, + BOOL *pbQueued) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - HasQueuedCallbacks - NOT IMPLEMENTED\n")); return S_OK; } HRESULT -CordbAppDomain::EnumerateThreads(/* [out] */ ICorDebugThreadEnum **ppThreads) { +CordbAppDomain::EnumerateThreads(ICorDebugThreadEnum **ppThreads) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateThreads - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::SetAllThreadsDebugState( - /* [in] */ CorDebugThreadState state, /* [in] */ - ICorDebugThread *pExceptThisThread) { +HRESULT +CordbAppDomain::SetAllThreadsDebugState(CorDebugThreadState state, + ICorDebugThread *pExceptThisThread) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); return S_OK; @@ -62,33 +62,32 @@ HRESULT CordbAppDomain::Detach(void) { return S_OK; } -HRESULT CordbAppDomain::Terminate(/* [in] */ UINT exitCode) { +HRESULT CordbAppDomain::Terminate(UINT exitCode) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Terminate - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::CanCommitChanges( - /* [in] */ ULONG cSnapshots, /* [size_is][in] */ - ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ - ICorDebugErrorInfoEnum **pError) { +HRESULT +CordbAppDomain::CanCommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot *pSnapshots[], + ICorDebugErrorInfoEnum **pError) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - CanCommitChanges - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::CommitChanges( - /* [in] */ ULONG cSnapshots, /* [size_is][in] */ - ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ - ICorDebugErrorInfoEnum **pError) { +HRESULT +CordbAppDomain::CommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot *pSnapshots[], + ICorDebugErrorInfoEnum **pError) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - CommitChanges - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::QueryInterface( - /* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { + REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { if (id == IID_ICorDebugAppDomain) { *ppInterface = (ICorDebugAppDomain *)this; } else if (id == IID_ICorDebugAppDomain2) { @@ -105,61 +104,53 @@ HRESULT CordbAppDomain::QueryInterface( *ppInterface = NULL; return E_NOINTERFACE; } + AddRef(); return S_OK; } -ULONG CordbAppDomain::AddRef(void) { return S_OK; } - -ULONG CordbAppDomain::Release(void) { return S_OK; } - -HRESULT CordbAppDomain::GetProcess( - /* [out] */ ICorDebugProcess **ppProcess) { +HRESULT CordbAppDomain::GetProcess(ICorDebugProcess **ppProcess) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetProcess - NOT IMPLEMENTED\n")); - - *ppProcess = pProcess; + pProcess->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); return S_OK; } -HRESULT CordbAppDomain::EnumerateAssemblies( - /* [out] */ ICorDebugAssemblyEnum **ppAssemblies) { +HRESULT +CordbAppDomain::EnumerateAssemblies(ICorDebugAssemblyEnum **ppAssemblies) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateAssemblies - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::GetModuleFromMetaDataInterface( - /* [in] */ IUnknown *pIMetaData, /* [out] */ - ICorDebugModule **ppModule) { +HRESULT +CordbAppDomain::GetModuleFromMetaDataInterface(IUnknown *pIMetaData, + ICorDebugModule **ppModule) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetModuleFromMetaDataInterface - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::EnumerateBreakpoints( - /* [out] */ ICorDebugBreakpointEnum **ppBreakpoints) { +HRESULT +CordbAppDomain::EnumerateBreakpoints(ICorDebugBreakpointEnum **ppBreakpoints) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateBreakpoints - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::EnumerateSteppers( - /* [out] */ ICorDebugStepperEnum **ppSteppers) { +HRESULT CordbAppDomain::EnumerateSteppers(ICorDebugStepperEnum **ppSteppers) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateSteppers - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::IsAttached(/* [out] */ BOOL *pbAttached) { +HRESULT CordbAppDomain::IsAttached(BOOL *pbAttached) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - IsAttached - NOT IMPLEMENTED\n")); return S_OK; } HRESULT -CordbAppDomain::GetName(/* [in] */ ULONG32 cchName, - /* [out] */ ULONG32 *pcchName, - /* [length_is][size_is][out] */ WCHAR szName[]) { +CordbAppDomain::GetName(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]) { LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetName - IMPLEMENTED\n")); if (cchName < strlen("DefaultDomain")) { *pcchName = (ULONG32)strlen("DefaultDomain") + 1; @@ -170,7 +161,7 @@ CordbAppDomain::GetName(/* [in] */ ULONG32 cchName, return S_OK; } -HRESULT CordbAppDomain::GetObject(/* [out] */ ICorDebugValue **ppObject) { +HRESULT CordbAppDomain::GetObject(ICorDebugValue **ppObject) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetObject - NOT IMPLEMENTED\n")); return S_OK; @@ -181,48 +172,46 @@ HRESULT CordbAppDomain::Attach(void) { return S_OK; } -HRESULT CordbAppDomain::GetID(/* [out] */ ULONG32 *pId) { +HRESULT CordbAppDomain::GetID(ULONG32 *pId) { *pId = 0; LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetID - IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::GetArrayOrPointerType( - /* [in] */ CorElementType elementType, /* [in] */ ULONG32 nRank, - /* [in] */ - ICorDebugType *pTypeArg, /* [out] */ ICorDebugType **ppType) { +HRESULT CordbAppDomain::GetArrayOrPointerType(CorElementType elementType, + ULONG32 nRank, + + ICorDebugType *pTypeArg, + ICorDebugType **ppType) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetArrayOrPointerType - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAppDomain::GetFunctionPointerType( - /* [in] */ ULONG32 nTypeArgs, /* [size_is][in] */ - ICorDebugType *ppTypeArgs[], /* [out] */ - ICorDebugType **ppType) { +HRESULT CordbAppDomain::GetFunctionPointerType(ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[], + ICorDebugType **ppType) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetFunctionPointerType - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::GetCachedWinRTTypesForIIDs( - /* [in] */ ULONG32 cReqTypes, /* [size_is][in] */ - GUID *iidsToResolve, /* [out] */ - ICorDebugTypeEnum **ppTypesEnum) { + ULONG32 cReqTypes, GUID *iidsToResolve, ICorDebugTypeEnum **ppTypesEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetCachedWinRTTypesForIIDs - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAppDomain::GetCachedWinRTTypes( - /* [out] */ ICorDebugGuidToTypeEnum **ppGuidToTypeEnum) { + ICorDebugGuidToTypeEnum **ppGuidToTypeEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetCachedWinRTTypes - NOT IMPLEMENTED\n")); return S_OK; } HRESULT -CordbAppDomain::GetObjectForCCW(/* [in] */ CORDB_ADDRESS ccwPointer, /* [out] */ +CordbAppDomain::GetObjectForCCW(CORDB_ADDRESS ccwPointer, ICorDebugValue **ppManagedObject) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetObjectForCCW - NOT IMPLEMENTED\n")); @@ -236,11 +225,12 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, "CordbAppDomainEnum - Next - NOT IMPLEMENTED\n")); *pceltFetched = celt; for (ULONG i = 0; i < celt; i++) { - if (current_pos >= pProcess->appdomains->GetCount()) { + if (current_pos >= pProcess->appDomains->GetCount()) { *pceltFetched = 0; return S_FALSE; } - CordbAppDomain* appdomain = (CordbAppDomain*)pProcess->appdomains->Get(current_pos); + CordbAppDomain *appdomain = + (CordbAppDomain *)pProcess->appDomains->Get(current_pos); appdomain->QueryInterface(IID_ICorDebugAppDomain, (void **)values + current_pos); current_pos++; @@ -270,7 +260,7 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Clone(ICorDebugEnum **ppEnum) { HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::GetCount(ULONG *pcelt) { LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomainEnum - GetCount - IMPLEMENTED\n")); - *pcelt = pProcess->appdomains->GetCount(); + *pcelt = pProcess->appDomains->GetCount(); return S_OK; } @@ -288,13 +278,10 @@ CordbAppDomainEnum::QueryInterface(REFIID id, void **pInterface) { "CordbAppDomain - QueryInterface - NOT IMPLEMENTED\n")); return E_NOINTERFACE; } + AddRef(); return S_OK; } -ULONG STDMETHODCALLTYPE CordbAppDomainEnum::AddRef(void) { return 1; } - -ULONG STDMETHODCALLTYPE CordbAppDomainEnum::Release(void) { return 1; } - CordbAppDomainEnum::CordbAppDomainEnum(Connection *conn, CordbProcess *ppProcess) : CordbBaseMono(conn) { diff --git a/src/mono/dbi/cordb-appdomain.h b/src/mono/dbi/cordb-appdomain.h index 9a2b6fecf8237a..bfc17b89da1606 100644 --- a/src/mono/dbi/cordb-appdomain.h +++ b/src/mono/dbi/cordb-appdomain.h @@ -14,68 +14,64 @@ class CordbAppDomain : public CordbBaseMono, public ICorDebugAppDomain2, public ICorDebugAppDomain3, public ICorDebugAppDomain4 { + CordbProcess *pProcess; + public: - CordbAppDomain(Connection *conn, ICorDebugProcess *ppProcess); - ICorDebugProcess *pProcess; - HRESULT STDMETHODCALLTYPE Stop(/* [in] */ DWORD dwTimeoutIgnored); - HRESULT STDMETHODCALLTYPE Continue(/* [in] */ BOOL fIsOutOfBand); - HRESULT STDMETHODCALLTYPE IsRunning(/* [out] */ BOOL *pbRunning); - HRESULT STDMETHODCALLTYPE HasQueuedCallbacks( - /* [in] */ ICorDebugThread *pThread, /* [out] */ BOOL *pbQueued); - HRESULT STDMETHODCALLTYPE - EnumerateThreads(/* [out] */ ICorDebugThreadEnum **ppThreads); - HRESULT STDMETHODCALLTYPE - SetAllThreadsDebugState(/* [in] */ CorDebugThreadState state, /* [in] */ + CordbAppDomain(Connection *conn, CordbProcess *ppProcess); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbAppDomain"; } + HRESULT Stop(DWORD dwTimeoutIgnored); + HRESULT Continue(BOOL fIsOutOfBand); + HRESULT IsRunning(BOOL *pbRunning); + HRESULT HasQueuedCallbacks(ICorDebugThread *pThread, BOOL *pbQueued); + HRESULT + EnumerateThreads(ICorDebugThreadEnum **ppThreads); + HRESULT + SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread *pExceptThisThread); - HRESULT STDMETHODCALLTYPE Detach(void); - HRESULT STDMETHODCALLTYPE Terminate(/* [in] */ UINT exitCode); - HRESULT STDMETHODCALLTYPE - CanCommitChanges(/* [in] */ ULONG cSnapshots, /* [size_is][in] */ - ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + HRESULT Detach(void); + HRESULT Terminate(UINT exitCode); + HRESULT + CanCommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot *pSnapshots[], ICorDebugErrorInfoEnum **pError); - HRESULT STDMETHODCALLTYPE - CommitChanges(/* [in] */ ULONG cSnapshots, /* [size_is][in] */ - ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + HRESULT + CommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot *pSnapshots[], ICorDebugErrorInfoEnum **pError); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE - GetProcess(/* [out] */ ICorDebugProcess **ppProcess); - HRESULT STDMETHODCALLTYPE - EnumerateAssemblies(/* [out] */ ICorDebugAssemblyEnum **ppAssemblies); - HRESULT STDMETHODCALLTYPE GetModuleFromMetaDataInterface( - /* [in] */ IUnknown *pIMetaData, /* [out] */ ICorDebugModule **ppModule); - HRESULT STDMETHODCALLTYPE - EnumerateBreakpoints(/* [out] */ ICorDebugBreakpointEnum **ppBreakpoints); - HRESULT STDMETHODCALLTYPE - EnumerateSteppers(/* [out] */ ICorDebugStepperEnum **ppSteppers); - HRESULT STDMETHODCALLTYPE IsAttached(/* [out] */ BOOL *pbAttached); - HRESULT STDMETHODCALLTYPE - GetName(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, - /* [length_is][size_is][out] */ WCHAR szName[]); - HRESULT STDMETHODCALLTYPE GetObject(/* [out] */ ICorDebugValue **ppObject); - HRESULT STDMETHODCALLTYPE Attach(void); - HRESULT STDMETHODCALLTYPE GetID(/* [out] */ ULONG32 *pId); - HRESULT STDMETHODCALLTYPE GetArrayOrPointerType( - /* [in] */ CorElementType elementType, /* [in] */ ULONG32 nRank, - /* [in] */ ICorDebugType *pTypeArg, /* [out] */ - ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE - GetFunctionPointerType(/* [in] */ ULONG32 nTypeArgs, /* [size_is][in] */ - ICorDebugType *ppTypeArgs[], /* [out] */ + HRESULT + GetProcess(ICorDebugProcess **ppProcess); + HRESULT + EnumerateAssemblies(ICorDebugAssemblyEnum **ppAssemblies); + HRESULT GetModuleFromMetaDataInterface(IUnknown *pIMetaData, + ICorDebugModule **ppModule); + HRESULT + EnumerateBreakpoints(ICorDebugBreakpointEnum **ppBreakpoints); + HRESULT + EnumerateSteppers(ICorDebugStepperEnum **ppSteppers); + HRESULT IsAttached(BOOL *pbAttached); + HRESULT + GetName(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]); + HRESULT GetObject(ICorDebugValue **ppObject); + HRESULT Attach(void); + HRESULT GetID(ULONG32 *pId); + HRESULT GetArrayOrPointerType(CorElementType elementType, ULONG32 nRank, + ICorDebugType *pTypeArg, + ICorDebugType **ppType); + HRESULT + GetFunctionPointerType(ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE - GetCachedWinRTTypesForIIDs(/* [in] */ ULONG32 cReqTypes, /* [size_is][in] */ - GUID *iidsToResolve, /* [out] */ + HRESULT + GetCachedWinRTTypesForIIDs(ULONG32 cReqTypes, GUID *iidsToResolve, ICorDebugTypeEnum **ppTypesEnum); - HRESULT STDMETHODCALLTYPE - GetCachedWinRTTypes(/* [out] */ ICorDebugGuidToTypeEnum **ppGuidToTypeEnum); - HRESULT STDMETHODCALLTYPE - GetObjectForCCW(/* [in] */ CORDB_ADDRESS ccwPointer, /* [out] */ - ICorDebugValue **ppManagedObject); + HRESULT + GetCachedWinRTTypes(ICorDebugGuidToTypeEnum **ppGuidToTypeEnum); + HRESULT + GetObjectForCCW(CORDB_ADDRESS ccwPointer, ICorDebugValue **ppManagedObject); }; class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum { @@ -84,15 +80,15 @@ class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum { public: CordbAppDomainEnum(Connection *conn, CordbProcess *ppProcess); - HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugAppDomain *values[], - ULONG *pceltFetched); - HRESULT STDMETHODCALLTYPE Skip(ULONG celt); - HRESULT STDMETHODCALLTYPE Reset(void); - HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum **ppEnum); - HRESULT STDMETHODCALLTYPE GetCount(ULONG *pcelt); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbAppDomainEnum"; } + HRESULT Next(ULONG celt, ICorDebugAppDomain *values[], ULONG *pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum **ppEnum); + HRESULT GetCount(ULONG *pcelt); + HRESULT QueryInterface(REFIID riid, void **ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index ef880e20847d29..6eae2102120ed7 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -17,54 +17,50 @@ using namespace std; CordbAssembly::CordbAssembly(Connection *conn, CordbProcess *process, CordbAppDomain *appDomain, int id_assembly) : CordbBaseMono(conn) { - pProcess = process; - pAppDomain = appDomain; - id = id_assembly; + m_pProcess = process; + m_pAppDomain = appDomain; + m_pAppDomain->InternalAddRef(); + m_debuggerId = id_assembly; } -HRESULT CordbAssembly::IsFullyTrusted(/* [out] */ BOOL *pbFullyTrusted) { +CordbAssembly::~CordbAssembly() { m_pAppDomain->InternalRelease(); } + +HRESULT CordbAssembly::IsFullyTrusted(BOOL *pbFullyTrusted) { *pbFullyTrusted = true; LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - IsFullyTrusted - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAssembly::GetAppDomain( - /* [out] */ ICorDebugAppDomain **ppAppDomain) { +HRESULT CordbAssembly::GetAppDomain(ICorDebugAppDomain **ppAppDomain) { LOG((LF_CORDB, LL_INFO1000000, "CorDebugAssembly - GetAppDomain - IMPLEMENTED\n")); - *ppAppDomain = static_cast(pAppDomain); + m_pAppDomain->QueryInterface(IID_ICorDebugAppDomain, (void **)ppAppDomain); return S_OK; } -HRESULT CordbAssembly::EnumerateModules( - /* [out] */ ICorDebugModuleEnum **ppModules) { +HRESULT CordbAssembly::EnumerateModules(ICorDebugModuleEnum **ppModules) { LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - EnumerateModules - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAssembly::GetCodeBase( - /* [in] */ ULONG32 cchName, - /* [out] */ ULONG32 *pcchName, - /* [length_is][size_is][out] */ WCHAR szName[]) { +HRESULT CordbAssembly::GetCodeBase(ULONG32 cchName, ULONG32 *pcchName, + WCHAR szName[]) { LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - GetCodeBase - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbAssembly::GetName( - /* [in] */ ULONG32 cchName, - /* [out] */ ULONG32 *pcchName, - /* [length_is][size_is][out] */ WCHAR szName[]) { +HRESULT CordbAssembly::GetName(ULONG32 cchName, ULONG32 *pcchName, + WCHAR szName[]) { LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - GetName - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbAssembly::QueryInterface( - /* [in] */ REFIID id, - /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { + REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { if (id == IID_ICorDebugAssembly) *ppInterface = static_cast(this); else if (id == IID_ICorDebugAssembly2) @@ -76,22 +72,37 @@ HRESULT CordbAssembly::QueryInterface( *ppInterface = NULL; return E_NOINTERFACE; } - + AddRef(); return S_OK; } -ULONG CordbAssembly::AddRef(void) { return S_OK; } - -ULONG CordbAssembly::Release(void) { return S_OK; } +HRESULT CordbAssembly::GetProcess(ICorDebugProcess **ppProcess) { + LOG((LF_CORDB, LL_INFO1000000, + "CorDebugAssembly - GetProcess - IMPLEMENTED\n")); + conn->GetProcess()->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); + return S_OK; +} CordbModule::CordbModule(Connection *conn, CordbProcess *process, CordbAssembly *assembly, int id_assembly) : CordbBaseMono(conn) { - pProcess = process; - pCordbSymbol = NULL; - pAssembly = assembly; - id = id_assembly; + m_pProcess = process; + m_pRegMeta = NULL; + m_pAssembly = assembly; + m_debuggerId = id_assembly; + m_pAssembly->InternalAddRef(); dwFlags = 0; + conn->GetProcess()->AddModule(this); + m_pAssemblyMetadataBlob = NULL; +} + +CordbModule::~CordbModule() { + if (m_pRegMeta) + m_pRegMeta->InternalRelease(); + if (m_pAssembly) + m_pAssembly->InternalRelease(); + if (m_pAssemblyMetadataBlob) + free(m_pAssemblyMetadataBlob); } HRESULT CordbModule::QueryInterface(REFIID id, void **pInterface) { @@ -109,245 +120,217 @@ HRESULT CordbModule::QueryInterface(REFIID id, void **pInterface) { *pInterface = NULL; return E_NOINTERFACE; } + AddRef(); return S_OK; } -ULONG CordbModule::AddRef(void) { return S_OK; } - -ULONG CordbModule::Release(void) { return S_OK; } - -HRESULT CordbModule::IsMappedLayout( - /* [out] */ BOOL *pIsMapped) { +HRESULT CordbModule::IsMappedLayout(BOOL *pIsMapped) { *pIsMapped = FALSE; LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsMappedLayout - IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::CreateReaderForInMemorySymbols( - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppObj) { +HRESULT CordbModule::CreateReaderForInMemorySymbols(REFIID riid, void **ppObj) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - CreateReaderForInMemorySymbols - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::SetJMCStatus( - /* [in] */ BOOL bIsJustMyCode, - /* [in] */ ULONG32 cTokens, - /* [size_is][in] */ mdToken pTokens[]) { +HRESULT CordbModule::SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, + mdToken pTokens[]) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - SetJMCStatus - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::ApplyChanges( - /* [in] */ ULONG cbMetadata, - /* [size_is][in] */ BYTE pbMetadata[], - /* [in] */ ULONG cbIL, - /* [size_is][in] */ BYTE pbIL[]) { +HRESULT CordbModule::ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], + ULONG cbIL, BYTE pbIL[]) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - ApplyChanges - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::SetJITCompilerFlags( - /* [in] */ DWORD dwFlags) { +HRESULT CordbModule::SetJITCompilerFlags(DWORD dwFlags) { this->dwFlags = dwFlags; LOG((LF_CORDB, LL_INFO100000, "CordbModule - SetJITCompilerFlags - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::GetJITCompilerFlags( - /* [out] */ DWORD *pdwFlags) { +HRESULT CordbModule::GetJITCompilerFlags(DWORD *pdwFlags) { *pdwFlags = dwFlags; LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetJITCompilerFlags - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::ResolveAssembly( - /* [in] */ mdToken tkAssemblyRef, - /* [out] */ ICorDebugAssembly **ppAssembly) { +HRESULT CordbModule::ResolveAssembly(mdToken tkAssemblyRef, + ICorDebugAssembly **ppAssembly) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - ResolveAssembly - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::GetProcess( - /* [out] */ ICorDebugProcess **ppProcess) { +HRESULT CordbModule::GetProcess(ICorDebugProcess **ppProcess) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetProcess - NOT IMPLEMENTED\n")); - // *ppProcess = pProcess; + conn->GetProcess()->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); return S_OK; } -HRESULT CordbModule::GetBaseAddress( - /* [out] */ CORDB_ADDRESS *pAddress) { +HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS *pAddress) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, id); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); int cmdId = - conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, - MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); + conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, + MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - assembly_metadata_blob = m_dbgprot_decode_byte_array( - bAnswer->buf, &bAnswer->buf, bAnswer->end, &assembly_metadata_len); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array( + bAnswer->p, &bAnswer->p, bAnswer->end, &m_assemblyMetadataLen); LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); - *pAddress = (CORDB_ADDRESS)assembly_metadata_blob; + *pAddress = (CORDB_ADDRESS)m_pAssemblyMetadataBlob; return S_OK; } -HRESULT CordbModule::GetName( - /* [in] */ ULONG32 cchName, - /* [out] */ ULONG32 *pcchName, - /* [length_is][size_is][out] */ WCHAR szName[]) { +HRESULT CordbModule::GetName(ULONG32 cchName, ULONG32 *pcchName, + WCHAR szName[]) { LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetName - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, - MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, + MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); char *assembly_name = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); if (cchName < strlen(assembly_name) + 1) { *pcchName = (ULONG32)strlen(assembly_name) + 1; free(assembly_name); return S_OK; } - MultiByteToWideChar(CP_UTF8, - 0, - assembly_name, - -1, - szName, - cchName); + MultiByteToWideChar(CP_UTF8, 0, assembly_name, -1, szName, cchName); *pcchName = cchName; free(assembly_name); return S_OK; } -HRESULT CordbModule::EnableJITDebugging( - /* [in] */ BOOL bTrackJITInfo, - /* [in] */ BOOL bAllowJitOpts) { +HRESULT CordbModule::EnableJITDebugging(BOOL bTrackJITInfo, + BOOL bAllowJitOpts) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - EnableJITDebugging - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::EnableClassLoadCallbacks( - /* [in] */ BOOL bClassLoadCallbacks) { +HRESULT CordbModule::EnableClassLoadCallbacks(BOOL bClassLoadCallbacks) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - EnableClassLoadCallbacks - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::GetFunctionFromToken( - /* [in] */ mdMethodDef methodDef, - /* [out] */ ICorDebugFunction **ppFunction) { +HRESULT CordbModule::GetFunctionFromToken(mdMethodDef methodDef, + ICorDebugFunction **ppFunction) { // check in a cache before talk to mono runtime to get info LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetFunctionFromToken - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); m_dbgprot_buffer_add_int(&localbuf, methodDef); int cmdId = - conn->send_event(MDBGPROT_CMD_SET_ASSEMBLY, - MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); + conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, + MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + int id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); CordbFunction *func = NULL; - func = pProcess->cordb->findFunction(id); + func = m_pProcess->FindFunction(id); if (func == NULL) { func = new CordbFunction(conn, methodDef, id, this); - pProcess->cordb->functions->Append(func); } - *ppFunction = func; + func->QueryInterface(IID_ICorDebugFunction, (void **)ppFunction); return S_OK; } -HRESULT CordbModule::GetFunctionFromRVA( - /* [in] */ CORDB_ADDRESS rva, - /* [out] */ ICorDebugFunction **ppFunction) { +HRESULT CordbModule::GetFunctionFromRVA(CORDB_ADDRESS rva, + ICorDebugFunction **ppFunction) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetFunctionFromRVA - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::GetClassFromToken( - /* [in] */ mdTypeDef typeDef, - /* [out] */ ICorDebugClass **ppClass) { - CordbClass *pClass = new CordbClass(conn, typeDef, id); - *ppClass = static_cast(pClass); +HRESULT CordbModule::GetClassFromToken(mdTypeDef typeDef, + ICorDebugClass **ppClass) { + CordbClass *pClass = new CordbClass(conn, typeDef, GetDebuggerId()); + pClass->QueryInterface(IID_ICorDebugClass, (void **)ppClass); return S_OK; } -HRESULT CordbModule::CreateBreakpoint( - /* [out] */ ICorDebugModuleBreakpoint **ppBreakpoint) { +HRESULT +CordbModule::CreateBreakpoint(ICorDebugModuleBreakpoint **ppBreakpoint) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - CreateBreakpoint - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbModule::GetEditAndContinueSnapshot( - /* [out] */ ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot) { + ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetEditAndContinueSnapshot - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::GetMetaDataInterface( - /* [in] */ REFIID riid, - /* [out] */ IUnknown **ppObj) { - if (pCordbSymbol == NULL) - pCordbSymbol = new RegMeta(pAssembly, this); - pCordbSymbol->QueryInterface(riid, (void **)ppObj); +HRESULT CordbModule::GetMetaDataInterface(REFIID riid, IUnknown **ppObj) { + if (m_pRegMeta == NULL) { + m_pRegMeta = new RegMeta(m_pAssembly, this); + m_pRegMeta->InternalAddRef(); + } + m_pRegMeta->QueryInterface(riid, (void **)ppObj); LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetMetaDataInterface - IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::GetToken( - /* [out] */ mdModule *pToken) { +HRESULT CordbModule::GetToken(mdModule *pToken) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetToken - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::IsDynamic( - /* [out] */ BOOL *pDynamic) { +HRESULT CordbModule::IsDynamic(BOOL *pDynamic) { LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::GetGlobalVariableValue( - /* [in] */ mdFieldDef fieldDef, - /* [out] */ ICorDebugValue **ppValue) { +HRESULT CordbModule::GetGlobalVariableValue(mdFieldDef fieldDef, + ICorDebugValue **ppValue) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetGlobalVariableValue - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbModule::GetSize( - /* [out] */ ULONG32 *pcBytes) { +HRESULT CordbModule::GetSize(ULONG32 *pcBytes) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetSize -IMPLEMENTED\n")); - *pcBytes = assembly_metadata_len; + *pcBytes = m_assemblyMetadataLen; return S_OK; } -HRESULT CordbModule::IsInMemory( - /* [out] */ BOOL *pInMemory) { +HRESULT CordbModule::IsInMemory(BOOL *pInMemory) { LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsInMemory - IMPLEMENTED\n")); return S_OK; } + +HRESULT CordbModule::GetAssembly(ICorDebugAssembly **ppAssembly) { + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetAssembly - IMPLEMENTED\n")); + m_pAssembly->QueryInterface(IID_ICorDebugAssembly, (void **)ppAssembly); + return S_OK; +} diff --git a/src/mono/dbi/cordb-assembly.h b/src/mono/dbi/cordb-assembly.h index 118b0b5c4a7e5f..0bbc177147760c 100644 --- a/src/mono/dbi/cordb-assembly.h +++ b/src/mono/dbi/cordb-assembly.h @@ -14,99 +14,90 @@ class CordbModule : public CordbBaseMono, public ICorDebugModule2, public ICorDebugModule3, public ICorDebugModule4 { -public: - int id; // id on mono side; - CordbProcess *pProcess; - RegMeta *pCordbSymbol; - CordbAssembly *pAssembly; - uint8_t *assembly_metadata_blob; - int32_t assembly_metadata_len; + int m_debuggerId; // id on mono side; + CordbProcess *m_pProcess; + RegMeta *m_pRegMeta; + CordbAssembly *m_pAssembly; + uint8_t *m_pAssemblyMetadataBlob; + int32_t m_assemblyMetadataLen; unsigned long dwFlags; +public: CordbModule(Connection *conn, CordbProcess *process, CordbAssembly *assembly, int id_assembly); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbModule"; } + ~CordbModule(); - HRESULT CordbModule::QueryInterface(REFIID id, void **pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE IsMappedLayout(/* [out] */ BOOL *pIsMapped); - HRESULT STDMETHODCALLTYPE CreateReaderForInMemorySymbols( - /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObj); - HRESULT STDMETHODCALLTYPE - SetJMCStatus(/* [in] */ BOOL bIsJustMyCode, - /* [in] */ ULONG32 cTokens, /* [size_is][in] */ - mdToken pTokens[]); - HRESULT STDMETHODCALLTYPE - ApplyChanges(/* [in] */ ULONG cbMetadata, - /* [size_is][in] */ BYTE pbMetadata[], /* [in] */ - ULONG cbIL, /* [size_is][in] */ BYTE pbIL[]); - HRESULT STDMETHODCALLTYPE SetJITCompilerFlags(/* [in] */ DWORD dwFlags); - HRESULT STDMETHODCALLTYPE GetJITCompilerFlags(/* [out] */ DWORD *pdwFlags); - HRESULT STDMETHODCALLTYPE - ResolveAssembly(/* [in] */ mdToken tkAssemblyRef, /* [out] */ - ICorDebugAssembly **ppAssembly); - HRESULT STDMETHODCALLTYPE - GetProcess(/* [out] */ ICorDebugProcess **ppProcess); - HRESULT STDMETHODCALLTYPE GetBaseAddress(/* [out] */ CORDB_ADDRESS *pAddress); - HRESULT STDMETHODCALLTYPE - GetAssembly(/* [out] */ ICorDebugAssembly **ppAssembly); - HRESULT STDMETHODCALLTYPE - GetName(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, - /* [length_is][size_is][out] */ WCHAR szName[]); - HRESULT STDMETHODCALLTYPE EnableJITDebugging(/* [in] */ BOOL bTrackJITInfo, - /* [in] */ BOOL bAllowJitOpts); - HRESULT STDMETHODCALLTYPE - EnableClassLoadCallbacks(/* [in] */ BOOL bClassLoadCallbacks); - HRESULT STDMETHODCALLTYPE - GetFunctionFromToken(/* [in] */ mdMethodDef methodDef, /* [out] */ - ICorDebugFunction **ppFunction); - HRESULT STDMETHODCALLTYPE - GetFunctionFromRVA(/* [in] */ CORDB_ADDRESS rva, /* [out] */ - ICorDebugFunction **ppFunction); - HRESULT STDMETHODCALLTYPE GetClassFromToken( - /* [in] */ mdTypeDef typeDef, /* [out] */ ICorDebugClass **ppClass); - HRESULT STDMETHODCALLTYPE - CreateBreakpoint(/* [out] */ ICorDebugModuleBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE GetEditAndContinueSnapshot( - /* [out] */ ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot); - HRESULT STDMETHODCALLTYPE GetMetaDataInterface(/* [in] */ REFIID riid, - /* [out] */ IUnknown **ppObj); - HRESULT STDMETHODCALLTYPE GetToken(/* [out] */ mdModule *pToken); - HRESULT STDMETHODCALLTYPE IsDynamic(/* [out] */ BOOL *pDynamic); - HRESULT STDMETHODCALLTYPE - GetGlobalVariableValue(/* [in] */ mdFieldDef fieldDef, /* [out] */ - ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetSize(/* [out] */ ULONG32 *pcBytes); - HRESULT STDMETHODCALLTYPE IsInMemory(/* [out] */ BOOL *pInMemory); + HRESULT QueryInterface(REFIID id, void **pInterface); + HRESULT IsMappedLayout(BOOL *pIsMapped); + HRESULT CreateReaderForInMemorySymbols(REFIID riid, void **ppObj); + HRESULT + SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken pTokens[]); + HRESULT + ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], ULONG cbIL, BYTE pbIL[]); + HRESULT SetJITCompilerFlags(DWORD dwFlags); + HRESULT GetJITCompilerFlags(DWORD *pdwFlags); + HRESULT + ResolveAssembly(mdToken tkAssemblyRef, ICorDebugAssembly **ppAssembly); + HRESULT + GetProcess(ICorDebugProcess **ppProcess); + HRESULT GetBaseAddress(CORDB_ADDRESS *pAddress); + HRESULT + GetAssembly(ICorDebugAssembly **ppAssembly); + HRESULT + GetName(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]); + HRESULT EnableJITDebugging(BOOL bTrackJITInfo, BOOL bAllowJitOpts); + HRESULT + EnableClassLoadCallbacks(BOOL bClassLoadCallbacks); + HRESULT + GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction **ppFunction); + HRESULT + GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction **ppFunction); + HRESULT GetClassFromToken(mdTypeDef typeDef, ICorDebugClass **ppClass); + HRESULT + CreateBreakpoint(ICorDebugModuleBreakpoint **ppBreakpoint); + HRESULT GetEditAndContinueSnapshot( + ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot); + HRESULT GetMetaDataInterface(REFIID riid, IUnknown **ppObj); + HRESULT GetToken(mdModule *pToken); + HRESULT IsDynamic(BOOL *pDynamic); + HRESULT + GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue **ppValue); + HRESULT GetSize(ULONG32 *pcBytes); + HRESULT IsInMemory(BOOL *pInMemory); + int GetDebuggerId() const { return m_debuggerId; } }; class CordbAssembly : public CordbBaseMono, public ICorDebugAssembly, public ICorDebugAssembly2 { + CordbProcess *m_pProcess; + CordbAppDomain *m_pAppDomain; + int m_debuggerId; + public: - CordbProcess *pProcess; - CordbAppDomain *pAppDomain; - int id; CordbAssembly(Connection *conn, CordbProcess *process, CordbAppDomain *appDomain, int id_assembly); - HRESULT STDMETHODCALLTYPE IsFullyTrusted(/* [out] */ BOOL *pbFullyTrusted); - HRESULT STDMETHODCALLTYPE - GetProcess(/* [out] */ ICorDebugProcess **ppProcess); - HRESULT STDMETHODCALLTYPE - GetAppDomain(/* [out] */ ICorDebugAppDomain **ppAppDomain); - HRESULT STDMETHODCALLTYPE - EnumerateModules(/* [out] */ ICorDebugModuleEnum **ppModules); - HRESULT STDMETHODCALLTYPE - GetCodeBase(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, - /* [length_is][size_is][out] */ WCHAR szName[]); - HRESULT STDMETHODCALLTYPE - GetName(/* [in] */ ULONG32 cchName, /* [out] */ ULONG32 *pcchName, - /* [length_is][size_is][out] */ WCHAR szName[]); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbAssembly"; } + ~CordbAssembly(); + HRESULT IsFullyTrusted(BOOL *pbFullyTrusted); + HRESULT + GetProcess(ICorDebugProcess **ppProcess); + HRESULT + GetAppDomain(ICorDebugAppDomain **ppAppDomain); + HRESULT + EnumerateModules(ICorDebugModuleEnum **ppModules); + HRESULT + GetCodeBase(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]); + HRESULT + GetName(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); }; #endif diff --git a/src/mono/dbi/cordb-blocking-obj.cpp b/src/mono/dbi/cordb-blocking-obj.cpp index dc55147e5f3e62..cc8244d787061f 100644 --- a/src/mono/dbi/cordb-blocking-obj.cpp +++ b/src/mono/dbi/cordb-blocking-obj.cpp @@ -4,8 +4,8 @@ // File: CORDB-BLOCKING-OBJ.CPP // -#include #include +#include CordbBlockingObjectEnum::CordbBlockingObjectEnum(Connection *conn) : CordbBaseMono(conn) {} @@ -42,12 +42,13 @@ HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::GetCount(ULONG *pcelt) { } HRESULT STDMETHODCALLTYPE -CordbBlockingObjectEnum::QueryInterface(REFIID riid, void **ppvObject) { +CordbBlockingObjectEnum::QueryInterface(REFIID id, void **ppInterface) { + if (id == IID_ICorDebugBlockingObjectEnum) + *ppInterface = (ICorDebugBlockingObjectEnum *)this; + else if (id == IID_IUnknown) + *ppInterface = (IUnknown *)(ICorDebugBlockingObjectEnum *)this; LOG((LF_CORDB, LL_INFO100000, - "CordbBlockingObjectEnum - QueryInterface - NOT IMPLEMENTED\n")); - return E_NOTIMPL; + "CordbBlockingObjectEnum - QueryInterface - IMPLEMENTED\n")); + AddRef(); + return S_OK; } - -ULONG STDMETHODCALLTYPE CordbBlockingObjectEnum::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbBlockingObjectEnum::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-blocking-obj.h b/src/mono/dbi/cordb-blocking-obj.h index 4e8b7ebd2d9544..39774b05a2411f 100644 --- a/src/mono/dbi/cordb-blocking-obj.h +++ b/src/mono/dbi/cordb-blocking-obj.h @@ -13,15 +13,16 @@ class CordbBlockingObjectEnum : public CordbBaseMono, public ICorDebugBlockingObjectEnum { public: CordbBlockingObjectEnum(Connection *conn); - HRESULT STDMETHODCALLTYPE Next(ULONG celt, CorDebugBlockingObject values[], - ULONG *pceltFetched); - HRESULT STDMETHODCALLTYPE Skip(ULONG celt); - HRESULT STDMETHODCALLTYPE Reset(void); - HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum **ppEnum); - HRESULT STDMETHODCALLTYPE GetCount(ULONG *pcelt); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbBlockingObjectEnum"; } + HRESULT Next(ULONG celt, CorDebugBlockingObject values[], + ULONG *pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum **ppEnum); + HRESULT GetCount(ULONG *pcelt); + HRESULT QueryInterface(REFIID riid, void **ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-breakpoint.cpp b/src/mono/dbi/cordb-breakpoint.cpp index f51eacc8470925..85e9d0a92cfdd5 100644 --- a/src/mono/dbi/cordb-breakpoint.cpp +++ b/src/mono/dbi/cordb-breakpoint.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include using namespace std; @@ -15,13 +16,17 @@ CordbFunctionBreakpoint::CordbFunctionBreakpoint(Connection *conn, CordbCode *code, ULONG32 offset) : CordbBaseMono(conn) { - this->code = code; - this->offset = offset; + this->m_pCode = code; + this->m_offset = offset; + conn->GetProcess()->AddBreakpoint(this); } +CordbFunctionBreakpoint::~CordbFunctionBreakpoint() {} + HRESULT __stdcall CordbFunctionBreakpoint::GetFunction( ICorDebugFunction **ppFunction) { - *ppFunction = static_cast(code->func); + GetCode()->GetFunction()->QueryInterface(IID_ICorDebugFunction, + (void **)ppFunction); LOG((LF_CORDB, LL_INFO1000000, "CordbFunctionBreakpoint - GetFunction - IMPLEMENTED\n")); return S_OK; @@ -42,10 +47,11 @@ HRESULT __stdcall CordbFunctionBreakpoint::Activate(BOOL bActive) { m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_LOCATION_ONLY); - m_dbgprot_buffer_add_id(&sendbuf, this->code->func->id); - m_dbgprot_buffer_add_long(&sendbuf, offset); - conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, - MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_add_id(&sendbuf, + this->GetCode()->GetFunction()->GetDebuggerId()); + m_dbgprot_buffer_add_long(&sendbuf, m_offset); + conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, + MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); LOG((LF_CORDB, LL_INFO1000000, "CordbFunctionBreakpoint - Activate - IMPLEMENTED\n")); @@ -71,9 +77,6 @@ HRESULT __stdcall CordbFunctionBreakpoint::QueryInterface(REFIID id, // this interface. (issue 143976) // return CordbBreakpoint::QueryInterface(id, pInterface); } + AddRef(); return S_OK; } - -ULONG __stdcall CordbFunctionBreakpoint::AddRef(void) { return 0; } - -auto __stdcall CordbFunctionBreakpoint::Release(void) -> ULONG { return 0; } diff --git a/src/mono/dbi/cordb-breakpoint.h b/src/mono/dbi/cordb-breakpoint.h index fed152f6a8d0ec..204cc3eef528ea 100644 --- a/src/mono/dbi/cordb-breakpoint.h +++ b/src/mono/dbi/cordb-breakpoint.h @@ -11,20 +11,23 @@ class CordbFunctionBreakpoint : public CordbBaseMono, public ICorDebugFunctionBreakpoint { + CordbCode *m_pCode; + ULONG32 m_offset; + public: - CordbCode *code; - ULONG32 offset; CordbFunctionBreakpoint(Connection *conn, CordbCode *code, ULONG32 offset); - HRESULT STDMETHODCALLTYPE - GetFunction(/* [out] */ ICorDebugFunction **ppFunction); - HRESULT STDMETHODCALLTYPE GetOffset(/* [out] */ ULONG32 *pnOffset); - HRESULT STDMETHODCALLTYPE Activate(/* [in] */ BOOL bActive); - HRESULT STDMETHODCALLTYPE IsActive(/* [out] */ BOOL *pbActive); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + ULONG32 GetOffset() const { return m_offset; } + CordbCode *GetCode() const { return m_pCode; } + const char *GetClassName() { return "CordbFunctionBreakpoint"; } + ~CordbFunctionBreakpoint(); + HRESULT GetFunction(ICorDebugFunction **ppFunction); + HRESULT GetOffset(ULONG32 *pnOffset); + HRESULT Activate(BOOL bActive); + HRESULT IsActive(BOOL *pbActive); + HRESULT QueryInterface(REFIID id, + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); }; #endif diff --git a/src/mono/dbi/cordb-chain.cpp b/src/mono/dbi/cordb-chain.cpp index 73dab2bf02d3ed..42389434d8bb10 100644 --- a/src/mono/dbi/cordb-chain.cpp +++ b/src/mono/dbi/cordb-chain.cpp @@ -16,15 +16,17 @@ HRESULT __stdcall CordbChainEnum::Next(ULONG celt, ICorDebugChain *chains[], ULONG *pceltFetched) { LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Next - NOT IMPLEMENTED\n")); - chains[0] = new CordbChain(conn, thread, CHAIN_PROCESS_START, false); - chains[1] = new CordbChain(conn, thread, CHAIN_ENTER_MANAGED, true); + chains[0] = new CordbChain(conn, m_pThread, CHAIN_PROCESS_START, false); + chains[1] = new CordbChain(conn, m_pThread, CHAIN_ENTER_MANAGED, true); + chains[0]->AddRef(); + chains[1]->AddRef(); *pceltFetched = celt; return S_OK; } CordbChainEnum::CordbChainEnum(Connection *conn, CordbThread *thread) : CordbBaseMono(conn) { - this->thread = thread; + this->m_pThread = thread; } HRESULT __stdcall CordbChainEnum::QueryInterface(REFIID id, void **pInterface) { @@ -38,23 +40,17 @@ HRESULT __stdcall CordbChainEnum::Skip(ULONG celt) { return E_NOTIMPL; } -ULONG STDMETHODCALLTYPE CordbChainEnum::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbChainEnum::Release(void) { return 0; } - HRESULT STDMETHODCALLTYPE CordbChainEnum::Reset(void) { LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Reset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChainEnum::Clone( - /* [out] */ ICorDebugEnum **ppEnum) { +HRESULT STDMETHODCALLTYPE CordbChainEnum::Clone(ICorDebugEnum **ppEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Clone - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChainEnum::GetCount( - /* [out] */ ULONG *pcelt) { +HRESULT STDMETHODCALLTYPE CordbChainEnum::GetCount(ULONG *pcelt) { LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - GetCount - NOT IMPLEMENTED\n")); @@ -65,99 +61,88 @@ HRESULT STDMETHODCALLTYPE CordbChainEnum::GetCount( CordbChain::CordbChain(Connection *conn, CordbThread *thread, CorDebugChainReason chain_reason, bool is_managed) : CordbBaseMono(conn) { - this->thread = thread; - this->chain_reason = chain_reason; - this->is_managed = is_managed; + this->m_pThread = thread; + this->m_chainReason = chain_reason; + this->m_isManaged = is_managed; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetThread(/* [out] */ ICorDebugThread **ppThread) { - *ppThread = static_cast(thread); +HRESULT STDMETHODCALLTYPE CordbChain::GetThread(ICorDebugThread **ppThread) { + m_pThread->QueryInterface(IID_ICorDebugThread, (void **)ppThread); LOG((LF_CORDB, LL_INFO1000000, "CordbChain - GetThread - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbChain::GetStackRange( - /* [out] */ CORDB_ADDRESS *pStart, /* [out] */ CORDB_ADDRESS *pEnd) { +HRESULT STDMETHODCALLTYPE CordbChain::GetStackRange(CORDB_ADDRESS *pStart, + CORDB_ADDRESS *pEnd) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetStackRange - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetContext(/* [out] */ ICorDebugContext **ppContext) { +HRESULT STDMETHODCALLTYPE CordbChain::GetContext(ICorDebugContext **ppContext) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetContext - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetCaller(/* [out] */ ICorDebugChain **ppChain) { +HRESULT STDMETHODCALLTYPE CordbChain::GetCaller(ICorDebugChain **ppChain) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetCaller - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetCallee(/* [out] */ ICorDebugChain **ppChain) { +HRESULT STDMETHODCALLTYPE CordbChain::GetCallee(ICorDebugChain **ppChain) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetCallee - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetPrevious(/* [out] */ ICorDebugChain **ppChain) { +HRESULT STDMETHODCALLTYPE CordbChain::GetPrevious(ICorDebugChain **ppChain) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetPrevious - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetNext(/* [out] */ ICorDebugChain **ppChain) { +HRESULT STDMETHODCALLTYPE CordbChain::GetNext(ICorDebugChain **ppChain) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetNext - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChain::IsManaged(/* [out] */ BOOL *pManaged) { +HRESULT STDMETHODCALLTYPE CordbChain::IsManaged(BOOL *pManaged) { LOG((LF_CORDB, LL_INFO1000000, "CordbChain - IsManaged - IMPLEMENTED\n")); - *pManaged = is_managed; + *pManaged = m_isManaged; return S_OK; } HRESULT STDMETHODCALLTYPE -CordbChain::EnumerateFrames(/* [out] */ ICorDebugFrameEnum **ppFrames) { - *ppFrames = new CordbFrameEnum(conn, thread); +CordbChain::EnumerateFrames(ICorDebugFrameEnum **ppFrames) { + CordbFrameEnum *pFrame = new CordbFrameEnum(conn, m_pThread); + pFrame->AddRef(); + *ppFrames = static_cast(pFrame); LOG((LF_CORDB, LL_INFO1000000, "CordbChain - EnumerateFrames - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetActiveFrame(/* [out] */ ICorDebugFrame **ppFrame) { +HRESULT STDMETHODCALLTYPE CordbChain::GetActiveFrame(ICorDebugFrame **ppFrame) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetActiveFrame - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE -CordbChain::GetRegisterSet(/* [out] */ ICorDebugRegisterSet **ppRegisters) { +CordbChain::GetRegisterSet(ICorDebugRegisterSet **ppRegisters) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetRegisterSet - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetReason(/* [out] */ CorDebugChainReason *pReason) { - *pReason = chain_reason; +HRESULT STDMETHODCALLTYPE CordbChain::GetReason(CorDebugChainReason *pReason) { + *pReason = m_chainReason; LOG((LF_CORDB, LL_INFO1000000, "CordbChain - GetReason - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbChain::QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { +HRESULT STDMETHODCALLTYPE CordbChain::QueryInterface( + REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { LOG((LF_CORDB, LL_INFO100000, "CordbChain - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } - -ULONG STDMETHODCALLTYPE CordbChain::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbChain::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-chain.h b/src/mono/dbi/cordb-chain.h index 06c19d4a0c900b..8823e3d7b3a6ad 100644 --- a/src/mono/dbi/cordb-chain.h +++ b/src/mono/dbi/cordb-chain.h @@ -10,53 +10,53 @@ #include class CordbChainEnum : public CordbBaseMono, public ICorDebugChainEnum { + CordbThread *m_pThread; + public: - CordbThread *thread; CordbChainEnum(Connection *conn, CordbThread *thread); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE Skip(/* [in] */ ULONG celt); - HRESULT STDMETHODCALLTYPE Reset(void); - HRESULT STDMETHODCALLTYPE Clone(/* [out] */ ICorDebugEnum **ppEnum); - HRESULT STDMETHODCALLTYPE GetCount(/* [out] */ ULONG *pcelt); - HRESULT STDMETHODCALLTYPE - Next(/* [in] */ ULONG celt, - /* [length_is][size_is][out] */ ICorDebugChain *chains[], - /* [out] */ ULONG *pceltFetched); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbChainEnum"; } + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum **ppEnum); + HRESULT GetCount(ULONG *pcelt); + HRESULT + Next(ULONG celt, ICorDebugChain *chains[], ULONG *pceltFetched); }; class CordbChain : public CordbBaseMono, public ICorDebugChain { + CordbThread *m_pThread; + CorDebugChainReason m_chainReason; + bool m_isManaged; + public: - CordbThread *thread; - CorDebugChainReason chain_reason; - bool is_managed; CordbChain(Connection *conn, CordbThread *thread, CorDebugChainReason chain_reason, bool is_managed); - HRESULT STDMETHODCALLTYPE GetThread(/* [out] */ ICorDebugThread **ppThread); - HRESULT STDMETHODCALLTYPE GetStackRange(/* [out] */ CORDB_ADDRESS *pStart, - /* [out] */ CORDB_ADDRESS *pEnd); - HRESULT STDMETHODCALLTYPE - GetContext(/* [out] */ ICorDebugContext **ppContext); - HRESULT STDMETHODCALLTYPE GetCaller(/* [out] */ ICorDebugChain **ppChain); - HRESULT STDMETHODCALLTYPE GetCallee(/* [out] */ ICorDebugChain **ppChain); - HRESULT STDMETHODCALLTYPE GetPrevious(/* [out] */ ICorDebugChain **ppChain); - HRESULT STDMETHODCALLTYPE GetNext(/* [out] */ ICorDebugChain **ppChain); - HRESULT STDMETHODCALLTYPE IsManaged(/* [out] */ BOOL *pManaged); - HRESULT STDMETHODCALLTYPE - EnumerateFrames(/* [out] */ ICorDebugFrameEnum **ppFrames); - HRESULT STDMETHODCALLTYPE - GetActiveFrame(/* [out] */ ICorDebugFrame **ppFrame); - HRESULT STDMETHODCALLTYPE - GetRegisterSet(/* [out] */ ICorDebugRegisterSet **ppRegisters); - HRESULT STDMETHODCALLTYPE GetReason(/* [out] */ CorDebugChainReason *pReason); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbChain"; } + HRESULT GetThread(ICorDebugThread **ppThread); + HRESULT GetStackRange(CORDB_ADDRESS *pStart, CORDB_ADDRESS *pEnd); + HRESULT + GetContext(ICorDebugContext **ppContext); + HRESULT GetCaller(ICorDebugChain **ppChain); + HRESULT GetCallee(ICorDebugChain **ppChain); + HRESULT GetPrevious(ICorDebugChain **ppChain); + HRESULT GetNext(ICorDebugChain **ppChain); + HRESULT IsManaged(BOOL *pManaged); + HRESULT + EnumerateFrames(ICorDebugFrameEnum **ppFrames); + HRESULT + GetActiveFrame(ICorDebugFrame **ppFrame); + HRESULT + GetRegisterSet(ICorDebugRegisterSet **ppRegisters); + HRESULT GetReason(CorDebugChainReason *pReason); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); }; #endif diff --git a/src/mono/dbi/cordb-class.cpp b/src/mono/dbi/cordb-class.cpp index 64308718fe8874..85d4eec076d7b1 100644 --- a/src/mono/dbi/cordb-class.cpp +++ b/src/mono/dbi/cordb-class.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -15,21 +16,26 @@ using namespace std; CordbClass::CordbClass(Connection *conn, mdToken token, int module_id) : CordbBaseMono(conn) { - this->token = token; - this->module_id = module_id; + this->m_metadataToken = token; + this->m_debuggerId = module_id; } HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule **pModule) { LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetModule - IMPLEMENTED\n")); if (pModule) { - return conn->ppCordb->GetModule(module_id, pModule); + CordbModule *module = conn->GetProcess()->GetModule(m_debuggerId); + if (module) { + *pModule = static_cast(module); + (*pModule)->AddRef(); + return S_OK; + } } - return S_OK; + return S_FALSE; } HRESULT STDMETHODCALLTYPE CordbClass::GetToken(mdTypeDef *pTypeDef) { LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetToken - IMPLEMENTED\n")); - *pTypeDef = token; + *pTypeDef = m_metadataToken; return S_OK; } @@ -41,7 +47,7 @@ HRESULT STDMETHODCALLTYPE CordbClass::GetStaticFieldValue( content_value.booleanValue = 0; CordbValue *value = new CordbValue(conn, ELEMENT_TYPE_BOOLEAN, content_value, 1); - *ppValue = static_cast(value); + value->QueryInterface(IID_ICorDebugValue, (void **)ppValue); return S_OK; } @@ -57,14 +63,10 @@ HRESULT STDMETHODCALLTYPE CordbClass::QueryInterface(REFIID id, *pInterface = NULL; return E_NOINTERFACE; } - + AddRef(); return S_OK; } -ULONG STDMETHODCALLTYPE CordbClass::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbClass::Release(void) { return 0; } - HRESULT STDMETHODCALLTYPE CordbClass::GetParameterizedType( CorElementType elementType, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], ICorDebugType **ppType) { diff --git a/src/mono/dbi/cordb-class.h b/src/mono/dbi/cordb-class.h index 4098bad7073bda..920f6f74df1cc6 100644 --- a/src/mono/dbi/cordb-class.h +++ b/src/mono/dbi/cordb-class.h @@ -12,24 +12,24 @@ class CordbClass : public CordbBaseMono, public ICorDebugClass, public ICorDebugClass2 { - mdToken token; + mdToken m_metadataToken; + int m_debuggerId; public: - int module_id; CordbClass(Connection *conn, mdToken token, int module_id); - HRESULT STDMETHODCALLTYPE GetModule(ICorDebugModule **pModule); - HRESULT STDMETHODCALLTYPE GetToken(mdTypeDef *pTypeDef); - HRESULT STDMETHODCALLTYPE GetStaticFieldValue(mdFieldDef fieldDef, - ICorDebugFrame *pFrame, - ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE GetParameterizedType(CorElementType elementType, - ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[], - ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE SetJMCStatus(BOOL bIsJustMyCode); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbClass"; } + HRESULT GetModule(ICorDebugModule **pModule); + HRESULT GetToken(mdTypeDef *pTypeDef); + HRESULT GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame *pFrame, + ICorDebugValue **ppValue); + HRESULT QueryInterface(REFIID riid, void **ppvObject); + + HRESULT GetParameterizedType(CorElementType elementType, ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[], + ICorDebugType **ppType); + HRESULT SetJMCStatus(BOOL bIsJustMyCode); }; #endif diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index c2396f8b4ca54c..ea1c4b25827044 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -15,7 +15,7 @@ using namespace std; CordbCode::CordbCode(Connection *conn, CordbFunction *func) : CordbBaseMono(conn) { - this->func = func; + this->m_pFunction = func; } HRESULT __stdcall CordbCode::IsIL(BOOL *pbIL) { @@ -37,14 +37,13 @@ HRESULT __stdcall CordbCode::GetSize(ULONG32 *pcBytes) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, this->func->id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int code_size = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + int code_size = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); *pcBytes = code_size; LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetSize - IMPLEMENTED\n")); return S_OK; @@ -54,8 +53,7 @@ HRESULT __stdcall CordbCode::CreateBreakpoint( ULONG32 offset, ICorDebugFunctionBreakpoint **ppBreakpoint) { // add it in a list to not recreate a already created breakpoint CordbFunctionBreakpoint *bp = new CordbFunctionBreakpoint(conn, this, offset); - *ppBreakpoint = static_cast(bp); - conn->ppCordb->breakpoints->Append(bp); + bp->QueryInterface(IID_ICorDebugFunctionBreakpoint, (void **)ppBreakpoint); LOG((LF_CORDB, LL_INFO1000000, "CordbCode - CreateBreakpoint - IMPLEMENTED\n")); return S_OK; @@ -67,16 +65,17 @@ HRESULT __stdcall CordbCode::GetCode(ULONG32 startOffset, ULONG32 endOffset, MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, this->func->id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - uint8_t *code = m_dbgprot_decode_byte_array(bAnswer->buf, &bAnswer->buf, - bAnswer->end, (int32_t*)pcBufferSize); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + uint8_t *code = m_dbgprot_decode_byte_array( + bAnswer->p, &bAnswer->p, bAnswer->end, (int32_t *)pcBufferSize); memcpy(buffer, code, *pcBufferSize); + free(code); LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetCode - IMPLEMENTED\n")); return S_OK; } @@ -112,9 +111,6 @@ HRESULT __stdcall CordbCode::QueryInterface(REFIID id, void **pInterface) { *pInterface = NULL; return E_NOINTERFACE; } + AddRef(); return S_OK; } - -ULONG __stdcall CordbCode::AddRef(void) { return 0; } - -ULONG __stdcall CordbCode::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-code.h b/src/mono/dbi/cordb-code.h index 7e7cdecf63c451..28e238ec4286ab 100644 --- a/src/mono/dbi/cordb-code.h +++ b/src/mono/dbi/cordb-code.h @@ -10,34 +10,33 @@ #include class CordbCode : public CordbBaseMono, public ICorDebugCode { + CordbFunction *m_pFunction; + public: - CordbFunction *func; CordbCode(Connection *conn, CordbFunction *func); - HRESULT STDMETHODCALLTYPE IsIL(/* [out] */ BOOL *pbIL); - HRESULT STDMETHODCALLTYPE - GetFunction(/* [out] */ ICorDebugFunction **ppFunction); - HRESULT STDMETHODCALLTYPE GetAddress(/* [out] */ CORDB_ADDRESS *pStart); - HRESULT STDMETHODCALLTYPE GetSize(/* [out] */ ULONG32 *pcBytes); - HRESULT STDMETHODCALLTYPE - CreateBreakpoint(/* [in] */ ULONG32 offset, /* [out] */ - ICorDebugFunctionBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE GetCode( - /* [in] */ ULONG32 startOffset, /* [in] */ ULONG32 endOffset, /* [in] */ - ULONG32 cBufferAlloc, /* [length_is][size_is][out] */ BYTE buffer[], - /* [out] */ ULONG32 *pcBufferSize); - HRESULT STDMETHODCALLTYPE GetVersionNumber(/* [out] */ ULONG32 *nVersion); - HRESULT STDMETHODCALLTYPE - GetILToNativeMapping(/* [in] */ ULONG32 cMap, /* [out] */ ULONG32 *pcMap, - /* [length_is][size_is][out] */ + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbCode"; } + HRESULT IsIL(BOOL *pbIL); + HRESULT + GetFunction(ICorDebugFunction **ppFunction); + HRESULT GetAddress(CORDB_ADDRESS *pStart); + HRESULT GetSize(ULONG32 *pcBytes); + HRESULT + CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint **ppBreakpoint); + HRESULT GetCode(ULONG32 startOffset, ULONG32 endOffset, ULONG32 cBufferAlloc, + BYTE buffer[], ULONG32 *pcBufferSize); + HRESULT GetVersionNumber(ULONG32 *nVersion); + HRESULT + GetILToNativeMapping(ULONG32 cMap, ULONG32 *pcMap, + COR_DEBUG_IL_TO_NATIVE_MAP map[]); - HRESULT STDMETHODCALLTYPE - GetEnCRemapSequencePoints(/* [in] */ ULONG32 cMap, /* [out] */ ULONG32 *pcMap, - /* [length_is][size_is][out] */ ULONG32 offsets[]); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); + HRESULT + GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32 *pcMap, ULONG32 offsets[]); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + + CordbFunction *GetFunction() const { return m_pFunction; } }; #endif diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index 763d89ae55421e..f46b5dc7e54817 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -4,6 +4,7 @@ // File: CORDB-EVAL.CPP // +#include #include #include #include @@ -19,23 +20,30 @@ CordbEval::CordbEval(Connection *conn, CordbThread *thread) : CordbBaseMono(conn) { - this->thread = thread; - ppValue = NULL; - cmdId = -1; + this->m_pThread = thread; + if (thread) + thread->InternalAddRef(); + m_pValue = NULL; + m_commandId = -1; } +CordbEval::~CordbEval() { + if (m_pThread) + m_pThread->InternalRelease(); +} HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( ICorDebugFunction *pFunction, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]) { - this->thread->ppProcess->Stop(false); + conn->GetProcess()->Stop(false); LOG((LF_CORDB, LL_INFO1000000, "CordbEval - CallParameterizedFunction - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); m_dbgprot_buffer_add_int(&localbuf, 1); - m_dbgprot_buffer_add_int(&localbuf, ((CordbFunction *)pFunction)->id); + m_dbgprot_buffer_add_int(&localbuf, + ((CordbFunction *)pFunction)->GetDebuggerId()); m_dbgprot_buffer_add_int(&localbuf, nArgs); for (ULONG32 i = 0; i < nArgs; i++) { CorElementType ty; @@ -70,24 +78,23 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( m_dbgprot_buffer_add_id(&localbuf, cc->intValue); break; default: - return E_NOTIMPL; + return E_NOTIMPL; } } - cmdId = conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_INVOKE_METHOD, - &localbuf); + m_commandId = conn->SendEvent(MDBGPROT_CMD_SET_VM, + MDBGPROT_CMD_VM_INVOKE_METHOD, &localbuf); m_dbgprot_buffer_free(&localbuf); - conn->pending_eval->Append(this); + conn->GetProcess()->AddPendingEval(this); return S_OK; } void CordbEval::EvalComplete(MdbgProtBuffer *bAnswer) { - m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); - CordbObjectValue::CreateCordbValue(conn, bAnswer, &ppValue); - conn->ppCordb->pCallback->EvalComplete( - static_cast(thread->ppProcess->appdomains->Get(0)), - static_cast(thread), - static_cast(this)); + m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); + CordbObjectValue::CreateCordbValue(conn, bAnswer, &m_pValue); + + conn->GetCordb()->GetCallback()->EvalComplete( + conn->GetProcess()->GetCurrentAppDomain(), m_pThread, this); } HRESULT STDMETHODCALLTYPE @@ -122,16 +129,16 @@ CordbEval::NewParameterizedArray(ICorDebugType *pElementType, ULONG32 rank, HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, UINT uiLength) { - this->thread->ppProcess->Stop(false); + conn->GetProcess()->Stop(false); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_THREAD, - MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, + MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int domainId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + int domainId = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); LPSTR szString; UTF8STR(string, szString); @@ -139,10 +146,11 @@ HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, domainId); m_dbgprot_buffer_add_string(&localbuf, szString); - this->cmdId = - conn->send_event(MDBGPROT_CMD_SET_APPDOMAIN, - MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); - conn->pending_eval->Append(this); + this->m_commandId = + conn->SendEvent(MDBGPROT_CMD_SET_APPDOMAIN, + MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); + m_dbgprot_buffer_free(&localbuf); + conn->GetProcess()->AddPendingEval(this); return S_OK; } @@ -151,10 +159,6 @@ HRESULT STDMETHODCALLTYPE CordbEval::RudeAbort(void) { return S_OK; } -ULONG CordbEval::AddRef(void) { return 1; } - -ULONG CordbEval::Release(void) { return 1; } - HRESULT CordbEval::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { @@ -168,7 +172,7 @@ CordbEval::QueryInterface(REFIID id, *pInterface = NULL; return E_NOINTERFACE; } - + AddRef(); return S_OK; } @@ -218,7 +222,7 @@ HRESULT STDMETHODCALLTYPE CordbEval::Abort(void) { } HRESULT STDMETHODCALLTYPE CordbEval::GetResult(ICorDebugValue **ppResult) { - *ppResult = ppValue; + *ppResult = m_pValue; LOG((LF_CORDB, LL_INFO1000000, "CordbEval - GetResult - IMPLEMENTED\n")); return S_OK; } diff --git a/src/mono/dbi/cordb-eval.h b/src/mono/dbi/cordb-eval.h index 17e9daf11a390d..5c4d1b244bbf5e 100644 --- a/src/mono/dbi/cordb-eval.h +++ b/src/mono/dbi/cordb-eval.h @@ -12,54 +12,53 @@ class CordbEval : public CordbBaseMono, public ICorDebugEval, public ICorDebugEval2 { - CordbThread *thread; - ICorDebugValue *ppValue; + CordbThread *m_pThread; + ICorDebugValue *m_pValue; + int m_commandId; public: - int cmdId; CordbEval(Connection *conn, CordbThread *thread); + ~CordbEval(); void EvalComplete(MdbgProtBuffer *bAnswer); - virtual HRESULT STDMETHODCALLTYPE CallParameterizedFunction( - ICorDebugFunction *pFunction, ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]); - virtual HRESULT STDMETHODCALLTYPE NewParameterizedObject( - ICorDebugFunction *pConstructor, ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]); - virtual HRESULT STDMETHODCALLTYPE NewParameterizedObjectNoConstructor( - ICorDebugClass *pClass, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[]); - virtual HRESULT STDMETHODCALLTYPE CallFunction(ICorDebugFunction *pFunction, - ULONG32 nArgs, - ICorDebugValue *ppArgs[]); - virtual HRESULT STDMETHODCALLTYPE NewObject(ICorDebugFunction *pConstructor, - ULONG32 nArgs, - ICorDebugValue *ppArgs[]); - virtual HRESULT STDMETHODCALLTYPE + HRESULT CallParameterizedFunction(ICorDebugFunction *pFunction, + ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[], ULONG32 nArgs, + ICorDebugValue *ppArgs[]); + HRESULT NewParameterizedObject(ICorDebugFunction *pConstructor, + ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], + ULONG32 nArgs, ICorDebugValue *ppArgs[]); + HRESULT NewParameterizedObjectNoConstructor(ICorDebugClass *pClass, + ULONG32 nTypeArgs, + ICorDebugType *ppTypeArgs[]); + HRESULT CallFunction(ICorDebugFunction *pFunction, ULONG32 nArgs, + ICorDebugValue *ppArgs[]); + HRESULT NewObject(ICorDebugFunction *pConstructor, ULONG32 nArgs, + ICorDebugValue *ppArgs[]); + HRESULT NewObjectNoConstructor(ICorDebugClass *pClass); - virtual HRESULT STDMETHODCALLTYPE NewString(LPCWSTR string); - virtual HRESULT STDMETHODCALLTYPE NewArray(CorElementType elementType, - ICorDebugClass *pElementClass, - ULONG32 rank, ULONG32 dims[], - ULONG32 lowBounds[]); - virtual HRESULT STDMETHODCALLTYPE IsActive(BOOL *pbActive); - virtual HRESULT STDMETHODCALLTYPE Abort(void); - virtual HRESULT STDMETHODCALLTYPE GetResult(ICorDebugValue **ppResult); - virtual HRESULT STDMETHODCALLTYPE GetThread(ICorDebugThread **ppThread); - virtual HRESULT STDMETHODCALLTYPE CreateValue(CorElementType elementType, - ICorDebugClass *pElementClass, - ICorDebugValue **ppValue); - virtual HRESULT STDMETHODCALLTYPE + HRESULT NewString(LPCWSTR string); + HRESULT NewArray(CorElementType elementType, ICorDebugClass *pElementClass, + ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]); + HRESULT IsActive(BOOL *pbActive); + HRESULT Abort(void); + HRESULT GetResult(ICorDebugValue **ppResult); + HRESULT GetThread(ICorDebugThread **ppThread); + HRESULT CreateValue(CorElementType elementType, ICorDebugClass *pElementClass, + ICorDebugValue **ppValue); + HRESULT CreateValueForType(ICorDebugType *pType, ICorDebugValue **ppValue); - virtual HRESULT STDMETHODCALLTYPE + HRESULT NewParameterizedArray(ICorDebugType *pElementType, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]); - virtual HRESULT STDMETHODCALLTYPE NewStringWithLength(LPCWSTR string, - UINT uiLength); - virtual HRESULT STDMETHODCALLTYPE RudeAbort(void); + HRESULT NewStringWithLength(LPCWSTR string, UINT uiLength); + HRESULT RudeAbort(void); HRESULT QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject); - ULONG AddRef(void); - ULONG Release(void); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbEval"; } + int GetCommandId() const { return m_commandId; } }; #endif diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index 595963211685cc..1fa6912b73e091 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -16,14 +16,19 @@ using namespace std; CordbFrameEnum::CordbFrameEnum(Connection *conn, CordbThread *thread) : CordbBaseMono(conn) { - this->thread = thread; + this->m_pThread = thread; + m_nFrames = 0; + m_ppFrames = NULL; } +CordbFrameEnum::~CordbFrameEnum() { Reset(); } + HRESULT STDMETHODCALLTYPE CordbFrameEnum::Next(ULONG celt, ICorDebugFrame *frames[], ULONG *pceltFetched) { - for (int i = 0; i < nframes; i++) { - frames[i] = this->frames[i]; + for (int i = 0; i < m_nFrames; i++) { + this->m_ppFrames[i]->QueryInterface(IID_ICorDebugFrame, + (void **)&frames[i]); } LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - Next - IMPLEMENTED\n")); return S_OK; @@ -35,8 +40,14 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::Skip(ULONG celt) { } HRESULT STDMETHODCALLTYPE CordbFrameEnum::Reset(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - Reset - NOT IMPLEMENTED\n")); - return E_NOTIMPL; + for (int i = 0; i < m_nFrames; i++) { + this->m_ppFrames[i]->InternalRelease(); + } + m_nFrames = 0; + if (m_ppFrames) + free(m_ppFrames); + m_ppFrames = NULL; + return S_OK; } HRESULT STDMETHODCALLTYPE CordbFrameEnum::Clone(ICorDebugEnum **ppEnum) { @@ -45,40 +56,40 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::Clone(ICorDebugEnum **ppEnum) { } HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG *pcelt) { + Reset(); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - GetCount - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); m_dbgprot_buffer_add_int(&localbuf, 0); m_dbgprot_buffer_add_int(&localbuf, -1); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_THREAD, - MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, + MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - nframes = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - frames = (CordbNativeFrame **)malloc(sizeof(CordbNativeFrame *) * nframes); - - for (int i = 0; i < nframes; i++) { - int frameid = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int methodId = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int il_offset = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int flags = - m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); - - CordbNativeFrame *frame = - new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, thread); - frames[i] = frame; + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + m_nFrames = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_ppFrames = + (CordbNativeFrame **)malloc(sizeof(CordbNativeFrame *) * m_nFrames); + + for (int i = 0; i < m_nFrames; i++) { + int frameid = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + int methodId = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int il_offset = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + int flags = m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); + + CordbNativeFrame *frame = new CordbNativeFrame(conn, frameid, methodId, + il_offset, flags, m_pThread); + frame->InternalAddRef(); + m_ppFrames[i] = frame; } - if (!thread->registerset) - thread->registerset = new CordbRegisteSet(conn, 0, 0); + if (!m_pThread->GetStepper()) + m_pThread->SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); - *pcelt = nframes; + *pcelt = m_nFrames; return S_OK; } @@ -89,55 +100,46 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::QueryInterface(REFIID riid, return E_NOTIMPL; } -ULONG STDMETHODCALLTYPE CordbFrameEnum::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbFrameEnum::Release(void) { return 0; } - CordbJITILFrame::CordbJITILFrame(Connection *conn, int frameid, int methodId, int il_offset, int flags, CordbThread *thread) : CordbBaseMono(conn) { - this->frameid = frameid; - this->methodId = methodId; - this->il_offset = il_offset; - this->flags = flags; - this->thread = thread; + this->m_debuggerFrameId = frameid; + this->m_debuggerMethodId = methodId; + this->m_ilOffset = il_offset; + this->m_flags = flags; + this->m_pThread = thread; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetChain( - /* [out] */ ICorDebugChain **ppChain) { +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetChain(ICorDebugChain **ppChain) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetChain - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCode( - /* [out] */ ICorDebugCode **ppCode) { +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCode(ICorDebugCode **ppCode) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCode - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunction( - /* [out] */ ICorDebugFunction **ppFunction) { - CordbFunction *func = thread->ppProcess->cordb->findFunction(methodId); +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::GetFunction(ICorDebugFunction **ppFunction) { + CordbFunction *func = conn->GetProcess()->FindFunction(m_debuggerMethodId); if (!func) { - func = new CordbFunction(conn, 0, methodId, NULL); - thread->ppProcess->cordb->functions->Append(func); + func = new CordbFunction(conn, 0, m_debuggerMethodId, NULL); } - - *ppFunction = static_cast(func); + func->QueryInterface(IID_ICorDebugFunction, (void **)ppFunction); LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetFunction - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunctionToken( - /* [out] */ mdMethodDef *pToken) { +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::GetFunctionToken(mdMethodDef *pToken) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetFunctionToken - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackRange( - /* [out] */ CORDB_ADDRESS *pStart, - /* [out] */ CORDB_ADDRESS *pEnd) { +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackRange(CORDB_ADDRESS *pStart, + CORDB_ADDRESS *pEnd) { *pStart = 4096; *pEnd = 8192; LOG((LF_CORDB, LL_INFO100000, @@ -145,28 +147,25 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackRange( return S_OK; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCaller( - /* [out] */ ICorDebugFrame **ppFrame) { +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCaller(ICorDebugFrame **ppFrame) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCaller - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCallee( - /* [out] */ ICorDebugFrame **ppFrame) { +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCallee(ICorDebugFrame **ppFrame) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCallee - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::CreateStepper( - /* [out] */ ICorDebugStepper **ppStepper) { +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::CreateStepper(ICorDebugStepper **ppStepper) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - CreateStepper - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::QueryInterface( - /* [in] */ REFIID id, - /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { + REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { if (id == IID_ICorDebugILFrame) { *pInterface = static_cast(this); } else if (id == IID_ICorDebugILFrame2) { @@ -179,6 +178,7 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::QueryInterface( *pInterface = NULL; return E_NOINTERFACE; } + AddRef(); return S_OK; } @@ -218,115 +218,108 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariableEx( HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCodeEx(ILCodeKind flags, ICorDebugCode **ppCode) { - if (flags == ILCODE_REJIT_IL) { + if (flags == ILCODE_REJIT_IL) *ppCode = NULL; - } else { - CordbCode *code = new CordbCode(conn, NULL); - *ppCode = static_cast(code); + else { + ICorDebugFunction *ppFunction; + GetFunction(&ppFunction); + ppFunction->GetILCode(ppCode); + ppFunction->Release(); } LOG((LF_CORDB, LL_INFO1000000, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n")); return S_OK; } -ULONG STDMETHODCALLTYPE CordbJITILFrame::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbJITILFrame::Release(void) { return 0; } - HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetIP( - /* [out] */ ULONG32 *pnOffset, - /* [out] */ CorDebugMappingResult *pMappingResult) { - *pnOffset = il_offset; + ULONG32 *pnOffset, CorDebugMappingResult *pMappingResult) { + *pnOffset = m_ilOffset; *pMappingResult = MAPPING_EXACT; LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetIP - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::SetIP( - /* [in] */ ULONG32 nOffset) { +HRESULT STDMETHODCALLTYPE CordbJITILFrame::SetIP(ULONG32 nOffset) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - SetIP - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariables( - /* [out] */ ICorDebugValueEnum **ppValueEnum) { +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::EnumerateLocalVariables(ICorDebugValueEnum **ppValueEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - EnumerateLocalVariables - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariable( - /* [in] */ DWORD dwIndex, - /* [out] */ ICorDebugValue **ppValue) { +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::GetLocalVariable(DWORD dwIndex, ICorDebugValue **ppValue) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); - m_dbgprot_buffer_add_id(&localbuf, frameid); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); m_dbgprot_buffer_add_int(&localbuf, 1); m_dbgprot_buffer_add_int(&localbuf, dwIndex); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_STACK_FRAME, - MDBGPROT_CMD_STACK_FRAME_GET_VALUES, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, + MDBGPROT_CMD_STACK_FRAME_GET_VALUES, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); return CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateArguments( - /* [out] */ ICorDebugValueEnum **ppValueEnum) { +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::EnumerateArguments(ICorDebugValueEnum **ppValueEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - EnumerateArguments - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetArgument( - /* [in] */ DWORD dwIndex, - /* [out] */ ICorDebugValue **ppValue) { +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::GetArgument(DWORD dwIndex, ICorDebugValue **ppValue) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, thread->thread_id); - m_dbgprot_buffer_add_id(&localbuf, frameid); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); m_dbgprot_buffer_add_int(&localbuf, dwIndex); - int cmdId = - conn->send_event(MDBGPROT_CMD_SET_STACK_FRAME, - MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, + MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetArgument - IMPLEMENTED\n")); return CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackDepth( - /* [out] */ ULONG32 *pDepth) { +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackDepth(ULONG32 *pDepth) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetStackDepth - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackValue( - /* [in] */ DWORD dwIndex, - /* [out] */ ICorDebugValue **ppValue) { +HRESULT STDMETHODCALLTYPE +CordbJITILFrame::GetStackValue(DWORD dwIndex, ICorDebugValue **ppValue) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetStackValue - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::CanSetIP( - /* [in] */ ULONG32 nOffset) { +HRESULT STDMETHODCALLTYPE CordbJITILFrame::CanSetIP(ULONG32 nOffset) { LOG((LF_CORDB, LL_INFO100000, "CordbFrame - CanSetIP - NOT IMPLEMENTED\n")); return E_NOTIMPL; } +CordbNativeFrame::~CordbNativeFrame() { m_JITILFrame->InternalRelease(); } + CordbNativeFrame::CordbNativeFrame(Connection *conn, int frameid, int methodId, int il_offset, int flags, CordbThread *thread) : CordbBaseMono(conn) { m_JITILFrame = new CordbJITILFrame(conn, frameid, methodId, il_offset, flags, thread); - this->thread = thread; + m_JITILFrame->InternalAddRef(); + this->m_pThread = thread; } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetIP(ULONG32 *pnOffset) { @@ -343,7 +336,7 @@ HRESULT STDMETHODCALLTYPE CordbNativeFrame::SetIP(ULONG32 nOffset) { HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetRegisterSet(ICorDebugRegisterSet **ppRegisters) { - return thread->GetRegisterSet(ppRegisters); + return m_pThread->GetRegisterSet(ppRegisters); } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterValue( @@ -399,8 +392,10 @@ HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetChain(ICorDebugChain **ppChain) { } HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCode(ICorDebugCode **ppCode) { - CordbCode *code = new CordbCode(conn, NULL); - *ppCode = static_cast(code); + ICorDebugFunction *ppFunction; + m_JITILFrame->GetFunction(&ppFunction); + ppFunction->GetILCode(ppCode); + ppFunction->Release(); LOG((LF_CORDB, LL_INFO100000, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n")); return S_OK; } @@ -465,14 +460,10 @@ HRESULT STDMETHODCALLTYPE CordbNativeFrame::QueryInterface(REFIID id, return E_NOINTERFACE; } } - + AddRef(); return S_OK; } -ULONG STDMETHODCALLTYPE CordbNativeFrame::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbNativeFrame::Release(void) { return 0; } - HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsChild(BOOL *pIsChild) { LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - IsChild - NOT IMPLEMENTED\n")); diff --git a/src/mono/dbi/cordb-frame.h b/src/mono/dbi/cordb-frame.h index 1eeab440f8e9c2..56447110bcb964 100644 --- a/src/mono/dbi/cordb-frame.h +++ b/src/mono/dbi/cordb-frame.h @@ -14,121 +14,126 @@ class CordbJITILFrame : public CordbBaseMono, public ICorDebugILFrame2, public ICorDebugILFrame3, public ICorDebugILFrame4 { + int m_debuggerFrameId; + int m_debuggerMethodId; + int m_ilOffset; + int m_flags; + CordbThread *m_pThread; + public: - int frameid; - int methodId; - int il_offset; - int flags; - CordbThread *thread; CordbJITILFrame(Connection *conn, int frameid, int methodId, int il_offset, int flags, CordbThread *thread); - HRESULT STDMETHODCALLTYPE GetChain(/* [out] */ ICorDebugChain **ppChain); - HRESULT STDMETHODCALLTYPE GetCode(/* [out] */ ICorDebugCode **ppCode); - HRESULT STDMETHODCALLTYPE - GetFunction(/* [out] */ ICorDebugFunction **ppFunction); - HRESULT STDMETHODCALLTYPE GetFunctionToken(/* [out] */ mdMethodDef *pToken); - HRESULT STDMETHODCALLTYPE GetStackRange(/* [out] */ CORDB_ADDRESS *pStart, - /* [out] */ CORDB_ADDRESS *pEnd); - HRESULT STDMETHODCALLTYPE GetCaller(/* [out] */ ICorDebugFrame **ppFrame); - HRESULT STDMETHODCALLTYPE GetCallee(/* [out] */ ICorDebugFrame **ppFrame); - HRESULT STDMETHODCALLTYPE - CreateStepper(/* [out] */ ICorDebugStepper **ppStepper); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE - GetIP(/* [out] */ ULONG32 *pnOffset, - /* [out] */ CorDebugMappingResult *pMappingResult); - HRESULT STDMETHODCALLTYPE SetIP(/* [in] */ ULONG32 nOffset); - HRESULT STDMETHODCALLTYPE - EnumerateLocalVariables(/* [out] */ ICorDebugValueEnum **ppValueEnum); - HRESULT STDMETHODCALLTYPE GetLocalVariable( - /* [in] */ DWORD dwIndex, /* [out] */ ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE - EnumerateArguments(/* [out] */ ICorDebugValueEnum **ppValueEnum); - HRESULT STDMETHODCALLTYPE GetArgument(/* [in] */ DWORD dwIndex, - /* [out] */ ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetStackDepth(/* [out] */ ULONG32 *pDepth); - HRESULT STDMETHODCALLTYPE GetStackValue(/* [in] */ DWORD dwIndex, - /* [out] */ ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE CanSetIP(/* [in] */ ULONG32 nOffset); - HRESULT STDMETHODCALLTYPE RemapFunction(ULONG32 newILOffset); - HRESULT STDMETHODCALLTYPE + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbJITILFrame"; } + HRESULT GetChain(ICorDebugChain **ppChain); + HRESULT GetCode(ICorDebugCode **ppCode); + HRESULT + GetFunction(ICorDebugFunction **ppFunction); + HRESULT GetFunctionToken(mdMethodDef *pToken); + HRESULT GetStackRange(CORDB_ADDRESS *pStart, CORDB_ADDRESS *pEnd); + HRESULT GetCaller(ICorDebugFrame **ppFrame); + HRESULT GetCallee(ICorDebugFrame **ppFrame); + HRESULT + CreateStepper(ICorDebugStepper **ppStepper); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + + HRESULT + GetIP(ULONG32 *pnOffset, CorDebugMappingResult *pMappingResult); + HRESULT SetIP(ULONG32 nOffset); + HRESULT + EnumerateLocalVariables(ICorDebugValueEnum **ppValueEnum); + HRESULT GetLocalVariable(DWORD dwIndex, ICorDebugValue **ppValue); + HRESULT + EnumerateArguments(ICorDebugValueEnum **ppValueEnum); + HRESULT GetArgument(DWORD dwIndex, ICorDebugValue **ppValue); + HRESULT GetStackDepth(ULONG32 *pDepth); + HRESULT GetStackValue(DWORD dwIndex, ICorDebugValue **ppValue); + HRESULT CanSetIP(ULONG32 nOffset); + HRESULT RemapFunction(ULONG32 newILOffset); + HRESULT EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum); - HRESULT STDMETHODCALLTYPE + HRESULT GetReturnValueForILOffset(ULONG32 ILoffset, ICorDebugValue **ppReturnValue); - HRESULT STDMETHODCALLTYPE + HRESULT EnumerateLocalVariablesEx(ILCodeKind flags, ICorDebugValueEnum **ppValueEnum); - HRESULT STDMETHODCALLTYPE GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, - ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetCodeEx(ILCodeKind flags, ICorDebugCode **ppCode); + HRESULT GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, + ICorDebugValue **ppValue); + HRESULT GetCodeEx(ILCodeKind flags, ICorDebugCode **ppCode); }; class CordbNativeFrame : public CordbBaseMono, public ICorDebugNativeFrame, public ICorDebugNativeFrame2 { CordbJITILFrame *m_JITILFrame; + CordbThread *m_pThread; public: - CordbThread *thread; CordbNativeFrame(Connection *conn, int frameid, int methodId, int il_offset, int flags, CordbThread *thread); - HRESULT STDMETHODCALLTYPE GetIP(ULONG32 *pnOffset); - HRESULT STDMETHODCALLTYPE SetIP(ULONG32 nOffset); - HRESULT STDMETHODCALLTYPE GetRegisterSet(ICorDebugRegisterSet **ppRegisters); - HRESULT STDMETHODCALLTYPE GetLocalRegisterValue(CorDebugRegister reg, - ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetLocalDoubleRegisterValue( - CorDebugRegister highWordReg, CorDebugRegister lowWordReg, - ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetLocalMemoryValue(CORDB_ADDRESS address, - ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetLocalRegisterMemoryValue( - CorDebugRegister highWordReg, CORDB_ADDRESS lowWordAddress, - ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetLocalMemoryRegisterValue( - CORDB_ADDRESS highWordAddress, CorDebugRegister lowWordRegister, - ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE CanSetIP(ULONG32 nOffset); - HRESULT STDMETHODCALLTYPE GetChain(ICorDebugChain **ppChain); - HRESULT STDMETHODCALLTYPE GetCode(ICorDebugCode **ppCode); - HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction **ppFunction); - HRESULT STDMETHODCALLTYPE GetFunctionToken(mdMethodDef *pToken); - HRESULT STDMETHODCALLTYPE GetStackRange(CORDB_ADDRESS *pStart, - CORDB_ADDRESS *pEnd); - HRESULT STDMETHODCALLTYPE GetCaller(ICorDebugFrame **ppFrame); - HRESULT STDMETHODCALLTYPE GetCallee(ICorDebugFrame **ppFrame); - HRESULT STDMETHODCALLTYPE CreateStepper(ICorDebugStepper **ppStepper); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE IsChild(BOOL *pIsChild); - HRESULT STDMETHODCALLTYPE IsMatchingParentFrame( - ICorDebugNativeFrame2 *pPotentialParentFrame, BOOL *pIsParent); - HRESULT STDMETHODCALLTYPE GetStackParameterSize(ULONG32 *pSize); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbNativeFrame"; } + ~CordbNativeFrame(); + HRESULT GetIP(ULONG32 *pnOffset); + HRESULT SetIP(ULONG32 nOffset); + HRESULT GetRegisterSet(ICorDebugRegisterSet **ppRegisters); + HRESULT GetLocalRegisterValue(CorDebugRegister reg, ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue); + HRESULT GetLocalDoubleRegisterValue(CorDebugRegister highWordReg, + CorDebugRegister lowWordReg, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue); + HRESULT GetLocalMemoryValue(CORDB_ADDRESS address, ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue); + HRESULT GetLocalRegisterMemoryValue(CorDebugRegister highWordReg, + CORDB_ADDRESS lowWordAddress, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue); + HRESULT GetLocalMemoryRegisterValue(CORDB_ADDRESS highWordAddress, + CorDebugRegister lowWordRegister, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue **ppValue); + HRESULT CanSetIP(ULONG32 nOffset); + HRESULT GetChain(ICorDebugChain **ppChain); + HRESULT GetCode(ICorDebugCode **ppCode); + HRESULT GetFunction(ICorDebugFunction **ppFunction); + HRESULT GetFunctionToken(mdMethodDef *pToken); + HRESULT GetStackRange(CORDB_ADDRESS *pStart, CORDB_ADDRESS *pEnd); + HRESULT GetCaller(ICorDebugFrame **ppFrame); + HRESULT GetCallee(ICorDebugFrame **ppFrame); + HRESULT CreateStepper(ICorDebugStepper **ppStepper); + HRESULT QueryInterface(REFIID riid, void **ppvObject); + + HRESULT IsChild(BOOL *pIsChild); + HRESULT IsMatchingParentFrame(ICorDebugNativeFrame2 *pPotentialParentFrame, + BOOL *pIsParent); + HRESULT GetStackParameterSize(ULONG32 *pSize); }; class CordbFrameEnum : public CordbBaseMono, public ICorDebugFrameEnum { + CordbThread *m_pThread; + int m_nFrames; + CordbNativeFrame **m_ppFrames; + public: - CordbThread *thread; - int nframes; - CordbNativeFrame **frames; CordbFrameEnum(Connection *conn, CordbThread *thread); - HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugFrame *frames[], - ULONG *pceltFetched); - HRESULT STDMETHODCALLTYPE Skip(ULONG celt); - HRESULT STDMETHODCALLTYPE Reset(void); - HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum **ppEnum); - HRESULT STDMETHODCALLTYPE GetCount(ULONG *pcelt); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbFrameEnum"; } + ~CordbFrameEnum(); + HRESULT Next(ULONG celt, ICorDebugFrame *frames[], ULONG *pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum **ppEnum); + HRESULT GetCount(ULONG *pcelt); + HRESULT QueryInterface(REFIID riid, void **ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-function.cpp b/src/mono/dbi/cordb-function.cpp index 9c9a7928f8b5f2..55a28de305a81d 100644 --- a/src/mono/dbi/cordb-function.cpp +++ b/src/mono/dbi/cordb-function.cpp @@ -4,19 +4,31 @@ // File: CORDB-FUNCTION.CPP // +#include #include #include +#include #include using namespace std; CordbFunction::CordbFunction(Connection *conn, mdToken token, int id, - ICorDebugModule *module) + CordbModule *module) : CordbBaseMono(conn) { - this->token = token; - this->id = id; - code = NULL; - this->module = module; + this->m_metadataToken = token; + this->m_debuggerId = id; + m_pCode = NULL; + this->m_pModule = module; + if (module) + module->InternalAddRef(); + conn->GetProcess()->AddFunction(this); +} + +CordbFunction::~CordbFunction() { + if (m_pCode) + m_pCode->InternalRelease(); + if (m_pModule) + m_pModule->InternalRelease(); } HRESULT __stdcall CordbFunction::QueryInterface(REFIID id, void **pInterface) { @@ -35,35 +47,34 @@ HRESULT __stdcall CordbFunction::QueryInterface(REFIID id, void **pInterface) { *pInterface = NULL; return E_NOINTERFACE; } - + AddRef(); return S_OK; } -ULONG __stdcall CordbFunction::AddRef(void) { return 0; } - -ULONG __stdcall CordbFunction::Release(void) { return 0; } - -HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule** ppModule) { - MdbgProtBuffer localbuf; - if (!module) { - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule **ppModule) { + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetModule - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + if (!m_pModule) { + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); + m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer* bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int module_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - conn->ppCordb->GetModule(module_id, &module); - } + int module_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + m_pModule = conn->GetProcess()->GetModule(module_id); + if (m_pModule) + m_pModule->InternalAddRef(); + } - if (!module) - return S_FALSE; + if (!m_pModule) + return S_FALSE; - *ppModule = module; - return S_OK; + m_pModule->AddRef(); + *ppModule = static_cast(m_pModule); + return S_OK; } HRESULT __stdcall CordbFunction::GetClass(ICorDebugClass **ppClass) { @@ -73,33 +84,39 @@ HRESULT __stdcall CordbFunction::GetClass(ICorDebugClass **ppClass) { } HRESULT __stdcall CordbFunction::GetToken(mdMethodDef *pMethodDef) { - if (this->token == 0) { + if (this->GetMetadataToken() == 0) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetToken - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_TOKEN, &localbuf); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, + MDBGPROT_CMD_METHOD_TOKEN, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - this->token = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + this->m_metadataToken = + m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); } - *pMethodDef = this->token; + *pMethodDef = this->GetMetadataToken(); return S_OK; } HRESULT __stdcall CordbFunction::GetILCode(ICorDebugCode **ppCode) { - if (code == NULL) - code = new CordbCode(conn, this); - *ppCode = static_cast(code); + if (m_pCode == NULL) { + m_pCode = new CordbCode(conn, this); + m_pCode->InternalAddRef(); + } + m_pCode->QueryInterface(IID_ICorDebugCode, (void **)ppCode); LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetILCode - IMPLEMENTED\n")); return S_OK; } HRESULT __stdcall CordbFunction::GetNativeCode(ICorDebugCode **ppCode) { - *ppCode = static_cast(code); + if (m_pCode == NULL) { + m_pCode = new CordbCode(conn, this); + m_pCode->InternalAddRef(); + } + m_pCode->QueryInterface(IID_ICorDebugCode, (void **)ppCode); LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetNativeCode - IMPLEMENTED\n")); return S_OK; diff --git a/src/mono/dbi/cordb-function.h b/src/mono/dbi/cordb-function.h index 5af4314d8d7b77..00ef3c955564ce 100644 --- a/src/mono/dbi/cordb-function.h +++ b/src/mono/dbi/cordb-function.h @@ -15,38 +15,42 @@ class CordbFunction : public CordbBaseMono, public ICorDebugFunction2, public ICorDebugFunction3, public ICorDebugFunction4 { + int m_debuggerId; + mdToken m_metadataToken; + CordbCode *m_pCode; + CordbModule *m_pModule; + public: - int id; - mdToken token; - CordbCode *code; - ICorDebugModule *module; + CordbFunction(Connection *conn, mdToken token, int id, CordbModule *module); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbFunction"; } + ~CordbFunction(); + int GetDebuggerId() const { return m_debuggerId; } + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - CordbFunction(Connection *conn, mdToken token, int id, ICorDebugModule *module); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE GetModule(/* [out] */ ICorDebugModule **ppModule); - HRESULT STDMETHODCALLTYPE GetClass(/* [out] */ ICorDebugClass **ppClass); - HRESULT STDMETHODCALLTYPE GetToken(/* [out] */ mdMethodDef *pMethodDef); - HRESULT STDMETHODCALLTYPE GetILCode(/* [out] */ ICorDebugCode **ppCode); - HRESULT STDMETHODCALLTYPE GetNativeCode(/* [out] */ ICorDebugCode **ppCode); - HRESULT STDMETHODCALLTYPE - CreateBreakpoint(/* [out] */ ICorDebugFunctionBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE - GetLocalVarSigToken(/* [out] */ mdSignature *pmdSig); - HRESULT STDMETHODCALLTYPE - GetCurrentVersionNumber(/* [out] */ ULONG32 *pnCurrentVersion); - HRESULT STDMETHODCALLTYPE SetJMCStatus(/* [in] */ BOOL bIsJustMyCode); - HRESULT STDMETHODCALLTYPE GetJMCStatus(/* [out] */ BOOL *pbIsJustMyCode); - HRESULT STDMETHODCALLTYPE - EnumerateNativeCode(/* [out] */ ICorDebugCodeEnum **ppCodeEnum); - HRESULT STDMETHODCALLTYPE GetVersionNumber(/* [out] */ ULONG32 *pnVersion); - HRESULT STDMETHODCALLTYPE + HRESULT GetModule(ICorDebugModule **ppModule); + HRESULT GetClass(ICorDebugClass **ppClass); + HRESULT GetToken(mdMethodDef *pMethodDef); + HRESULT GetILCode(ICorDebugCode **ppCode); + HRESULT GetNativeCode(ICorDebugCode **ppCode); + HRESULT + CreateBreakpoint(ICorDebugFunctionBreakpoint **ppBreakpoint); + HRESULT + GetLocalVarSigToken(mdSignature *pmdSig); + HRESULT + GetCurrentVersionNumber(ULONG32 *pnCurrentVersion); + HRESULT SetJMCStatus(BOOL bIsJustMyCode); + HRESULT GetJMCStatus(BOOL *pbIsJustMyCode); + HRESULT + EnumerateNativeCode(ICorDebugCodeEnum **ppCodeEnum); + HRESULT GetVersionNumber(ULONG32 *pnVersion); + HRESULT GetActiveReJitRequestILCode(ICorDebugILCode **ppReJitedILCode); - HRESULT STDMETHODCALLTYPE + HRESULT CreateNativeBreakpoint(ICorDebugFunctionBreakpoint **ppBreakpoint); + mdToken GetMetadataToken() const { return m_metadataToken; } }; #endif diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index 74e8c4a65fab0a..bef6dc8fcfbe6b 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -4,19 +4,100 @@ // File: CORDB-PROCESS.CPP // -#include #include +#include +#include +#include +#include +#include #include +#include +#include using namespace std; -CordbProcess::CordbProcess() : CordbBaseMono(NULL) { - suspended = false; - appdomains = new ArrayList(); +CordbProcess::CordbProcess(Cordb *cordb) : CordbBaseMono(NULL) { + m_pAppDomainEnum = NULL; + m_pBreakpoints = new ArrayList(); + m_pThreads = new ArrayList(); + m_pFunctions = new ArrayList(); + m_pModules = new ArrayList(); + appDomains = new ArrayList(); + m_pPendingEval = new ArrayList(); + this->m_pCordb = cordb; +} + +CordbProcess::~CordbProcess() { + if (m_pAppDomainEnum) + m_pAppDomainEnum->InternalRelease(); + DWORD i = 0; + while (i < m_pBreakpoints->GetCount()) { + CordbFunctionBreakpoint *breakpoint = + (CordbFunctionBreakpoint *)m_pBreakpoints->Get(i); + if (breakpoint) + breakpoint->InternalRelease(); + i++; + } + i = 0; + while (i < m_pThreads->GetCount()) { + CordbThread *thread = (CordbThread *)m_pThreads->Get(i); + thread->InternalRelease(); + i++; + } + i = 0; + while (i < m_pFunctions->GetCount()) { + CordbFunction *function = (CordbFunction *)m_pFunctions->Get(i); + function->InternalRelease(); + i++; + } + i = 0; + while (i < appDomains->GetCount()) { + CordbAppDomain *appdomain = (CordbAppDomain *)appDomains->Get(i); + appdomain->InternalRelease(); + i++; + } + i = 0; + while (i < m_pModules->GetCount()) { + CordbModule *module = (CordbModule *)m_pModules->Get(i); + module->InternalRelease(); + i++; + } + i = 0; + while (i < m_pPendingEval->GetCount()) { + CordbEval *eval = (CordbEval *)m_pPendingEval->Get(i); + if (eval) + eval->InternalRelease(); + i++; + } + delete m_pBreakpoints; + delete m_pThreads; + delete m_pFunctions; + delete m_pModules; + delete appDomains; + delete m_pPendingEval; + delete conn; +} + +void CordbProcess::CheckPendingEval() { + DWORD i = 0; + while (i < m_pPendingEval->GetCount()) { + CordbEval *eval = (CordbEval *)m_pPendingEval->Get(i); + if (eval) { + ReceivedReplyPacket *recvbuf = + conn->GetAnswerWithError(eval->GetCommandId()); + if (recvbuf) { + eval->EvalComplete(recvbuf->Buffer()); + eval->InternalRelease(); + dbg_lock(); + m_pPendingEval->Set(i, NULL); + dbg_unlock(); + } + } + i++; + } } - HRESULT CordbProcess::EnumerateLoaderHeapMemoryRegions( - /* [out] */ ICorDebugMemoryRangeEnum **ppRanges) { + ICorDebugMemoryRangeEnum **ppRanges) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateLoaderHeapMemoryRegions - NOT IMPLEMENTED\n")); return S_OK; @@ -30,7 +111,7 @@ HRESULT CordbProcess::EnableGCNotificationEvents(BOOL fEnable) { } HRESULT CordbProcess::EnableExceptionCallbacksOutsideOfMyCode( - /* [in] */ BOOL enableExceptionsOutsideOfJMC) { + BOOL enableExceptionsOutsideOfJMC) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnableExceptionCallbacksOutsideOfMyCode - " "NOT IMPLEMENTED\n")); @@ -46,113 +127,94 @@ HRESULT CordbProcess::SetWriteableMetadataUpdateMode( return S_OK; } -HRESULT CordbProcess::GetGCHeapInformation( - /* [out] */ COR_HEAPINFO *pHeapInfo) { +HRESULT CordbProcess::GetGCHeapInformation(COR_HEAPINFO *pHeapInfo) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetGCHeapInformation - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::EnumerateHeap( - /* [out] */ ICorDebugHeapEnum **ppObjects) { +HRESULT CordbProcess::EnumerateHeap(ICorDebugHeapEnum **ppObjects) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateHeap - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::EnumerateHeapRegions( - /* [out] */ ICorDebugHeapSegmentEnum **ppRegions) { +HRESULT +CordbProcess::EnumerateHeapRegions(ICorDebugHeapSegmentEnum **ppRegions) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateHeapRegions - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetObject( - /* [in] */ CORDB_ADDRESS addr, - /* [out] */ ICorDebugObjectValue **pObject) { +HRESULT CordbProcess::GetObject(CORDB_ADDRESS addr, + ICorDebugObjectValue **pObject) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetObject - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::EnumerateGCReferences( - /* [in] */ BOOL enumerateWeakReferences, - /* [out] */ ICorDebugGCReferenceEnum **ppEnum) { +HRESULT CordbProcess::EnumerateGCReferences(BOOL enumerateWeakReferences, + ICorDebugGCReferenceEnum **ppEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateGCReferences - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::EnumerateHandles( - /* [in] */ CorGCReferenceType types, - /* [out] */ ICorDebugGCReferenceEnum **ppEnum) { +HRESULT CordbProcess::EnumerateHandles(CorGCReferenceType types, + ICorDebugGCReferenceEnum **ppEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateHandles - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetTypeID( - /* [in] */ CORDB_ADDRESS obj, - /* [out] */ COR_TYPEID *pId) { +HRESULT CordbProcess::GetTypeID(CORDB_ADDRESS obj, COR_TYPEID *pId) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetTypeID - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetTypeForTypeID( - /* [in] */ COR_TYPEID id, - /* [out] */ ICorDebugType **ppType) { +HRESULT CordbProcess::GetTypeForTypeID(COR_TYPEID id, ICorDebugType **ppType) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetTypeForTypeID - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetArrayLayout( - /* [in] */ COR_TYPEID id, - /* [out] */ COR_ARRAY_LAYOUT *pLayout) { +HRESULT CordbProcess::GetArrayLayout(COR_TYPEID id, COR_ARRAY_LAYOUT *pLayout) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetArrayLayout - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetTypeLayout( - /* [in] */ COR_TYPEID id, - /* [out] */ COR_TYPE_LAYOUT *pLayout) { +HRESULT CordbProcess::GetTypeLayout(COR_TYPEID id, COR_TYPE_LAYOUT *pLayout) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetTypeLayout - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetTypeFields( - /* [in] */ COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], - ULONG32 *pceltNeeded) { +HRESULT CordbProcess::GetTypeFields(COR_TYPEID id, ULONG32 celt, + COR_FIELD fields[], ULONG32 *pceltNeeded) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetTypeFields - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::EnableNGENPolicy( - /* [in] */ CorDebugNGENPolicy ePolicy) { +HRESULT CordbProcess::EnableNGENPolicy(CorDebugNGENPolicy ePolicy) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnableNGENPolicy - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::Filter( - /* [size_is][length_is][in] */ const BYTE pRecord[], - /* [in] */ DWORD countBytes, - /* [in] */ CorDebugRecordFormat format, - /* [in] */ DWORD dwFlags, - /* [in] */ DWORD dwThreadId, - /* [in] */ ICorDebugManagedCallback *pCallback, - /* [out][in] */ CORDB_CONTINUE_STATUS *pContinueStatus) { +HRESULT +CordbProcess::Filter(const BYTE pRecord[], DWORD countBytes, + CorDebugRecordFormat format, DWORD dwFlags, + DWORD dwThreadId, ICorDebugManagedCallback *pCallback, + /* [out][in] */ CORDB_CONTINUE_STATUS *pContinueStatus) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - Filter - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::ProcessStateChanged( - /* [in] */ CorDebugStateChange eChange) { +HRESULT CordbProcess::ProcessStateChanged(CorDebugStateChange eChange) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ProcessStateChanged - NOT IMPLEMENTED\n")); return S_OK; @@ -165,73 +227,58 @@ HRESULT CordbProcess::SetEnableCustomNotification(ICorDebugClass *pClass, return S_OK; } -HRESULT CordbProcess::GetID( - /* [out] */ DWORD *pdwProcessId) { +HRESULT CordbProcess::GetID(DWORD *pdwProcessId) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetID - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetHandle( - /* [out] */ HPROCESS *phProcessHandle) { +HRESULT CordbProcess::GetHandle(HPROCESS *phProcessHandle) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetHandle - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetThread( - /* [in] */ DWORD dwThreadId, - /* [out] */ ICorDebugThread **ppThread) { +HRESULT CordbProcess::GetThread(DWORD dwThreadId, ICorDebugThread **ppThread) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetThread - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::EnumerateObjects( - /* [out] */ ICorDebugObjectEnum **ppObjects) { +HRESULT CordbProcess::EnumerateObjects(ICorDebugObjectEnum **ppObjects) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateObjects - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::IsTransitionStub( - /* [in] */ CORDB_ADDRESS address, - /* [out] */ BOOL *pbTransitionStub) { +HRESULT CordbProcess::IsTransitionStub(CORDB_ADDRESS address, + BOOL *pbTransitionStub) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - IsTransitionStub - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::IsOSSuspended( - /* [in] */ DWORD threadID, - /* [out] */ BOOL *pbSuspended) { +HRESULT CordbProcess::IsOSSuspended(DWORD threadID, BOOL *pbSuspended) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - IsOSSuspended - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetThreadContext( - /* [in] */ DWORD threadID, - /* [in] */ ULONG32 contextSize, - /* [size_is][length_is][out][in] */ BYTE context[]) { +HRESULT CordbProcess::GetThreadContext(DWORD threadID, ULONG32 contextSize, + BYTE context[]) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetThreadContext - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::SetThreadContext( - /* [in] */ DWORD threadID, - /* [in] */ ULONG32 contextSize, - /* [size_is][length_is][in] */ BYTE context[]) { +HRESULT CordbProcess::SetThreadContext(DWORD threadID, ULONG32 contextSize, + BYTE context[]) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetThreadContext - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::ReadMemory( - /* [in] */ CORDB_ADDRESS address, - /* [in] */ DWORD size, - /* [length_is][size_is][out] */ BYTE buffer[], - /* [out] */ SIZE_T *read) { +HRESULT CordbProcess::ReadMemory(CORDB_ADDRESS address, DWORD size, + BYTE buffer[], SIZE_T *read) { memcpy(buffer, (void *)address, size); if (read != NULL) *read = size; @@ -239,25 +286,20 @@ HRESULT CordbProcess::ReadMemory( return S_OK; } -HRESULT CordbProcess::WriteMemory( - /* [in] */ CORDB_ADDRESS address, - /* [in] */ DWORD size, - /* [size_is][in] */ BYTE buffer[], - /* [out] */ SIZE_T *written) { +HRESULT CordbProcess::WriteMemory(CORDB_ADDRESS address, DWORD size, + BYTE buffer[], SIZE_T *written) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - WriteMemory - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::ClearCurrentException( - /* [in] */ DWORD threadID) { +HRESULT CordbProcess::ClearCurrentException(DWORD threadID) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ClearCurrentException - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::EnableLogMessages( - /* [in] */ BOOL fOnOff) { +HRESULT CordbProcess::EnableLogMessages(BOOL fOnOff) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnableLogMessages - NOT IMPLEMENTED\n")); return S_OK; @@ -265,99 +307,91 @@ HRESULT CordbProcess::EnableLogMessages( HRESULT CordbProcess::ModifyLogSwitch( /* [annotation][in] */ - _In_ WCHAR *pLogSwitchName, - /* [in] */ LONG lLevel) { + _In_ WCHAR *pLogSwitchName, LONG lLevel) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ModifyLogSwitch - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::EnumerateAppDomains( - /* [out] */ ICorDebugAppDomainEnum **ppAppDomains) { - *ppAppDomains = new CordbAppDomainEnum(conn, this); +HRESULT +CordbProcess::EnumerateAppDomains(ICorDebugAppDomainEnum **ppAppDomains) { + if (!m_pAppDomainEnum) { + m_pAppDomainEnum = new CordbAppDomainEnum(conn, this); + m_pAppDomainEnum->InternalAddRef(); + } + m_pAppDomainEnum->QueryInterface(IID_ICorDebugAppDomainEnum, + (void **)ppAppDomains); LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - EnumerateAppDomains - IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetObject( - /* [out] */ ICorDebugValue **ppObject) { +HRESULT CordbProcess::GetObject(ICorDebugValue **ppObject) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetObject - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::ThreadForFiberCookie( - /* [in] */ DWORD fiberCookie, - /* [out] */ ICorDebugThread **ppThread) { +HRESULT CordbProcess::ThreadForFiberCookie(DWORD fiberCookie, + ICorDebugThread **ppThread) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ThreadForFiberCookie - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetHelperThreadID( - /* [out] */ DWORD *pThreadID) { +HRESULT CordbProcess::GetHelperThreadID(DWORD *pThreadID) { LOG((LF_CORDB, LL_INFO100000, "GetHelperThreadID - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetThreadForTaskID( - /* [in] */ TASKID taskid, - /* [out] */ ICorDebugThread2 **ppThread) { +HRESULT CordbProcess::GetThreadForTaskID(TASKID taskid, + ICorDebugThread2 **ppThread) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetHelperThreadID - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetVersion( - /* [out] */ COR_VERSION *version) { +HRESULT CordbProcess::GetVersion(COR_VERSION *version) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetVersion - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::SetUnmanagedBreakpoint( - /* [in] */ CORDB_ADDRESS address, - /* [in] */ ULONG32 bufsize, - /* [length_is][size_is][out] */ BYTE buffer[], - /* [out] */ ULONG32 *bufLen) { +HRESULT CordbProcess::SetUnmanagedBreakpoint(CORDB_ADDRESS address, + ULONG32 bufsize, BYTE buffer[], + ULONG32 *bufLen) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetUnmanagedBreakpoint - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::ClearUnmanagedBreakpoint( - /* [in] */ CORDB_ADDRESS address) { +HRESULT CordbProcess::ClearUnmanagedBreakpoint(CORDB_ADDRESS address) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ClearUnmanagedBreakpoint - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::SetDesiredNGENCompilerFlags( - /* [in] */ DWORD pdwFlags) { +HRESULT CordbProcess::SetDesiredNGENCompilerFlags(DWORD pdwFlags) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::GetDesiredNGENCompilerFlags( - /* [out] */ DWORD *pdwFlags) { +HRESULT CordbProcess::GetDesiredNGENCompilerFlags(DWORD *pdwFlags) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::GetReferenceValueFromGCHandle( - /* [in] */ UINT_PTR handle, - /* [out] */ ICorDebugReferenceValue **pOutValue) { + UINT_PTR handle, ICorDebugReferenceValue **pOutValue) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetReferenceValueFromGCHandle - NOT IMPLEMENTED\n")); return S_OK; } HRESULT CordbProcess::QueryInterface( - /* [in] */ REFIID id, - /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { + REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { if (id == IID_ICorDebugProcess) { *pInterface = static_cast(this); } else if (id == IID_ICorDebugController) { @@ -382,50 +416,41 @@ HRESULT CordbProcess::QueryInterface( } else if (id == IID_IUnknown) { *pInterface = static_cast(static_cast(this)); - } - - else { + } else { *pInterface = NULL; return E_NOINTERFACE; } - + AddRef(); return S_OK; } -ULONG CordbProcess::AddRef(void) { return S_OK; } - -ULONG CordbProcess::Release(void) { return S_OK; } - -HRESULT CordbProcess::Stop( - /* [in] */ DWORD dwTimeoutIgnored) { +HRESULT CordbProcess::Stop(DWORD dwTimeoutIgnored) { LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - Stop - IMPLEMENTED\n")); MdbgProtBuffer sendbuf; m_dbgprot_buffer_init(&sendbuf, 128); - conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SUSPEND, &sendbuf); - suspended = true; + conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SUSPEND, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); return S_OK; } -HRESULT CordbProcess::Continue( - /* [in] */ BOOL fIsOutOfBand) { +HRESULT CordbProcess::Continue(BOOL fIsOutOfBand) { LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - Continue - IMPLEMENTED\n")); MdbgProtBuffer sendbuf; m_dbgprot_buffer_init(&sendbuf, 128); - conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_RESUME, &sendbuf); + conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_RESUME, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); return S_OK; } -HRESULT CordbProcess::IsRunning( - /* [out] */ BOOL *pbRunning) { +HRESULT CordbProcess::IsRunning(BOOL *pbRunning) { *pbRunning = true; LOG((LF_CORDB, LL_INFO100000, "CordbProcess - IsRunning - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::HasQueuedCallbacks( - /* [in] */ ICorDebugThread *pThread, - /* [out] */ BOOL *pbQueued) { +HRESULT CordbProcess::HasQueuedCallbacks(ICorDebugThread *pThread, + BOOL *pbQueued) { // conn->process_packet_from_queue(); *pbQueued = false; LOG((LF_CORDB, LL_INFO1000000, @@ -433,16 +458,15 @@ HRESULT CordbProcess::HasQueuedCallbacks( return S_OK; } -HRESULT CordbProcess::EnumerateThreads( - /* [out] */ ICorDebugThreadEnum **ppThreads) { +HRESULT CordbProcess::EnumerateThreads(ICorDebugThreadEnum **ppThreads) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateThreads - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::SetAllThreadsDebugState( - /* [in] */ CorDebugThreadState state, - /* [in] */ ICorDebugThread *pExceptThisThread) { +HRESULT +CordbProcess::SetAllThreadsDebugState(CorDebugThreadState state, + ICorDebugThread *pExceptThisThread) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); return S_OK; @@ -453,29 +477,125 @@ HRESULT CordbProcess::Detach(void) { return S_OK; } -HRESULT CordbProcess::Terminate( - /* [in] */ UINT exitCode) { +HRESULT CordbProcess::Terminate(UINT exitCode) { MdbgProtBuffer sendbuf; m_dbgprot_buffer_init(&sendbuf, 128); m_dbgprot_buffer_add_int(&sendbuf, -1); - conn->send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_EXIT, &sendbuf); + conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_EXIT, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); return S_OK; } -HRESULT CordbProcess::CanCommitChanges( - /* [in] */ ULONG cSnapshots, - /* [size_is][in] */ ICorDebugEditAndContinueSnapshot *pSnapshots[], - /* [out] */ ICorDebugErrorInfoEnum **pError) { +HRESULT +CordbProcess::CanCommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot *pSnapshots[], + ICorDebugErrorInfoEnum **pError) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - CanCommitChanges - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT CordbProcess::CommitChanges( - /* [in] */ ULONG cSnapshots, - /* [size_is][in] */ ICorDebugEditAndContinueSnapshot *pSnapshots[], - /* [out] */ ICorDebugErrorInfoEnum **pError) { +HRESULT +CordbProcess::CommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot *pSnapshots[], + ICorDebugErrorInfoEnum **pError) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - CommitChanges - NOT IMPLEMENTED\n")); return S_OK; } + +void CordbProcess::AddThread(CordbThread *thread) { + m_pThreads->Append(thread); + thread->InternalAddRef(); +} + +void CordbProcess::AddFunction(CordbFunction *function) { + m_pFunctions->Append(function); + function->InternalAddRef(); +} + +void CordbProcess::AddModule(CordbModule *module) { + m_pModules->Append(module); + module->InternalAddRef(); +} + +void CordbProcess::AddAppDomain(CordbAppDomain *appDomain) { + appDomains->Append(appDomain); + appDomain->InternalAddRef(); +} + +void CordbProcess::AddPendingEval(CordbEval *eval) { + m_pPendingEval->Append(eval); + eval->InternalAddRef(); +} +void CordbProcess::AddBreakpoint(CordbFunctionBreakpoint *bp) { + m_pBreakpoints->Append(bp); + bp->InternalAddRef(); +} + +CordbFunction *CordbProcess::FindFunction(int id) { + DWORD i = 0; + while (i < m_pFunctions->GetCount()) { + CordbFunction *function = (CordbFunction *)m_pFunctions->Get(i); + if (function->GetDebuggerId() == id) { + return function; + } + i++; + } + return NULL; +} + +CordbFunction *CordbProcess::FindFunctionByToken(int token) { + DWORD i = 0; + while (i < m_pFunctions->GetCount()) { + CordbFunction *function = (CordbFunction *)m_pFunctions->Get(i); + if (function->GetMetadataToken() == token) { + return function; + } + i++; + } + return NULL; +} + +CordbModule *CordbProcess::GetModule(int module_id) { + for (DWORD i = 0; i < m_pModules->GetCount(); i++) { + CordbModule *module = (CordbModule *)m_pModules->Get(i); + if (module->GetDebuggerId() == module_id) { + return module; + } + } + return NULL; +} + +CordbAppDomain *CordbProcess::GetCurrentAppDomain() { + if (appDomains->GetCount() > 0) + return (CordbAppDomain *)appDomains->Get(0); + return NULL; +} + +CordbThread *CordbProcess::FindThread(long thread_id) { + DWORD i = 0; + while (i < m_pThreads->GetCount()) { + CordbThread *thread = (CordbThread *)m_pThreads->Get(i); + if (thread->GetThreadId() == thread_id) { + return thread; + } + i++; + } + return NULL; +} + +CordbFunctionBreakpoint * +CordbProcess::GetBreakpointByOffsetAndFuncId(int64_t offset, int method_id) { + DWORD i = 0; + CordbFunctionBreakpoint *breakpoint = NULL; + while (i < m_pBreakpoints->GetCount()) { + breakpoint = (CordbFunctionBreakpoint *)m_pBreakpoints->Get(i); + if (breakpoint->GetOffset() == offset && + breakpoint->GetCode()->GetFunction()->GetDebuggerId() == method_id) { + return breakpoint; + } + i++; + } + return NULL; +} diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index c1275c216b3c00..6ee6c9b0e71760 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -20,134 +20,131 @@ class CordbProcess : public CordbBaseMono, public ICorDebugProcess8, public ICorDebugProcess10, public ICorDebugProcess11 { + ArrayList *m_pBreakpoints; + ArrayList *m_pThreads; + ArrayList *m_pFunctions; + ArrayList *m_pModules; + ArrayList *m_pPendingEval; + CordbAppDomainEnum *m_pAppDomainEnum; + Cordb *m_pCordb; + public: - ArrayList *appdomains; - int suspended; - Cordb *cordb; - CordbProcess(); - HRESULT STDMETHODCALLTYPE EnumerateLoaderHeapMemoryRegions( - /* [out] */ ICorDebugMemoryRangeEnum **ppRanges); - HRESULT STDMETHODCALLTYPE EnableGCNotificationEvents(BOOL fEnable); - HRESULT STDMETHODCALLTYPE EnableExceptionCallbacksOutsideOfMyCode( - /* [in] */ BOOL enableExceptionsOutsideOfJMC); - HRESULT STDMETHODCALLTYPE + ArrayList *appDomains; + CordbProcess(Cordb *cordb); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbProcess"; } + Cordb *GetCordb() const { return m_pCordb; } + ~CordbProcess(); + HRESULT EnumerateLoaderHeapMemoryRegions(ICorDebugMemoryRangeEnum **ppRanges); + HRESULT EnableGCNotificationEvents(BOOL fEnable); + HRESULT + EnableExceptionCallbacksOutsideOfMyCode(BOOL enableExceptionsOutsideOfJMC); + HRESULT SetWriteableMetadataUpdateMode(WriteableMetadataUpdateMode flags); - HRESULT STDMETHODCALLTYPE - GetGCHeapInformation(/* [out] */ COR_HEAPINFO *pHeapInfo); - HRESULT STDMETHODCALLTYPE - EnumerateHeap(/* [out] */ ICorDebugHeapEnum **ppObjects); - HRESULT STDMETHODCALLTYPE - EnumerateHeapRegions(/* [out] */ ICorDebugHeapSegmentEnum **ppRegions); - HRESULT STDMETHODCALLTYPE - GetObject(/* [in] */ CORDB_ADDRESS addr, - /* [out] */ ICorDebugObjectValue **pObject); - HRESULT STDMETHODCALLTYPE - EnumerateGCReferences(/* [in] */ BOOL enumerateWeakReferences, /* [out] */ + HRESULT + GetGCHeapInformation(COR_HEAPINFO *pHeapInfo); + HRESULT + EnumerateHeap(ICorDebugHeapEnum **ppObjects); + HRESULT + EnumerateHeapRegions(ICorDebugHeapSegmentEnum **ppRegions); + HRESULT + GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue **pObject); + HRESULT + EnumerateGCReferences(BOOL enumerateWeakReferences, ICorDebugGCReferenceEnum **ppEnum); - HRESULT STDMETHODCALLTYPE - EnumerateHandles(/* [in] */ CorGCReferenceType types, /* [out] */ - ICorDebugGCReferenceEnum **ppEnum); - HRESULT STDMETHODCALLTYPE GetTypeID(/* [in] */ CORDB_ADDRESS obj, - /* [out] */ COR_TYPEID *pId); - HRESULT STDMETHODCALLTYPE GetTypeForTypeID( - /* [in] */ COR_TYPEID id, /* [out] */ ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE GetArrayLayout( - /* [in] */ COR_TYPEID id, /* [out] */ COR_ARRAY_LAYOUT *pLayout); - HRESULT STDMETHODCALLTYPE GetTypeLayout(/* [in] */ COR_TYPEID id, - /* [out] */ COR_TYPE_LAYOUT *pLayout); - HRESULT STDMETHODCALLTYPE GetTypeFields(/* [in] */ COR_TYPEID id, - ULONG32 celt, COR_FIELD fields[], - ULONG32 *pceltNeeded); - HRESULT STDMETHODCALLTYPE - EnableNGENPolicy(/* [in] */ CorDebugNGENPolicy ePolicy); - HRESULT STDMETHODCALLTYPE - Filter(/* [size_is][length_is][in] */ const BYTE pRecord[], - /* [in] */ DWORD countBytes, - /* [in] */ CorDebugRecordFormat format, /* [in] */ - DWORD dwFlags, /* [in] */ DWORD dwThreadId, - /* [in] */ ICorDebugManagedCallback *pCallback, - /* [out][in] */ + HRESULT + EnumerateHandles(CorGCReferenceType types, ICorDebugGCReferenceEnum **ppEnum); + HRESULT GetTypeID(CORDB_ADDRESS obj, COR_TYPEID *pId); + HRESULT GetTypeForTypeID(COR_TYPEID id, ICorDebugType **ppType); + HRESULT GetArrayLayout(COR_TYPEID id, COR_ARRAY_LAYOUT *pLayout); + HRESULT GetTypeLayout(COR_TYPEID id, COR_TYPE_LAYOUT *pLayout); + HRESULT GetTypeFields(COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], + ULONG32 *pceltNeeded); + HRESULT + EnableNGENPolicy(CorDebugNGENPolicy ePolicy); + HRESULT + Filter(const BYTE pRecord[], DWORD countBytes, CorDebugRecordFormat format, + DWORD dwFlags, DWORD dwThreadId, ICorDebugManagedCallback *pCallback, CORDB_CONTINUE_STATUS *pContinueStatus); - HRESULT STDMETHODCALLTYPE - ProcessStateChanged(/* [in] */ CorDebugStateChange eChange); - HRESULT STDMETHODCALLTYPE SetEnableCustomNotification(ICorDebugClass *pClass, - BOOL fEnable); - HRESULT STDMETHODCALLTYPE GetID(/* [out] */ DWORD *pdwProcessId); - HRESULT STDMETHODCALLTYPE GetHandle(/* [out] */ HPROCESS *phProcessHandle); - HRESULT STDMETHODCALLTYPE GetThread(/* [in] */ DWORD dwThreadId, - /* [out] */ ICorDebugThread **ppThread); - HRESULT STDMETHODCALLTYPE - EnumerateObjects(/* [out] */ ICorDebugObjectEnum **ppObjects); - HRESULT STDMETHODCALLTYPE IsTransitionStub( - /* [in] */ CORDB_ADDRESS address, /* [out] */ BOOL *pbTransitionStub); - HRESULT STDMETHODCALLTYPE IsOSSuspended(/* [in] */ DWORD threadID, - /* [out] */ BOOL *pbSuspended); - HRESULT STDMETHODCALLTYPE - GetThreadContext(/* [in] */ DWORD threadID, /* [in] */ ULONG32 contextSize, - /* [size_is][length_is][out][in] */ BYTE context[]); - HRESULT STDMETHODCALLTYPE - SetThreadContext(/* [in] */ DWORD threadID, /* [in] */ ULONG32 contextSize, - /* [size_is][length_is][in] */ BYTE context[]); - HRESULT STDMETHODCALLTYPE - ReadMemory(/* [in] */ CORDB_ADDRESS address, /* [in] */ DWORD size, - /* [length_is][size_is][out] */ BYTE buffer[], /* [out] */ - SIZE_T *read); - HRESULT STDMETHODCALLTYPE - WriteMemory(/* [in] */ CORDB_ADDRESS address, - /* [in] */ DWORD size, /* [size_is][in] */ - BYTE buffer[], /* [out] */ SIZE_T *written); - HRESULT STDMETHODCALLTYPE ClearCurrentException(/* [in] */ DWORD threadID); - HRESULT STDMETHODCALLTYPE EnableLogMessages(/* [in] */ BOOL fOnOff); - HRESULT STDMETHODCALLTYPE - ModifyLogSwitch(/* [annotation][in] */ _In_ WCHAR *pLogSwitchName, - /* [in] */ LONG lLevel); - HRESULT STDMETHODCALLTYPE - EnumerateAppDomains(/* [out] */ ICorDebugAppDomainEnum **ppAppDomains); - HRESULT STDMETHODCALLTYPE GetObject(/* [out] */ ICorDebugValue **ppObject); - HRESULT STDMETHODCALLTYPE ThreadForFiberCookie( - /* [in] */ DWORD fiberCookie, /* [out] */ ICorDebugThread **ppThread); - HRESULT STDMETHODCALLTYPE GetHelperThreadID(/* [out] */ DWORD *pThreadID); - HRESULT STDMETHODCALLTYPE GetThreadForTaskID( - /* [in] */ TASKID taskid, /* [out] */ ICorDebugThread2 **ppThread); - HRESULT STDMETHODCALLTYPE GetVersion(/* [out] */ COR_VERSION *version); - HRESULT STDMETHODCALLTYPE SetUnmanagedBreakpoint( - /* [in] */ CORDB_ADDRESS address, /* [in] */ ULONG32 bufsize, - /* [length_is][size_is][out] */ BYTE buffer[], - /* [out] */ ULONG32 *bufLen); - HRESULT STDMETHODCALLTYPE - ClearUnmanagedBreakpoint(/* [in] */ CORDB_ADDRESS address); - HRESULT STDMETHODCALLTYPE - SetDesiredNGENCompilerFlags(/* [in] */ DWORD pdwFlags); - HRESULT STDMETHODCALLTYPE - GetDesiredNGENCompilerFlags(/* [out] */ DWORD *pdwFlags); - HRESULT STDMETHODCALLTYPE - GetReferenceValueFromGCHandle(/* [in] */ UINT_PTR handle, /* [out] */ + HRESULT + ProcessStateChanged(CorDebugStateChange eChange); + HRESULT SetEnableCustomNotification(ICorDebugClass *pClass, BOOL fEnable); + HRESULT GetID(DWORD *pdwProcessId); + HRESULT GetHandle(HPROCESS *phProcessHandle); + HRESULT GetThread(DWORD dwThreadId, ICorDebugThread **ppThread); + HRESULT + EnumerateObjects(ICorDebugObjectEnum **ppObjects); + HRESULT IsTransitionStub(CORDB_ADDRESS address, BOOL *pbTransitionStub); + HRESULT IsOSSuspended(DWORD threadID, BOOL *pbSuspended); + HRESULT + GetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); + HRESULT + SetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); + HRESULT + ReadMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T *read); + HRESULT + WriteMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], + SIZE_T *written); + HRESULT ClearCurrentException(DWORD threadID); + HRESULT EnableLogMessages(BOOL fOnOff); + HRESULT + ModifyLogSwitch(_In_ WCHAR *pLogSwitchName, LONG lLevel); + HRESULT + EnumerateAppDomains(ICorDebugAppDomainEnum **ppAppDomains); + HRESULT GetObject(ICorDebugValue **ppObject); + HRESULT ThreadForFiberCookie(DWORD fiberCookie, ICorDebugThread **ppThread); + HRESULT GetHelperThreadID(DWORD *pThreadID); + HRESULT GetThreadForTaskID(TASKID taskid, ICorDebugThread2 **ppThread); + HRESULT GetVersion(COR_VERSION *version); + HRESULT SetUnmanagedBreakpoint(CORDB_ADDRESS address, ULONG32 bufsize, + BYTE buffer[], ULONG32 *bufLen); + HRESULT + ClearUnmanagedBreakpoint(CORDB_ADDRESS address); + HRESULT + SetDesiredNGENCompilerFlags(DWORD pdwFlags); + HRESULT + GetDesiredNGENCompilerFlags(DWORD *pdwFlags); + HRESULT + GetReferenceValueFromGCHandle(UINT_PTR handle, ICorDebugReferenceValue **pOutValue); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE Stop(/* [in] */ DWORD dwTimeoutIgnored); - HRESULT STDMETHODCALLTYPE Continue(/* [in] */ BOOL fIsOutOfBand); - HRESULT STDMETHODCALLTYPE IsRunning(/* [out] */ BOOL *pbRunning); - HRESULT STDMETHODCALLTYPE HasQueuedCallbacks( - /* [in] */ ICorDebugThread *pThread, /* [out] */ BOOL *pbQueued); - HRESULT STDMETHODCALLTYPE - EnumerateThreads(/* [out] */ ICorDebugThreadEnum **ppThreads); - HRESULT STDMETHODCALLTYPE - SetAllThreadsDebugState(/* [in] */ CorDebugThreadState state, /* [in] */ + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + + HRESULT Stop(DWORD dwTimeoutIgnored); + HRESULT Continue(BOOL fIsOutOfBand); + HRESULT IsRunning(BOOL *pbRunning); + HRESULT HasQueuedCallbacks(ICorDebugThread *pThread, BOOL *pbQueued); + HRESULT + EnumerateThreads(ICorDebugThreadEnum **ppThreads); + HRESULT + SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread *pExceptThisThread); - HRESULT STDMETHODCALLTYPE Detach(void); - HRESULT STDMETHODCALLTYPE Terminate(/* [in] */ UINT exitCode); - HRESULT STDMETHODCALLTYPE - CanCommitChanges(/* [in] */ ULONG cSnapshots, /* [size_is][in] */ - ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + HRESULT Detach(void); + HRESULT Terminate(UINT exitCode); + HRESULT + CanCommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot *pSnapshots[], ICorDebugErrorInfoEnum **pError); - HRESULT STDMETHODCALLTYPE - CommitChanges(/* [in] */ ULONG cSnapshots, /* [size_is][in] */ - ICorDebugEditAndContinueSnapshot *pSnapshots[], /* [out] */ + HRESULT + CommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot *pSnapshots[], ICorDebugErrorInfoEnum **pError); + + void AddThread(CordbThread *thread); + void AddFunction(CordbFunction *function); + void AddModule(CordbModule *module); + void AddAppDomain(CordbAppDomain *appDomain); + void AddBreakpoint(CordbFunctionBreakpoint *bp); + void AddPendingEval(CordbEval *eval); + CordbFunction *FindFunction(int id); + CordbFunction *FindFunctionByToken(int token); + CordbModule *GetModule(int module_id); + CordbAppDomain *GetCurrentAppDomain(); + CordbThread *FindThread(long thread_id); + CordbFunctionBreakpoint *GetBreakpointByOffsetAndFuncId(int64_t offset, + int method_id); + void CheckPendingEval(); }; #endif diff --git a/src/mono/dbi/cordb-register.cpp b/src/mono/dbi/cordb-register.cpp index dde7c4186e0002..876463a04f24f6 100644 --- a/src/mono/dbi/cordb-register.cpp +++ b/src/mono/dbi/cordb-register.cpp @@ -10,57 +10,50 @@ using namespace std; -HRESULT __stdcall CordbRegisteSet::GetRegistersAvailable(ULONG64 *pAvailable) { +HRESULT __stdcall CordbRegisterSet::GetRegistersAvailable(ULONG64 *pAvailable) { LOG((LF_CORDB, LL_INFO100000, - "CordbRegisteSet - GetRegistersAvailable - NOT IMPLEMENTED\n")); + "CordbRegisterSet - GetRegistersAvailable - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -CordbRegisteSet::CordbRegisteSet(Connection *conn, uint8_t *ctx, uint32_t ctx_len) +CordbRegisterSet::CordbRegisterSet(Connection *conn, uint8_t *ctx, + uint32_t ctx_len) : CordbBaseMono(conn) { - this->ctx = ctx; - this->ctx_len = ctx_len; + this->m_pCtx = ctx; + this->m_ctxLen = ctx_len; } -HRESULT __stdcall CordbRegisteSet::QueryInterface(REFIID id, - void **pInterface) { +HRESULT __stdcall CordbRegisterSet::QueryInterface(REFIID id, + void **pInterface) { LOG((LF_CORDB, LL_INFO100000, - "CordbRegisteSet - QueryInterface - NOT IMPLEMENTED\n")); + "CordbRegisterSet - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbRegisteSet::GetRegisters(ULONG64 mask, ULONG32 regCount, - CORDB_REGISTER regBuffer[]) { +HRESULT __stdcall CordbRegisterSet::GetRegisters(ULONG64 mask, ULONG32 regCount, + CORDB_REGISTER regBuffer[]) { LOG((LF_CORDB, LL_INFO100000, - "CordbRegisteSet - GetRegisters - NOT IMPLEMENTED\n")); + "CordbRegisterSet - GetRegisters - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -ULONG __stdcall CordbRegisteSet::Release(void) { return 0; } - -ULONG __stdcall CordbRegisteSet::AddRef(void) { return 0; } - -HRESULT STDMETHODCALLTYPE CordbRegisteSet::SetRegisters( - /* [in] */ ULONG64 mask, - /* [in] */ ULONG32 regCount, - /* [size_is][in] */ CORDB_REGISTER regBuffer[]) { +HRESULT STDMETHODCALLTYPE CordbRegisterSet::SetRegisters( + ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]) { LOG((LF_CORDB, LL_INFO100000, - "CordbRegisteSet - SetRegisters - NOT IMPLEMENTED\n")); + "CordbRegisterSet - SetRegisters - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbRegisteSet::GetThreadContext( - /* [in] */ ULONG32 contextSize, - /* [size_is][length_is][out][in] */ BYTE context[]) { +HRESULT STDMETHODCALLTYPE +CordbRegisterSet::GetThreadContext(ULONG32 contextSize, BYTE context[]) { LOG((LF_CORDB, LL_INFO100000, - "CordbRegisteSet - GetThreadContext - NOT IMPLEMENTED\n")); + "CordbRegisterSet - GetThreadContext - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbRegisteSet::SetThreadContext( - /* [in] */ ULONG32 contextSize, - /* [size_is][length_is][in] */ BYTE context[]) { +HRESULT STDMETHODCALLTYPE +CordbRegisterSet::SetThreadContext(ULONG32 contextSize, BYTE context[]) { LOG((LF_CORDB, LL_INFO100000, - "CordbRegisteSet - SetThreadContext - NOT IMPLEMENTED\n")); + "CordbRegisterSet - SetThreadContext - NOT IMPLEMENTED\n")); return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-register.h b/src/mono/dbi/cordb-register.h index 2d0a4de0077491..b50b410de9e847 100644 --- a/src/mono/dbi/cordb-register.h +++ b/src/mono/dbi/cordb-register.h @@ -9,31 +9,26 @@ #include -class CordbRegisteSet : public CordbBaseMono, public ICorDebugRegisterSet { - uint8_t *ctx; - uint32_t ctx_len; +class CordbRegisterSet : public CordbBaseMono, public ICorDebugRegisterSet { + uint8_t *m_pCtx; + uint32_t m_ctxLen; public: - CordbRegisteSet(Connection *conn, uint8_t *ctx, uint32_t ctx_len); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE - GetRegistersAvailable(/* [out] */ ULONG64 *pAvailable); - HRESULT STDMETHODCALLTYPE - GetRegisters(/* [in] */ ULONG64 mask, /* [in] */ ULONG32 regCount, - /* [length_is][size_is][out] */ CORDB_REGISTER regBuffer[]); - HRESULT STDMETHODCALLTYPE SetRegisters( - /* [in] */ ULONG64 mask, /* [in] */ ULONG32 regCount, /* [size_is][in] */ - CORDB_REGISTER regBuffer[]); - HRESULT STDMETHODCALLTYPE GetThreadContext( - /* [in] */ ULONG32 contextSize, /* [size_is][length_is][out][in] */ - BYTE context[]); - HRESULT STDMETHODCALLTYPE SetThreadContext( - /* [in] */ ULONG32 contextSize, /* [size_is][length_is][in] */ - BYTE context[]); + CordbRegisterSet(Connection *conn, uint8_t *ctx, uint32_t ctx_len); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbRegisterSet"; } + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + + HRESULT + GetRegistersAvailable(ULONG64 *pAvailable); + HRESULT + GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]); + HRESULT SetRegisters(ULONG64 mask, ULONG32 regCount, + CORDB_REGISTER regBuffer[]); + HRESULT GetThreadContext(ULONG32 contextSize, BYTE context[]); + HRESULT SetThreadContext(ULONG32 contextSize, BYTE context[]); }; #endif diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index 020ab778ec57ec..d411afa5bbac91 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -13,12 +13,12 @@ using namespace std; CordbStepper::CordbStepper(Connection *conn, CordbThread *thread) : CordbBaseMono(conn) { - this->thread = thread; - hasStepped = false; - isComplete = false; - eventId = -1; + m_pThread = thread; + m_commandId = -1; } +CordbStepper::~CordbStepper() {} + HRESULT STDMETHODCALLTYPE CordbStepper::IsActive(BOOL *pbActive) { LOG((LF_CORDB, LL_INFO100000, "CordbStepper - IsActive - NOT IMPLEMENTED\n")); return E_NOTIMPL; @@ -30,9 +30,10 @@ HRESULT STDMETHODCALLTYPE CordbStepper::Deactivate(void) { int buflen = 128; m_dbgprot_buffer_init(&sendbuf, buflen); m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); - m_dbgprot_buffer_add_int(&sendbuf, eventId); - conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, - MDBGPROT_CMD_EVENT_REQUEST_CLEAR, &sendbuf); + m_dbgprot_buffer_add_int(&sendbuf, m_commandId); + conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, + MDBGPROT_CMD_EVENT_REQUEST_CLEAR, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); return S_OK; } @@ -58,8 +59,6 @@ HRESULT STDMETHODCALLTYPE CordbStepper::Step(BOOL bStepIn) { HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, COR_DEBUG_STEP_RANGE ranges[], ULONG32 cRangeCount) { - isComplete = false; - hasStepped = true; MdbgProtBuffer sendbuf; int buflen = 128; m_dbgprot_buffer_init(&sendbuf, buflen); @@ -68,25 +67,23 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); - m_dbgprot_buffer_add_id(&sendbuf, thread->thread_id); + m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO : MDBGPROT_STEP_DEPTH_OVER); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, - MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, + MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - eventId = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + m_commandId = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepRange - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { - isComplete = false; - hasStepped = true; MdbgProtBuffer sendbuf; int buflen = 128; m_dbgprot_buffer_init(&sendbuf, buflen); @@ -95,16 +92,16 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); - m_dbgprot_buffer_add_id(&sendbuf, thread->thread_id); + m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_DEPTH_OUT); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, - MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, + MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepOut - IMPLEMENTED\n")); return S_OK; @@ -116,24 +113,23 @@ HRESULT STDMETHODCALLTYPE CordbStepper::SetRangeIL(BOOL bIL) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbStepper::QueryInterface(REFIID riid, - void **ppvObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbStepper - QueryInterface - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -ULONG STDMETHODCALLTYPE CordbStepper::AddRef(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbStepper - AddRef - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -ULONG STDMETHODCALLTYPE CordbStepper::Release(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbStepper - Release - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbStepper::QueryInterface(REFIID id, + void **pInterface) { + if (id == IID_ICorDebugStepper) + *pInterface = static_cast(this); + else if (id == IID_ICorDebugStepper2) + *pInterface = static_cast(this); + else if (id == IID_IUnknown) + *pInterface = + static_cast(static_cast(this)); + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; } HRESULT STDMETHODCALLTYPE CordbStepper::SetJMC(BOOL fIsJMCStepper) { LOG((LF_CORDB, LL_INFO100000, "CordbStepper - SetJMC - NOT IMPLEMENTED\n")); - return E_NOTIMPL; + return S_OK; } diff --git a/src/mono/dbi/cordb-stepper.h b/src/mono/dbi/cordb-stepper.h index 77f7756ff8a239..f86d2ea9bdf8f9 100644 --- a/src/mono/dbi/cordb-stepper.h +++ b/src/mono/dbi/cordb-stepper.h @@ -12,27 +12,27 @@ class CordbStepper : public CordbBaseMono, public ICorDebugStepper, public ICorDebugStepper2 { - CordbThread *thread; - bool hasStepped; - int eventId; + CordbThread *m_pThread; + int m_commandId; public: - bool isComplete; CordbStepper(Connection *conn, CordbThread *thread); - HRESULT STDMETHODCALLTYPE IsActive(BOOL *pbActive); - HRESULT STDMETHODCALLTYPE Deactivate(void); - HRESULT STDMETHODCALLTYPE SetInterceptMask(CorDebugIntercept mask); - HRESULT STDMETHODCALLTYPE SetUnmappedStopMask(CorDebugUnmappedStop mask); - HRESULT STDMETHODCALLTYPE Step(BOOL bStepIn); - HRESULT STDMETHODCALLTYPE StepRange(BOOL bStepIn, - COR_DEBUG_STEP_RANGE ranges[], - ULONG32 cRangeCount); - HRESULT STDMETHODCALLTYPE StepOut(void); - HRESULT STDMETHODCALLTYPE SetRangeIL(BOOL bIL); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE SetJMC(BOOL fIsJMCStepper); + ~CordbStepper(); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbStepper"; } + HRESULT IsActive(BOOL *pbActive); + HRESULT Deactivate(void); + HRESULT SetInterceptMask(CorDebugIntercept mask); + HRESULT SetUnmappedStopMask(CorDebugUnmappedStop mask); + HRESULT Step(BOOL bStepIn); + HRESULT StepRange(BOOL bStepIn, COR_DEBUG_STEP_RANGE ranges[], + ULONG32 cRangeCount); + HRESULT StepOut(void); + HRESULT SetRangeIL(BOOL bIL); + HRESULT QueryInterface(REFIID riid, void **ppvObject); + + HRESULT SetJMC(BOOL fIsJMCStepper); }; #endif diff --git a/src/mono/dbi/cordb-symbol.cpp b/src/mono/dbi/cordb-symbol.cpp index 07879332ea2d1d..ab130f0d618226 100644 --- a/src/mono/dbi/cordb-symbol.cpp +++ b/src/mono/dbi/cordb-symbol.cpp @@ -21,12 +21,8 @@ using namespace std; -RegMeta::RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule) { - module_id = -1; - pCordbAssembly = cordbAssembly; - this->cordbModule = cordbModule; - token_id = 0; - +RegMeta::RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule) + : CordbBaseMono(NULL) { m_pStgdb = new CLiteWeightStgdbRW(); ULONG32 pcchName = 0; cordbModule->GetName(0, &pcchName, NULL); @@ -36,8 +32,11 @@ RegMeta::RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule) { cordbModule->GetName(pcchName, &pcchName, full_path); m_pStgdb->OpenForRead(full_path, NULL, 0, 0); + free(full_path); } +RegMeta::~RegMeta() { delete m_pStgdb; } + HRESULT RegMeta::EnumGenericParams( HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdToken tkOwner, // [IN] TypeDef or MethodDef whose generic parameters are @@ -652,13 +651,11 @@ HRESULT RegMeta::QueryInterface(REFIID riid, LPVOID *ppUnk) { IfFailGo(E_NOINTERFACE); } ErrExit: + if (hr == S_OK) + AddRef(); return hr; } -ULONG RegMeta::AddRef() { return S_OK; } - -ULONG RegMeta::Release() { return S_OK; } - // IMetaDataImport functions void RegMeta::CloseEnum(HCORENUM hEnum) { BEGIN_CLEANUP_ENTRYPOINT; diff --git a/src/mono/dbi/cordb-symbol.h b/src/mono/dbi/cordb-symbol.h index 16b5ae06985074..ca6ee04b49ff40 100644 --- a/src/mono/dbi/cordb-symbol.h +++ b/src/mono/dbi/cordb-symbol.h @@ -14,15 +14,17 @@ class CLiteWeightStgdbRW; -class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { - int token_id; - CordbAssembly *pCordbAssembly; - CordbModule *cordbModule; +class RegMeta : public CordbBaseMono, + public IMetaDataImport2, + public IMetaDataAssemblyImport { CLiteWeightStgdbRW *m_pStgdb; - int module_id; public: RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule); + ~RegMeta(); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbRegMeta"; } inline int IsGlobalMethodParentTk(mdTypeDef td) { return (td == mdTypeDefNil || td == mdTokenNil); @@ -225,43 +227,38 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG *pcAssemblies); // [OUT] The number of assemblies returned. // IUnknown methods - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppvObj); - - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); + HRESULT QueryInterface(REFIID riid, LPVOID *ppvObj); // IMetaDataImport functions - void STDMETHODCALLTYPE CloseEnum(HCORENUM hEnum); - HRESULT STDMETHODCALLTYPE CountEnum(HCORENUM hEnum, ULONG *pulCount); - HRESULT STDMETHODCALLTYPE ResetEnum(HCORENUM hEnum, ULONG ulPos); - HRESULT STDMETHODCALLTYPE EnumTypeDefs(HCORENUM *phEnum, - mdTypeDef rTypeDefs[], ULONG cMax, - ULONG *pcTypeDefs); - HRESULT STDMETHODCALLTYPE EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td, - mdInterfaceImpl rImpls[], - ULONG cMax, ULONG *pcImpls); - HRESULT STDMETHODCALLTYPE EnumTypeRefs(HCORENUM *phEnum, - mdTypeRef rTypeRefs[], ULONG cMax, - ULONG *pcTypeRefs); - - HRESULT STDMETHODCALLTYPE FindTypeDefByName( // S_OK or error. - LPCWSTR szTypeDef, // [IN] Name of the Type. + void CloseEnum(HCORENUM hEnum); + HRESULT CountEnum(HCORENUM hEnum, ULONG *pulCount); + HRESULT ResetEnum(HCORENUM hEnum, ULONG ulPos); + HRESULT EnumTypeDefs(HCORENUM *phEnum, mdTypeDef rTypeDefs[], ULONG cMax, + ULONG *pcTypeDefs); + HRESULT EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td, + mdInterfaceImpl rImpls[], ULONG cMax, + ULONG *pcImpls); + HRESULT EnumTypeRefs(HCORENUM *phEnum, mdTypeRef rTypeRefs[], ULONG cMax, + ULONG *pcTypeRefs); + + HRESULT FindTypeDefByName( // S_OK or error. + LPCWSTR szTypeDef, // [IN] Name of the Type. mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class. mdTypeDef *ptd); // [OUT] Put the TypeDef token here. - HRESULT STDMETHODCALLTYPE GetScopeProps( // S_OK or error. + HRESULT GetScopeProps( // S_OK or error. __out_ecount_part_opt(cchName, *pchName) LPWSTR szName, // [OUT] Put the name here. ULONG cchName, // [IN] Size of name buffer in wide chars. ULONG *pchName, // [OUT] Put size of name (wide chars) here. GUID *pmvid); // [OUT, OPTIONAL] Put MVID here. - HRESULT STDMETHODCALLTYPE GetModuleFromScope( // S_OK. - mdModule *pmd); // [OUT] Put mdModule token here. + HRESULT GetModuleFromScope( // S_OK. + mdModule *pmd); // [OUT] Put mdModule token here. - HRESULT STDMETHODCALLTYPE GetTypeDefProps( // S_OK or error. - mdTypeDef td, // [IN] TypeDef token for inquiry. + HRESULT GetTypeDefProps( // S_OK or error. + mdTypeDef td, // [IN] TypeDef token for inquiry. __out_ecount_part_opt(cchTypeDef, *pchTypeDef) LPWSTR szTypeDef, // [OUT] Put name here. ULONG cchTypeDef, // [IN] size of name buffer in wide chars. @@ -269,13 +266,13 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { DWORD *pdwTypeDefFlags, // [OUT] Put flags here. mdToken *ptkExtends); // [OUT] Put base class TypeDef/TypeRef here. - HRESULT STDMETHODCALLTYPE GetInterfaceImplProps( // S_OK or error. - mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. - mdTypeDef *pClass, // [OUT] Put implementing class token here. - mdToken *ptkIface); // [OUT] Put implemented interface token here. + HRESULT GetInterfaceImplProps( // S_OK or error. + mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. + mdTypeDef *pClass, // [OUT] Put implementing class token here. + mdToken *ptkIface); // [OUT] Put implemented interface token here. - HRESULT STDMETHODCALLTYPE GetTypeRefProps( // S_OK or error. - mdTypeRef tr, // [IN] TypeRef token. + HRESULT GetTypeRefProps( // S_OK or error. + mdTypeRef tr, // [IN] TypeRef token. mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or // AssemblyRef. __out_ecount_part_opt(cchName, *pchName) @@ -283,113 +280,113 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG cchName, // [IN] Size of buffer. ULONG *pchName); // [OUT] Size of Name. - HRESULT STDMETHODCALLTYPE ResolveTypeRef(mdTypeRef tr, REFIID riid, - IUnknown **ppIScope, mdTypeDef *ptd); - - HRESULT STDMETHODCALLTYPE EnumMembers( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. + HRESULT ResolveTypeRef(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, + mdTypeDef *ptd); - HRESULT STDMETHODCALLTYPE EnumMembersWithName( // S_OK, S_FALSE, or error. + HRESULT EnumMembers( // S_OK, S_FALSE, or error. HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. mdToken rMembers[], // [OUT] Put MemberDefs here. ULONG cMax, // [IN] Max MemberDefs to put. ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumMethods( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdMethodDef rMethods[], // [OUT] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. + HRESULT EnumMembersWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdToken rMembers[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumMethodsWithName( // S_OK, S_FALSE, or error. + HRESULT EnumMethods( // S_OK, S_FALSE, or error. HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdMethodDef rMethods[], // [OU] Put MethodDefs here. + mdMethodDef rMethods[], // [OUT] Put MethodDefs here. ULONG cMax, // [IN] Max MethodDefs to put. ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumFields( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + HRESULT EnumMethodsWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdMethodDef rMethods[], // [OU] Put MethodDefs here. + ULONG cMax, // [IN] Max MethodDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT EnumFields( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdTypeDef cl, // [IN] TypeDef to scope the enumeration. mdFieldDef rFields[], // [OUT] Put FieldDefs here. ULONG cMax, // [IN] Max FieldDefs to put. ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumFieldsWithName( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdFieldDef rFields[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. + HRESULT EnumFieldsWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdFieldDef rFields[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumParams( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + HRESULT EnumParams( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdMethodDef mb, // [IN] MethodDef to scope the enumeration. mdParamDef rParams[], // [OUT] Put ParamDefs here. ULONG cMax, // [IN] Max ParamDefs to put. ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumMemberRefs( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + HRESULT EnumMemberRefs( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdToken tkParent, // [IN] Parent token to scope the enumeration. mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here. ULONG cMax, // [IN] Max MemberRefs to put. ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumMethodImpls( // S_OK, S_FALSE, or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + HRESULT EnumMethodImpls( // S_OK, S_FALSE, or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdTypeDef td, // [IN] TypeDef to scope the enumeration. mdToken rMethodBody[], // [OUT] Put Method Body tokens here. mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here. ULONG cMax, // [IN] Max tokens to put. ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumPermissionSets( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tk, // [IN] if !NIL, token to scope the enumeration. - DWORD dwActions, // [IN] if !0, return only these actions. + HRESULT EnumPermissionSets( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tk, // [IN] if !NIL, token to scope the enumeration. + DWORD dwActions, // [IN] if !0, return only these actions. mdPermission rPermission[], // [OUT] Put Permissions here. ULONG cMax, // [IN] Max Permissions to put. ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE FindMember( + HRESULT FindMember( mdTypeDef td, // [IN] given typedef LPCWSTR szName, // [IN] member name PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature ULONG cbSigBlob, // [IN] count of bytes in the signature blob mdToken *pmb); // [OUT] matching memberdef - HRESULT STDMETHODCALLTYPE FindMethod( + HRESULT FindMethod( mdTypeDef td, // [IN] given typedef LPCWSTR szName, // [IN] member name PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature ULONG cbSigBlob, // [IN] count of bytes in the signature blob mdMethodDef *pmb); // [OUT] matching memberdef - HRESULT STDMETHODCALLTYPE FindField( + HRESULT FindField( mdTypeDef td, // [IN] given typedef LPCWSTR szName, // [IN] member name PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature ULONG cbSigBlob, // [IN] count of bytes in the signature blob mdFieldDef *pmb); // [OUT] matching memberdef - HRESULT STDMETHODCALLTYPE FindMemberRef( + HRESULT FindMemberRef( mdTypeRef td, // [IN] given typeRef LPCWSTR szName, // [IN] member name PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature ULONG cbSigBlob, // [IN] count of bytes in the signature blob mdMemberRef *pmr); // [OUT] matching memberref - HRESULT STDMETHODCALLTYPE GetMethodProps( + HRESULT GetMethodProps( mdMethodDef mb, // The method for which to get props. mdTypeDef *pClass, // Put method's class here. __out_ecount_part_opt(cchMethod, *pchMethod) @@ -402,9 +399,9 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG *pulCodeRVA, // [OUT] codeRVA DWORD *pdwImplFlags); // [OUT] Impl. Flags - HRESULT STDMETHODCALLTYPE GetMemberRefProps( // S_OK or error. - mdMemberRef mr, // [IN] given memberref - mdToken *ptk, // [OUT] Put classref or classdef here. + HRESULT GetMemberRefProps( // S_OK or error. + mdMemberRef mr, // [IN] given memberref + mdToken *ptk, // [OUT] Put classref or classdef here. __out_ecount_part_opt(cchMember, *pchMember) LPWSTR szMember, // [OUT] buffer to fill for member's name ULONG cchMember, // [IN] the count of char of szMember @@ -412,22 +409,22 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value ULONG *pbSig); // [OUT] actual size of signature blob - HRESULT STDMETHODCALLTYPE EnumProperties( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + HRESULT EnumProperties( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdTypeDef td, // [IN] TypeDef to scope the enumeration. mdProperty rProperties[], // [OUT] Put Properties here. ULONG cMax, // [IN] Max properties to put. ULONG *pcProperties); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE EnumEvents( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + HRESULT EnumEvents( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. mdTypeDef td, // [IN] TypeDef to scope the enumeration. mdEvent rEvents[], // [OUT] Put events here. ULONG cMax, // [IN] Max events to put. ULONG *pcEvents); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE GetEventProps( // S_OK, S_FALSE, or error. - mdEvent ev, // [IN] event token + HRESULT GetEventProps( // S_OK, S_FALSE, or error. + mdEvent ev, // [IN] event token mdTypeDef *pClass, // [OUT] typedef containing the event declarion. LPCWSTR szEvent, // [OUT] Event name ULONG cchEvent, // [IN] the count of wchar of szEvent @@ -441,20 +438,20 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG cMax, // [IN] size of rmdOtherMethod ULONG *pcOtherMethod); // [OUT] total number of other method of this event - HRESULT STDMETHODCALLTYPE EnumMethodSemantics( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdToken rEventProp[], // [OUT] Put Event/Property here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcEventProp); // [OUT] Put # put here. + HRESULT EnumMethodSemantics( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdMethodDef mb, // [IN] MethodDef to scope the enumeration. + mdToken rEventProp[], // [OUT] Put Event/Property here. + ULONG cMax, // [IN] Max properties to put. + ULONG *pcEventProp); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE GetMethodSemantics( // S_OK, S_FALSE, or error. - mdMethodDef mb, // [IN] method token - mdToken tkEventProp, // [IN] event/property token. - DWORD *pdwSemanticsFlags); // [OUT] the role flags for the - // method/propevent pair + HRESULT GetMethodSemantics( // S_OK, S_FALSE, or error. + mdMethodDef mb, // [IN] method token + mdToken tkEventProp, // [IN] event/property token. + DWORD *pdwSemanticsFlags); // [OUT] the role flags for the + // method/propevent pair - HRESULT STDMETHODCALLTYPE + HRESULT GetClassLayout(mdTypeDef td, // [IN] give typedef DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16 COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array @@ -462,97 +459,97 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG *pcFieldOffset, // [OUT] needed array size ULONG *pulClassSize); // [OUT] the size of the class - HRESULT STDMETHODCALLTYPE GetFieldMarshal( + HRESULT GetFieldMarshal( mdToken tk, // [IN] given a field's memberdef PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field ULONG *pcbNativeType); // [OUT] the count of bytes of *ppvNativeType - HRESULT STDMETHODCALLTYPE GetRVA( // S_OK or error. - mdToken tk, // Member for which to set offset - ULONG *pulCodeRVA, // The offset - DWORD *pdwImplFlags); // the implementation flags + HRESULT GetRVA( // S_OK or error. + mdToken tk, // Member for which to set offset + ULONG *pulCodeRVA, // The offset + DWORD *pdwImplFlags); // the implementation flags - HRESULT STDMETHODCALLTYPE GetPermissionSetProps( + HRESULT GetPermissionSetProps( mdPermission pm, // [IN] the permission token. DWORD *pdwAction, // [OUT] CorDeclSecurity. void const **ppvPermission, // [OUT] permission blob. ULONG *pcbPermission); // [OUT] count of bytes of pvPermission. - HRESULT STDMETHODCALLTYPE GetSigFromToken( // S_OK or error. - mdSignature mdSig, // [IN] Signature token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. - ULONG *pcbSig); // [OUT] return size of signature. + HRESULT GetSigFromToken( // S_OK or error. + mdSignature mdSig, // [IN] Signature token. + PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. + ULONG *pcbSig); // [OUT] return size of signature. - HRESULT STDMETHODCALLTYPE GetModuleRefProps( // S_OK or error. - mdModuleRef mur, // [IN] moduleref token. + HRESULT GetModuleRefProps( // S_OK or error. + mdModuleRef mur, // [IN] moduleref token. __out_ecount_part_opt(cchName, *pchName) LPWSTR szName, // [OUT] buffer to fill with the moduleref name. ULONG cchName, // [IN] size of szName in wide characters. ULONG *pchName); // [OUT] actual count of characters in the name. - HRESULT STDMETHODCALLTYPE EnumModuleRefs( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. - ULONG cmax, // [IN] max memberrefs to put. - ULONG *pcModuleRefs); // [OUT] put # put here. + HRESULT EnumModuleRefs( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. + ULONG cmax, // [IN] max memberrefs to put. + ULONG *pcModuleRefs); // [OUT] put # put here. - HRESULT STDMETHODCALLTYPE GetTypeSpecFromToken( // S_OK or error. - mdTypeSpec typespec, // [IN] TypeSpec token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature - ULONG *pcbSig); // [OUT] return size of signature. + HRESULT GetTypeSpecFromToken( // S_OK or error. + mdTypeSpec typespec, // [IN] TypeSpec token. + PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature + ULONG *pcbSig); // [OUT] return size of signature. - HRESULT STDMETHODCALLTYPE + HRESULT GetNameFromToken( // Not Recommended! May be removed! mdToken tk, // [IN] Token to get name from. Must have a name. MDUTF8CSTR *pszUtf8NamePtr); // [OUT] Return pointer to UTF8 name in heap. - HRESULT STDMETHODCALLTYPE EnumUnresolvedMethods( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken rMethods[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. + HRESULT EnumUnresolvedMethods( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken rMethods[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. - HRESULT STDMETHODCALLTYPE GetUserString( // S_OK or error. - mdString stk, // [IN] String token. + HRESULT GetUserString( // S_OK or error. + mdString stk, // [IN] String token. __out_ecount_part_opt(cchString, *pchString) LPWSTR szString, // [OUT] Copy of string. ULONG cchString, // [IN] Max chars of room in szString. ULONG *pchString); // [OUT] How many chars in actual string. - HRESULT STDMETHODCALLTYPE GetPinvokeMap( // S_OK or error. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. + HRESULT GetPinvokeMap( // S_OK or error. + mdToken tk, // [IN] FieldDef or MethodDef. + DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. __out_ecount_part_opt(cchImportName, *pchImportName) LPWSTR szImportName, // [OUT] Import name. ULONG cchImportName, // [IN] Size of the name buffer. ULONG *pchImportName, // [OUT] Actual number of characters stored. mdModuleRef *pmrImportDLL); // [OUT] ModuleRef token for the target DLL. - HRESULT STDMETHODCALLTYPE EnumSignatures( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdSignature rSignatures[], // [OUT] put signatures here. - ULONG cmax, // [IN] max signatures to put. - ULONG *pcSignatures); // [OUT] put # put here. - - HRESULT STDMETHODCALLTYPE EnumTypeSpecs( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. - ULONG cmax, // [IN] max TypeSpecs to put. - ULONG *pcTypeSpecs); // [OUT] put # put here. - - HRESULT STDMETHODCALLTYPE EnumUserStrings( // S_OK or error. - HCORENUM *phEnum, // [IN/OUT] pointer to the enum. - mdString rStrings[], // [OUT] put Strings here. - ULONG cmax, // [IN] max Strings to put. - ULONG *pcStrings); // [OUT] put # put here. - - HRESULT STDMETHODCALLTYPE GetParamForMethodIndex( // S_OK or error. - mdMethodDef md, // [IN] Method token. - ULONG ulParamSeq, // [IN] Parameter sequence. - mdParamDef *ppd); // [IN] Put Param token here. - - HRESULT STDMETHODCALLTYPE EnumCustomAttributes( // S_OK or error. - HCORENUM *phEnum, // [IN, OUT] COR enumerator. + HRESULT EnumSignatures( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdSignature rSignatures[], // [OUT] put signatures here. + ULONG cmax, // [IN] max signatures to put. + ULONG *pcSignatures); // [OUT] put # put here. + + HRESULT EnumTypeSpecs( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. + ULONG cmax, // [IN] max TypeSpecs to put. + ULONG *pcTypeSpecs); // [OUT] put # put here. + + HRESULT EnumUserStrings( // S_OK or error. + HCORENUM *phEnum, // [IN/OUT] pointer to the enum. + mdString rStrings[], // [OUT] put Strings here. + ULONG cmax, // [IN] max Strings to put. + ULONG *pcStrings); // [OUT] put # put here. + + HRESULT GetParamForMethodIndex( // S_OK or error. + mdMethodDef md, // [IN] Method token. + ULONG ulParamSeq, // [IN] Parameter sequence. + mdParamDef *ppd); // [IN] Put Param token here. + + HRESULT EnumCustomAttributes( // S_OK or error. + HCORENUM *phEnum, // [IN, OUT] COR enumerator. mdToken tk, // [IN] Token to scope the enumeration, 0 for all. mdToken tkType, // [IN] Type of interest, 0 for all. mdCustomAttribute @@ -561,19 +558,19 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG *pcCustomAttributes); // [OUT, OPTIONAL] Put count of token values // here. - HRESULT STDMETHODCALLTYPE GetCustomAttributeProps( // S_OK or error. - mdCustomAttribute cv, // [IN] CustomAttribute token. - mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. - mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. - void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. - ULONG *pcbSize); // [OUT, OPTIONAL] Put size of date here. + HRESULT GetCustomAttributeProps( // S_OK or error. + mdCustomAttribute cv, // [IN] CustomAttribute token. + mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. + mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. + void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. + ULONG *pcbSize); // [OUT, OPTIONAL] Put size of date here. - HRESULT STDMETHODCALLTYPE FindTypeRef( + HRESULT FindTypeRef( mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. LPCWSTR szName, // [IN] TypeRef Name. mdTypeRef *ptr); // [OUT] matching TypeRef. - HRESULT STDMETHODCALLTYPE GetMemberProps( + HRESULT GetMemberProps( mdToken mb, // The member for which to get props. mdTypeDef *pClass, // Put member's class here. __out_ecount_part_opt(cchMember, *pchMember) @@ -591,7 +588,7 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for // non-strings. - HRESULT STDMETHODCALLTYPE GetFieldProps( + HRESULT GetFieldProps( mdFieldDef mb, // The field for which to get props. mdTypeDef *pClass, // Put field's class here. __out_ecount_part_opt(cchField, *pchField) @@ -607,13 +604,13 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for // non-strings. - HRESULT STDMETHODCALLTYPE GetPropertyProps( // S_OK, S_FALSE, or error. - mdProperty prop, // [IN] property token - mdTypeDef *pClass, // [OUT] typedef containing the property declarion. - LPCWSTR szProperty, // [OUT] Property name - ULONG cchProperty, // [IN] the count of wchar of szProperty - ULONG *pchProperty, // [OUT] actual count of wchar for property name - DWORD *pdwPropFlags, // [OUT] property flags. + HRESULT GetPropertyProps( // S_OK, S_FALSE, or error. + mdProperty prop, // [IN] property token + mdTypeDef *pClass, // [OUT] typedef containing the property declarion. + LPCWSTR szProperty, // [OUT] Property name + ULONG cchProperty, // [IN] the count of wchar of szProperty + ULONG *pchProperty, // [OUT] actual count of wchar for property name + DWORD *pdwPropFlags, // [OUT] property flags. PCCOR_SIGNATURE *ppvSig, // [OUT] property type. pointing to meta data internal blob ULONG *pbSig, // [OUT] count of bytes in *ppvSig @@ -629,10 +626,10 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG * pcOtherMethod); // [OUT] total number of other method of this property - HRESULT STDMETHODCALLTYPE GetParamProps( // S_OK or error. - mdParamDef tk, // [IN]The Parameter. - mdMethodDef *pmd, // [OUT] Parent Method token. - ULONG *pulSequence, // [OUT] Parameter sequence. + HRESULT GetParamProps( // S_OK or error. + mdParamDef tk, // [IN]The Parameter. + mdMethodDef *pmd, // [OUT] Parent Method token. + ULONG *pulSequence, // [OUT] Parameter sequence. __out_ecount_part_opt(cchName, *pchName) LPWSTR szName, // [OUT] Put name here. ULONG cchName, // [OUT] Size of name buffer. @@ -644,27 +641,27 @@ class RegMeta : public IMetaDataImport2, public IMetaDataAssemblyImport { ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for // non-strings. - HRESULT STDMETHODCALLTYPE GetCustomAttributeByName( // S_OK or error. - mdToken tkObj, // [IN] Object with Custom Attribute. - LPCWSTR szName, // [IN] Name of desired Custom Attribute. - const void **ppData, // [OUT] Put pointer to data here. - ULONG *pcbData); // [OUT] Put size of data here. + HRESULT GetCustomAttributeByName( // S_OK or error. + mdToken tkObj, // [IN] Object with Custom Attribute. + LPCWSTR szName, // [IN] Name of desired Custom Attribute. + const void **ppData, // [OUT] Put pointer to data here. + ULONG *pcbData); // [OUT] Put size of data here. - BOOL STDMETHODCALLTYPE IsValidToken( // True or False. - mdToken tk); // [IN] Given token. + BOOL IsValidToken( // True or False. + mdToken tk); // [IN] Given token. - HRESULT STDMETHODCALLTYPE GetNestedClassProps( // S_OK or error. - mdTypeDef tdNestedClass, // [IN] NestedClass token. - mdTypeDef *ptdEnclosingClass); // [OUT] EnclosingClass token. + HRESULT GetNestedClassProps( // S_OK or error. + mdTypeDef tdNestedClass, // [IN] NestedClass token. + mdTypeDef *ptdEnclosingClass); // [OUT] EnclosingClass token. - HRESULT STDMETHODCALLTYPE GetNativeCallConvFromSig( // S_OK or error. - void const *pvSig, // [IN] Pointer to signature. - ULONG cbSig, // [IN] Count of signature bytes. + HRESULT GetNativeCallConvFromSig( // S_OK or error. + void const *pvSig, // [IN] Pointer to signature. + ULONG cbSig, // [IN] Count of signature bytes. ULONG *pCallConv); // [OUT] Put calling conv here (see CorPinvokemap). - HRESULT STDMETHODCALLTYPE IsGlobal( // S_OK or error. - mdToken pd, // [IN] Type, Field, or Method token. - int *pbGlobal); // [OUT] Put 1 if global, 0 otherwise. + HRESULT IsGlobal( // S_OK or error. + mdToken pd, // [IN] Type, Field, or Method token. + int *pbGlobal); // [OUT] Put 1 if global, 0 otherwise. }; #endif diff --git a/src/mono/dbi/cordb-thread.cpp b/src/mono/dbi/cordb-thread.cpp index f9225beafcc8ea..b514b61082e273 100644 --- a/src/mono/dbi/cordb-thread.cpp +++ b/src/mono/dbi/cordb-thread.cpp @@ -20,10 +20,31 @@ using namespace std; CordbThread::CordbThread(Connection *conn, CordbProcess *ppProcess, long thread_id) : CordbBaseMono(conn) { - this->ppProcess = ppProcess; - this->thread_id = thread_id; - stepper = NULL; - registerset = NULL; + this->m_pProcess = ppProcess; + this->m_threadId = thread_id; + m_pStepper = NULL; + m_pRegisterSet = NULL; + m_pCurrentFrame = NULL; + m_pBlockingObject = NULL; + ppProcess->AddThread(this); +} + +CordbThread::~CordbThread() { + if (m_pCurrentFrame) + m_pCurrentFrame->InternalRelease(); + if (m_pBlockingObject) + m_pBlockingObject->InternalRelease(); + if (m_pRegisterSet) + m_pRegisterSet->InternalRelease(); + if (m_pStepper) + m_pStepper->InternalRelease(); +} + +void CordbThread::SetRegisterSet(CordbRegisterSet *rs) { + if (m_pRegisterSet != NULL) + m_pRegisterSet->InternalRelease(); + m_pRegisterSet = rs; + m_pRegisterSet->InternalAddRef(); } HRESULT STDMETHODCALLTYPE CordbThread::HasUnhandledException(void) { @@ -33,65 +54,62 @@ HRESULT STDMETHODCALLTYPE CordbThread::HasUnhandledException(void) { } HRESULT STDMETHODCALLTYPE CordbThread::GetBlockingObjects( - /* [out] */ ICorDebugBlockingObjectEnum **ppBlockingObjectEnum) { + ICorDebugBlockingObjectEnum **ppBlockingObjectEnum) { LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetBlockingObjects - IMPLEMENTED\n")); - CordbBlockingObjectEnum *blockingObject = new CordbBlockingObjectEnum(conn); - *ppBlockingObjectEnum = - static_cast(blockingObject); - + if (m_pBlockingObject == NULL) { + m_pBlockingObject = new CordbBlockingObjectEnum(conn); + m_pBlockingObject->InternalAddRef(); + } + m_pBlockingObject->QueryInterface(IID_ICorDebugBlockingObjectEnum, + (void **)ppBlockingObjectEnum); return S_OK; } HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentCustomDebuggerNotification( - /* [out] */ ICorDebugValue **ppNotificationObject) { + ICorDebugValue **ppNotificationObject) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetCurrentCustomDebuggerNotification - NOT " "IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::CreateStackWalk( - /* [out] */ ICorDebugStackWalk **ppStackWalk) { +HRESULT STDMETHODCALLTYPE +CordbThread::CreateStackWalk(ICorDebugStackWalk **ppStackWalk) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - CreateStackWalk - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::GetActiveInternalFrames( - /* [in] */ ULONG32 cInternalFrames, - /* [out] */ ULONG32 *pcInternalFrames, - /* [length_is][size_is][out][in] */ + ULONG32 cInternalFrames, ULONG32 *pcInternalFrames, ICorDebugInternalFrame2 *ppInternalFrames[]) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetActiveInternalFrames - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFunctions( - /* [in] */ ULONG32 cFunctions, - /* [out] */ ULONG32 *pcFunctions, - /* [length_is][size_is][out][in] */ COR_ACTIVE_FUNCTION pFunctions[]) { +HRESULT STDMETHODCALLTYPE +CordbThread::GetActiveFunctions(ULONG32 cFunctions, ULONG32 *pcFunctions, + COR_ACTIVE_FUNCTION pFunctions[]) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetActiveFunctions - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetConnectionID( - /* [out] */ CONNID *pdwConnectionId) { +HRESULT STDMETHODCALLTYPE +CordbThread::GetConnectionID(CONNID *pdwConnectionId) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetConnectionID - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetTaskID( - /* [out] */ TASKID *pTaskId) { +HRESULT STDMETHODCALLTYPE CordbThread::GetTaskID(TASKID *pTaskId) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetTaskID - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetVolatileOSThreadID( - /* [out] */ DWORD *pdwTid) { +HRESULT STDMETHODCALLTYPE CordbThread::GetVolatileOSThreadID(DWORD *pdwTid) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetVolatileOSThreadID - NOT IMPLEMENTED\n")); return E_NOTIMPL; @@ -99,57 +117,54 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetVolatileOSThreadID( HRESULT STDMETHODCALLTYPE CordbThread::InterceptCurrentException( - /* [in] */ ICorDebugFrame *pFrame) { + ICorDebugFrame *pFrame) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - InterceptCurrentException - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetProcess( - /* [out] */ ICorDebugProcess **ppProcess) { +HRESULT STDMETHODCALLTYPE +CordbThread::GetProcess(ICorDebugProcess **ppProcess) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetProcess - NOT IMPLEMENTED\n")); - return E_NOTIMPL; + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetID( - /* [out] */ DWORD *pdwThreadId) { - *pdwThreadId = thread_id; +HRESULT STDMETHODCALLTYPE CordbThread::GetID(DWORD *pdwThreadId) { + *pdwThreadId = GetThreadId(); LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetID - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetHandle( - /* [out] */ HTHREAD *phThreadHandle) { +HRESULT STDMETHODCALLTYPE CordbThread::GetHandle(HTHREAD *phThreadHandle) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetHandle - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetAppDomain( - /* [out] */ ICorDebugAppDomain **ppAppDomain) { - *ppAppDomain = - static_cast(this->conn->pCorDebugAppDomain); +HRESULT STDMETHODCALLTYPE +CordbThread::GetAppDomain(ICorDebugAppDomain **ppAppDomain) { + conn->GetCurrentAppDomain()->QueryInterface(IID_ICorDebugAppDomain, + (void **)ppAppDomain); LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetAppDomain - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::SetDebugState( - /* [in] */ CorDebugThreadState state) { +HRESULT STDMETHODCALLTYPE +CordbThread::SetDebugState(CorDebugThreadState state) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - SetDebugState - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetDebugState( - /* [out] */ CorDebugThreadState *pState) { +HRESULT STDMETHODCALLTYPE +CordbThread::GetDebugState(CorDebugThreadState *pState) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetDebugState - NOT IMPLEMENTED\n")); *pState = THREAD_RUN; return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetUserState( - /* [out] */ CorDebugUserState *pState) { +HRESULT STDMETHODCALLTYPE CordbThread::GetUserState(CorDebugUserState *pState) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetUserState - NOT IMPLEMENTED\n")); @@ -157,8 +172,8 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetUserState( return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentException( - /* [out] */ ICorDebugValue **ppExceptionObject) { +HRESULT STDMETHODCALLTYPE +CordbThread::GetCurrentException(ICorDebugValue **ppExceptionObject) { LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetCurrentException - IMPLEMENTED\n")); @@ -171,96 +186,94 @@ HRESULT STDMETHODCALLTYPE CordbThread::ClearCurrentException(void) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::CreateStepper( - /* [out] */ ICorDebugStepper **ppStepper) { - CordbStepper *stepper = new CordbStepper(conn, this); - this->stepper = stepper; - *ppStepper = static_cast(stepper); +HRESULT STDMETHODCALLTYPE +CordbThread::CreateStepper(ICorDebugStepper **ppStepper) { + if (m_pStepper) + m_pStepper->InternalRelease(); + m_pStepper = new CordbStepper(conn, this); + m_pStepper->InternalAddRef(); + m_pStepper->QueryInterface(IID_ICorDebugStepper, (void **)ppStepper); LOG((LF_CORDB, LL_INFO1000000, "CordbThread - CreateStepper - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::EnumerateChains( - /* [out] */ ICorDebugChainEnum **ppChains) { +HRESULT STDMETHODCALLTYPE +CordbThread::EnumerateChains(ICorDebugChainEnum **ppChains) { CordbChainEnum *pChains = new CordbChainEnum(conn, this); + pChains->AddRef(); *ppChains = static_cast(pChains); LOG((LF_CORDB, LL_INFO1000000, "CordbThread - EnumerateChains - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetActiveChain( - /* [out] */ ICorDebugChain **ppChain) { +HRESULT STDMETHODCALLTYPE +CordbThread::GetActiveChain(ICorDebugChain **ppChain) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetActiveChain - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFrame( - /* [out] */ ICorDebugFrame **ppFrame) { +HRESULT STDMETHODCALLTYPE +CordbThread::GetActiveFrame(ICorDebugFrame **ppFrame) { LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetActiveFrame - IMPLEMENTED\n")); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, thread_id); + m_dbgprot_buffer_add_id(&localbuf, GetThreadId()); m_dbgprot_buffer_add_int(&localbuf, 0); m_dbgprot_buffer_add_int(&localbuf, -1); - int cmdId = this->conn->send_event( + int cmdId = this->conn->SendEvent( MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int nframes = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + int nframes = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); if (nframes > 0) { - int frameid = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int methodId = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int il_offset = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int flags = - m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); - CordbNativeFrame *frame = + int frameid = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + int methodId = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int il_offset = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + int flags = m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); + if (m_pCurrentFrame) + m_pCurrentFrame->InternalRelease(); + m_pCurrentFrame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, this); - *ppFrame = static_cast(frame); + m_pCurrentFrame->InternalAddRef(); + m_pCurrentFrame->QueryInterface(IID_ICorDebugFrame, (void **)ppFrame); } - registerset = new CordbRegisteSet(conn, 0, 0); + SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetRegisterSet( - /* [out] */ ICorDebugRegisterSet **ppRegisters) { +HRESULT STDMETHODCALLTYPE +CordbThread::GetRegisterSet(ICorDebugRegisterSet **ppRegisters) { LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetRegisterSet - IMPLEMENTED\n")); - if (!registerset) - registerset = new CordbRegisteSet(conn, 0, 0); - - *ppRegisters = static_cast(registerset); + if (!m_pRegisterSet) + SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); + m_pRegisterSet->AddRef(); + *ppRegisters = static_cast(m_pRegisterSet); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::CreateEval( - /* [out] */ ICorDebugEval **ppEval) { +HRESULT STDMETHODCALLTYPE CordbThread::CreateEval(ICorDebugEval **ppEval) { LOG((LF_CORDB, LL_INFO1000000, "CordbThread - CreateEval - IMPLEMENTED\n")); CordbEval *eval = new CordbEval(this->conn, this); eval->QueryInterface(IID_ICorDebugEval, (void **)ppEval); return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetObject( - /* [out] */ ICorDebugValue **ppObject) { +HRESULT STDMETHODCALLTYPE CordbThread::GetObject(ICorDebugValue **ppObject) { LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetObject - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::QueryInterface( - /* [in] */ REFIID id, - /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { + REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { if (id == IID_ICorDebugThread) { *ppInterface = static_cast(this); } else if (id == IID_ICorDebugThread2) { @@ -276,9 +289,6 @@ HRESULT STDMETHODCALLTYPE CordbThread::QueryInterface( *ppInterface = NULL; return E_NOINTERFACE; } + AddRef(); return S_OK; } - -ULONG STDMETHODCALLTYPE CordbThread::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbThread::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-thread.h b/src/mono/dbi/cordb-thread.h index 0273549691edfe..fe1c7103a1195f 100644 --- a/src/mono/dbi/cordb-thread.h +++ b/src/mono/dbi/cordb-thread.h @@ -14,64 +14,68 @@ class CordbThread : public CordbBaseMono, public ICorDebugThread2, public ICorDebugThread3, public ICorDebugThread4 { + long m_threadId; + CordbProcess *m_pProcess; + CordbStepper *m_pStepper; + CordbRegisterSet *m_pRegisterSet; + CordbNativeFrame *m_pCurrentFrame; + CordbBlockingObjectEnum *m_pBlockingObject; + public: - long thread_id; - CordbProcess *ppProcess; - CordbStepper *stepper; - CordbRegisteSet *registerset; CordbThread(Connection *conn, CordbProcess *ppProcess, long thread_id); - HRESULT STDMETHODCALLTYPE HasUnhandledException(void); - HRESULT STDMETHODCALLTYPE GetBlockingObjects( - /* [out] */ ICorDebugBlockingObjectEnum **ppBlockingObjectEnum); - HRESULT STDMETHODCALLTYPE GetCurrentCustomDebuggerNotification( - /* [out] */ ICorDebugValue **ppNotificationObject); - HRESULT STDMETHODCALLTYPE - CreateStackWalk(/* [out] */ ICorDebugStackWalk **ppStackWalk); - HRESULT STDMETHODCALLTYPE - GetActiveInternalFrames(/* [in] */ ULONG32 cInternalFrames, /* [out] */ - ULONG32 *pcInternalFrames, - /* [length_is][size_is][out][in] */ + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbThread"; } + ~CordbThread(); + void SetRegisterSet(CordbRegisterSet *rs); + HRESULT HasUnhandledException(void); + HRESULT + GetBlockingObjects(ICorDebugBlockingObjectEnum **ppBlockingObjectEnum); + HRESULT + GetCurrentCustomDebuggerNotification(ICorDebugValue **ppNotificationObject); + HRESULT + CreateStackWalk(ICorDebugStackWalk **ppStackWalk); + HRESULT + GetActiveInternalFrames(ULONG32 cInternalFrames, ULONG32 *pcInternalFrames, ICorDebugInternalFrame2 *ppInternalFrames[]); - HRESULT STDMETHODCALLTYPE GetActiveFunctions( - /* [in] */ ULONG32 cFunctions, /* [out] */ ULONG32 *pcFunctions, - /* [length_is][size_is][out][in] */ - COR_ACTIVE_FUNCTION pFunctions[]); - HRESULT STDMETHODCALLTYPE - GetConnectionID(/* [out] */ CONNID *pdwConnectionId); - HRESULT STDMETHODCALLTYPE GetTaskID(/* [out] */ TASKID *pTaskId); - HRESULT STDMETHODCALLTYPE GetVolatileOSThreadID(/* [out] */ DWORD *pdwTid); - HRESULT STDMETHODCALLTYPE - InterceptCurrentException(/* [in] */ ICorDebugFrame *pFrame); - HRESULT STDMETHODCALLTYPE - GetProcess(/* [out] */ ICorDebugProcess **ppProcess); - HRESULT STDMETHODCALLTYPE GetID(/* [out] */ DWORD *pdwThreadId); - HRESULT STDMETHODCALLTYPE GetHandle(/* [out] */ HTHREAD *phThreadHandle); - HRESULT STDMETHODCALLTYPE - GetAppDomain(/* [out] */ ICorDebugAppDomain **ppAppDomain); - HRESULT STDMETHODCALLTYPE SetDebugState(/* [in] */ CorDebugThreadState state); - HRESULT STDMETHODCALLTYPE - GetDebugState(/* [out] */ CorDebugThreadState *pState); - HRESULT STDMETHODCALLTYPE GetUserState(/* [out] */ CorDebugUserState *pState); - HRESULT STDMETHODCALLTYPE - GetCurrentException(/* [out] */ ICorDebugValue **ppExceptionObject); - HRESULT STDMETHODCALLTYPE ClearCurrentException(void); - HRESULT STDMETHODCALLTYPE - CreateStepper(/* [out] */ ICorDebugStepper **ppStepper); - HRESULT STDMETHODCALLTYPE - EnumerateChains(/* [out] */ ICorDebugChainEnum **ppChains); - HRESULT STDMETHODCALLTYPE - GetActiveChain(/* [out] */ ICorDebugChain **ppChain); - HRESULT STDMETHODCALLTYPE - GetActiveFrame(/* [out] */ ICorDebugFrame **ppFrame); - HRESULT STDMETHODCALLTYPE - GetRegisterSet(/* [out] */ ICorDebugRegisterSet **ppRegisters); - HRESULT STDMETHODCALLTYPE CreateEval(/* [out] */ ICorDebugEval **ppEval); - HRESULT STDMETHODCALLTYPE GetObject(/* [out] */ ICorDebugValue **ppObject); - HRESULT STDMETHODCALLTYPE - QueryInterface(/* [in] */ REFIID id, /* [iid_is][out] */ - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); + HRESULT GetActiveFunctions(ULONG32 cFunctions, ULONG32 *pcFunctions, + COR_ACTIVE_FUNCTION pFunctions[]); + HRESULT + GetConnectionID(CONNID *pdwConnectionId); + HRESULT GetTaskID(TASKID *pTaskId); + HRESULT GetVolatileOSThreadID(DWORD *pdwTid); + HRESULT + InterceptCurrentException(ICorDebugFrame *pFrame); + HRESULT + GetProcess(ICorDebugProcess **ppProcess); + HRESULT GetID(DWORD *pdwThreadId); + HRESULT GetHandle(HTHREAD *phThreadHandle); + HRESULT + GetAppDomain(ICorDebugAppDomain **ppAppDomain); + HRESULT SetDebugState(CorDebugThreadState state); + HRESULT + GetDebugState(CorDebugThreadState *pState); + HRESULT GetUserState(CorDebugUserState *pState); + HRESULT + GetCurrentException(ICorDebugValue **ppExceptionObject); + HRESULT ClearCurrentException(void); + HRESULT + CreateStepper(ICorDebugStepper **ppStepper); + HRESULT + EnumerateChains(ICorDebugChainEnum **ppChains); + HRESULT + GetActiveChain(ICorDebugChain **ppChain); + HRESULT + GetActiveFrame(ICorDebugFrame **ppFrame); + HRESULT + GetRegisterSet(ICorDebugRegisterSet **ppRegisters); + HRESULT CreateEval(ICorDebugEval **ppEval); + HRESULT GetObject(ICorDebugValue **ppObject); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + + long GetThreadId() const { return m_threadId; } + CordbStepper *GetStepper() const { return m_pStepper; } }; #endif diff --git a/src/mono/dbi/cordb-type.cpp b/src/mono/dbi/cordb-type.cpp index c6bfc05d06b2e9..9dd3ba1c6a0c1a 100644 --- a/src/mono/dbi/cordb-type.cpp +++ b/src/mono/dbi/cordb-type.cpp @@ -14,31 +14,48 @@ using namespace std; CordbType::CordbType(CorElementType type, Connection *conn, CordbClass *klass, CordbType *typeParameter) : CordbBaseMono(conn) { - this->klass = klass; - this->type = type; - this->typeParameter = typeParameter; + this->m_pClass = klass; + this->m_type = type; + this->m_pTypeParameter = typeParameter; + m_pTypeEnum = NULL; + if (typeParameter) + typeParameter->InternalAddRef(); + if (klass) + klass->InternalAddRef(); +} + +CordbType::~CordbType() { + if (m_pClass) + m_pClass->InternalRelease(); + if (m_pTypeParameter) + m_pTypeParameter->InternalRelease(); + if (m_pTypeEnum) + m_pTypeEnum->InternalRelease(); } HRESULT STDMETHODCALLTYPE CordbType::GetType(CorElementType *ty) { - *ty = type; + *ty = m_type; LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetType - IMPLEMENTED\n")); return S_OK; } HRESULT STDMETHODCALLTYPE CordbType::GetClass(ICorDebugClass **ppClass) { LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetClass - IMPLEMENTED\n")); - if (!klass) { + if (!m_pClass) { LOG((LF_CORDB, LL_INFO100000, "CordbType - GetClass - NO CLASS\n")); return S_OK; } - *ppClass = static_cast(klass); + m_pClass->QueryInterface(IID_ICorDebugClass, (void **)ppClass); return S_OK; } HRESULT STDMETHODCALLTYPE CordbType::EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum) { - CordbTypeEnum *tp = new CordbTypeEnum(conn, typeParameter); - *ppTyParEnum = static_cast(tp); + if (m_pTypeEnum == NULL) { + m_pTypeEnum = new CordbTypeEnum(conn, m_pTypeParameter); + m_pTypeEnum->InternalAddRef(); + } + m_pTypeEnum->QueryInterface(IID_ICorDebugTypeEnum, (void **)ppTyParEnum); LOG((LF_CORDB, LL_INFO1000000, "CordbType - EnumerateTypeParameters - IMPLEMENTED\n")); @@ -49,7 +66,7 @@ HRESULT STDMETHODCALLTYPE CordbType::GetFirstTypeParameter(ICorDebugType **value) { LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetFirstTypeParameter - IMPLEMENTED\n")); - *value = static_cast(typeParameter); + m_pTypeParameter->QueryInterface(IID_ICorDebugType, (void **)value); return S_OK; } @@ -82,14 +99,10 @@ HRESULT STDMETHODCALLTYPE CordbType::QueryInterface(REFIID id, *pInterface = NULL; return E_NOINTERFACE; } - + AddRef(); return S_OK; } -ULONG STDMETHODCALLTYPE CordbType::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbType::Release(void) { return 0; } - HRESULT STDMETHODCALLTYPE CordbType::GetTypeID(COR_TYPEID *id) { LOG((LF_CORDB, LL_INFO100000, "CordbType - GetTypeID - NOT IMPLEMENTED\n")); return E_NOTIMPL; @@ -97,15 +110,22 @@ HRESULT STDMETHODCALLTYPE CordbType::GetTypeID(COR_TYPEID *id) { CordbTypeEnum::CordbTypeEnum(Connection *conn, CordbType *type) : CordbBaseMono(conn) { - this->type = type; + this->m_pType = type; + if (type) + type->InternalAddRef(); +} + +CordbTypeEnum::~CordbTypeEnum() { + if (m_pType) + m_pType->InternalRelease(); } HRESULT STDMETHODCALLTYPE CordbTypeEnum::Next(ULONG celt, ICorDebugType *values[], ULONG *pceltFetched) { *pceltFetched = celt; - if (type != NULL) - values[0] = type; + if (m_pType != NULL) + m_pType->QueryInterface(IID_ICorDebugType, (void **)&values[0]); LOG((LF_CORDB, LL_INFO1000000, "CordbTypeEnum - Next - IMPLEMENTED\n")); return S_OK; } @@ -126,7 +146,7 @@ HRESULT STDMETHODCALLTYPE CordbTypeEnum::Clone(ICorDebugEnum **ppEnum) { } HRESULT STDMETHODCALLTYPE CordbTypeEnum::GetCount(ULONG *pcelt) { - if (type != NULL) + if (m_pType != NULL) *pcelt = 1; else *pcelt = 0; @@ -147,10 +167,6 @@ HRESULT STDMETHODCALLTYPE CordbTypeEnum::QueryInterface(REFIID id, *pInterface = NULL; return E_NOINTERFACE; } - + AddRef(); return S_OK; } - -ULONG STDMETHODCALLTYPE CordbTypeEnum::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbTypeEnum::Release(void) { return 0; } diff --git a/src/mono/dbi/cordb-type.h b/src/mono/dbi/cordb-type.h index 15ce0232749d50..4030cc626cd6d0 100644 --- a/src/mono/dbi/cordb-type.h +++ b/src/mono/dbi/cordb-type.h @@ -12,43 +12,48 @@ class CordbType : public CordbBaseMono, public ICorDebugType, public ICorDebugType2 { - CorElementType type; - CordbClass *klass; - CordbType *typeParameter; + CorElementType m_type; + CordbClass *m_pClass; + CordbType *m_pTypeParameter; + CordbTypeEnum *m_pTypeEnum; public: CordbType(CorElementType type, Connection *conn, CordbClass *klass = NULL, CordbType *typeParameter = NULL); - HRESULT STDMETHODCALLTYPE GetType(CorElementType *ty); - HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass **ppClass); - HRESULT STDMETHODCALLTYPE + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbType"; } + ~CordbType(); + HRESULT GetType(CorElementType *ty); + HRESULT GetClass(ICorDebugClass **ppClass); + HRESULT EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum); - HRESULT STDMETHODCALLTYPE GetFirstTypeParameter(ICorDebugType **value); - HRESULT STDMETHODCALLTYPE GetBase(ICorDebugType **pBase); - HRESULT STDMETHODCALLTYPE GetStaticFieldValue(mdFieldDef fieldDef, - ICorDebugFrame *pFrame, - ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetRank(ULONG32 *pnRank); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE GetTypeID(COR_TYPEID *id); + HRESULT GetFirstTypeParameter(ICorDebugType **value); + HRESULT GetBase(ICorDebugType **pBase); + HRESULT GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame *pFrame, + ICorDebugValue **ppValue); + HRESULT GetRank(ULONG32 *pnRank); + HRESULT QueryInterface(REFIID riid, void **ppvObject); + + HRESULT GetTypeID(COR_TYPEID *id); }; class CordbTypeEnum : public CordbBaseMono, public ICorDebugTypeEnum { - CordbType *type; + CordbType *m_pType; public: CordbTypeEnum(Connection *conn, CordbType *type); - virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugType *values[], - ULONG *pceltFetched); - HRESULT STDMETHODCALLTYPE Skip(ULONG celt); - HRESULT STDMETHODCALLTYPE Reset(void); - HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum **ppEnum); - HRESULT STDMETHODCALLTYPE GetCount(ULONG *pcelt); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbTypeEnum"; } + ~CordbTypeEnum(); + virtual HRESULT Next(ULONG celt, ICorDebugType *values[], + ULONG *pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum **ppEnum); + HRESULT GetCount(ULONG *pcelt); + HRESULT QueryInterface(REFIID riid, void **ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index 460150d8678a00..999a7fdcee1b8d 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -15,24 +15,30 @@ using namespace std; CordbValue::CordbValue(Connection *conn, CorElementType type, CordbContent value, int size) : CordbBaseMono(conn) { - this->type = type; - this->value = value; - this->size = size; + this->m_type = type; + this->m_value = value; + this->m_size = size; this->conn = conn; + m_pType = NULL; +} + +CordbValue::~CordbValue() { + if (m_pType) + m_pType->InternalRelease(); } HRESULT STDMETHODCALLTYPE CordbValue::GetType(CorElementType *pType) { - *pType = type; + *pType = m_type; return S_OK; } HRESULT STDMETHODCALLTYPE CordbValue::GetSize(ULONG32 *pSize) { - *pSize = size; + *pSize = m_size; return S_OK; } HRESULT STDMETHODCALLTYPE CordbValue::GetAddress(CORDB_ADDRESS *pAddress) { - *pAddress = (CORDB_ADDRESS)&value; + *pAddress = (CORDB_ADDRESS)&m_value; LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetAddress - IMPLEMENTED\n")); return S_OK; } @@ -62,17 +68,17 @@ HRESULT STDMETHODCALLTYPE CordbValue::QueryInterface(REFIID id, *pInterface = NULL; return E_NOINTERFACE; } + AddRef(); return S_OK; } -ULONG STDMETHODCALLTYPE CordbValue::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbValue::Release(void) { return 0; } - HRESULT STDMETHODCALLTYPE CordbValue::GetExactType(ICorDebugType **ppType) { LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetExactType - IMPLEMENTED\n")); - CordbType *tp = new CordbType(type, conn); - *ppType = static_cast(tp); + if (m_pType == NULL) { + m_pType = new CordbType(m_type, conn); + m_pType->InternalAddRef(); + } + m_pType->QueryInterface(IID_ICorDebugType, (void **)ppType); return S_OK; } @@ -83,12 +89,12 @@ HRESULT STDMETHODCALLTYPE CordbValue::GetSize64(ULONG64 *pSize) { HRESULT STDMETHODCALLTYPE CordbValue::GetValue(void *pTo) { LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetValue - IMPLEMENTED\n")); - memcpy(pTo, &value, size); + memcpy(pTo, &m_value, m_size); return S_OK; } HRESULT STDMETHODCALLTYPE CordbValue::SetValue(void *pFrom) { - memcpy(&value, pFrom, size); + memcpy(&m_value, pFrom, m_size); LOG((LF_CORDB, LL_INFO1000000, "CordbValue - SetValue - IMPLEMENTED\n")); return S_OK; } @@ -96,7 +102,7 @@ HRESULT STDMETHODCALLTYPE CordbValue::SetValue(void *pFrom) { HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetType(CorElementType *pType) { LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetType - IMPLEMENTED\n")); - *pType = type; + *pType = m_type; return S_OK; } @@ -108,7 +114,7 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize(ULONG32 *pSize) { HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetAddress(CORDB_ADDRESS *pAddress) { - *pAddress = (CORDB_ADDRESS)&object_id; + *pAddress = (CORDB_ADDRESS)&m_debuggerId; LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetAddress - IMPLEMENTED\n")); return S_OK; @@ -139,114 +145,117 @@ CordbReferenceValue::QueryInterface(REFIID id, void **pInterface) { *pInterface = NULL; return E_NOINTERFACE; } + AddRef(); return S_OK; } -ULONG STDMETHODCALLTYPE CordbReferenceValue::AddRef(void) { return 1; } - -ULONG STDMETHODCALLTYPE CordbReferenceValue::Release(void) { return 1; } - HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType **ppType) { LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetExactType - IMPLEMENTED\n")); - if (cordbtype) { - *ppType = static_cast(cordbtype); + if (m_pCordbType) { + m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); return S_OK; } - if (klass != NULL) { - cordbtype = new CordbType(type, conn, klass); - *ppType = static_cast(cordbtype); + if (m_pClass != NULL) { + m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); return S_OK; } - if (type == ELEMENT_TYPE_CLASS && object_id != -1) { + if (m_type == ELEMENT_TYPE_CLASS && m_debuggerId != -1) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_OBJECT_REF, - MDBGPROT_CMD_OBJECT_REF_GET_TYPE, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, + MDBGPROT_CMD_OBJECT_REF_GET_TYPE, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int type_id = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + int type_id = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, type_id); - cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, - &localbuf); + cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, + &localbuf); m_dbgprot_buffer_free(&localbuf); - bAnswer = conn->get_answer(cmdId); + bAnswer = conn->GetAnswer(cmdId); char *namespace_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); char *class_name_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); char *class_fullname_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); int assembly_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int module_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - type_id = m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id2 = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int token = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - klass = new CordbClass(conn, token, assembly_id); - cordbtype = new CordbType(type, conn, klass); - *ppType = static_cast(cordbtype); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int module_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + type_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int type_id2 = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int token = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_pClass = new CordbClass(conn, token, assembly_id); + m_pClass->InternalAddRef(); + m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); return S_OK; } - if (type == ELEMENT_TYPE_SZARRAY && object_id != -1) { - CordbClass *klass = NULL; + if (m_type == ELEMENT_TYPE_SZARRAY && m_debuggerId != -1) { + m_pClass = NULL; MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, - MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, + MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int type_id = - m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + int type_id = m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); + int rank = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); if (type_id == ELEMENT_TYPE_CLASS) { int klass_id = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, klass_id); - cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, - MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, + &localbuf); m_dbgprot_buffer_free(&localbuf); - bAnswer = conn->get_answer(cmdId); + bAnswer = conn->GetAnswer(cmdId); char *namespace_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); char *class_name_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); char *class_fullname_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); int assembly_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); int module_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id3 = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id2 = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int token = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - klass = new CordbClass(conn, token, module_id); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int type_id3 = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int type_id2 = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int token = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_pClass = new CordbClass(conn, token, module_id); + m_pClass->InternalAddRef(); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); } - cordbtype = new CordbType(type, conn, NULL, - new CordbType((CorElementType)type_id, conn, klass)); - *ppType = static_cast(cordbtype); + m_pCordbType = + new CordbType(m_type, conn, NULL, + new CordbType((CorElementType)type_id, conn, m_pClass)); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); return S_OK; } - CordbType *tp = new CordbType(type, conn); - *ppType = static_cast(tp); + m_pCordbType = new CordbType(m_type, conn); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); return S_OK; } @@ -268,44 +277,41 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(void *pFrom) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::IsNull(/* [out] */ BOOL *pbNull) { - if (object_id == -1) +HRESULT STDMETHODCALLTYPE CordbReferenceValue::IsNull(BOOL *pbNull) { + if (m_debuggerId == -1) *pbNull = true; LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - IsNull - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::GetValue(/* [out] */ CORDB_ADDRESS *pValue) { - if (object_id == -1) +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetValue(CORDB_ADDRESS *pValue) { + if (m_debuggerId == -1) *pValue = NULL; else - *pValue = (CORDB_ADDRESS)&object_id; + *pValue = (CORDB_ADDRESS)&m_debuggerId; LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetValue - IMPLEMENTED\n")); return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::SetValue(/* [in] */ CORDB_ADDRESS value) { +HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(CORDB_ADDRESS value) { LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - SetValue CORDB_ADDRESS - NOT IMPLEMENTED\n")); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE -CordbReferenceValue::Dereference(/* [out] */ ICorDebugValue **ppValue) { - if (object_id == -1) +CordbReferenceValue::Dereference(ICorDebugValue **ppValue) { + if (m_debuggerId == -1) return CORDBG_E_BAD_REFERENCE_VALUE; - if (type == ELEMENT_TYPE_SZARRAY || type == ELEMENT_TYPE_ARRAY) { + if (m_type == ELEMENT_TYPE_SZARRAY || m_type == ELEMENT_TYPE_ARRAY) { CordbArrayValue *objectValue = - new CordbArrayValue(conn, cordbtype, object_id, klass); + new CordbArrayValue(conn, m_pCordbType, m_debuggerId, m_pClass); objectValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); } else { CordbObjectValue *objectValue = - new CordbObjectValue(conn, type, object_id, klass); + new CordbObjectValue(conn, m_type, m_debuggerId, m_pClass); objectValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); } LOG((LF_CORDB, LL_INFO1000000, @@ -314,7 +320,7 @@ CordbReferenceValue::Dereference(/* [out] */ ICorDebugValue **ppValue) { } HRESULT STDMETHODCALLTYPE -CordbReferenceValue::DereferenceStrong(/* [out] */ ICorDebugValue **ppValue) { +CordbReferenceValue::DereferenceStrong(ICorDebugValue **ppValue) { LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - DereferenceStrong - NOT IMPLEMENTED\n")); return E_NOTIMPL; @@ -322,26 +328,47 @@ CordbReferenceValue::DereferenceStrong(/* [out] */ ICorDebugValue **ppValue) { CordbReferenceValue::CordbReferenceValue(Connection *conn, CorElementType type, int object_id, CordbClass *klass, - CordbType *cordbtype) + CordbType *cordbType) : CordbBaseMono(conn) { - this->type = type; - this->object_id = object_id; + this->m_type = type; + this->m_debuggerId = object_id; this->conn = conn; - this->klass = klass; - this->cordbtype = cordbtype; + this->m_pClass = klass; + this->m_pCordbType = cordbType; + if (cordbType) + cordbType->InternalAddRef(); + if (klass) + klass->InternalAddRef(); +} + +CordbReferenceValue::~CordbReferenceValue() { + if (m_pCordbType) + m_pCordbType->InternalRelease(); + if (m_pClass) + m_pClass->InternalRelease(); } CordbObjectValue::CordbObjectValue(Connection *conn, CorElementType type, int object_id, CordbClass *klass) : CordbBaseMono(conn) { - this->type = type; - this->object_id = object_id; - this->klass = klass; + this->m_type = type; + this->m_debuggerId = object_id; + this->m_pClass = klass; + if (klass) + klass->InternalAddRef(); + m_pCordbType = NULL; +} + +CordbObjectValue::~CordbObjectValue() { + if (m_pClass) + m_pClass->InternalRelease(); + if (m_pCordbType) + m_pCordbType->InternalRelease(); } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetType(CorElementType *pType) { LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetType - IMPLEMENTED\n")); - *pType = type; + *pType = m_type; return S_OK; } @@ -354,7 +381,7 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize(ULONG32 *pSize) { HRESULT STDMETHODCALLTYPE CordbObjectValue::GetAddress(CORDB_ADDRESS *pAddress) { - *pAddress = (CORDB_ADDRESS)&object_id; + *pAddress = (CORDB_ADDRESS)&m_debuggerId; LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetAddress - IMPLEMENTED\n")); return S_OK; @@ -367,16 +394,15 @@ CordbObjectValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { return E_NOTIMPL; } -ULONG STDMETHODCALLTYPE CordbObjectValue::AddRef(void) { return 1; } - -ULONG STDMETHODCALLTYPE CordbObjectValue::Release(void) { return 1; } - HRESULT STDMETHODCALLTYPE CordbObjectValue::GetExactType(ICorDebugType **ppType) { LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetExactType - IMPLEMENTED\n")); - CordbType *tp = new CordbType(type, conn, klass); - *ppType = static_cast(tp); + if (m_pCordbType == NULL) { + m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType->InternalAddRef(); + } + m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); return S_OK; } @@ -407,19 +433,19 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethodAndType( } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32 *pcchString) { - if (object_id == -1) + if (m_debuggerId == -1) return S_OK; - if (type == ELEMENT_TYPE_STRING) { + if (m_type == ELEMENT_TYPE_STRING) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_STRING_REF, - MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, + MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - *pcchString = (ULONG32) - m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + *pcchString = + (ULONG32)m_dbgprot_decode_long(bAnswer->p, &bAnswer->p, bAnswer->end); return S_OK; } return E_NOTIMPL; @@ -428,37 +454,33 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32 *pcchString) { HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, ULONG32 *pcchString, WCHAR szString[]) { - if (object_id == -1) + if (m_debuggerId == -1) return S_OK; - if (type == ELEMENT_TYPE_STRING) { + if (m_type == ELEMENT_TYPE_STRING) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_STRING_REF, - MDBGPROT_CMD_STRING_REF_GET_VALUE, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, + MDBGPROT_CMD_STRING_REF_GET_VALUE, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); *pcchString = cchString; int use_utf16 = - m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); if (use_utf16) { LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n")); } else { char *value = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetString - IMPLEMENTED\n")); if (cchString >= strlen(value)) { - MultiByteToWideChar(CP_UTF8, - 0, - value, - -1, - szString, - cchString); + MultiByteToWideChar(CP_UTF8, 0, value, -1, szString, cchString); *pcchString = cchString; } + free(value); } return S_OK; } @@ -522,8 +544,7 @@ CordbObjectValue::GetFunction(ICorDebugFunction **ppFunction) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::GetClass(/* [out] */ ICorDebugClass **ppClass) { +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetClass(ICorDebugClass **ppClass) { LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetClass - NOT IMPLEMENTED\n")); return E_NOTIMPL; @@ -534,23 +555,22 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue( LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetFieldValue - IMPLEMENTED\n")); - if (object_id == -1) + if (m_debuggerId == -1) return S_FALSE; MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); m_dbgprot_buffer_add_int(&localbuf, fieldDef); int cmdId = - conn->send_event(MDBGPROT_CMD_SET_OBJECT_REF, - MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); + conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, + MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = - conn->get_answer_with_error(cmdId); + ReceivedReplyPacket *received_reply_packet = conn->GetAnswerWithError(cmdId); CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *bAnswer = received_reply_packet->buf; + MdbgProtBuffer *bAnswer = received_reply_packet->Buffer(); return CreateCordbValue(conn, bAnswer, ppValue); } @@ -559,80 +579,83 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, MdbgProtBuffer *bAnswer, ICorDebugValue **ppValue) { CorElementType type = (CorElementType)m_dbgprot_decode_byte( - bAnswer->buf, &bAnswer->buf, bAnswer->end); + bAnswer->p, &bAnswer->p, bAnswer->end); CordbContent value; if ((MdbgProtValueTypeId)type == MDBGPROT_VALUE_TYPE_ID_NULL) { CorElementType type = (CorElementType)m_dbgprot_decode_byte( - bAnswer->buf, &bAnswer->buf, bAnswer->end); + bAnswer->p, &bAnswer->p, bAnswer->end); if (type == ELEMENT_TYPE_CLASS || type == ELEMENT_TYPE_STRING) { int klass_id = (CorElementType)m_dbgprot_decode_id( - bAnswer->buf, &bAnswer->buf, bAnswer->end); + bAnswer->p, &bAnswer->p, bAnswer->end); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, klass_id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, - MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, + MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - bAnswer = conn->get_answer(cmdId); + bAnswer = conn->GetAnswer(cmdId); char *namespace_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); char *class_name_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); char *class_fullname_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); int assembly_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); int module_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int type_id2 = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int token = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int type_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int type_id2 = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int token = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); CordbClass *klass = new CordbClass(conn, token, module_id); CordbReferenceValue *refValue = new CordbReferenceValue(conn, type, -1, klass); refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); } if (type == ELEMENT_TYPE_SZARRAY) { CordbClass *klass = NULL; int type_id = - m_dbgprot_decode_byte(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); if (type_id == ELEMENT_TYPE_CLASS) { int klass_id = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, klass_id); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_TYPE, - MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, + MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - bAnswer = conn->get_answer(cmdId); + bAnswer = conn->GetAnswer(cmdId); char *namespace_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); char *class_name_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); char *class_fullname_str = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); int assembly_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); int module_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); int type_id3 = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); int type_id2 = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); - int token = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int token = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); klass = new CordbClass(conn, token, module_id); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); } - CordbType *cordbtype = new CordbType( - type, conn, NULL, new CordbType((CorElementType)type_id, conn, klass)); + CordbType *cordbtype = + new CordbType(type, conn, NULL, + new CordbType((CorElementType)type_id, conn, klass)); CordbReferenceValue *refValue = new CordbReferenceValue(conn, type, -1, klass, cordbtype); refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); @@ -645,31 +668,30 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, case ELEMENT_TYPE_I1: case ELEMENT_TYPE_U1: value.booleanValue = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); break; case ELEMENT_TYPE_CHAR: case ELEMENT_TYPE_I2: case ELEMENT_TYPE_U2: value.charValue = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: case ELEMENT_TYPE_R4: value.intValue = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: case ELEMENT_TYPE_R8: value.longValue = - m_dbgprot_decode_long(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_long(bAnswer->p, &bAnswer->p, bAnswer->end); break; case ELEMENT_TYPE_CLASS: case ELEMENT_TYPE_SZARRAY: case ELEMENT_TYPE_STRING: { - int object_id = - m_dbgprot_decode_id(bAnswer->buf, &bAnswer->buf, bAnswer->end); + int object_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); CordbReferenceValue *refValue = new CordbReferenceValue(conn, type, object_id); refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); @@ -680,8 +702,9 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, return S_FALSE; } - *ppValue = new CordbValue(conn, type, value, - convert_mono_type_2_icordbg_size(type)); // + *ppValue = + new CordbValue(conn, type, value, convert_mono_type_2_icordbg_size(type)); + (*ppValue)->AddRef(); return S_OK; } @@ -754,7 +777,7 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::QueryInterface(REFIID id, } else if (id == IID_ICorDebugHeapValue3) { *pInterface = static_cast(this); } else if ((id == IID_ICorDebugStringValue) && - (type == ELEMENT_TYPE_STRING)) { + (m_type == ELEMENT_TYPE_STRING)) { *pInterface = static_cast(this); } else if (id == IID_IUnknown) { *pInterface = @@ -763,17 +786,28 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::QueryInterface(REFIID id, *pInterface = NULL; return E_NOINTERFACE; } + AddRef(); return S_OK; } CordbArrayValue::CordbArrayValue(Connection *conn, CordbType *type, int object_id, CordbClass *klass) : CordbBaseMono(conn) { - this->type = type; - this->object_id = object_id; - this->klass = klass; + this->m_pCordbType = type; + this->m_debuggerId = object_id; + this->m_pClass = klass; + if (klass) + klass->InternalAddRef(); + if (m_pCordbType) + m_pCordbType->InternalAddRef(); } +CordbArrayValue::~CordbArrayValue() { + if (m_pClass) + m_pClass->InternalRelease(); + if (m_pCordbType) + m_pCordbType->InternalRelease(); +} HRESULT STDMETHODCALLTYPE CordbArrayValue::GetClass(ICorDebugClass **ppClass) { LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetClass - NOT IMPLEMENTED\n")); @@ -833,7 +867,7 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize(ULONG32 *pSize) { } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetAddress(CORDB_ADDRESS *pAddress) { - *pAddress = (CORDB_ADDRESS)&object_id; + *pAddress = (CORDB_ADDRESS)&m_debuggerId; LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetAddress - IMPLEMENTED\n")); return S_OK; @@ -870,14 +904,10 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::QueryInterface(REFIID id, *pInterface = NULL; return E_NOINTERFACE; } - + AddRef(); return S_OK; } -ULONG STDMETHODCALLTYPE CordbArrayValue::AddRef(void) { return 0; } - -ULONG STDMETHODCALLTYPE CordbArrayValue::Release(void) { return 0; } - HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethodAndType( mdMemberRef memberRef, ICorDebugFunction **ppFunction, ICorDebugType **ppType) { @@ -927,7 +957,7 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateRelocBreakpoint( HRESULT STDMETHODCALLTYPE CordbArrayValue::GetExactType(ICorDebugType **ppType) { - *ppType = static_cast(type); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetExactType - NOT IMPLEMENTED\n")); return S_OK; @@ -1006,13 +1036,13 @@ CordbArrayValue::GetElementType(CorElementType *pType) { HRESULT STDMETHODCALLTYPE CordbArrayValue::GetRank(ULONG32 *pnRank) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, - MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, + MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + int rank = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetRank - IMPLEMENTED\n")); *pnRank = rank; return S_OK; @@ -1021,16 +1051,16 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetRank(ULONG32 *pnRank) { HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCount(ULONG32 *pnCount) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, - MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, + MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); - int rank = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); - count = m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + int rank = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_nCount = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetCount - IMPLEMENTED\n")); - *pnCount = count; + *pnCount = m_nCount; return S_OK; } @@ -1038,7 +1068,7 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetDimensions(ULONG32 cdim, ULONG32 dims[]) { LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetDimensions - IMPLEMENTED\n")); - dims[0] = count; + dims[0] = m_nCount; return S_OK; } @@ -1063,14 +1093,14 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement( MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, object_id); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); m_dbgprot_buffer_add_int(&localbuf, indices[cdim - 1]); m_dbgprot_buffer_add_int(&localbuf, 1); - int cmdId = conn->send_event(MDBGPROT_CMD_SET_ARRAY_REF, - MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, + MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->get_answer(cmdId); + MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); return S_OK; } diff --git a/src/mono/dbi/cordb-value.h b/src/mono/dbi/cordb-value.h index 9eaa1633d353fe..a6787942b96606 100644 --- a/src/mono/dbi/cordb-value.h +++ b/src/mono/dbi/cordb-value.h @@ -22,26 +22,29 @@ class CordbValue : public CordbBaseMono, public ICorDebugValue2, public ICorDebugValue3, public ICorDebugGenericValue { - CorElementType type; - CordbContent value; - int size; - Connection *conn; + CorElementType m_type; + CordbContent m_value; + int m_size; + CordbType *m_pType; public: CordbValue(Connection *conn, CorElementType type, CordbContent value, int size); - HRESULT STDMETHODCALLTYPE GetType(CorElementType *pType); - HRESULT STDMETHODCALLTYPE GetSize(ULONG32 *pSize); - HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS *pAddress); - HRESULT STDMETHODCALLTYPE + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbValue"; } + ~CordbValue(); + HRESULT GetType(CorElementType *pType); + HRESULT GetSize(ULONG32 *pSize); + HRESULT GetAddress(CORDB_ADDRESS *pAddress); + HRESULT CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE GetSize64(ULONG64 *pSize); - HRESULT STDMETHODCALLTYPE GetValue(void *pTo); - HRESULT STDMETHODCALLTYPE SetValue(void *pFrom); + HRESULT QueryInterface(REFIID riid, void **ppvObject); + + HRESULT GetExactType(ICorDebugType **ppType); + HRESULT GetSize64(ULONG64 *pSize); + HRESULT GetValue(void *pTo); + HRESULT SetValue(void *pFrom); }; class CordbReferenceValue : public CordbBaseMono, @@ -49,32 +52,34 @@ class CordbReferenceValue : public CordbBaseMono, public ICorDebugValue2, public ICorDebugValue3, public ICorDebugGenericValue { - CorElementType type; - int object_id; - Connection *conn; - CordbClass *klass; - CordbType *cordbtype; + CorElementType m_type; + int m_debuggerId; + CordbClass *m_pClass; + CordbType *m_pCordbType; public: CordbReferenceValue(Connection *conn, CorElementType type, int object_id, - CordbClass *klass = NULL, CordbType *cordbtype = NULL); - HRESULT STDMETHODCALLTYPE GetType(CorElementType *pType); - HRESULT STDMETHODCALLTYPE GetSize(ULONG32 *pSize); - HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS *pAddress); - HRESULT STDMETHODCALLTYPE + CordbClass *klass = NULL, CordbType *cordbType = NULL); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbReferenceValue"; } + ~CordbReferenceValue(); + HRESULT GetType(CorElementType *pType); + HRESULT GetSize(ULONG32 *pSize); + HRESULT GetAddress(CORDB_ADDRESS *pAddress); + HRESULT CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE GetSize64(ULONG64 *pSize); - HRESULT STDMETHODCALLTYPE GetValue(void *pTo); - HRESULT STDMETHODCALLTYPE SetValue(void *pFrom); - HRESULT STDMETHODCALLTYPE IsNull(BOOL *pbNull); - HRESULT STDMETHODCALLTYPE GetValue(CORDB_ADDRESS *pValue); - HRESULT STDMETHODCALLTYPE SetValue(CORDB_ADDRESS value); - HRESULT STDMETHODCALLTYPE Dereference(ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE DereferenceStrong(ICorDebugValue **ppValue); + HRESULT QueryInterface(REFIID riid, void **ppvObject); + + HRESULT GetExactType(ICorDebugType **ppType); + HRESULT GetSize64(ULONG64 *pSize); + HRESULT GetValue(void *pTo); + HRESULT SetValue(void *pFrom); + HRESULT IsNull(BOOL *pbNull); + HRESULT GetValue(CORDB_ADDRESS *pValue); + HRESULT SetValue(CORDB_ADDRESS value); + HRESULT Dereference(ICorDebugValue **ppValue); + HRESULT DereferenceStrong(ICorDebugValue **ppValue); }; class CordbObjectValue : public CordbBaseMono, @@ -89,64 +94,65 @@ class CordbObjectValue : public CordbBaseMono, public ICorDebugExceptionObjectValue, public ICorDebugComObjectValue, public ICorDebugDelegateObjectValue { - CorElementType type; - int object_id; - CordbClass *klass; + CorElementType m_type; + int m_debuggerId; + CordbClass *m_pClass; + CordbType *m_pCordbType; public: CordbObjectValue(Connection *conn, CorElementType type, int object_id, CordbClass *klass); - HRESULT STDMETHODCALLTYPE GetClass(/* [out] */ ICorDebugClass **ppClass); - HRESULT STDMETHODCALLTYPE GetFieldValue(ICorDebugClass *pClass, - mdFieldDef fieldDef, - ICorDebugValue **ppValue); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbObjectValue"; } + ~CordbObjectValue(); + HRESULT GetClass(ICorDebugClass **ppClass); + HRESULT GetFieldValue(ICorDebugClass *pClass, mdFieldDef fieldDef, + ICorDebugValue **ppValue); static HRESULT CreateCordbValue(Connection *conn, MdbgProtBuffer *bAnswer, ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetVirtualMethod(mdMemberRef memberRef, - ICorDebugFunction **ppFunction); - HRESULT STDMETHODCALLTYPE GetContext(ICorDebugContext **ppContext); - HRESULT STDMETHODCALLTYPE IsValueClass(BOOL *pbIsValueClass); - HRESULT STDMETHODCALLTYPE GetManagedCopy(IUnknown **ppObject); - HRESULT STDMETHODCALLTYPE SetFromManagedCopy(IUnknown *pObject); - HRESULT STDMETHODCALLTYPE IsValid(BOOL *pbValid); - HRESULT STDMETHODCALLTYPE + HRESULT GetVirtualMethod(mdMemberRef memberRef, + ICorDebugFunction **ppFunction); + HRESULT GetContext(ICorDebugContext **ppContext); + HRESULT IsValueClass(BOOL *pbIsValueClass); + HRESULT GetManagedCopy(IUnknown **ppObject); + HRESULT SetFromManagedCopy(IUnknown *pObject); + HRESULT IsValid(BOOL *pbValid); + HRESULT CreateRelocBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE GetType(CorElementType *pType); - HRESULT STDMETHODCALLTYPE GetSize(ULONG32 *pSize); - HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS *pAddress); - HRESULT STDMETHODCALLTYPE + HRESULT GetType(CorElementType *pType); + HRESULT GetSize(ULONG32 *pSize); + HRESULT GetAddress(CORDB_ADDRESS *pAddress); + HRESULT CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE GetSize64(ULONG64 *pSize); - HRESULT STDMETHODCALLTYPE GetValue(void *pTo); - HRESULT STDMETHODCALLTYPE SetValue(void *pFrom); - HRESULT STDMETHODCALLTYPE + HRESULT QueryInterface(REFIID riid, void **ppvObject); + + HRESULT GetExactType(ICorDebugType **ppType); + HRESULT GetSize64(ULONG64 *pSize); + HRESULT GetValue(void *pTo); + HRESULT SetValue(void *pFrom); + HRESULT GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction **ppFunction, ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE GetLength(ULONG32 *pcchString); - HRESULT STDMETHODCALLTYPE GetString(ULONG32 cchString, ULONG32 *pcchString, - WCHAR szString[]); - HRESULT STDMETHODCALLTYPE CreateHandle(CorDebugHandleType type, - ICorDebugHandleValue **ppHandle); - HRESULT STDMETHODCALLTYPE GetThreadOwningMonitorLock( - ICorDebugThread **ppThread, DWORD *pAcquisitionCount); - HRESULT STDMETHODCALLTYPE + HRESULT GetLength(ULONG32 *pcchString); + HRESULT GetString(ULONG32 cchString, ULONG32 *pcchString, WCHAR szString[]); + HRESULT CreateHandle(CorDebugHandleType type, + ICorDebugHandleValue **ppHandle); + HRESULT GetThreadOwningMonitorLock(ICorDebugThread **ppThread, + DWORD *pAcquisitionCount); + HRESULT GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum); - HRESULT STDMETHODCALLTYPE EnumerateExceptionCallStack( + HRESULT EnumerateExceptionCallStack( ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum); - HRESULT STDMETHODCALLTYPE GetCachedInterfaceTypes( - BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum); - HRESULT STDMETHODCALLTYPE GetCachedInterfacePointers(BOOL bIInspectableOnly, - ULONG32 celt, - ULONG32 *pcEltFetched, - CORDB_ADDRESS *ptrs); - HRESULT STDMETHODCALLTYPE GetTarget(ICorDebugReferenceValue **ppObject); - HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction **ppFunction); + HRESULT GetCachedInterfaceTypes(BOOL bIInspectableOnly, + ICorDebugTypeEnum **ppInterfacesEnum); + HRESULT GetCachedInterfacePointers(BOOL bIInspectableOnly, ULONG32 celt, + ULONG32 *pcEltFetched, + CORDB_ADDRESS *ptrs); + HRESULT GetTarget(ICorDebugReferenceValue **ppObject); + HRESULT GetFunction(ICorDebugFunction **ppFunction); }; class CordbArrayValue : public CordbBaseMono, @@ -162,71 +168,69 @@ class CordbArrayValue : public CordbBaseMono, public ICorDebugComObjectValue, public ICorDebugDelegateObjectValue, public ICorDebugArrayValue { - CordbType *type; - int object_id; - CordbClass *klass; - int count; + CordbType *m_pCordbType; + int m_debuggerId; + CordbClass *m_pClass; + int m_nCount; public: CordbArrayValue(Connection *conn, CordbType *type, int object_id, CordbClass *klass); - HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass **ppClass); - HRESULT STDMETHODCALLTYPE GetFieldValue(ICorDebugClass *pClass, - mdFieldDef fieldDef, - ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetVirtualMethod(mdMemberRef memberRef, - ICorDebugFunction **ppFunction); - HRESULT STDMETHODCALLTYPE GetContext(ICorDebugContext **ppContext); - HRESULT STDMETHODCALLTYPE IsValueClass(BOOL *pbIsValueClass); - HRESULT STDMETHODCALLTYPE GetManagedCopy(IUnknown **ppObject); - HRESULT STDMETHODCALLTYPE SetFromManagedCopy(IUnknown *pObject); - HRESULT STDMETHODCALLTYPE GetType(CorElementType *pType); - HRESULT STDMETHODCALLTYPE GetSize(ULONG32 *pSize); - HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS *pAddress); - HRESULT STDMETHODCALLTYPE + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbArrayValue"; } + ~CordbArrayValue(); + HRESULT GetClass(ICorDebugClass **ppClass); + HRESULT GetFieldValue(ICorDebugClass *pClass, mdFieldDef fieldDef, + ICorDebugValue **ppValue); + HRESULT GetVirtualMethod(mdMemberRef memberRef, + ICorDebugFunction **ppFunction); + HRESULT GetContext(ICorDebugContext **ppContext); + HRESULT IsValueClass(BOOL *pbIsValueClass); + HRESULT GetManagedCopy(IUnknown **ppObject); + HRESULT SetFromManagedCopy(IUnknown *pObject); + HRESULT GetType(CorElementType *pType); + HRESULT GetSize(ULONG32 *pSize); + HRESULT GetAddress(CORDB_ADDRESS *pAddress); + HRESULT CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE + HRESULT QueryInterface(REFIID riid, void **ppvObject); + + HRESULT GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction **ppFunction, ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE GetValue(void *pTo); - HRESULT STDMETHODCALLTYPE SetValue(void *pFrom); - HRESULT STDMETHODCALLTYPE GetLength(ULONG32 *pcchString); - HRESULT STDMETHODCALLTYPE GetString(ULONG32 cchString, ULONG32 *pcchString, - WCHAR szString[]); - HRESULT STDMETHODCALLTYPE IsValid(BOOL *pbValid); - HRESULT STDMETHODCALLTYPE + HRESULT GetValue(void *pTo); + HRESULT SetValue(void *pFrom); + HRESULT GetLength(ULONG32 *pcchString); + HRESULT GetString(ULONG32 cchString, ULONG32 *pcchString, WCHAR szString[]); + HRESULT IsValid(BOOL *pbValid); + HRESULT CreateRelocBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType **ppType); - HRESULT STDMETHODCALLTYPE GetSize64(ULONG64 *pSize); - HRESULT STDMETHODCALLTYPE CreateHandle(CorDebugHandleType type, - ICorDebugHandleValue **ppHandle); - HRESULT STDMETHODCALLTYPE GetThreadOwningMonitorLock( - ICorDebugThread **ppThread, DWORD *pAcquisitionCount); - HRESULT STDMETHODCALLTYPE + HRESULT GetExactType(ICorDebugType **ppType); + HRESULT GetSize64(ULONG64 *pSize); + HRESULT CreateHandle(CorDebugHandleType type, + ICorDebugHandleValue **ppHandle); + HRESULT GetThreadOwningMonitorLock(ICorDebugThread **ppThread, + DWORD *pAcquisitionCount); + HRESULT GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum); - HRESULT STDMETHODCALLTYPE EnumerateExceptionCallStack( + HRESULT EnumerateExceptionCallStack( ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum); - HRESULT STDMETHODCALLTYPE GetCachedInterfaceTypes( - BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum); - HRESULT STDMETHODCALLTYPE GetCachedInterfacePointers(BOOL bIInspectableOnly, - ULONG32 celt, - ULONG32 *pcEltFetched, - CORDB_ADDRESS *ptrs); - HRESULT STDMETHODCALLTYPE GetTarget(ICorDebugReferenceValue **ppObject); - HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction **ppFunction); - - HRESULT STDMETHODCALLTYPE GetElementType(CorElementType *pType); - HRESULT STDMETHODCALLTYPE GetRank(ULONG32 *pnRank); - HRESULT STDMETHODCALLTYPE GetCount(ULONG32 *pnCount); - HRESULT STDMETHODCALLTYPE GetDimensions(ULONG32 cdim, ULONG32 dims[]); - HRESULT STDMETHODCALLTYPE HasBaseIndicies(BOOL *pbHasBaseIndicies); - HRESULT STDMETHODCALLTYPE GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]); - HRESULT STDMETHODCALLTYPE GetElement(ULONG32 cdim, ULONG32 indices[], - ICorDebugValue **ppValue); - HRESULT STDMETHODCALLTYPE GetElementAtPosition(ULONG32 nPosition, - ICorDebugValue **ppValue); + HRESULT GetCachedInterfaceTypes(BOOL bIInspectableOnly, + ICorDebugTypeEnum **ppInterfacesEnum); + HRESULT GetCachedInterfacePointers(BOOL bIInspectableOnly, ULONG32 celt, + ULONG32 *pcEltFetched, + CORDB_ADDRESS *ptrs); + HRESULT GetTarget(ICorDebugReferenceValue **ppObject); + HRESULT GetFunction(ICorDebugFunction **ppFunction); + + HRESULT GetElementType(CorElementType *pType); + HRESULT GetRank(ULONG32 *pnRank); + HRESULT GetCount(ULONG32 *pnCount); + HRESULT GetDimensions(ULONG32 cdim, ULONG32 dims[]); + HRESULT HasBaseIndicies(BOOL *pbHasBaseIndicies); + HRESULT GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]); + HRESULT GetElement(ULONG32 cdim, ULONG32 indices[], ICorDebugValue **ppValue); + HRESULT GetElementAtPosition(ULONG32 nPosition, ICorDebugValue **ppValue); }; #endif diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 050b449c188f2b..7272c54714fce7 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -16,6 +16,9 @@ #include #include +#define DEBUG_ADDRESS "127.0.0.1" +#define DEBUG_PORT "4712" + int convert_mono_type_2_icordbg_size(int type) { switch (type) { case ELEMENT_TYPE_VOID: @@ -50,16 +53,16 @@ MONO_API HRESULT CoreCLRCreateCordbObjectEx(int iDebuggerVersion, DWORD pid, return S_OK; } -static void receive_thread(Connection *c) { c->receive(); } +static void receive_thread(Connection *c) { c->Receive(); } -static void debugger_thread(void *ppProcess) { - Connection *connection = new Connection((CordbProcess *)ppProcess, - ((CordbProcess *)ppProcess)->cordb); - ((CordbProcess *)ppProcess)->SetConnection(connection); - connection->start_connection(); - connection->transport_handshake(); - connection->loop_send_receive(); - connection->close_connection(); +static void debugger_thread(void *m_pProcess) { + Connection *connection = new Connection( + (CordbProcess *)m_pProcess, ((CordbProcess *)m_pProcess)->GetCordb()); + ((CordbProcess *)m_pProcess)->SetConnection(connection); + connection->StartConnection(); + connection->TransportHandshake(); + connection->LoopSendReceive(); + connection->CloseConnection(); } HRESULT Cordb::Initialize(void) { @@ -72,210 +75,175 @@ HRESULT Cordb::Terminate(void) { return S_OK; } -HRESULT Cordb::SetManagedHandler( - /* [in] */ ICorDebugManagedCallback *pCallback) { +HRESULT Cordb::SetManagedHandler(ICorDebugManagedCallback *pCallback) { LOG((LF_CORDB, LL_INFO1000000, "Cordb - SetManagedHandler - IMPLEMENTED\n")); - this->pCallback = pCallback; - this->pCallback->AddRef(); - + this->m_pCallback = pCallback; + this->GetCallback()->AddRef(); return S_OK; } -HRESULT Cordb::SetUnmanagedHandler( - /* [in] */ ICorDebugUnmanagedCallback *pCallback) { +HRESULT Cordb::SetUnmanagedHandler(ICorDebugUnmanagedCallback *pCallback) { LOG((LF_CORDB, LL_INFO100000, "Cordb - SetUnmanagedHandler - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT Cordb::CreateProcess( - /* [in] */ LPCWSTR lpApplicationName, - /* [in] */ LPWSTR lpCommandLine, - /* [in] */ LPSECURITY_ATTRIBUTES lpProcessAttributes, - /* [in] */ LPSECURITY_ATTRIBUTES lpThreadAttributes, - /* [in] */ BOOL bInheritHandles, - /* [in] */ DWORD dwCreationFlags, - /* [in] */ PVOID lpEnvironment, - /* [in] */ LPCWSTR lpCurrentDirectory, - /* [in] */ LPSTARTUPINFOW lpStartupInfo, - /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, - /* [in] */ CorDebugCreateProcessFlags debuggingFlags, - /* [out] */ ICorDebugProcess **ppProcess) { +HRESULT Cordb::CreateProcess(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, DWORD dwCreationFlags, + PVOID lpEnvironment, LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + CorDebugCreateProcessFlags debuggingFlags, + ICorDebugProcess **ppProcess) { LOG((LF_CORDB, LL_INFO100000, "Cordb - CreateProcess - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT Cordb::DebugActiveProcess( - /* [in] */ DWORD id, - /* [in] */ BOOL win32Attach, - /* [out] */ ICorDebugProcess **ppProcess) { +HRESULT Cordb::DebugActiveProcess(DWORD id, BOOL win32Attach, + ICorDebugProcess **ppProcess) { LOG((LF_CORDB, LL_INFO1000000, "Cordb - DebugActiveProcess - IMPLEMENTED\n")); - *ppProcess = new CordbProcess(); - ((CordbProcess *)*ppProcess)->cordb = this; + m_pProcess = new CordbProcess(this); + m_pProcess->InternalAddRef(); + m_pProcess->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); DWORD thread_id; - CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)debugger_thread, - ((CordbProcess *)*ppProcess), 0, &thread_id); + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)debugger_thread, m_pProcess, 0, + &thread_id); return S_OK; } -HRESULT Cordb::EnumerateProcesses( - /* [out] */ ICorDebugProcessEnum **ppProcess) { +HRESULT Cordb::EnumerateProcesses(ICorDebugProcessEnum **ppProcess) { LOG((LF_CORDB, LL_INFO100000, "Cordb - EnumerateProcesses - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT Cordb::GetProcess( - /* [in] */ DWORD dwProcessId, - /* [out] */ ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO100000, "Cordb - GetProcess - NOT IMPLEMENTED\n")); +HRESULT Cordb::GetProcess(DWORD dwProcessId, ICorDebugProcess **ppProcess) { + m_pProcess->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); return S_OK; } -HRESULT Cordb::CanLaunchOrAttach( - /* [in] */ DWORD dwProcessId, - /* [in] */ BOOL win32DebuggingEnabled) { +HRESULT Cordb::CanLaunchOrAttach(DWORD dwProcessId, + BOOL win32DebuggingEnabled) { LOG((LF_CORDB, LL_INFO100000, "Cordb - CanLaunchOrAttach - NOT IMPLEMENTED\n")); return S_OK; } -Cordb::Cordb() { - pCallback = NULL; - breakpoints = new ArrayList(); - threads = new ArrayList(); - functions = new ArrayList(); - modules = new ArrayList(); +Cordb::Cordb() : CordbBaseMono(NULL) { + m_pCallback = NULL; + m_pSemReadWrite = new UTSemReadWrite(); #ifdef LOGGING InitializeLogging(); #endif } -CordbFunction *Cordb::findFunction(int id) { - DWORD i = 0; - while (i < functions->GetCount()) { - CordbFunction *function = (CordbFunction *)functions->Get(i); - if (function->id == id) { - return function; - } - i++; - } - return NULL; -} - -CordbFunction *Cordb::findFunctionByToken(int token) { - DWORD i = 0; - while (i < functions->GetCount()) { - CordbFunction *function = (CordbFunction*)functions->Get(i); - if (function->token == token) { - return function; - } - i++; - } - return NULL; +Cordb::~Cordb() { + this->GetCallback()->Release(); + m_pProcess->InternalRelease(); + delete m_pSemReadWrite; +#ifdef LOGGING + ShutdownLogging(); +#endif } -HRESULT Cordb::QueryInterface( - /* [in] */ REFIID riid, - /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) { +HRESULT +Cordb::QueryInterface(REFIID riid, + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) { LOG((LF_CORDB, LL_INFO100000, "Cordb - QueryInterface - NOT IMPLEMENTED\n")); return S_OK; } -ULONG Cordb::AddRef(void) { return S_OK; } - -ULONG Cordb::Release(void) { return S_OK; } - HRESULT Cordb::CreateProcessEx( - /* [in] */ ICorDebugRemoteTarget *pRemoteTarget, - /* [in] */ LPCWSTR lpApplicationName, - /* [annotation][in] */ - _In_ LPWSTR lpCommandLine, - /* [in] */ LPSECURITY_ATTRIBUTES lpProcessAttributes, - /* [in] */ LPSECURITY_ATTRIBUTES lpThreadAttributes, - /* [in] */ BOOL bInheritHandles, - /* [in] */ DWORD dwCreationFlags, - /* [in] */ PVOID lpEnvironment, - /* [in] */ LPCWSTR lpCurrentDirectory, - /* [in] */ LPSTARTUPINFOW lpStartupInfo, - /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, - /* [in] */ CorDebugCreateProcessFlags debuggingFlags, - /* [out] */ ICorDebugProcess **ppProcess) { + ICorDebugRemoteTarget *pRemoteTarget, LPCWSTR lpApplicationName, + _In_ LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, + DWORD dwCreationFlags, PVOID lpEnvironment, LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation, + CorDebugCreateProcessFlags debuggingFlags, ICorDebugProcess **ppProcess) { LOG((LF_CORDB, LL_INFO100000, "Cordb - CreateProcessEx - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT Cordb::DebugActiveProcessEx( - /* [in] */ ICorDebugRemoteTarget *pRemoteTarget, - /* [in] */ DWORD dwProcessId, - /* [in] */ BOOL fWin32Attach, - /* [out] */ ICorDebugProcess **ppProcess) { +HRESULT Cordb::DebugActiveProcessEx(ICorDebugRemoteTarget *pRemoteTarget, + DWORD dwProcessId, BOOL fWin32Attach, + ICorDebugProcess **ppProcess) { LOG((LF_CORDB, LL_INFO100000, "Cordb - DebugActiveProcessEx - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT Cordb::GetModule(int module_id, ICorDebugModule** pModule) -{ - for (DWORD i = 0; i < modules->GetCount(); i++) { - CordbModule* module = (CordbModule*)modules->Get(i); - if (module->id == module_id) { - *pModule = module; - return S_OK; - } - } - return S_FALSE; +ReceivedReplyPacket::ReceivedReplyPacket(int error, int error_2, int id, + MdbgProtBuffer *buf) { + this->error = error; + this->error_2 = error_2; + this->id = id; + this->buf = buf; +} + +ReceivedReplyPacket::~ReceivedReplyPacket() { + if (buf) { + m_dbgprot_buffer_free(buf); + delete buf; + } } Connection::Connection(CordbProcess *proc, Cordb *cordb) { - ppProcess = proc; - ppCordb = cordb; - pCorDebugAppDomain = NULL; - received_replies = new ArrayList(); - received_packets_to_process = new ArrayList(); - is_answer_pending = false; - pending_eval = new ArrayList(); + pProcess = proc; + pCordb = cordb; + receiveReplies = new ArrayList(); + receivedPacketsToProcess = new ArrayList(); } -CordbThread *Connection::findThread(ArrayList *threads, long thread_id) { +Connection::~Connection() { DWORD i = 0; - while (i < threads->GetCount()) { - CordbThread *thread = (CordbThread *)threads->Get(i); - if (thread->thread_id == thread_id) { - return thread; + while (i < receiveReplies->GetCount()) { + ReceivedReplyPacket *rrp = (ReceivedReplyPacket *)receiveReplies->Get(i); + if (rrp) { + delete rrp; + } + i++; + } + i = 0; + while (i < receivedPacketsToProcess->GetCount()) { + MdbgProtBuffer *buf = (MdbgProtBuffer *)receivedPacketsToProcess->Get(i); + if (buf) { + m_dbgprot_buffer_free(buf); + free(buf); } i++; } - return NULL; + delete socket; + delete receiveReplies; + delete receivedPacketsToProcess; } -void Connection::receive() { +void Connection::Receive() { while (true) { MdbgProtBuffer recvbuf_header; m_dbgprot_buffer_init(&recvbuf_header, HEADER_LENGTH); - int iResult = - connect_socket->Receive((char *)recvbuf_header.buf, HEADER_LENGTH); + int iResult = socket->Receive((char *)recvbuf_header.buf, HEADER_LENGTH); if (iResult == -1) { - ppCordb->pCallback->ExitProcess( - static_cast(ppProcess)); + pCordb->GetCallback()->ExitProcess( + static_cast(GetProcess())); break; } while (iResult == 0) { LOG((LF_CORDB, LL_INFO100000, "transport_recv () sleep returned %d, expected %d.\n", iResult, HEADER_LENGTH)); - iResult = - connect_socket->Receive((char *)recvbuf_header.buf, HEADER_LENGTH); + iResult = socket->Receive((char *)recvbuf_header.buf, HEADER_LENGTH); Sleep(1000); } MdbgProtHeader header; MdbgProtBuffer *recvbuf = new MdbgProtBuffer(); m_dbgprot_decode_command_header(&recvbuf_header, &header); - + m_dbgprot_buffer_free(&recvbuf_header); m_dbgprot_buffer_init(recvbuf, header.len - HEADER_LENGTH); if (header.len < HEADER_LENGTH) { @@ -283,93 +251,87 @@ void Connection::receive() { } if (header.len - HEADER_LENGTH != 0) { - iResult = connect_socket->Receive((char *)recvbuf->buf, - header.len - HEADER_LENGTH); + iResult = socket->Receive((char *)recvbuf->p, header.len - HEADER_LENGTH); int totalRead = iResult; while (totalRead < header.len - HEADER_LENGTH) { - iResult = connect_socket->Receive((char *)recvbuf->buf + totalRead, - (header.len - HEADER_LENGTH) - totalRead); + iResult = socket->Receive((char *)recvbuf->p + totalRead, + (header.len - HEADER_LENGTH) - totalRead); totalRead += iResult; } } dbg_lock(); if (header.flags == REPLY_PACKET) { - ReceivedReplyPacket *rp = - (ReceivedReplyPacket *)malloc(sizeof(ReceivedReplyPacket)); - rp->error = header.error; - rp->error_2 = header.error_2; - rp->id = header.id; - rp->buf = recvbuf; - received_replies->Append(rp); + ReceivedReplyPacket *rp = new ReceivedReplyPacket( + header.error, header.error_2, header.id, recvbuf); + receiveReplies->Append(rp); } else { - received_packets_to_process->Append(recvbuf); + receivedPacketsToProcess->Append(recvbuf); } dbg_unlock(); } } -MdbgProtBuffer *Connection::get_answer(int cmdId) { - ReceivedReplyPacket * rrp = NULL; - while (rrp == NULL || rrp->id != cmdId) { +MdbgProtBuffer *Connection::GetAnswer(int cmdId) { + ReceivedReplyPacket *rrp = NULL; + while (rrp == NULL || rrp->Id() != cmdId) { dbg_lock(); - for (int i = received_replies->GetCount() - 1; i >= 0; i--) { - rrp = (ReceivedReplyPacket*)received_replies->Get(i); - if (rrp->id == cmdId) - break; + for (int i = receiveReplies->GetCount() - 1; i >= 0; i--) { + rrp = (ReceivedReplyPacket *)receiveReplies->Get(i); + if (rrp->Id() == cmdId) + break; } dbg_unlock(); } - return rrp->buf; + return rrp->Buffer(); } -ReceivedReplyPacket *Connection::get_answer_with_error(int cmdId) { - ReceivedReplyPacket * rrp = NULL; - while (rrp == NULL || rrp->id != cmdId) { +ReceivedReplyPacket *Connection::GetAnswerWithError(int cmdId) { + ReceivedReplyPacket *rrp = NULL; + while (rrp == NULL || rrp->Id() != cmdId) { dbg_lock(); - for (int i = received_replies->GetCount() - 1; i >= 0; i--) { - rrp = (ReceivedReplyPacket*)received_replies->Get(i); - if (rrp->id == cmdId) - break; + for (int i = receiveReplies->GetCount() - 1; i >= 0; i--) { + rrp = (ReceivedReplyPacket *)receiveReplies->Get(i); + if (rrp->Id() == cmdId) + break; } dbg_unlock(); } return rrp; } -void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { - int spolicy = - m_dbgprot_decode_byte(recvbuf->buf, &recvbuf->buf, recvbuf->end); - int nevents = m_dbgprot_decode_int(recvbuf->buf, &recvbuf->buf, recvbuf->end); +CordbAppDomain *Connection::GetCurrentAppDomain() { + return GetProcess()->GetCurrentAppDomain(); +} +void Connection::ProcessPacketInternal(MdbgProtBuffer *recvbuf) { + int spolicy = m_dbgprot_decode_byte(recvbuf->p, &recvbuf->p, recvbuf->end); + int nevents = m_dbgprot_decode_int(recvbuf->p, &recvbuf->p, recvbuf->end); + CordbAppDomain *pCorDebugAppDomain = GetCurrentAppDomain(); for (int i = 0; i < nevents; ++i) { - int kind = m_dbgprot_decode_byte(recvbuf->buf, &recvbuf->buf, recvbuf->end); - int req_id = - m_dbgprot_decode_int(recvbuf->buf, &recvbuf->buf, recvbuf->end); + int kind = m_dbgprot_decode_byte(recvbuf->p, &recvbuf->p, recvbuf->end); + int req_id = m_dbgprot_decode_int(recvbuf->p, &recvbuf->p, recvbuf->end); MdbgProtEventKind etype = (MdbgProtEventKind)kind; - long thread_id = - m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + long thread_id = m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); LOG((LF_CORDB, LL_INFO100000, "Received %d %d events %s, suspend=%d\n", i, nevents, m_dbgprot_event_to_string(etype), spolicy)); switch (etype) { case MDBGPROT_EVENT_KIND_VM_START: { - ppProcess->suspended = true; - ppCordb->pCallback->CreateProcess( - static_cast(ppProcess)); + pCordb->GetCallback()->CreateProcess( + static_cast(GetProcess())); } break; case MDBGPROT_EVENT_KIND_VM_DEATH: { - ppCordb->pCallback->ExitProcess( - static_cast(ppProcess)); + pCordb->GetCallback()->ExitProcess( + static_cast(GetProcess())); } break; case MDBGPROT_EVENT_KIND_THREAD_START: { - CordbThread *thread = new CordbThread(this, ppProcess, thread_id); - ppCordb->threads->Append(thread); - ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); + CordbThread *thread = new CordbThread(this, GetProcess(), thread_id); + pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); } break; case MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE: { @@ -378,185 +340,162 @@ void Connection::process_packet_internal(MdbgProtBuffer *recvbuf) { // all the callbacks call a resume, in this case that we are faking 2 // callbacks without receive command, we should not send the continue int assembly_id = - m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); if (pCorDebugAppDomain == NULL) { - pCorDebugAppDomain = new CordbAppDomain( - this, static_cast(ppProcess)); - ppProcess->Stop(false); - ppCordb->pCallback->CreateAppDomain( - static_cast(ppProcess), pCorDebugAppDomain); + pCorDebugAppDomain = new CordbAppDomain(this, GetProcess()); + GetProcess()->Stop(false); + pCordb->GetCallback()->CreateAppDomain( + static_cast(GetProcess()), pCorDebugAppDomain); } - ICorDebugAssembly *pAssembly = - new CordbAssembly(this, ppProcess, pCorDebugAppDomain, assembly_id); - ppProcess->Stop(false); - ppCordb->pCallback->LoadAssembly(pCorDebugAppDomain, pAssembly); - - ppProcess->suspended = true; - ICorDebugModule *pModule = new CordbModule( - this, ppProcess, (CordbAssembly *)pAssembly, assembly_id); - ppCordb->modules->Append(pModule); - ppCordb->pCallback->LoadModule(pCorDebugAppDomain, pModule); + CordbAssembly *pAssembly = new CordbAssembly( + this, GetProcess(), pCorDebugAppDomain, assembly_id); + CordbModule *pModule = new CordbModule( + this, GetProcess(), (CordbAssembly *)pAssembly, assembly_id); + + GetProcess()->Stop(false); + pCordb->GetCallback()->LoadAssembly(pCorDebugAppDomain, pAssembly); + + pCordb->GetCallback()->LoadModule(pCorDebugAppDomain, pModule); } break; case MDBGPROT_EVENT_KIND_BREAKPOINT: { int method_id = - m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); int64_t offset = - m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); - CordbThread *thread = findThread(ppCordb->threads, thread_id); + m_dbgprot_decode_long(recvbuf->p, &recvbuf->p, recvbuf->end); + CordbThread *thread = GetProcess()->FindThread(thread_id); if (thread == NULL) { - thread = new CordbThread(this, ppProcess, thread_id); - ppCordb->threads->Append(thread); - ppProcess->Stop(false); - ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); + thread = new CordbThread(this, GetProcess(), thread_id); + GetProcess()->Stop(false); + pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); } DWORD i = 0; - CordbFunctionBreakpoint *breakpoint; - while (i < ppCordb->breakpoints->GetCount()) { - breakpoint = (CordbFunctionBreakpoint*)ppCordb->breakpoints->Get(i); - if (breakpoint->offset == offset && - breakpoint->code->func->id == method_id) { - ppCordb->pCallback->Breakpoint( - pCorDebugAppDomain, thread, - static_cast(breakpoint)); - break; - } - i++; - } + CordbFunctionBreakpoint *breakpoint = + GetProcess()->GetBreakpointByOffsetAndFuncId(offset, method_id); + pCordb->GetCallback()->Breakpoint( + pCorDebugAppDomain, thread, + static_cast(breakpoint)); } break; case MDBGPROT_EVENT_KIND_STEP: { int method_id = - m_dbgprot_decode_id(recvbuf->buf, &recvbuf->buf, recvbuf->end); + m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); int64_t offset = - m_dbgprot_decode_long(recvbuf->buf, &recvbuf->buf, recvbuf->end); - CordbThread *thread = findThread(ppCordb->threads, thread_id); + m_dbgprot_decode_long(recvbuf->p, &recvbuf->p, recvbuf->end); + CordbThread *thread = GetProcess()->FindThread(thread_id); if (thread == NULL) { - thread = new CordbThread(this, ppProcess, thread_id); - ppCordb->threads->Append(thread); - ppProcess->Stop(false); - ppCordb->pCallback->CreateThread(pCorDebugAppDomain, thread); + thread = new CordbThread(this, GetProcess(), thread_id); + GetProcess()->Stop(false); + pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); } - ppCordb->pCallback->StepComplete(pCorDebugAppDomain, thread, - thread->stepper, STEP_NORMAL); + pCordb->GetCallback()->StepComplete(pCorDebugAppDomain, thread, + thread->GetStepper(), STEP_NORMAL); } break; default: { - LOG((LF_CORDB, LL_INFO100000, "Not implemented - %s\n", m_dbgprot_event_to_string(etype))); + LOG((LF_CORDB, LL_INFO100000, "Not implemented - %s\n", + m_dbgprot_event_to_string(etype))); } } } // m_dbgprot_buffer_free(&recvbuf); } -int Connection::process_packet(bool is_answer) { +int Connection::ProcessPacket(bool is_answer) { if (!is_answer) - process_packet_from_queue(); + ProcessPacketFromQueue(); return 1; } -void Connection::process_packet_from_queue() { +void Connection::ProcessPacketFromQueue() { DWORD i = 0; - while (i < received_packets_to_process->GetCount()) { - MdbgProtBuffer *req = - (MdbgProtBuffer *)received_packets_to_process->Get(i); + while (i < receivedPacketsToProcess->GetCount()) { + MdbgProtBuffer *req = (MdbgProtBuffer *)receivedPacketsToProcess->Get(i); if (req) { - process_packet_internal(req); - dbg_lock(); - received_packets_to_process->Set(i, NULL); - dbg_unlock(); - delete req; + ProcessPacketInternal(req); + dbg_lock(); + receivedPacketsToProcess->Set(i, NULL); + dbg_unlock(); + delete req; } i++; } - while (i < pending_eval->GetCount()) { - CordbEval *eval = (CordbEval *)pending_eval->Get(i); - if (eval) { - ReceivedReplyPacket* recvbuf = get_answer_with_error(eval->cmdId); - if (recvbuf) - eval->EvalComplete(recvbuf->buf); - dbg_lock(); - pending_eval->Set(i, NULL); - dbg_unlock(); - } - i--; - } + GetProcess()->CheckPendingEval(); } -void Connection::loop_send_receive() { +void Connection::LoopSendReceive() { DWORD thread_id; CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)receive_thread, this, 0, &thread_id); - enable_event(MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD); - enable_event(MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE); - enable_event(MDBGPROT_EVENT_KIND_THREAD_START); - enable_event(MDBGPROT_EVENT_KIND_THREAD_DEATH); - enable_event(MDBGPROT_EVENT_KIND_APPDOMAIN_UNLOAD); - enable_event(MDBGPROT_EVENT_KIND_USER_BREAK); - enable_event(MDBGPROT_EVENT_KIND_USER_LOG); - enable_event(MDBGPROT_EVENT_KIND_VM_DEATH); + EnableEvent(MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD); + EnableEvent(MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE); + EnableEvent(MDBGPROT_EVENT_KIND_THREAD_START); + EnableEvent(MDBGPROT_EVENT_KIND_THREAD_DEATH); + EnableEvent(MDBGPROT_EVENT_KIND_APPDOMAIN_UNLOAD); + EnableEvent(MDBGPROT_EVENT_KIND_USER_BREAK); + EnableEvent(MDBGPROT_EVENT_KIND_USER_LOG); + EnableEvent(MDBGPROT_EVENT_KIND_VM_DEATH); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_int(&localbuf, MAJOR_VERSION); m_dbgprot_buffer_add_int(&localbuf, MINOR_VERSION); - int cmdId = send_event(MDBGPROT_CMD_SET_VM, - MDBGPROT_CMD_VM_SET_PROTOCOL_VERSION, &localbuf); + int cmdId = SendEvent(MDBGPROT_CMD_SET_VM, + MDBGPROT_CMD_VM_SET_PROTOCOL_VERSION, &localbuf); m_dbgprot_buffer_free(&localbuf); m_dbgprot_buffer_init(&localbuf, 128); - cmdId = send_event(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_VERSION, &localbuf); + cmdId = SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_VERSION, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = get_answer(cmdId); + MdbgProtBuffer *bAnswer = GetAnswer(cmdId); char *vm_version = - m_dbgprot_decode_string(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); int major_version = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); int minor_version = - m_dbgprot_decode_int(bAnswer->buf, &bAnswer->buf, bAnswer->end); + m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); LOG((LF_CORDB, LL_INFO100000, "Protocol version %d.%d, server protocol version %d.%d.\n", MAJOR_VERSION, MINOR_VERSION, major_version, minor_version)); - + free(vm_version); int iResult = 0; // Receive until the peer closes the connection do { - iResult = process_packet(); + iResult = ProcessPacket(); Sleep(100); } while (iResult >= 0); } -void Connection::enable_event(MdbgProtEventKind eventKind) { +void Connection::EnableEvent(MdbgProtEventKind eventKind) { MdbgProtBuffer sendbuf; int buflen = 128; m_dbgprot_buffer_init(&sendbuf, buflen); m_dbgprot_buffer_add_byte(&sendbuf, eventKind); m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); m_dbgprot_buffer_add_byte(&sendbuf, 0); // modifiers - send_event(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, - &sendbuf); + SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, + &sendbuf); m_dbgprot_buffer_free(&sendbuf); } -void Connection::close_connection() { - connect_socket->Close(); -} +void Connection::CloseConnection() { socket->Close(); } -void Connection::start_connection() { +void Connection::StartConnection() { LOG((LF_CORDB, LL_INFO100000, "Start Connection\n")); - connect_socket = new Socket(); + socket = new Socket(); - LOG((LF_CORDB, LL_INFO100000, "Listening to 127.0.0.1:1003\n")); + LOG((LF_CORDB, LL_INFO100000, "Listening to %s:%s\n", DEBUG_ADDRESS, + DEBUG_PORT)); - int ret = connect_socket->OpenSocketAcceptConnection("127.0.0.1", "1003"); + int ret = socket->OpenSocketAcceptConnection(DEBUG_ADDRESS, DEBUG_PORT); if (ret == -1) exit(1); LOG((LF_CORDB, LL_INFO100000, "Accepted connection from client.\n")); } -void Connection::transport_handshake() { +void Connection::TransportHandshake() { int buflen = 128; MdbgProtBuffer sendbuf; @@ -566,38 +505,27 @@ void Connection::transport_handshake() { m_dbgprot_buffer_init(&recvbuf, buflen); int iResult; - iResult = connect_socket->Receive((char *)recvbuf.buf, buflen); + iResult = socket->Receive((char *)recvbuf.buf, buflen); // Send an initial buffer m_dbgprot_buffer_add_data(&sendbuf, (uint8_t *)"DWP-Handshake", 13); - send_packet(sendbuf); + SendPacket(sendbuf); + m_dbgprot_buffer_free(&sendbuf); + m_dbgprot_buffer_free(&recvbuf); } -void Connection::send_packet(MdbgProtBuffer &sendbuf) { - int iResult = connect_socket->Send((const char *)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf)); +void Connection::SendPacket(MdbgProtBuffer &sendbuf) { + int iResult = + socket->Send((const char *)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf)); if (iResult == -1) { return; } } -void Connection::receive_packet(MdbgProtBuffer &recvbuf, int len) { - m_dbgprot_buffer_init(&recvbuf, len); - int iResult; - iResult = connect_socket->Receive((char *)recvbuf.buf, len); -} - -void Connection::receive_header(MdbgProtHeader *header) { - MdbgProtBuffer recvbuf; - m_dbgprot_buffer_init(&recvbuf, 11); - int iResult; - iResult = connect_socket->Receive((char *)recvbuf.buf, HEADER_LENGTH); - m_dbgprot_decode_command_header(&recvbuf, header); -} - -int Connection::send_event(int cmd_set, int cmd, MdbgProtBuffer *sendbuf) { +int Connection::SendEvent(int cmd_set, int cmd, MdbgProtBuffer *sendbuf) { MdbgProtBuffer outbuf; int ret = m_dbgprot_buffer_add_command_header(sendbuf, cmd_set, cmd, &outbuf); - send_packet(outbuf); + SendPacket(outbuf); return ret; } @@ -615,21 +543,46 @@ MONO_API HRESULT CreateCordbObject(int iDebuggerVersion, void **ppCordb) { return S_OK; } -HRESULT CordbModule::GetAssembly( - /* [out] */ ICorDebugAssembly **ppAssembly) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetAssembly - IMPLEMENTED\n")); - *ppAssembly = static_cast(pAssembly); - return S_OK; +CordbBaseMono::CordbBaseMono(Connection *conn) { + this->conn = conn; + m_cRef = 0; + m_cRefInternal = 0; + LOG((LF_CORDB, LL_INFO100000, "%s - New - %p\n", GetClassName(), this)); } -HRESULT CordbAssembly::GetProcess( - /* [out] */ ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO1000000, - "CorDebugAssembly - GetProcess - IMPLEMENTED\n")); - *ppProcess = static_cast(pProcess); - return S_OK; +CordbBaseMono::~CordbBaseMono() {} + +ULONG CordbBaseMono::InternalAddRef() { + return InterlockedIncrement(&m_cRefInternal); +} + +ULONG CordbBaseMono::InternalRelease() { + ULONG cRef = InterlockedDecrement(&m_cRefInternal); + LOG(( + LF_CORDB, LL_INFO100000, + "%s - InternalRelease - Decrement - EXTERNAL - %d - INTERNAL - %d - %p\n", + GetClassName(), m_cRef, cRef, this)); + if (cRef == 0 && m_cRef == 0) { + LOG((LF_CORDB, LL_INFO100000, "%s - InternalRelease - Delete - %p\n", + GetClassName(), this)); + delete this; + } + return cRef; } -CordbBaseMono::CordbBaseMono(Connection *conn) { this->conn = conn; } +ULONG CordbBaseMono::BaseAddRef() { return InterlockedIncrement(&m_cRef); } + +ULONG CordbBaseMono::BaseRelease() { + ULONG cRef = InterlockedDecrement(&m_cRef); + LOG((LF_CORDB, LL_INFO100000, + "%s - Release - Decrement - EXTERNAL - %d - INTERNAL - %d - %p\n", + GetClassName(), cRef, m_cRefInternal, this)); + if (cRef == 0 && m_cRefInternal == 0) { + LOG((LF_CORDB, LL_INFO100000, "%s - Release - Delete - %p\n", + GetClassName(), this)); + delete this; + } + return cRef; +} void CordbBaseMono::SetConnection(Connection *conn) { this->conn = conn; } diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 808e4e774d6ad3..8560e06a1cf8aa 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -29,21 +29,17 @@ return S_FALSE; \ } while (0) +static UTSemReadWrite *m_pSemReadWrite; -static UTSemReadWrite* m_pSemReadWrite = new UTSemReadWrite(); - -#define dbg_lock() m_pSemReadWrite->LockRead(); -#define dbg_unlock() m_pSemReadWrite->UnlockRead(); - -/*#define dbg_lock() mono_os_mutex_lock(&debug_mutex.m); -#define dbg_unlock() mono_os_mutex_unlock(&debug_mutex.m); -static MonoCoopMutex debug_mutex;*/ +#define dbg_lock() m_pSemReadWrite->LockRead(); +#define dbg_unlock() m_pSemReadWrite->UnlockRead(); #ifdef _DEBUG #define LOGGING -#include "log.h" #endif +#include "log.h" + #include "arraylist.h" #define CreateProcess CreateProcessW @@ -53,145 +49,140 @@ class Cordb; class CordbProcess; class CordbAppDomain; class CordbAssembly; +class CordbModule; class CordbCode; class CordbThread; class CordbFunction; class CordbStepper; class RegMeta; -class CordbRegisteSet; +class CordbRegisterSet; class CordbClass; - -typedef struct ReceivedReplyPacket { +class CordbNativeFrame; +class CordbAppDomainEnum; +class CordbTypeEnum; +class CordbBlockingObjectEnum; +class CordbFunctionBreakpoint; +class CordbEval; + +class ReceivedReplyPacket { int error; int error_2; int id; MdbgProtBuffer *buf; -} ReceivedReplyPacket; - -int convert_mono_type_2_icordbg_size(int type); -class Cordb : public ICorDebug, public ICorDebugRemote { public: - ArrayList *breakpoints; - ArrayList *threads; - ArrayList *functions; - ArrayList *modules; - - ICorDebugManagedCallback *pCallback; - Cordb(); - - CordbFunction *findFunction(int id); - CordbFunction *findFunctionByToken(int token); - HRESULT Initialize(void); - - HRESULT Terminate(void); - - HRESULT SetManagedHandler( - /* [in] */ ICorDebugManagedCallback *pCallback); - - HRESULT SetUnmanagedHandler( - /* [in] */ ICorDebugUnmanagedCallback *pCallback); - - HRESULT CreateProcess( - /* [in] */ LPCWSTR lpApplicationName, - /* [in] */ LPWSTR lpCommandLine, - /* [in] */ LPSECURITY_ATTRIBUTES lpProcessAttributes, - /* [in] */ LPSECURITY_ATTRIBUTES lpThreadAttributes, - /* [in] */ BOOL bInheritHandles, - /* [in] */ DWORD dwCreationFlags, - /* [in] */ PVOID lpEnvironment, - /* [in] */ LPCWSTR lpCurrentDirectory, - /* [in] */ LPSTARTUPINFOW lpStartupInfo, - /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, - /* [in] */ CorDebugCreateProcessFlags debuggingFlags, - /* [out] */ ICorDebugProcess **ppProcess); - - HRESULT DebugActiveProcess( - /* [in] */ DWORD id, - /* [in] */ BOOL win32Attach, - /* [out] */ ICorDebugProcess **ppProcess); - HRESULT EnumerateProcesses( - /* [out] */ ICorDebugProcessEnum **ppProcess); - - HRESULT GetProcess( - /* [in] */ DWORD dwProcessId, - /* [out] */ ICorDebugProcess **ppProcess); - - HRESULT CanLaunchOrAttach( - /* [in] */ DWORD dwProcessId, - /* [in] */ BOOL win32DebuggingEnabled); - HRESULT QueryInterface( - /* [in] */ REFIID riid, - /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG AddRef(void); - ULONG Release(void); - HRESULT CreateProcessEx( - /* [in] */ ICorDebugRemoteTarget *pRemoteTarget, - /* [in] */ LPCWSTR lpApplicationName, - /* [annotation][in] */ - _In_ LPWSTR lpCommandLine, - /* [in] */ LPSECURITY_ATTRIBUTES lpProcessAttributes, - /* [in] */ LPSECURITY_ATTRIBUTES lpThreadAttributes, - /* [in] */ BOOL bInheritHandles, - /* [in] */ DWORD dwCreationFlags, - /* [in] */ PVOID lpEnvironment, - /* [in] */ LPCWSTR lpCurrentDirectory, - /* [in] */ LPSTARTUPINFOW lpStartupInfo, - /* [in] */ LPPROCESS_INFORMATION lpProcessInformation, - /* [in] */ CorDebugCreateProcessFlags debuggingFlags, - /* [out] */ ICorDebugProcess **ppProcess); - - HRESULT DebugActiveProcessEx( - /* [in] */ ICorDebugRemoteTarget *pRemoteTarget, - /* [in] */ DWORD dwProcessId, - /* [in] */ BOOL fWin32Attach, - /* [out] */ ICorDebugProcess **ppProcess); - HRESULT GetModule(int module_id, ICorDebugModule** pModule); + ReceivedReplyPacket(int error, int error_2, int id, MdbgProtBuffer *buf); + ~ReceivedReplyPacket(); + MdbgProtBuffer *Buffer() { return buf; } + int Error() { return error; } + int Error2() { return error_2; } + int Id() { return id; } }; +int convert_mono_type_2_icordbg_size(int type); + class Connection { - Socket *connect_socket; - bool is_answer_pending; + Socket *socket; + CordbProcess *pProcess; + Cordb *pCordb; + ArrayList *receiveReplies; + ArrayList *pendingEval; + ArrayList *receivedPacketsToProcess; + void ProcessPacketInternal(MdbgProtBuffer *recvbuf); + void ProcessPacketFromQueue(); + void EnableEvent(MdbgProtEventKind eventKind); + void SendPacket(MdbgProtBuffer &sendbuf); + int ProcessPacket(bool is_answer = false); public: - CordbProcess *ppProcess; - Cordb *ppCordb; - CordbAppDomain *pCorDebugAppDomain; - ArrayList *received_replies; - ArrayList *pending_eval; - ArrayList *received_packets_to_process; + CordbProcess *GetProcess() const { return pProcess; } + Cordb *GetCordb() const { return pCordb; } Connection(CordbProcess *proc, Cordb *cordb); - void loop_send_receive(); - void process_packet_internal(MdbgProtBuffer *recvbuf); - void process_packet_from_queue(); - void enable_event(MdbgProtEventKind eventKind); - void close_connection(); - void start_connection(); - void transport_handshake(); - void receive(); - void send_packet(MdbgProtBuffer &sendbuf); - void receive_packet(MdbgProtBuffer &b, int len); - void receive_header(MdbgProtHeader *header); - int send_event(int cmd_set, int cmd, MdbgProtBuffer *sendbuf); - int process_packet(bool is_answer = false); - MdbgProtBuffer *get_answer(int cmdId); - ReceivedReplyPacket *get_answer_with_error(int cmdId); - CordbThread *findThread(ArrayList *threads, long thread_id); + ~Connection(); + + void LoopSendReceive(); + void CloseConnection(); + void StartConnection(); + void TransportHandshake(); + void Receive(); + + int SendEvent(int cmd_set, int cmd, MdbgProtBuffer *sendbuf); + MdbgProtBuffer *GetAnswer(int cmdId); + ReceivedReplyPacket *GetAnswerWithError(int cmdId); + CordbAppDomain *GetCurrentAppDomain(); }; class CordbBaseMono { protected: Connection *conn; - + ULONG m_cRef; // Ref count. + ULONG m_cRefInternal; // Ref count. public: CordbBaseMono(Connection *conn); + virtual ~CordbBaseMono(); void SetConnection(Connection *conn); + ULONG BaseAddRef(void); + ULONG BaseRelease(void); + ULONG InternalAddRef(void); + ULONG InternalRelease(void); + virtual const char *GetClassName() { return "CordbBaseMono"; } +}; + +class Cordb : public ICorDebug, public ICorDebugRemote, public CordbBaseMono { + ICorDebugManagedCallback *m_pCallback; + CordbProcess *m_pProcess; + +public: + ICorDebugManagedCallback *GetCallback() const { return m_pCallback; } + Cordb(); + ULONG AddRef(void) { return (BaseAddRef()); } + ULONG Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "Cordb"; } + ~Cordb(); + + HRESULT Initialize(void); + + HRESULT Terminate(void); + + HRESULT SetManagedHandler(ICorDebugManagedCallback *pCallback); + + HRESULT SetUnmanagedHandler(ICorDebugUnmanagedCallback *pCallback); + + HRESULT CreateProcess(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, DWORD dwCreationFlags, + PVOID lpEnvironment, LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + CorDebugCreateProcessFlags debuggingFlags, + ICorDebugProcess **ppProcess); + + HRESULT DebugActiveProcess(DWORD id, BOOL win32Attach, + ICorDebugProcess **ppProcess); + HRESULT EnumerateProcesses(ICorDebugProcessEnum **ppProcess); + + HRESULT GetProcess(DWORD dwProcessId, ICorDebugProcess **ppProcess); + + HRESULT CanLaunchOrAttach(DWORD dwProcessId, BOOL win32DebuggingEnabled); + HRESULT QueryInterface(REFIID riid, + _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject); + HRESULT CreateProcessEx( + ICorDebugRemoteTarget *pRemoteTarget, LPCWSTR lpApplicationName, + _In_ LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, + DWORD dwCreationFlags, PVOID lpEnvironment, LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation, + CorDebugCreateProcessFlags debuggingFlags, ICorDebugProcess **ppProcess); + + HRESULT DebugActiveProcessEx(ICorDebugRemoteTarget *pRemoteTarget, + DWORD dwProcessId, BOOL fWin32Attach, + ICorDebugProcess **ppProcess); }; #define CHECK_ERROR_RETURN_FALSE(localbuf) \ do { \ - if (localbuf->error > 0 || localbuf->error_2 > 0) { \ + if (localbuf->Error() > 0 || localbuf->Error2() > 0) { \ LOG((LF_CORDB, LL_INFO100000, "ERROR RECEIVED\n")); \ return S_FALSE; \ } \ diff --git a/src/mono/dbi/debugger-coreclr-compat.h b/src/mono/dbi/debugger-coreclr-compat.h index 0d9f9654a621e8..93deb5a604ed70 100644 --- a/src/mono/dbi/debugger-coreclr-compat.h +++ b/src/mono/dbi/debugger-coreclr-compat.h @@ -13,13 +13,9 @@ #define g_realloc realloc #include "stdafx.h" -static -inline -int32_t -dbg_rt_atomic_inc_int32_t (volatile int32_t *value) -{ - STATIC_CONTRACT_NOTHROW; - return static_cast(InterlockedIncrement ((volatile LONG *)(value))); +static inline int32_t dbg_rt_atomic_inc_int32_t(volatile int32_t *value) { + STATIC_CONTRACT_NOTHROW; + return static_cast(InterlockedIncrement((volatile LONG *)(value))); } #endif \ No newline at end of file diff --git a/src/mono/dbi/socket-dbi/socket.cpp b/src/mono/dbi/socket-dbi/socket.cpp index 9507fa58018a8f..2dc78e6795f976 100644 --- a/src/mono/dbi/socket-dbi/socket.cpp +++ b/src/mono/dbi/socket-dbi/socket.cpp @@ -27,6 +27,11 @@ #endif +Socket::~Socket() +{ + Close(); +} + int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { socketId = -1; @@ -51,7 +56,7 @@ int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { socketId = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); if (socketId == -1) { - return socketId; + return -1; } int flag = 1; diff --git a/src/mono/dbi/socket-dbi/socket.h b/src/mono/dbi/socket-dbi/socket.h index 5b536e4b53c315..62e321fe249f81 100644 --- a/src/mono/dbi/socket-dbi/socket.h +++ b/src/mono/dbi/socket-dbi/socket.h @@ -8,8 +8,9 @@ #define __SOCKET_DBI_H__ class Socket { - int socketId; + long long socketId; public: + ~Socket(); int OpenSocketAcceptConnection(const char *address, const char *port); void Close(); int Receive(char *buff, int buflen); diff --git a/src/mono/mono/mini/debugger-protocol.c b/src/mono/mono/mini/debugger-protocol.c index 9294b49982b254..8afa9f2c39e784 100644 --- a/src/mono/mono/mini/debugger-protocol.c +++ b/src/mono/mono/mini/debugger-protocol.c @@ -30,16 +30,16 @@ m_dbgprot_buffer_add_command_header (MdbgProtBuffer *data, int command_set, int void m_dbgprot_decode_command_header (MdbgProtBuffer *recvbuf, MdbgProtHeader *header) { - header->len = m_dbgprot_decode_int (recvbuf->buf, &recvbuf->buf, recvbuf->end); - header->id = m_dbgprot_decode_int (recvbuf->buf, &recvbuf->buf, recvbuf->end); - header->flags = m_dbgprot_decode_byte (recvbuf->buf, &recvbuf->buf, recvbuf->end); + header->len = m_dbgprot_decode_int (recvbuf->p, &recvbuf->p, recvbuf->end); + header->id = m_dbgprot_decode_int (recvbuf->p, &recvbuf->p, recvbuf->end); + header->flags = m_dbgprot_decode_byte (recvbuf->p, &recvbuf->p, recvbuf->end); if (header->flags == REPLY_PACKET) { - header->error = m_dbgprot_decode_byte (recvbuf->buf, &recvbuf->buf, recvbuf->end); - header->error_2 = m_dbgprot_decode_byte (recvbuf->buf, &recvbuf->buf, recvbuf->end); + header->error = m_dbgprot_decode_byte (recvbuf->p, &recvbuf->p, recvbuf->end); + header->error_2 = m_dbgprot_decode_byte (recvbuf->p, &recvbuf->p, recvbuf->end); } else { - header->command_set = m_dbgprot_decode_byte (recvbuf->buf, &recvbuf->buf, recvbuf->end); - header->command = m_dbgprot_decode_byte (recvbuf->buf, &recvbuf->buf, recvbuf->end); + header->command_set = m_dbgprot_decode_byte (recvbuf->p, &recvbuf->p, recvbuf->end); + header->command = m_dbgprot_decode_byte (recvbuf->p, &recvbuf->p, recvbuf->end); } } From 12127b9e5c8229b01617856282906062c40680bf Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Fri, 19 Feb 2021 17:07:25 -0300 Subject: [PATCH 11/64] Checking error when get reply from debugger --- src/mono/dbi/cordb-assembly.cpp | 21 +++- src/mono/dbi/cordb-code.cpp | 14 ++- src/mono/dbi/cordb-eval.cpp | 15 ++- src/mono/dbi/cordb-eval.h | 2 +- src/mono/dbi/cordb-frame.cpp | 29 +++-- src/mono/dbi/cordb-function.cpp | 15 ++- src/mono/dbi/cordb-process.cpp | 2 +- src/mono/dbi/cordb-stepper.cpp | 12 +- src/mono/dbi/cordb-thread.cpp | 16 ++- src/mono/dbi/cordb-value.cpp | 204 +++++++++++++++++++++----------- src/mono/dbi/cordb-value.h | 5 +- src/mono/dbi/cordb.cpp | 53 ++------- src/mono/dbi/cordb.h | 12 +- 13 files changed, 234 insertions(+), 166 deletions(-) diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 6eae2102120ed7..267654b6fb7c0c 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -188,9 +188,12 @@ HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS *pAddress) { MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array( - bAnswer->p, &bAnswer->p, bAnswer->end, &m_assemblyMetadataLen); + pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); @@ -209,9 +212,12 @@ HRESULT CordbModule::GetName(ULONG32 cchName, ULONG32 *pcchName, MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + char *assembly_name = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); if (cchName < strlen(assembly_name) + 1) { *pcchName = (ULONG32)strlen(assembly_name) + 1; @@ -251,8 +257,11 @@ HRESULT CordbModule::GetFunctionFromToken(mdMethodDef methodDef, MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + int id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); CordbFunction *func = NULL; func = m_pProcess->FindFunction(id); if (func == NULL) { diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index ea1c4b25827044..72414c7677f572 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -42,8 +42,11 @@ HRESULT __stdcall CordbCode::GetSize(ULONG32 *pcBytes) { MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int code_size = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + int code_size = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); *pcBytes = code_size; LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetSize - IMPLEMENTED\n")); return S_OK; @@ -70,9 +73,12 @@ HRESULT __stdcall CordbCode::GetCode(ULONG32 startOffset, ULONG32 endOffset, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + uint8_t *code = m_dbgprot_decode_byte_array( - bAnswer->p, &bAnswer->p, bAnswer->end, (int32_t *)pcBufferSize); + pReply->p, &pReply->p, pReply->end, (int32_t *)pcBufferSize); memcpy(buffer, code, *pcBufferSize); free(code); diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index f46b5dc7e54817..431f1920c8cf15 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -88,10 +88,10 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( return S_OK; } -void CordbEval::EvalComplete(MdbgProtBuffer *bAnswer) { +void CordbEval::EvalComplete(MdbgProtBuffer *pReply) { - m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); - CordbObjectValue::CreateCordbValue(conn, bAnswer, &m_pValue); + m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + CordbObjectValue::CreateCordbValue(conn, pReply, &m_pValue); conn->GetCordb()->GetCallback()->EvalComplete( conn->GetProcess()->GetCurrentAppDomain(), m_pThread, this); @@ -137,8 +137,11 @@ HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int domainId = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + int domainId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); LPSTR szString; UTF8STR(string, szString); @@ -239,7 +242,7 @@ HRESULT STDMETHODCALLTYPE CordbEval::CreateValue(CorElementType elementType, content_value.booleanValue = 0; CordbValue *value = new CordbValue(conn, elementType, content_value, - convert_mono_type_2_icordbg_size(elementType)); + CordbObjectValue::GetTypeSize(elementType)); LOG((LF_CORDB, LL_INFO1000000, "CordbEval - CreateValue - IMPLEMENTED\n")); value->QueryInterface(IID_ICorDebugValue, (void **)ppValue); return S_OK; diff --git a/src/mono/dbi/cordb-eval.h b/src/mono/dbi/cordb-eval.h index 5c4d1b244bbf5e..2af68c39b2c38e 100644 --- a/src/mono/dbi/cordb-eval.h +++ b/src/mono/dbi/cordb-eval.h @@ -19,7 +19,7 @@ class CordbEval : public CordbBaseMono, public: CordbEval(Connection *conn, CordbThread *thread); ~CordbEval(); - void EvalComplete(MdbgProtBuffer *bAnswer); + void EvalComplete(MdbgProtBuffer *pReply); HRESULT CallParameterizedFunction(ICorDebugFunction *pFunction, ULONG32 nTypeArgs, diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index 1fa6912b73e091..885c710583ba01 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -69,16 +69,19 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG *pcelt) { MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - m_nFrames = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + m_nFrames = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); m_ppFrames = (CordbNativeFrame **)malloc(sizeof(CordbNativeFrame *) * m_nFrames); for (int i = 0; i < m_nFrames; i++) { - int frameid = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); - int methodId = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int il_offset = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); - int flags = m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); + int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); CordbNativeFrame *frame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, m_pThread); @@ -264,8 +267,11 @@ CordbJITILFrame::GetLocalVariable(DWORD dwIndex, ICorDebugValue **ppValue) { MDBGPROT_CMD_STACK_FRAME_GET_VALUES, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - return CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + return CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); } HRESULT STDMETHODCALLTYPE @@ -287,9 +293,12 @@ CordbJITILFrame::GetArgument(DWORD dwIndex, ICorDebugValue **ppValue) { MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetArgument - IMPLEMENTED\n")); - return CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); + return CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackDepth(ULONG32 *pDepth) { diff --git a/src/mono/dbi/cordb-function.cpp b/src/mono/dbi/cordb-function.cpp index 55a28de305a81d..f61ad43a011050 100644 --- a/src/mono/dbi/cordb-function.cpp +++ b/src/mono/dbi/cordb-function.cpp @@ -61,9 +61,12 @@ HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule **ppModule) { MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = + conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - int module_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); m_pModule = conn->GetProcess()->GetModule(module_id); if (m_pModule) m_pModule->InternalAddRef(); @@ -92,10 +95,14 @@ HRESULT __stdcall CordbFunction::GetToken(mdMethodDef *pMethodDef) { int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_TOKEN, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + + ReceivedReplyPacket *received_reply_packet = + conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); this->m_metadataToken = - m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); } *pMethodDef = this->GetMetadataToken(); return S_OK; diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index bef6dc8fcfbe6b..73429a109fad39 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -84,7 +84,7 @@ void CordbProcess::CheckPendingEval() { CordbEval *eval = (CordbEval *)m_pPendingEval->Get(i); if (eval) { ReceivedReplyPacket *recvbuf = - conn->GetAnswerWithError(eval->GetCommandId()); + conn->GetReplyWithError(eval->GetCommandId()); if (recvbuf) { eval->EvalComplete(recvbuf->Buffer()); eval->InternalRelease(); diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index d411afa5bbac91..19594a504a206e 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -76,8 +76,12 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - m_commandId = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + m_commandId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepRange - IMPLEMENTED\n")); return S_OK; @@ -101,7 +105,9 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepOut - IMPLEMENTED\n")); return S_OK; diff --git a/src/mono/dbi/cordb-thread.cpp b/src/mono/dbi/cordb-thread.cpp index b514b61082e273..f7fee7fb30cc0b 100644 --- a/src/mono/dbi/cordb-thread.cpp +++ b/src/mono/dbi/cordb-thread.cpp @@ -229,13 +229,17 @@ CordbThread::GetActiveFrame(ICorDebugFrame **ppFrame) { int cmdId = this->conn->SendEvent( MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int nframes = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + int nframes = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); if (nframes > 0) { - int frameid = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); - int methodId = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int il_offset = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); - int flags = m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); + int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); if (m_pCurrentFrame) m_pCurrentFrame->InternalRelease(); m_pCurrentFrame = diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index 999a7fdcee1b8d..bd934eeb9340b7 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -171,8 +171,13 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_TYPE, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int type_id = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + + ReceivedReplyPacket *received_reply_packet = + conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + int type_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, type_id); @@ -180,19 +185,23 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - bAnswer = conn->GetAnswer(cmdId); + + received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + pReply = received_reply_packet->Buffer(); + char *namespace_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); char *class_name_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); char *class_fullname_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); int assembly_id = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int module_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - type_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int type_id2 = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int token = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); m_pClass = new CordbClass(conn, token, assembly_id); m_pClass->InternalAddRef(); m_pCordbType = new CordbType(m_type, conn, m_pClass); @@ -212,12 +221,17 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int type_id = m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); - int rank = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + + ReceivedReplyPacket *received_reply_packet = + conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + + int type_id = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); if (type_id == ELEMENT_TYPE_CLASS) { int klass_id = - m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, klass_id); @@ -225,20 +239,24 @@ CordbReferenceValue::GetExactType(ICorDebugType **ppType) { cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - bAnswer = conn->GetAnswer(cmdId); + + received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + pReply = received_reply_packet->Buffer(); + char *namespace_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); char *class_name_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); char *class_fullname_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); int assembly_id = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int module_id = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int type_id3 = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int type_id2 = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int token = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); m_pClass = new CordbClass(conn, token, module_id); m_pClass->InternalAddRef(); free(namespace_str); @@ -443,9 +461,14 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32 *pcchString) { int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + + ReceivedReplyPacket *received_reply_packet = + conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + *pcchString = - (ULONG32)m_dbgprot_decode_long(bAnswer->p, &bAnswer->p, bAnswer->end); + (ULONG32)m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); return S_OK; } return E_NOTIMPL; @@ -464,16 +487,21 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_VALUE, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); + + ReceivedReplyPacket *received_reply_packet = + conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + *pcchString = cchString; int use_utf16 = - m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); if (use_utf16) { LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n")); } else { char *value = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetString - IMPLEMENTED\n")); if (cchString >= strlen(value)) { @@ -568,26 +596,51 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue( MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetAnswerWithError(cmdId); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *bAnswer = received_reply_packet->Buffer(); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - return CreateCordbValue(conn, bAnswer, ppValue); + return CreateCordbValue(conn, pReply, ppValue); +} + +int CordbObjectValue::GetTypeSize(int type) { + switch (type) { + case ELEMENT_TYPE_VOID: + return 0; + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + return 1; + break; + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + return 2; + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: + return 4; + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: + return 8; + } + return 0; } HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, - MdbgProtBuffer *bAnswer, + MdbgProtBuffer *pReply, ICorDebugValue **ppValue) { CorElementType type = (CorElementType)m_dbgprot_decode_byte( - bAnswer->p, &bAnswer->p, bAnswer->end); + pReply->p, &pReply->p, pReply->end); CordbContent value; if ((MdbgProtValueTypeId)type == MDBGPROT_VALUE_TYPE_ID_NULL) { CorElementType type = (CorElementType)m_dbgprot_decode_byte( - bAnswer->p, &bAnswer->p, bAnswer->end); + pReply->p, &pReply->p, pReply->end); if (type == ELEMENT_TYPE_CLASS || type == ELEMENT_TYPE_STRING) { int klass_id = (CorElementType)m_dbgprot_decode_id( - bAnswer->p, &bAnswer->p, bAnswer->end); + pReply->p, &pReply->p, pReply->end); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); @@ -595,20 +648,23 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - bAnswer = conn->GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = + conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); char *namespace_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); char *class_name_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); char *class_fullname_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); int assembly_id = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int module_id = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int type_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int type_id2 = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int token = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); CordbClass *klass = new CordbClass(conn, token, module_id); CordbReferenceValue *refValue = @@ -621,10 +677,10 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, if (type == ELEMENT_TYPE_SZARRAY) { CordbClass *klass = NULL; int type_id = - m_dbgprot_decode_byte(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); if (type_id == ELEMENT_TYPE_CLASS) { int klass_id = - m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); @@ -632,22 +688,25 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); - bAnswer = conn->GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = + conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); char *namespace_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); char *class_name_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); char *class_fullname_str = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); int assembly_id = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int module_id = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int type_id3 = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int type_id2 = - m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); - int token = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); klass = new CordbClass(conn, token, module_id); free(namespace_str); free(class_name_str); @@ -668,30 +727,30 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, case ELEMENT_TYPE_I1: case ELEMENT_TYPE_U1: value.booleanValue = - m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); break; case ELEMENT_TYPE_CHAR: case ELEMENT_TYPE_I2: case ELEMENT_TYPE_U2: value.charValue = - m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: case ELEMENT_TYPE_R4: value.intValue = - m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: case ELEMENT_TYPE_R8: value.longValue = - m_dbgprot_decode_long(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); break; case ELEMENT_TYPE_CLASS: case ELEMENT_TYPE_SZARRAY: case ELEMENT_TYPE_STRING: { - int object_id = m_dbgprot_decode_id(bAnswer->p, &bAnswer->p, bAnswer->end); + int object_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); CordbReferenceValue *refValue = new CordbReferenceValue(conn, type, object_id); refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); @@ -702,8 +761,7 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, return S_FALSE; } - *ppValue = - new CordbValue(conn, type, value, convert_mono_type_2_icordbg_size(type)); + *ppValue = new CordbValue(conn, type, value, GetTypeSize(type)); (*ppValue)->AddRef(); return S_OK; } @@ -1041,8 +1099,10 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetRank(ULONG32 *pnRank) { int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int rank = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetRank - IMPLEMENTED\n")); *pnRank = rank; return S_OK; @@ -1056,9 +1116,11 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCount(ULONG32 *pnCount) { int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - int rank = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); - m_nCount = m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_nCount = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetCount - IMPLEMENTED\n")); *pnCount = m_nCount; return S_OK; @@ -1100,8 +1162,10 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement( int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = conn->GetAnswer(cmdId); - CordbObjectValue::CreateCordbValue(conn, bAnswer, ppValue); + ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); return S_OK; } diff --git a/src/mono/dbi/cordb-value.h b/src/mono/dbi/cordb-value.h index a6787942b96606..b43fc753ea5524 100644 --- a/src/mono/dbi/cordb-value.h +++ b/src/mono/dbi/cordb-value.h @@ -109,10 +109,9 @@ class CordbObjectValue : public CordbBaseMono, HRESULT GetClass(ICorDebugClass **ppClass); HRESULT GetFieldValue(ICorDebugClass *pClass, mdFieldDef fieldDef, ICorDebugValue **ppValue); - - static HRESULT CreateCordbValue(Connection *conn, MdbgProtBuffer *bAnswer, + static HRESULT CreateCordbValue(Connection *conn, MdbgProtBuffer *pReply, ICorDebugValue **ppValue); - + static int GetTypeSize(int type); HRESULT GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction **ppFunction); HRESULT GetContext(ICorDebugContext **ppContext); diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 7272c54714fce7..7561a5e5ed7233 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -19,31 +19,6 @@ #define DEBUG_ADDRESS "127.0.0.1" #define DEBUG_PORT "4712" -int convert_mono_type_2_icordbg_size(int type) { - switch (type) { - case ELEMENT_TYPE_VOID: - return 0; - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_I1: - case ELEMENT_TYPE_U1: - return 1; - break; - case ELEMENT_TYPE_CHAR: - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - return 2; - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - case ELEMENT_TYPE_R4: - return 4; - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - case ELEMENT_TYPE_R8: - return 8; - } - return 0; -} - MONO_API HRESULT CoreCLRCreateCordbObjectEx(int iDebuggerVersion, DWORD pid, LPCWSTR lpApplicationGroupId, HMODULE hmodTargetCLR, @@ -272,7 +247,7 @@ void Connection::Receive() { } } -MdbgProtBuffer *Connection::GetAnswer(int cmdId) { +MdbgProtBuffer *Connection::GetReply(int cmdId) { ReceivedReplyPacket *rrp = NULL; while (rrp == NULL || rrp->Id() != cmdId) { dbg_lock(); @@ -286,7 +261,7 @@ MdbgProtBuffer *Connection::GetAnswer(int cmdId) { return rrp->Buffer(); } -ReceivedReplyPacket *Connection::GetAnswerWithError(int cmdId) { +ReceivedReplyPacket *Connection::GetReplyWithError(int cmdId) { ReceivedReplyPacket *rrp = NULL; while (rrp == NULL || rrp->Id() != cmdId) { dbg_lock(); @@ -446,13 +421,15 @@ void Connection::LoopSendReceive() { cmdId = SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_VERSION, &localbuf); m_dbgprot_buffer_free(&localbuf); - MdbgProtBuffer *bAnswer = GetAnswer(cmdId); + ReceivedReplyPacket *received_reply_packet = GetReplyWithError(cmdId); + MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + char *vm_version = - m_dbgprot_decode_string(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); int major_version = - m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); int minor_version = - m_dbgprot_decode_int(bAnswer->p, &bAnswer->p, bAnswer->end); + m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); LOG((LF_CORDB, LL_INFO100000, "Protocol version %d.%d, server protocol version %d.%d.\n", @@ -532,13 +509,11 @@ int Connection::SendEvent(int cmd_set, int cmd, MdbgProtBuffer *sendbuf) { MONO_API HRESULT CoreCLRCreateCordbObject(int iDebuggerVersion, DWORD pid, HMODULE hmodTargetCLR, void **ppCordb) { - LOG((LF_CORDB, LL_INFO100000, "CoreCLRCreateCordbObject\n")); *ppCordb = new Cordb(); return S_OK; } MONO_API HRESULT CreateCordbObject(int iDebuggerVersion, void **ppCordb) { - LOG((LF_CORDB, LL_INFO100000, "CreateCordbObject\n")); *ppCordb = new Cordb(); return S_OK; } @@ -547,7 +522,6 @@ CordbBaseMono::CordbBaseMono(Connection *conn) { this->conn = conn; m_cRef = 0; m_cRefInternal = 0; - LOG((LF_CORDB, LL_INFO100000, "%s - New - %p\n", GetClassName(), this)); } CordbBaseMono::~CordbBaseMono() {} @@ -558,13 +532,7 @@ ULONG CordbBaseMono::InternalAddRef() { ULONG CordbBaseMono::InternalRelease() { ULONG cRef = InterlockedDecrement(&m_cRefInternal); - LOG(( - LF_CORDB, LL_INFO100000, - "%s - InternalRelease - Decrement - EXTERNAL - %d - INTERNAL - %d - %p\n", - GetClassName(), m_cRef, cRef, this)); if (cRef == 0 && m_cRef == 0) { - LOG((LF_CORDB, LL_INFO100000, "%s - InternalRelease - Delete - %p\n", - GetClassName(), this)); delete this; } return cRef; @@ -574,12 +542,7 @@ ULONG CordbBaseMono::BaseAddRef() { return InterlockedIncrement(&m_cRef); } ULONG CordbBaseMono::BaseRelease() { ULONG cRef = InterlockedDecrement(&m_cRef); - LOG((LF_CORDB, LL_INFO100000, - "%s - Release - Decrement - EXTERNAL - %d - INTERNAL - %d - %p\n", - GetClassName(), cRef, m_cRefInternal, this)); if (cRef == 0 && m_cRefInternal == 0) { - LOG((LF_CORDB, LL_INFO100000, "%s - Release - Delete - %p\n", - GetClassName(), this)); delete this; } return cRef; diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 8560e06a1cf8aa..9a8c7a2dcdbedb 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -79,15 +79,13 @@ class ReceivedReplyPacket { int Id() { return id; } }; -int convert_mono_type_2_icordbg_size(int type); - class Connection { Socket *socket; CordbProcess *pProcess; Cordb *pCordb; - ArrayList *receiveReplies; - ArrayList *pendingEval; - ArrayList *receivedPacketsToProcess; + ArrayList *receiveReplies; //TODO use hashmap + ArrayList *pendingEval; //TODO use hashmap + ArrayList *receivedPacketsToProcess; //TODO use hashmap void ProcessPacketInternal(MdbgProtBuffer *recvbuf); void ProcessPacketFromQueue(); void EnableEvent(MdbgProtEventKind eventKind); @@ -107,8 +105,8 @@ class Connection { void Receive(); int SendEvent(int cmd_set, int cmd, MdbgProtBuffer *sendbuf); - MdbgProtBuffer *GetAnswer(int cmdId); - ReceivedReplyPacket *GetAnswerWithError(int cmdId); + MdbgProtBuffer *GetReply(int cmdId); + ReceivedReplyPacket *GetReplyWithError(int cmdId); CordbAppDomain *GetCurrentAppDomain(); }; From 217dc721ffa77ddfb51f94e83ed715e9bb461106 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Mon, 22 Feb 2021 12:03:00 -0300 Subject: [PATCH 12/64] Fix format, reuse regmeta from coreclr and try to fix compilation on windows --- src/mono/CMakeLists.txt | 4 +- src/mono/dbi/CMakeLists.txt | 14 +- src/mono/dbi/cordb-appdomain.cpp | 435 ++-- src/mono/dbi/cordb-appdomain.h | 152 +- src/mono/dbi/cordb-assembly.cpp | 615 +++--- src/mono/dbi/cordb-assembly.h | 176 +- src/mono/dbi/cordb-blocking-obj.cpp | 67 +- src/mono/dbi/cordb-blocking-obj.h | 34 +- src/mono/dbi/cordb-breakpoint.cpp | 110 +- src/mono/dbi/cordb-breakpoint.h | 48 +- src/mono/dbi/cordb-chain.cpp | 188 +- src/mono/dbi/cordb-chain.h | 103 +- src/mono/dbi/cordb-class.cpp | 116 +- src/mono/dbi/cordb-class.h | 44 +- src/mono/dbi/cordb-code.cpp | 161 +- src/mono/dbi/cordb-code.h | 61 +- src/mono/dbi/cordb-eval.cpp | 378 ++-- src/mono/dbi/cordb-eval.h | 101 +- src/mono/dbi/cordb-frame.cpp | 755 +++---- src/mono/dbi/cordb-frame.h | 244 ++- src/mono/dbi/cordb-function.cpp | 300 +-- src/mono/dbi/cordb-function.h | 84 +- src/mono/dbi/cordb-process.cpp | 992 +++++---- src/mono/dbi/cordb-process.h | 250 +-- src/mono/dbi/cordb-register.cpp | 62 +- src/mono/dbi/cordb-register.h | 43 +- src/mono/dbi/cordb-stepper.cpp | 207 +- src/mono/dbi/cordb-stepper.h | 49 +- src/mono/dbi/cordb-symbol.cpp | 2771 ------------------------ src/mono/dbi/cordb-symbol.h | 667 ------ src/mono/dbi/cordb-thread.cpp | 432 ++-- src/mono/dbi/cordb-thread.h | 136 +- src/mono/dbi/cordb-type.cpp | 272 +-- src/mono/dbi/cordb-type.h | 93 +- src/mono/dbi/cordb-value.cpp | 1965 +++++++++-------- src/mono/dbi/cordb-value.h | 378 ++-- src/mono/dbi/cordb.cpp | 950 ++++---- src/mono/dbi/cordb.h | 270 ++- src/mono/dbi/debugger-coreclr-compat.h | 7 +- 39 files changed, 5389 insertions(+), 8345 deletions(-) delete mode 100644 src/mono/dbi/cordb-symbol.cpp delete mode 100644 src/mono/dbi/cordb-symbol.h diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index de56fcd3bf0d82..668a62ebb662f3 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -699,7 +699,9 @@ endif() ### End of OS specific checks add_subdirectory(mono) -add_subdirectory(dbi) +if (HOST_LINUX OR HOST_WIN32 OR HOST_DARWIN) + add_subdirectory(dbi) +endif() configure_file(cmake/config.h.in config.h) configure_file(cmake/eglib-config.h.cmake.in mono/eglib/eglib-config.h) # TODO: eglib-config.h is not needed, we're using hardcoded eglib-config.hw diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index d24ef6a5048ef8..15726ab30c1bfd 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -13,6 +13,18 @@ set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") set(CLR_CMAKE_HOST_ARCH ${CMAKE_GENERATOR_PLATFORM}) +if(HOST_WIN32) + if(HOST_X86) + set(CLR_CMAKE_HOST_ARCH x86) + elseif(HOST_ARM64) + set(CLR_CMAKE_HOST_ARCH arm64) + elseif(HOST_ARM) + set(CLR_CMAKE_HOST_ARCH arm) + elseif(HOST_AMD64) + set(CLR_CMAKE_HOST_ARCH x64) + endif() +endif() + add_definitions(-DDBI_COMPONENT_MONO) include_directories( @@ -54,8 +66,6 @@ set(mscorbi_sources_base cordb-register.h cordb-stepper.cpp cordb-stepper.h - cordb-symbol.cpp - cordb-symbol.h cordb-thread.cpp cordb-thread.h cordb-type.cpp diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp index e1b9e7cf5c9e21..ea2aaa890937a8 100644 --- a/src/mono/dbi/cordb-appdomain.cpp +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -10,281 +10,286 @@ using namespace std; -CordbAppDomain::CordbAppDomain(Connection *conn, CordbProcess *ppProcess) - : CordbBaseMono(conn) { - pProcess = ppProcess; - pProcess->AddAppDomain(this); +CordbAppDomain::CordbAppDomain(Connection* conn, CordbProcess* ppProcess) : CordbBaseMono(conn) +{ + pProcess = ppProcess; + pProcess->AddAppDomain(this); } -HRESULT CordbAppDomain::Stop(DWORD dwTimeoutIgnored) { - LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Stop - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::Stop(DWORD dwTimeoutIgnored) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Stop - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::Continue(BOOL fIsOutOfBand) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - Continue - NOT IMPLEMENTED\n")); +HRESULT CordbAppDomain::Continue(BOOL fIsOutOfBand) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Continue - NOT IMPLEMENTED\n")); - pProcess->Continue(fIsOutOfBand); - return S_OK; + pProcess->Continue(fIsOutOfBand); + return S_OK; } -HRESULT CordbAppDomain::IsRunning(BOOL *pbRunning) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - IsRunning - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::IsRunning(BOOL* pbRunning) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - IsRunning - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::HasQueuedCallbacks(ICorDebugThread *pThread, - BOOL *pbQueued) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - HasQueuedCallbacks - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - HasQueuedCallbacks - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbAppDomain::EnumerateThreads(ICorDebugThreadEnum **ppThreads) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - EnumerateThreads - NOT IMPLEMENTED\n")); - return S_OK; +CordbAppDomain::EnumerateThreads(ICorDebugThreadEnum** ppThreads) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateThreads - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbAppDomain::SetAllThreadsDebugState(CorDebugThreadState state, - ICorDebugThread *pExceptThisThread) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); - return S_OK; +CordbAppDomain::SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::Detach(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Detach - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::Detach(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Detach - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::Terminate(UINT exitCode) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - Terminate - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::Terminate(UINT exitCode) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Terminate - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbAppDomain::CanCommitChanges(ULONG cSnapshots, - ICorDebugEditAndContinueSnapshot *pSnapshots[], - ICorDebugErrorInfoEnum **pError) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - CanCommitChanges - NOT IMPLEMENTED\n")); - return S_OK; +CordbAppDomain::CanCommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot* pSnapshots[], + ICorDebugErrorInfoEnum** pError) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - CanCommitChanges - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbAppDomain::CommitChanges(ULONG cSnapshots, - ICorDebugEditAndContinueSnapshot *pSnapshots[], - ICorDebugErrorInfoEnum **pError) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - CommitChanges - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbAppDomain::QueryInterface( - REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { - if (id == IID_ICorDebugAppDomain) { - *ppInterface = (ICorDebugAppDomain *)this; - } else if (id == IID_ICorDebugAppDomain2) { - *ppInterface = (ICorDebugAppDomain2 *)this; - } else if (id == IID_ICorDebugAppDomain3) { - *ppInterface = (ICorDebugAppDomain3 *)this; - } else if (id == IID_ICorDebugAppDomain4) { - *ppInterface = (ICorDebugAppDomain4 *)this; - } else if (id == IID_ICorDebugController) - *ppInterface = (ICorDebugController *)(ICorDebugAppDomain *)this; - else if (id == IID_IUnknown) - *ppInterface = (IUnknown *)(ICorDebugAppDomain *)this; - else { - *ppInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -HRESULT CordbAppDomain::GetProcess(ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - GetProcess - NOT IMPLEMENTED\n")); - pProcess->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); - return S_OK; +CordbAppDomain::CommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot* pSnapshots[], + ICorDebugErrorInfoEnum** pError) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - CommitChanges - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbAppDomain::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface) +{ + if (id == IID_ICorDebugAppDomain) + { + *ppInterface = (ICorDebugAppDomain*)this; + } + else if (id == IID_ICorDebugAppDomain2) + { + *ppInterface = (ICorDebugAppDomain2*)this; + } + else if (id == IID_ICorDebugAppDomain3) + { + *ppInterface = (ICorDebugAppDomain3*)this; + } + else if (id == IID_ICorDebugAppDomain4) + { + *ppInterface = (ICorDebugAppDomain4*)this; + } + else if (id == IID_ICorDebugController) + *ppInterface = (ICorDebugController*)(ICorDebugAppDomain*)this; + else if (id == IID_IUnknown) + *ppInterface = (IUnknown*)(ICorDebugAppDomain*)this; + else + { + *ppInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; +} + +HRESULT CordbAppDomain::GetProcess(ICorDebugProcess** ppProcess) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetProcess - NOT IMPLEMENTED\n")); + pProcess->QueryInterface(IID_ICorDebugProcess, (void**)ppProcess); + return S_OK; } HRESULT -CordbAppDomain::EnumerateAssemblies(ICorDebugAssemblyEnum **ppAssemblies) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - EnumerateAssemblies - NOT IMPLEMENTED\n")); - return S_OK; +CordbAppDomain::EnumerateAssemblies(ICorDebugAssemblyEnum** ppAssemblies) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateAssemblies - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbAppDomain::GetModuleFromMetaDataInterface(IUnknown *pIMetaData, - ICorDebugModule **ppModule) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - GetModuleFromMetaDataInterface - NOT IMPLEMENTED\n")); - return S_OK; +CordbAppDomain::GetModuleFromMetaDataInterface(IUnknown* pIMetaData, ICorDebugModule** ppModule) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetModuleFromMetaDataInterface - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbAppDomain::EnumerateBreakpoints(ICorDebugBreakpointEnum **ppBreakpoints) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - EnumerateBreakpoints - NOT IMPLEMENTED\n")); - return S_OK; +CordbAppDomain::EnumerateBreakpoints(ICorDebugBreakpointEnum** ppBreakpoints) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateBreakpoints - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::EnumerateSteppers(ICorDebugStepperEnum **ppSteppers) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - EnumerateSteppers - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::EnumerateSteppers(ICorDebugStepperEnum** ppSteppers) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateSteppers - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::IsAttached(BOOL *pbAttached) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - IsAttached - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::IsAttached(BOOL* pbAttached) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - IsAttached - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbAppDomain::GetName(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]) { - LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetName - IMPLEMENTED\n")); - if (cchName < strlen("DefaultDomain")) { - *pcchName = (ULONG32)strlen("DefaultDomain") + 1; - return S_OK; - } - wcscpy(szName, W("DefaultDomain")); +CordbAppDomain::GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetName - IMPLEMENTED\n")); + if (cchName < strlen("DefaultDomain")) + { + *pcchName = (ULONG32)strlen("DefaultDomain") + 1; + return S_OK; + } + wcscpy(szName, W("DefaultDomain")); - return S_OK; + return S_OK; } -HRESULT CordbAppDomain::GetObject(ICorDebugValue **ppObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - GetObject - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::GetObject(ICorDebugValue** ppObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetObject - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::Attach(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Attach - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::Attach(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Attach - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::GetID(ULONG32 *pId) { - *pId = 0; - LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetID - IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::GetID(ULONG32* pId) +{ + *pId = 0; + LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomain - GetID - IMPLEMENTED\n")); + return S_OK; } HRESULT CordbAppDomain::GetArrayOrPointerType(CorElementType elementType, - ULONG32 nRank, + ULONG32 nRank, - ICorDebugType *pTypeArg, - ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - GetArrayOrPointerType - NOT IMPLEMENTED\n")); - return S_OK; + ICorDebugType* pTypeArg, + ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetArrayOrPointerType - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::GetFunctionPointerType(ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[], - ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - GetFunctionPointerType - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::GetFunctionPointerType(ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[], ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetFunctionPointerType - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::GetCachedWinRTTypesForIIDs( - ULONG32 cReqTypes, GUID *iidsToResolve, ICorDebugTypeEnum **ppTypesEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - GetCachedWinRTTypesForIIDs - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::GetCachedWinRTTypesForIIDs(ULONG32 cReqTypes, + GUID* iidsToResolve, + ICorDebugTypeEnum** ppTypesEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetCachedWinRTTypesForIIDs - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbAppDomain::GetCachedWinRTTypes( - ICorDebugGuidToTypeEnum **ppGuidToTypeEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - GetCachedWinRTTypes - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbAppDomain::GetCachedWinRTTypes(ICorDebugGuidToTypeEnum** ppGuidToTypeEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetCachedWinRTTypes - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbAppDomain::GetObjectForCCW(CORDB_ADDRESS ccwPointer, - ICorDebugValue **ppManagedObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - GetObjectForCCW - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, - ICorDebugAppDomain *values[], - ULONG *pceltFetched) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomainEnum - Next - NOT IMPLEMENTED\n")); - *pceltFetched = celt; - for (ULONG i = 0; i < celt; i++) { - if (current_pos >= pProcess->appDomains->GetCount()) { - *pceltFetched = 0; - return S_FALSE; +CordbAppDomain::GetObjectForCCW(CORDB_ADDRESS ccwPointer, ICorDebugValue** ppManagedObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetObjectForCCW - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, ICorDebugAppDomain* values[], ULONG* pceltFetched) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomainEnum - Next - NOT IMPLEMENTED\n")); + *pceltFetched = celt; + for (ULONG i = 0; i < celt; i++) + { + if (current_pos >= pProcess->appDomains->GetCount()) + { + *pceltFetched = 0; + return S_FALSE; + } + CordbAppDomain* appdomain = (CordbAppDomain*)pProcess->appDomains->Get(current_pos); + appdomain->QueryInterface(IID_ICorDebugAppDomain, (void**)values + current_pos); + current_pos++; } - CordbAppDomain *appdomain = - (CordbAppDomain *)pProcess->appDomains->Get(current_pos); - appdomain->QueryInterface(IID_ICorDebugAppDomain, - (void **)values + current_pos); - current_pos++; - } - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Skip(ULONG celt) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomainEnum - Skip - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Reset(void) { - current_pos = 0; - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomainEnum - Reset - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Clone(ICorDebugEnum **ppEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomainEnum - Clone - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::GetCount(ULONG *pcelt) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbAppDomainEnum - GetCount - IMPLEMENTED\n")); - *pcelt = pProcess->appDomains->GetCount(); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE -CordbAppDomainEnum::QueryInterface(REFIID id, void **pInterface) { - if (id == IID_IUnknown) - *pInterface = - static_cast(static_cast(this)); - else if (id == IID_ICorDebugAppDomainEnum) - *pInterface = static_cast(this); - else if (id == IID_ICorDebugEnum) - *pInterface = static_cast(this); - else { - LOG((LF_CORDB, LL_INFO100000, - "CordbAppDomain - QueryInterface - NOT IMPLEMENTED\n")); - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -CordbAppDomainEnum::CordbAppDomainEnum(Connection *conn, - CordbProcess *ppProcess) - : CordbBaseMono(conn) { - current_pos = 0; - this->pProcess = ppProcess; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Skip(ULONG celt) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomainEnum - Skip - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Reset(void) +{ + current_pos = 0; + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomainEnum - Reset - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Clone(ICorDebugEnum** ppEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomainEnum - Clone - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::GetCount(ULONG* pcelt) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomainEnum - GetCount - IMPLEMENTED\n")); + *pcelt = pProcess->appDomains->GetCount(); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_IUnknown) + *pInterface = static_cast(static_cast(this)); + else if (id == IID_ICorDebugAppDomainEnum) + *pInterface = static_cast(this); + else if (id == IID_ICorDebugEnum) + *pInterface = static_cast(this); + else + { + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - QueryInterface - NOT IMPLEMENTED\n")); + return E_NOINTERFACE; + } + AddRef(); + return S_OK; +} + +CordbAppDomainEnum::CordbAppDomainEnum(Connection* conn, CordbProcess* ppProcess) : CordbBaseMono(conn) +{ + current_pos = 0; + this->pProcess = ppProcess; } diff --git a/src/mono/dbi/cordb-appdomain.h b/src/mono/dbi/cordb-appdomain.h index bfc17b89da1606..2d86349825086f 100644 --- a/src/mono/dbi/cordb-appdomain.h +++ b/src/mono/dbi/cordb-appdomain.h @@ -13,82 +13,94 @@ class CordbAppDomain : public CordbBaseMono, public ICorDebugAppDomain, public ICorDebugAppDomain2, public ICorDebugAppDomain3, - public ICorDebugAppDomain4 { - CordbProcess *pProcess; + public ICorDebugAppDomain4 +{ + CordbProcess* pProcess; public: - CordbAppDomain(Connection *conn, CordbProcess *ppProcess); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbAppDomain"; } - HRESULT Stop(DWORD dwTimeoutIgnored); - HRESULT Continue(BOOL fIsOutOfBand); - HRESULT IsRunning(BOOL *pbRunning); - HRESULT HasQueuedCallbacks(ICorDebugThread *pThread, BOOL *pbQueued); - HRESULT - EnumerateThreads(ICorDebugThreadEnum **ppThreads); - HRESULT - SetAllThreadsDebugState(CorDebugThreadState state, - ICorDebugThread *pExceptThisThread); - HRESULT Detach(void); - HRESULT Terminate(UINT exitCode); - HRESULT - CanCommitChanges(ULONG cSnapshots, - ICorDebugEditAndContinueSnapshot *pSnapshots[], - ICorDebugErrorInfoEnum **pError); - HRESULT - CommitChanges(ULONG cSnapshots, - ICorDebugEditAndContinueSnapshot *pSnapshots[], - ICorDebugErrorInfoEnum **pError); - HRESULT - QueryInterface(REFIID id, - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface); - HRESULT - GetProcess(ICorDebugProcess **ppProcess); - HRESULT - EnumerateAssemblies(ICorDebugAssemblyEnum **ppAssemblies); - HRESULT GetModuleFromMetaDataInterface(IUnknown *pIMetaData, - ICorDebugModule **ppModule); - HRESULT - EnumerateBreakpoints(ICorDebugBreakpointEnum **ppBreakpoints); - HRESULT - EnumerateSteppers(ICorDebugStepperEnum **ppSteppers); - HRESULT IsAttached(BOOL *pbAttached); - HRESULT - GetName(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]); - HRESULT GetObject(ICorDebugValue **ppObject); - HRESULT Attach(void); - HRESULT GetID(ULONG32 *pId); - HRESULT GetArrayOrPointerType(CorElementType elementType, ULONG32 nRank, - ICorDebugType *pTypeArg, - ICorDebugType **ppType); - HRESULT - GetFunctionPointerType(ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], - ICorDebugType **ppType); - HRESULT - GetCachedWinRTTypesForIIDs(ULONG32 cReqTypes, GUID *iidsToResolve, - ICorDebugTypeEnum **ppTypesEnum); - HRESULT - GetCachedWinRTTypes(ICorDebugGuidToTypeEnum **ppGuidToTypeEnum); - HRESULT - GetObjectForCCW(CORDB_ADDRESS ccwPointer, ICorDebugValue **ppManagedObject); + CordbAppDomain(Connection* conn, CordbProcess* ppProcess); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbAppDomain"; + } + HRESULT Stop(DWORD dwTimeoutIgnored); + HRESULT Continue(BOOL fIsOutOfBand); + HRESULT IsRunning(BOOL* pbRunning); + HRESULT HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued); + HRESULT + EnumerateThreads(ICorDebugThreadEnum** ppThreads); + HRESULT + SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread); + HRESULT Detach(void); + HRESULT Terminate(UINT exitCode); + HRESULT + CanCommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); + HRESULT + CommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface); + HRESULT + GetProcess(ICorDebugProcess** ppProcess); + HRESULT + EnumerateAssemblies(ICorDebugAssemblyEnum** ppAssemblies); + HRESULT GetModuleFromMetaDataInterface(IUnknown* pIMetaData, ICorDebugModule** ppModule); + HRESULT + EnumerateBreakpoints(ICorDebugBreakpointEnum** ppBreakpoints); + HRESULT + EnumerateSteppers(ICorDebugStepperEnum** ppSteppers); + HRESULT IsAttached(BOOL* pbAttached); + HRESULT + GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); + HRESULT GetObject(ICorDebugValue** ppObject); + HRESULT Attach(void); + HRESULT GetID(ULONG32* pId); + HRESULT GetArrayOrPointerType(CorElementType elementType, + ULONG32 nRank, + ICorDebugType* pTypeArg, + ICorDebugType** ppType); + HRESULT + GetFunctionPointerType(ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[], ICorDebugType** ppType); + HRESULT + GetCachedWinRTTypesForIIDs(ULONG32 cReqTypes, GUID* iidsToResolve, ICorDebugTypeEnum** ppTypesEnum); + HRESULT + GetCachedWinRTTypes(ICorDebugGuidToTypeEnum** ppGuidToTypeEnum); + HRESULT + GetObjectForCCW(CORDB_ADDRESS ccwPointer, ICorDebugValue** ppManagedObject); }; -class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum { - DWORD current_pos; - CordbProcess *pProcess; +class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum +{ + DWORD current_pos; + CordbProcess* pProcess; public: - CordbAppDomainEnum(Connection *conn, CordbProcess *ppProcess); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbAppDomainEnum"; } - HRESULT Next(ULONG celt, ICorDebugAppDomain *values[], ULONG *pceltFetched); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum **ppEnum); - HRESULT GetCount(ULONG *pcelt); - HRESULT QueryInterface(REFIID riid, void **ppvObject); + CordbAppDomainEnum(Connection* conn, CordbProcess* ppProcess); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbAppDomainEnum"; + } + HRESULT Next(ULONG celt, ICorDebugAppDomain* values[], ULONG* pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum** ppEnum); + HRESULT GetCount(ULONG* pcelt); + HRESULT QueryInterface(REFIID riid, void** ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 267654b6fb7c0c..00b60bb90a0981 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -9,337 +9,366 @@ #include #include #include -#include #include +#include "corerror.h" +#include "metamodel.h" +#include "metamodelpub.h" +#include "rwutil.h" +#include "stdafx.h" +#include "stgio.h" + +#include "importhelper.h" + +#include +#include "mdlog.h" +#include "mdperf.h" +#include "regmeta.h" using namespace std; -CordbAssembly::CordbAssembly(Connection *conn, CordbProcess *process, - CordbAppDomain *appDomain, int id_assembly) - : CordbBaseMono(conn) { - m_pProcess = process; - m_pAppDomain = appDomain; - m_pAppDomain->InternalAddRef(); - m_debuggerId = id_assembly; -} - -CordbAssembly::~CordbAssembly() { m_pAppDomain->InternalRelease(); } - -HRESULT CordbAssembly::IsFullyTrusted(BOOL *pbFullyTrusted) { - *pbFullyTrusted = true; - LOG((LF_CORDB, LL_INFO100000, - "CorDebugAssembly - IsFullyTrusted - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbAssembly::GetAppDomain(ICorDebugAppDomain **ppAppDomain) { - LOG((LF_CORDB, LL_INFO1000000, - "CorDebugAssembly - GetAppDomain - IMPLEMENTED\n")); - m_pAppDomain->QueryInterface(IID_ICorDebugAppDomain, (void **)ppAppDomain); - return S_OK; -} - -HRESULT CordbAssembly::EnumerateModules(ICorDebugModuleEnum **ppModules) { - LOG((LF_CORDB, LL_INFO100000, - "CorDebugAssembly - EnumerateModules - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbAssembly::GetCodeBase(ULONG32 cchName, ULONG32 *pcchName, - WCHAR szName[]) { - LOG((LF_CORDB, LL_INFO100000, - "CorDebugAssembly - GetCodeBase - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbAssembly::GetName(ULONG32 cchName, ULONG32 *pcchName, - WCHAR szName[]) { - LOG((LF_CORDB, LL_INFO100000, - "CorDebugAssembly - GetName - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbAssembly::QueryInterface( - REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { - if (id == IID_ICorDebugAssembly) - *ppInterface = static_cast(this); - else if (id == IID_ICorDebugAssembly2) - *ppInterface = static_cast(this); - else if (id == IID_IUnknown) - *ppInterface = - static_cast(static_cast(this)); - else { - *ppInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -HRESULT CordbAssembly::GetProcess(ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO1000000, - "CorDebugAssembly - GetProcess - IMPLEMENTED\n")); - conn->GetProcess()->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); - return S_OK; -} - -CordbModule::CordbModule(Connection *conn, CordbProcess *process, - CordbAssembly *assembly, int id_assembly) - : CordbBaseMono(conn) { - m_pProcess = process; - m_pRegMeta = NULL; - m_pAssembly = assembly; - m_debuggerId = id_assembly; - m_pAssembly->InternalAddRef(); - dwFlags = 0; - conn->GetProcess()->AddModule(this); - m_pAssemblyMetadataBlob = NULL; -} - -CordbModule::~CordbModule() { - if (m_pRegMeta) - m_pRegMeta->InternalRelease(); - if (m_pAssembly) - m_pAssembly->InternalRelease(); - if (m_pAssemblyMetadataBlob) - free(m_pAssemblyMetadataBlob); -} - -HRESULT CordbModule::QueryInterface(REFIID id, void **pInterface) { - if (id == IID_ICorDebugModule) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugModule2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugModule3) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugModule4) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -HRESULT CordbModule::IsMappedLayout(BOOL *pIsMapped) { - *pIsMapped = FALSE; - LOG((LF_CORDB, LL_INFO1000000, - "CordbModule - IsMappedLayout - IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbModule::CreateReaderForInMemorySymbols(REFIID riid, void **ppObj) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - CreateReaderForInMemorySymbols - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbModule::SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, - mdToken pTokens[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - SetJMCStatus - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbModule::ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], - ULONG cbIL, BYTE pbIL[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - ApplyChanges - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbModule::SetJITCompilerFlags(DWORD dwFlags) { - this->dwFlags = dwFlags; - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - SetJITCompilerFlags - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbModule::GetJITCompilerFlags(DWORD *pdwFlags) { - *pdwFlags = dwFlags; - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - GetJITCompilerFlags - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbModule::ResolveAssembly(mdToken tkAssemblyRef, - ICorDebugAssembly **ppAssembly) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - ResolveAssembly - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbModule::GetProcess(ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - GetProcess - NOT IMPLEMENTED\n")); - conn->GetProcess()->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); - return S_OK; -} - -HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS *pAddress) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); - int cmdId = - conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, - MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - - m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array( - pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); +CordbAssembly::CordbAssembly(Connection* conn, CordbProcess* process, CordbAppDomain* appDomain, int id_assembly) + : CordbBaseMono(conn) +{ + m_pProcess = process; + m_pAppDomain = appDomain; + m_pAppDomain->InternalAddRef(); + m_debuggerId = id_assembly; +} - LOG((LF_CORDB, LL_INFO1000000, - "CordbModule - GetBaseAddress - IMPLEMENTED\n")); - - *pAddress = (CORDB_ADDRESS)m_pAssemblyMetadataBlob; - return S_OK; -} - -HRESULT CordbModule::GetName(ULONG32 cchName, ULONG32 *pcchName, - WCHAR szName[]) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetName - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, - MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); - m_dbgprot_buffer_free(&localbuf); +CordbAssembly::~CordbAssembly() +{ + m_pAppDomain->InternalRelease(); +} - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); +HRESULT CordbAssembly::IsFullyTrusted(BOOL* pbFullyTrusted) +{ + *pbFullyTrusted = true; + LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - IsFullyTrusted - NOT IMPLEMENTED\n")); + return S_OK; +} - char *assembly_name = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); +HRESULT CordbAssembly::GetAppDomain(ICorDebugAppDomain** ppAppDomain) +{ + LOG((LF_CORDB, LL_INFO1000000, "CorDebugAssembly - GetAppDomain - IMPLEMENTED\n")); + m_pAppDomain->QueryInterface(IID_ICorDebugAppDomain, (void**)ppAppDomain); + return S_OK; +} - if (cchName < strlen(assembly_name) + 1) { - *pcchName = (ULONG32)strlen(assembly_name) + 1; - free(assembly_name); +HRESULT CordbAssembly::EnumerateModules(ICorDebugModuleEnum** ppModules) +{ + LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - EnumerateModules - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbAssembly::GetCodeBase(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - GetCodeBase - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbAssembly::GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - GetName - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbAssembly::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface) +{ + if (id == IID_ICorDebugAssembly) + *ppInterface = static_cast(this); + else if (id == IID_ICorDebugAssembly2) + *ppInterface = static_cast(this); + else if (id == IID_IUnknown) + *ppInterface = static_cast(static_cast(this)); + else + { + *ppInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; +} + +HRESULT CordbAssembly::GetProcess(ICorDebugProcess** ppProcess) +{ + LOG((LF_CORDB, LL_INFO1000000, "CorDebugAssembly - GetProcess - IMPLEMENTED\n")); + conn->GetProcess()->QueryInterface(IID_ICorDebugProcess, (void**)ppProcess); return S_OK; - } - MultiByteToWideChar(CP_UTF8, 0, assembly_name, -1, szName, cchName); - *pcchName = cchName; - free(assembly_name); - return S_OK; } -HRESULT CordbModule::EnableJITDebugging(BOOL bTrackJITInfo, - BOOL bAllowJitOpts) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - EnableJITDebugging - NOT IMPLEMENTED\n")); - return S_OK; +CordbModule::CordbModule(Connection* conn, CordbProcess* process, CordbAssembly* assembly, int id_assembly) + : CordbBaseMono(conn) +{ + m_pProcess = process; + m_pRegMeta = NULL; + m_pAssembly = assembly; + m_debuggerId = id_assembly; + m_pAssembly->InternalAddRef(); + dwFlags = 0; + conn->GetProcess()->AddModule(this); + m_pAssemblyMetadataBlob = NULL; +} + +CordbModule::~CordbModule() +{ + if (m_pAssembly) + m_pAssembly->InternalRelease(); + if (m_pAssemblyMetadataBlob) + free(m_pAssemblyMetadataBlob); +} + +HRESULT CordbModule::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugModule) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugModule2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugModule3) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugModule4) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -HRESULT CordbModule::EnableClassLoadCallbacks(BOOL bClassLoadCallbacks) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - EnableClassLoadCallbacks - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbModule::IsMappedLayout(BOOL* pIsMapped) +{ + *pIsMapped = FALSE; + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsMappedLayout - IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetFunctionFromToken(mdMethodDef methodDef, - ICorDebugFunction **ppFunction) { - // check in a cache before talk to mono runtime to get info - LOG((LF_CORDB, LL_INFO1000000, - "CordbModule - GetFunctionFromToken - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - m_dbgprot_buffer_add_int(&localbuf, methodDef); - int cmdId = - conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, - MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT CordbModule::CreateReaderForInMemorySymbols(REFIID riid, void** ppObj) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - CreateReaderForInMemorySymbols - NOT IMPLEMENTED\n")); + return S_OK; +} - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); +HRESULT CordbModule::SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken pTokens[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - SetJMCStatus - NOT IMPLEMENTED\n")); + return S_OK; +} - int id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - CordbFunction *func = NULL; - func = m_pProcess->FindFunction(id); - if (func == NULL) { - func = new CordbFunction(conn, methodDef, id, this); - } - func->QueryInterface(IID_ICorDebugFunction, (void **)ppFunction); - return S_OK; +HRESULT CordbModule::ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], ULONG cbIL, BYTE pbIL[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - ApplyChanges - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetFunctionFromRVA(CORDB_ADDRESS rva, - ICorDebugFunction **ppFunction) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - GetFunctionFromRVA - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbModule::SetJITCompilerFlags(DWORD dwFlags) +{ + this->dwFlags = dwFlags; + LOG((LF_CORDB, LL_INFO100000, "CordbModule - SetJITCompilerFlags - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetClassFromToken(mdTypeDef typeDef, - ICorDebugClass **ppClass) { - CordbClass *pClass = new CordbClass(conn, typeDef, GetDebuggerId()); - pClass->QueryInterface(IID_ICorDebugClass, (void **)ppClass); - return S_OK; +HRESULT CordbModule::GetJITCompilerFlags(DWORD* pdwFlags) +{ + *pdwFlags = dwFlags; + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetJITCompilerFlags - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbModule::ResolveAssembly(mdToken tkAssemblyRef, ICorDebugAssembly** ppAssembly) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - ResolveAssembly - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbModule::GetProcess(ICorDebugProcess** ppProcess) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetProcess - NOT IMPLEMENTED\n")); + conn->GetProcess()->QueryInterface(IID_ICorDebugProcess, (void**)ppProcess); + return S_OK; +} + +HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS* pAddress) +{ + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); + + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); + + *pAddress = (CORDB_ADDRESS)m_pAssemblyMetadataBlob; + return S_OK; +} + +HRESULT CordbModule::GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetName - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + char* assembly_name = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + + if (cchName < strlen(assembly_name) + 1) + { + *pcchName = (ULONG32)strlen(assembly_name) + 1; + free(assembly_name); + return S_OK; + } + MultiByteToWideChar(CP_UTF8, 0, assembly_name, -1, szName, cchName); + *pcchName = cchName; + free(assembly_name); + return S_OK; +} + +HRESULT CordbModule::EnableJITDebugging(BOOL bTrackJITInfo, BOOL bAllowJitOpts) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - EnableJITDebugging - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbModule::EnableClassLoadCallbacks(BOOL bClassLoadCallbacks) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - EnableClassLoadCallbacks - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbModule::GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction** ppFunction) +{ + // check in a cache before talk to mono runtime to get info + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetFunctionFromToken - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + m_dbgprot_buffer_add_int(&localbuf, methodDef); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + CordbFunction* func = NULL; + func = m_pProcess->FindFunction(id); + if (func == NULL) + { + func = new CordbFunction(conn, methodDef, id, this); + } + func->QueryInterface(IID_ICorDebugFunction, (void**)ppFunction); + return S_OK; +} + +HRESULT CordbModule::GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction** ppFunction) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetFunctionFromRVA - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbModule::GetClassFromToken(mdTypeDef typeDef, ICorDebugClass** ppClass) +{ + CordbClass* pClass = new CordbClass(conn, typeDef, GetDebuggerId()); + pClass->QueryInterface(IID_ICorDebugClass, (void**)ppClass); + return S_OK; } HRESULT -CordbModule::CreateBreakpoint(ICorDebugModuleBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - CreateBreakpoint - NOT IMPLEMENTED\n")); - return S_OK; +CordbModule::CreateBreakpoint(ICorDebugModuleBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - CreateBreakpoint - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetEditAndContinueSnapshot( - ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - GetEditAndContinueSnapshot - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbModule::GetEditAndContinueSnapshot(ICorDebugEditAndContinueSnapshot** ppEditAndContinueSnapshot) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetEditAndContinueSnapshot - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetMetaDataInterface(REFIID riid, IUnknown **ppObj) { - if (m_pRegMeta == NULL) { - m_pRegMeta = new RegMeta(m_pAssembly, this); - m_pRegMeta->InternalAddRef(); - } - m_pRegMeta->QueryInterface(riid, (void **)ppObj); - LOG((LF_CORDB, LL_INFO1000000, - "CordbModule - GetMetaDataInterface - IMPLEMENTED\n")); - return S_OK; +HRESULT CordbModule::GetMetaDataInterface(REFIID riid, IUnknown** ppObj) +{ + if (m_pRegMeta == NULL) + { + m_pRegMeta = new RegMeta(); + + m_pStgdbRW = new CLiteWeightStgdbRW(); + ULONG32 pcchName = 0; + GetName(0, &pcchName, NULL); + + WCHAR* full_path; + full_path = (WCHAR*)malloc(sizeof(WCHAR) * pcchName); + GetName(pcchName, &pcchName, full_path); + + m_pStgdbRW->OpenForRead(full_path, NULL, 0, 0); + free(full_path); + + m_pRegMeta->InitWithStgdb((ICorDebugModule*)this, m_pStgdbRW); + } + m_pRegMeta->QueryInterface(riid, (void**)ppObj); + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetMetaDataInterface - IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetToken(mdModule *pToken) { - LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetToken - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbModule::GetToken(mdModule* pToken) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetToken - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::IsDynamic(BOOL *pDynamic) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); - return S_OK; +HRESULT CordbModule::IsDynamic(BOOL* pDynamic) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetGlobalVariableValue(mdFieldDef fieldDef, - ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbModule - GetGlobalVariableValue - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbModule::GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetGlobalVariableValue - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetSize(ULONG32 *pcBytes) { - LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetSize -IMPLEMENTED\n")); - *pcBytes = m_assemblyMetadataLen; - return S_OK; +HRESULT CordbModule::GetSize(ULONG32* pcBytes) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetSize -IMPLEMENTED\n")); + *pcBytes = m_assemblyMetadataLen; + return S_OK; } -HRESULT CordbModule::IsInMemory(BOOL *pInMemory) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsInMemory - IMPLEMENTED\n")); - return S_OK; +HRESULT CordbModule::IsInMemory(BOOL* pInMemory) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsInMemory - IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbModule::GetAssembly(ICorDebugAssembly **ppAssembly) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetAssembly - IMPLEMENTED\n")); - m_pAssembly->QueryInterface(IID_ICorDebugAssembly, (void **)ppAssembly); - return S_OK; +HRESULT CordbModule::GetAssembly(ICorDebugAssembly** ppAssembly) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetAssembly - IMPLEMENTED\n")); + m_pAssembly->QueryInterface(IID_ICorDebugAssembly, (void**)ppAssembly); + return S_OK; } diff --git a/src/mono/dbi/cordb-assembly.h b/src/mono/dbi/cordb-assembly.h index 0bbc177147760c..632252bee09bba 100644 --- a/src/mono/dbi/cordb-assembly.h +++ b/src/mono/dbi/cordb-assembly.h @@ -9,95 +9,115 @@ #include +class CLiteWeightStgdbRW; + class CordbModule : public CordbBaseMono, public ICorDebugModule, public ICorDebugModule2, public ICorDebugModule3, - public ICorDebugModule4 { - int m_debuggerId; // id on mono side; - CordbProcess *m_pProcess; - RegMeta *m_pRegMeta; - CordbAssembly *m_pAssembly; - uint8_t *m_pAssemblyMetadataBlob; - int32_t m_assemblyMetadataLen; - unsigned long dwFlags; + public ICorDebugModule4 +{ + int m_debuggerId; // id on mono side; + CordbProcess* m_pProcess; + RegMeta* m_pRegMeta; + CordbAssembly* m_pAssembly; + CLiteWeightStgdbRW* m_pStgdbRW; + uint8_t* m_pAssemblyMetadataBlob; + int32_t m_assemblyMetadataLen; + unsigned long dwFlags; public: - CordbModule(Connection *conn, CordbProcess *process, CordbAssembly *assembly, - int id_assembly); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbModule"; } - ~CordbModule(); + CordbModule(Connection* conn, CordbProcess* process, CordbAssembly* assembly, int id_assembly); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbModule"; + } + ~CordbModule(); - HRESULT QueryInterface(REFIID id, void **pInterface); - HRESULT IsMappedLayout(BOOL *pIsMapped); - HRESULT CreateReaderForInMemorySymbols(REFIID riid, void **ppObj); - HRESULT - SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken pTokens[]); - HRESULT - ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], ULONG cbIL, BYTE pbIL[]); - HRESULT SetJITCompilerFlags(DWORD dwFlags); - HRESULT GetJITCompilerFlags(DWORD *pdwFlags); - HRESULT - ResolveAssembly(mdToken tkAssemblyRef, ICorDebugAssembly **ppAssembly); - HRESULT - GetProcess(ICorDebugProcess **ppProcess); - HRESULT GetBaseAddress(CORDB_ADDRESS *pAddress); - HRESULT - GetAssembly(ICorDebugAssembly **ppAssembly); - HRESULT - GetName(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]); - HRESULT EnableJITDebugging(BOOL bTrackJITInfo, BOOL bAllowJitOpts); - HRESULT - EnableClassLoadCallbacks(BOOL bClassLoadCallbacks); - HRESULT - GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction **ppFunction); - HRESULT - GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction **ppFunction); - HRESULT GetClassFromToken(mdTypeDef typeDef, ICorDebugClass **ppClass); - HRESULT - CreateBreakpoint(ICorDebugModuleBreakpoint **ppBreakpoint); - HRESULT GetEditAndContinueSnapshot( - ICorDebugEditAndContinueSnapshot **ppEditAndContinueSnapshot); - HRESULT GetMetaDataInterface(REFIID riid, IUnknown **ppObj); - HRESULT GetToken(mdModule *pToken); - HRESULT IsDynamic(BOOL *pDynamic); - HRESULT - GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue **ppValue); - HRESULT GetSize(ULONG32 *pcBytes); - HRESULT IsInMemory(BOOL *pInMemory); - int GetDebuggerId() const { return m_debuggerId; } + HRESULT QueryInterface(REFIID id, void** pInterface); + HRESULT IsMappedLayout(BOOL* pIsMapped); + HRESULT CreateReaderForInMemorySymbols(REFIID riid, void** ppObj); + HRESULT + SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken pTokens[]); + HRESULT + ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], ULONG cbIL, BYTE pbIL[]); + HRESULT SetJITCompilerFlags(DWORD dwFlags); + HRESULT GetJITCompilerFlags(DWORD* pdwFlags); + HRESULT + ResolveAssembly(mdToken tkAssemblyRef, ICorDebugAssembly** ppAssembly); + HRESULT + GetProcess(ICorDebugProcess** ppProcess); + HRESULT GetBaseAddress(CORDB_ADDRESS* pAddress); + HRESULT + GetAssembly(ICorDebugAssembly** ppAssembly); + HRESULT + GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); + HRESULT EnableJITDebugging(BOOL bTrackJITInfo, BOOL bAllowJitOpts); + HRESULT + EnableClassLoadCallbacks(BOOL bClassLoadCallbacks); + HRESULT + GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction** ppFunction); + HRESULT + GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction** ppFunction); + HRESULT GetClassFromToken(mdTypeDef typeDef, ICorDebugClass** ppClass); + HRESULT + CreateBreakpoint(ICorDebugModuleBreakpoint** ppBreakpoint); + HRESULT GetEditAndContinueSnapshot(ICorDebugEditAndContinueSnapshot** ppEditAndContinueSnapshot); + HRESULT GetMetaDataInterface(REFIID riid, IUnknown** ppObj); + HRESULT GetToken(mdModule* pToken); + HRESULT IsDynamic(BOOL* pDynamic); + HRESULT + GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue** ppValue); + HRESULT GetSize(ULONG32* pcBytes); + HRESULT IsInMemory(BOOL* pInMemory); + int GetDebuggerId() const + { + return m_debuggerId; + } }; -class CordbAssembly : public CordbBaseMono, - public ICorDebugAssembly, - public ICorDebugAssembly2 { - CordbProcess *m_pProcess; - CordbAppDomain *m_pAppDomain; - int m_debuggerId; +class CordbAssembly : public CordbBaseMono, public ICorDebugAssembly, public ICorDebugAssembly2 +{ + CordbProcess* m_pProcess; + CordbAppDomain* m_pAppDomain; + int m_debuggerId; public: - CordbAssembly(Connection *conn, CordbProcess *process, - CordbAppDomain *appDomain, int id_assembly); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbAssembly"; } - ~CordbAssembly(); - HRESULT IsFullyTrusted(BOOL *pbFullyTrusted); - HRESULT - GetProcess(ICorDebugProcess **ppProcess); - HRESULT - GetAppDomain(ICorDebugAppDomain **ppAppDomain); - HRESULT - EnumerateModules(ICorDebugModuleEnum **ppModules); - HRESULT - GetCodeBase(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]); - HRESULT - GetName(ULONG32 cchName, ULONG32 *pcchName, WCHAR szName[]); - HRESULT - QueryInterface(REFIID id, - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface); + CordbAssembly(Connection* conn, CordbProcess* process, CordbAppDomain* appDomain, int id_assembly); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbAssembly"; + } + ~CordbAssembly(); + HRESULT IsFullyTrusted(BOOL* pbFullyTrusted); + HRESULT + GetProcess(ICorDebugProcess** ppProcess); + HRESULT + GetAppDomain(ICorDebugAppDomain** ppAppDomain); + HRESULT + EnumerateModules(ICorDebugModuleEnum** ppModules); + HRESULT + GetCodeBase(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); + HRESULT + GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface); }; #endif diff --git a/src/mono/dbi/cordb-blocking-obj.cpp b/src/mono/dbi/cordb-blocking-obj.cpp index cc8244d787061f..98a2dfcc1c9dce 100644 --- a/src/mono/dbi/cordb-blocking-obj.cpp +++ b/src/mono/dbi/cordb-blocking-obj.cpp @@ -7,48 +7,47 @@ #include #include -CordbBlockingObjectEnum::CordbBlockingObjectEnum(Connection *conn) - : CordbBaseMono(conn) {} - -HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Next( - ULONG celt, CorDebugBlockingObject values[], ULONG *pceltFetched) { - LOG((LF_CORDB, LL_INFO100000, - "CordbBlockingObjectEnum - Next - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +CordbBlockingObjectEnum::CordbBlockingObjectEnum(Connection* conn) : CordbBaseMono(conn) {} + +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Next(ULONG celt, + CorDebugBlockingObject values[], + ULONG* pceltFetched) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbBlockingObjectEnum - Next - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Skip(ULONG celt) { - LOG((LF_CORDB, LL_INFO100000, - "CordbBlockingObjectEnum - Skip - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Skip(ULONG celt) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbBlockingObjectEnum - Skip - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Reset(void) { - LOG((LF_CORDB, LL_INFO100000, - "CordbBlockingObjectEnum - Reset - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Reset(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbBlockingObjectEnum - Reset - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbBlockingObjectEnum::Clone(ICorDebugEnum **ppEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbBlockingObjectEnum - Clone - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::Clone(ICorDebugEnum** ppEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbBlockingObjectEnum - Clone - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::GetCount(ULONG *pcelt) { - pcelt = 0; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::GetCount(ULONG* pcelt) +{ + pcelt = 0; + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbBlockingObjectEnum::QueryInterface(REFIID id, void **ppInterface) { - if (id == IID_ICorDebugBlockingObjectEnum) - *ppInterface = (ICorDebugBlockingObjectEnum *)this; - else if (id == IID_IUnknown) - *ppInterface = (IUnknown *)(ICorDebugBlockingObjectEnum *)this; - LOG((LF_CORDB, LL_INFO100000, - "CordbBlockingObjectEnum - QueryInterface - IMPLEMENTED\n")); - AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbBlockingObjectEnum::QueryInterface(REFIID id, void** ppInterface) +{ + if (id == IID_ICorDebugBlockingObjectEnum) + *ppInterface = (ICorDebugBlockingObjectEnum*)this; + else if (id == IID_IUnknown) + *ppInterface = (IUnknown*)(ICorDebugBlockingObjectEnum*)this; + LOG((LF_CORDB, LL_INFO100000, "CordbBlockingObjectEnum - QueryInterface - IMPLEMENTED\n")); + AddRef(); + return S_OK; } diff --git a/src/mono/dbi/cordb-blocking-obj.h b/src/mono/dbi/cordb-blocking-obj.h index 39774b05a2411f..7997db8139af63 100644 --- a/src/mono/dbi/cordb-blocking-obj.h +++ b/src/mono/dbi/cordb-blocking-obj.h @@ -9,20 +9,28 @@ #include -class CordbBlockingObjectEnum : public CordbBaseMono, - public ICorDebugBlockingObjectEnum { +class CordbBlockingObjectEnum : public CordbBaseMono, public ICorDebugBlockingObjectEnum +{ public: - CordbBlockingObjectEnum(Connection *conn); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbBlockingObjectEnum"; } - HRESULT Next(ULONG celt, CorDebugBlockingObject values[], - ULONG *pceltFetched); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum **ppEnum); - HRESULT GetCount(ULONG *pcelt); - HRESULT QueryInterface(REFIID riid, void **ppvObject); + CordbBlockingObjectEnum(Connection* conn); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbBlockingObjectEnum"; + } + HRESULT Next(ULONG celt, CorDebugBlockingObject values[], ULONG* pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum** ppEnum); + HRESULT GetCount(ULONG* pcelt); + HRESULT QueryInterface(REFIID riid, void** ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-breakpoint.cpp b/src/mono/dbi/cordb-breakpoint.cpp index 85e9d0a92cfdd5..f5f31dc9d3d41e 100644 --- a/src/mono/dbi/cordb-breakpoint.cpp +++ b/src/mono/dbi/cordb-breakpoint.cpp @@ -12,71 +12,71 @@ using namespace std; -CordbFunctionBreakpoint::CordbFunctionBreakpoint(Connection *conn, - CordbCode *code, - ULONG32 offset) - : CordbBaseMono(conn) { - this->m_pCode = code; - this->m_offset = offset; - conn->GetProcess()->AddBreakpoint(this); +CordbFunctionBreakpoint::CordbFunctionBreakpoint(Connection* conn, CordbCode* code, ULONG32 offset) + : CordbBaseMono(conn) +{ + this->m_pCode = code; + this->m_offset = offset; + conn->GetProcess()->AddBreakpoint(this); } CordbFunctionBreakpoint::~CordbFunctionBreakpoint() {} -HRESULT __stdcall CordbFunctionBreakpoint::GetFunction( - ICorDebugFunction **ppFunction) { - GetCode()->GetFunction()->QueryInterface(IID_ICorDebugFunction, - (void **)ppFunction); - LOG((LF_CORDB, LL_INFO1000000, - "CordbFunctionBreakpoint - GetFunction - IMPLEMENTED\n")); - return S_OK; +HRESULT __stdcall CordbFunctionBreakpoint::GetFunction(ICorDebugFunction** ppFunction) +{ + GetCode()->GetFunction()->QueryInterface(IID_ICorDebugFunction, (void**)ppFunction); + LOG((LF_CORDB, LL_INFO1000000, "CordbFunctionBreakpoint - GetFunction - IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbFunctionBreakpoint::GetOffset(ULONG32 *pnOffset) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunctionBreakpoint - GetOffset - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunctionBreakpoint::GetOffset(ULONG32* pnOffset) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunctionBreakpoint - GetOffset - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunctionBreakpoint::Activate(BOOL bActive) { - if (bActive) { - MdbgProtBuffer sendbuf; - int buflen = 128; - m_dbgprot_buffer_init(&sendbuf, buflen); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_BREAKPOINT); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); - m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_LOCATION_ONLY); - m_dbgprot_buffer_add_id(&sendbuf, - this->GetCode()->GetFunction()->GetDebuggerId()); - m_dbgprot_buffer_add_long(&sendbuf, m_offset); - conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, - MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - LOG((LF_CORDB, LL_INFO1000000, - "CordbFunctionBreakpoint - Activate - IMPLEMENTED\n")); - } else { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunctionBreakpoint - Activate - FALSE - NOT IMPLEMENTED\n")); - } - return S_OK; +HRESULT __stdcall CordbFunctionBreakpoint::Activate(BOOL bActive) +{ + if (bActive) + { + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_BREAKPOINT); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_LOCATION_ONLY); + m_dbgprot_buffer_add_id(&sendbuf, this->GetCode()->GetFunction()->GetDebuggerId()); + m_dbgprot_buffer_add_long(&sendbuf, m_offset); + conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + LOG((LF_CORDB, LL_INFO1000000, "CordbFunctionBreakpoint - Activate - IMPLEMENTED\n")); + } + else + { + LOG((LF_CORDB, LL_INFO100000, "CordbFunctionBreakpoint - Activate - FALSE - NOT IMPLEMENTED\n")); + } + return S_OK; } -HRESULT __stdcall CordbFunctionBreakpoint::IsActive(BOOL *pbActive) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunctionBreakpoint - IsActive - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunctionBreakpoint::IsActive(BOOL* pbActive) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunctionBreakpoint - IsActive - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunctionBreakpoint::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugFunctionBreakpoint) { - *pInterface = static_cast(this); - } else { - // Not looking for a function breakpoint? See if the base class handles - // this interface. (issue 143976) - // return CordbBreakpoint::QueryInterface(id, pInterface); - } - AddRef(); - return S_OK; +HRESULT __stdcall CordbFunctionBreakpoint::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugFunctionBreakpoint) + { + *pInterface = static_cast(this); + } + else + { + // Not looking for a function breakpoint? See if the base class handles + // this interface. (issue 143976) + // return CordbBreakpoint::QueryInterface(id, pInterface); + } + AddRef(); + return S_OK; } diff --git a/src/mono/dbi/cordb-breakpoint.h b/src/mono/dbi/cordb-breakpoint.h index 204cc3eef528ea..c7aa1b32127407 100644 --- a/src/mono/dbi/cordb-breakpoint.h +++ b/src/mono/dbi/cordb-breakpoint.h @@ -9,25 +9,39 @@ #include -class CordbFunctionBreakpoint : public CordbBaseMono, - public ICorDebugFunctionBreakpoint { - CordbCode *m_pCode; - ULONG32 m_offset; +class CordbFunctionBreakpoint : public CordbBaseMono, public ICorDebugFunctionBreakpoint +{ + CordbCode* m_pCode; + ULONG32 m_offset; public: - CordbFunctionBreakpoint(Connection *conn, CordbCode *code, ULONG32 offset); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - ULONG32 GetOffset() const { return m_offset; } - CordbCode *GetCode() const { return m_pCode; } - const char *GetClassName() { return "CordbFunctionBreakpoint"; } - ~CordbFunctionBreakpoint(); - HRESULT GetFunction(ICorDebugFunction **ppFunction); - HRESULT GetOffset(ULONG32 *pnOffset); - HRESULT Activate(BOOL bActive); - HRESULT IsActive(BOOL *pbActive); - HRESULT QueryInterface(REFIID id, - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + CordbFunctionBreakpoint(Connection* conn, CordbCode* code, ULONG32 offset); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + ULONG32 GetOffset() const + { + return m_offset; + } + CordbCode* GetCode() const + { + return m_pCode; + } + const char* GetClassName() + { + return "CordbFunctionBreakpoint"; + } + ~CordbFunctionBreakpoint(); + HRESULT GetFunction(ICorDebugFunction** ppFunction); + HRESULT GetOffset(ULONG32* pnOffset); + HRESULT Activate(BOOL bActive); + HRESULT IsActive(BOOL* pbActive); + HRESULT QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); }; #endif diff --git a/src/mono/dbi/cordb-chain.cpp b/src/mono/dbi/cordb-chain.cpp index 42389434d8bb10..e1702ef9862c07 100644 --- a/src/mono/dbi/cordb-chain.cpp +++ b/src/mono/dbi/cordb-chain.cpp @@ -12,137 +12,143 @@ using namespace std; -HRESULT __stdcall CordbChainEnum::Next(ULONG celt, ICorDebugChain *chains[], - ULONG *pceltFetched) { - LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Next - NOT IMPLEMENTED\n")); +HRESULT __stdcall CordbChainEnum::Next(ULONG celt, ICorDebugChain* chains[], ULONG* pceltFetched) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Next - NOT IMPLEMENTED\n")); - chains[0] = new CordbChain(conn, m_pThread, CHAIN_PROCESS_START, false); - chains[1] = new CordbChain(conn, m_pThread, CHAIN_ENTER_MANAGED, true); - chains[0]->AddRef(); - chains[1]->AddRef(); - *pceltFetched = celt; - return S_OK; + chains[0] = new CordbChain(conn, m_pThread, CHAIN_PROCESS_START, false); + chains[1] = new CordbChain(conn, m_pThread, CHAIN_ENTER_MANAGED, true); + chains[0]->AddRef(); + chains[1]->AddRef(); + *pceltFetched = celt; + return S_OK; } -CordbChainEnum::CordbChainEnum(Connection *conn, CordbThread *thread) - : CordbBaseMono(conn) { - this->m_pThread = thread; +CordbChainEnum::CordbChainEnum(Connection* conn, CordbThread* thread) : CordbBaseMono(conn) +{ + this->m_pThread = thread; } -HRESULT __stdcall CordbChainEnum::QueryInterface(REFIID id, void **pInterface) { - LOG((LF_CORDB, LL_INFO100000, - "CordbChainEnum - QueryInterface - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbChainEnum::QueryInterface(REFIID id, void** pInterface) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - QueryInterface - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbChainEnum::Skip(ULONG celt) { - LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Skip - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbChainEnum::Skip(ULONG celt) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Skip - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChainEnum::Reset(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Reset - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChainEnum::Reset(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Reset - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChainEnum::Clone(ICorDebugEnum **ppEnum) { - LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Clone - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChainEnum::Clone(ICorDebugEnum** ppEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Clone - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChainEnum::GetCount(ULONG *pcelt) { - LOG((LF_CORDB, LL_INFO100000, - "CordbChainEnum - GetCount - NOT IMPLEMENTED\n")); +HRESULT STDMETHODCALLTYPE CordbChainEnum::GetCount(ULONG* pcelt) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - GetCount - NOT IMPLEMENTED\n")); - *pcelt = 2; - return S_OK; + *pcelt = 2; + return S_OK; } -CordbChain::CordbChain(Connection *conn, CordbThread *thread, - CorDebugChainReason chain_reason, bool is_managed) - : CordbBaseMono(conn) { - this->m_pThread = thread; - this->m_chainReason = chain_reason; - this->m_isManaged = is_managed; +CordbChain::CordbChain(Connection* conn, CordbThread* thread, CorDebugChainReason chain_reason, bool is_managed) + : CordbBaseMono(conn) +{ + this->m_pThread = thread; + this->m_chainReason = chain_reason; + this->m_isManaged = is_managed; } -HRESULT STDMETHODCALLTYPE CordbChain::GetThread(ICorDebugThread **ppThread) { - m_pThread->QueryInterface(IID_ICorDebugThread, (void **)ppThread); - LOG((LF_CORDB, LL_INFO1000000, "CordbChain - GetThread - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbChain::GetThread(ICorDebugThread** ppThread) +{ + m_pThread->QueryInterface(IID_ICorDebugThread, (void**)ppThread); + LOG((LF_CORDB, LL_INFO1000000, "CordbChain - GetThread - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbChain::GetStackRange(CORDB_ADDRESS *pStart, - CORDB_ADDRESS *pEnd) { - LOG((LF_CORDB, LL_INFO100000, - "CordbChain - GetStackRange - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetStackRange - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChain::GetContext(ICorDebugContext **ppContext) { - LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetContext - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::GetContext(ICorDebugContext** ppContext) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetContext - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChain::GetCaller(ICorDebugChain **ppChain) { - LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetCaller - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::GetCaller(ICorDebugChain** ppChain) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetCaller - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChain::GetCallee(ICorDebugChain **ppChain) { - LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetCallee - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::GetCallee(ICorDebugChain** ppChain) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetCallee - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChain::GetPrevious(ICorDebugChain **ppChain) { - LOG((LF_CORDB, LL_INFO100000, - "CordbChain - GetPrevious - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::GetPrevious(ICorDebugChain** ppChain) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetPrevious - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChain::GetNext(ICorDebugChain **ppChain) { - LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetNext - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::GetNext(ICorDebugChain** ppChain) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetNext - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChain::IsManaged(BOOL *pManaged) { - LOG((LF_CORDB, LL_INFO1000000, "CordbChain - IsManaged - IMPLEMENTED\n")); - *pManaged = m_isManaged; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbChain::IsManaged(BOOL* pManaged) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbChain - IsManaged - IMPLEMENTED\n")); + *pManaged = m_isManaged; + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbChain::EnumerateFrames(ICorDebugFrameEnum **ppFrames) { - CordbFrameEnum *pFrame = new CordbFrameEnum(conn, m_pThread); - pFrame->AddRef(); - *ppFrames = static_cast(pFrame); - LOG((LF_CORDB, LL_INFO1000000, - "CordbChain - EnumerateFrames - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbChain::EnumerateFrames(ICorDebugFrameEnum** ppFrames) +{ + CordbFrameEnum* pFrame = new CordbFrameEnum(conn, m_pThread); + pFrame->AddRef(); + *ppFrames = static_cast(pFrame); + LOG((LF_CORDB, LL_INFO1000000, "CordbChain - EnumerateFrames - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbChain::GetActiveFrame(ICorDebugFrame **ppFrame) { - LOG((LF_CORDB, LL_INFO100000, - "CordbChain - GetActiveFrame - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::GetActiveFrame(ICorDebugFrame** ppFrame) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetActiveFrame - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbChain::GetRegisterSet(ICorDebugRegisterSet **ppRegisters) { - LOG((LF_CORDB, LL_INFO100000, - "CordbChain - GetRegisterSet - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::GetRegisterSet(ICorDebugRegisterSet** ppRegisters) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - GetRegisterSet - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbChain::GetReason(CorDebugChainReason *pReason) { - *pReason = m_chainReason; - LOG((LF_CORDB, LL_INFO1000000, "CordbChain - GetReason - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbChain::GetReason(CorDebugChainReason* pReason) +{ + *pReason = m_chainReason; + LOG((LF_CORDB, LL_INFO1000000, "CordbChain - GetReason - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbChain::QueryInterface( - REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { - LOG((LF_CORDB, LL_INFO100000, - "CordbChain - QueryInterface - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbChain::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbChain - QueryInterface - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-chain.h b/src/mono/dbi/cordb-chain.h index 8823e3d7b3a6ad..9011ebc1d646d3 100644 --- a/src/mono/dbi/cordb-chain.h +++ b/src/mono/dbi/cordb-chain.h @@ -9,54 +9,73 @@ #include -class CordbChainEnum : public CordbBaseMono, public ICorDebugChainEnum { - CordbThread *m_pThread; +class CordbChainEnum : public CordbBaseMono, public ICorDebugChainEnum +{ + CordbThread* m_pThread; public: - CordbChainEnum(Connection *conn, CordbThread *thread); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbChainEnum"; } - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); - - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum **ppEnum); - HRESULT GetCount(ULONG *pcelt); - HRESULT - Next(ULONG celt, ICorDebugChain *chains[], ULONG *pceltFetched); + CordbChainEnum(Connection* conn, CordbThread* thread); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbChainEnum"; + } + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum** ppEnum); + HRESULT GetCount(ULONG* pcelt); + HRESULT + Next(ULONG celt, ICorDebugChain* chains[], ULONG* pceltFetched); }; -class CordbChain : public CordbBaseMono, public ICorDebugChain { - CordbThread *m_pThread; - CorDebugChainReason m_chainReason; - bool m_isManaged; +class CordbChain : public CordbBaseMono, public ICorDebugChain +{ + CordbThread* m_pThread; + CorDebugChainReason m_chainReason; + bool m_isManaged; public: - CordbChain(Connection *conn, CordbThread *thread, - CorDebugChainReason chain_reason, bool is_managed); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbChain"; } - HRESULT GetThread(ICorDebugThread **ppThread); - HRESULT GetStackRange(CORDB_ADDRESS *pStart, CORDB_ADDRESS *pEnd); - HRESULT - GetContext(ICorDebugContext **ppContext); - HRESULT GetCaller(ICorDebugChain **ppChain); - HRESULT GetCallee(ICorDebugChain **ppChain); - HRESULT GetPrevious(ICorDebugChain **ppChain); - HRESULT GetNext(ICorDebugChain **ppChain); - HRESULT IsManaged(BOOL *pManaged); - HRESULT - EnumerateFrames(ICorDebugFrameEnum **ppFrames); - HRESULT - GetActiveFrame(ICorDebugFrame **ppFrame); - HRESULT - GetRegisterSet(ICorDebugRegisterSet **ppRegisters); - HRESULT GetReason(CorDebugChainReason *pReason); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + CordbChain(Connection* conn, CordbThread* thread, CorDebugChainReason chain_reason, bool is_managed); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbChain"; + } + HRESULT GetThread(ICorDebugThread** ppThread); + HRESULT GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); + HRESULT + GetContext(ICorDebugContext** ppContext); + HRESULT GetCaller(ICorDebugChain** ppChain); + HRESULT GetCallee(ICorDebugChain** ppChain); + HRESULT GetPrevious(ICorDebugChain** ppChain); + HRESULT GetNext(ICorDebugChain** ppChain); + HRESULT IsManaged(BOOL* pManaged); + HRESULT + EnumerateFrames(ICorDebugFrameEnum** ppFrames); + HRESULT + GetActiveFrame(ICorDebugFrame** ppFrame); + HRESULT + GetRegisterSet(ICorDebugRegisterSet** ppRegisters); + HRESULT GetReason(CorDebugChainReason* pReason); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); }; #endif diff --git a/src/mono/dbi/cordb-class.cpp b/src/mono/dbi/cordb-class.cpp index 85d4eec076d7b1..0f08f17dc608b0 100644 --- a/src/mono/dbi/cordb-class.cpp +++ b/src/mono/dbi/cordb-class.cpp @@ -14,69 +14,81 @@ using namespace std; -CordbClass::CordbClass(Connection *conn, mdToken token, int module_id) - : CordbBaseMono(conn) { - this->m_metadataToken = token; - this->m_debuggerId = module_id; +CordbClass::CordbClass(Connection* conn, mdToken token, int module_id) : CordbBaseMono(conn) +{ + this->m_metadataToken = token; + this->m_debuggerId = module_id; } -HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule **pModule) { - LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetModule - IMPLEMENTED\n")); - if (pModule) { - CordbModule *module = conn->GetProcess()->GetModule(m_debuggerId); - if (module) { - *pModule = static_cast(module); - (*pModule)->AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule** pModule) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetModule - IMPLEMENTED\n")); + if (pModule) + { + CordbModule* module = conn->GetProcess()->GetModule(m_debuggerId); + if (module) + { + *pModule = static_cast(module); + (*pModule)->AddRef(); + return S_OK; + } } - } - return S_FALSE; + return S_FALSE; } -HRESULT STDMETHODCALLTYPE CordbClass::GetToken(mdTypeDef *pTypeDef) { - LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetToken - IMPLEMENTED\n")); - *pTypeDef = m_metadataToken; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbClass::GetToken(mdTypeDef* pTypeDef) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetToken - IMPLEMENTED\n")); + *pTypeDef = m_metadataToken; + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbClass::GetStaticFieldValue( - mdFieldDef fieldDef, ICorDebugFrame *pFrame, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbClass - GetStaticFieldValue - NOT IMPLEMENTED\n")); - CordbContent content_value; - content_value.booleanValue = 0; - CordbValue *value = - new CordbValue(conn, ELEMENT_TYPE_BOOLEAN, content_value, 1); - value->QueryInterface(IID_ICorDebugValue, (void **)ppValue); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbClass::GetStaticFieldValue(mdFieldDef fieldDef, + ICorDebugFrame* pFrame, + ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbClass - GetStaticFieldValue - NOT IMPLEMENTED\n")); + CordbContent content_value; + content_value.booleanValue = 0; + CordbValue* value = new CordbValue(conn, ELEMENT_TYPE_BOOLEAN, content_value, 1); + value->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbClass::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugClass) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugClass2) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbClass::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugClass) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugClass2) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbClass::GetParameterizedType( - CorElementType elementType, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], - ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbClass - GetParameterizedType - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbClass::GetParameterizedType(CorElementType elementType, + ULONG32 nTypeArgs, + ICorDebugType* ppTypeArgs[], + ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbClass - GetParameterizedType - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbClass::SetJMCStatus(BOOL bIsJustMyCode) { - LOG((LF_CORDB, LL_INFO100000, - "CordbClass - SetJMCStatus - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbClass::SetJMCStatus(BOOL bIsJustMyCode) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbClass - SetJMCStatus - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-class.h b/src/mono/dbi/cordb-class.h index 920f6f74df1cc6..f501586d13b4c0 100644 --- a/src/mono/dbi/cordb-class.h +++ b/src/mono/dbi/cordb-class.h @@ -9,27 +9,35 @@ #include -class CordbClass : public CordbBaseMono, - public ICorDebugClass, - public ICorDebugClass2 { - mdToken m_metadataToken; - int m_debuggerId; +class CordbClass : public CordbBaseMono, public ICorDebugClass, public ICorDebugClass2 +{ + mdToken m_metadataToken; + int m_debuggerId; public: - CordbClass(Connection *conn, mdToken token, int module_id); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbClass"; } - HRESULT GetModule(ICorDebugModule **pModule); - HRESULT GetToken(mdTypeDef *pTypeDef); - HRESULT GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame *pFrame, - ICorDebugValue **ppValue); - HRESULT QueryInterface(REFIID riid, void **ppvObject); + CordbClass(Connection* conn, mdToken token, int module_id); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbClass"; + } + HRESULT GetModule(ICorDebugModule** pModule); + HRESULT GetToken(mdTypeDef* pTypeDef); + HRESULT GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame* pFrame, ICorDebugValue** ppValue); + HRESULT QueryInterface(REFIID riid, void** ppvObject); - HRESULT GetParameterizedType(CorElementType elementType, ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[], - ICorDebugType **ppType); - HRESULT SetJMCStatus(BOOL bIsJustMyCode); + HRESULT GetParameterizedType(CorElementType elementType, + ULONG32 nTypeArgs, + ICorDebugType* ppTypeArgs[], + ICorDebugType** ppType); + HRESULT SetJMCStatus(BOOL bIsJustMyCode); }; #endif diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index 72414c7677f572..98e434a8f3ce04 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -13,110 +13,113 @@ using namespace std; -CordbCode::CordbCode(Connection *conn, CordbFunction *func) - : CordbBaseMono(conn) { - this->m_pFunction = func; +CordbCode::CordbCode(Connection* conn, CordbFunction* func) : CordbBaseMono(conn) +{ + this->m_pFunction = func; } -HRESULT __stdcall CordbCode::IsIL(BOOL *pbIL) { - LOG((LF_CORDB, LL_INFO100000, "CordbCode - IsIL - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbCode::IsIL(BOOL* pbIL) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbCode - IsIL - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbCode::GetFunction(ICorDebugFunction **ppFunction) { - LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetFunction - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbCode::GetFunction(ICorDebugFunction** ppFunction) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetFunction - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbCode::GetAddress(CORDB_ADDRESS *pStart) { - LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetAddress - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbCode::GetAddress(CORDB_ADDRESS* pStart) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetAddress - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbCode::GetSize(ULONG32 *pcBytes) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); +HRESULT __stdcall CordbCode::GetSize(ULONG32* pcBytes) +{ + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); - m_dbgprot_buffer_free(&localbuf); + m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - int code_size = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - *pcBytes = code_size; - LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetSize - IMPLEMENTED\n")); - return S_OK; + int code_size = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + *pcBytes = code_size; + LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetSize - IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbCode::CreateBreakpoint( - ULONG32 offset, ICorDebugFunctionBreakpoint **ppBreakpoint) { - // add it in a list to not recreate a already created breakpoint - CordbFunctionBreakpoint *bp = new CordbFunctionBreakpoint(conn, this, offset); - bp->QueryInterface(IID_ICorDebugFunctionBreakpoint, (void **)ppBreakpoint); - LOG((LF_CORDB, LL_INFO1000000, - "CordbCode - CreateBreakpoint - IMPLEMENTED\n")); - return S_OK; +HRESULT __stdcall CordbCode::CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint** ppBreakpoint) +{ + // add it in a list to not recreate a already created breakpoint + CordbFunctionBreakpoint* bp = new CordbFunctionBreakpoint(conn, this, offset); + bp->QueryInterface(IID_ICorDebugFunctionBreakpoint, (void**)ppBreakpoint); + LOG((LF_CORDB, LL_INFO1000000, "CordbCode - CreateBreakpoint - IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbCode::GetCode(ULONG32 startOffset, ULONG32 endOffset, - ULONG32 cBufferAlloc, BYTE buffer[], - ULONG32 *pcBufferSize) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); +HRESULT __stdcall CordbCode::GetCode( + ULONG32 startOffset, ULONG32 endOffset, ULONG32 cBufferAlloc, BYTE buffer[], ULONG32* pcBufferSize) +{ + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); - m_dbgprot_buffer_free(&localbuf); + m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - uint8_t *code = m_dbgprot_decode_byte_array( - pReply->p, &pReply->p, pReply->end, (int32_t *)pcBufferSize); + uint8_t* code = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, (int32_t*)pcBufferSize); - memcpy(buffer, code, *pcBufferSize); - free(code); - LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetCode - IMPLEMENTED\n")); - return S_OK; + memcpy(buffer, code, *pcBufferSize); + free(code); + LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetCode - IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbCode::GetVersionNumber(ULONG32 *nVersion) { - *nVersion = 1; - LOG((LF_CORDB, LL_INFO100000, - "CordbCode - GetVersionNumber - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT __stdcall CordbCode::GetVersionNumber(ULONG32* nVersion) +{ + *nVersion = 1; + LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetVersionNumber - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbCode::GetILToNativeMapping( - ULONG32 cMap, ULONG32 *pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbCode - GetILToNativeMapping - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbCode::GetILToNativeMapping(ULONG32 cMap, ULONG32* pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetILToNativeMapping - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbCode::GetEnCRemapSequencePoints(ULONG32 cMap, - ULONG32 *pcMap, - ULONG32 offsets[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbCode - GetEnCRemapSequencePoints - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbCode::GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32* pcMap, ULONG32 offsets[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetEnCRemapSequencePoints - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbCode::QueryInterface(REFIID id, void **pInterface) { - if (id == IID_ICorDebugCode) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; +HRESULT __stdcall CordbCode::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugCode) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } diff --git a/src/mono/dbi/cordb-code.h b/src/mono/dbi/cordb-code.h index 28e238ec4286ab..4108d051a51a18 100644 --- a/src/mono/dbi/cordb-code.h +++ b/src/mono/dbi/cordb-code.h @@ -9,34 +9,47 @@ #include -class CordbCode : public CordbBaseMono, public ICorDebugCode { - CordbFunction *m_pFunction; +class CordbCode : public CordbBaseMono, public ICorDebugCode +{ + CordbFunction* m_pFunction; public: - CordbCode(Connection *conn, CordbFunction *func); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbCode"; } - HRESULT IsIL(BOOL *pbIL); - HRESULT - GetFunction(ICorDebugFunction **ppFunction); - HRESULT GetAddress(CORDB_ADDRESS *pStart); - HRESULT GetSize(ULONG32 *pcBytes); - HRESULT - CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint **ppBreakpoint); - HRESULT GetCode(ULONG32 startOffset, ULONG32 endOffset, ULONG32 cBufferAlloc, - BYTE buffer[], ULONG32 *pcBufferSize); - HRESULT GetVersionNumber(ULONG32 *nVersion); - HRESULT - GetILToNativeMapping(ULONG32 cMap, ULONG32 *pcMap, + CordbCode(Connection* conn, CordbFunction* func); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbCode"; + } + HRESULT IsIL(BOOL* pbIL); + HRESULT + GetFunction(ICorDebugFunction** ppFunction); + HRESULT GetAddress(CORDB_ADDRESS* pStart); + HRESULT GetSize(ULONG32* pcBytes); + HRESULT + CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint** ppBreakpoint); + HRESULT GetCode(ULONG32 startOffset, ULONG32 endOffset, ULONG32 cBufferAlloc, BYTE buffer[], ULONG32* pcBufferSize); + HRESULT GetVersionNumber(ULONG32* nVersion); + HRESULT + GetILToNativeMapping(ULONG32 cMap, + ULONG32* pcMap, - COR_DEBUG_IL_TO_NATIVE_MAP map[]); - HRESULT - GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32 *pcMap, ULONG32 offsets[]); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + COR_DEBUG_IL_TO_NATIVE_MAP map[]); + HRESULT + GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32* pcMap, ULONG32 offsets[]); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - CordbFunction *GetFunction() const { return m_pFunction; } + CordbFunction* GetFunction() const + { + return m_pFunction; + } }; #endif diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index 431f1920c8cf15..7915dd73b0c28e 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -18,232 +18,242 @@ #include "rwutil.h" #include "stdafx.h" -CordbEval::CordbEval(Connection *conn, CordbThread *thread) - : CordbBaseMono(conn) { - this->m_pThread = thread; - if (thread) - thread->InternalAddRef(); - m_pValue = NULL; - m_commandId = -1; -} - -CordbEval::~CordbEval() { - if (m_pThread) - m_pThread->InternalRelease(); -} -HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction( - ICorDebugFunction *pFunction, ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]) { - conn->GetProcess()->Stop(false); - LOG((LF_CORDB, LL_INFO1000000, - "CordbEval - CallParameterizedFunction - IMPLEMENTED\n")); - - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_int(&localbuf, 1); - m_dbgprot_buffer_add_int(&localbuf, - ((CordbFunction *)pFunction)->GetDebuggerId()); - m_dbgprot_buffer_add_int(&localbuf, nArgs); - for (ULONG32 i = 0; i < nArgs; i++) { - CorElementType ty; - ppArgs[i]->GetType(&ty); - CordbContent *cc; - ppArgs[i]->GetAddress((CORDB_ADDRESS *)&cc); - m_dbgprot_buffer_add_byte(&localbuf, ty); - switch (ty) { - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_I1: - case ELEMENT_TYPE_U1: - m_dbgprot_buffer_add_int(&localbuf, cc->booleanValue); - break; - case ELEMENT_TYPE_CHAR: - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - m_dbgprot_buffer_add_int(&localbuf, cc->charValue); - break; - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - case ELEMENT_TYPE_R4: - m_dbgprot_buffer_add_int(&localbuf, cc->intValue); - break; - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - case ELEMENT_TYPE_R8: - m_dbgprot_buffer_add_long(&localbuf, cc->longValue); - break; - case ELEMENT_TYPE_CLASS: - case ELEMENT_TYPE_SZARRAY: - case ELEMENT_TYPE_STRING: - m_dbgprot_buffer_add_id(&localbuf, cc->intValue); - break; - default: - return E_NOTIMPL; +CordbEval::CordbEval(Connection* conn, CordbThread* thread) : CordbBaseMono(conn) +{ + this->m_pThread = thread; + if (thread) + thread->InternalAddRef(); + m_pValue = NULL; + m_commandId = -1; +} + +CordbEval::~CordbEval() +{ + if (m_pThread) + m_pThread->InternalRelease(); +} +HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction(ICorDebugFunction* pFunction, + ULONG32 nTypeArgs, + ICorDebugType* ppTypeArgs[], + ULONG32 nArgs, + ICorDebugValue* ppArgs[]) +{ + conn->GetProcess()->Stop(false); + LOG((LF_CORDB, LL_INFO1000000, "CordbEval - CallParameterizedFunction - IMPLEMENTED\n")); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_int(&localbuf, 1); + m_dbgprot_buffer_add_int(&localbuf, ((CordbFunction*)pFunction)->GetDebuggerId()); + m_dbgprot_buffer_add_int(&localbuf, nArgs); + for (ULONG32 i = 0; i < nArgs; i++) + { + CorElementType ty; + ppArgs[i]->GetType(&ty); + CordbContent* cc; + ppArgs[i]->GetAddress((CORDB_ADDRESS*)&cc); + m_dbgprot_buffer_add_byte(&localbuf, ty); + switch (ty) + { + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + m_dbgprot_buffer_add_int(&localbuf, cc->booleanValue); + break; + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + m_dbgprot_buffer_add_int(&localbuf, cc->charValue); + break; + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: + m_dbgprot_buffer_add_int(&localbuf, cc->intValue); + break; + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: + m_dbgprot_buffer_add_long(&localbuf, cc->longValue); + break; + case ELEMENT_TYPE_CLASS: + case ELEMENT_TYPE_SZARRAY: + case ELEMENT_TYPE_STRING: + m_dbgprot_buffer_add_id(&localbuf, cc->intValue); + break; + default: + return E_NOTIMPL; + } } - } - m_commandId = conn->SendEvent(MDBGPROT_CMD_SET_VM, - MDBGPROT_CMD_VM_INVOKE_METHOD, &localbuf); - m_dbgprot_buffer_free(&localbuf); - conn->GetProcess()->AddPendingEval(this); - return S_OK; + m_commandId = conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_INVOKE_METHOD, &localbuf); + m_dbgprot_buffer_free(&localbuf); + conn->GetProcess()->AddPendingEval(this); + return S_OK; } -void CordbEval::EvalComplete(MdbgProtBuffer *pReply) { +void CordbEval::EvalComplete(MdbgProtBuffer* pReply) +{ - m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - CordbObjectValue::CreateCordbValue(conn, pReply, &m_pValue); + m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + CordbObjectValue::CreateCordbValue(conn, pReply, &m_pValue); - conn->GetCordb()->GetCallback()->EvalComplete( - conn->GetProcess()->GetCurrentAppDomain(), m_pThread, this); + conn->GetCordb()->GetCallback()->EvalComplete(conn->GetProcess()->GetCurrentAppDomain(), m_pThread, this); } -HRESULT STDMETHODCALLTYPE -CordbEval::CreateValueForType(ICorDebugType *pType, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbEval - CreateValueForType - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::CreateValueForType(ICorDebugType* pType, ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - CreateValueForType - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedObject( - ICorDebugFunction *pConstructor, ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[], ULONG32 nArgs, ICorDebugValue *ppArgs[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbEval - NewParameterizedObject - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedObject(ICorDebugFunction* pConstructor, + ULONG32 nTypeArgs, + ICorDebugType* ppTypeArgs[], + ULONG32 nArgs, + ICorDebugValue* ppArgs[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewParameterizedObject - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedObjectNoConstructor( - ICorDebugClass *pClass, ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbEval - NewParameterizedObjectNoConstructor - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedObjectNoConstructor(ICorDebugClass* pClass, + ULONG32 nTypeArgs, + ICorDebugType* ppTypeArgs[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewParameterizedObjectNoConstructor - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbEval::NewParameterizedArray(ICorDebugType *pElementType, ULONG32 rank, - ULONG32 dims[], ULONG32 lowBounds[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbEval - NewParameterizedArray - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedArray(ICorDebugType* pElementType, + ULONG32 rank, + ULONG32 dims[], + ULONG32 lowBounds[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewParameterizedArray - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, - UINT uiLength) { - conn->GetProcess()->Stop(false); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, - MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, UINT uiLength) +{ + conn->GetProcess()->Stop(false); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - int domainId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int domainId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - LPSTR szString; - UTF8STR(string, szString); + LPSTR szString; + UTF8STR(string, szString); - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, domainId); - m_dbgprot_buffer_add_string(&localbuf, szString); - this->m_commandId = - conn->SendEvent(MDBGPROT_CMD_SET_APPDOMAIN, - MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); - m_dbgprot_buffer_free(&localbuf); - conn->GetProcess()->AddPendingEval(this); - return S_OK; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, domainId); + m_dbgprot_buffer_add_string(&localbuf, szString); + this->m_commandId = conn->SendEvent(MDBGPROT_CMD_SET_APPDOMAIN, MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); + m_dbgprot_buffer_free(&localbuf); + conn->GetProcess()->AddPendingEval(this); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbEval::RudeAbort(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbEval - RudeAbort - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbEval::RudeAbort(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - RudeAbort - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbEval::QueryInterface(REFIID id, - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { - if (id == IID_ICorDebugEval) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugEval2) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; +CordbEval::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface) +{ + if (id == IID_ICorDebugEval) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugEval2) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbEval::CallFunction(ICorDebugFunction *pFunction, - ULONG32 nArgs, - ICorDebugValue *ppArgs[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbEval - CallFunction - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::CallFunction(ICorDebugFunction* pFunction, ULONG32 nArgs, ICorDebugValue* ppArgs[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - CallFunction - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::NewObject(ICorDebugFunction *pConstructor, - ULONG32 nArgs, - ICorDebugValue *ppArgs[]) { - LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewObject - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::NewObject(ICorDebugFunction* pConstructor, ULONG32 nArgs, ICorDebugValue* ppArgs[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewObject - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbEval::NewObjectNoConstructor(ICorDebugClass *pClass) { - LOG((LF_CORDB, LL_INFO100000, - "CordbEval - NewObjectNoConstructor - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::NewObjectNoConstructor(ICorDebugClass* pClass) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewObjectNoConstructor - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::NewString(LPCWSTR string) { - LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewString - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::NewString(LPCWSTR string) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewString - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::NewArray(CorElementType elementType, - ICorDebugClass *pElementClass, - ULONG32 rank, ULONG32 dims[], - ULONG32 lowBounds[]) { - LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewArray - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::NewArray( + CorElementType elementType, ICorDebugClass* pElementClass, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - NewArray - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::IsActive(BOOL *pbActive) { - LOG((LF_CORDB, LL_INFO100000, "CordbEval - IsActive - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::IsActive(BOOL* pbActive) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - IsActive - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::Abort(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbEval - Abort - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbEval::Abort(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - Abort - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbEval::GetResult(ICorDebugValue **ppResult) { - *ppResult = m_pValue; - LOG((LF_CORDB, LL_INFO1000000, "CordbEval - GetResult - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbEval::GetResult(ICorDebugValue** ppResult) +{ + *ppResult = m_pValue; + LOG((LF_CORDB, LL_INFO1000000, "CordbEval - GetResult - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbEval::GetThread(ICorDebugThread **ppThread) { - LOG((LF_CORDB, LL_INFO100000, "CordbEval - GetThread - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbEval::GetThread(ICorDebugThread** ppThread) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbEval - GetThread - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbEval::CreateValue(CorElementType elementType, - ICorDebugClass *pElementClass, - ICorDebugValue **ppValue) { - CordbContent content_value; - content_value.booleanValue = 0; - CordbValue *value = - new CordbValue(conn, elementType, content_value, - CordbObjectValue::GetTypeSize(elementType)); - LOG((LF_CORDB, LL_INFO1000000, "CordbEval - CreateValue - IMPLEMENTED\n")); - value->QueryInterface(IID_ICorDebugValue, (void **)ppValue); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbEval::CreateValue(CorElementType elementType, + ICorDebugClass* pElementClass, + ICorDebugValue** ppValue) +{ + CordbContent content_value; + content_value.booleanValue = 0; + CordbValue* value = new CordbValue(conn, elementType, content_value, CordbObjectValue::GetTypeSize(elementType)); + LOG((LF_CORDB, LL_INFO1000000, "CordbEval - CreateValue - IMPLEMENTED\n")); + value->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + return S_OK; } diff --git a/src/mono/dbi/cordb-eval.h b/src/mono/dbi/cordb-eval.h index 2af68c39b2c38e..b1772087736aa9 100644 --- a/src/mono/dbi/cordb-eval.h +++ b/src/mono/dbi/cordb-eval.h @@ -9,56 +9,63 @@ #include -class CordbEval : public CordbBaseMono, - public ICorDebugEval, - public ICorDebugEval2 { - CordbThread *m_pThread; - ICorDebugValue *m_pValue; - int m_commandId; +class CordbEval : public CordbBaseMono, public ICorDebugEval, public ICorDebugEval2 +{ + CordbThread* m_pThread; + ICorDebugValue* m_pValue; + int m_commandId; public: - CordbEval(Connection *conn, CordbThread *thread); - ~CordbEval(); - void EvalComplete(MdbgProtBuffer *pReply); + CordbEval(Connection* conn, CordbThread* thread); + ~CordbEval(); + void EvalComplete(MdbgProtBuffer* pReply); - HRESULT CallParameterizedFunction(ICorDebugFunction *pFunction, - ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[], ULONG32 nArgs, - ICorDebugValue *ppArgs[]); - HRESULT NewParameterizedObject(ICorDebugFunction *pConstructor, - ULONG32 nTypeArgs, ICorDebugType *ppTypeArgs[], - ULONG32 nArgs, ICorDebugValue *ppArgs[]); - HRESULT NewParameterizedObjectNoConstructor(ICorDebugClass *pClass, - ULONG32 nTypeArgs, - ICorDebugType *ppTypeArgs[]); - HRESULT CallFunction(ICorDebugFunction *pFunction, ULONG32 nArgs, - ICorDebugValue *ppArgs[]); - HRESULT NewObject(ICorDebugFunction *pConstructor, ULONG32 nArgs, - ICorDebugValue *ppArgs[]); - HRESULT - NewObjectNoConstructor(ICorDebugClass *pClass); - HRESULT NewString(LPCWSTR string); - HRESULT NewArray(CorElementType elementType, ICorDebugClass *pElementClass, - ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]); - HRESULT IsActive(BOOL *pbActive); - HRESULT Abort(void); - HRESULT GetResult(ICorDebugValue **ppResult); - HRESULT GetThread(ICorDebugThread **ppThread); - HRESULT CreateValue(CorElementType elementType, ICorDebugClass *pElementClass, - ICorDebugValue **ppValue); - HRESULT - CreateValueForType(ICorDebugType *pType, ICorDebugValue **ppValue); - HRESULT - NewParameterizedArray(ICorDebugType *pElementType, ULONG32 rank, - ULONG32 dims[], ULONG32 lowBounds[]); - HRESULT NewStringWithLength(LPCWSTR string, UINT uiLength); - HRESULT RudeAbort(void); - HRESULT QueryInterface(REFIID riid, - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbEval"; } - int GetCommandId() const { return m_commandId; } + HRESULT CallParameterizedFunction(ICorDebugFunction* pFunction, + ULONG32 nTypeArgs, + ICorDebugType* ppTypeArgs[], + ULONG32 nArgs, + ICorDebugValue* ppArgs[]); + HRESULT NewParameterizedObject(ICorDebugFunction* pConstructor, + ULONG32 nTypeArgs, + ICorDebugType* ppTypeArgs[], + ULONG32 nArgs, + ICorDebugValue* ppArgs[]); + HRESULT NewParameterizedObjectNoConstructor(ICorDebugClass* pClass, ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[]); + HRESULT CallFunction(ICorDebugFunction* pFunction, ULONG32 nArgs, ICorDebugValue* ppArgs[]); + HRESULT NewObject(ICorDebugFunction* pConstructor, ULONG32 nArgs, ICorDebugValue* ppArgs[]); + HRESULT + NewObjectNoConstructor(ICorDebugClass* pClass); + HRESULT NewString(LPCWSTR string); + HRESULT NewArray( + CorElementType elementType, ICorDebugClass* pElementClass, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]); + HRESULT IsActive(BOOL* pbActive); + HRESULT Abort(void); + HRESULT GetResult(ICorDebugValue** ppResult); + HRESULT GetThread(ICorDebugThread** ppThread); + HRESULT CreateValue(CorElementType elementType, ICorDebugClass* pElementClass, ICorDebugValue** ppValue); + HRESULT + CreateValueForType(ICorDebugType* pType, ICorDebugValue** ppValue); + HRESULT + NewParameterizedArray(ICorDebugType* pElementType, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]); + HRESULT NewStringWithLength(LPCWSTR string, UINT uiLength); + HRESULT RudeAbort(void); + HRESULT QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbEval"; + } + int GetCommandId() const + { + return m_commandId; + } }; #endif diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index 885c710583ba01..d08ae9e6bbeef3 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -14,481 +14,506 @@ using namespace std; -CordbFrameEnum::CordbFrameEnum(Connection *conn, CordbThread *thread) - : CordbBaseMono(conn) { - this->m_pThread = thread; - m_nFrames = 0; - m_ppFrames = NULL; +CordbFrameEnum::CordbFrameEnum(Connection* conn, CordbThread* thread) : CordbBaseMono(conn) +{ + this->m_pThread = thread; + m_nFrames = 0; + m_ppFrames = NULL; } -CordbFrameEnum::~CordbFrameEnum() { Reset(); } - -HRESULT STDMETHODCALLTYPE CordbFrameEnum::Next(ULONG celt, - ICorDebugFrame *frames[], - ULONG *pceltFetched) { - for (int i = 0; i < m_nFrames; i++) { - this->m_ppFrames[i]->QueryInterface(IID_ICorDebugFrame, - (void **)&frames[i]); - } - LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - Next - IMPLEMENTED\n")); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbFrameEnum::Skip(ULONG celt) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - Skip - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +CordbFrameEnum::~CordbFrameEnum() +{ + Reset(); } -HRESULT STDMETHODCALLTYPE CordbFrameEnum::Reset(void) { - for (int i = 0; i < m_nFrames; i++) { - this->m_ppFrames[i]->InternalRelease(); - } - m_nFrames = 0; - if (m_ppFrames) - free(m_ppFrames); - m_ppFrames = NULL; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbFrameEnum::Next(ULONG celt, ICorDebugFrame* frames[], ULONG* pceltFetched) +{ + for (int i = 0; i < m_nFrames; i++) + { + this->m_ppFrames[i]->QueryInterface(IID_ICorDebugFrame, (void**)&frames[i]); + } + LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - Next - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbFrameEnum::Clone(ICorDebugEnum **ppEnum) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - Clone - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbFrameEnum::Skip(ULONG celt) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - Skip - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG *pcelt) { - Reset(); - - LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - GetCount - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_int(&localbuf, 0); - m_dbgprot_buffer_add_int(&localbuf, -1); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, - MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - - m_nFrames = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_ppFrames = - (CordbNativeFrame **)malloc(sizeof(CordbNativeFrame *) * m_nFrames); - - for (int i = 0; i < m_nFrames; i++) { - int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - - CordbNativeFrame *frame = new CordbNativeFrame(conn, frameid, methodId, - il_offset, flags, m_pThread); - frame->InternalAddRef(); - m_ppFrames[i] = frame; - } +HRESULT STDMETHODCALLTYPE CordbFrameEnum::Reset(void) +{ + for (int i = 0; i < m_nFrames; i++) + { + this->m_ppFrames[i]->InternalRelease(); + } + m_nFrames = 0; + if (m_ppFrames) + free(m_ppFrames); + m_ppFrames = NULL; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE CordbFrameEnum::Clone(ICorDebugEnum** ppEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - Clone - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG* pcelt) +{ + Reset(); + + LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - GetCount - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_int(&localbuf, 0); + m_dbgprot_buffer_add_int(&localbuf, -1); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_nFrames = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_ppFrames = (CordbNativeFrame**)malloc(sizeof(CordbNativeFrame*) * m_nFrames); + + for (int i = 0; i < m_nFrames; i++) + { + int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + + CordbNativeFrame* frame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, m_pThread); + frame->InternalAddRef(); + m_ppFrames[i] = frame; + } - if (!m_pThread->GetStepper()) - m_pThread->SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); + if (!m_pThread->GetStepper()) + m_pThread->SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); - *pcelt = m_nFrames; - return S_OK; + *pcelt = m_nFrames; + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbFrameEnum::QueryInterface(REFIID riid, - void **ppvObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrameEnum - QueryInterface - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbFrameEnum::QueryInterface(REFIID riid, void** ppvObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - QueryInterface - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -CordbJITILFrame::CordbJITILFrame(Connection *conn, int frameid, int methodId, - int il_offset, int flags, CordbThread *thread) - : CordbBaseMono(conn) { - this->m_debuggerFrameId = frameid; - this->m_debuggerMethodId = methodId; - this->m_ilOffset = il_offset; - this->m_flags = flags; - this->m_pThread = thread; +CordbJITILFrame::CordbJITILFrame( + Connection* conn, int frameid, int methodId, int il_offset, int flags, CordbThread* thread) + : CordbBaseMono(conn) +{ + this->m_debuggerFrameId = frameid; + this->m_debuggerMethodId = methodId; + this->m_ilOffset = il_offset; + this->m_flags = flags; + this->m_pThread = thread; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetChain(ICorDebugChain **ppChain) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetChain - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetChain(ICorDebugChain** ppChain) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetChain - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCode(ICorDebugCode **ppCode) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCode - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCode(ICorDebugCode** ppCode) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCode - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::GetFunction(ICorDebugFunction **ppFunction) { - CordbFunction *func = conn->GetProcess()->FindFunction(m_debuggerMethodId); - if (!func) { - func = new CordbFunction(conn, 0, m_debuggerMethodId, NULL); - } - func->QueryInterface(IID_ICorDebugFunction, (void **)ppFunction); - LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetFunction - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunction(ICorDebugFunction** ppFunction) +{ + CordbFunction* func = conn->GetProcess()->FindFunction(m_debuggerMethodId); + if (!func) + { + func = new CordbFunction(conn, 0, m_debuggerMethodId, NULL); + } + func->QueryInterface(IID_ICorDebugFunction, (void**)ppFunction); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetFunction - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::GetFunctionToken(mdMethodDef *pToken) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - GetFunctionToken - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunctionToken(mdMethodDef* pToken) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetFunctionToken - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackRange(CORDB_ADDRESS *pStart, - CORDB_ADDRESS *pEnd) { - *pStart = 4096; - *pEnd = 8192; - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - GetStackRange - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd) +{ + *pStart = 4096; + *pEnd = 8192; + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetStackRange - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCaller(ICorDebugFrame **ppFrame) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCaller - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCaller(ICorDebugFrame** ppFrame) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCaller - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCallee(ICorDebugFrame **ppFrame) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCallee - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCallee(ICorDebugFrame** ppFrame) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetCallee - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::CreateStepper(ICorDebugStepper **ppStepper) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - CreateStepper - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::CreateStepper(ICorDebugStepper** ppStepper) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - CreateStepper - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::QueryInterface( - REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { - if (id == IID_ICorDebugILFrame) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugILFrame2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugILFrame3) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugILFrame4) { - *pInterface = static_cast(this); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface) +{ + if (id == IID_ICorDebugILFrame) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugILFrame2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugILFrame3) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugILFrame4) + { + *pInterface = static_cast(this); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::RemapFunction(ULONG32 newILOffset) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - RemapFunction - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::RemapFunction(ULONG32 newILOffset) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - RemapFunction - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - EnumerateTypeParameters - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateTypeParameters(ICorDebugTypeEnum** ppTyParEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - EnumerateTypeParameters - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetReturnValueForILOffset( - ULONG32 ILoffset, ICorDebugValue **ppReturnValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - GetReturnValueForILOffset - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetReturnValueForILOffset(ULONG32 ILoffset, ICorDebugValue** ppReturnValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetReturnValueForILOffset - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariablesEx( - ILCodeKind flags, ICorDebugValueEnum **ppValueEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - EnumerateLocalVariablesEx - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariablesEx(ILCodeKind flags, ICorDebugValueEnum** ppValueEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - EnumerateLocalVariablesEx - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariableEx( - ILCodeKind flags, DWORD dwIndex, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - GetLocalVariableEx - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetLocalVariableEx - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } - -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCodeEx(ILCodeKind flags, - ICorDebugCode **ppCode) { - if (flags == ILCODE_REJIT_IL) - *ppCode = NULL; - else { - ICorDebugFunction *ppFunction; - GetFunction(&ppFunction); - ppFunction->GetILCode(ppCode); - ppFunction->Release(); - } - LOG((LF_CORDB, LL_INFO1000000, - "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n")); - return S_OK; + +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetCodeEx(ILCodeKind flags, ICorDebugCode** ppCode) +{ + if (flags == ILCODE_REJIT_IL) + *ppCode = NULL; + else + { + ICorDebugFunction* ppFunction; + GetFunction(&ppFunction); + ppFunction->GetILCode(ppCode); + ppFunction->Release(); + } + LOG((LF_CORDB, LL_INFO1000000, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetIP( - ULONG32 *pnOffset, CorDebugMappingResult *pMappingResult) { - *pnOffset = m_ilOffset; - *pMappingResult = MAPPING_EXACT; - LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetIP - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetIP(ULONG32* pnOffset, CorDebugMappingResult* pMappingResult) +{ + *pnOffset = m_ilOffset; + *pMappingResult = MAPPING_EXACT; + LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetIP - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::SetIP(ULONG32 nOffset) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrame - SetIP - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::SetIP(ULONG32 nOffset) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - SetIP - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::EnumerateLocalVariables(ICorDebugValueEnum **ppValueEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - EnumerateLocalVariables - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariables(ICorDebugValueEnum** ppValueEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - EnumerateLocalVariables - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::GetLocalVariable(DWORD dwIndex, ICorDebugValue **ppValue) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); - m_dbgprot_buffer_add_int(&localbuf, 1); - m_dbgprot_buffer_add_int(&localbuf, dwIndex); +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariable(DWORD dwIndex, ICorDebugValue** ppValue) +{ + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); + m_dbgprot_buffer_add_int(&localbuf, 1); + m_dbgprot_buffer_add_int(&localbuf, dwIndex); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, - MDBGPROT_CMD_STACK_FRAME_GET_VALUES, &localbuf); - m_dbgprot_buffer_free(&localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, MDBGPROT_CMD_STACK_FRAME_GET_VALUES, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - return CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); + return CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); } -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::EnumerateArguments(ICorDebugValueEnum **ppValueEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - EnumerateArguments - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateArguments(ICorDebugValueEnum** ppValueEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - EnumerateArguments - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::GetArgument(DWORD dwIndex, ICorDebugValue **ppValue) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetArgument(DWORD dwIndex, ICorDebugValue** ppValue) +{ + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); - m_dbgprot_buffer_add_int(&localbuf, dwIndex); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, - MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); - m_dbgprot_buffer_free(&localbuf); + m_dbgprot_buffer_add_int(&localbuf, dwIndex); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetArgument - IMPLEMENTED\n")); - return CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetArgument - IMPLEMENTED\n")); + return CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackDepth(ULONG32 *pDepth) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - GetStackDepth - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackDepth(ULONG32* pDepth) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetStackDepth - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbJITILFrame::GetStackValue(DWORD dwIndex, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFrame - GetStackValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackValue(DWORD dwIndex, ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetStackValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbJITILFrame::CanSetIP(ULONG32 nOffset) { - LOG((LF_CORDB, LL_INFO100000, "CordbFrame - CanSetIP - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbJITILFrame::CanSetIP(ULONG32 nOffset) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFrame - CanSetIP - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -CordbNativeFrame::~CordbNativeFrame() { m_JITILFrame->InternalRelease(); } +CordbNativeFrame::~CordbNativeFrame() +{ + m_JITILFrame->InternalRelease(); +} -CordbNativeFrame::CordbNativeFrame(Connection *conn, int frameid, int methodId, - int il_offset, int flags, - CordbThread *thread) - : CordbBaseMono(conn) { - m_JITILFrame = - new CordbJITILFrame(conn, frameid, methodId, il_offset, flags, thread); - m_JITILFrame->InternalAddRef(); - this->m_pThread = thread; +CordbNativeFrame::CordbNativeFrame( + Connection* conn, int frameid, int methodId, int il_offset, int flags, CordbThread* thread) + : CordbBaseMono(conn) +{ + m_JITILFrame = new CordbJITILFrame(conn, frameid, methodId, il_offset, flags, thread); + m_JITILFrame->InternalAddRef(); + this->m_pThread = thread; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetIP(ULONG32 *pnOffset) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetIP - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetIP(ULONG32* pnOffset) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetIP - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::SetIP(ULONG32 nOffset) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - SetIP - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::SetIP(ULONG32 nOffset) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - SetIP - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbNativeFrame::GetRegisterSet(ICorDebugRegisterSet **ppRegisters) { - return m_pThread->GetRegisterSet(ppRegisters); +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetRegisterSet(ICorDebugRegisterSet** ppRegisters) +{ + return m_pThread->GetRegisterSet(ppRegisters); } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterValue( - CorDebugRegister reg, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetLocalRegisterValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterValue(CorDebugRegister reg, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetLocalRegisterValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalDoubleRegisterValue( - CorDebugRegister highWordReg, CorDebugRegister lowWordReg, ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetLocalDoubleRegisterValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalDoubleRegisterValue(CorDebugRegister highWordReg, + CorDebugRegister lowWordReg, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetLocalDoubleRegisterValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalMemoryValue( - CORDB_ADDRESS address, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetLocalMemoryValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalMemoryValue(CORDB_ADDRESS address, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetLocalMemoryValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterMemoryValue( - CorDebugRegister highWordReg, CORDB_ADDRESS lowWordAddress, ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetLocalRegisterMemoryValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalRegisterMemoryValue(CorDebugRegister highWordReg, + CORDB_ADDRESS lowWordAddress, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetLocalRegisterMemoryValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalMemoryRegisterValue( - CORDB_ADDRESS highWordAddress, CorDebugRegister lowWordRegister, - ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetLocalMemoryRegisterValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetLocalMemoryRegisterValue(CORDB_ADDRESS highWordAddress, + CorDebugRegister lowWordRegister, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetLocalMemoryRegisterValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::CanSetIP(ULONG32 nOffset) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - CanSetIP - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::CanSetIP(ULONG32 nOffset) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - CanSetIP - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetChain(ICorDebugChain **ppChain) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetChain - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetChain(ICorDebugChain** ppChain) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetChain - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCode(ICorDebugCode **ppCode) { - ICorDebugFunction *ppFunction; - m_JITILFrame->GetFunction(&ppFunction); - ppFunction->GetILCode(ppCode); - ppFunction->Release(); - LOG((LF_CORDB, LL_INFO100000, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCode(ICorDebugCode** ppCode) +{ + ICorDebugFunction* ppFunction; + m_JITILFrame->GetFunction(&ppFunction); + ppFunction->GetILCode(ppCode); + ppFunction->Release(); + LOG((LF_CORDB, LL_INFO100000, "CordbJITILFrame - GetCodeEx - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbNativeFrame::GetFunction(ICorDebugFunction **ppFunction) { - return m_JITILFrame->GetFunction(ppFunction); +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetFunction(ICorDebugFunction** ppFunction) +{ + return m_JITILFrame->GetFunction(ppFunction); } -HRESULT STDMETHODCALLTYPE -CordbNativeFrame::GetFunctionToken(mdMethodDef *pToken) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetFunctionToken - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetFunctionToken(mdMethodDef* pToken) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetFunctionToken - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetStackRange(CORDB_ADDRESS *pStart, - CORDB_ADDRESS *pEnd) { - return m_JITILFrame->GetStackRange(pStart, pEnd); +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd) +{ + return m_JITILFrame->GetStackRange(pStart, pEnd); } -HRESULT STDMETHODCALLTYPE -CordbNativeFrame::GetCaller(ICorDebugFrame **ppFrame) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetCaller - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCaller(ICorDebugFrame** ppFrame) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetCaller - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbNativeFrame::GetCallee(ICorDebugFrame **ppFrame) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetCallee - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetCallee(ICorDebugFrame** ppFrame) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetCallee - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbNativeFrame::CreateStepper(ICorDebugStepper **ppStepper) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - CreateStepper - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::CreateStepper(ICorDebugStepper** ppStepper) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - CreateStepper - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugFrame) { - *pInterface = static_cast( - static_cast(this)); - } else if (id == IID_ICorDebugNativeFrame) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugNativeFrame2) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = - static_cast(static_cast(this)); - } else { - // might be searching for an IL Frame. delegate that search to the - // JITILFrame - if (m_JITILFrame != NULL) { - return m_JITILFrame->QueryInterface(id, pInterface); - } else { - *pInterface = NULL; - return E_NOINTERFACE; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugFrame) + { + *pInterface = static_cast(static_cast(this)); + } + else if (id == IID_ICorDebugNativeFrame) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugNativeFrame2) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + // might be searching for an IL Frame. delegate that search to the + // JITILFrame + if (m_JITILFrame != NULL) + { + return m_JITILFrame->QueryInterface(id, pInterface); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } } - } - AddRef(); - return S_OK; + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsChild(BOOL *pIsChild) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - IsChild - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsChild(BOOL* pIsChild) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - IsChild - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsMatchingParentFrame( - ICorDebugNativeFrame2 *pPotentialParentFrame, BOOL *pIsParent) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - IsMatchingParentFrame - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::IsMatchingParentFrame(ICorDebugNativeFrame2* pPotentialParentFrame, + BOOL* pIsParent) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - IsMatchingParentFrame - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbNativeFrame::GetStackParameterSize(ULONG32 *pSize) { - LOG((LF_CORDB, LL_INFO100000, - "CordbNativeFrame - GetStackParameterSize - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbNativeFrame::GetStackParameterSize(ULONG32* pSize) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbNativeFrame - GetStackParameterSize - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-frame.h b/src/mono/dbi/cordb-frame.h index 56447110bcb964..1e6464c82809f5 100644 --- a/src/mono/dbi/cordb-frame.h +++ b/src/mono/dbi/cordb-frame.h @@ -13,127 +13,153 @@ class CordbJITILFrame : public CordbBaseMono, public ICorDebugILFrame, public ICorDebugILFrame2, public ICorDebugILFrame3, - public ICorDebugILFrame4 { - int m_debuggerFrameId; - int m_debuggerMethodId; - int m_ilOffset; - int m_flags; - CordbThread *m_pThread; + public ICorDebugILFrame4 +{ + int m_debuggerFrameId; + int m_debuggerMethodId; + int m_ilOffset; + int m_flags; + CordbThread* m_pThread; public: - CordbJITILFrame(Connection *conn, int frameid, int methodId, int il_offset, - int flags, CordbThread *thread); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbJITILFrame"; } - HRESULT GetChain(ICorDebugChain **ppChain); - HRESULT GetCode(ICorDebugCode **ppCode); - HRESULT - GetFunction(ICorDebugFunction **ppFunction); - HRESULT GetFunctionToken(mdMethodDef *pToken); - HRESULT GetStackRange(CORDB_ADDRESS *pStart, CORDB_ADDRESS *pEnd); - HRESULT GetCaller(ICorDebugFrame **ppFrame); - HRESULT GetCallee(ICorDebugFrame **ppFrame); - HRESULT - CreateStepper(ICorDebugStepper **ppStepper); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + CordbJITILFrame(Connection* conn, int frameid, int methodId, int il_offset, int flags, CordbThread* thread); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbJITILFrame"; + } + HRESULT GetChain(ICorDebugChain** ppChain); + HRESULT GetCode(ICorDebugCode** ppCode); + HRESULT + GetFunction(ICorDebugFunction** ppFunction); + HRESULT GetFunctionToken(mdMethodDef* pToken); + HRESULT GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); + HRESULT GetCaller(ICorDebugFrame** ppFrame); + HRESULT GetCallee(ICorDebugFrame** ppFrame); + HRESULT + CreateStepper(ICorDebugStepper** ppStepper); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT - GetIP(ULONG32 *pnOffset, CorDebugMappingResult *pMappingResult); - HRESULT SetIP(ULONG32 nOffset); - HRESULT - EnumerateLocalVariables(ICorDebugValueEnum **ppValueEnum); - HRESULT GetLocalVariable(DWORD dwIndex, ICorDebugValue **ppValue); - HRESULT - EnumerateArguments(ICorDebugValueEnum **ppValueEnum); - HRESULT GetArgument(DWORD dwIndex, ICorDebugValue **ppValue); - HRESULT GetStackDepth(ULONG32 *pDepth); - HRESULT GetStackValue(DWORD dwIndex, ICorDebugValue **ppValue); - HRESULT CanSetIP(ULONG32 nOffset); - HRESULT RemapFunction(ULONG32 newILOffset); - HRESULT - EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum); - HRESULT - GetReturnValueForILOffset(ULONG32 ILoffset, ICorDebugValue **ppReturnValue); - HRESULT - EnumerateLocalVariablesEx(ILCodeKind flags, ICorDebugValueEnum **ppValueEnum); - HRESULT GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, - ICorDebugValue **ppValue); - HRESULT GetCodeEx(ILCodeKind flags, ICorDebugCode **ppCode); + HRESULT + GetIP(ULONG32* pnOffset, CorDebugMappingResult* pMappingResult); + HRESULT SetIP(ULONG32 nOffset); + HRESULT + EnumerateLocalVariables(ICorDebugValueEnum** ppValueEnum); + HRESULT GetLocalVariable(DWORD dwIndex, ICorDebugValue** ppValue); + HRESULT + EnumerateArguments(ICorDebugValueEnum** ppValueEnum); + HRESULT GetArgument(DWORD dwIndex, ICorDebugValue** ppValue); + HRESULT GetStackDepth(ULONG32* pDepth); + HRESULT GetStackValue(DWORD dwIndex, ICorDebugValue** ppValue); + HRESULT CanSetIP(ULONG32 nOffset); + HRESULT RemapFunction(ULONG32 newILOffset); + HRESULT + EnumerateTypeParameters(ICorDebugTypeEnum** ppTyParEnum); + HRESULT + GetReturnValueForILOffset(ULONG32 ILoffset, ICorDebugValue** ppReturnValue); + HRESULT + EnumerateLocalVariablesEx(ILCodeKind flags, ICorDebugValueEnum** ppValueEnum); + HRESULT GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, ICorDebugValue** ppValue); + HRESULT GetCodeEx(ILCodeKind flags, ICorDebugCode** ppCode); }; -class CordbNativeFrame : public CordbBaseMono, - public ICorDebugNativeFrame, - public ICorDebugNativeFrame2 { - CordbJITILFrame *m_JITILFrame; - CordbThread *m_pThread; +class CordbNativeFrame : public CordbBaseMono, public ICorDebugNativeFrame, public ICorDebugNativeFrame2 +{ + CordbJITILFrame* m_JITILFrame; + CordbThread* m_pThread; public: - CordbNativeFrame(Connection *conn, int frameid, int methodId, int il_offset, - int flags, CordbThread *thread); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbNativeFrame"; } - ~CordbNativeFrame(); - HRESULT GetIP(ULONG32 *pnOffset); - HRESULT SetIP(ULONG32 nOffset); - HRESULT GetRegisterSet(ICorDebugRegisterSet **ppRegisters); - HRESULT GetLocalRegisterValue(CorDebugRegister reg, ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue); - HRESULT GetLocalDoubleRegisterValue(CorDebugRegister highWordReg, - CorDebugRegister lowWordReg, - ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue); - HRESULT GetLocalMemoryValue(CORDB_ADDRESS address, ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue); - HRESULT GetLocalRegisterMemoryValue(CorDebugRegister highWordReg, - CORDB_ADDRESS lowWordAddress, - ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue); - HRESULT GetLocalMemoryRegisterValue(CORDB_ADDRESS highWordAddress, - CorDebugRegister lowWordRegister, - ULONG cbSigBlob, - PCCOR_SIGNATURE pvSigBlob, - ICorDebugValue **ppValue); - HRESULT CanSetIP(ULONG32 nOffset); - HRESULT GetChain(ICorDebugChain **ppChain); - HRESULT GetCode(ICorDebugCode **ppCode); - HRESULT GetFunction(ICorDebugFunction **ppFunction); - HRESULT GetFunctionToken(mdMethodDef *pToken); - HRESULT GetStackRange(CORDB_ADDRESS *pStart, CORDB_ADDRESS *pEnd); - HRESULT GetCaller(ICorDebugFrame **ppFrame); - HRESULT GetCallee(ICorDebugFrame **ppFrame); - HRESULT CreateStepper(ICorDebugStepper **ppStepper); - HRESULT QueryInterface(REFIID riid, void **ppvObject); + CordbNativeFrame(Connection* conn, int frameid, int methodId, int il_offset, int flags, CordbThread* thread); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbNativeFrame"; + } + ~CordbNativeFrame(); + HRESULT GetIP(ULONG32* pnOffset); + HRESULT SetIP(ULONG32 nOffset); + HRESULT GetRegisterSet(ICorDebugRegisterSet** ppRegisters); + HRESULT GetLocalRegisterValue(CorDebugRegister reg, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue); + HRESULT GetLocalDoubleRegisterValue(CorDebugRegister highWordReg, + CorDebugRegister lowWordReg, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue); + HRESULT GetLocalMemoryValue(CORDB_ADDRESS address, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue); + HRESULT GetLocalRegisterMemoryValue(CorDebugRegister highWordReg, + CORDB_ADDRESS lowWordAddress, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue); + HRESULT GetLocalMemoryRegisterValue(CORDB_ADDRESS highWordAddress, + CorDebugRegister lowWordRegister, + ULONG cbSigBlob, + PCCOR_SIGNATURE pvSigBlob, + ICorDebugValue** ppValue); + HRESULT CanSetIP(ULONG32 nOffset); + HRESULT GetChain(ICorDebugChain** ppChain); + HRESULT GetCode(ICorDebugCode** ppCode); + HRESULT GetFunction(ICorDebugFunction** ppFunction); + HRESULT GetFunctionToken(mdMethodDef* pToken); + HRESULT GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); + HRESULT GetCaller(ICorDebugFrame** ppFrame); + HRESULT GetCallee(ICorDebugFrame** ppFrame); + HRESULT CreateStepper(ICorDebugStepper** ppStepper); + HRESULT QueryInterface(REFIID riid, void** ppvObject); - HRESULT IsChild(BOOL *pIsChild); - HRESULT IsMatchingParentFrame(ICorDebugNativeFrame2 *pPotentialParentFrame, - BOOL *pIsParent); - HRESULT GetStackParameterSize(ULONG32 *pSize); + HRESULT IsChild(BOOL* pIsChild); + HRESULT IsMatchingParentFrame(ICorDebugNativeFrame2* pPotentialParentFrame, BOOL* pIsParent); + HRESULT GetStackParameterSize(ULONG32* pSize); }; -class CordbFrameEnum : public CordbBaseMono, public ICorDebugFrameEnum { - CordbThread *m_pThread; - int m_nFrames; - CordbNativeFrame **m_ppFrames; +class CordbFrameEnum : public CordbBaseMono, public ICorDebugFrameEnum +{ + CordbThread* m_pThread; + int m_nFrames; + CordbNativeFrame** m_ppFrames; public: - CordbFrameEnum(Connection *conn, CordbThread *thread); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbFrameEnum"; } - ~CordbFrameEnum(); - HRESULT Next(ULONG celt, ICorDebugFrame *frames[], ULONG *pceltFetched); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum **ppEnum); - HRESULT GetCount(ULONG *pcelt); - HRESULT QueryInterface(REFIID riid, void **ppvObject); + CordbFrameEnum(Connection* conn, CordbThread* thread); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbFrameEnum"; + } + ~CordbFrameEnum(); + HRESULT Next(ULONG celt, ICorDebugFrame* frames[], ULONG* pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum** ppEnum); + HRESULT GetCount(ULONG* pcelt); + HRESULT QueryInterface(REFIID riid, void** ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-function.cpp b/src/mono/dbi/cordb-function.cpp index f61ad43a011050..3914640e6019fc 100644 --- a/src/mono/dbi/cordb-function.cpp +++ b/src/mono/dbi/cordb-function.cpp @@ -12,180 +12,188 @@ using namespace std; -CordbFunction::CordbFunction(Connection *conn, mdToken token, int id, - CordbModule *module) - : CordbBaseMono(conn) { - this->m_metadataToken = token; - this->m_debuggerId = id; - m_pCode = NULL; - this->m_pModule = module; - if (module) - module->InternalAddRef(); - conn->GetProcess()->AddFunction(this); -} - -CordbFunction::~CordbFunction() { - if (m_pCode) - m_pCode->InternalRelease(); - if (m_pModule) - m_pModule->InternalRelease(); -} - -HRESULT __stdcall CordbFunction::QueryInterface(REFIID id, void **pInterface) { - if (id == IID_ICorDebugFunction) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugFunction2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugFunction3) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugFunction4) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = - static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule **ppModule) { - LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetModule - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - if (!m_pModule) { - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket *received_reply_packet = - conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - - int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - m_pModule = conn->GetProcess()->GetModule(module_id); +CordbFunction::CordbFunction(Connection* conn, mdToken token, int id, CordbModule* module) : CordbBaseMono(conn) +{ + this->m_metadataToken = token; + this->m_debuggerId = id; + m_pCode = NULL; + this->m_pModule = module; + if (module) + module->InternalAddRef(); + conn->GetProcess()->AddFunction(this); +} + +CordbFunction::~CordbFunction() +{ + if (m_pCode) + m_pCode->InternalRelease(); if (m_pModule) - m_pModule->InternalAddRef(); - } + m_pModule->InternalRelease(); +} + +HRESULT __stdcall CordbFunction::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugFunction) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugFunction2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugFunction3) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugFunction4) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; +} + +HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule** ppModule) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetModule - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + if (!m_pModule) + { + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); + m_dbgprot_buffer_free(&localbuf); - if (!m_pModule) - return S_FALSE; + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + m_pModule = conn->GetProcess()->GetModule(module_id); + if (m_pModule) + m_pModule->InternalAddRef(); + } + + if (!m_pModule) + return S_FALSE; - m_pModule->AddRef(); - *ppModule = static_cast(m_pModule); - return S_OK; -} + m_pModule->AddRef(); + *ppModule = static_cast(m_pModule); + return S_OK; +} -HRESULT __stdcall CordbFunction::GetClass(ICorDebugClass **ppClass) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunction - GetClass - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunction::GetClass(ICorDebugClass** ppClass) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetClass - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetToken(mdMethodDef *pMethodDef) { - if (this->GetMetadataToken() == 0) { - LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetToken - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, - MDBGPROT_CMD_METHOD_TOKEN, &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT __stdcall CordbFunction::GetToken(mdMethodDef* pMethodDef) +{ + if (this->GetMetadataToken() == 0) + { + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetToken - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_TOKEN, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = - conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - this->m_metadataToken = - m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - } - *pMethodDef = this->GetMetadataToken(); - return S_OK; + this->m_metadataToken = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + } + *pMethodDef = this->GetMetadataToken(); + return S_OK; } -HRESULT __stdcall CordbFunction::GetILCode(ICorDebugCode **ppCode) { - if (m_pCode == NULL) { - m_pCode = new CordbCode(conn, this); - m_pCode->InternalAddRef(); - } - m_pCode->QueryInterface(IID_ICorDebugCode, (void **)ppCode); - LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetILCode - IMPLEMENTED\n")); - return S_OK; +HRESULT __stdcall CordbFunction::GetILCode(ICorDebugCode** ppCode) +{ + if (m_pCode == NULL) + { + m_pCode = new CordbCode(conn, this); + m_pCode->InternalAddRef(); + } + m_pCode->QueryInterface(IID_ICorDebugCode, (void**)ppCode); + LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetILCode - IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbFunction::GetNativeCode(ICorDebugCode **ppCode) { - if (m_pCode == NULL) { - m_pCode = new CordbCode(conn, this); - m_pCode->InternalAddRef(); - } - m_pCode->QueryInterface(IID_ICorDebugCode, (void **)ppCode); - LOG((LF_CORDB, LL_INFO1000000, - "CordbFunction - GetNativeCode - IMPLEMENTED\n")); - return S_OK; +HRESULT __stdcall CordbFunction::GetNativeCode(ICorDebugCode** ppCode) +{ + if (m_pCode == NULL) + { + m_pCode = new CordbCode(conn, this); + m_pCode->InternalAddRef(); + } + m_pCode->QueryInterface(IID_ICorDebugCode, (void**)ppCode); + LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetNativeCode - IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbFunction::CreateBreakpoint( - ICorDebugFunctionBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunction - CreateBreakpoint - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunction::CreateBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - CreateBreakpoint - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetLocalVarSigToken(mdSignature *pmdSig) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunction - GetLocalVarSigToken - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunction::GetLocalVarSigToken(mdSignature* pmdSig) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetLocalVarSigToken - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetCurrentVersionNumber( - ULONG32 *pnCurrentVersion) { - *pnCurrentVersion = 1; - LOG((LF_CORDB, LL_INFO1000000, - "CordbFunction - GetCurrentVersionNumber - IMPLEMENTED\n")); - return S_OK; +HRESULT __stdcall CordbFunction::GetCurrentVersionNumber(ULONG32* pnCurrentVersion) +{ + *pnCurrentVersion = 1; + LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetCurrentVersionNumber - IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbFunction::SetJMCStatus(BOOL bIsJustMyCode) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunction - SetJMCStatus - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunction::SetJMCStatus(BOOL bIsJustMyCode) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - SetJMCStatus - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetJMCStatus(BOOL *pbIsJustMyCode) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunction - GetJMCStatus - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunction::GetJMCStatus(BOOL* pbIsJustMyCode) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetJMCStatus - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::EnumerateNativeCode( - ICorDebugCodeEnum **ppCodeEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunction - EnumerateNativeCode - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunction::EnumerateNativeCode(ICorDebugCodeEnum** ppCodeEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - EnumerateNativeCode - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetVersionNumber(ULONG32 *pnVersion) { - *pnVersion = 1; - LOG((LF_CORDB, LL_INFO1000000, - "CordbFunction - GetVersionNumber - IMPLEMENTED\n")); - return S_OK; +HRESULT __stdcall CordbFunction::GetVersionNumber(ULONG32* pnVersion) +{ + *pnVersion = 1; + LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetVersionNumber - IMPLEMENTED\n")); + return S_OK; } -HRESULT __stdcall CordbFunction::GetActiveReJitRequestILCode( - ICorDebugILCode **ppReJitedILCode) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunction - GetActiveReJitRequestILCode - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunction::GetActiveReJitRequestILCode(ICorDebugILCode** ppReJitedILCode) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetActiveReJitRequestILCode - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::CreateNativeBreakpoint( - ICorDebugFunctionBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbFunction - CreateNativeBreakpoint - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbFunction::CreateNativeBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - CreateNativeBreakpoint - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-function.h b/src/mono/dbi/cordb-function.h index 00ef3c955564ce..b2c44ac73c4bc7 100644 --- a/src/mono/dbi/cordb-function.h +++ b/src/mono/dbi/cordb-function.h @@ -14,43 +14,59 @@ class CordbFunction : public CordbBaseMono, public ICorDebugFunction, public ICorDebugFunction2, public ICorDebugFunction3, - public ICorDebugFunction4 { - int m_debuggerId; - mdToken m_metadataToken; - CordbCode *m_pCode; - CordbModule *m_pModule; + public ICorDebugFunction4 +{ + int m_debuggerId; + mdToken m_metadataToken; + CordbCode* m_pCode; + CordbModule* m_pModule; public: - CordbFunction(Connection *conn, mdToken token, int id, CordbModule *module); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbFunction"; } - ~CordbFunction(); - int GetDebuggerId() const { return m_debuggerId; } - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + CordbFunction(Connection* conn, mdToken token, int id, CordbModule* module); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbFunction"; + } + ~CordbFunction(); + int GetDebuggerId() const + { + return m_debuggerId; + } + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT GetModule(ICorDebugModule **ppModule); - HRESULT GetClass(ICorDebugClass **ppClass); - HRESULT GetToken(mdMethodDef *pMethodDef); - HRESULT GetILCode(ICorDebugCode **ppCode); - HRESULT GetNativeCode(ICorDebugCode **ppCode); - HRESULT - CreateBreakpoint(ICorDebugFunctionBreakpoint **ppBreakpoint); - HRESULT - GetLocalVarSigToken(mdSignature *pmdSig); - HRESULT - GetCurrentVersionNumber(ULONG32 *pnCurrentVersion); - HRESULT SetJMCStatus(BOOL bIsJustMyCode); - HRESULT GetJMCStatus(BOOL *pbIsJustMyCode); - HRESULT - EnumerateNativeCode(ICorDebugCodeEnum **ppCodeEnum); - HRESULT GetVersionNumber(ULONG32 *pnVersion); - HRESULT - GetActiveReJitRequestILCode(ICorDebugILCode **ppReJitedILCode); - HRESULT - CreateNativeBreakpoint(ICorDebugFunctionBreakpoint **ppBreakpoint); - mdToken GetMetadataToken() const { return m_metadataToken; } + HRESULT GetModule(ICorDebugModule** ppModule); + HRESULT GetClass(ICorDebugClass** ppClass); + HRESULT GetToken(mdMethodDef* pMethodDef); + HRESULT GetILCode(ICorDebugCode** ppCode); + HRESULT GetNativeCode(ICorDebugCode** ppCode); + HRESULT + CreateBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint); + HRESULT + GetLocalVarSigToken(mdSignature* pmdSig); + HRESULT + GetCurrentVersionNumber(ULONG32* pnCurrentVersion); + HRESULT SetJMCStatus(BOOL bIsJustMyCode); + HRESULT GetJMCStatus(BOOL* pbIsJustMyCode); + HRESULT + EnumerateNativeCode(ICorDebugCodeEnum** ppCodeEnum); + HRESULT GetVersionNumber(ULONG32* pnVersion); + HRESULT + GetActiveReJitRequestILCode(ICorDebugILCode** ppReJitedILCode); + HRESULT + CreateNativeBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint); + mdToken GetMetadataToken() const + { + return m_metadataToken; + } }; #endif diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index 73429a109fad39..dd072b1c1aaa54 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -16,586 +16,630 @@ using namespace std; -CordbProcess::CordbProcess(Cordb *cordb) : CordbBaseMono(NULL) { - m_pAppDomainEnum = NULL; - m_pBreakpoints = new ArrayList(); - m_pThreads = new ArrayList(); - m_pFunctions = new ArrayList(); - m_pModules = new ArrayList(); - appDomains = new ArrayList(); - m_pPendingEval = new ArrayList(); - this->m_pCordb = cordb; -} - -CordbProcess::~CordbProcess() { - if (m_pAppDomainEnum) - m_pAppDomainEnum->InternalRelease(); - DWORD i = 0; - while (i < m_pBreakpoints->GetCount()) { - CordbFunctionBreakpoint *breakpoint = - (CordbFunctionBreakpoint *)m_pBreakpoints->Get(i); - if (breakpoint) - breakpoint->InternalRelease(); - i++; - } - i = 0; - while (i < m_pThreads->GetCount()) { - CordbThread *thread = (CordbThread *)m_pThreads->Get(i); - thread->InternalRelease(); - i++; - } - i = 0; - while (i < m_pFunctions->GetCount()) { - CordbFunction *function = (CordbFunction *)m_pFunctions->Get(i); - function->InternalRelease(); - i++; - } - i = 0; - while (i < appDomains->GetCount()) { - CordbAppDomain *appdomain = (CordbAppDomain *)appDomains->Get(i); - appdomain->InternalRelease(); - i++; - } - i = 0; - while (i < m_pModules->GetCount()) { - CordbModule *module = (CordbModule *)m_pModules->Get(i); - module->InternalRelease(); - i++; - } - i = 0; - while (i < m_pPendingEval->GetCount()) { - CordbEval *eval = (CordbEval *)m_pPendingEval->Get(i); - if (eval) - eval->InternalRelease(); - i++; - } - delete m_pBreakpoints; - delete m_pThreads; - delete m_pFunctions; - delete m_pModules; - delete appDomains; - delete m_pPendingEval; - delete conn; -} - -void CordbProcess::CheckPendingEval() { - DWORD i = 0; - while (i < m_pPendingEval->GetCount()) { - CordbEval *eval = (CordbEval *)m_pPendingEval->Get(i); - if (eval) { - ReceivedReplyPacket *recvbuf = - conn->GetReplyWithError(eval->GetCommandId()); - if (recvbuf) { - eval->EvalComplete(recvbuf->Buffer()); - eval->InternalRelease(); - dbg_lock(); - m_pPendingEval->Set(i, NULL); - dbg_unlock(); - } +CordbProcess::CordbProcess(Cordb* cordb) : CordbBaseMono(NULL) +{ + m_pAppDomainEnum = NULL; + m_pBreakpoints = new ArrayList(); + m_pThreads = new ArrayList(); + m_pFunctions = new ArrayList(); + m_pModules = new ArrayList(); + appDomains = new ArrayList(); + m_pPendingEval = new ArrayList(); + this->m_pCordb = cordb; +} + +CordbProcess::~CordbProcess() +{ + if (m_pAppDomainEnum) + m_pAppDomainEnum->InternalRelease(); + DWORD i = 0; + while (i < m_pBreakpoints->GetCount()) + { + CordbFunctionBreakpoint* breakpoint = (CordbFunctionBreakpoint*)m_pBreakpoints->Get(i); + if (breakpoint) + breakpoint->InternalRelease(); + i++; + } + i = 0; + while (i < m_pThreads->GetCount()) + { + CordbThread* thread = (CordbThread*)m_pThreads->Get(i); + thread->InternalRelease(); + i++; + } + i = 0; + while (i < m_pFunctions->GetCount()) + { + CordbFunction* function = (CordbFunction*)m_pFunctions->Get(i); + function->InternalRelease(); + i++; + } + i = 0; + while (i < appDomains->GetCount()) + { + CordbAppDomain* appdomain = (CordbAppDomain*)appDomains->Get(i); + appdomain->InternalRelease(); + i++; + } + i = 0; + while (i < m_pModules->GetCount()) + { + CordbModule* module = (CordbModule*)m_pModules->Get(i); + module->InternalRelease(); + i++; + } + i = 0; + while (i < m_pPendingEval->GetCount()) + { + CordbEval* eval = (CordbEval*)m_pPendingEval->Get(i); + if (eval) + eval->InternalRelease(); + i++; + } + delete m_pBreakpoints; + delete m_pThreads; + delete m_pFunctions; + delete m_pModules; + delete appDomains; + delete m_pPendingEval; + delete conn; +} + +void CordbProcess::CheckPendingEval() +{ + DWORD i = 0; + while (i < m_pPendingEval->GetCount()) + { + CordbEval* eval = (CordbEval*)m_pPendingEval->Get(i); + if (eval) + { + ReceivedReplyPacket* recvbuf = conn->GetReplyWithError(eval->GetCommandId()); + if (recvbuf) + { + eval->EvalComplete(recvbuf->Buffer()); + eval->InternalRelease(); + dbg_lock(); + m_pPendingEval->Set(i, NULL); + dbg_unlock(); + } + } + i++; } - i++; - } } -HRESULT CordbProcess::EnumerateLoaderHeapMemoryRegions( - ICorDebugMemoryRangeEnum **ppRanges) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnumerateLoaderHeapMemoryRegions - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::EnumerateLoaderHeapMemoryRegions(ICorDebugMemoryRangeEnum** ppRanges) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateLoaderHeapMemoryRegions - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::EnableGCNotificationEvents(BOOL fEnable) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnableGCNotificationEvents - NOT IMPLEMENTED\n")); +HRESULT CordbProcess::EnableGCNotificationEvents(BOOL fEnable) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnableGCNotificationEvents - NOT IMPLEMENTED\n")); - return S_OK; + return S_OK; } -HRESULT CordbProcess::EnableExceptionCallbacksOutsideOfMyCode( - BOOL enableExceptionsOutsideOfJMC) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnableExceptionCallbacksOutsideOfMyCode - " - "NOT IMPLEMENTED\n")); +HRESULT CordbProcess::EnableExceptionCallbacksOutsideOfMyCode(BOOL enableExceptionsOutsideOfJMC) +{ + LOG((LF_CORDB, LL_INFO100000, + "CordbProcess - EnableExceptionCallbacksOutsideOfMyCode - " + "NOT IMPLEMENTED\n")); - return S_OK; + return S_OK; } -HRESULT CordbProcess::SetWriteableMetadataUpdateMode( - WriteableMetadataUpdateMode flags) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - SetWriteableMetadataUpdateMode - NOT IMPLEMENTED\n")); +HRESULT CordbProcess::SetWriteableMetadataUpdateMode(WriteableMetadataUpdateMode flags) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetWriteableMetadataUpdateMode - NOT IMPLEMENTED\n")); - return S_OK; + return S_OK; } -HRESULT CordbProcess::GetGCHeapInformation(COR_HEAPINFO *pHeapInfo) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetGCHeapInformation - NOT IMPLEMENTED\n")); +HRESULT CordbProcess::GetGCHeapInformation(COR_HEAPINFO* pHeapInfo) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetGCHeapInformation - NOT IMPLEMENTED\n")); - return S_OK; + return S_OK; } -HRESULT CordbProcess::EnumerateHeap(ICorDebugHeapEnum **ppObjects) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnumerateHeap - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::EnumerateHeap(ICorDebugHeapEnum** ppObjects) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateHeap - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbProcess::EnumerateHeapRegions(ICorDebugHeapSegmentEnum **ppRegions) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnumerateHeapRegions - NOT IMPLEMENTED\n")); - return S_OK; +CordbProcess::EnumerateHeapRegions(ICorDebugHeapSegmentEnum** ppRegions) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateHeapRegions - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetObject(CORDB_ADDRESS addr, - ICorDebugObjectValue **pObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetObject - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue** pObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetObject - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::EnumerateGCReferences(BOOL enumerateWeakReferences, - ICorDebugGCReferenceEnum **ppEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnumerateGCReferences - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::EnumerateGCReferences(BOOL enumerateWeakReferences, ICorDebugGCReferenceEnum** ppEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateGCReferences - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::EnumerateHandles(CorGCReferenceType types, - ICorDebugGCReferenceEnum **ppEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnumerateHandles - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::EnumerateHandles(CorGCReferenceType types, ICorDebugGCReferenceEnum** ppEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateHandles - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetTypeID(CORDB_ADDRESS obj, COR_TYPEID *pId) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetTypeID - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetTypeID(CORDB_ADDRESS obj, COR_TYPEID* pId) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetTypeID - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetTypeForTypeID(COR_TYPEID id, ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetTypeForTypeID - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetTypeForTypeID(COR_TYPEID id, ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetTypeForTypeID - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetArrayLayout(COR_TYPEID id, COR_ARRAY_LAYOUT *pLayout) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetArrayLayout - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetArrayLayout(COR_TYPEID id, COR_ARRAY_LAYOUT* pLayout) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetArrayLayout - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetTypeLayout(COR_TYPEID id, COR_TYPE_LAYOUT *pLayout) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetTypeLayout - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetTypeLayout(COR_TYPEID id, COR_TYPE_LAYOUT* pLayout) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetTypeLayout - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetTypeFields(COR_TYPEID id, ULONG32 celt, - COR_FIELD fields[], ULONG32 *pceltNeeded) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetTypeFields - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetTypeFields(COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], ULONG32* pceltNeeded) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetTypeFields - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::EnableNGENPolicy(CorDebugNGENPolicy ePolicy) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnableNGENPolicy - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::EnableNGENPolicy(CorDebugNGENPolicy ePolicy) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnableNGENPolicy - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbProcess::Filter(const BYTE pRecord[], DWORD countBytes, - CorDebugRecordFormat format, DWORD dwFlags, - DWORD dwThreadId, ICorDebugManagedCallback *pCallback, - /* [out][in] */ CORDB_CONTINUE_STATUS *pContinueStatus) { - LOG((LF_CORDB, LL_INFO100000, "CordbProcess - Filter - NOT IMPLEMENTED\n")); - return S_OK; +CordbProcess::Filter(const BYTE pRecord[], + DWORD countBytes, + CorDebugRecordFormat format, + DWORD dwFlags, + DWORD dwThreadId, + ICorDebugManagedCallback* pCallback, + /* [out][in] */ CORDB_CONTINUE_STATUS* pContinueStatus) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - Filter - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::ProcessStateChanged(CorDebugStateChange eChange) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - ProcessStateChanged - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::ProcessStateChanged(CorDebugStateChange eChange) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ProcessStateChanged - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::SetEnableCustomNotification(ICorDebugClass *pClass, - BOOL fEnable) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - SetEnableCustomNotification - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::SetEnableCustomNotification(ICorDebugClass* pClass, BOOL fEnable) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetEnableCustomNotification - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetID(DWORD *pdwProcessId) { - LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetID - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetID(DWORD* pdwProcessId) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetID - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetHandle(HPROCESS *phProcessHandle) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetHandle - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetHandle(HPROCESS* phProcessHandle) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetHandle - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetThread(DWORD dwThreadId, ICorDebugThread **ppThread) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetThread - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetThread(DWORD dwThreadId, ICorDebugThread** ppThread) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetThread - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::EnumerateObjects(ICorDebugObjectEnum **ppObjects) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnumerateObjects - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::EnumerateObjects(ICorDebugObjectEnum** ppObjects) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateObjects - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::IsTransitionStub(CORDB_ADDRESS address, - BOOL *pbTransitionStub) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - IsTransitionStub - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::IsTransitionStub(CORDB_ADDRESS address, BOOL* pbTransitionStub) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - IsTransitionStub - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::IsOSSuspended(DWORD threadID, BOOL *pbSuspended) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - IsOSSuspended - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::IsOSSuspended(DWORD threadID, BOOL* pbSuspended) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - IsOSSuspended - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::GetThreadContext(DWORD threadID, ULONG32 contextSize, - BYTE context[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetThreadContext - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetThreadContext - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::SetThreadContext(DWORD threadID, ULONG32 contextSize, - BYTE context[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - SetThreadContext - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::SetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetThreadContext - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::ReadMemory(CORDB_ADDRESS address, DWORD size, - BYTE buffer[], SIZE_T *read) { - memcpy(buffer, (void *)address, size); - if (read != NULL) - *read = size; - LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - ReadMemory - IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::ReadMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* read) +{ + memcpy(buffer, (void*)address, size); + if (read != NULL) + *read = size; + LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - ReadMemory - IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::WriteMemory(CORDB_ADDRESS address, DWORD size, - BYTE buffer[], SIZE_T *written) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - WriteMemory - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::WriteMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* written) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - WriteMemory - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::ClearCurrentException(DWORD threadID) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - ClearCurrentException - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::ClearCurrentException(DWORD threadID) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ClearCurrentException - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::EnableLogMessages(BOOL fOnOff) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnableLogMessages - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::EnableLogMessages(BOOL fOnOff) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnableLogMessages - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT CordbProcess::ModifyLogSwitch( /* [annotation][in] */ - _In_ WCHAR *pLogSwitchName, LONG lLevel) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - ModifyLogSwitch - NOT IMPLEMENTED\n")); - return S_OK; + _In_ WCHAR* pLogSwitchName, + LONG lLevel) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ModifyLogSwitch - NOT IMPLEMENTED\n")); + return S_OK; } HRESULT -CordbProcess::EnumerateAppDomains(ICorDebugAppDomainEnum **ppAppDomains) { - if (!m_pAppDomainEnum) { - m_pAppDomainEnum = new CordbAppDomainEnum(conn, this); - m_pAppDomainEnum->InternalAddRef(); - } - m_pAppDomainEnum->QueryInterface(IID_ICorDebugAppDomainEnum, - (void **)ppAppDomains); - LOG((LF_CORDB, LL_INFO1000000, - "CordbProcess - EnumerateAppDomains - IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::GetObject(ICorDebugValue **ppObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetObject - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::ThreadForFiberCookie(DWORD fiberCookie, - ICorDebugThread **ppThread) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - ThreadForFiberCookie - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::GetHelperThreadID(DWORD *pThreadID) { - LOG((LF_CORDB, LL_INFO100000, "GetHelperThreadID - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::GetThreadForTaskID(TASKID taskid, - ICorDebugThread2 **ppThread) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetHelperThreadID - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::GetVersion(COR_VERSION *version) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetVersion - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::SetUnmanagedBreakpoint(CORDB_ADDRESS address, - ULONG32 bufsize, BYTE buffer[], - ULONG32 *bufLen) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - SetUnmanagedBreakpoint - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::ClearUnmanagedBreakpoint(CORDB_ADDRESS address) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - ClearUnmanagedBreakpoint - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::SetDesiredNGENCompilerFlags(DWORD pdwFlags) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - SetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::GetDesiredNGENCompilerFlags(DWORD *pdwFlags) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::GetReferenceValueFromGCHandle( - UINT_PTR handle, ICorDebugReferenceValue **pOutValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - GetReferenceValueFromGCHandle - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::QueryInterface( - REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface) { - if (id == IID_ICorDebugProcess) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugController) { - *pInterface = static_cast( - static_cast(this)); - } else if (id == IID_ICorDebugProcess2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugProcess3) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugProcess4) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugProcess5) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugProcess7) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugProcess8) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugProcess10) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugProcess11) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = - static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -HRESULT CordbProcess::Stop(DWORD dwTimeoutIgnored) { - LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - Stop - IMPLEMENTED\n")); - MdbgProtBuffer sendbuf; - m_dbgprot_buffer_init(&sendbuf, 128); - conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SUSPEND, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - return S_OK; -} - -HRESULT CordbProcess::Continue(BOOL fIsOutOfBand) { - LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - Continue - IMPLEMENTED\n")); - MdbgProtBuffer sendbuf; - m_dbgprot_buffer_init(&sendbuf, 128); - conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_RESUME, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - return S_OK; -} - -HRESULT CordbProcess::IsRunning(BOOL *pbRunning) { - *pbRunning = true; - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - IsRunning - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::HasQueuedCallbacks(ICorDebugThread *pThread, - BOOL *pbQueued) { - // conn->process_packet_from_queue(); - *pbQueued = false; - LOG((LF_CORDB, LL_INFO1000000, - "CordbProcess - HasQueuedCallbacks - IMPLEMENTED\n")); - return S_OK; -} - -HRESULT CordbProcess::EnumerateThreads(ICorDebugThreadEnum **ppThreads) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - EnumerateThreads - NOT IMPLEMENTED\n")); - return S_OK; +CordbProcess::EnumerateAppDomains(ICorDebugAppDomainEnum** ppAppDomains) +{ + if (!m_pAppDomainEnum) + { + m_pAppDomainEnum = new CordbAppDomainEnum(conn, this); + m_pAppDomainEnum->InternalAddRef(); + } + m_pAppDomainEnum->QueryInterface(IID_ICorDebugAppDomainEnum, (void**)ppAppDomains); + LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - EnumerateAppDomains - IMPLEMENTED\n")); + return S_OK; } -HRESULT -CordbProcess::SetAllThreadsDebugState(CorDebugThreadState state, - ICorDebugThread *pExceptThisThread) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetObject(ICorDebugValue** ppObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetObject - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::Detach(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbProcess - Detach - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::ThreadForFiberCookie(DWORD fiberCookie, ICorDebugThread** ppThread) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ThreadForFiberCookie - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT CordbProcess::Terminate(UINT exitCode) { - MdbgProtBuffer sendbuf; - m_dbgprot_buffer_init(&sendbuf, 128); - m_dbgprot_buffer_add_int(&sendbuf, -1); - conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_EXIT, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - return S_OK; +HRESULT CordbProcess::GetHelperThreadID(DWORD* pThreadID) +{ + LOG((LF_CORDB, LL_INFO100000, "GetHelperThreadID - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT -CordbProcess::CanCommitChanges(ULONG cSnapshots, - ICorDebugEditAndContinueSnapshot *pSnapshots[], - ICorDebugErrorInfoEnum **pError) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - CanCommitChanges - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetThreadForTaskID(TASKID taskid, ICorDebugThread2** ppThread) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetHelperThreadID - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT -CordbProcess::CommitChanges(ULONG cSnapshots, - ICorDebugEditAndContinueSnapshot *pSnapshots[], - ICorDebugErrorInfoEnum **pError) { - LOG((LF_CORDB, LL_INFO100000, - "CordbProcess - CommitChanges - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT CordbProcess::GetVersion(COR_VERSION* version) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetVersion - NOT IMPLEMENTED\n")); + return S_OK; } -void CordbProcess::AddThread(CordbThread *thread) { - m_pThreads->Append(thread); - thread->InternalAddRef(); +HRESULT CordbProcess::SetUnmanagedBreakpoint(CORDB_ADDRESS address, ULONG32 bufsize, BYTE buffer[], ULONG32* bufLen) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetUnmanagedBreakpoint - NOT IMPLEMENTED\n")); + return S_OK; } -void CordbProcess::AddFunction(CordbFunction *function) { - m_pFunctions->Append(function); - function->InternalAddRef(); +HRESULT CordbProcess::ClearUnmanagedBreakpoint(CORDB_ADDRESS address) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - ClearUnmanagedBreakpoint - NOT IMPLEMENTED\n")); + return S_OK; } -void CordbProcess::AddModule(CordbModule *module) { - m_pModules->Append(module); - module->InternalAddRef(); +HRESULT CordbProcess::SetDesiredNGENCompilerFlags(DWORD pdwFlags) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n")); + return S_OK; } -void CordbProcess::AddAppDomain(CordbAppDomain *appDomain) { - appDomains->Append(appDomain); - appDomain->InternalAddRef(); +HRESULT CordbProcess::GetDesiredNGENCompilerFlags(DWORD* pdwFlags) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetDesiredNGENCompilerFlags - NOT IMPLEMENTED\n")); + return S_OK; } -void CordbProcess::AddPendingEval(CordbEval *eval) { - m_pPendingEval->Append(eval); - eval->InternalAddRef(); -} -void CordbProcess::AddBreakpoint(CordbFunctionBreakpoint *bp) { - m_pBreakpoints->Append(bp); - bp->InternalAddRef(); +HRESULT CordbProcess::GetReferenceValueFromGCHandle(UINT_PTR handle, ICorDebugReferenceValue** pOutValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - GetReferenceValueFromGCHandle - NOT IMPLEMENTED\n")); + return S_OK; } -CordbFunction *CordbProcess::FindFunction(int id) { - DWORD i = 0; - while (i < m_pFunctions->GetCount()) { - CordbFunction *function = (CordbFunction *)m_pFunctions->Get(i); - if (function->GetDebuggerId() == id) { - return function; +HRESULT CordbProcess::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface) +{ + if (id == IID_ICorDebugProcess) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugController) + { + *pInterface = static_cast(static_cast(this)); + } + else if (id == IID_ICorDebugProcess2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugProcess3) + { + *pInterface = static_cast(this); } - i++; - } - return NULL; + else if (id == IID_ICorDebugProcess4) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugProcess5) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugProcess7) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugProcess8) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugProcess10) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugProcess11) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -CordbFunction *CordbProcess::FindFunctionByToken(int token) { - DWORD i = 0; - while (i < m_pFunctions->GetCount()) { - CordbFunction *function = (CordbFunction *)m_pFunctions->Get(i); - if (function->GetMetadataToken() == token) { - return function; - } - i++; - } - return NULL; +HRESULT CordbProcess::Stop(DWORD dwTimeoutIgnored) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - Stop - IMPLEMENTED\n")); + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, 128); + conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SUSPEND, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + return S_OK; } -CordbModule *CordbProcess::GetModule(int module_id) { - for (DWORD i = 0; i < m_pModules->GetCount(); i++) { - CordbModule *module = (CordbModule *)m_pModules->Get(i); - if (module->GetDebuggerId() == module_id) { - return module; - } - } - return NULL; +HRESULT CordbProcess::Continue(BOOL fIsOutOfBand) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - Continue - IMPLEMENTED\n")); + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, 128); + conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_RESUME, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + return S_OK; +} + +HRESULT CordbProcess::IsRunning(BOOL* pbRunning) +{ + *pbRunning = true; + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - IsRunning - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbProcess::HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued) +{ + // conn->process_packet_from_queue(); + *pbQueued = false; + LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - HasQueuedCallbacks - IMPLEMENTED\n")); + return S_OK; } -CordbAppDomain *CordbProcess::GetCurrentAppDomain() { - if (appDomains->GetCount() > 0) - return (CordbAppDomain *)appDomains->Get(0); - return NULL; +HRESULT CordbProcess::EnumerateThreads(ICorDebugThreadEnum** ppThreads) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateThreads - NOT IMPLEMENTED\n")); + return S_OK; } -CordbThread *CordbProcess::FindThread(long thread_id) { - DWORD i = 0; - while (i < m_pThreads->GetCount()) { - CordbThread *thread = (CordbThread *)m_pThreads->Get(i); - if (thread->GetThreadId() == thread_id) { - return thread; +HRESULT +CordbProcess::SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbProcess::Detach(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - Detach - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT CordbProcess::Terminate(UINT exitCode) +{ + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, 128); + m_dbgprot_buffer_add_int(&sendbuf, -1); + conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_EXIT, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + return S_OK; +} + +HRESULT +CordbProcess::CanCommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot* pSnapshots[], + ICorDebugErrorInfoEnum** pError) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - CanCommitChanges - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT +CordbProcess::CommitChanges(ULONG cSnapshots, + ICorDebugEditAndContinueSnapshot* pSnapshots[], + ICorDebugErrorInfoEnum** pError) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbProcess - CommitChanges - NOT IMPLEMENTED\n")); + return S_OK; +} + +void CordbProcess::AddThread(CordbThread* thread) +{ + m_pThreads->Append(thread); + thread->InternalAddRef(); +} + +void CordbProcess::AddFunction(CordbFunction* function) +{ + m_pFunctions->Append(function); + function->InternalAddRef(); +} + +void CordbProcess::AddModule(CordbModule* module) +{ + m_pModules->Append(module); + module->InternalAddRef(); +} + +void CordbProcess::AddAppDomain(CordbAppDomain* appDomain) +{ + appDomains->Append(appDomain); + appDomain->InternalAddRef(); +} + +void CordbProcess::AddPendingEval(CordbEval* eval) +{ + m_pPendingEval->Append(eval); + eval->InternalAddRef(); +} +void CordbProcess::AddBreakpoint(CordbFunctionBreakpoint* bp) +{ + m_pBreakpoints->Append(bp); + bp->InternalAddRef(); +} + +CordbFunction* CordbProcess::FindFunction(int id) +{ + DWORD i = 0; + while (i < m_pFunctions->GetCount()) + { + CordbFunction* function = (CordbFunction*)m_pFunctions->Get(i); + if (function->GetDebuggerId() == id) + { + return function; + } + i++; + } + return NULL; +} + +CordbFunction* CordbProcess::FindFunctionByToken(int token) +{ + DWORD i = 0; + while (i < m_pFunctions->GetCount()) + { + CordbFunction* function = (CordbFunction*)m_pFunctions->Get(i); + if (function->GetMetadataToken() == token) + { + return function; + } + i++; + } + return NULL; +} + +CordbModule* CordbProcess::GetModule(int module_id) +{ + for (DWORD i = 0; i < m_pModules->GetCount(); i++) + { + CordbModule* module = (CordbModule*)m_pModules->Get(i); + if (module->GetDebuggerId() == module_id) + { + return module; + } + } + return NULL; +} + +CordbAppDomain* CordbProcess::GetCurrentAppDomain() +{ + if (appDomains->GetCount() > 0) + return (CordbAppDomain*)appDomains->Get(0); + return NULL; +} + +CordbThread* CordbProcess::FindThread(long thread_id) +{ + DWORD i = 0; + while (i < m_pThreads->GetCount()) + { + CordbThread* thread = (CordbThread*)m_pThreads->Get(i); + if (thread->GetThreadId() == thread_id) + { + return thread; + } + i++; } - i++; - } - return NULL; -} - -CordbFunctionBreakpoint * -CordbProcess::GetBreakpointByOffsetAndFuncId(int64_t offset, int method_id) { - DWORD i = 0; - CordbFunctionBreakpoint *breakpoint = NULL; - while (i < m_pBreakpoints->GetCount()) { - breakpoint = (CordbFunctionBreakpoint *)m_pBreakpoints->Get(i); - if (breakpoint->GetOffset() == offset && - breakpoint->GetCode()->GetFunction()->GetDebuggerId() == method_id) { - return breakpoint; + return NULL; +} + +CordbFunctionBreakpoint* CordbProcess::GetBreakpointByOffsetAndFuncId(int64_t offset, int method_id) +{ + DWORD i = 0; + CordbFunctionBreakpoint* breakpoint = NULL; + while (i < m_pBreakpoints->GetCount()) + { + breakpoint = (CordbFunctionBreakpoint*)m_pBreakpoints->Get(i); + if (breakpoint->GetOffset() == offset && breakpoint->GetCode()->GetFunction()->GetDebuggerId() == method_id) + { + return breakpoint; + } + i++; } - i++; - } - return NULL; + return NULL; } diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index 6ee6c9b0e71760..e0604c7df7ba05 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -19,132 +19,138 @@ class CordbProcess : public CordbBaseMono, public ICorDebugProcess7, public ICorDebugProcess8, public ICorDebugProcess10, - public ICorDebugProcess11 { - ArrayList *m_pBreakpoints; - ArrayList *m_pThreads; - ArrayList *m_pFunctions; - ArrayList *m_pModules; - ArrayList *m_pPendingEval; - CordbAppDomainEnum *m_pAppDomainEnum; - Cordb *m_pCordb; + public ICorDebugProcess11 +{ + ArrayList* m_pBreakpoints; + ArrayList* m_pThreads; + ArrayList* m_pFunctions; + ArrayList* m_pModules; + ArrayList* m_pPendingEval; + CordbAppDomainEnum* m_pAppDomainEnum; + Cordb* m_pCordb; public: - ArrayList *appDomains; - CordbProcess(Cordb *cordb); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbProcess"; } - Cordb *GetCordb() const { return m_pCordb; } - ~CordbProcess(); - HRESULT EnumerateLoaderHeapMemoryRegions(ICorDebugMemoryRangeEnum **ppRanges); - HRESULT EnableGCNotificationEvents(BOOL fEnable); - HRESULT - EnableExceptionCallbacksOutsideOfMyCode(BOOL enableExceptionsOutsideOfJMC); - HRESULT - SetWriteableMetadataUpdateMode(WriteableMetadataUpdateMode flags); - HRESULT - GetGCHeapInformation(COR_HEAPINFO *pHeapInfo); - HRESULT - EnumerateHeap(ICorDebugHeapEnum **ppObjects); - HRESULT - EnumerateHeapRegions(ICorDebugHeapSegmentEnum **ppRegions); - HRESULT - GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue **pObject); - HRESULT - EnumerateGCReferences(BOOL enumerateWeakReferences, - ICorDebugGCReferenceEnum **ppEnum); - HRESULT - EnumerateHandles(CorGCReferenceType types, ICorDebugGCReferenceEnum **ppEnum); - HRESULT GetTypeID(CORDB_ADDRESS obj, COR_TYPEID *pId); - HRESULT GetTypeForTypeID(COR_TYPEID id, ICorDebugType **ppType); - HRESULT GetArrayLayout(COR_TYPEID id, COR_ARRAY_LAYOUT *pLayout); - HRESULT GetTypeLayout(COR_TYPEID id, COR_TYPE_LAYOUT *pLayout); - HRESULT GetTypeFields(COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], - ULONG32 *pceltNeeded); - HRESULT - EnableNGENPolicy(CorDebugNGENPolicy ePolicy); - HRESULT - Filter(const BYTE pRecord[], DWORD countBytes, CorDebugRecordFormat format, - DWORD dwFlags, DWORD dwThreadId, ICorDebugManagedCallback *pCallback, - CORDB_CONTINUE_STATUS *pContinueStatus); - HRESULT - ProcessStateChanged(CorDebugStateChange eChange); - HRESULT SetEnableCustomNotification(ICorDebugClass *pClass, BOOL fEnable); - HRESULT GetID(DWORD *pdwProcessId); - HRESULT GetHandle(HPROCESS *phProcessHandle); - HRESULT GetThread(DWORD dwThreadId, ICorDebugThread **ppThread); - HRESULT - EnumerateObjects(ICorDebugObjectEnum **ppObjects); - HRESULT IsTransitionStub(CORDB_ADDRESS address, BOOL *pbTransitionStub); - HRESULT IsOSSuspended(DWORD threadID, BOOL *pbSuspended); - HRESULT - GetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); - HRESULT - SetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); - HRESULT - ReadMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T *read); - HRESULT - WriteMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], - SIZE_T *written); - HRESULT ClearCurrentException(DWORD threadID); - HRESULT EnableLogMessages(BOOL fOnOff); - HRESULT - ModifyLogSwitch(_In_ WCHAR *pLogSwitchName, LONG lLevel); - HRESULT - EnumerateAppDomains(ICorDebugAppDomainEnum **ppAppDomains); - HRESULT GetObject(ICorDebugValue **ppObject); - HRESULT ThreadForFiberCookie(DWORD fiberCookie, ICorDebugThread **ppThread); - HRESULT GetHelperThreadID(DWORD *pThreadID); - HRESULT GetThreadForTaskID(TASKID taskid, ICorDebugThread2 **ppThread); - HRESULT GetVersion(COR_VERSION *version); - HRESULT SetUnmanagedBreakpoint(CORDB_ADDRESS address, ULONG32 bufsize, - BYTE buffer[], ULONG32 *bufLen); - HRESULT - ClearUnmanagedBreakpoint(CORDB_ADDRESS address); - HRESULT - SetDesiredNGENCompilerFlags(DWORD pdwFlags); - HRESULT - GetDesiredNGENCompilerFlags(DWORD *pdwFlags); - HRESULT - GetReferenceValueFromGCHandle(UINT_PTR handle, - ICorDebugReferenceValue **pOutValue); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + ArrayList* appDomains; + CordbProcess(Cordb* cordb); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbProcess"; + } + Cordb* GetCordb() const + { + return m_pCordb; + } + ~CordbProcess(); + HRESULT EnumerateLoaderHeapMemoryRegions(ICorDebugMemoryRangeEnum** ppRanges); + HRESULT EnableGCNotificationEvents(BOOL fEnable); + HRESULT + EnableExceptionCallbacksOutsideOfMyCode(BOOL enableExceptionsOutsideOfJMC); + HRESULT + SetWriteableMetadataUpdateMode(WriteableMetadataUpdateMode flags); + HRESULT + GetGCHeapInformation(COR_HEAPINFO* pHeapInfo); + HRESULT + EnumerateHeap(ICorDebugHeapEnum** ppObjects); + HRESULT + EnumerateHeapRegions(ICorDebugHeapSegmentEnum** ppRegions); + HRESULT + GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue** pObject); + HRESULT + EnumerateGCReferences(BOOL enumerateWeakReferences, ICorDebugGCReferenceEnum** ppEnum); + HRESULT + EnumerateHandles(CorGCReferenceType types, ICorDebugGCReferenceEnum** ppEnum); + HRESULT GetTypeID(CORDB_ADDRESS obj, COR_TYPEID* pId); + HRESULT GetTypeForTypeID(COR_TYPEID id, ICorDebugType** ppType); + HRESULT GetArrayLayout(COR_TYPEID id, COR_ARRAY_LAYOUT* pLayout); + HRESULT GetTypeLayout(COR_TYPEID id, COR_TYPE_LAYOUT* pLayout); + HRESULT GetTypeFields(COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], ULONG32* pceltNeeded); + HRESULT + EnableNGENPolicy(CorDebugNGENPolicy ePolicy); + HRESULT + Filter(const BYTE pRecord[], + DWORD countBytes, + CorDebugRecordFormat format, + DWORD dwFlags, + DWORD dwThreadId, + ICorDebugManagedCallback* pCallback, + CORDB_CONTINUE_STATUS* pContinueStatus); + HRESULT + ProcessStateChanged(CorDebugStateChange eChange); + HRESULT SetEnableCustomNotification(ICorDebugClass* pClass, BOOL fEnable); + HRESULT GetID(DWORD* pdwProcessId); + HRESULT GetHandle(HPROCESS* phProcessHandle); + HRESULT GetThread(DWORD dwThreadId, ICorDebugThread** ppThread); + HRESULT + EnumerateObjects(ICorDebugObjectEnum** ppObjects); + HRESULT IsTransitionStub(CORDB_ADDRESS address, BOOL* pbTransitionStub); + HRESULT IsOSSuspended(DWORD threadID, BOOL* pbSuspended); + HRESULT + GetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); + HRESULT + SetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); + HRESULT + ReadMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* read); + HRESULT + WriteMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* written); + HRESULT ClearCurrentException(DWORD threadID); + HRESULT EnableLogMessages(BOOL fOnOff); + HRESULT + ModifyLogSwitch(_In_ WCHAR* pLogSwitchName, LONG lLevel); + HRESULT + EnumerateAppDomains(ICorDebugAppDomainEnum** ppAppDomains); + HRESULT GetObject(ICorDebugValue** ppObject); + HRESULT ThreadForFiberCookie(DWORD fiberCookie, ICorDebugThread** ppThread); + HRESULT GetHelperThreadID(DWORD* pThreadID); + HRESULT GetThreadForTaskID(TASKID taskid, ICorDebugThread2** ppThread); + HRESULT GetVersion(COR_VERSION* version); + HRESULT SetUnmanagedBreakpoint(CORDB_ADDRESS address, ULONG32 bufsize, BYTE buffer[], ULONG32* bufLen); + HRESULT + ClearUnmanagedBreakpoint(CORDB_ADDRESS address); + HRESULT + SetDesiredNGENCompilerFlags(DWORD pdwFlags); + HRESULT + GetDesiredNGENCompilerFlags(DWORD* pdwFlags); + HRESULT + GetReferenceValueFromGCHandle(UINT_PTR handle, ICorDebugReferenceValue** pOutValue); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT Stop(DWORD dwTimeoutIgnored); - HRESULT Continue(BOOL fIsOutOfBand); - HRESULT IsRunning(BOOL *pbRunning); - HRESULT HasQueuedCallbacks(ICorDebugThread *pThread, BOOL *pbQueued); - HRESULT - EnumerateThreads(ICorDebugThreadEnum **ppThreads); - HRESULT - SetAllThreadsDebugState(CorDebugThreadState state, - ICorDebugThread *pExceptThisThread); - HRESULT Detach(void); - HRESULT Terminate(UINT exitCode); - HRESULT - CanCommitChanges(ULONG cSnapshots, - ICorDebugEditAndContinueSnapshot *pSnapshots[], - ICorDebugErrorInfoEnum **pError); - HRESULT - CommitChanges(ULONG cSnapshots, - ICorDebugEditAndContinueSnapshot *pSnapshots[], - ICorDebugErrorInfoEnum **pError); + HRESULT Stop(DWORD dwTimeoutIgnored); + HRESULT Continue(BOOL fIsOutOfBand); + HRESULT IsRunning(BOOL* pbRunning); + HRESULT HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued); + HRESULT + EnumerateThreads(ICorDebugThreadEnum** ppThreads); + HRESULT + SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread); + HRESULT Detach(void); + HRESULT Terminate(UINT exitCode); + HRESULT + CanCommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); + HRESULT + CommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); - void AddThread(CordbThread *thread); - void AddFunction(CordbFunction *function); - void AddModule(CordbModule *module); - void AddAppDomain(CordbAppDomain *appDomain); - void AddBreakpoint(CordbFunctionBreakpoint *bp); - void AddPendingEval(CordbEval *eval); - CordbFunction *FindFunction(int id); - CordbFunction *FindFunctionByToken(int token); - CordbModule *GetModule(int module_id); - CordbAppDomain *GetCurrentAppDomain(); - CordbThread *FindThread(long thread_id); - CordbFunctionBreakpoint *GetBreakpointByOffsetAndFuncId(int64_t offset, - int method_id); - void CheckPendingEval(); + void AddThread(CordbThread* thread); + void AddFunction(CordbFunction* function); + void AddModule(CordbModule* module); + void AddAppDomain(CordbAppDomain* appDomain); + void AddBreakpoint(CordbFunctionBreakpoint* bp); + void AddPendingEval(CordbEval* eval); + CordbFunction* FindFunction(int id); + CordbFunction* FindFunctionByToken(int token); + CordbModule* GetModule(int module_id); + CordbAppDomain* GetCurrentAppDomain(); + CordbThread* FindThread(long thread_id); + CordbFunctionBreakpoint* GetBreakpointByOffsetAndFuncId(int64_t offset, int method_id); + void CheckPendingEval(); }; #endif diff --git a/src/mono/dbi/cordb-register.cpp b/src/mono/dbi/cordb-register.cpp index 876463a04f24f6..32f6014b3efca6 100644 --- a/src/mono/dbi/cordb-register.cpp +++ b/src/mono/dbi/cordb-register.cpp @@ -10,50 +10,44 @@ using namespace std; -HRESULT __stdcall CordbRegisterSet::GetRegistersAvailable(ULONG64 *pAvailable) { - LOG((LF_CORDB, LL_INFO100000, - "CordbRegisterSet - GetRegistersAvailable - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbRegisterSet::GetRegistersAvailable(ULONG64* pAvailable) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - GetRegistersAvailable - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -CordbRegisterSet::CordbRegisterSet(Connection *conn, uint8_t *ctx, - uint32_t ctx_len) - : CordbBaseMono(conn) { - this->m_pCtx = ctx; - this->m_ctxLen = ctx_len; +CordbRegisterSet::CordbRegisterSet(Connection* conn, uint8_t* ctx, uint32_t ctx_len) : CordbBaseMono(conn) +{ + this->m_pCtx = ctx; + this->m_ctxLen = ctx_len; } -HRESULT __stdcall CordbRegisterSet::QueryInterface(REFIID id, - void **pInterface) { - LOG((LF_CORDB, LL_INFO100000, - "CordbRegisterSet - QueryInterface - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbRegisterSet::QueryInterface(REFIID id, void** pInterface) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - QueryInterface - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT __stdcall CordbRegisterSet::GetRegisters(ULONG64 mask, ULONG32 regCount, - CORDB_REGISTER regBuffer[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbRegisterSet - GetRegisters - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT __stdcall CordbRegisterSet::GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - GetRegisters - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbRegisterSet::SetRegisters( - ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbRegisterSet - SetRegisters - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbRegisterSet::SetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - SetRegisters - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbRegisterSet::GetThreadContext(ULONG32 contextSize, BYTE context[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbRegisterSet - GetThreadContext - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbRegisterSet::GetThreadContext(ULONG32 contextSize, BYTE context[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - GetThreadContext - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbRegisterSet::SetThreadContext(ULONG32 contextSize, BYTE context[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbRegisterSet - SetThreadContext - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbRegisterSet::SetThreadContext(ULONG32 contextSize, BYTE context[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - SetThreadContext - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-register.h b/src/mono/dbi/cordb-register.h index b50b410de9e847..1c136307a18587 100644 --- a/src/mono/dbi/cordb-register.h +++ b/src/mono/dbi/cordb-register.h @@ -9,26 +9,35 @@ #include -class CordbRegisterSet : public CordbBaseMono, public ICorDebugRegisterSet { - uint8_t *m_pCtx; - uint32_t m_ctxLen; +class CordbRegisterSet : public CordbBaseMono, public ICorDebugRegisterSet +{ + uint8_t* m_pCtx; + uint32_t m_ctxLen; public: - CordbRegisterSet(Connection *conn, uint8_t *ctx, uint32_t ctx_len); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbRegisterSet"; } - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + CordbRegisterSet(Connection* conn, uint8_t* ctx, uint32_t ctx_len); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbRegisterSet"; + } + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT - GetRegistersAvailable(ULONG64 *pAvailable); - HRESULT - GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]); - HRESULT SetRegisters(ULONG64 mask, ULONG32 regCount, - CORDB_REGISTER regBuffer[]); - HRESULT GetThreadContext(ULONG32 contextSize, BYTE context[]); - HRESULT SetThreadContext(ULONG32 contextSize, BYTE context[]); + HRESULT + GetRegistersAvailable(ULONG64* pAvailable); + HRESULT + GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]); + HRESULT SetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]); + HRESULT GetThreadContext(ULONG32 contextSize, BYTE context[]); + HRESULT SetThreadContext(ULONG32 contextSize, BYTE context[]); }; #endif diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index 19594a504a206e..96c188544f40e6 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -11,131 +11,128 @@ using namespace std; -CordbStepper::CordbStepper(Connection *conn, CordbThread *thread) - : CordbBaseMono(conn) { - m_pThread = thread; - m_commandId = -1; +CordbStepper::CordbStepper(Connection* conn, CordbThread* thread) : CordbBaseMono(conn) +{ + m_pThread = thread; + m_commandId = -1; } CordbStepper::~CordbStepper() {} -HRESULT STDMETHODCALLTYPE CordbStepper::IsActive(BOOL *pbActive) { - LOG((LF_CORDB, LL_INFO100000, "CordbStepper - IsActive - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbStepper::IsActive(BOOL* pbActive) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - IsActive - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbStepper::Deactivate(void) { - LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - Deactivate - IMPLEMENTED\n")); - MdbgProtBuffer sendbuf; - int buflen = 128; - m_dbgprot_buffer_init(&sendbuf, buflen); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); - m_dbgprot_buffer_add_int(&sendbuf, m_commandId); - conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, - MDBGPROT_CMD_EVENT_REQUEST_CLEAR, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbStepper::Deactivate(void) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - Deactivate - IMPLEMENTED\n")); + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); + m_dbgprot_buffer_add_int(&sendbuf, m_commandId); + conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_CLEAR, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbStepper::SetInterceptMask(CorDebugIntercept mask) { - LOG((LF_CORDB, LL_INFO100000, - "CordbStepper - SetInterceptMask - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbStepper::SetInterceptMask(CorDebugIntercept mask) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - SetInterceptMask - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbStepper::SetUnmappedStopMask(CorDebugUnmappedStop mask) { - LOG((LF_CORDB, LL_INFO100000, - "CordbStepper - SetUnmappedStopMask - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbStepper::SetUnmappedStopMask(CorDebugUnmappedStop mask) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - SetUnmappedStopMask - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbStepper::Step(BOOL bStepIn) { - LOG((LF_CORDB, LL_INFO100000, "CordbStepper - Step - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbStepper::Step(BOOL bStepIn) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - Step - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, - COR_DEBUG_STEP_RANGE ranges[], - ULONG32 cRangeCount) { - MdbgProtBuffer sendbuf; - int buflen = 128; - m_dbgprot_buffer_init(&sendbuf, buflen); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); - m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); - - m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); - m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO - : MDBGPROT_STEP_DEPTH_OVER); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, - MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - - m_commandId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - - LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepRange - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, COR_DEBUG_STEP_RANGE ranges[], ULONG32 cRangeCount) +{ + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); + + m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); + m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO : MDBGPROT_STEP_DEPTH_OVER); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_commandId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + + LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepRange - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { - MdbgProtBuffer sendbuf; - int buflen = 128; - m_dbgprot_buffer_init(&sendbuf, buflen); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); - m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); - - m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_DEPTH_OUT); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, - MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - - LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepOut - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) +{ + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); + + m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_DEPTH_OUT); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepOut - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbStepper::SetRangeIL(BOOL bIL) { - LOG((LF_CORDB, LL_INFO100000, - "CordbStepper - SetRangeIL - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbStepper::SetRangeIL(BOOL bIL) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - SetRangeIL - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbStepper::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugStepper) - *pInterface = static_cast(this); - else if (id == IID_ICorDebugStepper2) - *pInterface = static_cast(this); - else if (id == IID_IUnknown) - *pInterface = - static_cast(static_cast(this)); - else - return E_NOINTERFACE; - - AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbStepper::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugStepper) + *pInterface = static_cast(this); + else if (id == IID_ICorDebugStepper2) + *pInterface = static_cast(this); + else if (id == IID_IUnknown) + *pInterface = static_cast(static_cast(this)); + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbStepper::SetJMC(BOOL fIsJMCStepper) { - LOG((LF_CORDB, LL_INFO100000, "CordbStepper - SetJMC - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbStepper::SetJMC(BOOL fIsJMCStepper) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbStepper - SetJMC - NOT IMPLEMENTED\n")); + return S_OK; } diff --git a/src/mono/dbi/cordb-stepper.h b/src/mono/dbi/cordb-stepper.h index f86d2ea9bdf8f9..3aec9c473e1f4c 100644 --- a/src/mono/dbi/cordb-stepper.h +++ b/src/mono/dbi/cordb-stepper.h @@ -9,30 +9,37 @@ #include -class CordbStepper : public CordbBaseMono, - public ICorDebugStepper, - public ICorDebugStepper2 { - CordbThread *m_pThread; - int m_commandId; +class CordbStepper : public CordbBaseMono, public ICorDebugStepper, public ICorDebugStepper2 +{ + CordbThread* m_pThread; + int m_commandId; public: - CordbStepper(Connection *conn, CordbThread *thread); - ~CordbStepper(); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbStepper"; } - HRESULT IsActive(BOOL *pbActive); - HRESULT Deactivate(void); - HRESULT SetInterceptMask(CorDebugIntercept mask); - HRESULT SetUnmappedStopMask(CorDebugUnmappedStop mask); - HRESULT Step(BOOL bStepIn); - HRESULT StepRange(BOOL bStepIn, COR_DEBUG_STEP_RANGE ranges[], - ULONG32 cRangeCount); - HRESULT StepOut(void); - HRESULT SetRangeIL(BOOL bIL); - HRESULT QueryInterface(REFIID riid, void **ppvObject); + CordbStepper(Connection* conn, CordbThread* thread); + ~CordbStepper(); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbStepper"; + } + HRESULT IsActive(BOOL* pbActive); + HRESULT Deactivate(void); + HRESULT SetInterceptMask(CorDebugIntercept mask); + HRESULT SetUnmappedStopMask(CorDebugUnmappedStop mask); + HRESULT Step(BOOL bStepIn); + HRESULT StepRange(BOOL bStepIn, COR_DEBUG_STEP_RANGE ranges[], ULONG32 cRangeCount); + HRESULT StepOut(void); + HRESULT SetRangeIL(BOOL bIL); + HRESULT QueryInterface(REFIID riid, void** ppvObject); - HRESULT SetJMC(BOOL fIsJMCStepper); + HRESULT SetJMC(BOOL fIsJMCStepper); }; #endif diff --git a/src/mono/dbi/cordb-symbol.cpp b/src/mono/dbi/cordb-symbol.cpp deleted file mode 100644 index ab130f0d618226..00000000000000 --- a/src/mono/dbi/cordb-symbol.cpp +++ /dev/null @@ -1,2771 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// -// File: CORDB-SYMBOL.CPP -// - -#include "corerror.h" -#include "metamodel.h" -#include "metamodelpub.h" -#include "rwutil.h" -#include "stdafx.h" -#include "stgio.h" - -#include "importhelper.h" - -#include - -#include -#include -#include - -using namespace std; - -RegMeta::RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule) - : CordbBaseMono(NULL) { - m_pStgdb = new CLiteWeightStgdbRW(); - ULONG32 pcchName = 0; - cordbModule->GetName(0, &pcchName, NULL); - - WCHAR *full_path; - full_path = (WCHAR *)malloc(sizeof(WCHAR) * pcchName); - cordbModule->GetName(pcchName, &pcchName, full_path); - - m_pStgdb->OpenForRead(full_path, NULL, 0, 0); - free(full_path); -} - -RegMeta::~RegMeta() { delete m_pStgdb; } - -HRESULT RegMeta::EnumGenericParams( - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tkOwner, // [IN] TypeDef or MethodDef whose generic parameters are - // requested - mdGenericParam rTokens[], // [OUT] Put GenericParams here. - ULONG cMaxTokens, // [IN] Max GenericParams to put. - ULONG *pcTokens) { - HRESULT hr = S_OK; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart; - ULONG ridEnd; - HENUMInternal *pEnum; - GenericParamRec *pRec; - ULONG index; - CMiniMdRW *pMiniMd = NULL; - - pMiniMd = &(m_pStgdb->m_MiniMd); - - // See if this version of the metadata can do Generics - if (!pMiniMd->SupportsGenerics()) { - if (pcTokens) - *pcTokens = 0; - hr = S_FALSE; - goto ErrExit; - } - - _ASSERTE(TypeFromToken(tkOwner) == mdtTypeDef || - TypeFromToken(tkOwner) == mdtMethodDef); - - if (*ppmdEnum == 0) { - // instantiating a new ENUM - - //@todo GENERICS: review this. Are we expecting a sorted table or not? - if (pMiniMd->IsSorted(TBL_GenericParam)) { - if (TypeFromToken(tkOwner) == mdtTypeDef) { - IfFailGo(pMiniMd->getGenericParamsForTypeDef(RidFromToken(tkOwner), - &ridEnd, &ridStart)); - } else { - IfFailGo(pMiniMd->getGenericParamsForMethodDef(RidFromToken(tkOwner), - &ridEnd, &ridStart)); - } - - IfFailGo(HENUMInternal::CreateSimpleEnum(mdtGenericParam, ridStart, - ridEnd, &pEnum)); - } else { - // table is not sorted so we have to create dynamic array - // create the dynamic enumerator - // - ridStart = 1; - ridEnd = pMiniMd->getCountGenericParams() + 1; - - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtGenericParam, &pEnum)); - - for (index = ridStart; index < ridEnd; index++) { - IfFailGo(pMiniMd->GetGenericParamRecord(index, &pRec)); - if (tkOwner == pMiniMd->getOwnerOfGenericParam(pRec)) { - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(index, mdtGenericParam))); - } - } - } - - // set the output parameter - *ppmdEnum = pEnum; - } else { - pEnum = *ppmdEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMaxTokens, rTokens, pcTokens); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} - -HRESULT RegMeta::GetGenericParamProps( // S_OK or error. - mdGenericParam rd, // [IN] The type parameter - ULONG *pulSequence, // [OUT] Parameter sequence number - DWORD *pdwAttr, // [OUT] Type parameter flags (for future use) - mdToken *ptOwner, // [OUT] The owner (TypeDef or MethodDef) - DWORD *reserved, // [OUT] The kind (TypeDef/Ref/Spec, for future use) - __out_ecount_opt(cchName) LPWSTR szName, // [OUT] The name - ULONG cchName, // [IN] Size of name buffer - ULONG *pchName) // [OUT] Actual size of name -{ - HRESULT hr = NOERROR; - - BEGIN_ENTRYPOINT_NOTHROW; - - GenericParamRec *pGenericParamRec; - CMiniMdRW *pMiniMd = NULL; - RID ridRD = RidFromToken(rd); - - pMiniMd = &(m_pStgdb->m_MiniMd); - - // See if this version of the metadata can do Generics - if (!pMiniMd->SupportsGenerics()) - IfFailGo(CLDB_E_INCOMPATIBLE); - - if ((TypeFromToken(rd) == mdtGenericParam) && (ridRD != 0)) { - IfFailGo( - pMiniMd->GetGenericParamRecord(RidFromToken(rd), &pGenericParamRec)); - - if (pulSequence) - *pulSequence = pMiniMd->getNumberOfGenericParam(pGenericParamRec); - if (pdwAttr) - *pdwAttr = pMiniMd->getFlagsOfGenericParam(pGenericParamRec); - if (ptOwner) - *ptOwner = pMiniMd->getOwnerOfGenericParam(pGenericParamRec); - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not - // rewritten with S_OK - if (pchName || szName) - IfFailGo(pMiniMd->getNameOfGenericParam(pGenericParamRec, szName, cchName, - pchName)); - } else - hr = META_E_BAD_INPUT_PARAMETER; - -ErrExit: - - return hr; -} // [OUT] Put size of name (wide chars) here. - -HRESULT RegMeta::GetMethodSpecProps( - mdMethodSpec mi, // [IN] The method instantiation - mdToken *tkParent, // [OUT] MethodDef or MemberRef - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob) { - - HRESULT hr = NOERROR; - - MethodSpecRec *pMethodSpecRec; - CMiniMdRW *pMiniMd = NULL; - - pMiniMd = &(m_pStgdb->m_MiniMd); - - // See if this version of the metadata can do Generics - if (!pMiniMd->SupportsGenerics()) - IfFailGo(CLDB_E_INCOMPATIBLE); - - _ASSERTE(TypeFromToken(mi) == mdtMethodSpec && RidFromToken(mi)); - - IfFailGo(pMiniMd->GetMethodSpecRecord(RidFromToken(mi), &pMethodSpecRec)); - - if (tkParent) - *tkParent = pMiniMd->getMethodOfMethodSpec(pMethodSpecRec); - - if (ppvSigBlob || pcbSigBlob) { - // caller wants signature information - PCCOR_SIGNATURE pvSigTmp; - ULONG cbSig; - IfFailGo(pMiniMd->getInstantiationOfMethodSpec(pMethodSpecRec, &pvSigTmp, - &cbSig)); - if (ppvSigBlob) - *ppvSigBlob = pvSigTmp; - if (pcbSigBlob) - *pcbSigBlob = cbSig; - } - -ErrExit: - - return hr; -} // [OUT] actual size of signature blob - -HRESULT RegMeta::EnumGenericParamConstraints( - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdGenericParam tk, // [IN] GenericParam whose constraints are requested - mdGenericParamConstraint - rGenericParamConstraints[], // [OUT] Put GenericParamConstraints here. - ULONG cMax, // [IN] Max GenericParamConstraints to put. - ULONG *pcGenericParamConstraints) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumGenericParamConstraints - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] Put # put here. - -HRESULT RegMeta::GetGenericParamConstraintProps( // S_OK or error. - mdGenericParamConstraint gpc, // [IN] GenericParamConstraint - mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained - mdToken *ptkConstraintType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetGenericParamConstraintProps - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] TypeDef/Ref/Spec constraint - -HRESULT RegMeta::GetPEKind( // S_OK or error. - DWORD *pdwPEKind, // [OUT] The kind of PE (0 - not a PE) - DWORD *pdwMachine) { - HRESULT hr = NOERROR; - MAPPINGTYPE mt = MTYPE_NOMAPPING; - - if (m_pStgdb->m_pStgIO != NULL) - mt = m_pStgdb->m_pStgIO->GetMemoryMappedType(); - - hr = m_pStgdb->GetPEKind(mt, pdwPEKind, pdwMachine); - return hr; -} // [OUT] Machine as defined in NT header - -HRESULT RegMeta::GetVersionString( // S_OK or error. - _Out_writes_to_opt_(ccBufSize, *pccBufSize) - LPWSTR pwzBuf, // [OUT] Put version string here. - DWORD cchBufSize, // [IN] size of the buffer, in wide chars - DWORD *pchBufSize) { - HRESULT hr = NOERROR; - - DWORD cch; // Length of WideChar string. - LPCSTR pVer; // Pointer to version string. - - if (m_pStgdb->m_pvMd != NULL) { - // For convenience, get a pointer to the version string. - // @todo: get from alternate locations when there is no STOREAGESIGNATURE. - pVer = reinterpret_cast( - reinterpret_cast(m_pStgdb->m_pvMd)->pVersion); - // Attempt to convert into caller's buffer. - cch = WszMultiByteToWideChar(CP_UTF8, 0, pVer, -1, pwzBuf, cchBufSize); - // Did the string fit? - if (cch == 0) { - // No, didn't fit. Find out space required. - cch = WszMultiByteToWideChar(CP_UTF8, 0, pVer, -1, pwzBuf, 0); - // NUL terminate string. - if (cchBufSize > 0) - pwzBuf[cchBufSize - 1] = W('\0'); - // Truncation return code. - hr = CLDB_S_TRUNCATION; - } - } else { - // No string. - if (cchBufSize > 0) - *pwzBuf = W('\0'); - cch = 0; - } - - if (pchBufSize) - *pchBufSize = cch; - - return hr; -} // [OUT] Size of the version string, wide chars, including terminating nul. - -HRESULT RegMeta::EnumMethodSpecs( - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tk, // [IN] MethodDef or MemberRef whose MethodSpecs are requested - mdMethodSpec rMethodSpecs[], // [OUT] Put MethodSpecs here. - ULONG cMax, // [IN] Max tokens to put. - ULONG *pcMethodSpecs) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumMethodSpecs - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] Put actual count here. - -HRESULT RegMeta::GetAssemblyProps( // S_OK or error. - mdAssembly mda, // [IN] The Assembly for which to get the properties. - const void **ppbPublicKey, // [OUT] Pointer to the public key. - ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. - ULONG *pulHashAlgId, // [OUT] Hash Algorithm. - _Out_writes_to_opt_(cchName, *pchName) LPWSTR - szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. - DWORD *pdwAssemblyFlags) { - HRESULT hr = S_OK; - - BEGIN_ENTRYPOINT_NOTHROW; - - AssemblyRec *pRecord; - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - _ASSERTE(TypeFromToken(mda) == mdtAssembly && RidFromToken(mda)); - IfFailGo(pMiniMd->GetAssemblyRecord(RidFromToken(mda), &pRecord)); - - if (ppbPublicKey != NULL) { - IfFailGo(pMiniMd->getPublicKeyOfAssembly( - pRecord, (const BYTE **)ppbPublicKey, pcbPublicKey)); - } - if (pulHashAlgId) - *pulHashAlgId = pMiniMd->getHashAlgIdOfAssembly(pRecord); - if (pMetaData) { - pMetaData->usMajorVersion = pMiniMd->getMajorVersionOfAssembly(pRecord); - pMetaData->usMinorVersion = pMiniMd->getMinorVersionOfAssembly(pRecord); - pMetaData->usBuildNumber = pMiniMd->getBuildNumberOfAssembly(pRecord); - pMetaData->usRevisionNumber = pMiniMd->getRevisionNumberOfAssembly(pRecord); - IfFailGo(pMiniMd->getLocaleOfAssembly(pRecord, pMetaData->szLocale, - pMetaData->cbLocale, - &pMetaData->cbLocale)); - pMetaData->ulProcessor = 0; - pMetaData->ulOS = 0; - } - if (pdwAssemblyFlags) { - *pdwAssemblyFlags = pMiniMd->getFlagsOfAssembly(pRecord); - - // Turn on the afPublicKey if PublicKey blob is not empty - DWORD cbPublicKey; - const BYTE *pbPublicKey; - IfFailGo( - pMiniMd->getPublicKeyOfAssembly(pRecord, &pbPublicKey, &cbPublicKey)); - if (cbPublicKey != 0) - *pdwAssemblyFlags |= afPublicKey; - } - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szName || pchName) - IfFailGo(pMiniMd->getNameOfAssembly(pRecord, szName, cchName, pchName)); -ErrExit: - - return hr; -} // [OUT] Flags. - -HRESULT RegMeta::GetAssemblyRefProps( // S_OK or error. - mdAssemblyRef mdar, // [IN] The AssemblyRef for which to get the properties. - const void * - *ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token. - ULONG * - pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or token. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. - const void **ppbHashValue, // [OUT] Hash blob. - ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob. - DWORD *pdwAssemblyRefFlags) { - HRESULT hr = S_OK; - - BEGIN_ENTRYPOINT_NOTHROW; - - AssemblyRefRec *pRecord; - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - _ASSERTE(TypeFromToken(mdar) == mdtAssemblyRef && RidFromToken(mdar)); - IfFailGo(pMiniMd->GetAssemblyRefRecord(RidFromToken(mdar), &pRecord)); - - if (ppbPublicKeyOrToken != NULL) { - IfFailGo(pMiniMd->getPublicKeyOrTokenOfAssemblyRef( - pRecord, (const BYTE **)ppbPublicKeyOrToken, pcbPublicKeyOrToken)); - } - if (pMetaData) { - pMetaData->usMajorVersion = pMiniMd->getMajorVersionOfAssemblyRef(pRecord); - pMetaData->usMinorVersion = pMiniMd->getMinorVersionOfAssemblyRef(pRecord); - pMetaData->usBuildNumber = pMiniMd->getBuildNumberOfAssemblyRef(pRecord); - pMetaData->usRevisionNumber = - pMiniMd->getRevisionNumberOfAssemblyRef(pRecord); - IfFailGo(pMiniMd->getLocaleOfAssemblyRef(pRecord, pMetaData->szLocale, - pMetaData->cbLocale, - &pMetaData->cbLocale)); - pMetaData->ulProcessor = 0; - pMetaData->ulOS = 0; - } - if (ppbHashValue != NULL) { - IfFailGo(pMiniMd->getHashValueOfAssemblyRef( - pRecord, (const BYTE **)ppbHashValue, pcbHashValue)); - } - if (pdwAssemblyRefFlags) - *pdwAssemblyRefFlags = pMiniMd->getFlagsOfAssemblyRef(pRecord); - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szName || pchName) - IfFailGo(pMiniMd->getNameOfAssemblyRef(pRecord, szName, cchName, pchName)); -ErrExit: - - return hr; -} // [OUT] Flags. - -HRESULT RegMeta::GetFileProps( // S_OK or error. - mdFile mdf, // [IN] The File for which to get the properties. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob. - ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob. - DWORD *pdwFileFlags) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetFileProps - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] Flags. - -HRESULT RegMeta::GetExportedTypeProps( // S_OK or error. - mdExportedType - mdct, // [IN] The ExportedType for which to get the properties. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - mdToken - *ptkImplementation, // [OUT] mdFile or mdAssemblyRef or mdExportedType. - mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file. - DWORD *pdwExportedTypeFlags) { - HRESULT hr = S_OK; // A result. - - ExportedTypeRec *pRecord; // The exported type. - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - int bTruncation = 0; // Was there name truncation? - - _ASSERTE(TypeFromToken(mdct) == mdtExportedType && RidFromToken(mdct)); - IfFailGo(pMiniMd->GetExportedTypeRecord(RidFromToken(mdct), &pRecord)); - - if (szName || pchName) { - LPCSTR szTypeNamespace; - LPCSTR szTypeName; - - IfFailGo( - pMiniMd->getTypeNamespaceOfExportedType(pRecord, &szTypeNamespace)); - PREFIX_ASSUME(szTypeNamespace != NULL); - MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzTypeNamespace, szTypeNamespace); - IfNullGo(wzTypeNamespace); - - IfFailGo(pMiniMd->getTypeNameOfExportedType(pRecord, &szTypeName)); - _ASSERTE(*szTypeName); - MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzTypeName, szTypeName); - IfNullGo(wzTypeName); - - if (szName) - bTruncation = - !(ns::MakePath(szName, cchName, wzTypeNamespace, wzTypeName)); - if (pchName) { - if (bTruncation || !szName) - *pchName = ns::GetFullLength(wzTypeNamespace, wzTypeName); - else - *pchName = (ULONG)(wcslen(szName) + 1); - } - } - if (ptkImplementation) - *ptkImplementation = pMiniMd->getImplementationOfExportedType(pRecord); - if (ptkTypeDef) - *ptkTypeDef = pMiniMd->getTypeDefIdOfExportedType(pRecord); - if (pdwExportedTypeFlags) - *pdwExportedTypeFlags = pMiniMd->getFlagsOfExportedType(pRecord); - - if (bTruncation && hr == S_OK) { - if ((szName != NULL) && (cchName > 0)) { - // null-terminate the truncated output string - szName[cchName - 1] = W('\0'); - } - hr = CLDB_S_TRUNCATION; - } - -ErrExit: - - return hr; -} // [OUT] Flags. - -HRESULT RegMeta::GetManifestResourceProps( // S_OK or error. - mdManifestResource - mdmr, // [IN] The ManifestResource for which to get the properties. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides - // the ManifestResource. - DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within - // the file. - DWORD *pdwResourceFlags) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetManifestResourceProps - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] Flags. - -HRESULT RegMeta::EnumAssemblyRefs( // S_OK or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdAssemblyRef rAssemblyRefs[], // [OUT] Put AssemblyRefs here. - ULONG cMax, // [IN] Max AssemblyRefs to put. - ULONG *pcTokens) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumAssemblyRefs - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] Put # put here. - -HRESULT RegMeta::EnumFiles( // S_OK or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdFile rFiles[], // [OUT] Put Files here. - ULONG cMax, // [IN] Max Files to put. - ULONG *pcTokens) { - HRESULT hr = NOERROR; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - HENUMInternal *pEnum; - - if (*ppmdEnum == 0) { - // instantiate a new ENUM. - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - // create the enumerator. - IfFailGo(HENUMInternal::CreateSimpleEnum( - mdtFile, 1, pMiniMd->getCountFiles() + 1, &pEnum)); - - // set the output parameter. - *ppmdEnum = pEnum; - } else - pEnum = *ppmdEnum; - - // we can only fill the minimum of what the caller asked for or what we have - // left. - IfFailGo(HENUMInternal::EnumWithCount(pEnum, cMax, rFiles, pcTokens)); -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} // [OUT] Put # put here. - -HRESULT RegMeta::EnumExportedTypes( // S_OK or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdExportedType rExportedTypes[], // [OUT] Put ExportedTypes here. - ULONG cMax, // [IN] Max ExportedTypes to put. - ULONG *pcTokens) { - HRESULT hr = NOERROR; - - BEGIN_ENTRYPOINT_NOTHROW; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - HENUMInternal *pEnum; - - if (*ppmdEnum == 0) { - // instantiate a new ENUM. - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - if (pMiniMd->HasDelete()) { - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtExportedType, &pEnum)); - - // add all Types to the dynamic array if name is not _Delete - for (ULONG index = 1; index <= pMiniMd->getCountExportedTypes(); - index++) { - ExportedTypeRec *pRec; - IfFailGo(pMiniMd->GetExportedTypeRecord(index, &pRec)); - LPCSTR szTypeName; - IfFailGo(pMiniMd->getTypeNameOfExportedType(pRec, &szTypeName)); - if (IsDeletedName(szTypeName)) { - continue; - } - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(index, mdtExportedType))); - } - } else { - // create the enumerator. - IfFailGo(HENUMInternal::CreateSimpleEnum( - mdtExportedType, 1, pMiniMd->getCountExportedTypes() + 1, &pEnum)); - } - - // set the output parameter. - *ppmdEnum = pEnum; - } else - pEnum = *ppmdEnum; - - // we can only fill the minimum of what the caller asked for or what we have - // left. - IfFailGo(HENUMInternal::EnumWithCount(pEnum, cMax, rExportedTypes, pcTokens)); -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} // [OUT] Put # put here. - -HRESULT RegMeta::EnumManifestResources( // S_OK or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdManifestResource - rManifestResources[], // [OUT] Put ManifestResources here. - ULONG cMax, // [IN] Max Resources to put. - ULONG *pcTokens) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumManifestResources - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] Put # put here. - -HRESULT RegMeta::FindExportedTypeByName( // S_OK or error - LPCWSTR szName, // [IN] Name of the ExportedType. - mdToken mdtExportedType, // [IN] ExportedType for the enclosing class. - mdExportedType *ptkExportedType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - FindExportedTypeByName - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] Put the ExportedType token here. - -HRESULT RegMeta::FindManifestResourceByName( // S_OK or error - LPCWSTR szName, // [IN] Name of the ManifestResource. - mdManifestResource *ptkManifestResource) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - FindManifestResourceByName - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] Put the ManifestResource token here. - -HRESULT RegMeta::FindAssembliesByName( // S_OK or error - LPCWSTR szAppBase, // [IN] optional - can be NULL - LPCWSTR szPrivateBin, // [IN] optional - can be NULL - LPCWSTR szAssemblyName, // [IN] required - this is the assembly you are - // requesting - IUnknown *ppIUnk[], // [OUT] put IMetaDataAssemblyImport pointers here - ULONG cMax, // [IN] The max number to put - ULONG *pcAssemblies) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - FindAssembliesByName - NOT IMPLEMENTED\n")); - return S_OK; -} // [OUT] The number of assemblies returned. - -// IUnknown methods -HRESULT RegMeta::QueryInterface(REFIID riid, LPVOID *ppUnk) { - HRESULT hr = S_OK; - int fIsInterfaceRW = false; - *ppUnk = 0; - if (riid == IID_IUnknown) { - *ppUnk = (IUnknown *)(IMetaDataImport2 *)this; - } else if (riid == IID_IMDCommon) { - *ppUnk = (IMDCommon *)this; - } else if (riid == IID_IMetaDataImport) { - *ppUnk = (IMetaDataImport2 *)this; - } else if (riid == IID_IMetaDataImport2) { - *ppUnk = (IMetaDataImport2 *)this; - } else if (riid == IID_IMetaDataAssemblyImport) { - *ppUnk = (IMetaDataAssemblyImport *)this; - } else { - IfFailGo(E_NOINTERFACE); - } -ErrExit: - if (hr == S_OK) - AddRef(); - return hr; -} - -// IMetaDataImport functions -void RegMeta::CloseEnum(HCORENUM hEnum) { - BEGIN_CLEANUP_ENTRYPOINT; - // No need to lock this function. - HENUMInternal *pmdEnum = reinterpret_cast(hEnum); - - if (pmdEnum == NULL) - return; - - HENUMInternal::DestroyEnum(pmdEnum); - END_CLEANUP_ENTRYPOINT; -} - -HRESULT RegMeta::CountEnum(HCORENUM hEnum, ULONG *pulCount) { - HENUMInternal *pmdEnum = reinterpret_cast(hEnum); - HRESULT hr = S_OK; - - // No need to lock this function. - - _ASSERTE(pulCount); - - if (pmdEnum == NULL) { - *pulCount = 0; - goto ErrExit; - } - - if (pmdEnum->m_tkKind == (TBL_MethodImpl << 24)) { - // Number of tokens must always be a multiple of 2. - _ASSERTE(!(pmdEnum->m_ulCount % 2)); - // There are two entries in the Enumerator for each MethodImpl. - *pulCount = pmdEnum->m_ulCount / 2; - } else - *pulCount = pmdEnum->m_ulCount; -ErrExit: - return hr; -} - -HRESULT RegMeta::ResetEnum(HCORENUM hEnum, ULONG ulPos) { - LOG((LF_CORDB, LL_INFO100000, "CordbSymbol - ResetEnum - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumTypeDefs(HCORENUM *phEnum, mdTypeDef rTypeDefs[], - ULONG cMax, ULONG *pcTypeDefs) { - HRESULT hr = S_OK; - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - HENUMInternal *pEnum; - if (*phEnum == NULL) { - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - HENUMInternal::CreateDynamicArrayEnum(mdtTypeDef, &pEnum); - for (ULONG index = 2; index <= pMiniMd->getCountTypeDefs(); index++) { - TypeDefRec *pRec; - pMiniMd->GetTypeDefRecord(index, &pRec); - LPCSTR szTypeDefName; - pMiniMd->getNameOfTypeDef(pRec, &szTypeDefName); - if (IsDeletedName(szTypeDefName)) - continue; - HENUMInternal::AddElementToEnum(pEnum, TokenFromRid(index, mdtTypeDef)); - } - *ppmdEnum = pEnum; - } else { - pEnum = *ppmdEnum; - } - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rTypeDefs, pcTypeDefs); - return hr; -} - -HRESULT RegMeta::EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td, - mdInterfaceImpl rImpls[], ULONG cMax, - ULONG *pcImpls) { - HRESULT hr = S_OK; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart; - ULONG ridEnd; - HENUMInternal *pEnum; - InterfaceImplRec *pRec; - ULONG index; - - _ASSERTE(TypeFromToken(td) == mdtTypeDef); - - if (*ppmdEnum == 0) { - // instantiating a new ENUM - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - if (pMiniMd->IsSorted(TBL_InterfaceImpl)) { - IfFailGo(pMiniMd->getInterfaceImplsForTypeDef(RidFromToken(td), &ridEnd, - &ridStart)); - IfFailGo(HENUMInternal::CreateSimpleEnum(mdtInterfaceImpl, ridStart, - ridEnd, &pEnum)); - } else { - // table is not sorted so we have to create dynmaic array - // create the dynamic enumerator - // - ridStart = 1; - ridEnd = pMiniMd->getCountInterfaceImpls() + 1; - - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtInterfaceImpl, &pEnum)); - - for (index = ridStart; index < ridEnd; index++) { - IfFailGo(pMiniMd->GetInterfaceImplRecord(index, &pRec)); - if (td == pMiniMd->getClassOfInterfaceImpl(pRec)) { - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(index, mdtInterfaceImpl))); - } - } - } - - // set the output parameter - *ppmdEnum = pEnum; - } else { - pEnum = *ppmdEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rImpls, pcImpls); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} - -HRESULT RegMeta::EnumTypeRefs(HCORENUM *phEnum, mdTypeRef rTypeRefs[], - ULONG cMax, ULONG *pcTypeRefs) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumTypeRefs - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::FindTypeDefByName( // S_OK or error. - LPCWSTR wzTypeDef, // [IN] Name of the Type. - mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class. - mdTypeDef *ptd) // [OUT] Put the TypeDef token here. -{ - HRESULT hr = S_OK; - if (wzTypeDef == NULL) - IfFailGo(E_INVALIDARG); - PREFIX_ASSUME(wzTypeDef != NULL); - LPSTR szTypeDef; - UTF8STR(wzTypeDef, szTypeDef); - LPCSTR szNamespace; - LPCSTR szName; - - _ASSERTE(ptd); - _ASSERTE(TypeFromToken(tkEnclosingClass) == mdtTypeDef || - TypeFromToken(tkEnclosingClass) == mdtTypeRef || - IsNilToken(tkEnclosingClass)); - - // initialize output parameter - *ptd = mdTypeDefNil; - - ns::SplitInline(szTypeDef, szNamespace, szName); - hr = ImportHelper::FindTypeDefByName(&(m_pStgdb->m_MiniMd), szNamespace, - szName, tkEnclosingClass, ptd); -ErrExit: - return hr; -} - -HRESULT RegMeta::GetScopeProps( // S_OK or error. - __out_ecount_part_opt(cchName, *pchName) - LPWSTR szName, // [OUT] Put the name here. - ULONG cchName, // [IN] Size of name buffer in wide chars. - ULONG *pchName, // [OUT] Put size of name (wide chars) here. - GUID *pmvid) // [OUT, OPTIONAL] Put MVID here. -{ - HRESULT hr = S_OK; - - BEGIN_ENTRYPOINT_NOTHROW; - - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - ModuleRec *pModuleRec; - - // there is only one module record - IfFailGo(pMiniMd->GetModuleRecord(1, &pModuleRec)); - - if (pmvid != NULL) { - IfFailGo(pMiniMd->getMvidOfModule(pModuleRec, pmvid)); - } - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szName || pchName) - IfFailGo(pMiniMd->getNameOfModule(pModuleRec, szName, cchName, pchName)); -ErrExit: - return hr; -} - -HRESULT RegMeta::GetModuleFromScope( // S_OK. - mdModule *pmd) // [OUT] Put mdModule token here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetModuleFromScope - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetTypeDefProps( // S_OK or error. - mdTypeDef td, // [IN] TypeDef token for inquiry. - __out_ecount_part_opt(cchTypeDef, *pchTypeDef) - LPWSTR szTypeDef, // [OUT] Put name here. - ULONG cchTypeDef, // [IN] size of name buffer in wide chars. - ULONG *pchTypeDef, // [OUT] put size of name (wide chars) here. - DWORD *pdwTypeDefFlags, // [OUT] Put flags here. - mdToken *ptkExtends) // [OUT] Put base class TypeDef/TypeRef here. -{ - HRESULT hr = S_OK; - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - TypeDefRec *pTypeDefRec; - BOOL fTruncation = FALSE; - - if (TypeFromToken(td) != mdtTypeDef) { - hr = S_FALSE; - goto ErrExit; - } - if (td == mdTypeDefNil) { - // Backward compatibility with CLR 2.0 implementation - if (pdwTypeDefFlags != NULL) - *pdwTypeDefFlags = 0; - if (ptkExtends != NULL) - *ptkExtends = mdTypeRefNil; - if (pchTypeDef != NULL) - *pchTypeDef = 1; - if ((szTypeDef != NULL) && (cchTypeDef > 0)) - szTypeDef[0] = 0; - - hr = S_OK; - goto ErrExit; - } - - pMiniMd->GetTypeDefRecord(RidFromToken(td), &pTypeDefRec); - - if ((szTypeDef != NULL) || (pchTypeDef != NULL)) { - LPCSTR szNamespace; - LPCSTR szName; - - pMiniMd->getNamespaceOfTypeDef(pTypeDefRec, &szNamespace); - MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzNamespace, szNamespace); - IfNullGo(wzNamespace); - - pMiniMd->getNameOfTypeDef(pTypeDefRec, &szName); - MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzName, szName); - - if (szTypeDef != NULL) { - fTruncation = !(ns::MakePath(szTypeDef, cchTypeDef, wzNamespace, wzName)); - } - if (pchTypeDef != NULL) { - if (fTruncation || (szTypeDef == NULL)) { - *pchTypeDef = ns::GetFullLength(wzNamespace, wzName); - } else { - *pchTypeDef = (ULONG)(wcslen(szTypeDef) + 1); - } - } - } - if (pdwTypeDefFlags != NULL) { - // caller wants type flags - *pdwTypeDefFlags = pMiniMd->getFlagsOfTypeDef(pTypeDefRec); - } - if (ptkExtends != NULL) { - *ptkExtends = pMiniMd->getExtendsOfTypeDef(pTypeDefRec); - - // take care of the 0 case - if (RidFromToken(*ptkExtends) == 0) { - *ptkExtends = mdTypeRefNil; - } - } - - if (fTruncation && (hr == S_OK)) { - if ((szTypeDef != NULL) && (cchTypeDef > 0)) { - // null-terminate the truncated output string - szTypeDef[cchTypeDef - 1] = W('\0'); - } - hr = CLDB_S_TRUNCATION; - } - -ErrExit: - return hr; -} - -HRESULT RegMeta::GetInterfaceImplProps( // S_OK or error. - mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. - mdTypeDef *pClass, // [OUT] Put implementing class token here. - mdToken *ptkIface) // [OUT] Put implemented interface token here. -{ - HRESULT hr = S_OK; - - CMiniMdRW *pMiniMd = NULL; - InterfaceImplRec *pIIRec = NULL; - - _ASSERTE(TypeFromToken(iiImpl) == mdtInterfaceImpl); - - pMiniMd = &(m_pStgdb->m_MiniMd); - IfFailGo(pMiniMd->GetInterfaceImplRecord(RidFromToken(iiImpl), &pIIRec)); - - if (pClass) { - *pClass = pMiniMd->getClassOfInterfaceImpl(pIIRec); - } - if (ptkIface) { - *ptkIface = pMiniMd->getInterfaceOfInterfaceImpl(pIIRec); - } - -ErrExit: - return hr; -} - -HRESULT RegMeta::GetTypeRefProps( // S_OK or error. - mdTypeRef tr, // [IN] TypeRef token. - mdToken * - ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or AssemblyRef. - __out_ecount_part_opt(cchName, *pchName) - LPWSTR szTypeRef, // [OUT] Name of the TypeRef. - ULONG cchTypeRef, // [IN] Size of buffer. - ULONG *pchTypeRef) // [OUT] Size of Name. -{ - HRESULT hr = S_OK; - CMiniMdRW *pMiniMd; - TypeRefRec *pTypeRefRec; - BOOL fTruncation = FALSE; // Was there name truncation? - - if (TypeFromToken(tr) != mdtTypeRef) { - hr = S_FALSE; - goto ErrExit; - } - if (tr == mdTypeRefNil) { - // Backward compatibility with CLR 2.0 implementation - if (ptkResolutionScope != NULL) - *ptkResolutionScope = mdTokenNil; - if (pchTypeRef != NULL) - *pchTypeRef = 1; - if ((szTypeRef != NULL) && (cchTypeRef > 0)) - szTypeRef[0] = 0; - - hr = S_OK; - goto ErrExit; - } - - pMiniMd = &(m_pStgdb->m_MiniMd); - IfFailGo(pMiniMd->GetTypeRefRecord(RidFromToken(tr), &pTypeRefRec)); - - if (ptkResolutionScope != NULL) { - *ptkResolutionScope = pMiniMd->getResolutionScopeOfTypeRef(pTypeRefRec); - } - - if ((szTypeRef != NULL) || (pchTypeRef != NULL)) { - LPCSTR szNamespace; - LPCSTR szName; - - IfFailGo(pMiniMd->getNamespaceOfTypeRef(pTypeRefRec, &szNamespace)); - MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzNamespace, szNamespace); - IfNullGo(wzNamespace); - - IfFailGo(pMiniMd->getNameOfTypeRef(pTypeRefRec, &szName)); - MAKE_WIDEPTR_FROMUTF8_NOTHROW(wzName, szName); - IfNullGo(wzName); - - if (szTypeRef != NULL) { - fTruncation = !(ns::MakePath(szTypeRef, cchTypeRef, wzNamespace, wzName)); - } - if (pchTypeRef != NULL) { - if (fTruncation || (szTypeRef == NULL)) { - *pchTypeRef = ns::GetFullLength(wzNamespace, wzName); - } else { - *pchTypeRef = (ULONG)(wcslen(szTypeRef) + 1); - } - } - } - if (fTruncation && (hr == S_OK)) { - if ((szTypeRef != NULL) && (cchTypeRef > 0)) { - // null-terminate the truncated output string - szTypeRef[cchTypeRef - 1] = W('\0'); - } - hr = CLDB_S_TRUNCATION; - } - -ErrExit: - return hr; -} - -HRESULT RegMeta::ResolveTypeRef(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, - mdTypeDef *ptd) { - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - ResolveTypeRef - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumMembers( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumMembers - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumMembersWithName( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumMembersWithName - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumMethods( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdMethodDef rMethods[], // [OUT] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - HRESULT hr = NOERROR; - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart; - ULONG ridEnd; - TypeDefRec *pRec; - HENUMInternal *pEnum = *ppmdEnum; - - if (pEnum == 0) { - // instantiating a new ENUM - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - // Check for mdTypeDefNil (representing ). - // If so, this will map it to its token. - // - if (IsGlobalMethodParentTk(td)) { - td = COR_GLOBAL_PARENT_TOKEN; - } - - IfFailGo(m_pStgdb->m_MiniMd.GetTypeDefRecord(RidFromToken(td), &pRec)); - ridStart = m_pStgdb->m_MiniMd.getMethodListOfTypeDef(pRec); - IfFailGo(m_pStgdb->m_MiniMd.getEndMethodListOfTypeDef(RidFromToken(td), - &ridEnd)); - - if (pMiniMd->HasIndirectTable(TBL_Method) || pMiniMd->HasDelete()) { - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtMethodDef, &pEnum)); - - // add all methods to the dynamic array - for (ULONG index = ridStart; index < ridEnd; index++) { - if (pMiniMd->HasDelete()) { - MethodRec *pMethRec; - RID rid; - IfFailGo(pMiniMd->GetMethodRid(index, &rid)); - IfFailGo(pMiniMd->GetMethodRecord(rid, &pMethRec)); - LPCSTR szMethodName; - IfFailGo(pMiniMd->getNameOfMethod(pMethRec, &szMethodName)); - if (IsMdRTSpecialName(pMethRec->GetFlags()) && - IsDeletedName(szMethodName)) { - continue; - } - } - RID rid; - IfFailGo(pMiniMd->GetMethodRid(index, &rid)); - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(rid, mdtMethodDef))); - } - } else { - IfFailGo(HENUMInternal::CreateSimpleEnum(mdtMethodDef, ridStart, ridEnd, - &pEnum)); - } - - // set the output parameter - *ppmdEnum = pEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rMethods, pcTokens); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - END_ENTRYPOINT_NOTHROW; - - return hr; -} - -HRESULT RegMeta::EnumMethodsWithName( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdMethodDef rMethods[], // [OU] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumMethodsWithName - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumFields( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdFieldDef rFields[], // [OUT] Put FieldDefs here. - ULONG cMax, // [IN] Max FieldDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - HRESULT hr = NOERROR; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart; - ULONG ridEnd; - TypeDefRec *pRec; - HENUMInternal *pEnum = *ppmdEnum; - - if (pEnum == NULL) { - // instantiating a new ENUM - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - // Check for mdTypeDefNil (representing ). - // If so, this will map it to its token. - // - if (IsGlobalMethodParentTk(td)) { - td = COR_GLOBAL_PARENT_TOKEN; - } - - IfFailGo(m_pStgdb->m_MiniMd.GetTypeDefRecord(RidFromToken(td), &pRec)); - ridStart = m_pStgdb->m_MiniMd.getFieldListOfTypeDef(pRec); - IfFailGo( - m_pStgdb->m_MiniMd.getEndFieldListOfTypeDef(RidFromToken(td), &ridEnd)); - - if (pMiniMd->HasIndirectTable(TBL_Field) || pMiniMd->HasDelete()) { - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtFieldDef, &pEnum)); - - // add all methods to the dynamic array - for (ULONG index = ridStart; index < ridEnd; index++) { - if (pMiniMd->HasDelete()) { - FieldRec *pFieldRec; - RID rid; - IfFailGo(pMiniMd->GetFieldRid(index, &rid)); - IfFailGo(pMiniMd->GetFieldRecord(rid, &pFieldRec)); - LPCUTF8 szFieldName; - IfFailGo(pMiniMd->getNameOfField(pFieldRec, &szFieldName)); - if (IsFdRTSpecialName(pFieldRec->GetFlags()) && - IsDeletedName(szFieldName)) { - continue; - } - } - RID rid; - IfFailGo(pMiniMd->GetFieldRid(index, &rid)); - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(rid, mdtFieldDef))); - } - } else { - IfFailGo(HENUMInternal::CreateSimpleEnum(mdtFieldDef, ridStart, ridEnd, - &pEnum)); - } - - // set the output parameter - *ppmdEnum = pEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rFields, pcTokens); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - END_ENTRYPOINT_NOTHROW; - - return hr; -} - -HRESULT RegMeta::EnumFieldsWithName( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdFieldDef rFields[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - HRESULT hr = NOERROR; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart; - ULONG ridEnd; - ULONG index; - TypeDefRec *pRec; - FieldRec *pField; - HENUMInternal *pEnum = *ppmdEnum; - LPUTF8 szNameUtf8; - UTF8STR(szName, szNameUtf8); - LPCUTF8 szNameUtf8Tmp; - - if (pEnum == 0) { - // instantiating a new ENUM - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - // Check for mdTypeDefNil (representing ). - // If so, this will map it to its token. - // - if (IsGlobalMethodParentTk(cl)) { - cl = COR_GLOBAL_PARENT_TOKEN; - } - - // create the enumerator - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtMethodDef, &pEnum)); - - // get the range of field rids given a typedef - IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(cl), &pRec)); - ridStart = m_pStgdb->m_MiniMd.getFieldListOfTypeDef(pRec); - IfFailGo( - m_pStgdb->m_MiniMd.getEndFieldListOfTypeDef(RidFromToken(cl), &ridEnd)); - - for (index = ridStart; index < ridEnd; index++) { - if (szNameUtf8 == NULL) { - RID rid; - IfFailGo(pMiniMd->GetFieldRid(index, &rid)); - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(rid, mdtFieldDef))); - } else { - RID rid; - IfFailGo(pMiniMd->GetFieldRid(index, &rid)); - IfFailGo(pMiniMd->GetFieldRecord(rid, &pField)); - IfFailGo(pMiniMd->getNameOfField(pField, &szNameUtf8Tmp)); - if (strcmp(szNameUtf8Tmp, szNameUtf8) == 0) { - IfFailGo(pMiniMd->GetFieldRid(index, &rid)); - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(rid, mdtFieldDef))); - } - } - } - - // set the output parameter - *ppmdEnum = pEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rFields, pcTokens); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} - -HRESULT RegMeta::EnumParams( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdParamDef rParams[], // [OUT] Put ParamDefs here. - ULONG cMax, // [IN] Max ParamDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - HRESULT hr = NOERROR; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart; - ULONG ridEnd; - MethodRec *pRec; - HENUMInternal *pEnum = *ppmdEnum; - - if (pEnum == 0) { - // instantiating a new ENUM - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - IfFailGo(m_pStgdb->m_MiniMd.GetMethodRecord(RidFromToken(mb), &pRec)); - ridStart = m_pStgdb->m_MiniMd.getParamListOfMethod(pRec); - IfFailGo( - m_pStgdb->m_MiniMd.getEndParamListOfMethod(RidFromToken(mb), &ridEnd)); - - if (pMiniMd->HasIndirectTable(TBL_Param)) { - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtParamDef, &pEnum)); - - // add all methods to the dynamic array - for (ULONG index = ridStart; index < ridEnd; index++) { - RID rid; - IfFailGo(pMiniMd->GetParamRid(index, &rid)); - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(rid, mdtParamDef))); - } - } else { - IfFailGo(HENUMInternal::CreateSimpleEnum(mdtParamDef, ridStart, ridEnd, - &pEnum)); - } - - // set the output parameter - *ppmdEnum = pEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rParams, pcTokens); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} - -HRESULT RegMeta::EnumMemberRefs( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tkParent, // [IN] Parent token to scope the enumeration. - mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here. - ULONG cMax, // [IN] Max MemberRefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumMemberRefs - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumMethodImpls( // S_OK, S_FALSE, or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdToken rMethodBody[], // [OUT] Put Method Body tokens here. - mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here. - ULONG cMax, // [IN] Max tokens to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumMethodImpls - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumPermissionSets( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tk, // [IN] if !NIL, token to scope the enumeration. - DWORD dwActions, // [IN] if !0, return only these actions. - mdPermission rPermission[], // [OUT] Put Permissions here. - ULONG cMax, // [IN] Max Permissions to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumPermissionSets - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::FindMember( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdToken *pmb) // [OUT] matching memberdef -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - FindMember - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::FindMethod( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMethodDef *pmb) // [OUT] matching memberdef -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - FindMethod - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::FindField( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdFieldDef *pmb) // [OUT] matching memberdef -{ - LOG((LF_CORDB, LL_INFO100000, "CordbSymbol - FindField - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::FindMemberRef( - mdTypeRef td, // [IN] given typeRef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMemberRef *pmr) // [OUT] matching memberref -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - FindMemberRef - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetMethodProps( - mdMethodDef mb, // The method for which to get props. - mdTypeDef *pClass, // Put method's class here. - __out_ecount_part_opt(cchMethod, *pchMethod) - LPWSTR szMethod, // Put method's name here. - ULONG cchMethod, // Size of szMethod buffer in wide chars. - ULONG *pchMethod, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - ULONG *pulCodeRVA, // [OUT] codeRVA - DWORD *pdwImplFlags) // [OUT] Impl. Flags -{ - HRESULT hr = NOERROR; - BEGIN_ENTRYPOINT_NOTHROW; - - MethodRec *pMethodRec; - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - _ASSERTE(TypeFromToken(mb) == mdtMethodDef); - - IfFailGo(pMiniMd->GetMethodRecord(RidFromToken(mb), &pMethodRec)); - - if (pClass) { - // caller wants parent typedef - IfFailGo(pMiniMd->FindParentOfMethodHelper(mb, pClass)); - - if (IsGlobalMethodParentToken(*pClass)) { - // If the parent of Method is the , return mdTypeDefNil instead. - *pClass = mdTypeDefNil; - } - } - if (ppvSigBlob || pcbSigBlob) { - // caller wants signature information - PCCOR_SIGNATURE pvSigTmp; - ULONG cbSig; - IfFailGo(pMiniMd->getSignatureOfMethod(pMethodRec, &pvSigTmp, &cbSig)); - if (ppvSigBlob) - *ppvSigBlob = pvSigTmp; - if (pcbSigBlob) - *pcbSigBlob = cbSig; - } - if (pdwAttr) { - *pdwAttr = pMiniMd->getFlagsOfMethod(pMethodRec); - } - if (pulCodeRVA) { - *pulCodeRVA = pMiniMd->getRVAOfMethod(pMethodRec); - } - if (pdwImplFlags) { - *pdwImplFlags = (DWORD)pMiniMd->getImplFlagsOfMethod(pMethodRec); - } - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szMethod || pchMethod) { - IfFailGo( - pMiniMd->getNameOfMethod(pMethodRec, szMethod, cchMethod, pchMethod)); - } - -ErrExit: - - return hr; -} - -HRESULT RegMeta::GetMemberRefProps( // S_OK or error. - mdMemberRef mr, // [IN] given memberref - mdToken *ptk, // [OUT] Put classref or classdef here. - __out_ecount_part_opt(cchMember, *pchMember) - LPWSTR szMember, // [OUT] buffer to fill for member's name - ULONG cchMember, // [IN] the count of char of szMember - ULONG *pchMember, // [OUT] actual count of char in member name - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value - ULONG *pbSig) // [OUT] actual size of signature blob -{ - HRESULT hr = NOERROR; - - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - MemberRefRec *pMemberRefRec; - - _ASSERTE(TypeFromToken(mr) == mdtMemberRef); - - IfFailGo(pMiniMd->GetMemberRefRecord(RidFromToken(mr), &pMemberRefRec)); - - if (ptk) { - *ptk = pMiniMd->getClassOfMemberRef(pMemberRefRec); - if (IsGlobalMethodParentToken(*ptk)) { - // If the parent of MemberRef is the , return mdTypeDefNil - // instead. - *ptk = mdTypeDefNil; - } - } - if (ppvSigBlob || pbSig) { - // caller wants signature information - PCCOR_SIGNATURE pvSigTmp; - ULONG cbSig; - IfFailGo( - pMiniMd->getSignatureOfMemberRef(pMemberRefRec, &pvSigTmp, &cbSig)); - if (ppvSigBlob) - *ppvSigBlob = pvSigTmp; - if (pbSig) - *pbSig = cbSig; - } - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szMember || pchMember) { - IfFailGo(pMiniMd->getNameOfMemberRef(pMemberRefRec, szMember, cchMember, - pchMember)); - } - -ErrExit: - - return hr; -} - -HRESULT RegMeta::EnumProperties( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdProperty rProperties[], // [OUT] Put Properties here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcProperties) // [OUT] Put # put here. -{ - HRESULT hr = NOERROR; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart = 0; - ULONG ridEnd = 0; - ULONG ridMax = 0; - HENUMInternal *pEnum = *ppmdEnum; - - if (IsNilToken(td)) { - if (pcProperties) - *pcProperties = 0; - hr = S_FALSE; - goto ErrExit; - } - - _ASSERTE(TypeFromToken(td) == mdtTypeDef); - - if (pEnum == 0) { - // instantiating a new ENUM - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - RID ridPropertyMap; - PropertyMapRec *pPropertyMapRec; - - // get the starting/ending rid of properties of this typedef - IfFailGo(pMiniMd->FindPropertyMapFor(RidFromToken(td), &ridPropertyMap)); - if (!InvalidRid(ridPropertyMap)) { - IfFailGo(m_pStgdb->m_MiniMd.GetPropertyMapRecord(ridPropertyMap, - &pPropertyMapRec)); - ridStart = pMiniMd->getPropertyListOfPropertyMap(pPropertyMapRec); - IfFailGo( - pMiniMd->getEndPropertyListOfPropertyMap(ridPropertyMap, &ridEnd)); - ridMax = pMiniMd->getCountPropertys() + 1; - if (ridStart == 0) - ridStart = 1; - if (ridEnd > ridMax) - ridEnd = ridMax; - if (ridStart > ridEnd) - ridStart = ridEnd; - } - - if (pMiniMd->HasIndirectTable(TBL_Property) || pMiniMd->HasDelete()) { - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtProperty, &pEnum)); - - // add all methods to the dynamic array - for (ULONG index = ridStart; index < ridEnd; index++) { - if (pMiniMd->HasDelete()) { - PropertyRec *pRec; - RID rid; - IfFailGo(pMiniMd->GetPropertyRid(index, &rid)); - IfFailGo(pMiniMd->GetPropertyRecord(rid, &pRec)); - LPCUTF8 szPropertyName; - IfFailGo(pMiniMd->getNameOfProperty(pRec, &szPropertyName)); - if (IsPrRTSpecialName(pRec->GetPropFlags()) && - IsDeletedName(szPropertyName)) { - continue; - } - } - RID rid; - IfFailGo(pMiniMd->GetPropertyRid(index, &rid)); - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(rid, mdtProperty))); - } - } else { - IfFailGo(HENUMInternal::CreateSimpleEnum(mdtProperty, ridStart, ridEnd, - &pEnum)); - } - - // set the output parameter - *ppmdEnum = pEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rProperties, pcProperties); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} - -HRESULT RegMeta::EnumEvents( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdEvent rEvents[], // [OUT] Put events here. - ULONG cMax, // [IN] Max events to put. - ULONG *pcEvents) // [OUT] Put # put here. -{ - HRESULT hr = NOERROR; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart = 0; - ULONG ridEnd = 0; - ULONG ridMax = 0; - HENUMInternal *pEnum = *ppmdEnum; - - _ASSERTE(TypeFromToken(td) == mdtTypeDef); - - if (pEnum == 0) { - // instantiating a new ENUM - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - RID ridEventMap; - EventMapRec *pEventMapRec; - - // get the starting/ending rid of properties of this typedef - IfFailGo(pMiniMd->FindEventMapFor(RidFromToken(td), &ridEventMap)); - if (!InvalidRid(ridEventMap)) { - IfFailGo(pMiniMd->GetEventMapRecord(ridEventMap, &pEventMapRec)); - ridStart = pMiniMd->getEventListOfEventMap(pEventMapRec); - IfFailGo(pMiniMd->getEndEventListOfEventMap(ridEventMap, &ridEnd)); - ridMax = pMiniMd->getCountEvents() + 1; - if (ridStart == 0) - ridStart = 1; - if (ridEnd > ridMax) - ridEnd = ridMax; - if (ridStart > ridEnd) - ridStart = ridEnd; - } - - if (pMiniMd->HasIndirectTable(TBL_Event) || pMiniMd->HasDelete()) { - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtEvent, &pEnum)); - - // add all methods to the dynamic array - for (ULONG index = ridStart; index < ridEnd; index++) { - if (pMiniMd->HasDelete()) { - EventRec *pRec; - RID rid; - IfFailGo(pMiniMd->GetEventRid(index, &rid)); - IfFailGo(pMiniMd->GetEventRecord(rid, &pRec)); - LPCSTR szEventName; - IfFailGo(pMiniMd->getNameOfEvent(pRec, &szEventName)); - if (IsEvRTSpecialName(pRec->GetEventFlags()) && - IsDeletedName(szEventName)) { - continue; - } - } - RID rid; - IfFailGo(pMiniMd->GetEventRid(index, &rid)); - IfFailGo(HENUMInternal::AddElementToEnum(pEnum, - TokenFromRid(rid, mdtEvent))); - } - } else { - IfFailGo( - HENUMInternal::CreateSimpleEnum(mdtEvent, ridStart, ridEnd, &pEnum)); - } - - // set the output parameter - *ppmdEnum = pEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rEvents, pcEvents); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} - -HRESULT RegMeta::GetEventProps( // S_OK, S_FALSE, or error. - mdEvent ev, // [IN] event token - mdTypeDef *pClass, // [OUT] typedef containing the event declarion. - LPCWSTR szEvent, // [OUT] Event name - ULONG cchEvent, // [IN] the count of wchar of szEvent - ULONG *pchEvent, // [OUT] actual count of wchar for event's name - DWORD *pdwEventFlags, // [OUT] Event flags. - mdToken *ptkEventType, // [OUT] EventType class - mdMethodDef *pmdAddOn, // [OUT] AddOn method of the event - mdMethodDef *pmdRemoveOn, // [OUT] RemoveOn method of the event - mdMethodDef *pmdFire, // [OUT] Fire method of the event - mdMethodDef rmdOtherMethod[], // [OUT] other method of the event - ULONG cMax, // [IN] size of rmdOtherMethod - ULONG *pcOtherMethod) // [OUT] total number of other method of this event -{ - HRESULT hr = NOERROR; - - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - EventRec *pRec; - HENUMInternal hEnum; - - _ASSERTE(TypeFromToken(ev) == mdtEvent); - - HENUMInternal::ZeroEnum(&hEnum); - IfFailGo(pMiniMd->GetEventRecord(RidFromToken(ev), &pRec)); - - if (pClass) { - // find the event map entry corresponding to this event - IfFailGo(pMiniMd->FindParentOfEventHelper(ev, pClass)); - } - if (pdwEventFlags) { - *pdwEventFlags = pMiniMd->getEventFlagsOfEvent(pRec); - } - if (ptkEventType) { - *ptkEventType = pMiniMd->getEventTypeOfEvent(pRec); - } - { - MethodSemanticsRec *pSemantics; - RID ridCur; - ULONG cCurOtherMethod = 0; - ULONG ulSemantics; - mdMethodDef tkMethod; - - // initialize output parameters - if (pmdAddOn) - *pmdAddOn = mdMethodDefNil; - if (pmdRemoveOn) - *pmdRemoveOn = mdMethodDefNil; - if (pmdFire) - *pmdFire = mdMethodDefNil; - - IfFailGo(pMiniMd->FindMethodSemanticsHelper(ev, &hEnum)); - while (HENUMInternal::EnumNext(&hEnum, (mdToken *)&ridCur)) { - IfFailGo(pMiniMd->GetMethodSemanticsRecord(ridCur, &pSemantics)); - ulSemantics = pMiniMd->getSemanticOfMethodSemantics(pSemantics); - tkMethod = TokenFromRid(pMiniMd->getMethodOfMethodSemantics(pSemantics), - mdtMethodDef); - switch (ulSemantics) { - case msAddOn: - if (pmdAddOn) - *pmdAddOn = tkMethod; - break; - case msRemoveOn: - if (pmdRemoveOn) - *pmdRemoveOn = tkMethod; - break; - case msFire: - if (pmdFire) - *pmdFire = tkMethod; - break; - case msOther: - if (cCurOtherMethod < cMax) - rmdOtherMethod[cCurOtherMethod] = tkMethod; - cCurOtherMethod++; - break; - default: - _ASSERTE(!"BadKind!"); - } - } - - // set the output parameter - if (pcOtherMethod) - *pcOtherMethod = cCurOtherMethod; - } - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szEvent || pchEvent) { - IfFailGo( - pMiniMd->getNameOfEvent(pRec, (LPWSTR)szEvent, cchEvent, pchEvent)); - } - -ErrExit: - HENUMInternal::ClearEnum(&hEnum); - - return hr; -} - -HRESULT RegMeta::EnumMethodSemantics( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdToken rEventProp[], // [OUT] Put Event/Property here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcEventProp) // [OUT] Put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumMethodSemantics - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetMethodSemantics( // S_OK, S_FALSE, or error. - mdMethodDef mb, // [IN] method token - mdToken tkEventProp, // [IN] event/property token. - DWORD * - pdwSemanticsFlags) // [OUT] the role flags for the method/propevent pair -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetMethodSemantics - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetClassLayout( - mdTypeDef td, // [IN] give typedef - DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16 - COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array - ULONG cMax, // [IN] size of the array - ULONG *pcFieldOffset, // [OUT] needed array size - ULONG *pulClassSize) // [OUT] the size of the class -{ - HRESULT hr = NOERROR; - - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - ClassLayoutRec *pRec; - RID ridClassLayout; - int bLayout = 0; // Was any layout information found? - - _ASSERTE(TypeFromToken(td) == mdtTypeDef); - - IfFailGo(pMiniMd->FindClassLayoutHelper(td, &ridClassLayout)); - - if (InvalidRid(ridClassLayout)) { - // Nothing specified - return default values of 0. - if (pdwPackSize) - *pdwPackSize = 0; - if (pulClassSize) - *pulClassSize = 0; - } else { - IfFailGo( - pMiniMd->GetClassLayoutRecord(RidFromToken(ridClassLayout), &pRec)); - if (pdwPackSize) - *pdwPackSize = pMiniMd->getPackingSizeOfClassLayout(pRec); - if (pulClassSize) - *pulClassSize = pMiniMd->getClassSizeOfClassLayout(pRec); - bLayout = 1; - } - - // fill the layout array - if (rFieldOffset || pcFieldOffset) { - ULONG iFieldOffset = 0; - ULONG ridFieldStart; - ULONG ridFieldEnd; - ULONG ridFieldLayout; - ULONG ulOffset; - TypeDefRec *pTypeDefRec; - FieldLayoutRec *pLayout2Rec; - mdFieldDef fd; - - // record for this typedef in TypeDef Table - IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(td), &pTypeDefRec)); - - // find the starting and end field for this typedef - ridFieldStart = pMiniMd->getFieldListOfTypeDef(pTypeDefRec); - IfFailGo(pMiniMd->getEndFieldListOfTypeDef(RidFromToken(td), &ridFieldEnd)); - - // loop through the field table - - for (; ridFieldStart < ridFieldEnd; ridFieldStart++) { - // Calculate the field token. - RID rid; - IfFailGo(pMiniMd->GetFieldRid(ridFieldStart, &rid)); - fd = TokenFromRid(rid, mdtFieldDef); - - // Calculate the FieldLayout rid for the current field. - IfFailGo(pMiniMd->FindFieldLayoutHelper(fd, &ridFieldLayout)); - - // Calculate the offset. - if (InvalidRid(ridFieldLayout)) - ulOffset = (ULONG)-1; - else { - // get the FieldLayout record. - IfFailGo(pMiniMd->GetFieldLayoutRecord(ridFieldLayout, &pLayout2Rec)); - ulOffset = pMiniMd->getOffSetOfFieldLayout(pLayout2Rec); - bLayout = 1; - } - - // fill in the field layout if output buffer still has space. - if (cMax > iFieldOffset && rFieldOffset) { - rFieldOffset[iFieldOffset].ridOfField = fd; - rFieldOffset[iFieldOffset].ulOffset = ulOffset; - } - - // advance the index to the buffer. - iFieldOffset++; - } - - if (bLayout && pcFieldOffset) - *pcFieldOffset = iFieldOffset; - } - - if (!bLayout) - hr = CLDB_E_RECORD_NOTFOUND; - -ErrExit: - - return hr; -} - -HRESULT RegMeta::GetFieldMarshal( - mdToken tk, // [IN] given a field's memberdef - PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field - ULONG *pcbNativeType) // [OUT] the count of bytes of *ppvNativeType -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetFieldMarshal - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetRVA( // S_OK or error. - mdToken tk, // Member for which to set offset - ULONG *pulCodeRVA, // The offset - DWORD *pdwImplFlags) // the implementation flags -{ - LOG((LF_CORDB, LL_INFO100000, "CordbSymbol - GetRVA - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetPermissionSetProps( - mdPermission pm, // [IN] the permission token. - DWORD *pdwAction, // [OUT] CorDeclSecurity. - void const **ppvPermission, // [OUT] permission blob. - ULONG *pcbPermission) // [OUT] count of bytes of pvPermission. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetPermissionSetProps - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetSigFromToken( // S_OK or error. - mdSignature mdSig, // [IN] Signature token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. - ULONG *pcbSig) // [OUT] return size of signature. -{ - HRESULT hr = NOERROR; - - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - StandAloneSigRec *pRec; - - _ASSERTE(TypeFromToken(mdSig) == mdtSignature); - _ASSERTE(ppvSig && pcbSig); - - IfFailGo(pMiniMd->GetStandAloneSigRecord(RidFromToken(mdSig), &pRec)); - IfFailGo(pMiniMd->getSignatureOfStandAloneSig(pRec, ppvSig, pcbSig)); - -ErrExit: - - return hr; -} - -HRESULT RegMeta::GetModuleRefProps( // S_OK or error. - mdModuleRef mur, // [IN] moduleref token. - __out_ecount_part_opt(cchName, *pchName) - LPWSTR szName, // [OUT] buffer to fill with the moduleref name. - ULONG cchName, // [IN] size of szName in wide characters. - ULONG *pchName) // [OUT] actual count of characters in the name. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetModuleRefProps - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumModuleRefs( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. - ULONG cmax, // [IN] max memberrefs to put. - ULONG *pcModuleRefs) // [OUT] put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumModuleRefs - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetTypeSpecFromToken( // S_OK or error. - mdTypeSpec typespec, // [IN] TypeSpec token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature - ULONG *pcbSig) // [OUT] return size of signature. -{ - HRESULT hr = NOERROR; - - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - TypeSpecRec *pRec = NULL; - - _ASSERTE(TypeFromToken(typespec) == mdtTypeSpec); - _ASSERTE(ppvSig && pcbSig); - - IfFailGo(pMiniMd->GetTypeSpecRecord(RidFromToken(typespec), &pRec)); - IfFailGo(pMiniMd->getSignatureOfTypeSpec(pRec, ppvSig, pcbSig)); - -ErrExit: - - return hr; -} - -HRESULT RegMeta::GetNameFromToken( // Not Recommended! May be removed! - mdToken tk, // [IN] Token to get name from. Must have a name. - MDUTF8CSTR *pszUtf8NamePtr) // [OUT] Return pointer to UTF8 name in heap. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetNameFromToken - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumUnresolvedMethods( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken rMethods[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens) // [OUT] Put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumUnresolvedMethods - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetUserString( // S_OK or error. - mdString stk, // [IN] String token. - __out_ecount_opt(cchStringSize) LPWSTR wszString, // [OUT] Copy of string. - ULONG cchStringSize, // [IN] Max chars of room in szString. - ULONG *pcchStringSize) // [OUT] How many chars in actual string. -{ - HRESULT hr = S_OK; - ULONG cchStringSize_Dummy; - MetaData::DataBlob userString; - - // Get the string data. - IfFailGo(m_pStgdb->m_MiniMd.GetUserString(RidFromToken(stk), &userString)); - // Want to get whole characters, followed by byte to indicate whether there - // are extended characters (>= 0x80). - if ((userString.GetSize() % sizeof(WCHAR)) == 0) { - Debug_ReportError( - "User strings should have 1 byte terminator (either 0x00 or 0x80)."); - IfFailGo(CLDB_E_FILE_CORRUPT); - } - - // Strip off the last byte. - if (!userString.TruncateBySize(1)) { - Debug_ReportInternalError( - "There's a bug, because previous % 2 check didn't return 0."); - IfFailGo(METADATA_E_INTERNAL_ERROR); - } - - // Convert bytes to characters. - if (pcchStringSize == NULL) { - pcchStringSize = &cchStringSize_Dummy; - } - *pcchStringSize = userString.GetSize() / sizeof(WCHAR); - - // Copy the string back to the caller. - if ((wszString != NULL) && (cchStringSize > 0)) { - ULONG cbStringSize = cchStringSize * sizeof(WCHAR); - memcpy(wszString, userString.GetDataPointer(), - min(userString.GetSize(), cbStringSize)); - if (cbStringSize < userString.GetSize()) { - if ((wszString != NULL) && (cchStringSize > 0)) { - // null-terminate the truncated output string - wszString[cchStringSize - 1] = W('\0'); - } - - hr = CLDB_S_TRUNCATION; - } - } - -ErrExit: - return hr; -} - -HRESULT RegMeta::GetPinvokeMap( // S_OK or error. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. - __out_ecount_part_opt(cchImportName, *pchImportName) - LPWSTR szImportName, // [OUT] Import name. - ULONG cchImportName, // [IN] Size of the name buffer. - ULONG *pchImportName, // [OUT] Actual number of characters stored. - mdModuleRef *pmrImportDLL) // [OUT] ModuleRef token for the target DLL. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetPinvokeMap - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumSignatures( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdSignature rSignatures[], // [OUT] put signatures here. - ULONG cmax, // [IN] max signatures to put. - ULONG *pcSignatures) // [OUT] put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumSignatures - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumTypeSpecs( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. - ULONG cmax, // [IN] max TypeSpecs to put. - ULONG *pcTypeSpecs) // [OUT] put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumTypeSpecs - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumUserStrings( // S_OK or error. - HCORENUM *phEnum, // [IN/OUT] pointer to the enum. - mdString rStrings[], // [OUT] put Strings here. - ULONG cmax, // [IN] max Strings to put. - ULONG *pcStrings) // [OUT] put # put here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - EnumUserStrings - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetParamForMethodIndex( // S_OK or error. - mdMethodDef md, // [IN] Method token. - ULONG ulParamSeq, // [IN] Parameter sequence. - mdParamDef *ppd) // [IN] Put Param token here. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetParamForMethodIndex - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::EnumCustomAttributes( // S_OK or error. - HCORENUM *phEnum, // [IN, OUT] COR enumerator. - mdToken tk, // [IN] Token to scope the enumeration, 0 for all. - mdToken tkType, // [IN] Type of interest, 0 for all. - mdCustomAttribute - rCustomAttributes[], // [OUT] Put custom attribute tokens here. - ULONG cMax, // [IN] Size of rCustomAttributes. - ULONG - *pcCustomAttributes) // [OUT, OPTIONAL] Put count of token values here. -{ - HRESULT hr = S_OK; - - HENUMInternal **ppmdEnum = reinterpret_cast(phEnum); - ULONG ridStart; - ULONG ridEnd; - HENUMInternal *pEnum = *ppmdEnum; - CustomAttributeRec *pRec; - ULONG index; - - if (pEnum == 0) { - // instantiating a new ENUM - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - CLookUpHash *pHashTable = pMiniMd->m_pLookUpHashs[TBL_CustomAttribute]; - - // Does caller want all custom Values? - if (IsNilToken(tk)) { - IfFailGo(HENUMInternal::CreateSimpleEnum( - mdtCustomAttribute, 1, pMiniMd->getCountCustomAttributes() + 1, - &pEnum)); - } else { - // Scope by some object. - if (pMiniMd->IsSorted(TBL_CustomAttribute)) { - // Get CustomAttributes for the object. - IfFailGo(pMiniMd->getCustomAttributeForToken(tk, &ridEnd, &ridStart)); - - if (IsNilToken(tkType)) { - // Simple enumerator for object's entire list. - IfFailGo(HENUMInternal::CreateSimpleEnum(mdtCustomAttribute, ridStart, - ridEnd, &pEnum)); - } else { - // Dynamic enumerator for subsetted list. - - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtCustomAttribute, - &pEnum)); - - for (index = ridStart; index < ridEnd; index++) { - IfFailGo(pMiniMd->GetCustomAttributeRecord(index, &pRec)); - if (tkType == pMiniMd->getTypeOfCustomAttribute(pRec)) { - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(index, mdtCustomAttribute))); - } - } - } - } else { - - if (pHashTable) { - // table is not sorted but hash is built - // We want to create dynmaic array to hold the dynamic enumerator. - TOKENHASHENTRY *p; - ULONG iHash; - int pos; - mdToken tkParentTmp; - mdToken tkTypeTmp; - - // Hash the data. - iHash = pMiniMd->HashCustomAttribute(tk); - - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtCustomAttribute, - &pEnum)); - - // Go through every entry in the hash chain looking for ours. - for (p = pHashTable->FindFirst(iHash, pos); p; - p = pHashTable->FindNext(pos)) { - - CustomAttributeRec *pCustomAttribute; - IfFailGo(pMiniMd->GetCustomAttributeRecord(RidFromToken(p->tok), - &pCustomAttribute)); - tkParentTmp = pMiniMd->getParentOfCustomAttribute(pCustomAttribute); - tkTypeTmp = pMiniMd->getTypeOfCustomAttribute(pCustomAttribute); - if (tkParentTmp == tk) { - if (IsNilToken(tkType) || tkType == tkTypeTmp) { - // compare the blob value - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(p->tok, mdtCustomAttribute))); - } - } - } - } else { - - // table is not sorted and hash is not built so we have to create - // dynmaic array create the dynamic enumerator and loop through CA - // table linearly - // - ridStart = 1; - ridEnd = pMiniMd->getCountCustomAttributes() + 1; - - IfFailGo(HENUMInternal::CreateDynamicArrayEnum(mdtCustomAttribute, - &pEnum)); - - for (index = ridStart; index < ridEnd; index++) { - IfFailGo(pMiniMd->GetCustomAttributeRecord(index, &pRec)); - if (tk == pMiniMd->getParentOfCustomAttribute(pRec) && - (tkType == pMiniMd->getTypeOfCustomAttribute(pRec) || - IsNilToken(tkType))) { - IfFailGo(HENUMInternal::AddElementToEnum( - pEnum, TokenFromRid(index, mdtCustomAttribute))); - } - } - } - } - } - - // set the output parameter - *ppmdEnum = pEnum; - } - - // fill the output token buffer - hr = HENUMInternal::EnumWithCount(pEnum, cMax, rCustomAttributes, - pcCustomAttributes); - -ErrExit: - HENUMInternal::DestroyEnumIfEmpty(ppmdEnum); - - return hr; -} - -HRESULT RegMeta::GetCustomAttributeProps( // S_OK or error. - mdCustomAttribute cv, // [IN] CustomAttribute token. - mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. - mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. - void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. - ULONG *pcbSize) // [OUT, OPTIONAL] Put size of date here. -{ - HRESULT hr = S_OK; // A result. - - CMiniMdRW *pMiniMd; - - _ASSERTE(TypeFromToken(cv) == mdtCustomAttribute); - - pMiniMd = &(m_pStgdb->m_MiniMd); - CustomAttributeRec *pCustomAttributeRec; // The custom value record. - - IfFailGo(pMiniMd->GetCustomAttributeRecord(RidFromToken(cv), - &pCustomAttributeRec)); - - if (ptkObj) - *ptkObj = pMiniMd->getParentOfCustomAttribute(pCustomAttributeRec); - - if (ptkType) - *ptkType = pMiniMd->getTypeOfCustomAttribute(pCustomAttributeRec); - - if (ppBlob != NULL) { - IfFailGo(pMiniMd->getValueOfCustomAttribute( - pCustomAttributeRec, (const BYTE **)ppBlob, pcbSize)); - } - -ErrExit: - - return hr; -} - -HRESULT RegMeta::FindTypeRef( - mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. - LPCWSTR szName, // [IN] TypeRef Name. - mdTypeRef *ptr) // [OUT] matching TypeRef. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - FindTypeRef - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetMemberProps( - mdToken mb, // The member for which to get props. - mdTypeDef *pClass, // Put member's class here. - __out_ecount_part_opt(cchMember, *pchMember) - LPWSTR szMember, // Put member's name here. - ULONG cchMember, // Size of szMember buffer in wide chars. - ULONG *pchMember, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - ULONG *pulCodeRVA, // [OUT] codeRVA - DWORD *pdwImplFlags, // [OUT] Impl. Flags - DWORD - *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppValue, // [OUT] constant value - ULONG * - pcchValue) // [OUT] size of constant string in chars, 0 for non-strings. -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetMemberProps - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::GetFieldProps( - mdFieldDef fd, // The field for which to get props. - mdTypeDef *pClass, // Put field's class here. - __out_ecount_part_opt(cchField, *pchField) - LPWSTR szField, // Put field's name here. - ULONG cchField, // Size of szField buffer in wide chars. - ULONG *pchField, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - DWORD - *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppValue, // [OUT] constant value - ULONG - *pchValue) // [OUT] size of constant string in chars, 0 for non-strings. -{ - HRESULT hr = NOERROR; - - BEGIN_ENTRYPOINT_NOTHROW; - - FieldRec *pFieldRec; - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - _ASSERTE(TypeFromToken(fd) == mdtFieldDef); - - IfFailGo(pMiniMd->GetFieldRecord(RidFromToken(fd), &pFieldRec)); - - if (pClass) { - // caller wants parent typedef - IfFailGo(pMiniMd->FindParentOfFieldHelper(fd, pClass)); - - if (IsGlobalMethodParentToken(*pClass)) { - // If the parent of Field is the , return mdTypeDefNil instead. - *pClass = mdTypeDefNil; - } - } - if (ppvSigBlob || pcbSigBlob) { - // caller wants signature information - PCCOR_SIGNATURE pvSigTmp; - ULONG cbSig; - IfFailGo(pMiniMd->getSignatureOfField(pFieldRec, &pvSigTmp, &cbSig)); - if (ppvSigBlob) - *ppvSigBlob = pvSigTmp; - if (pcbSigBlob) - *pcbSigBlob = cbSig; - } - if (pdwAttr) { - *pdwAttr = pMiniMd->getFlagsOfField(pFieldRec); - } - if (pdwCPlusTypeFlag || ppValue || pchValue) { - // get the constant value - ULONG cbValue; - RID rid; - IfFailGo(pMiniMd->FindConstantHelper(fd, &rid)); - - if (pchValue) - *pchValue = 0; - - if (InvalidRid(rid)) { - // There is no constant value associate with it - if (pdwCPlusTypeFlag) - *pdwCPlusTypeFlag = ELEMENT_TYPE_VOID; - - if (ppValue) - *ppValue = NULL; - } else { - ConstantRec *pConstantRec; - IfFailGo(m_pStgdb->m_MiniMd.GetConstantRecord(rid, &pConstantRec)); - DWORD dwType; - - // get the type of constant value - dwType = pMiniMd->getTypeOfConstant(pConstantRec); - if (pdwCPlusTypeFlag) - *pdwCPlusTypeFlag = dwType; - - // get the value blob - if (ppValue != NULL) { - IfFailGo(pMiniMd->getValueOfConstant(pConstantRec, - (const BYTE **)ppValue, &cbValue)); - if (pchValue && dwType == ELEMENT_TYPE_STRING) - *pchValue = cbValue / sizeof(WCHAR); - } - } - } - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szField || pchField) { - IfFailGo(pMiniMd->getNameOfField(pFieldRec, szField, cchField, pchField)); - } - -ErrExit: - - return hr; -} - -HRESULT RegMeta::GetPropertyProps( // S_OK, S_FALSE, or error. - mdProperty prop, // [IN] property token - mdTypeDef *pClass, // [OUT] typedef containing the property declarion. - LPCWSTR szProperty, // [OUT] Property name - ULONG cchProperty, // [IN] the count of wchar of szProperty - ULONG *pchProperty, // [OUT] actual count of wchar for property name - DWORD *pdwPropFlags, // [OUT] property flags. - PCCOR_SIGNATURE - *ppvSig, // [OUT] property type. pointing to meta data internal blob - ULONG *pbSig, // [OUT] count of bytes in *ppvSig - DWORD - *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_* - UVCP_CONSTANT *ppDefaultValue, // [OUT] constant value - ULONG *pchDefaultValue, // [OUT] size of constant string in chars, 0 for - // non-strings. - mdMethodDef *pmdSetter, // [OUT] setter method of the property - mdMethodDef *pmdGetter, // [OUT] getter method of the property - mdMethodDef rmdOtherMethod[], // [OUT] other method of the property - ULONG cMax, // [IN] size of rmdOtherMethod - ULONG *pcOtherMethod) // [OUT] total number of other method of this property -{ - HRESULT hr = NOERROR; - - CMiniMdRW *pMiniMd; - PropertyRec *pRec; - HENUMInternal hEnum; - - _ASSERTE(TypeFromToken(prop) == mdtProperty); - - pMiniMd = &(m_pStgdb->m_MiniMd); - - HENUMInternal::ZeroEnum(&hEnum); - IfFailGo(pMiniMd->GetPropertyRecord(RidFromToken(prop), &pRec)); - - if (pClass) { - // find the property map entry corresponding to this property - IfFailGo(pMiniMd->FindParentOfPropertyHelper(prop, pClass)); - } - if (pdwPropFlags) { - *pdwPropFlags = pMiniMd->getPropFlagsOfProperty(pRec); - } - if (ppvSig || pbSig) { - // caller wants the signature - // - ULONG cbSig; - PCCOR_SIGNATURE pvSig; - IfFailGo(pMiniMd->getTypeOfProperty(pRec, &pvSig, &cbSig)); - if (ppvSig) { - *ppvSig = pvSig; - } - if (pbSig) { - *pbSig = cbSig; - } - } - if (pdwCPlusTypeFlag || ppDefaultValue || pchDefaultValue) { - // get the constant value - ULONG cbValue; - RID rid; - IfFailGo(pMiniMd->FindConstantHelper(prop, &rid)); - - if (pchDefaultValue) - *pchDefaultValue = 0; - - if (InvalidRid(rid)) { - // There is no constant value associate with it - if (pdwCPlusTypeFlag) - *pdwCPlusTypeFlag = ELEMENT_TYPE_VOID; - - if (ppDefaultValue) - *ppDefaultValue = NULL; - } else { - ConstantRec *pConstantRec; - IfFailGo(m_pStgdb->m_MiniMd.GetConstantRecord(rid, &pConstantRec)); - DWORD dwType; - - // get the type of constant value - dwType = pMiniMd->getTypeOfConstant(pConstantRec); - if (pdwCPlusTypeFlag) - *pdwCPlusTypeFlag = dwType; - - // get the value blob - if (ppDefaultValue != NULL) { - IfFailGo(pMiniMd->getValueOfConstant( - pConstantRec, (const BYTE **)ppDefaultValue, &cbValue)); - if (pchDefaultValue && dwType == ELEMENT_TYPE_STRING) - *pchDefaultValue = cbValue / sizeof(WCHAR); - } - } - } - { - MethodSemanticsRec *pSemantics; - RID ridCur; - ULONG cCurOtherMethod = 0; - ULONG ulSemantics; - mdMethodDef tkMethod; - - // initialize output parameters - if (pmdSetter) - *pmdSetter = mdMethodDefNil; - if (pmdGetter) - *pmdGetter = mdMethodDefNil; - - IfFailGo(pMiniMd->FindMethodSemanticsHelper(prop, &hEnum)); - while (HENUMInternal::EnumNext(&hEnum, (mdToken *)&ridCur)) { - IfFailGo(pMiniMd->GetMethodSemanticsRecord(ridCur, &pSemantics)); - ulSemantics = pMiniMd->getSemanticOfMethodSemantics(pSemantics); - tkMethod = TokenFromRid(pMiniMd->getMethodOfMethodSemantics(pSemantics), - mdtMethodDef); - switch (ulSemantics) { - case msSetter: - if (pmdSetter) - *pmdSetter = tkMethod; - break; - case msGetter: - if (pmdGetter) - *pmdGetter = tkMethod; - break; - case msOther: - if (cCurOtherMethod < cMax) - rmdOtherMethod[cCurOtherMethod] = tkMethod; - cCurOtherMethod++; - break; - default: - _ASSERTE(!"BadKind!"); - } - } - - // set the output parameter - if (pcOtherMethod) - *pcOtherMethod = cCurOtherMethod; - } - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szProperty || pchProperty) { - IfFailGo(pMiniMd->getNameOfProperty(pRec, (LPWSTR)szProperty, cchProperty, - pchProperty)); - } - -ErrExit: - HENUMInternal::ClearEnum(&hEnum); - return hr; -} - -HRESULT RegMeta::GetParamProps( // S_OK or error. - mdParamDef pd, // [IN]The Parameter. - mdMethodDef *pmd, // [OUT] Parent Method token. - ULONG *pulSequence, // [OUT] Parameter sequence. - __out_ecount_part_opt(cchName, *pchName) - LPWSTR szName, // [OUT] Put name here. - ULONG cchName, // [OUT] Size of name buffer. - ULONG *pchName, // [OUT] Put actual size of name here. - DWORD *pdwAttr, // [OUT] Put flags here. - DWORD * - pdwCPlusTypeFlag, // [OUT] Flag for value type. selected ELEMENT_TYPE_*. - UVCP_CONSTANT *ppValue, // [OUT] Constant value. - ULONG - *pchValue) // [OUT] size of constant string in chars, 0 for non-strings. -{ - HRESULT hr = NOERROR; - - ParamRec *pParamRec; - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - _ASSERTE(TypeFromToken(pd) == mdtParamDef); - - IfFailGo(pMiniMd->GetParamRecord(RidFromToken(pd), &pParamRec)); - - if (pmd) { - IfFailGo(pMiniMd->FindParentOfParamHelper(pd, pmd)); - _ASSERTE(TypeFromToken(*pmd) == mdtMethodDef); - } - if (pulSequence) - *pulSequence = pMiniMd->getSequenceOfParam(pParamRec); - if (pdwAttr) { - *pdwAttr = pMiniMd->getFlagsOfParam(pParamRec); - } - if (pdwCPlusTypeFlag || ppValue || pchValue) { - // get the constant value - ULONG cbValue; - RID rid; - IfFailGo(pMiniMd->FindConstantHelper(pd, &rid)); - - if (pchValue) - *pchValue = 0; - - if (InvalidRid(rid)) { - // There is no constant value associate with it - if (pdwCPlusTypeFlag) - *pdwCPlusTypeFlag = ELEMENT_TYPE_VOID; - - if (ppValue) - *ppValue = NULL; - } else { - ConstantRec *pConstantRec; - IfFailGo(m_pStgdb->m_MiniMd.GetConstantRecord(rid, &pConstantRec)); - DWORD dwType; - - // get the type of constant value - dwType = pMiniMd->getTypeOfConstant(pConstantRec); - if (pdwCPlusTypeFlag) - *pdwCPlusTypeFlag = dwType; - - // get the value blob - if (ppValue != NULL) { - IfFailGo(pMiniMd->getValueOfConstant(pConstantRec, - (const BYTE **)ppValue, &cbValue)); - if (pchValue && dwType == ELEMENT_TYPE_STRING) - *pchValue = cbValue / sizeof(WCHAR); - } - } - } - // This call has to be last to set 'hr', so CLDB_S_TRUNCATION is not rewritten - // with S_OK - if (szName || pchName) - IfFailGo(pMiniMd->getNameOfParam(pParamRec, szName, cchName, pchName)); - -ErrExit: - - return hr; -} - -HRESULT RegMeta::GetAssemblyFromScope(mdAssembly *ptkAssembly) { - HRESULT hr = NOERROR; - CMiniMdRW *pMiniMd = NULL; - - _ASSERTE(ptkAssembly); - - pMiniMd = &(m_pStgdb->m_MiniMd); - if (pMiniMd->getCountAssemblys()) { - *ptkAssembly = TokenFromRid(1, mdtAssembly); - } else { - IfFailGo(CLDB_E_RECORD_NOTFOUND); - } -ErrExit: - END_ENTRYPOINT_NOTHROW; - return hr; -} - -HRESULT RegMeta::GetCustomAttributeByName( // S_OK or error. - mdToken tkObj, // [IN] Object with Custom Attribute. - LPCWSTR wzName, // [IN] Name of desired Custom Attribute. - const void **ppData, // [OUT] Put pointer to data here. - ULONG *pcbData) // [OUT] Put size of data here. -{ - HRESULT hr; // A result. - - LPUTF8 szName; // Name in UFT8. - int iLen; // A length. - CMiniMdRW *pMiniMd = NULL; - - pMiniMd = &(m_pStgdb->m_MiniMd); - - iLen = WszWideCharToMultiByte(CP_UTF8, 0, wzName, -1, NULL, 0, 0, 0); - szName = (LPUTF8)_alloca(iLen); - VERIFY(WszWideCharToMultiByte(CP_UTF8, 0, wzName, -1, szName, iLen, 0, 0)); - - hr = ImportHelper::GetCustomAttributeByName(pMiniMd, tkObj, szName, ppData, - pcbData); - - return hr; -} - -BOOL RegMeta::IsValidToken( // True or False. - mdToken tk) // [IN] Given token. -{ - BOOL fRet = FALSE; - HRESULT hr = S_OK; - - // If acquiring the lock failed... - IfFailGo(hr); - - fRet = m_pStgdb->m_MiniMd._IsValidToken(tk); - -ErrExit: - return fRet; -} - -HRESULT RegMeta::GetNestedClassProps( // S_OK or error. - mdTypeDef tdNestedClass, // [IN] NestedClass token. - mdTypeDef *ptdEnclosingClass) // [OUT] EnclosingClass token. -{ - HRESULT hr = NOERROR; - - BEGIN_ENTRYPOINT_NOTHROW; - - NestedClassRec *pRecord; - ULONG iRecord; - CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd); - - // If not a typedef -- return error. - if (TypeFromToken(tdNestedClass) != mdtTypeDef) { - IfFailGo(META_E_INVALID_TOKEN_TYPE); // PostError(META_E_INVALID_TOKEN_TYPE, - // tdNestedClass)); - } - - _ASSERTE(TypeFromToken(tdNestedClass) && !IsNilToken(tdNestedClass) && - ptdEnclosingClass); - - IfFailGo(pMiniMd->FindNestedClassHelper(tdNestedClass, &iRecord)); - - if (InvalidRid(iRecord)) { - hr = CLDB_E_RECORD_NOTFOUND; - goto ErrExit; - } - - IfFailGo(pMiniMd->GetNestedClassRecord(iRecord, &pRecord)); - - _ASSERTE(tdNestedClass == pMiniMd->getNestedClassOfNestedClass(pRecord)); - *ptdEnclosingClass = pMiniMd->getEnclosingClassOfNestedClass(pRecord); - -ErrExit: - return hr; -} - -HRESULT RegMeta::GetNativeCallConvFromSig( // S_OK or error. - void const *pvSig, // [IN] Pointer to signature. - ULONG cbSig, // [IN] Count of signature bytes. - ULONG *pCallConv) // [OUT] Put calling conv here (see CorPinvokemap). -{ - LOG((LF_CORDB, LL_INFO100000, - "CordbSymbol - GetNativeCallConvFromSig - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT RegMeta::IsGlobal( // S_OK or error. - mdToken pd, // [IN] Type, Field, or Method token. - int *pbGlobal) // [OUT] Put 1 if global, 0 otherwise. - -{ - LOG((LF_CORDB, LL_INFO100000, "CordbSymbol - IsGlobal - NOT IMPLEMENTED\n")); - return S_OK; -} diff --git a/src/mono/dbi/cordb-symbol.h b/src/mono/dbi/cordb-symbol.h deleted file mode 100644 index ca6ee04b49ff40..00000000000000 --- a/src/mono/dbi/cordb-symbol.h +++ /dev/null @@ -1,667 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// -// File: CORDB-SYMBOL.H -// - -#ifndef __MONO_DEBUGGER_CORDB_SYMBOL_H__ -#define __MONO_DEBUGGER_CORDB_SYMBOL_H__ - -#include -#include - -#define COR_GLOBAL_PARENT_TOKEN TokenFromRid(1, mdtTypeDef) - -class CLiteWeightStgdbRW; - -class RegMeta : public CordbBaseMono, - public IMetaDataImport2, - public IMetaDataAssemblyImport { - CLiteWeightStgdbRW *m_pStgdb; - -public: - RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule); - ~RegMeta(); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbRegMeta"; } - - inline int IsGlobalMethodParentTk(mdTypeDef td) { - return (td == mdTypeDefNil || td == mdTokenNil); - } - - int inline IsGlobalMethodParent(mdTypeDef *ptd) { - if (IsGlobalMethodParentTk(*ptd)) { - *ptd = COR_GLOBAL_PARENT_TOKEN; - return (true); - } - return (false); - } - - int inline IsGlobalMethodParentToken(mdTypeDef td) { - return (td == COR_GLOBAL_PARENT_TOKEN); - } - - STDMETHOD(EnumGenericParams) - (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken - tk, // [IN] TypeDef or MethodDef whose generic parameters are requested - mdGenericParam rGenericParams[], // [OUT] Put GenericParams here. - ULONG cMax, // [IN] Max GenericParams to put. - ULONG *pcGenericParams); - - STDMETHOD(GetGenericParamProps) - ( // S_OK or error. - mdGenericParam gp, // [IN] GenericParam - ULONG *pulParamSeq, // [OUT] Index of the type parameter - DWORD *pdwParamFlags, // [OUT] Flags, for future use (e.g. variance) - mdToken *ptOwner, // [OUT] Owner (TypeDef or MethodDef) - DWORD *reserved, // [OUT] For future use (e.g. non-type parameters) - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR wzname, // [OUT] Put name here - ULONG cchName, // [IN] Size of buffer - ULONG *pchName); // [OUT] Put size of name (wide chars) here. - - STDMETHOD(GetMethodSpecProps) - (mdMethodSpec mi, // [IN] The method instantiation - mdToken *tkParent, // [OUT] MethodDef or MemberRef - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob); // [OUT] actual size of signature blob - - STDMETHOD(EnumGenericParamConstraints) - (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdGenericParam tk, // [IN] GenericParam whose constraints are requested - mdGenericParamConstraint - rGenericParamConstraints[], // [OUT] Put GenericParamConstraints here. - ULONG cMax, // [IN] Max GenericParamConstraints to put. - ULONG *pcGenericParamConstraints); // [OUT] Put # put here. - - STDMETHOD(GetGenericParamConstraintProps) - ( // S_OK or error. - mdGenericParamConstraint gpc, // [IN] GenericParamConstraint - mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained - mdToken *ptkConstraintType); // [OUT] TypeDef/Ref/Spec constraint - - STDMETHOD(GetPEKind) - ( // S_OK or error. - DWORD *pdwPEKind, // [OUT] The kind of PE (0 - not a PE) - DWORD *pdwMAchine); // [OUT] Machine as defined in NT header - - STDMETHOD(GetVersionString) - ( // S_OK or error. - _Out_writes_to_opt_(ccBufSize, *pccBufSize) - LPWSTR pwzBuf, // [OUT] Put version string here. - DWORD ccBufSize, // [IN] size of the buffer, in wide chars - DWORD *pccBufSize); // [OUT] Size of the version string, wide chars, - // including terminating nul. - - STDMETHOD(EnumMethodSpecs) - (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tk, // [IN] MethodDef or MemberRef whose MethodSpecs are requested - mdMethodSpec rMethodSpecs[], // [OUT] Put MethodSpecs here. - ULONG cMax, // [IN] Max tokens to put. - ULONG *pcMethodSpecs); // [OUT] Put actual count here. - - STDMETHOD(GetAssemblyProps) - ( // S_OK or error. - mdAssembly mda, // [IN] The Assembly for which to get the properties. - const void **ppbPublicKey, // [OUT] Pointer to the public key. - ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. - ULONG *pulHashAlgId, // [OUT] Hash Algorithm. - _Out_writes_to_opt_(cchName, *pchName) LPWSTR - szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. - DWORD *pdwAssemblyFlags); // [OUT] Flags. - - STDMETHOD(GetAssemblyRefProps) - ( // S_OK or error. - mdAssemblyRef - mdar, // [IN] The AssemblyRef for which to get the properties. - const void * - *ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token. - ULONG *pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or - // token. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. - const void **ppbHashValue, // [OUT] Hash blob. - ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob. - DWORD *pdwAssemblyRefFlags); // [OUT] Flags. - - STDMETHOD(GetFileProps) - ( // S_OK or error. - mdFile mdf, // [IN] The File for which to get the properties. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob. - ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob. - DWORD *pdwFileFlags); // [OUT] Flags. - - STDMETHOD(GetExportedTypeProps) - ( // S_OK or error. - mdExportedType - mdct, // [IN] The ExportedType for which to get the properties. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - mdToken * - ptkImplementation, // [OUT] mdFile or mdAssemblyRef or mdExportedType. - mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file. - DWORD *pdwExportedTypeFlags); // [OUT] Flags. - - STDMETHOD(GetManifestResourceProps) - ( // S_OK or error. - mdManifestResource - mdmr, // [IN] The ManifestResource for which to get the properties. - _Out_writes_to_opt_(cchName, *pchName) - LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. - ULONG cchName, // [IN] Size of buffer in wide chars. - ULONG *pchName, // [OUT] Actual # of wide chars in name. - mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides - // the ManifestResource. - DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within - // the file. - DWORD *pdwResourceFlags); // [OUT] Flags. - - STDMETHOD(EnumAssemblyRefs) - ( // S_OK or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdAssemblyRef rAssemblyRefs[], // [OUT] Put AssemblyRefs here. - ULONG cMax, // [IN] Max AssemblyRefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumFiles) - ( // S_OK or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdFile rFiles[], // [OUT] Put Files here. - ULONG cMax, // [IN] Max Files to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumExportedTypes) - ( // S_OK or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdExportedType rExportedTypes[], // [OUT] Put ExportedTypes here. - ULONG cMax, // [IN] Max ExportedTypes to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(EnumManifestResources) - ( // S_OK or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdManifestResource - rManifestResources[], // [OUT] Put ManifestResources here. - ULONG cMax, // [IN] Max Resources to put. - ULONG *pcTokens); // [OUT] Put # put here. - - STDMETHOD(GetAssemblyFromScope) - ( // S_OK or error - mdAssembly *ptkAssembly); - - STDMETHOD(FindExportedTypeByName) - ( // S_OK or error - LPCWSTR szName, // [IN] Name of the ExportedType. - mdToken mdtExportedType, // [IN] ExportedType for the enclosing class. - mdExportedType - *ptkExportedType); // [OUT] Put the ExportedType token here. - - STDMETHOD(FindManifestResourceByName) - ( // S_OK or error - LPCWSTR szName, // [IN] Name of the ManifestResource. - mdManifestResource - *ptkManifestResource); // [OUT] Put the ManifestResource token here. - - STDMETHOD(FindAssembliesByName) - ( // S_OK or error - LPCWSTR szAppBase, // [IN] optional - can be NULL - LPCWSTR szPrivateBin, // [IN] optional - can be NULL - LPCWSTR szAssemblyName, // [IN] required - this is the assembly you are - // requesting - IUnknown *ppIUnk[], // [OUT] put IMetaDataAssemblyImport pointers here - ULONG cMax, // [IN] The max number to put - ULONG *pcAssemblies); // [OUT] The number of assemblies returned. - - // IUnknown methods - HRESULT QueryInterface(REFIID riid, LPVOID *ppvObj); - - // IMetaDataImport functions - - void CloseEnum(HCORENUM hEnum); - HRESULT CountEnum(HCORENUM hEnum, ULONG *pulCount); - HRESULT ResetEnum(HCORENUM hEnum, ULONG ulPos); - HRESULT EnumTypeDefs(HCORENUM *phEnum, mdTypeDef rTypeDefs[], ULONG cMax, - ULONG *pcTypeDefs); - HRESULT EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td, - mdInterfaceImpl rImpls[], ULONG cMax, - ULONG *pcImpls); - HRESULT EnumTypeRefs(HCORENUM *phEnum, mdTypeRef rTypeRefs[], ULONG cMax, - ULONG *pcTypeRefs); - - HRESULT FindTypeDefByName( // S_OK or error. - LPCWSTR szTypeDef, // [IN] Name of the Type. - mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class. - mdTypeDef *ptd); // [OUT] Put the TypeDef token here. - - HRESULT GetScopeProps( // S_OK or error. - __out_ecount_part_opt(cchName, *pchName) - LPWSTR szName, // [OUT] Put the name here. - ULONG cchName, // [IN] Size of name buffer in wide chars. - ULONG *pchName, // [OUT] Put size of name (wide chars) here. - GUID *pmvid); // [OUT, OPTIONAL] Put MVID here. - - HRESULT GetModuleFromScope( // S_OK. - mdModule *pmd); // [OUT] Put mdModule token here. - - HRESULT GetTypeDefProps( // S_OK or error. - mdTypeDef td, // [IN] TypeDef token for inquiry. - __out_ecount_part_opt(cchTypeDef, *pchTypeDef) - LPWSTR szTypeDef, // [OUT] Put name here. - ULONG cchTypeDef, // [IN] size of name buffer in wide chars. - ULONG *pchTypeDef, // [OUT] put size of name (wide chars) here. - DWORD *pdwTypeDefFlags, // [OUT] Put flags here. - mdToken *ptkExtends); // [OUT] Put base class TypeDef/TypeRef here. - - HRESULT GetInterfaceImplProps( // S_OK or error. - mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. - mdTypeDef *pClass, // [OUT] Put implementing class token here. - mdToken *ptkIface); // [OUT] Put implemented interface token here. - - HRESULT GetTypeRefProps( // S_OK or error. - mdTypeRef tr, // [IN] TypeRef token. - mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or - // AssemblyRef. - __out_ecount_part_opt(cchName, *pchName) - LPWSTR szName, // [OUT] Name of the TypeRef. - ULONG cchName, // [IN] Size of buffer. - ULONG *pchName); // [OUT] Size of Name. - - HRESULT ResolveTypeRef(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, - mdTypeDef *ptd); - - HRESULT EnumMembers( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumMembersWithName( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdToken rMembers[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumMethods( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdMethodDef rMethods[], // [OUT] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumMethodsWithName( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdMethodDef rMethods[], // [OU] Put MethodDefs here. - ULONG cMax, // [IN] Max MethodDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumFields( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - mdFieldDef rFields[], // [OUT] Put FieldDefs here. - ULONG cMax, // [IN] Max FieldDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumFieldsWithName( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef cl, // [IN] TypeDef to scope the enumeration. - LPCWSTR szName, // [IN] Limit results to those with this name. - mdFieldDef rFields[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumParams( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdParamDef rParams[], // [OUT] Put ParamDefs here. - ULONG cMax, // [IN] Max ParamDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumMemberRefs( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tkParent, // [IN] Parent token to scope the enumeration. - mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here. - ULONG cMax, // [IN] Max MemberRefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumMethodImpls( // S_OK, S_FALSE, or error - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdToken rMethodBody[], // [OUT] Put Method Body tokens here. - mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here. - ULONG cMax, // [IN] Max tokens to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT EnumPermissionSets( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken tk, // [IN] if !NIL, token to scope the enumeration. - DWORD dwActions, // [IN] if !0, return only these actions. - mdPermission rPermission[], // [OUT] Put Permissions here. - ULONG cMax, // [IN] Max Permissions to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT FindMember( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdToken *pmb); // [OUT] matching memberdef - - HRESULT FindMethod( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMethodDef *pmb); // [OUT] matching memberdef - - HRESULT FindField( - mdTypeDef td, // [IN] given typedef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdFieldDef *pmb); // [OUT] matching memberdef - - HRESULT FindMemberRef( - mdTypeRef td, // [IN] given typeRef - LPCWSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMemberRef *pmr); // [OUT] matching memberref - - HRESULT GetMethodProps( - mdMethodDef mb, // The method for which to get props. - mdTypeDef *pClass, // Put method's class here. - __out_ecount_part_opt(cchMethod, *pchMethod) - LPWSTR szMethod, // Put method's name here. - ULONG cchMethod, // Size of szMethod buffer in wide chars. - ULONG *pchMethod, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - ULONG *pulCodeRVA, // [OUT] codeRVA - DWORD *pdwImplFlags); // [OUT] Impl. Flags - - HRESULT GetMemberRefProps( // S_OK or error. - mdMemberRef mr, // [IN] given memberref - mdToken *ptk, // [OUT] Put classref or classdef here. - __out_ecount_part_opt(cchMember, *pchMember) - LPWSTR szMember, // [OUT] buffer to fill for member's name - ULONG cchMember, // [IN] the count of char of szMember - ULONG *pchMember, // [OUT] actual count of char in member name - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value - ULONG *pbSig); // [OUT] actual size of signature blob - - HRESULT EnumProperties( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdProperty rProperties[], // [OUT] Put Properties here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcProperties); // [OUT] Put # put here. - - HRESULT EnumEvents( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdTypeDef td, // [IN] TypeDef to scope the enumeration. - mdEvent rEvents[], // [OUT] Put events here. - ULONG cMax, // [IN] Max events to put. - ULONG *pcEvents); // [OUT] Put # put here. - - HRESULT GetEventProps( // S_OK, S_FALSE, or error. - mdEvent ev, // [IN] event token - mdTypeDef *pClass, // [OUT] typedef containing the event declarion. - LPCWSTR szEvent, // [OUT] Event name - ULONG cchEvent, // [IN] the count of wchar of szEvent - ULONG *pchEvent, // [OUT] actual count of wchar for event's name - DWORD *pdwEventFlags, // [OUT] Event flags. - mdToken *ptkEventType, // [OUT] EventType class - mdMethodDef *pmdAddOn, // [OUT] AddOn method of the event - mdMethodDef *pmdRemoveOn, // [OUT] RemoveOn method of the event - mdMethodDef *pmdFire, // [OUT] Fire method of the event - mdMethodDef rmdOtherMethod[], // [OUT] other method of the event - ULONG cMax, // [IN] size of rmdOtherMethod - ULONG *pcOtherMethod); // [OUT] total number of other method of this event - - HRESULT EnumMethodSemantics( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdMethodDef mb, // [IN] MethodDef to scope the enumeration. - mdToken rEventProp[], // [OUT] Put Event/Property here. - ULONG cMax, // [IN] Max properties to put. - ULONG *pcEventProp); // [OUT] Put # put here. - - HRESULT GetMethodSemantics( // S_OK, S_FALSE, or error. - mdMethodDef mb, // [IN] method token - mdToken tkEventProp, // [IN] event/property token. - DWORD *pdwSemanticsFlags); // [OUT] the role flags for the - // method/propevent pair - - HRESULT - GetClassLayout(mdTypeDef td, // [IN] give typedef - DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16 - COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array - ULONG cMax, // [IN] size of the array - ULONG *pcFieldOffset, // [OUT] needed array size - ULONG *pulClassSize); // [OUT] the size of the class - - HRESULT GetFieldMarshal( - mdToken tk, // [IN] given a field's memberdef - PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field - ULONG *pcbNativeType); // [OUT] the count of bytes of *ppvNativeType - - HRESULT GetRVA( // S_OK or error. - mdToken tk, // Member for which to set offset - ULONG *pulCodeRVA, // The offset - DWORD *pdwImplFlags); // the implementation flags - - HRESULT GetPermissionSetProps( - mdPermission pm, // [IN] the permission token. - DWORD *pdwAction, // [OUT] CorDeclSecurity. - void const **ppvPermission, // [OUT] permission blob. - ULONG *pcbPermission); // [OUT] count of bytes of pvPermission. - - HRESULT GetSigFromToken( // S_OK or error. - mdSignature mdSig, // [IN] Signature token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. - ULONG *pcbSig); // [OUT] return size of signature. - - HRESULT GetModuleRefProps( // S_OK or error. - mdModuleRef mur, // [IN] moduleref token. - __out_ecount_part_opt(cchName, *pchName) - LPWSTR szName, // [OUT] buffer to fill with the moduleref name. - ULONG cchName, // [IN] size of szName in wide characters. - ULONG *pchName); // [OUT] actual count of characters in the name. - - HRESULT EnumModuleRefs( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. - ULONG cmax, // [IN] max memberrefs to put. - ULONG *pcModuleRefs); // [OUT] put # put here. - - HRESULT GetTypeSpecFromToken( // S_OK or error. - mdTypeSpec typespec, // [IN] TypeSpec token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature - ULONG *pcbSig); // [OUT] return size of signature. - - HRESULT - GetNameFromToken( // Not Recommended! May be removed! - mdToken tk, // [IN] Token to get name from. Must have a name. - MDUTF8CSTR *pszUtf8NamePtr); // [OUT] Return pointer to UTF8 name in heap. - - HRESULT EnumUnresolvedMethods( // S_OK, S_FALSE, or error. - HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. - mdToken rMethods[], // [OUT] Put MemberDefs here. - ULONG cMax, // [IN] Max MemberDefs to put. - ULONG *pcTokens); // [OUT] Put # put here. - - HRESULT GetUserString( // S_OK or error. - mdString stk, // [IN] String token. - __out_ecount_part_opt(cchString, *pchString) - LPWSTR szString, // [OUT] Copy of string. - ULONG cchString, // [IN] Max chars of room in szString. - ULONG *pchString); // [OUT] How many chars in actual string. - - HRESULT GetPinvokeMap( // S_OK or error. - mdToken tk, // [IN] FieldDef or MethodDef. - DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. - __out_ecount_part_opt(cchImportName, *pchImportName) - LPWSTR szImportName, // [OUT] Import name. - ULONG cchImportName, // [IN] Size of the name buffer. - ULONG *pchImportName, // [OUT] Actual number of characters stored. - mdModuleRef *pmrImportDLL); // [OUT] ModuleRef token for the target DLL. - - HRESULT EnumSignatures( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdSignature rSignatures[], // [OUT] put signatures here. - ULONG cmax, // [IN] max signatures to put. - ULONG *pcSignatures); // [OUT] put # put here. - - HRESULT EnumTypeSpecs( // S_OK or error. - HCORENUM *phEnum, // [IN|OUT] pointer to the enum. - mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. - ULONG cmax, // [IN] max TypeSpecs to put. - ULONG *pcTypeSpecs); // [OUT] put # put here. - - HRESULT EnumUserStrings( // S_OK or error. - HCORENUM *phEnum, // [IN/OUT] pointer to the enum. - mdString rStrings[], // [OUT] put Strings here. - ULONG cmax, // [IN] max Strings to put. - ULONG *pcStrings); // [OUT] put # put here. - - HRESULT GetParamForMethodIndex( // S_OK or error. - mdMethodDef md, // [IN] Method token. - ULONG ulParamSeq, // [IN] Parameter sequence. - mdParamDef *ppd); // [IN] Put Param token here. - - HRESULT EnumCustomAttributes( // S_OK or error. - HCORENUM *phEnum, // [IN, OUT] COR enumerator. - mdToken tk, // [IN] Token to scope the enumeration, 0 for all. - mdToken tkType, // [IN] Type of interest, 0 for all. - mdCustomAttribute - rCustomAttributes[], // [OUT] Put custom attribute tokens here. - ULONG cMax, // [IN] Size of rCustomAttributes. - ULONG *pcCustomAttributes); // [OUT, OPTIONAL] Put count of token values - // here. - - HRESULT GetCustomAttributeProps( // S_OK or error. - mdCustomAttribute cv, // [IN] CustomAttribute token. - mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. - mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. - void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. - ULONG *pcbSize); // [OUT, OPTIONAL] Put size of date here. - - HRESULT FindTypeRef( - mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. - LPCWSTR szName, // [IN] TypeRef Name. - mdTypeRef *ptr); // [OUT] matching TypeRef. - - HRESULT GetMemberProps( - mdToken mb, // The member for which to get props. - mdTypeDef *pClass, // Put member's class here. - __out_ecount_part_opt(cchMember, *pchMember) - LPWSTR szMember, // Put member's name here. - ULONG cchMember, // Size of szMember buffer in wide chars. - ULONG *pchMember, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - ULONG *pulCodeRVA, // [OUT] codeRVA - DWORD *pdwImplFlags, // [OUT] Impl. Flags - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected - // ELEMENT_TYPE_* - UVCP_CONSTANT *ppValue, // [OUT] constant value - ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for - // non-strings. - - HRESULT GetFieldProps( - mdFieldDef mb, // The field for which to get props. - mdTypeDef *pClass, // Put field's class here. - __out_ecount_part_opt(cchField, *pchField) - LPWSTR szField, // Put field's name here. - ULONG cchField, // Size of szField buffer in wide chars. - ULONG *pchField, // Put actual size here - DWORD *pdwAttr, // Put flags here. - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob, // [OUT] actual size of signature blob - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected - // ELEMENT_TYPE_* - UVCP_CONSTANT *ppValue, // [OUT] constant value - ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for - // non-strings. - - HRESULT GetPropertyProps( // S_OK, S_FALSE, or error. - mdProperty prop, // [IN] property token - mdTypeDef *pClass, // [OUT] typedef containing the property declarion. - LPCWSTR szProperty, // [OUT] Property name - ULONG cchProperty, // [IN] the count of wchar of szProperty - ULONG *pchProperty, // [OUT] actual count of wchar for property name - DWORD *pdwPropFlags, // [OUT] property flags. - PCCOR_SIGNATURE - *ppvSig, // [OUT] property type. pointing to meta data internal blob - ULONG *pbSig, // [OUT] count of bytes in *ppvSig - DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected - // ELEMENT_TYPE_* - UVCP_CONSTANT *ppDefaultValue, // [OUT] constant value - ULONG *pcchDefaultValue, // [OUT] size of constant string in chars, 0 for - // non-strings. - mdMethodDef *pmdSetter, // [OUT] setter method of the property - mdMethodDef *pmdGetter, // [OUT] getter method of the property - mdMethodDef rmdOtherMethod[], // [OUT] other method of the property - ULONG cMax, // [IN] size of rmdOtherMethod - ULONG * - pcOtherMethod); // [OUT] total number of other method of this property - - HRESULT GetParamProps( // S_OK or error. - mdParamDef tk, // [IN]The Parameter. - mdMethodDef *pmd, // [OUT] Parent Method token. - ULONG *pulSequence, // [OUT] Parameter sequence. - __out_ecount_part_opt(cchName, *pchName) - LPWSTR szName, // [OUT] Put name here. - ULONG cchName, // [OUT] Size of name buffer. - ULONG *pchName, // [OUT] Put actual size of name here. - DWORD *pdwAttr, // [OUT] Put flags here. - DWORD *pdwCPlusTypeFlag, // [OUT] Flag for value type. selected - // ELEMENT_TYPE_*. - UVCP_CONSTANT *ppValue, // [OUT] Constant value. - ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for - // non-strings. - - HRESULT GetCustomAttributeByName( // S_OK or error. - mdToken tkObj, // [IN] Object with Custom Attribute. - LPCWSTR szName, // [IN] Name of desired Custom Attribute. - const void **ppData, // [OUT] Put pointer to data here. - ULONG *pcbData); // [OUT] Put size of data here. - - BOOL IsValidToken( // True or False. - mdToken tk); // [IN] Given token. - - HRESULT GetNestedClassProps( // S_OK or error. - mdTypeDef tdNestedClass, // [IN] NestedClass token. - mdTypeDef *ptdEnclosingClass); // [OUT] EnclosingClass token. - - HRESULT GetNativeCallConvFromSig( // S_OK or error. - void const *pvSig, // [IN] Pointer to signature. - ULONG cbSig, // [IN] Count of signature bytes. - ULONG *pCallConv); // [OUT] Put calling conv here (see CorPinvokemap). - - HRESULT IsGlobal( // S_OK or error. - mdToken pd, // [IN] Type, Field, or Method token. - int *pbGlobal); // [OUT] Put 1 if global, 0 otherwise. -}; - -#endif diff --git a/src/mono/dbi/cordb-thread.cpp b/src/mono/dbi/cordb-thread.cpp index f7fee7fb30cc0b..2539520582cf5a 100644 --- a/src/mono/dbi/cordb-thread.cpp +++ b/src/mono/dbi/cordb-thread.cpp @@ -17,282 +17,284 @@ using namespace std; -CordbThread::CordbThread(Connection *conn, CordbProcess *ppProcess, - long thread_id) - : CordbBaseMono(conn) { - this->m_pProcess = ppProcess; - this->m_threadId = thread_id; - m_pStepper = NULL; - m_pRegisterSet = NULL; - m_pCurrentFrame = NULL; - m_pBlockingObject = NULL; - ppProcess->AddThread(this); +CordbThread::CordbThread(Connection* conn, CordbProcess* ppProcess, long thread_id) : CordbBaseMono(conn) +{ + this->m_pProcess = ppProcess; + this->m_threadId = thread_id; + m_pStepper = NULL; + m_pRegisterSet = NULL; + m_pCurrentFrame = NULL; + m_pBlockingObject = NULL; + ppProcess->AddThread(this); } -CordbThread::~CordbThread() { - if (m_pCurrentFrame) - m_pCurrentFrame->InternalRelease(); - if (m_pBlockingObject) - m_pBlockingObject->InternalRelease(); - if (m_pRegisterSet) - m_pRegisterSet->InternalRelease(); - if (m_pStepper) - m_pStepper->InternalRelease(); +CordbThread::~CordbThread() +{ + if (m_pCurrentFrame) + m_pCurrentFrame->InternalRelease(); + if (m_pBlockingObject) + m_pBlockingObject->InternalRelease(); + if (m_pRegisterSet) + m_pRegisterSet->InternalRelease(); + if (m_pStepper) + m_pStepper->InternalRelease(); } -void CordbThread::SetRegisterSet(CordbRegisterSet *rs) { - if (m_pRegisterSet != NULL) - m_pRegisterSet->InternalRelease(); - m_pRegisterSet = rs; - m_pRegisterSet->InternalAddRef(); +void CordbThread::SetRegisterSet(CordbRegisterSet* rs) +{ + if (m_pRegisterSet != NULL) + m_pRegisterSet->InternalRelease(); + m_pRegisterSet = rs; + m_pRegisterSet->InternalAddRef(); } -HRESULT STDMETHODCALLTYPE CordbThread::HasUnhandledException(void) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - HasUnhandledException - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::HasUnhandledException(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - HasUnhandledException - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetBlockingObjects( - ICorDebugBlockingObjectEnum **ppBlockingObjectEnum) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbThread - GetBlockingObjects - IMPLEMENTED\n")); - if (m_pBlockingObject == NULL) { - m_pBlockingObject = new CordbBlockingObjectEnum(conn); - m_pBlockingObject->InternalAddRef(); - } - m_pBlockingObject->QueryInterface(IID_ICorDebugBlockingObjectEnum, - (void **)ppBlockingObjectEnum); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::GetBlockingObjects(ICorDebugBlockingObjectEnum** ppBlockingObjectEnum) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetBlockingObjects - IMPLEMENTED\n")); + if (m_pBlockingObject == NULL) + { + m_pBlockingObject = new CordbBlockingObjectEnum(conn); + m_pBlockingObject->InternalAddRef(); + } + m_pBlockingObject->QueryInterface(IID_ICorDebugBlockingObjectEnum, (void**)ppBlockingObjectEnum); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentCustomDebuggerNotification( - ICorDebugValue **ppNotificationObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetCurrentCustomDebuggerNotification - NOT " - "IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentCustomDebuggerNotification(ICorDebugValue** ppNotificationObject) +{ + LOG((LF_CORDB, LL_INFO100000, + "CordbThread - GetCurrentCustomDebuggerNotification - NOT " + "IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbThread::CreateStackWalk(ICorDebugStackWalk **ppStackWalk) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - CreateStackWalk - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::CreateStackWalk(ICorDebugStackWalk** ppStackWalk) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - CreateStackWalk - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetActiveInternalFrames( - ULONG32 cInternalFrames, ULONG32 *pcInternalFrames, - ICorDebugInternalFrame2 *ppInternalFrames[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetActiveInternalFrames - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetActiveInternalFrames(ULONG32 cInternalFrames, + ULONG32* pcInternalFrames, + ICorDebugInternalFrame2* ppInternalFrames[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetActiveInternalFrames - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetActiveFunctions(ULONG32 cFunctions, ULONG32 *pcFunctions, - COR_ACTIVE_FUNCTION pFunctions[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetActiveFunctions - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFunctions(ULONG32 cFunctions, + ULONG32* pcFunctions, + COR_ACTIVE_FUNCTION pFunctions[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetActiveFunctions - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetConnectionID(CONNID *pdwConnectionId) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetConnectionID - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetConnectionID(CONNID* pdwConnectionId) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetConnectionID - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetTaskID(TASKID *pTaskId) { - LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetTaskID - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetTaskID(TASKID* pTaskId) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetTaskID - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::GetVolatileOSThreadID(DWORD *pdwTid) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetVolatileOSThreadID - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetVolatileOSThreadID(DWORD* pdwTid) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetVolatileOSThreadID - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbThread::InterceptCurrentException( - ICorDebugFrame *pFrame) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - InterceptCurrentException - NOT IMPLEMENTED\n")); - return E_NOTIMPL; + ICorDebugFrame* pFrame) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - InterceptCurrentException - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetProcess(ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetProcess - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::GetProcess(ICorDebugProcess** ppProcess) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetProcess - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetID(DWORD *pdwThreadId) { - *pdwThreadId = GetThreadId(); - LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetID - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::GetID(DWORD* pdwThreadId) +{ + *pdwThreadId = GetThreadId(); + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetID - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetHandle(HTHREAD *phThreadHandle) { - LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetHandle - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetHandle(HTHREAD* phThreadHandle) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetHandle - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetAppDomain(ICorDebugAppDomain **ppAppDomain) { - conn->GetCurrentAppDomain()->QueryInterface(IID_ICorDebugAppDomain, - (void **)ppAppDomain); - LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetAppDomain - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::GetAppDomain(ICorDebugAppDomain** ppAppDomain) +{ + conn->GetCurrentAppDomain()->QueryInterface(IID_ICorDebugAppDomain, (void**)ppAppDomain); + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetAppDomain - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbThread::SetDebugState(CorDebugThreadState state) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - SetDebugState - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::SetDebugState(CorDebugThreadState state) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - SetDebugState - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetDebugState(CorDebugThreadState *pState) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetDebugState - NOT IMPLEMENTED\n")); - *pState = THREAD_RUN; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::GetDebugState(CorDebugThreadState* pState) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetDebugState - NOT IMPLEMENTED\n")); + *pState = THREAD_RUN; + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetUserState(CorDebugUserState *pState) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetUserState - NOT IMPLEMENTED\n")); +HRESULT STDMETHODCALLTYPE CordbThread::GetUserState(CorDebugUserState* pState) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetUserState - NOT IMPLEMENTED\n")); - *pState = (CorDebugUserState)0; - return S_OK; + *pState = (CorDebugUserState)0; + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetCurrentException(ICorDebugValue **ppExceptionObject) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbThread - GetCurrentException - IMPLEMENTED\n")); +HRESULT STDMETHODCALLTYPE CordbThread::GetCurrentException(ICorDebugValue** ppExceptionObject) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetCurrentException - IMPLEMENTED\n")); - return S_FALSE; + return S_FALSE; } -HRESULT STDMETHODCALLTYPE CordbThread::ClearCurrentException(void) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - ClearCurrentException - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::ClearCurrentException(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - ClearCurrentException - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbThread::CreateStepper(ICorDebugStepper **ppStepper) { - if (m_pStepper) - m_pStepper->InternalRelease(); - m_pStepper = new CordbStepper(conn, this); - m_pStepper->InternalAddRef(); - m_pStepper->QueryInterface(IID_ICorDebugStepper, (void **)ppStepper); - - LOG((LF_CORDB, LL_INFO1000000, - "CordbThread - CreateStepper - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::CreateStepper(ICorDebugStepper** ppStepper) +{ + if (m_pStepper) + m_pStepper->InternalRelease(); + m_pStepper = new CordbStepper(conn, this); + m_pStepper->InternalAddRef(); + m_pStepper->QueryInterface(IID_ICorDebugStepper, (void**)ppStepper); + + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - CreateStepper - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbThread::EnumerateChains(ICorDebugChainEnum **ppChains) { - CordbChainEnum *pChains = new CordbChainEnum(conn, this); - pChains->AddRef(); - *ppChains = static_cast(pChains); - LOG((LF_CORDB, LL_INFO1000000, - "CordbThread - EnumerateChains - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::EnumerateChains(ICorDebugChainEnum** ppChains) +{ + CordbChainEnum* pChains = new CordbChainEnum(conn, this); + pChains->AddRef(); + *ppChains = static_cast(pChains); + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - EnumerateChains - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetActiveChain(ICorDebugChain **ppChain) { - LOG((LF_CORDB, LL_INFO100000, - "CordbThread - GetActiveChain - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetActiveChain(ICorDebugChain** ppChain) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetActiveChain - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetActiveFrame(ICorDebugFrame **ppFrame) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbThread - GetActiveFrame - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, GetThreadId()); - m_dbgprot_buffer_add_int(&localbuf, 0); - m_dbgprot_buffer_add_int(&localbuf, -1); - - int cmdId = this->conn->SendEvent( - MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - - int nframes = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - if (nframes > 0) { - int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - if (m_pCurrentFrame) - m_pCurrentFrame->InternalRelease(); - m_pCurrentFrame = - new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, this); - m_pCurrentFrame->InternalAddRef(); - m_pCurrentFrame->QueryInterface(IID_ICorDebugFrame, (void **)ppFrame); - } - SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); - - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFrame(ICorDebugFrame** ppFrame) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetActiveFrame - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetThreadId()); + m_dbgprot_buffer_add_int(&localbuf, 0); + m_dbgprot_buffer_add_int(&localbuf, -1); + + int cmdId = this->conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int nframes = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + if (nframes > 0) + { + int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + if (m_pCurrentFrame) + m_pCurrentFrame->InternalRelease(); + m_pCurrentFrame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, this); + m_pCurrentFrame->InternalAddRef(); + m_pCurrentFrame->QueryInterface(IID_ICorDebugFrame, (void**)ppFrame); + } + SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); + + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbThread::GetRegisterSet(ICorDebugRegisterSet **ppRegisters) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbThread - GetRegisterSet - IMPLEMENTED\n")); +HRESULT STDMETHODCALLTYPE CordbThread::GetRegisterSet(ICorDebugRegisterSet** ppRegisters) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetRegisterSet - IMPLEMENTED\n")); - if (!m_pRegisterSet) - SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); - m_pRegisterSet->AddRef(); - *ppRegisters = static_cast(m_pRegisterSet); - return S_OK; + if (!m_pRegisterSet) + SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); + m_pRegisterSet->AddRef(); + *ppRegisters = static_cast(m_pRegisterSet); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::CreateEval(ICorDebugEval **ppEval) { - LOG((LF_CORDB, LL_INFO1000000, "CordbThread - CreateEval - IMPLEMENTED\n")); - CordbEval *eval = new CordbEval(this->conn, this); - eval->QueryInterface(IID_ICorDebugEval, (void **)ppEval); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::CreateEval(ICorDebugEval** ppEval) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbThread - CreateEval - IMPLEMENTED\n")); + CordbEval* eval = new CordbEval(this->conn, this); + eval->QueryInterface(IID_ICorDebugEval, (void**)ppEval); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbThread::GetObject(ICorDebugValue **ppObject) { - LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetObject - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbThread::GetObject(ICorDebugValue** ppObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbThread - GetObject - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbThread::QueryInterface( - REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppInterface) { - if (id == IID_ICorDebugThread) { - *ppInterface = static_cast(this); - } else if (id == IID_ICorDebugThread2) { - *ppInterface = static_cast(this); - } else if (id == IID_ICorDebugThread3) { - *ppInterface = static_cast(this); - } else if (id == IID_ICorDebugThread4) { - *ppInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *ppInterface = - static_cast(static_cast(this)); - } else { - *ppInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbThread::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface) +{ + if (id == IID_ICorDebugThread) + { + *ppInterface = static_cast(this); + } + else if (id == IID_ICorDebugThread2) + { + *ppInterface = static_cast(this); + } + else if (id == IID_ICorDebugThread3) + { + *ppInterface = static_cast(this); + } + else if (id == IID_ICorDebugThread4) + { + *ppInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *ppInterface = static_cast(static_cast(this)); + } + else + { + *ppInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } diff --git a/src/mono/dbi/cordb-thread.h b/src/mono/dbi/cordb-thread.h index fe1c7103a1195f..91629f0d67889e 100644 --- a/src/mono/dbi/cordb-thread.h +++ b/src/mono/dbi/cordb-thread.h @@ -13,69 +13,85 @@ class CordbThread : public CordbBaseMono, public ICorDebugThread, public ICorDebugThread2, public ICorDebugThread3, - public ICorDebugThread4 { - long m_threadId; - CordbProcess *m_pProcess; - CordbStepper *m_pStepper; - CordbRegisterSet *m_pRegisterSet; - CordbNativeFrame *m_pCurrentFrame; - CordbBlockingObjectEnum *m_pBlockingObject; + public ICorDebugThread4 +{ + long m_threadId; + CordbProcess* m_pProcess; + CordbStepper* m_pStepper; + CordbRegisterSet* m_pRegisterSet; + CordbNativeFrame* m_pCurrentFrame; + CordbBlockingObjectEnum* m_pBlockingObject; public: - CordbThread(Connection *conn, CordbProcess *ppProcess, long thread_id); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbThread"; } - ~CordbThread(); - void SetRegisterSet(CordbRegisterSet *rs); - HRESULT HasUnhandledException(void); - HRESULT - GetBlockingObjects(ICorDebugBlockingObjectEnum **ppBlockingObjectEnum); - HRESULT - GetCurrentCustomDebuggerNotification(ICorDebugValue **ppNotificationObject); - HRESULT - CreateStackWalk(ICorDebugStackWalk **ppStackWalk); - HRESULT - GetActiveInternalFrames(ULONG32 cInternalFrames, ULONG32 *pcInternalFrames, - ICorDebugInternalFrame2 *ppInternalFrames[]); - HRESULT GetActiveFunctions(ULONG32 cFunctions, ULONG32 *pcFunctions, - COR_ACTIVE_FUNCTION pFunctions[]); - HRESULT - GetConnectionID(CONNID *pdwConnectionId); - HRESULT GetTaskID(TASKID *pTaskId); - HRESULT GetVolatileOSThreadID(DWORD *pdwTid); - HRESULT - InterceptCurrentException(ICorDebugFrame *pFrame); - HRESULT - GetProcess(ICorDebugProcess **ppProcess); - HRESULT GetID(DWORD *pdwThreadId); - HRESULT GetHandle(HTHREAD *phThreadHandle); - HRESULT - GetAppDomain(ICorDebugAppDomain **ppAppDomain); - HRESULT SetDebugState(CorDebugThreadState state); - HRESULT - GetDebugState(CorDebugThreadState *pState); - HRESULT GetUserState(CorDebugUserState *pState); - HRESULT - GetCurrentException(ICorDebugValue **ppExceptionObject); - HRESULT ClearCurrentException(void); - HRESULT - CreateStepper(ICorDebugStepper **ppStepper); - HRESULT - EnumerateChains(ICorDebugChainEnum **ppChains); - HRESULT - GetActiveChain(ICorDebugChain **ppChain); - HRESULT - GetActiveFrame(ICorDebugFrame **ppFrame); - HRESULT - GetRegisterSet(ICorDebugRegisterSet **ppRegisters); - HRESULT CreateEval(ICorDebugEval **ppEval); - HRESULT GetObject(ICorDebugValue **ppObject); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *pInterface); + CordbThread(Connection* conn, CordbProcess* ppProcess, long thread_id); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbThread"; + } + ~CordbThread(); + void SetRegisterSet(CordbRegisterSet* rs); + HRESULT HasUnhandledException(void); + HRESULT + GetBlockingObjects(ICorDebugBlockingObjectEnum** ppBlockingObjectEnum); + HRESULT + GetCurrentCustomDebuggerNotification(ICorDebugValue** ppNotificationObject); + HRESULT + CreateStackWalk(ICorDebugStackWalk** ppStackWalk); + HRESULT + GetActiveInternalFrames(ULONG32 cInternalFrames, + ULONG32* pcInternalFrames, + ICorDebugInternalFrame2* ppInternalFrames[]); + HRESULT GetActiveFunctions(ULONG32 cFunctions, ULONG32* pcFunctions, COR_ACTIVE_FUNCTION pFunctions[]); + HRESULT + GetConnectionID(CONNID* pdwConnectionId); + HRESULT GetTaskID(TASKID* pTaskId); + HRESULT GetVolatileOSThreadID(DWORD* pdwTid); + HRESULT + InterceptCurrentException(ICorDebugFrame* pFrame); + HRESULT + GetProcess(ICorDebugProcess** ppProcess); + HRESULT GetID(DWORD* pdwThreadId); + HRESULT GetHandle(HTHREAD* phThreadHandle); + HRESULT + GetAppDomain(ICorDebugAppDomain** ppAppDomain); + HRESULT SetDebugState(CorDebugThreadState state); + HRESULT + GetDebugState(CorDebugThreadState* pState); + HRESULT GetUserState(CorDebugUserState* pState); + HRESULT + GetCurrentException(ICorDebugValue** ppExceptionObject); + HRESULT ClearCurrentException(void); + HRESULT + CreateStepper(ICorDebugStepper** ppStepper); + HRESULT + EnumerateChains(ICorDebugChainEnum** ppChains); + HRESULT + GetActiveChain(ICorDebugChain** ppChain); + HRESULT + GetActiveFrame(ICorDebugFrame** ppFrame); + HRESULT + GetRegisterSet(ICorDebugRegisterSet** ppRegisters); + HRESULT CreateEval(ICorDebugEval** ppEval); + HRESULT GetObject(ICorDebugValue** ppObject); + HRESULT + QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - long GetThreadId() const { return m_threadId; } - CordbStepper *GetStepper() const { return m_pStepper; } + long GetThreadId() const + { + return m_threadId; + } + CordbStepper* GetStepper() const + { + return m_pStepper; + } }; #endif diff --git a/src/mono/dbi/cordb-type.cpp b/src/mono/dbi/cordb-type.cpp index 9dd3ba1c6a0c1a..c0f1744494a809 100644 --- a/src/mono/dbi/cordb-type.cpp +++ b/src/mono/dbi/cordb-type.cpp @@ -11,162 +11,174 @@ using namespace std; -CordbType::CordbType(CorElementType type, Connection *conn, CordbClass *klass, - CordbType *typeParameter) - : CordbBaseMono(conn) { - this->m_pClass = klass; - this->m_type = type; - this->m_pTypeParameter = typeParameter; - m_pTypeEnum = NULL; - if (typeParameter) - typeParameter->InternalAddRef(); - if (klass) - klass->InternalAddRef(); -} - -CordbType::~CordbType() { - if (m_pClass) - m_pClass->InternalRelease(); - if (m_pTypeParameter) - m_pTypeParameter->InternalRelease(); - if (m_pTypeEnum) - m_pTypeEnum->InternalRelease(); -} - -HRESULT STDMETHODCALLTYPE CordbType::GetType(CorElementType *ty) { - *ty = m_type; - LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetType - IMPLEMENTED\n")); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbType::GetClass(ICorDebugClass **ppClass) { - LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetClass - IMPLEMENTED\n")); - if (!m_pClass) { - LOG((LF_CORDB, LL_INFO100000, "CordbType - GetClass - NO CLASS\n")); +CordbType::CordbType(CorElementType type, Connection* conn, CordbClass* klass, CordbType* typeParameter) + : CordbBaseMono(conn) +{ + this->m_pClass = klass; + this->m_type = type; + this->m_pTypeParameter = typeParameter; + m_pTypeEnum = NULL; + if (typeParameter) + typeParameter->InternalAddRef(); + if (klass) + klass->InternalAddRef(); +} + +CordbType::~CordbType() +{ + if (m_pClass) + m_pClass->InternalRelease(); + if (m_pTypeParameter) + m_pTypeParameter->InternalRelease(); + if (m_pTypeEnum) + m_pTypeEnum->InternalRelease(); +} + +HRESULT STDMETHODCALLTYPE CordbType::GetType(CorElementType* ty) +{ + *ty = m_type; + LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetType - IMPLEMENTED\n")); return S_OK; - } - m_pClass->QueryInterface(IID_ICorDebugClass, (void **)ppClass); - return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbType::EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum) { - if (m_pTypeEnum == NULL) { - m_pTypeEnum = new CordbTypeEnum(conn, m_pTypeParameter); - m_pTypeEnum->InternalAddRef(); - } - m_pTypeEnum->QueryInterface(IID_ICorDebugTypeEnum, (void **)ppTyParEnum); - - LOG((LF_CORDB, LL_INFO1000000, - "CordbType - EnumerateTypeParameters - IMPLEMENTED\n")); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE -CordbType::GetFirstTypeParameter(ICorDebugType **value) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbType - GetFirstTypeParameter - IMPLEMENTED\n")); - m_pTypeParameter->QueryInterface(IID_ICorDebugType, (void **)value); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbType::GetClass(ICorDebugClass** ppClass) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetClass - IMPLEMENTED\n")); + if (!m_pClass) + { + LOG((LF_CORDB, LL_INFO100000, "CordbType - GetClass - NO CLASS\n")); + return S_OK; + } + m_pClass->QueryInterface(IID_ICorDebugClass, (void**)ppClass); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbType::GetBase(ICorDebugType **pBase) { - LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetBase - IMPLEMENTED\n")); - return E_NOTIMPL; -} +HRESULT STDMETHODCALLTYPE CordbType::EnumerateTypeParameters(ICorDebugTypeEnum** ppTyParEnum) +{ + if (m_pTypeEnum == NULL) + { + m_pTypeEnum = new CordbTypeEnum(conn, m_pTypeParameter); + m_pTypeEnum->InternalAddRef(); + } + m_pTypeEnum->QueryInterface(IID_ICorDebugTypeEnum, (void**)ppTyParEnum); -HRESULT STDMETHODCALLTYPE CordbType::GetStaticFieldValue( - mdFieldDef fieldDef, ICorDebugFrame *pFrame, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbType - GetStaticFieldValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; + LOG((LF_CORDB, LL_INFO1000000, "CordbType - EnumerateTypeParameters - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbType::GetRank(ULONG32 *pnRank) { - LOG((LF_CORDB, LL_INFO100000, "CordbType - GetRank - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbType::GetFirstTypeParameter(ICorDebugType** value) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetFirstTypeParameter - IMPLEMENTED\n")); + m_pTypeParameter->QueryInterface(IID_ICorDebugType, (void**)value); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbType::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugType) - *pInterface = static_cast(this); - else if (id == IID_ICorDebugType2) - *pInterface = static_cast(this); - else if (id == IID_IUnknown) - *pInterface = static_cast(static_cast(this)); - else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbType::GetBase(ICorDebugType** pBase) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbType - GetBase - IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbType::GetStaticFieldValue(mdFieldDef fieldDef, + ICorDebugFrame* pFrame, + ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbType - GetStaticFieldValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbType::GetRank(ULONG32* pnRank) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbType - GetRank - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbType::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugType) + *pInterface = static_cast(this); + else if (id == IID_ICorDebugType2) + *pInterface = static_cast(this); + else if (id == IID_IUnknown) + *pInterface = static_cast(static_cast(this)); + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbType::GetTypeID(COR_TYPEID *id) { - LOG((LF_CORDB, LL_INFO100000, "CordbType - GetTypeID - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbType::GetTypeID(COR_TYPEID* id) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbType - GetTypeID - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -CordbTypeEnum::CordbTypeEnum(Connection *conn, CordbType *type) - : CordbBaseMono(conn) { - this->m_pType = type; - if (type) - type->InternalAddRef(); +CordbTypeEnum::CordbTypeEnum(Connection* conn, CordbType* type) : CordbBaseMono(conn) +{ + this->m_pType = type; + if (type) + type->InternalAddRef(); } -CordbTypeEnum::~CordbTypeEnum() { - if (m_pType) - m_pType->InternalRelease(); +CordbTypeEnum::~CordbTypeEnum() +{ + if (m_pType) + m_pType->InternalRelease(); } -HRESULT STDMETHODCALLTYPE CordbTypeEnum::Next(ULONG celt, - ICorDebugType *values[], - ULONG *pceltFetched) { - *pceltFetched = celt; - if (m_pType != NULL) - m_pType->QueryInterface(IID_ICorDebugType, (void **)&values[0]); - LOG((LF_CORDB, LL_INFO1000000, "CordbTypeEnum - Next - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbTypeEnum::Next(ULONG celt, ICorDebugType* values[], ULONG* pceltFetched) +{ + *pceltFetched = celt; + if (m_pType != NULL) + m_pType->QueryInterface(IID_ICorDebugType, (void**)&values[0]); + LOG((LF_CORDB, LL_INFO1000000, "CordbTypeEnum - Next - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbTypeEnum::Skip(ULONG celt) { - LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Skip - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbTypeEnum::Skip(ULONG celt) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Skip - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbTypeEnum::Reset(void) { - LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Reset - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbTypeEnum::Reset(void) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Reset - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbTypeEnum::Clone(ICorDebugEnum **ppEnum) { - LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Clone - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbTypeEnum::Clone(ICorDebugEnum** ppEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbTypeEnum - Clone - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbTypeEnum::GetCount(ULONG *pcelt) { - if (m_pType != NULL) - *pcelt = 1; - else - *pcelt = 0; - LOG((LF_CORDB, LL_INFO1000000, "CordbTypeEnum - GetCount - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbTypeEnum::GetCount(ULONG* pcelt) +{ + if (m_pType != NULL) + *pcelt = 1; + else + *pcelt = 0; + LOG((LF_CORDB, LL_INFO1000000, "CordbTypeEnum - GetCount - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbTypeEnum::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugEnum) - *pInterface = static_cast(this); - else if (id == IID_ICorDebugTypeEnum) - *pInterface = static_cast(this); - else if (id == IID_IUnknown) - *pInterface = - static_cast(static_cast(this)); - else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbTypeEnum::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugEnum) + *pInterface = static_cast(this); + else if (id == IID_ICorDebugTypeEnum) + *pInterface = static_cast(this); + else if (id == IID_IUnknown) + *pInterface = static_cast(static_cast(this)); + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } diff --git a/src/mono/dbi/cordb-type.h b/src/mono/dbi/cordb-type.h index 4030cc626cd6d0..1ad0f622956a5c 100644 --- a/src/mono/dbi/cordb-type.h +++ b/src/mono/dbi/cordb-type.h @@ -9,51 +9,66 @@ #include -class CordbType : public CordbBaseMono, - public ICorDebugType, - public ICorDebugType2 { - CorElementType m_type; - CordbClass *m_pClass; - CordbType *m_pTypeParameter; - CordbTypeEnum *m_pTypeEnum; +class CordbType : public CordbBaseMono, public ICorDebugType, public ICorDebugType2 +{ + CorElementType m_type; + CordbClass* m_pClass; + CordbType* m_pTypeParameter; + CordbTypeEnum* m_pTypeEnum; public: - CordbType(CorElementType type, Connection *conn, CordbClass *klass = NULL, - CordbType *typeParameter = NULL); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbType"; } - ~CordbType(); - HRESULT GetType(CorElementType *ty); - HRESULT GetClass(ICorDebugClass **ppClass); - HRESULT - EnumerateTypeParameters(ICorDebugTypeEnum **ppTyParEnum); - HRESULT GetFirstTypeParameter(ICorDebugType **value); - HRESULT GetBase(ICorDebugType **pBase); - HRESULT GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame *pFrame, - ICorDebugValue **ppValue); - HRESULT GetRank(ULONG32 *pnRank); - HRESULT QueryInterface(REFIID riid, void **ppvObject); - - HRESULT GetTypeID(COR_TYPEID *id); + CordbType(CorElementType type, Connection* conn, CordbClass* klass = NULL, CordbType* typeParameter = NULL); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbType"; + } + ~CordbType(); + HRESULT GetType(CorElementType* ty); + HRESULT GetClass(ICorDebugClass** ppClass); + HRESULT + EnumerateTypeParameters(ICorDebugTypeEnum** ppTyParEnum); + HRESULT GetFirstTypeParameter(ICorDebugType** value); + HRESULT GetBase(ICorDebugType** pBase); + HRESULT GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame* pFrame, ICorDebugValue** ppValue); + HRESULT GetRank(ULONG32* pnRank); + HRESULT QueryInterface(REFIID riid, void** ppvObject); + + HRESULT GetTypeID(COR_TYPEID* id); }; -class CordbTypeEnum : public CordbBaseMono, public ICorDebugTypeEnum { - CordbType *m_pType; +class CordbTypeEnum : public CordbBaseMono, public ICorDebugTypeEnum +{ + CordbType* m_pType; public: - CordbTypeEnum(Connection *conn, CordbType *type); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbTypeEnum"; } - ~CordbTypeEnum(); - virtual HRESULT Next(ULONG celt, ICorDebugType *values[], - ULONG *pceltFetched); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum **ppEnum); - HRESULT GetCount(ULONG *pcelt); - HRESULT QueryInterface(REFIID riid, void **ppvObject); + CordbTypeEnum(Connection* conn, CordbType* type); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbTypeEnum"; + } + ~CordbTypeEnum(); + virtual HRESULT Next(ULONG celt, ICorDebugType* values[], ULONG* pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(void); + HRESULT Clone(ICorDebugEnum** ppEnum); + HRESULT GetCount(ULONG* pcelt); + HRESULT QueryInterface(REFIID riid, void** ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index bd934eeb9340b7..2d35986638b07e 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -12,1166 +12,1159 @@ using namespace std; -CordbValue::CordbValue(Connection *conn, CorElementType type, - CordbContent value, int size) - : CordbBaseMono(conn) { - this->m_type = type; - this->m_value = value; - this->m_size = size; - this->conn = conn; - m_pType = NULL; +CordbValue::CordbValue(Connection* conn, CorElementType type, CordbContent value, int size) : CordbBaseMono(conn) +{ + this->m_type = type; + this->m_value = value; + this->m_size = size; + this->conn = conn; + m_pType = NULL; } -CordbValue::~CordbValue() { - if (m_pType) - m_pType->InternalRelease(); +CordbValue::~CordbValue() +{ + if (m_pType) + m_pType->InternalRelease(); } -HRESULT STDMETHODCALLTYPE CordbValue::GetType(CorElementType *pType) { - *pType = m_type; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbValue::GetType(CorElementType* pType) +{ + *pType = m_type; + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbValue::GetSize(ULONG32 *pSize) { - *pSize = m_size; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbValue::GetSize(ULONG32* pSize) +{ + *pSize = m_size; + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbValue::GetAddress(CORDB_ADDRESS *pAddress) { - *pAddress = (CORDB_ADDRESS)&m_value; - LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetAddress - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbValue::GetAddress(CORDB_ADDRESS* pAddress) +{ + *pAddress = (CORDB_ADDRESS)&m_value; + LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetAddress - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbValue - CreateBreakpoint - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbValue::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugValue) { - *pInterface = static_cast( - static_cast(this)); - } else if (id == IID_ICorDebugValue2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugValue3) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugGenericValue) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = - static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbValue::GetExactType(ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetExactType - IMPLEMENTED\n")); - if (m_pType == NULL) { - m_pType = new CordbType(m_type, conn); - m_pType->InternalAddRef(); - } - m_pType->QueryInterface(IID_ICorDebugType, (void **)ppType); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbValue::GetSize64(ULONG64 *pSize) { - LOG((LF_CORDB, LL_INFO100000, "CordbValue - GetSize64 - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbValue::GetValue(void *pTo) { - LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetValue - IMPLEMENTED\n")); - memcpy(pTo, &m_value, m_size); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbValue::SetValue(void *pFrom) { - memcpy(&m_value, pFrom, m_size); - LOG((LF_CORDB, LL_INFO1000000, "CordbValue - SetValue - IMPLEMENTED\n")); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetType(CorElementType *pType) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbReferenceValue - GetType - IMPLEMENTED\n")); - *pType = m_type; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize(ULONG32 *pSize) { - LOG((LF_CORDB, LL_INFO100000, - "CordbReferenceValue - GetSize - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbValue::CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbValue - CreateBreakpoint - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::GetAddress(CORDB_ADDRESS *pAddress) { - *pAddress = (CORDB_ADDRESS)&m_debuggerId; - LOG((LF_CORDB, LL_INFO1000000, - "CordbReferenceValue - GetAddress - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbValue::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugValue) + { + *pInterface = static_cast(static_cast(this)); + } + else if (id == IID_ICorDebugValue2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugValue3) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugGenericValue) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbReferenceValue - CreateBreakpoint - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbValue::GetExactType(ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetExactType - IMPLEMENTED\n")); + if (m_pType == NULL) + { + m_pType = new CordbType(m_type, conn); + m_pType->InternalAddRef(); + } + m_pType->QueryInterface(IID_ICorDebugType, (void**)ppType); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::QueryInterface(REFIID id, void **pInterface) { - if (id == IID_ICorDebugValue) { - *pInterface = static_cast( - static_cast(this)); - } else if (id == IID_ICorDebugValue2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugValue3) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugReferenceValue) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = - static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbValue::GetSize64(ULONG64* pSize) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbValue - GetSize64 - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::GetExactType(ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbReferenceValue - GetExactType - IMPLEMENTED\n")); - if (m_pCordbType) { - m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); +HRESULT STDMETHODCALLTYPE CordbValue::GetValue(void* pTo) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetValue - IMPLEMENTED\n")); + memcpy(pTo, &m_value, m_size); return S_OK; - } - if (m_pClass != NULL) { - m_pCordbType = new CordbType(m_type, conn, m_pClass); - m_pCordbType->InternalAddRef(); - m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); - return S_OK; - } - if (m_type == ELEMENT_TYPE_CLASS && m_debuggerId != -1) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); +} - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, - MDBGPROT_CMD_OBJECT_REF_GET_TYPE, &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT STDMETHODCALLTYPE CordbValue::SetValue(void* pFrom) +{ + memcpy(&m_value, pFrom, m_size); + LOG((LF_CORDB, LL_INFO1000000, "CordbValue - SetValue - IMPLEMENTED\n")); + return S_OK; +} - ReceivedReplyPacket *received_reply_packet = - conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetType(CorElementType* pType) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetType - IMPLEMENTED\n")); + *pType = m_type; + return S_OK; +} - int type_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize(ULONG32* pSize) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - GetSize - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, type_id); +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetAddress(CORDB_ADDRESS* pAddress) +{ + *pAddress = (CORDB_ADDRESS)&m_debuggerId; + LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetAddress - IMPLEMENTED\n")); + return S_OK; +} - cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, - &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT STDMETHODCALLTYPE CordbReferenceValue::CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - CreateBreakpoint - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - pReply = received_reply_packet->Buffer(); - - char *namespace_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char *class_name_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char *class_fullname_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - int assembly_id = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_pClass = new CordbClass(conn, token, assembly_id); - m_pClass->InternalAddRef(); - m_pCordbType = new CordbType(m_type, conn, m_pClass); - m_pCordbType->InternalAddRef(); - m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); - free(namespace_str); - free(class_name_str); - free(class_fullname_str); +HRESULT STDMETHODCALLTYPE CordbReferenceValue::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugValue) + { + *pInterface = static_cast(static_cast(this)); + } + else if (id == IID_ICorDebugValue2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugValue3) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugReferenceValue) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); return S_OK; - } - if (m_type == ELEMENT_TYPE_SZARRAY && m_debuggerId != -1) { - m_pClass = NULL; - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); +} - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, - MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetExactType - IMPLEMENTED\n")); + if (m_pCordbType) + { + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + return S_OK; + } + if (m_pClass != NULL) + { + m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + return S_OK; + } + if (m_type == ELEMENT_TYPE_CLASS && m_debuggerId != -1) + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - ReceivedReplyPacket *received_reply_packet = - conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - - int type_id = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - if (type_id == ELEMENT_TYPE_CLASS) { - int klass_id = - m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, klass_id); - - cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, - &localbuf); - m_dbgprot_buffer_free(&localbuf); - - received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - pReply = received_reply_packet->Buffer(); - - char *namespace_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char *class_name_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char *class_fullname_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - int assembly_id = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int module_id = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_pClass = new CordbClass(conn, token, module_id); - m_pClass->InternalAddRef(); - free(namespace_str); - free(class_name_str); - free(class_fullname_str); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_TYPE, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int type_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, type_id); + + cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + pReply = received_reply_packet->Buffer(); + + char* namespace_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_name_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_pClass = new CordbClass(conn, token, assembly_id); + m_pClass->InternalAddRef(); + m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); + return S_OK; } + if (m_type == ELEMENT_TYPE_SZARRAY && m_debuggerId != -1) + { + m_pClass = NULL; + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - m_pCordbType = - new CordbType(m_type, conn, NULL, - new CordbType((CorElementType)type_id, conn, m_pClass)); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int type_id = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + if (type_id == ELEMENT_TYPE_CLASS) + { + int klass_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, klass_id); + + cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + pReply = received_reply_packet->Buffer(); + + char* namespace_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_name_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_pClass = new CordbClass(conn, token, module_id); + m_pClass->InternalAddRef(); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); + } + + m_pCordbType = new CordbType(m_type, conn, NULL, new CordbType((CorElementType)type_id, conn, m_pClass)); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + return S_OK; + } + m_pCordbType = new CordbType(m_type, conn); m_pCordbType->InternalAddRef(); - m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); return S_OK; - } - m_pCordbType = new CordbType(m_type, conn); - m_pCordbType->InternalAddRef(); - m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); - return S_OK; } -HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize64(ULONG64 *pSize) { - LOG((LF_CORDB, LL_INFO100000, - "CordbReferenceValue - GetSize64 - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize64(ULONG64* pSize) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - GetSize64 - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetValue(void *pTo) { - LOG((LF_CORDB, LL_INFO100000, - "CordbReferenceValue - GetValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetValue(void* pTo) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - GetValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(void *pFrom) { - LOG((LF_CORDB, LL_INFO100000, - "CordbReferenceValue - SetValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(void* pFrom) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - SetValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbReferenceValue::IsNull(BOOL *pbNull) { - if (m_debuggerId == -1) - *pbNull = true; - LOG((LF_CORDB, LL_INFO1000000, - "CordbReferenceValue - IsNull - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbReferenceValue::IsNull(BOOL* pbNull) +{ + if (m_debuggerId == -1) + *pbNull = true; + LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - IsNull - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetValue(CORDB_ADDRESS *pValue) { - if (m_debuggerId == -1) - *pValue = NULL; - else - *pValue = (CORDB_ADDRESS)&m_debuggerId; - LOG((LF_CORDB, LL_INFO1000000, - "CordbReferenceValue - GetValue - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetValue(CORDB_ADDRESS* pValue) +{ + if (m_debuggerId == -1) + *pValue = NULL; + else + *pValue = (CORDB_ADDRESS)&m_debuggerId; + LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetValue - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(CORDB_ADDRESS value) { - LOG((LF_CORDB, LL_INFO100000, - "CordbReferenceValue - SetValue CORDB_ADDRESS - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbReferenceValue::SetValue(CORDB_ADDRESS value) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - SetValue CORDB_ADDRESS - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::Dereference(ICorDebugValue **ppValue) { - if (m_debuggerId == -1) - return CORDBG_E_BAD_REFERENCE_VALUE; - if (m_type == ELEMENT_TYPE_SZARRAY || m_type == ELEMENT_TYPE_ARRAY) { - CordbArrayValue *objectValue = - new CordbArrayValue(conn, m_pCordbType, m_debuggerId, m_pClass); - objectValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); - } else { - CordbObjectValue *objectValue = - new CordbObjectValue(conn, m_type, m_debuggerId, m_pClass); - objectValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); - } - LOG((LF_CORDB, LL_INFO1000000, - "CordbReferenceValue - Dereference - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbReferenceValue::Dereference(ICorDebugValue** ppValue) +{ + if (m_debuggerId == -1) + return CORDBG_E_BAD_REFERENCE_VALUE; + if (m_type == ELEMENT_TYPE_SZARRAY || m_type == ELEMENT_TYPE_ARRAY) + { + CordbArrayValue* objectValue = new CordbArrayValue(conn, m_pCordbType, m_debuggerId, m_pClass); + objectValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + } + else + { + CordbObjectValue* objectValue = new CordbObjectValue(conn, m_type, m_debuggerId, m_pClass); + objectValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + } + LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - Dereference - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbReferenceValue::DereferenceStrong(ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbReferenceValue - DereferenceStrong - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbReferenceValue::DereferenceStrong(ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbReferenceValue - DereferenceStrong - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +CordbReferenceValue::CordbReferenceValue( + Connection* conn, CorElementType type, int object_id, CordbClass* klass, CordbType* cordbType) + : CordbBaseMono(conn) +{ + this->m_type = type; + this->m_debuggerId = object_id; + this->conn = conn; + this->m_pClass = klass; + this->m_pCordbType = cordbType; + if (cordbType) + cordbType->InternalAddRef(); + if (klass) + klass->InternalAddRef(); +} + +CordbReferenceValue::~CordbReferenceValue() +{ + if (m_pCordbType) + m_pCordbType->InternalRelease(); + if (m_pClass) + m_pClass->InternalRelease(); +} + +CordbObjectValue::CordbObjectValue(Connection* conn, CorElementType type, int object_id, CordbClass* klass) + : CordbBaseMono(conn) +{ + this->m_type = type; + this->m_debuggerId = object_id; + this->m_pClass = klass; + if (klass) + klass->InternalAddRef(); + m_pCordbType = NULL; +} + +CordbObjectValue::~CordbObjectValue() +{ + if (m_pClass) + m_pClass->InternalRelease(); + if (m_pCordbType) + m_pCordbType->InternalRelease(); +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetType(CorElementType* pType) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetType - IMPLEMENTED\n")); + *pType = m_type; + return S_OK; } -CordbReferenceValue::CordbReferenceValue(Connection *conn, CorElementType type, - int object_id, CordbClass *klass, - CordbType *cordbType) - : CordbBaseMono(conn) { - this->m_type = type; - this->m_debuggerId = object_id; - this->conn = conn; - this->m_pClass = klass; - this->m_pCordbType = cordbType; - if (cordbType) - cordbType->InternalAddRef(); - if (klass) - klass->InternalAddRef(); +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize(ULONG32* pSize) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetSize - NOT IMPLEMENTED\n")); + *pSize = 10; + return S_OK; } -CordbReferenceValue::~CordbReferenceValue() { - if (m_pCordbType) - m_pCordbType->InternalRelease(); - if (m_pClass) - m_pClass->InternalRelease(); +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetAddress(CORDB_ADDRESS* pAddress) +{ + *pAddress = (CORDB_ADDRESS)&m_debuggerId; + LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetAddress - IMPLEMENTED\n")); + return S_OK; } -CordbObjectValue::CordbObjectValue(Connection *conn, CorElementType type, - int object_id, CordbClass *klass) - : CordbBaseMono(conn) { - this->m_type = type; - this->m_debuggerId = object_id; - this->m_pClass = klass; - if (klass) - klass->InternalAddRef(); - m_pCordbType = NULL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - CreateBreakpoint - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -CordbObjectValue::~CordbObjectValue() { - if (m_pClass) - m_pClass->InternalRelease(); - if (m_pCordbType) - m_pCordbType->InternalRelease(); +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetExactType(ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetExactType - IMPLEMENTED\n")); + if (m_pCordbType == NULL) + { + m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType->InternalAddRef(); + } + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetType(CorElementType *pType) { - LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetType - IMPLEMENTED\n")); - *pType = m_type; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize64(ULONG64* pSize) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetSize64 - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize(ULONG32 *pSize) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetSize - NOT IMPLEMENTED\n")); - *pSize = 10; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetValue(void* pTo) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::GetAddress(CORDB_ADDRESS *pAddress) { - *pAddress = (CORDB_ADDRESS)&m_debuggerId; - LOG((LF_CORDB, LL_INFO1000000, - "CordbObjectValue - GetAddress - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbObjectValue::SetValue(void* pFrom) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - SetValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - CreateBreakpoint - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethodAndType(mdMemberRef memberRef, + ICorDebugFunction** ppFunction, + ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::GetExactType(ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbObjectValue - GetExactType - IMPLEMENTED\n")); - if (m_pCordbType == NULL) { - m_pCordbType = new CordbType(m_type, conn, m_pClass); - m_pCordbType->InternalAddRef(); - } - m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32* pcchString) +{ + if (m_debuggerId == -1) + return S_OK; + if (m_type == ELEMENT_TYPE_STRING) + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + *pcchString = (ULONG32)m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); + return S_OK; + } + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetSize64(ULONG64 *pSize) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetSize64 - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]) +{ + if (m_debuggerId == -1) + return S_OK; + if (m_type == ELEMENT_TYPE_STRING) + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_VALUE, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + *pcchString = cchString; + int use_utf16 = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + if (use_utf16) + { + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n")); + } + else + { + char* value = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetString - IMPLEMENTED\n")); + if (cchString >= strlen(value)) + { + MultiByteToWideChar(CP_UTF8, 0, value, -1, szString, cchString); + *pcchString = cchString; + } + free(value); + } + return S_OK; + } + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetValue(void *pTo) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - CreateHandle - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::SetValue(void *pFrom) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - SetValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetThreadOwningMonitorLock(ICorDebugThread** ppThread, + DWORD* pAcquisitionCount) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethodAndType( - mdMemberRef memberRef, ICorDebugFunction **ppFunction, - ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetMonitorEventWaitList(ICorDebugThreadEnum** ppThreadEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32 *pcchString) { - if (m_debuggerId == -1) - return S_OK; - if (m_type == ELEMENT_TYPE_STRING) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); +HRESULT STDMETHODCALLTYPE +CordbObjectValue::EnumerateExceptionCallStack(ICorDebugExceptionObjectCallStackEnum** ppCallStackEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, - MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetCachedInterfaceTypes(BOOL bIInspectableOnly, + ICorDebugTypeEnum** ppInterfacesEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - ReceivedReplyPacket *received_reply_packet = - conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetCachedInterfacePointers(BOOL bIInspectableOnly, + ULONG32 celt, + ULONG32* pcEltFetched, + CORDB_ADDRESS* ptrs) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - *pcchString = - (ULONG32)m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); - return S_OK; - } - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetTarget(ICorDebugReferenceValue** ppObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetTarget - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, - ULONG32 *pcchString, - WCHAR szString[]) { - if (m_debuggerId == -1) - return S_OK; - if (m_type == ELEMENT_TYPE_STRING) { +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFunction(ICorDebugFunction** ppFunction) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetFunction - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetClass(ICorDebugClass** ppClass) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetClass - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue(ICorDebugClass* pClass, + mdFieldDef fieldDef, + ICorDebugValue** ppValue) +{ + + LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetFieldValue - IMPLEMENTED\n")); + if (m_debuggerId == -1) + return S_FALSE; + MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + m_dbgprot_buffer_add_int(&localbuf, fieldDef); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, - MDBGPROT_CMD_STRING_REF_GET_VALUE, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = - conn->GetReplyWithError(cmdId); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - - *pcchString = cchString; - int use_utf16 = - m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - if (use_utf16) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n")); - } else { - char *value = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - LOG((LF_CORDB, LL_INFO1000000, - "CordbObjectValue - GetString - IMPLEMENTED\n")); - if (cchString >= strlen(value)) { - MultiByteToWideChar(CP_UTF8, 0, value, -1, szString, cchString); - *pcchString = cchString; - } - free(value); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + return CreateCordbValue(conn, pReply, ppValue); +} + +int CordbObjectValue::GetTypeSize(int type) +{ + switch (type) + { + case ELEMENT_TYPE_VOID: + return 0; + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + return 1; + break; + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + return 2; + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: + return 4; + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: + return 8; } - return S_OK; - } - return E_NOTIMPL; + return 0; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateHandle( - CorDebugHandleType type, ICorDebugHandleValue **ppHandle) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - CreateHandle - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT CordbObjectValue::CreateCordbValue(Connection* conn, MdbgProtBuffer* pReply, ICorDebugValue** ppValue) +{ + CorElementType type = (CorElementType)m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + CordbContent value; + + if ((MdbgProtValueTypeId)type == MDBGPROT_VALUE_TYPE_ID_NULL) + { + CorElementType type = (CorElementType)m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + if (type == ELEMENT_TYPE_CLASS || type == ELEMENT_TYPE_STRING) + { + int klass_id = (CorElementType)m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, klass_id); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + char* namespace_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_name_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + + CordbClass* klass = new CordbClass(conn, token, module_id); + CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass); + refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); + } + if (type == ELEMENT_TYPE_SZARRAY) + { + CordbClass* klass = NULL; + int type_id = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + if (type_id == ELEMENT_TYPE_CLASS) + { + int klass_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, klass_id); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + char* namespace_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_name_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + klass = new CordbClass(conn, token, module_id); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); + } + CordbType* cordbtype = new CordbType(type, conn, NULL, new CordbType((CorElementType)type_id, conn, klass)); + CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass, cordbtype); + refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + } + return S_OK; + } + + switch (type) + { + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + value.booleanValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + break; + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + value.charValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + break; + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: + value.intValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + break; + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: + value.longValue = m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); + break; + case ELEMENT_TYPE_CLASS: + case ELEMENT_TYPE_SZARRAY: + case ELEMENT_TYPE_STRING: + { + int object_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, object_id); + refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + return S_OK; + } + default: + LOG((LF_CORDB, LL_INFO100000, "default value - %d", type)); + return S_FALSE; + } + + *ppValue = new CordbValue(conn, type, value, GetTypeSize(type)); + (*ppValue)->AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetThreadOwningMonitorLock( - ICorDebugThread **ppThread, DWORD *pAcquisitionCount) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetVirtualMethod - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetContext(ICorDebugContext** ppContext) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetContext - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::EnumerateExceptionCallStack( - ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::IsValueClass(BOOL* pbIsValueClass) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - IsValueClass - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetCachedInterfaceTypes( - BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::GetManagedCopy(IUnknown** ppObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetManagedCopy - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetCachedInterfacePointers( - BOOL bIInspectableOnly, ULONG32 celt, ULONG32 *pcEltFetched, - CORDB_ADDRESS *ptrs) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::SetFromManagedCopy(IUnknown* pObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - SetFromManagedCopy - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::GetTarget(ICorDebugReferenceValue **ppObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetTarget - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::IsValid(BOOL* pbValid) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - IsValid - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::GetFunction(ICorDebugFunction **ppFunction) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetFunction - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateRelocBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetClass(ICorDebugClass **ppClass) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetClass - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbObjectValue::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugValue) + { + *pInterface = static_cast(static_cast(this)); + } + else if (id == IID_ICorDebugValue2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugValue3) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugObjectValue) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugObjectValue2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugGenericValue) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugHeapValue) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugHeapValue2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugHeapValue3) + { + *pInterface = static_cast(this); + } + else if ((id == IID_ICorDebugStringValue) && (m_type == ELEMENT_TYPE_STRING)) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue( - ICorDebugClass *pClass, mdFieldDef fieldDef, ICorDebugValue **ppValue) { +CordbArrayValue::CordbArrayValue(Connection* conn, CordbType* type, int object_id, CordbClass* klass) + : CordbBaseMono(conn) +{ + this->m_pCordbType = type; + this->m_debuggerId = object_id; + this->m_pClass = klass; + if (klass) + klass->InternalAddRef(); + if (m_pCordbType) + m_pCordbType->InternalAddRef(); +} - LOG((LF_CORDB, LL_INFO1000000, - "CordbObjectValue - GetFieldValue - IMPLEMENTED\n")); - if (m_debuggerId == -1) - return S_FALSE; +CordbArrayValue::~CordbArrayValue() +{ + if (m_pClass) + m_pClass->InternalRelease(); + if (m_pCordbType) + m_pCordbType->InternalRelease(); +} +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetClass(ICorDebugClass** ppClass) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetClass - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - m_dbgprot_buffer_add_int(&localbuf, fieldDef); +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetFieldValue(ICorDebugClass* pClass, + mdFieldDef fieldDef, + ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetFieldValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - int cmdId = - conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, - MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); - m_dbgprot_buffer_free(&localbuf); +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetVirtualMethod - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetContext(ICorDebugContext** ppContext) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetContext - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - return CreateCordbValue(conn, pReply, ppValue); +HRESULT STDMETHODCALLTYPE CordbArrayValue::IsValueClass(BOOL* pbIsValueClass) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - IsValueClass - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -int CordbObjectValue::GetTypeSize(int type) { - switch (type) { - case ELEMENT_TYPE_VOID: - return 0; - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_I1: - case ELEMENT_TYPE_U1: - return 1; - break; - case ELEMENT_TYPE_CHAR: - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - return 2; - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - case ELEMENT_TYPE_R4: - return 4; - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - case ELEMENT_TYPE_R8: - return 8; - } - return 0; -} - -HRESULT CordbObjectValue::CreateCordbValue(Connection *conn, - MdbgProtBuffer *pReply, - ICorDebugValue **ppValue) { - CorElementType type = (CorElementType)m_dbgprot_decode_byte( - pReply->p, &pReply->p, pReply->end); - CordbContent value; - - if ((MdbgProtValueTypeId)type == MDBGPROT_VALUE_TYPE_ID_NULL) { - CorElementType type = (CorElementType)m_dbgprot_decode_byte( - pReply->p, &pReply->p, pReply->end); - if (type == ELEMENT_TYPE_CLASS || type == ELEMENT_TYPE_STRING) { - int klass_id = (CorElementType)m_dbgprot_decode_id( - pReply->p, &pReply->p, pReply->end); - - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, klass_id); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, - MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = - conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - char *namespace_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char *class_name_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char *class_fullname_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - int assembly_id = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int module_id = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - - CordbClass *klass = new CordbClass(conn, token, module_id); - CordbReferenceValue *refValue = - new CordbReferenceValue(conn, type, -1, klass); - refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); - free(namespace_str); - free(class_name_str); - free(class_fullname_str); - } - if (type == ELEMENT_TYPE_SZARRAY) { - CordbClass *klass = NULL; - int type_id = - m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - if (type_id == ELEMENT_TYPE_CLASS) { - int klass_id = - m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetManagedCopy(IUnknown** ppObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetManagedCopy - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, klass_id); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, - MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = - conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - char *namespace_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char *class_name_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char *class_fullname_str = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - int assembly_id = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int module_id = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id3 = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id2 = - m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - klass = new CordbClass(conn, token, module_id); - free(namespace_str); - free(class_name_str); - free(class_fullname_str); - } - CordbType *cordbtype = - new CordbType(type, conn, NULL, - new CordbType((CorElementType)type_id, conn, klass)); - CordbReferenceValue *refValue = - new CordbReferenceValue(conn, type, -1, klass, cordbtype); - refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); - } - return S_OK; - } - - switch (type) { - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_I1: - case ELEMENT_TYPE_U1: - value.booleanValue = - m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; - case ELEMENT_TYPE_CHAR: - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - value.charValue = - m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - case ELEMENT_TYPE_R4: - value.intValue = - m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - case ELEMENT_TYPE_R8: - value.longValue = - m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); - break; - case ELEMENT_TYPE_CLASS: - case ELEMENT_TYPE_SZARRAY: - case ELEMENT_TYPE_STRING: { - int object_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - CordbReferenceValue *refValue = - new CordbReferenceValue(conn, type, object_id); - refValue->QueryInterface(IID_ICorDebugValue, (void **)ppValue); - return S_OK; - } - default: - LOG((LF_CORDB, LL_INFO100000, "default value - %d", type)); - return S_FALSE; - } +HRESULT STDMETHODCALLTYPE CordbArrayValue::SetFromManagedCopy(IUnknown* pObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - SetFromManagedCopy - NOT IMPLEMENTED\n")); + return E_NOTIMPL; +} - *ppValue = new CordbValue(conn, type, value, GetTypeSize(type)); - (*ppValue)->AddRef(); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetType(CorElementType* pType) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetType - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethod( - mdMemberRef memberRef, ICorDebugFunction **ppFunction) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetVirtualMethod - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize(ULONG32* pSize) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetSize - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::GetContext(ICorDebugContext **ppContext) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetContext - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetAddress(CORDB_ADDRESS* pAddress) +{ + *pAddress = (CORDB_ADDRESS)&m_debuggerId; + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetAddress - IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbObjectValue::IsValueClass(BOOL *pbIsValueClass) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - IsValueClass - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - CreateBreakpoint - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::GetManagedCopy(IUnknown **ppObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - GetManagedCopy - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::QueryInterface(REFIID id, void** pInterface) +{ + if (id == IID_ICorDebugValue) + { + *pInterface = static_cast(static_cast(this)); + } + else if (id == IID_ICorDebugValue2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugValue3) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugArrayValue) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugGenericValue) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugHeapValue2) + { + *pInterface = static_cast(this); + } + else if (id == IID_ICorDebugHeapValue3) + { + *pInterface = static_cast(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast(static_cast(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + AddRef(); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbObjectValue::SetFromManagedCopy(IUnknown *pObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - SetFromManagedCopy - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbObjectValue::IsValid(BOOL *pbValid) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - IsValid - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateRelocBreakpoint( - ICorDebugValueBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbObjectValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbObjectValue::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugValue) { - *pInterface = static_cast( - static_cast(this)); - } else if (id == IID_ICorDebugValue2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugValue3) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugObjectValue) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugObjectValue2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugGenericValue) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugHeapValue) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugHeapValue2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugHeapValue3) { - *pInterface = static_cast(this); - } else if ((id == IID_ICorDebugStringValue) && - (m_type == ELEMENT_TYPE_STRING)) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = - static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -CordbArrayValue::CordbArrayValue(Connection *conn, CordbType *type, - int object_id, CordbClass *klass) - : CordbBaseMono(conn) { - this->m_pCordbType = type; - this->m_debuggerId = object_id; - this->m_pClass = klass; - if (klass) - klass->InternalAddRef(); - if (m_pCordbType) - m_pCordbType->InternalAddRef(); +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethodAndType(mdMemberRef memberRef, + ICorDebugFunction** ppFunction, + ICorDebugType** ppType) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -CordbArrayValue::~CordbArrayValue() { - if (m_pClass) - m_pClass->InternalRelease(); - if (m_pCordbType) - m_pCordbType->InternalRelease(); +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetValue(void* pTo) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetClass(ICorDebugClass **ppClass) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetClass - NOT IMPLEMENTED\n")); - return E_NOTIMPL; + +HRESULT STDMETHODCALLTYPE CordbArrayValue::SetValue(void* pFrom) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - SetValue - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetFieldValue( - ICorDebugClass *pClass, mdFieldDef fieldDef, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetFieldValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetLength(ULONG32* pcchString) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetLength - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethod( - mdMemberRef memberRef, ICorDebugFunction **ppFunction) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetVirtualMethod - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetString - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbArrayValue::GetContext(ICorDebugContext **ppContext) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetContext - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::IsValid(BOOL* pbValid) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - IsValid - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::IsValueClass(BOOL *pbIsValueClass) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - IsValueClass - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateRelocBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetManagedCopy(IUnknown **ppObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetManagedCopy - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetExactType(ICorDebugType** ppType) +{ + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetExactType - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbArrayValue::SetFromManagedCopy(IUnknown *pObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - SetFromManagedCopy - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize64(ULONG64* pSize) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetSize64 - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetType(CorElementType *pType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetType - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - CreateHandle - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize(ULONG32 *pSize) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetSize - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetThreadOwningMonitorLock(ICorDebugThread** ppThread, + DWORD* pAcquisitionCount) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetAddress(CORDB_ADDRESS *pAddress) { - *pAddress = (CORDB_ADDRESS)&m_debuggerId; - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetAddress - IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetMonitorEventWaitList(ICorDebugThreadEnum** ppThreadEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE -CordbArrayValue::CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - CreateBreakpoint - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::QueryInterface(REFIID id, - void **pInterface) { - if (id == IID_ICorDebugValue) { - *pInterface = - static_cast(static_cast(this)); - } else if (id == IID_ICorDebugValue2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugValue3) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugArrayValue) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugGenericValue) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugHeapValue2) { - *pInterface = static_cast(this); - } else if (id == IID_ICorDebugHeapValue3) { - *pInterface = static_cast(this); - } else if (id == IID_IUnknown) { - *pInterface = - static_cast(static_cast(this)); - } else { - *pInterface = NULL; - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetVirtualMethodAndType( - mdMemberRef memberRef, ICorDebugFunction **ppFunction, - ICorDebugType **ppType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetVirtualMethodAndType - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetValue(void *pTo) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::SetValue(void *pFrom) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - SetValue - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetLength(ULONG32 *pcchString) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetLength - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetString(ULONG32 cchString, - ULONG32 *pcchString, - WCHAR szString[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetString - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::IsValid(BOOL *pbValid) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - IsValid - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateRelocBreakpoint( - ICorDebugValueBreakpoint **ppBreakpoint) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - CreateRelocBreakpoint - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +CordbArrayValue::EnumerateExceptionCallStack(ICorDebugExceptionObjectCallStackEnum** ppCallStackEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbArrayValue::GetExactType(ICorDebugType **ppType) { - m_pCordbType->QueryInterface(IID_ICorDebugType, (void **)ppType); - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetExactType - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCachedInterfaceTypes(BOOL bIInspectableOnly, + ICorDebugTypeEnum** ppInterfacesEnum) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetSize64(ULONG64 *pSize) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetSize64 - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCachedInterfacePointers(BOOL bIInspectableOnly, + ULONG32 celt, + ULONG32* pcEltFetched, + CORDB_ADDRESS* ptrs) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::CreateHandle( - CorDebugHandleType type, ICorDebugHandleValue **ppHandle) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - CreateHandle - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetTarget(ICorDebugReferenceValue** ppObject) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetTarget - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetThreadOwningMonitorLock( - ICorDebugThread **ppThread, DWORD *pAcquisitionCount) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetThreadOwningMonitorLock - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetFunction(ICorDebugFunction** ppFunction) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetFunction - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbArrayValue::GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetMonitorEventWaitList - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElementType(CorElementType* pType) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetElementType - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::EnumerateExceptionCallStack( - ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - EnumerateExceptionCallStack - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetRank(ULONG32* pnRank) +{ + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetRank - IMPLEMENTED\n")); + *pnRank = rank; + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCachedInterfaceTypes( - BOOL bIInspectableOnly, ICorDebugTypeEnum **ppInterfacesEnum) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetCachedInterfaceTypes - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCount(ULONG32* pnCount) +{ + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_nCount = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetCount - IMPLEMENTED\n")); + *pnCount = m_nCount; + return S_OK; } -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCachedInterfacePointers( - BOOL bIInspectableOnly, ULONG32 celt, ULONG32 *pcEltFetched, - CORDB_ADDRESS *ptrs) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetCachedInterfacePointers - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetDimensions(ULONG32 cdim, ULONG32 dims[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetDimensions - IMPLEMENTED\n")); + dims[0] = m_nCount; + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbArrayValue::GetTarget(ICorDebugReferenceValue **ppObject) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetTarget - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::HasBaseIndicies(BOOL* pbHasBaseIndicies) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - HasBaseIndicies - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbArrayValue::GetFunction(ICorDebugFunction **ppFunction) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetFunction - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetBaseIndicies - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE -CordbArrayValue::GetElementType(CorElementType *pType) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetElementType - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetRank(ULONG32 *pnRank) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, - MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetRank - IMPLEMENTED\n")); - *pnRank = rank; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCount(ULONG32 *pnCount) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, - MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_nCount = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetCount - IMPLEMENTED\n")); - *pnCount = m_nCount; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetDimensions(ULONG32 cdim, - ULONG32 dims[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetDimensions - IMPLEMENTED\n")); - dims[0] = m_nCount; - return S_OK; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement(ULONG32 cdim, ULONG32 indices[], ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetElement - IMPLEMENTED\n")); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + m_dbgprot_buffer_add_int(&localbuf, indices[cdim - 1]); + m_dbgprot_buffer_add_int(&localbuf, 1); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); + return S_OK; } -HRESULT STDMETHODCALLTYPE -CordbArrayValue::HasBaseIndicies(BOOL *pbHasBaseIndicies) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - HasBaseIndicies - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetBaseIndicies(ULONG32 cdim, - ULONG32 indicies[]) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetBaseIndicies - NOT IMPLEMENTED\n")); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement( - ULONG32 cdim, ULONG32 indices[], ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO1000000, - "CordbArrayValue - GetElement - IMPLEMENTED\n")); - - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - m_dbgprot_buffer_add_int(&localbuf, indices[cdim - 1]); - m_dbgprot_buffer_add_int(&localbuf, 1); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, - MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); - CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElementAtPosition( - ULONG32 nPosition, ICorDebugValue **ppValue) { - LOG((LF_CORDB, LL_INFO100000, - "CordbArrayValue - GetElementAtPosition - NOT IMPLEMENTED\n")); - return E_NOTIMPL; +HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElementAtPosition(ULONG32 nPosition, ICorDebugValue** ppValue) +{ + LOG((LF_CORDB, LL_INFO100000, "CordbArrayValue - GetElementAtPosition - NOT IMPLEMENTED\n")); + return E_NOTIMPL; } diff --git a/src/mono/dbi/cordb-value.h b/src/mono/dbi/cordb-value.h index b43fc753ea5524..81feef882ae69e 100644 --- a/src/mono/dbi/cordb-value.h +++ b/src/mono/dbi/cordb-value.h @@ -10,76 +10,93 @@ #include #include -union CordbContent { - int16_t charValue; - int8_t booleanValue; - int32_t intValue; - int64_t longValue; - void *pointerValue; +union CordbContent +{ + int16_t charValue; + int8_t booleanValue; + int32_t intValue; + int64_t longValue; + void* pointerValue; }; -class CordbValue : public CordbBaseMono, - public ICorDebugValue2, - public ICorDebugValue3, - public ICorDebugGenericValue { - CorElementType m_type; - CordbContent m_value; - int m_size; - CordbType *m_pType; +class CordbValue : public CordbBaseMono, public ICorDebugValue2, public ICorDebugValue3, public ICorDebugGenericValue +{ + CorElementType m_type; + CordbContent m_value; + int m_size; + CordbType* m_pType; public: - CordbValue(Connection *conn, CorElementType type, CordbContent value, - int size); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbValue"; } - ~CordbValue(); - HRESULT GetType(CorElementType *pType); - HRESULT GetSize(ULONG32 *pSize); - HRESULT GetAddress(CORDB_ADDRESS *pAddress); - HRESULT - CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT QueryInterface(REFIID riid, void **ppvObject); - - HRESULT GetExactType(ICorDebugType **ppType); - HRESULT GetSize64(ULONG64 *pSize); - HRESULT GetValue(void *pTo); - HRESULT SetValue(void *pFrom); + CordbValue(Connection* conn, CorElementType type, CordbContent value, int size); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbValue"; + } + ~CordbValue(); + HRESULT GetType(CorElementType* pType); + HRESULT GetSize(ULONG32* pSize); + HRESULT GetAddress(CORDB_ADDRESS* pAddress); + HRESULT + CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT QueryInterface(REFIID riid, void** ppvObject); + + HRESULT GetExactType(ICorDebugType** ppType); + HRESULT GetSize64(ULONG64* pSize); + HRESULT GetValue(void* pTo); + HRESULT SetValue(void* pFrom); }; class CordbReferenceValue : public CordbBaseMono, public ICorDebugReferenceValue, public ICorDebugValue2, public ICorDebugValue3, - public ICorDebugGenericValue { - CorElementType m_type; - int m_debuggerId; - CordbClass *m_pClass; - CordbType *m_pCordbType; + public ICorDebugGenericValue +{ + CorElementType m_type; + int m_debuggerId; + CordbClass* m_pClass; + CordbType* m_pCordbType; public: - CordbReferenceValue(Connection *conn, CorElementType type, int object_id, - CordbClass *klass = NULL, CordbType *cordbType = NULL); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbReferenceValue"; } - ~CordbReferenceValue(); - HRESULT GetType(CorElementType *pType); - HRESULT GetSize(ULONG32 *pSize); - HRESULT GetAddress(CORDB_ADDRESS *pAddress); - HRESULT - CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT QueryInterface(REFIID riid, void **ppvObject); - - HRESULT GetExactType(ICorDebugType **ppType); - HRESULT GetSize64(ULONG64 *pSize); - HRESULT GetValue(void *pTo); - HRESULT SetValue(void *pFrom); - HRESULT IsNull(BOOL *pbNull); - HRESULT GetValue(CORDB_ADDRESS *pValue); - HRESULT SetValue(CORDB_ADDRESS value); - HRESULT Dereference(ICorDebugValue **ppValue); - HRESULT DereferenceStrong(ICorDebugValue **ppValue); + CordbReferenceValue( + Connection* conn, CorElementType type, int object_id, CordbClass* klass = NULL, CordbType* cordbType = NULL); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbReferenceValue"; + } + ~CordbReferenceValue(); + HRESULT GetType(CorElementType* pType); + HRESULT GetSize(ULONG32* pSize); + HRESULT GetAddress(CORDB_ADDRESS* pAddress); + HRESULT + CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT QueryInterface(REFIID riid, void** ppvObject); + + HRESULT GetExactType(ICorDebugType** ppType); + HRESULT GetSize64(ULONG64* pSize); + HRESULT GetValue(void* pTo); + HRESULT SetValue(void* pFrom); + HRESULT IsNull(BOOL* pbNull); + HRESULT GetValue(CORDB_ADDRESS* pValue); + HRESULT SetValue(CORDB_ADDRESS value); + HRESULT Dereference(ICorDebugValue** ppValue); + HRESULT DereferenceStrong(ICorDebugValue** ppValue); }; class CordbObjectValue : public CordbBaseMono, @@ -93,65 +110,67 @@ class CordbObjectValue : public CordbBaseMono, public ICorDebugHeapValue3, public ICorDebugExceptionObjectValue, public ICorDebugComObjectValue, - public ICorDebugDelegateObjectValue { - CorElementType m_type; - int m_debuggerId; - CordbClass *m_pClass; - CordbType *m_pCordbType; + public ICorDebugDelegateObjectValue +{ + CorElementType m_type; + int m_debuggerId; + CordbClass* m_pClass; + CordbType* m_pCordbType; public: - CordbObjectValue(Connection *conn, CorElementType type, int object_id, - CordbClass *klass); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbObjectValue"; } - ~CordbObjectValue(); - HRESULT GetClass(ICorDebugClass **ppClass); - HRESULT GetFieldValue(ICorDebugClass *pClass, mdFieldDef fieldDef, - ICorDebugValue **ppValue); - static HRESULT CreateCordbValue(Connection *conn, MdbgProtBuffer *pReply, - ICorDebugValue **ppValue); - static int GetTypeSize(int type); - HRESULT GetVirtualMethod(mdMemberRef memberRef, - ICorDebugFunction **ppFunction); - HRESULT GetContext(ICorDebugContext **ppContext); - HRESULT IsValueClass(BOOL *pbIsValueClass); - HRESULT GetManagedCopy(IUnknown **ppObject); - HRESULT SetFromManagedCopy(IUnknown *pObject); - HRESULT IsValid(BOOL *pbValid); - HRESULT - CreateRelocBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT GetType(CorElementType *pType); - HRESULT GetSize(ULONG32 *pSize); - HRESULT GetAddress(CORDB_ADDRESS *pAddress); - HRESULT - CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT QueryInterface(REFIID riid, void **ppvObject); - - HRESULT GetExactType(ICorDebugType **ppType); - HRESULT GetSize64(ULONG64 *pSize); - HRESULT GetValue(void *pTo); - HRESULT SetValue(void *pFrom); - HRESULT - GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction **ppFunction, - ICorDebugType **ppType); - HRESULT GetLength(ULONG32 *pcchString); - HRESULT GetString(ULONG32 cchString, ULONG32 *pcchString, WCHAR szString[]); - HRESULT CreateHandle(CorDebugHandleType type, - ICorDebugHandleValue **ppHandle); - HRESULT GetThreadOwningMonitorLock(ICorDebugThread **ppThread, - DWORD *pAcquisitionCount); - HRESULT - GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum); - HRESULT EnumerateExceptionCallStack( - ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum); - HRESULT GetCachedInterfaceTypes(BOOL bIInspectableOnly, - ICorDebugTypeEnum **ppInterfacesEnum); - HRESULT GetCachedInterfacePointers(BOOL bIInspectableOnly, ULONG32 celt, - ULONG32 *pcEltFetched, - CORDB_ADDRESS *ptrs); - HRESULT GetTarget(ICorDebugReferenceValue **ppObject); - HRESULT GetFunction(ICorDebugFunction **ppFunction); + CordbObjectValue(Connection* conn, CorElementType type, int object_id, CordbClass* klass); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbObjectValue"; + } + ~CordbObjectValue(); + HRESULT GetClass(ICorDebugClass** ppClass); + HRESULT GetFieldValue(ICorDebugClass* pClass, mdFieldDef fieldDef, ICorDebugValue** ppValue); + static HRESULT CreateCordbValue(Connection* conn, MdbgProtBuffer* pReply, ICorDebugValue** ppValue); + static int GetTypeSize(int type); + HRESULT GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction); + HRESULT GetContext(ICorDebugContext** ppContext); + HRESULT IsValueClass(BOOL* pbIsValueClass); + HRESULT GetManagedCopy(IUnknown** ppObject); + HRESULT SetFromManagedCopy(IUnknown* pObject); + HRESULT IsValid(BOOL* pbValid); + HRESULT + CreateRelocBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT GetType(CorElementType* pType); + HRESULT GetSize(ULONG32* pSize); + HRESULT GetAddress(CORDB_ADDRESS* pAddress); + HRESULT + CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT QueryInterface(REFIID riid, void** ppvObject); + + HRESULT GetExactType(ICorDebugType** ppType); + HRESULT GetSize64(ULONG64* pSize); + HRESULT GetValue(void* pTo); + HRESULT SetValue(void* pFrom); + HRESULT + GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction** ppFunction, ICorDebugType** ppType); + HRESULT GetLength(ULONG32* pcchString); + HRESULT GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]); + HRESULT CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle); + HRESULT GetThreadOwningMonitorLock(ICorDebugThread** ppThread, DWORD* pAcquisitionCount); + HRESULT + GetMonitorEventWaitList(ICorDebugThreadEnum** ppThreadEnum); + HRESULT EnumerateExceptionCallStack(ICorDebugExceptionObjectCallStackEnum** ppCallStackEnum); + HRESULT GetCachedInterfaceTypes(BOOL bIInspectableOnly, ICorDebugTypeEnum** ppInterfacesEnum); + HRESULT GetCachedInterfacePointers(BOOL bIInspectableOnly, + ULONG32 celt, + ULONG32* pcEltFetched, + CORDB_ADDRESS* ptrs); + HRESULT GetTarget(ICorDebugReferenceValue** ppObject); + HRESULT GetFunction(ICorDebugFunction** ppFunction); }; class CordbArrayValue : public CordbBaseMono, @@ -166,70 +185,73 @@ class CordbArrayValue : public CordbBaseMono, public ICorDebugExceptionObjectValue, public ICorDebugComObjectValue, public ICorDebugDelegateObjectValue, - public ICorDebugArrayValue { - CordbType *m_pCordbType; - int m_debuggerId; - CordbClass *m_pClass; - int m_nCount; + public ICorDebugArrayValue +{ + CordbType* m_pCordbType; + int m_debuggerId; + CordbClass* m_pClass; + int m_nCount; public: - CordbArrayValue(Connection *conn, CordbType *type, int object_id, - CordbClass *klass); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "CordbArrayValue"; } - ~CordbArrayValue(); - HRESULT GetClass(ICorDebugClass **ppClass); - HRESULT GetFieldValue(ICorDebugClass *pClass, mdFieldDef fieldDef, - ICorDebugValue **ppValue); - HRESULT GetVirtualMethod(mdMemberRef memberRef, - ICorDebugFunction **ppFunction); - HRESULT GetContext(ICorDebugContext **ppContext); - HRESULT IsValueClass(BOOL *pbIsValueClass); - HRESULT GetManagedCopy(IUnknown **ppObject); - HRESULT SetFromManagedCopy(IUnknown *pObject); - HRESULT GetType(CorElementType *pType); - HRESULT GetSize(ULONG32 *pSize); - HRESULT GetAddress(CORDB_ADDRESS *pAddress); - HRESULT - CreateBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT QueryInterface(REFIID riid, void **ppvObject); - - HRESULT - GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction **ppFunction, - ICorDebugType **ppType); - HRESULT GetValue(void *pTo); - HRESULT SetValue(void *pFrom); - HRESULT GetLength(ULONG32 *pcchString); - HRESULT GetString(ULONG32 cchString, ULONG32 *pcchString, WCHAR szString[]); - HRESULT IsValid(BOOL *pbValid); - HRESULT - CreateRelocBreakpoint(ICorDebugValueBreakpoint **ppBreakpoint); - HRESULT GetExactType(ICorDebugType **ppType); - HRESULT GetSize64(ULONG64 *pSize); - HRESULT CreateHandle(CorDebugHandleType type, - ICorDebugHandleValue **ppHandle); - HRESULT GetThreadOwningMonitorLock(ICorDebugThread **ppThread, - DWORD *pAcquisitionCount); - HRESULT - GetMonitorEventWaitList(ICorDebugThreadEnum **ppThreadEnum); - HRESULT EnumerateExceptionCallStack( - ICorDebugExceptionObjectCallStackEnum **ppCallStackEnum); - HRESULT GetCachedInterfaceTypes(BOOL bIInspectableOnly, - ICorDebugTypeEnum **ppInterfacesEnum); - HRESULT GetCachedInterfacePointers(BOOL bIInspectableOnly, ULONG32 celt, - ULONG32 *pcEltFetched, - CORDB_ADDRESS *ptrs); - HRESULT GetTarget(ICorDebugReferenceValue **ppObject); - HRESULT GetFunction(ICorDebugFunction **ppFunction); - - HRESULT GetElementType(CorElementType *pType); - HRESULT GetRank(ULONG32 *pnRank); - HRESULT GetCount(ULONG32 *pnCount); - HRESULT GetDimensions(ULONG32 cdim, ULONG32 dims[]); - HRESULT HasBaseIndicies(BOOL *pbHasBaseIndicies); - HRESULT GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]); - HRESULT GetElement(ULONG32 cdim, ULONG32 indices[], ICorDebugValue **ppValue); - HRESULT GetElementAtPosition(ULONG32 nPosition, ICorDebugValue **ppValue); + CordbArrayValue(Connection* conn, CordbType* type, int object_id, CordbClass* klass); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "CordbArrayValue"; + } + ~CordbArrayValue(); + HRESULT GetClass(ICorDebugClass** ppClass); + HRESULT GetFieldValue(ICorDebugClass* pClass, mdFieldDef fieldDef, ICorDebugValue** ppValue); + HRESULT GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction); + HRESULT GetContext(ICorDebugContext** ppContext); + HRESULT IsValueClass(BOOL* pbIsValueClass); + HRESULT GetManagedCopy(IUnknown** ppObject); + HRESULT SetFromManagedCopy(IUnknown* pObject); + HRESULT GetType(CorElementType* pType); + HRESULT GetSize(ULONG32* pSize); + HRESULT GetAddress(CORDB_ADDRESS* pAddress); + HRESULT + CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT QueryInterface(REFIID riid, void** ppvObject); + + HRESULT + GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction** ppFunction, ICorDebugType** ppType); + HRESULT GetValue(void* pTo); + HRESULT SetValue(void* pFrom); + HRESULT GetLength(ULONG32* pcchString); + HRESULT GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]); + HRESULT IsValid(BOOL* pbValid); + HRESULT + CreateRelocBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT GetExactType(ICorDebugType** ppType); + HRESULT GetSize64(ULONG64* pSize); + HRESULT CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle); + HRESULT GetThreadOwningMonitorLock(ICorDebugThread** ppThread, DWORD* pAcquisitionCount); + HRESULT + GetMonitorEventWaitList(ICorDebugThreadEnum** ppThreadEnum); + HRESULT EnumerateExceptionCallStack(ICorDebugExceptionObjectCallStackEnum** ppCallStackEnum); + HRESULT GetCachedInterfaceTypes(BOOL bIInspectableOnly, ICorDebugTypeEnum** ppInterfacesEnum); + HRESULT GetCachedInterfacePointers(BOOL bIInspectableOnly, + ULONG32 celt, + ULONG32* pcEltFetched, + CORDB_ADDRESS* ptrs); + HRESULT GetTarget(ICorDebugReferenceValue** ppObject); + HRESULT GetFunction(ICorDebugFunction** ppFunction); + + HRESULT GetElementType(CorElementType* pType); + HRESULT GetRank(ULONG32* pnRank); + HRESULT GetCount(ULONG32* pnCount); + HRESULT GetDimensions(ULONG32 cdim, ULONG32 dims[]); + HRESULT HasBaseIndicies(BOOL* pbHasBaseIndicies); + HRESULT GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]); + HRESULT GetElement(ULONG32 cdim, ULONG32 indices[], ICorDebugValue** ppValue); + HRESULT GetElementAtPosition(ULONG32 nPosition, ICorDebugValue** ppValue); }; #endif diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 7561a5e5ed7233..40d3697ce3eea4 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -19,533 +19,597 @@ #define DEBUG_ADDRESS "127.0.0.1" #define DEBUG_PORT "4712" -MONO_API HRESULT CoreCLRCreateCordbObjectEx(int iDebuggerVersion, DWORD pid, - LPCWSTR lpApplicationGroupId, - HMODULE hmodTargetCLR, - void **ppCordb) { - LOG((LF_CORDB, LL_INFO100000, "CoreCLRCreateCordbObjectEx\n")); - *ppCordb = new Cordb(); - return S_OK; +MONO_API HRESULT CoreCLRCreateCordbObjectEx( + int iDebuggerVersion, DWORD pid, LPCWSTR lpApplicationGroupId, HMODULE hmodTargetCLR, void** ppCordb) +{ + LOG((LF_CORDB, LL_INFO100000, "CoreCLRCreateCordbObjectEx\n")); + *ppCordb = new Cordb(); + return S_OK; } -static void receive_thread(Connection *c) { c->Receive(); } +static void receive_thread(Connection* c) +{ + c->Receive(); +} -static void debugger_thread(void *m_pProcess) { - Connection *connection = new Connection( - (CordbProcess *)m_pProcess, ((CordbProcess *)m_pProcess)->GetCordb()); - ((CordbProcess *)m_pProcess)->SetConnection(connection); - connection->StartConnection(); - connection->TransportHandshake(); - connection->LoopSendReceive(); - connection->CloseConnection(); +static void debugger_thread(void* m_pProcess) +{ + Connection* connection = new Connection((CordbProcess*)m_pProcess, ((CordbProcess*)m_pProcess)->GetCordb()); + ((CordbProcess*)m_pProcess)->SetConnection(connection); + connection->StartConnection(); + connection->TransportHandshake(); + connection->LoopSendReceive(); + connection->CloseConnection(); } -HRESULT Cordb::Initialize(void) { - LOG((LF_CORDB, LL_INFO100000, "Cordb - Initialize - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT Cordb::Initialize(void) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - Initialize - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT Cordb::Terminate(void) { - LOG((LF_CORDB, LL_INFO100000, "Cordb - Terminate - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT Cordb::Terminate(void) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - Terminate - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT Cordb::SetManagedHandler(ICorDebugManagedCallback *pCallback) { - LOG((LF_CORDB, LL_INFO1000000, "Cordb - SetManagedHandler - IMPLEMENTED\n")); - this->m_pCallback = pCallback; - this->GetCallback()->AddRef(); - return S_OK; +HRESULT Cordb::SetManagedHandler(ICorDebugManagedCallback* pCallback) +{ + LOG((LF_CORDB, LL_INFO1000000, "Cordb - SetManagedHandler - IMPLEMENTED\n")); + this->m_pCallback = pCallback; + this->GetCallback()->AddRef(); + return S_OK; } -HRESULT Cordb::SetUnmanagedHandler(ICorDebugUnmanagedCallback *pCallback) { - LOG((LF_CORDB, LL_INFO100000, - "Cordb - SetUnmanagedHandler - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT Cordb::SetUnmanagedHandler(ICorDebugUnmanagedCallback* pCallback) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - SetUnmanagedHandler - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT Cordb::CreateProcess(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, DWORD dwCreationFlags, - PVOID lpEnvironment, LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation, +HRESULT Cordb::CreateProcess(LPCWSTR lpApplicationName, + LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + PVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, CorDebugCreateProcessFlags debuggingFlags, - ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO100000, "Cordb - CreateProcess - NOT IMPLEMENTED\n")); - return S_OK; + ICorDebugProcess** ppProcess) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - CreateProcess - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT Cordb::DebugActiveProcess(DWORD id, BOOL win32Attach, - ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO1000000, "Cordb - DebugActiveProcess - IMPLEMENTED\n")); - m_pProcess = new CordbProcess(this); - m_pProcess->InternalAddRef(); - m_pProcess->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); +HRESULT Cordb::DebugActiveProcess(DWORD id, BOOL win32Attach, ICorDebugProcess** ppProcess) +{ + LOG((LF_CORDB, LL_INFO1000000, "Cordb - DebugActiveProcess - IMPLEMENTED\n")); + m_pProcess = new CordbProcess(this); + m_pProcess->InternalAddRef(); + m_pProcess->QueryInterface(IID_ICorDebugProcess, (void**)ppProcess); - DWORD thread_id; - CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)debugger_thread, m_pProcess, 0, - &thread_id); - return S_OK; + DWORD thread_id; + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)debugger_thread, m_pProcess, 0, &thread_id); + return S_OK; } -HRESULT Cordb::EnumerateProcesses(ICorDebugProcessEnum **ppProcess) { - LOG((LF_CORDB, LL_INFO100000, - "Cordb - EnumerateProcesses - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT Cordb::EnumerateProcesses(ICorDebugProcessEnum** ppProcess) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - EnumerateProcesses - NOT IMPLEMENTED\n")); + return S_OK; } -HRESULT Cordb::GetProcess(DWORD dwProcessId, ICorDebugProcess **ppProcess) { - m_pProcess->QueryInterface(IID_ICorDebugProcess, (void **)ppProcess); - return S_OK; +HRESULT Cordb::GetProcess(DWORD dwProcessId, ICorDebugProcess** ppProcess) +{ + m_pProcess->QueryInterface(IID_ICorDebugProcess, (void**)ppProcess); + return S_OK; } -HRESULT Cordb::CanLaunchOrAttach(DWORD dwProcessId, - BOOL win32DebuggingEnabled) { - LOG((LF_CORDB, LL_INFO100000, - "Cordb - CanLaunchOrAttach - NOT IMPLEMENTED\n")); - return S_OK; +HRESULT Cordb::CanLaunchOrAttach(DWORD dwProcessId, BOOL win32DebuggingEnabled) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - CanLaunchOrAttach - NOT IMPLEMENTED\n")); + return S_OK; } -Cordb::Cordb() : CordbBaseMono(NULL) { - m_pCallback = NULL; - m_pSemReadWrite = new UTSemReadWrite(); +Cordb::Cordb() : CordbBaseMono(NULL) +{ + m_pCallback = NULL; + m_pSemReadWrite = new UTSemReadWrite(); #ifdef LOGGING - InitializeLogging(); + InitializeLogging(); #endif } -Cordb::~Cordb() { - this->GetCallback()->Release(); - m_pProcess->InternalRelease(); - delete m_pSemReadWrite; +Cordb::~Cordb() +{ + this->GetCallback()->Release(); + m_pProcess->InternalRelease(); + delete m_pSemReadWrite; #ifdef LOGGING - ShutdownLogging(); + ShutdownLogging(); #endif } HRESULT -Cordb::QueryInterface(REFIID riid, - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) { - LOG((LF_CORDB, LL_INFO100000, "Cordb - QueryInterface - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT Cordb::CreateProcessEx( - ICorDebugRemoteTarget *pRemoteTarget, LPCWSTR lpApplicationName, - _In_ LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, - DWORD dwCreationFlags, PVOID lpEnvironment, LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation, - CorDebugCreateProcessFlags debuggingFlags, ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO100000, "Cordb - CreateProcessEx - NOT IMPLEMENTED\n")); - return S_OK; -} - -HRESULT Cordb::DebugActiveProcessEx(ICorDebugRemoteTarget *pRemoteTarget, - DWORD dwProcessId, BOOL fWin32Attach, - ICorDebugProcess **ppProcess) { - LOG((LF_CORDB, LL_INFO100000, - "Cordb - DebugActiveProcessEx - NOT IMPLEMENTED\n")); - return S_OK; -} - -ReceivedReplyPacket::ReceivedReplyPacket(int error, int error_2, int id, - MdbgProtBuffer *buf) { - this->error = error; - this->error_2 = error_2; - this->id = id; - this->buf = buf; -} - -ReceivedReplyPacket::~ReceivedReplyPacket() { - if (buf) { - m_dbgprot_buffer_free(buf); - delete buf; - } -} - -Connection::Connection(CordbProcess *proc, Cordb *cordb) { - pProcess = proc; - pCordb = cordb; - receiveReplies = new ArrayList(); - receivedPacketsToProcess = new ArrayList(); -} - -Connection::~Connection() { - DWORD i = 0; - while (i < receiveReplies->GetCount()) { - ReceivedReplyPacket *rrp = (ReceivedReplyPacket *)receiveReplies->Get(i); - if (rrp) { - delete rrp; - } - i++; - } - i = 0; - while (i < receivedPacketsToProcess->GetCount()) { - MdbgProtBuffer *buf = (MdbgProtBuffer *)receivedPacketsToProcess->Get(i); - if (buf) { - m_dbgprot_buffer_free(buf); - free(buf); +Cordb::QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - QueryInterface - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT Cordb::CreateProcessEx(ICorDebugRemoteTarget* pRemoteTarget, + LPCWSTR lpApplicationName, + _In_ LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + PVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + CorDebugCreateProcessFlags debuggingFlags, + ICorDebugProcess** ppProcess) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - CreateProcessEx - NOT IMPLEMENTED\n")); + return S_OK; +} + +HRESULT Cordb::DebugActiveProcessEx(ICorDebugRemoteTarget* pRemoteTarget, + DWORD dwProcessId, + BOOL fWin32Attach, + ICorDebugProcess** ppProcess) +{ + LOG((LF_CORDB, LL_INFO100000, "Cordb - DebugActiveProcessEx - NOT IMPLEMENTED\n")); + return S_OK; +} + +ReceivedReplyPacket::ReceivedReplyPacket(int error, int error_2, int id, MdbgProtBuffer* buf) +{ + this->error = error; + this->error_2 = error_2; + this->id = id; + this->buf = buf; +} + +ReceivedReplyPacket::~ReceivedReplyPacket() +{ + if (buf) + { + m_dbgprot_buffer_free(buf); + delete buf; } - i++; - } - delete socket; - delete receiveReplies; - delete receivedPacketsToProcess; } -void Connection::Receive() { - while (true) { - MdbgProtBuffer recvbuf_header; - m_dbgprot_buffer_init(&recvbuf_header, HEADER_LENGTH); - - int iResult = socket->Receive((char *)recvbuf_header.buf, HEADER_LENGTH); - - if (iResult == -1) { - pCordb->GetCallback()->ExitProcess( - static_cast(GetProcess())); - break; - } - while (iResult == 0) { - LOG((LF_CORDB, LL_INFO100000, - "transport_recv () sleep returned %d, expected %d.\n", iResult, - HEADER_LENGTH)); - iResult = socket->Receive((char *)recvbuf_header.buf, HEADER_LENGTH); - Sleep(1000); +Connection::Connection(CordbProcess* proc, Cordb* cordb) +{ + pProcess = proc; + pCordb = cordb; + receiveReplies = new ArrayList(); + receivedPacketsToProcess = new ArrayList(); +} + +Connection::~Connection() +{ + DWORD i = 0; + while (i < receiveReplies->GetCount()) + { + ReceivedReplyPacket* rrp = (ReceivedReplyPacket*)receiveReplies->Get(i); + if (rrp) + { + delete rrp; + } + i++; } - - MdbgProtHeader header; - MdbgProtBuffer *recvbuf = new MdbgProtBuffer(); - m_dbgprot_decode_command_header(&recvbuf_header, &header); - m_dbgprot_buffer_free(&recvbuf_header); - m_dbgprot_buffer_init(recvbuf, header.len - HEADER_LENGTH); - - if (header.len < HEADER_LENGTH) { - return; + i = 0; + while (i < receivedPacketsToProcess->GetCount()) + { + MdbgProtBuffer* buf = (MdbgProtBuffer*)receivedPacketsToProcess->Get(i); + if (buf) + { + m_dbgprot_buffer_free(buf); + free(buf); + } + i++; } - - if (header.len - HEADER_LENGTH != 0) { - iResult = socket->Receive((char *)recvbuf->p, header.len - HEADER_LENGTH); - int totalRead = iResult; - while (totalRead < header.len - HEADER_LENGTH) { - iResult = socket->Receive((char *)recvbuf->p + totalRead, - (header.len - HEADER_LENGTH) - totalRead); - totalRead += iResult; - } + delete socket; + delete receiveReplies; + delete receivedPacketsToProcess; +} + +void Connection::Receive() +{ + while (true) + { + MdbgProtBuffer recvbuf_header; + m_dbgprot_buffer_init(&recvbuf_header, HEADER_LENGTH); + + int iResult = socket->Receive((char*)recvbuf_header.buf, HEADER_LENGTH); + + if (iResult == -1) + { + pCordb->GetCallback()->ExitProcess(static_cast(GetProcess())); + break; + } + while (iResult == 0) + { + LOG((LF_CORDB, LL_INFO100000, "transport_recv () sleep returned %d, expected %d.\n", iResult, + HEADER_LENGTH)); + iResult = socket->Receive((char*)recvbuf_header.buf, HEADER_LENGTH); + Sleep(1000); + } + + MdbgProtHeader header; + MdbgProtBuffer* recvbuf = new MdbgProtBuffer(); + m_dbgprot_decode_command_header(&recvbuf_header, &header); + m_dbgprot_buffer_free(&recvbuf_header); + m_dbgprot_buffer_init(recvbuf, header.len - HEADER_LENGTH); + + if (header.len < HEADER_LENGTH) + { + return; + } + + if (header.len - HEADER_LENGTH != 0) + { + iResult = socket->Receive((char*)recvbuf->p, header.len - HEADER_LENGTH); + int totalRead = iResult; + while (totalRead < header.len - HEADER_LENGTH) + { + iResult = socket->Receive((char*)recvbuf->p + totalRead, (header.len - HEADER_LENGTH) - totalRead); + totalRead += iResult; + } + } + + dbg_lock(); + if (header.flags == REPLY_PACKET) + { + ReceivedReplyPacket* rp = new ReceivedReplyPacket(header.error, header.error_2, header.id, recvbuf); + receiveReplies->Append(rp); + } + else + { + receivedPacketsToProcess->Append(recvbuf); + } + dbg_unlock(); } +} - dbg_lock(); - if (header.flags == REPLY_PACKET) { - ReceivedReplyPacket *rp = new ReceivedReplyPacket( - header.error, header.error_2, header.id, recvbuf); - receiveReplies->Append(rp); - } else { - receivedPacketsToProcess->Append(recvbuf); - } - dbg_unlock(); - } -} - -MdbgProtBuffer *Connection::GetReply(int cmdId) { - ReceivedReplyPacket *rrp = NULL; - while (rrp == NULL || rrp->Id() != cmdId) { - dbg_lock(); - for (int i = receiveReplies->GetCount() - 1; i >= 0; i--) { - rrp = (ReceivedReplyPacket *)receiveReplies->Get(i); - if (rrp->Id() == cmdId) - break; +MdbgProtBuffer* Connection::GetReply(int cmdId) +{ + ReceivedReplyPacket* rrp = NULL; + while (rrp == NULL || rrp->Id() != cmdId) + { + dbg_lock(); + for (int i = receiveReplies->GetCount() - 1; i >= 0; i--) + { + rrp = (ReceivedReplyPacket*)receiveReplies->Get(i); + if (rrp->Id() == cmdId) + break; + } + dbg_unlock(); } - dbg_unlock(); - } - return rrp->Buffer(); -} - -ReceivedReplyPacket *Connection::GetReplyWithError(int cmdId) { - ReceivedReplyPacket *rrp = NULL; - while (rrp == NULL || rrp->Id() != cmdId) { - dbg_lock(); - for (int i = receiveReplies->GetCount() - 1; i >= 0; i--) { - rrp = (ReceivedReplyPacket *)receiveReplies->Get(i); - if (rrp->Id() == cmdId) - break; + return rrp->Buffer(); +} + +ReceivedReplyPacket* Connection::GetReplyWithError(int cmdId) +{ + ReceivedReplyPacket* rrp = NULL; + while (rrp == NULL || rrp->Id() != cmdId) + { + dbg_lock(); + for (int i = receiveReplies->GetCount() - 1; i >= 0; i--) + { + rrp = (ReceivedReplyPacket*)receiveReplies->Get(i); + if (rrp->Id() == cmdId) + break; + } + dbg_unlock(); } - dbg_unlock(); - } - return rrp; -} - -CordbAppDomain *Connection::GetCurrentAppDomain() { - return GetProcess()->GetCurrentAppDomain(); -} - -void Connection::ProcessPacketInternal(MdbgProtBuffer *recvbuf) { - int spolicy = m_dbgprot_decode_byte(recvbuf->p, &recvbuf->p, recvbuf->end); - int nevents = m_dbgprot_decode_int(recvbuf->p, &recvbuf->p, recvbuf->end); - CordbAppDomain *pCorDebugAppDomain = GetCurrentAppDomain(); - for (int i = 0; i < nevents; ++i) { - - int kind = m_dbgprot_decode_byte(recvbuf->p, &recvbuf->p, recvbuf->end); - int req_id = m_dbgprot_decode_int(recvbuf->p, &recvbuf->p, recvbuf->end); - - MdbgProtEventKind etype = (MdbgProtEventKind)kind; - - long thread_id = m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); - - LOG((LF_CORDB, LL_INFO100000, "Received %d %d events %s, suspend=%d\n", i, - nevents, m_dbgprot_event_to_string(etype), spolicy)); - - switch (etype) { - case MDBGPROT_EVENT_KIND_VM_START: { - pCordb->GetCallback()->CreateProcess( - static_cast(GetProcess())); - } break; - case MDBGPROT_EVENT_KIND_VM_DEATH: { - pCordb->GetCallback()->ExitProcess( - static_cast(GetProcess())); - } break; - case MDBGPROT_EVENT_KIND_THREAD_START: { - CordbThread *thread = new CordbThread(this, GetProcess(), thread_id); - pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); - } break; - case MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE: { - - } break; - case MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD: { - // all the callbacks call a resume, in this case that we are faking 2 - // callbacks without receive command, we should not send the continue - int assembly_id = - m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); - if (pCorDebugAppDomain == NULL) { - pCorDebugAppDomain = new CordbAppDomain(this, GetProcess()); - GetProcess()->Stop(false); - pCordb->GetCallback()->CreateAppDomain( - static_cast(GetProcess()), pCorDebugAppDomain); - } - CordbAssembly *pAssembly = new CordbAssembly( - this, GetProcess(), pCorDebugAppDomain, assembly_id); - CordbModule *pModule = new CordbModule( - this, GetProcess(), (CordbAssembly *)pAssembly, assembly_id); - - GetProcess()->Stop(false); - pCordb->GetCallback()->LoadAssembly(pCorDebugAppDomain, pAssembly); - - pCordb->GetCallback()->LoadModule(pCorDebugAppDomain, pModule); - } break; - case MDBGPROT_EVENT_KIND_BREAKPOINT: { - int method_id = - m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); - int64_t offset = - m_dbgprot_decode_long(recvbuf->p, &recvbuf->p, recvbuf->end); - CordbThread *thread = GetProcess()->FindThread(thread_id); - if (thread == NULL) { - thread = new CordbThread(this, GetProcess(), thread_id); - GetProcess()->Stop(false); - pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); - } - DWORD i = 0; - CordbFunctionBreakpoint *breakpoint = - GetProcess()->GetBreakpointByOffsetAndFuncId(offset, method_id); - pCordb->GetCallback()->Breakpoint( - pCorDebugAppDomain, thread, - static_cast(breakpoint)); - } break; - case MDBGPROT_EVENT_KIND_STEP: { - int method_id = - m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); - int64_t offset = - m_dbgprot_decode_long(recvbuf->p, &recvbuf->p, recvbuf->end); - CordbThread *thread = GetProcess()->FindThread(thread_id); - if (thread == NULL) { - thread = new CordbThread(this, GetProcess(), thread_id); - GetProcess()->Stop(false); - pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); - } - pCordb->GetCallback()->StepComplete(pCorDebugAppDomain, thread, - thread->GetStepper(), STEP_NORMAL); - } break; - default: { - LOG((LF_CORDB, LL_INFO100000, "Not implemented - %s\n", - m_dbgprot_event_to_string(etype))); + return rrp; +} + +CordbAppDomain* Connection::GetCurrentAppDomain() +{ + return GetProcess()->GetCurrentAppDomain(); +} + +void Connection::ProcessPacketInternal(MdbgProtBuffer* recvbuf) +{ + int spolicy = m_dbgprot_decode_byte(recvbuf->p, &recvbuf->p, recvbuf->end); + int nevents = m_dbgprot_decode_int(recvbuf->p, &recvbuf->p, recvbuf->end); + CordbAppDomain* pCorDebugAppDomain = GetCurrentAppDomain(); + for (int i = 0; i < nevents; ++i) + { + + int kind = m_dbgprot_decode_byte(recvbuf->p, &recvbuf->p, recvbuf->end); + int req_id = m_dbgprot_decode_int(recvbuf->p, &recvbuf->p, recvbuf->end); + + MdbgProtEventKind etype = (MdbgProtEventKind)kind; + + long thread_id = m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); + + LOG((LF_CORDB, LL_INFO100000, "Received %d %d events %s, suspend=%d\n", i, nevents, + m_dbgprot_event_to_string(etype), spolicy)); + + switch (etype) + { + case MDBGPROT_EVENT_KIND_VM_START: + { + pCordb->GetCallback()->CreateProcess(static_cast(GetProcess())); + } + break; + case MDBGPROT_EVENT_KIND_VM_DEATH: + { + pCordb->GetCallback()->ExitProcess(static_cast(GetProcess())); + } + break; + case MDBGPROT_EVENT_KIND_THREAD_START: + { + CordbThread* thread = new CordbThread(this, GetProcess(), thread_id); + pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); + } + break; + case MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE: + { + } + break; + case MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD: + { + // all the callbacks call a resume, in this case that we are faking 2 + // callbacks without receive command, we should not send the continue + int assembly_id = m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); + if (pCorDebugAppDomain == NULL) + { + pCorDebugAppDomain = new CordbAppDomain(this, GetProcess()); + GetProcess()->Stop(false); + pCordb->GetCallback()->CreateAppDomain(static_cast(GetProcess()), + pCorDebugAppDomain); + } + CordbAssembly* pAssembly = new CordbAssembly(this, GetProcess(), pCorDebugAppDomain, assembly_id); + CordbModule* pModule = new CordbModule(this, GetProcess(), (CordbAssembly*)pAssembly, assembly_id); + + GetProcess()->Stop(false); + pCordb->GetCallback()->LoadAssembly(pCorDebugAppDomain, pAssembly); + + pCordb->GetCallback()->LoadModule(pCorDebugAppDomain, pModule); + } + break; + case MDBGPROT_EVENT_KIND_BREAKPOINT: + { + int method_id = m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); + int64_t offset = m_dbgprot_decode_long(recvbuf->p, &recvbuf->p, recvbuf->end); + CordbThread* thread = GetProcess()->FindThread(thread_id); + if (thread == NULL) + { + thread = new CordbThread(this, GetProcess(), thread_id); + GetProcess()->Stop(false); + pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); + } + DWORD i = 0; + CordbFunctionBreakpoint* breakpoint = GetProcess()->GetBreakpointByOffsetAndFuncId(offset, method_id); + pCordb->GetCallback()->Breakpoint(pCorDebugAppDomain, thread, + static_cast(breakpoint)); + } + break; + case MDBGPROT_EVENT_KIND_STEP: + { + int method_id = m_dbgprot_decode_id(recvbuf->p, &recvbuf->p, recvbuf->end); + int64_t offset = m_dbgprot_decode_long(recvbuf->p, &recvbuf->p, recvbuf->end); + CordbThread* thread = GetProcess()->FindThread(thread_id); + if (thread == NULL) + { + thread = new CordbThread(this, GetProcess(), thread_id); + GetProcess()->Stop(false); + pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); + } + pCordb->GetCallback()->StepComplete(pCorDebugAppDomain, thread, thread->GetStepper(), STEP_NORMAL); + } + break; + default: + { + LOG((LF_CORDB, LL_INFO100000, "Not implemented - %s\n", m_dbgprot_event_to_string(etype))); + } + } } + // m_dbgprot_buffer_free(&recvbuf); +} + +int Connection::ProcessPacket(bool is_answer) +{ + if (!is_answer) + ProcessPacketFromQueue(); + return 1; +} + +void Connection::ProcessPacketFromQueue() +{ + DWORD i = 0; + while (i < receivedPacketsToProcess->GetCount()) + { + MdbgProtBuffer* req = (MdbgProtBuffer*)receivedPacketsToProcess->Get(i); + if (req) + { + ProcessPacketInternal(req); + dbg_lock(); + receivedPacketsToProcess->Set(i, NULL); + dbg_unlock(); + delete req; + } + i++; } - } - // m_dbgprot_buffer_free(&recvbuf); -} - -int Connection::ProcessPacket(bool is_answer) { - if (!is_answer) - ProcessPacketFromQueue(); - return 1; -} - -void Connection::ProcessPacketFromQueue() { - DWORD i = 0; - while (i < receivedPacketsToProcess->GetCount()) { - MdbgProtBuffer *req = (MdbgProtBuffer *)receivedPacketsToProcess->Get(i); - if (req) { - ProcessPacketInternal(req); - dbg_lock(); - receivedPacketsToProcess->Set(i, NULL); - dbg_unlock(); - delete req; - } - i++; - } - GetProcess()->CheckPendingEval(); -} - -void Connection::LoopSendReceive() { - DWORD thread_id; - CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)receive_thread, this, 0, - &thread_id); + GetProcess()->CheckPendingEval(); +} + +void Connection::LoopSendReceive() +{ + DWORD thread_id; + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)receive_thread, this, 0, &thread_id); - EnableEvent(MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD); - EnableEvent(MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE); - EnableEvent(MDBGPROT_EVENT_KIND_THREAD_START); - EnableEvent(MDBGPROT_EVENT_KIND_THREAD_DEATH); - EnableEvent(MDBGPROT_EVENT_KIND_APPDOMAIN_UNLOAD); - EnableEvent(MDBGPROT_EVENT_KIND_USER_BREAK); - EnableEvent(MDBGPROT_EVENT_KIND_USER_LOG); - EnableEvent(MDBGPROT_EVENT_KIND_VM_DEATH); + EnableEvent(MDBGPROT_EVENT_KIND_ASSEMBLY_LOAD); + EnableEvent(MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE); + EnableEvent(MDBGPROT_EVENT_KIND_THREAD_START); + EnableEvent(MDBGPROT_EVENT_KIND_THREAD_DEATH); + EnableEvent(MDBGPROT_EVENT_KIND_APPDOMAIN_UNLOAD); + EnableEvent(MDBGPROT_EVENT_KIND_USER_BREAK); + EnableEvent(MDBGPROT_EVENT_KIND_USER_LOG); + EnableEvent(MDBGPROT_EVENT_KIND_VM_DEATH); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_int(&localbuf, MAJOR_VERSION); - m_dbgprot_buffer_add_int(&localbuf, MINOR_VERSION); - int cmdId = SendEvent(MDBGPROT_CMD_SET_VM, - MDBGPROT_CMD_VM_SET_PROTOCOL_VERSION, &localbuf); - m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_int(&localbuf, MAJOR_VERSION); + m_dbgprot_buffer_add_int(&localbuf, MINOR_VERSION); + int cmdId = SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SET_PROTOCOL_VERSION, &localbuf); + m_dbgprot_buffer_free(&localbuf); - m_dbgprot_buffer_init(&localbuf, 128); - cmdId = SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_VERSION, &localbuf); - m_dbgprot_buffer_free(&localbuf); + m_dbgprot_buffer_init(&localbuf, 128); + cmdId = SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_VERSION, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket *received_reply_packet = GetReplyWithError(cmdId); - MdbgProtBuffer *pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = GetReplyWithError(cmdId); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - char *vm_version = - m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - int major_version = - m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int minor_version = - m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + char* vm_version = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + int major_version = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int minor_version = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - LOG((LF_CORDB, LL_INFO100000, - "Protocol version %d.%d, server protocol version %d.%d.\n", - MAJOR_VERSION, MINOR_VERSION, major_version, minor_version)); - free(vm_version); - int iResult = 0; - // Receive until the peer closes the connection - do { - iResult = ProcessPacket(); - Sleep(100); - } while (iResult >= 0); + LOG((LF_CORDB, LL_INFO100000, "Protocol version %d.%d, server protocol version %d.%d.\n", MAJOR_VERSION, + MINOR_VERSION, major_version, minor_version)); + free(vm_version); + int iResult = 0; + // Receive until the peer closes the connection + do + { + iResult = ProcessPacket(); + Sleep(100); + } while (iResult >= 0); } -void Connection::EnableEvent(MdbgProtEventKind eventKind) { - MdbgProtBuffer sendbuf; - int buflen = 128; - m_dbgprot_buffer_init(&sendbuf, buflen); - m_dbgprot_buffer_add_byte(&sendbuf, eventKind); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); - m_dbgprot_buffer_add_byte(&sendbuf, 0); // modifiers - SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, - &sendbuf); - m_dbgprot_buffer_free(&sendbuf); +void Connection::EnableEvent(MdbgProtEventKind eventKind) +{ + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, eventKind); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 0); // modifiers + SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); } -void Connection::CloseConnection() { socket->Close(); } +void Connection::CloseConnection() +{ + socket->Close(); +} -void Connection::StartConnection() { - LOG((LF_CORDB, LL_INFO100000, "Start Connection\n")); +void Connection::StartConnection() +{ + LOG((LF_CORDB, LL_INFO100000, "Start Connection\n")); - socket = new Socket(); + socket = new Socket(); - LOG((LF_CORDB, LL_INFO100000, "Listening to %s:%s\n", DEBUG_ADDRESS, - DEBUG_PORT)); + LOG((LF_CORDB, LL_INFO100000, "Listening to %s:%s\n", DEBUG_ADDRESS, DEBUG_PORT)); - int ret = socket->OpenSocketAcceptConnection(DEBUG_ADDRESS, DEBUG_PORT); - if (ret == -1) - exit(1); + int ret = socket->OpenSocketAcceptConnection(DEBUG_ADDRESS, DEBUG_PORT); + if (ret == -1) + exit(1); - LOG((LF_CORDB, LL_INFO100000, "Accepted connection from client.\n")); + LOG((LF_CORDB, LL_INFO100000, "Accepted connection from client.\n")); } -void Connection::TransportHandshake() { - int buflen = 128; +void Connection::TransportHandshake() +{ + int buflen = 128; - MdbgProtBuffer sendbuf; - m_dbgprot_buffer_init(&sendbuf, buflen); + MdbgProtBuffer sendbuf; + m_dbgprot_buffer_init(&sendbuf, buflen); - MdbgProtBuffer recvbuf; - m_dbgprot_buffer_init(&recvbuf, buflen); + MdbgProtBuffer recvbuf; + m_dbgprot_buffer_init(&recvbuf, buflen); - int iResult; - iResult = socket->Receive((char *)recvbuf.buf, buflen); + int iResult; + iResult = socket->Receive((char*)recvbuf.buf, buflen); - // Send an initial buffer - m_dbgprot_buffer_add_data(&sendbuf, (uint8_t *)"DWP-Handshake", 13); - SendPacket(sendbuf); - m_dbgprot_buffer_free(&sendbuf); - m_dbgprot_buffer_free(&recvbuf); + // Send an initial buffer + m_dbgprot_buffer_add_data(&sendbuf, (uint8_t*)"DWP-Handshake", 13); + SendPacket(sendbuf); + m_dbgprot_buffer_free(&sendbuf); + m_dbgprot_buffer_free(&recvbuf); } -void Connection::SendPacket(MdbgProtBuffer &sendbuf) { - int iResult = - socket->Send((const char *)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf)); - if (iResult == -1) { - return; - } +void Connection::SendPacket(MdbgProtBuffer& sendbuf) +{ + int iResult = socket->Send((const char*)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf)); + if (iResult == -1) + { + return; + } } -int Connection::SendEvent(int cmd_set, int cmd, MdbgProtBuffer *sendbuf) { - MdbgProtBuffer outbuf; - int ret = m_dbgprot_buffer_add_command_header(sendbuf, cmd_set, cmd, &outbuf); - SendPacket(outbuf); - return ret; +int Connection::SendEvent(int cmd_set, int cmd, MdbgProtBuffer* sendbuf) +{ + MdbgProtBuffer outbuf; + int ret = m_dbgprot_buffer_add_command_header(sendbuf, cmd_set, cmd, &outbuf); + SendPacket(outbuf); + return ret; } -MONO_API HRESULT CoreCLRCreateCordbObject(int iDebuggerVersion, DWORD pid, - HMODULE hmodTargetCLR, - void **ppCordb) { - *ppCordb = new Cordb(); - return S_OK; +MONO_API HRESULT CoreCLRCreateCordbObject(int iDebuggerVersion, DWORD pid, HMODULE hmodTargetCLR, void** ppCordb) +{ + *ppCordb = new Cordb(); + return S_OK; } -MONO_API HRESULT CreateCordbObject(int iDebuggerVersion, void **ppCordb) { - *ppCordb = new Cordb(); - return S_OK; +MONO_API HRESULT CreateCordbObject(int iDebuggerVersion, void** ppCordb) +{ + *ppCordb = new Cordb(); + return S_OK; } -CordbBaseMono::CordbBaseMono(Connection *conn) { - this->conn = conn; - m_cRef = 0; - m_cRefInternal = 0; +CordbBaseMono::CordbBaseMono(Connection* conn) +{ + this->conn = conn; + m_cRef = 0; + m_cRefInternal = 0; } CordbBaseMono::~CordbBaseMono() {} -ULONG CordbBaseMono::InternalAddRef() { - return InterlockedIncrement(&m_cRefInternal); +ULONG CordbBaseMono::InternalAddRef() +{ + return InterlockedIncrement(&m_cRefInternal); } -ULONG CordbBaseMono::InternalRelease() { - ULONG cRef = InterlockedDecrement(&m_cRefInternal); - if (cRef == 0 && m_cRef == 0) { - delete this; - } - return cRef; +ULONG CordbBaseMono::InternalRelease() +{ + ULONG cRef = InterlockedDecrement(&m_cRefInternal); + if (cRef == 0 && m_cRef == 0) + { + delete this; + } + return cRef; } -ULONG CordbBaseMono::BaseAddRef() { return InterlockedIncrement(&m_cRef); } +ULONG CordbBaseMono::BaseAddRef() +{ + return InterlockedIncrement(&m_cRef); +} -ULONG CordbBaseMono::BaseRelease() { - ULONG cRef = InterlockedDecrement(&m_cRef); - if (cRef == 0 && m_cRefInternal == 0) { - delete this; - } - return cRef; +ULONG CordbBaseMono::BaseRelease() +{ + ULONG cRef = InterlockedDecrement(&m_cRef); + if (cRef == 0 && m_cRefInternal == 0) + { + delete this; + } + return cRef; } -void CordbBaseMono::SetConnection(Connection *conn) { this->conn = conn; } +void CordbBaseMono::SetConnection(Connection* conn) +{ + this->conn = conn; +} diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 9a8c7a2dcdbedb..bcbbe545079d61 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -23,13 +23,14 @@ #include #endif -#define return_if_nok(error) \ - do { \ - if (!is_ok((error))) \ - return S_FALSE; \ - } while (0) +#define return_if_nok(error) \ + do \ + { \ + if (!is_ok((error))) \ + return S_FALSE; \ + } while (0) -static UTSemReadWrite *m_pSemReadWrite; +static UTSemReadWrite* m_pSemReadWrite; #define dbg_lock() m_pSemReadWrite->LockRead(); #define dbg_unlock() m_pSemReadWrite->UnlockRead(); @@ -64,126 +65,173 @@ class CordbBlockingObjectEnum; class CordbFunctionBreakpoint; class CordbEval; -class ReceivedReplyPacket { - int error; - int error_2; - int id; - MdbgProtBuffer *buf; +class ReceivedReplyPacket +{ + int error; + int error_2; + int id; + MdbgProtBuffer* buf; public: - ReceivedReplyPacket(int error, int error_2, int id, MdbgProtBuffer *buf); - ~ReceivedReplyPacket(); - MdbgProtBuffer *Buffer() { return buf; } - int Error() { return error; } - int Error2() { return error_2; } - int Id() { return id; } + ReceivedReplyPacket(int error, int error_2, int id, MdbgProtBuffer* buf); + ~ReceivedReplyPacket(); + MdbgProtBuffer* Buffer() + { + return buf; + } + int Error() + { + return error; + } + int Error2() + { + return error_2; + } + int Id() + { + return id; + } }; -class Connection { - Socket *socket; - CordbProcess *pProcess; - Cordb *pCordb; - ArrayList *receiveReplies; //TODO use hashmap - ArrayList *pendingEval; //TODO use hashmap - ArrayList *receivedPacketsToProcess; //TODO use hashmap - void ProcessPacketInternal(MdbgProtBuffer *recvbuf); - void ProcessPacketFromQueue(); - void EnableEvent(MdbgProtEventKind eventKind); - void SendPacket(MdbgProtBuffer &sendbuf); - int ProcessPacket(bool is_answer = false); +class Connection +{ + Socket* socket; + CordbProcess* pProcess; + Cordb* pCordb; + ArrayList* receiveReplies; // TODO use hashmap + ArrayList* pendingEval; // TODO use hashmap + ArrayList* receivedPacketsToProcess; // TODO use hashmap + void ProcessPacketInternal(MdbgProtBuffer* recvbuf); + void ProcessPacketFromQueue(); + void EnableEvent(MdbgProtEventKind eventKind); + void SendPacket(MdbgProtBuffer& sendbuf); + int ProcessPacket(bool is_answer = false); public: - CordbProcess *GetProcess() const { return pProcess; } - Cordb *GetCordb() const { return pCordb; } - Connection(CordbProcess *proc, Cordb *cordb); - ~Connection(); - - void LoopSendReceive(); - void CloseConnection(); - void StartConnection(); - void TransportHandshake(); - void Receive(); - - int SendEvent(int cmd_set, int cmd, MdbgProtBuffer *sendbuf); - MdbgProtBuffer *GetReply(int cmdId); - ReceivedReplyPacket *GetReplyWithError(int cmdId); - CordbAppDomain *GetCurrentAppDomain(); + CordbProcess* GetProcess() const + { + return pProcess; + } + Cordb* GetCordb() const + { + return pCordb; + } + Connection(CordbProcess* proc, Cordb* cordb); + ~Connection(); + + void LoopSendReceive(); + void CloseConnection(); + void StartConnection(); + void TransportHandshake(); + void Receive(); + + int SendEvent(int cmd_set, int cmd, MdbgProtBuffer* sendbuf); + MdbgProtBuffer* GetReply(int cmdId); + ReceivedReplyPacket* GetReplyWithError(int cmdId); + CordbAppDomain* GetCurrentAppDomain(); }; -class CordbBaseMono { +class CordbBaseMono +{ protected: - Connection *conn; - ULONG m_cRef; // Ref count. - ULONG m_cRefInternal; // Ref count. + Connection* conn; + ULONG m_cRef; // Ref count. + ULONG m_cRefInternal; // Ref count. public: - CordbBaseMono(Connection *conn); - virtual ~CordbBaseMono(); - void SetConnection(Connection *conn); - ULONG BaseAddRef(void); - ULONG BaseRelease(void); - ULONG InternalAddRef(void); - ULONG InternalRelease(void); - virtual const char *GetClassName() { return "CordbBaseMono"; } + CordbBaseMono(Connection* conn); + virtual ~CordbBaseMono(); + void SetConnection(Connection* conn); + ULONG BaseAddRef(void); + ULONG BaseRelease(void); + ULONG InternalAddRef(void); + ULONG InternalRelease(void); + virtual const char* GetClassName() + { + return "CordbBaseMono"; + } }; -class Cordb : public ICorDebug, public ICorDebugRemote, public CordbBaseMono { - ICorDebugManagedCallback *m_pCallback; - CordbProcess *m_pProcess; +class Cordb : public ICorDebug, public ICorDebugRemote, public CordbBaseMono +{ + ICorDebugManagedCallback* m_pCallback; + CordbProcess* m_pProcess; public: - ICorDebugManagedCallback *GetCallback() const { return m_pCallback; } - Cordb(); - ULONG AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) { return (BaseRelease()); } - const char *GetClassName() { return "Cordb"; } - ~Cordb(); - - HRESULT Initialize(void); - - HRESULT Terminate(void); - - HRESULT SetManagedHandler(ICorDebugManagedCallback *pCallback); - - HRESULT SetUnmanagedHandler(ICorDebugUnmanagedCallback *pCallback); - - HRESULT CreateProcess(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, DWORD dwCreationFlags, - PVOID lpEnvironment, LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation, - CorDebugCreateProcessFlags debuggingFlags, - ICorDebugProcess **ppProcess); - - HRESULT DebugActiveProcess(DWORD id, BOOL win32Attach, - ICorDebugProcess **ppProcess); - HRESULT EnumerateProcesses(ICorDebugProcessEnum **ppProcess); - - HRESULT GetProcess(DWORD dwProcessId, ICorDebugProcess **ppProcess); - - HRESULT CanLaunchOrAttach(DWORD dwProcessId, BOOL win32DebuggingEnabled); - HRESULT QueryInterface(REFIID riid, - _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject); - HRESULT CreateProcessEx( - ICorDebugRemoteTarget *pRemoteTarget, LPCWSTR lpApplicationName, - _In_ LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, - DWORD dwCreationFlags, PVOID lpEnvironment, LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation, - CorDebugCreateProcessFlags debuggingFlags, ICorDebugProcess **ppProcess); - - HRESULT DebugActiveProcessEx(ICorDebugRemoteTarget *pRemoteTarget, - DWORD dwProcessId, BOOL fWin32Attach, - ICorDebugProcess **ppProcess); + ICorDebugManagedCallback* GetCallback() const + { + return m_pCallback; + } + Cordb(); + ULONG AddRef(void) + { + return (BaseAddRef()); + } + ULONG Release(void) + { + return (BaseRelease()); + } + const char* GetClassName() + { + return "Cordb"; + } + ~Cordb(); + + HRESULT Initialize(void); + + HRESULT Terminate(void); + + HRESULT SetManagedHandler(ICorDebugManagedCallback* pCallback); + + HRESULT SetUnmanagedHandler(ICorDebugUnmanagedCallback* pCallback); + + HRESULT CreateProcess(LPCWSTR lpApplicationName, + LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + PVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + CorDebugCreateProcessFlags debuggingFlags, + ICorDebugProcess** ppProcess); + + HRESULT DebugActiveProcess(DWORD id, BOOL win32Attach, ICorDebugProcess** ppProcess); + HRESULT EnumerateProcesses(ICorDebugProcessEnum** ppProcess); + + HRESULT GetProcess(DWORD dwProcessId, ICorDebugProcess** ppProcess); + + HRESULT CanLaunchOrAttach(DWORD dwProcessId, BOOL win32DebuggingEnabled); + HRESULT QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject); + HRESULT CreateProcessEx(ICorDebugRemoteTarget* pRemoteTarget, + LPCWSTR lpApplicationName, + _In_ LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + PVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation, + CorDebugCreateProcessFlags debuggingFlags, + ICorDebugProcess** ppProcess); + + HRESULT DebugActiveProcessEx(ICorDebugRemoteTarget* pRemoteTarget, + DWORD dwProcessId, + BOOL fWin32Attach, + ICorDebugProcess** ppProcess); }; -#define CHECK_ERROR_RETURN_FALSE(localbuf) \ - do { \ - if (localbuf->Error() > 0 || localbuf->Error2() > 0) { \ - LOG((LF_CORDB, LL_INFO100000, "ERROR RECEIVED\n")); \ - return S_FALSE; \ - } \ - } while (0) +#define CHECK_ERROR_RETURN_FALSE(localbuf) \ + do \ + { \ + if (localbuf->Error() > 0 || localbuf->Error2() > 0) \ + { \ + LOG((LF_CORDB, LL_INFO100000, "ERROR RECEIVED\n")); \ + return S_FALSE; \ + } \ + } while (0) #endif diff --git a/src/mono/dbi/debugger-coreclr-compat.h b/src/mono/dbi/debugger-coreclr-compat.h index 93deb5a604ed70..536cc839611141 100644 --- a/src/mono/dbi/debugger-coreclr-compat.h +++ b/src/mono/dbi/debugger-coreclr-compat.h @@ -13,9 +13,10 @@ #define g_realloc realloc #include "stdafx.h" -static inline int32_t dbg_rt_atomic_inc_int32_t(volatile int32_t *value) { - STATIC_CONTRACT_NOTHROW; - return static_cast(InterlockedIncrement((volatile LONG *)(value))); +static inline int32_t dbg_rt_atomic_inc_int32_t(volatile int32_t* value) +{ + STATIC_CONTRACT_NOTHROW; + return static_cast(InterlockedIncrement((volatile LONG*)(value))); } #endif \ No newline at end of file From 91e74974acae06e498f5521ac161d3b55051c970 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Mon, 22 Feb 2021 12:18:35 -0300 Subject: [PATCH 13/64] Dont build when target is android or ios or wasm --- src/mono/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 668a62ebb662f3..68f4138fc4c09b 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -699,7 +699,7 @@ endif() ### End of OS specific checks add_subdirectory(mono) -if (HOST_LINUX OR HOST_WIN32 OR HOST_DARWIN) +if (NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER) add_subdirectory(dbi) endif() From d01a9edf233137024c6629577ff6f5c06ba4a2f2 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Mon, 22 Feb 2021 13:00:11 -0300 Subject: [PATCH 14/64] Fix error unused variable --- src/mono/dbi/socket-dbi/socket.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mono/dbi/socket-dbi/socket.cpp b/src/mono/dbi/socket-dbi/socket.cpp index e296c01d92e124..5acf9cad1a6ee1 100644 --- a/src/mono/dbi/socket-dbi/socket.cpp +++ b/src/mono/dbi/socket-dbi/socket.cpp @@ -66,7 +66,6 @@ int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { continue; iResult = bind(socketId, ptr->ai_addr, (int)ptr->ai_addrlen); - int err = errno; if (iResult == -1) continue; From be8f56d64a59a1b66f7d29670f557b282ebf3cec Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Mon, 22 Feb 2021 13:32:45 -0300 Subject: [PATCH 15/64] Fixing error: 'CFUserNotificationDisplayAlert' is unavailable: not available on macCatalyst --- src/coreclr/pal/src/misc/dbgmsg.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/pal/src/misc/dbgmsg.cpp b/src/coreclr/pal/src/misc/dbgmsg.cpp index a41d2d1036b47d..baca6ba4b6b9c1 100644 --- a/src/coreclr/pal/src/misc/dbgmsg.cpp +++ b/src/coreclr/pal/src/misc/dbgmsg.cpp @@ -765,6 +765,7 @@ Function : --*/ void PAL_DisplayDialog(const char *szTitle, const char *szText) { +#ifndef DBI_COMPONENT_MONO static DisplayDialogMode dispDialog = DisplayDialog_Uninitialized; if (dispDialog == DisplayDialog_Uninitialized) @@ -836,6 +837,7 @@ void PAL_DisplayDialog(const char *szTitle, const char *szText) } CFRelease(cfsTitle); } +#endif } /*++ From 11a62cbb24fb4a741cb563b1af7cd1991dfaeff7 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 22 Feb 2021 14:16:16 -0300 Subject: [PATCH 16/64] Fix compilation error on Linux --- src/mono/dbi/CMakeLists.txt | 4 ++-- src/mono/dbi/cordb.cpp | 8 ++++---- src/mono/dbi/socket-dbi/socket.cpp | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 15726ab30c1bfd..3c88dcc0c24645 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -96,7 +96,7 @@ if (CLR_CMAKE_HOST_UNIX) include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc/rt") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/src/safecrt") - append("-Wno-missing-prototypes" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wno-missing-prototypes -Wno-pointer-arith" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) include_directories("../../coreclr/pal/inc/rt/cpp") @@ -117,7 +117,7 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/md/enc md/enc) add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/utilcode utilcode) if (CLR_CMAKE_HOST_UNIX) add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/palrt palrt) - append("-Wno-strict-prototypes -Wno-deprecated" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wno-strict-prototypes -Wno-deprecated -Wno-pointer-arith" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif (CLR_CMAKE_HOST_UNIX) add_library(mscordbi SHARED "${mscorbi_sources};${PROJECT_SOURCE_DIR}/../mono/mini/debugger-protocol.c;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/xcordebug_i.cpp;${PROJECT_SOURCE_DIR}/../../coreclr/pal/prebuilt/idl/cordebug_i.cpp") diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 40d3697ce3eea4..2af8338e2f71cc 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -581,12 +581,12 @@ CordbBaseMono::~CordbBaseMono() {} ULONG CordbBaseMono::InternalAddRef() { - return InterlockedIncrement(&m_cRefInternal); + return InterlockedIncrement((volatile LONG*)&m_cRefInternal); } ULONG CordbBaseMono::InternalRelease() { - ULONG cRef = InterlockedDecrement(&m_cRefInternal); + ULONG cRef = InterlockedDecrement((volatile LONG*)&m_cRefInternal); if (cRef == 0 && m_cRef == 0) { delete this; @@ -596,12 +596,12 @@ ULONG CordbBaseMono::InternalRelease() ULONG CordbBaseMono::BaseAddRef() { - return InterlockedIncrement(&m_cRef); + return InterlockedIncrement((volatile LONG*)&m_cRef); } ULONG CordbBaseMono::BaseRelease() { - ULONG cRef = InterlockedDecrement(&m_cRef); + ULONG cRef = InterlockedDecrement((volatile LONG*)&m_cRef); if (cRef == 0 && m_cRefInternal == 0) { delete this; diff --git a/src/mono/dbi/socket-dbi/socket.cpp b/src/mono/dbi/socket-dbi/socket.cpp index 5acf9cad1a6ee1..f1ae3a965a2602 100644 --- a/src/mono/dbi/socket-dbi/socket.cpp +++ b/src/mono/dbi/socket-dbi/socket.cpp @@ -21,7 +21,9 @@ #include #include #include +#ifdef HAVE_SYS_SOCKIO_H #include +#endif #include #include #include From ac1735f5872a7cf4f9550eb9a51c706a5fd4adbd Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 22 Feb 2021 14:36:38 -0300 Subject: [PATCH 17/64] Fix function not found in maccatalyst Fix warning as error of macro redefinition --- src/coreclr/pal/src/map/virtual.cpp | 4 ++++ src/mono/dbi/CMakeLists.txt | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 456254bdbbb9a8..4cb0503aef0e9a 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1764,6 +1764,9 @@ VirtualProtect( bool PAL_JITWriteEnableHolder::JITWriteEnable(bool writeEnable) { +#ifdef DBI_COMPONENT_MONO + return false; +#else // Use a thread local to track per thread JIT Write enable state // Initialize threads to start with MAP_JIT pages readable and executable (R-X) by default. thread_local bool enabled = (pthread_jit_write_protect_np(1), false); @@ -1774,6 +1777,7 @@ PAL_JITWriteEnableHolder::JITWriteEnable(bool writeEnable) enabled = writeEnable; } return result; +#endif } #endif diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 3c88dcc0c24645..597d518f9ac272 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -22,7 +22,7 @@ if(HOST_WIN32) set(CLR_CMAKE_HOST_ARCH arm) elseif(HOST_AMD64) set(CLR_CMAKE_HOST_ARCH x64) - endif() + endif() endif() add_definitions(-DDBI_COMPONENT_MONO) @@ -96,7 +96,7 @@ if (CLR_CMAKE_HOST_UNIX) include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc/rt") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/src/safecrt") - append("-Wno-missing-prototypes -Wno-pointer-arith" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wno-missing-prototypes -Wno-pointer-arith -Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) include_directories("../../coreclr/pal/inc/rt/cpp") From d3cc3b43e4603d3f4ac391230914f7de2b87508b Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 22 Feb 2021 14:55:35 -0300 Subject: [PATCH 18/64] Dont compile mscordbi on maccatalyst --- src/coreclr/pal/src/map/virtual.cpp | 4 ---- src/coreclr/pal/src/misc/dbgmsg.cpp | 2 -- src/mono/CMakeLists.txt | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 4cb0503aef0e9a..456254bdbbb9a8 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1764,9 +1764,6 @@ VirtualProtect( bool PAL_JITWriteEnableHolder::JITWriteEnable(bool writeEnable) { -#ifdef DBI_COMPONENT_MONO - return false; -#else // Use a thread local to track per thread JIT Write enable state // Initialize threads to start with MAP_JIT pages readable and executable (R-X) by default. thread_local bool enabled = (pthread_jit_write_protect_np(1), false); @@ -1777,7 +1774,6 @@ PAL_JITWriteEnableHolder::JITWriteEnable(bool writeEnable) enabled = writeEnable; } return result; -#endif } #endif diff --git a/src/coreclr/pal/src/misc/dbgmsg.cpp b/src/coreclr/pal/src/misc/dbgmsg.cpp index baca6ba4b6b9c1..a41d2d1036b47d 100644 --- a/src/coreclr/pal/src/misc/dbgmsg.cpp +++ b/src/coreclr/pal/src/misc/dbgmsg.cpp @@ -765,7 +765,6 @@ Function : --*/ void PAL_DisplayDialog(const char *szTitle, const char *szText) { -#ifndef DBI_COMPONENT_MONO static DisplayDialogMode dispDialog = DisplayDialog_Uninitialized; if (dispDialog == DisplayDialog_Uninitialized) @@ -837,7 +836,6 @@ void PAL_DisplayDialog(const char *szTitle, const char *szText) } CFRelease(cfsTitle); } -#endif } /*++ diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 68f4138fc4c09b..294c268781a196 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -699,7 +699,7 @@ endif() ### End of OS specific checks add_subdirectory(mono) -if (NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER) +if (NOT HOST_IOS AND NOT HOST_ANDROID AND NOT HOST_BROWSER AND NOT HOST_MACCATALYST) add_subdirectory(dbi) endif() From 2ff0e68d116e2a327e62cd55c31a06540a652f09 Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 22 Feb 2021 15:34:59 -0300 Subject: [PATCH 19/64] Fix compilation on linux --- eng/native/configureplatform.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 9e7e7743c0f9ea..25d10118d922ad 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -41,9 +41,9 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux) set(CLR_CMAKE_HOST_UNIX_ARMV7L 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a) set(CLR_CMAKE_HOST_UNIX_ARM 1) - elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) set(CLR_CMAKE_HOST_UNIX_ARM64 1) - elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686 OR CMAKE_SYSTEM_PROCESSOR STREQUAL x86) set(CLR_CMAKE_HOST_UNIX_X86 1) else() clr_unknown_arch() From a1cb8e6915987a5a85e1f49f77875b57b7819308 Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 22 Feb 2021 15:40:29 -0300 Subject: [PATCH 20/64] Fix compilation on android, ios and browser --- src/mono/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 294c268781a196..8f958e9f81a56e 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -699,7 +699,7 @@ endif() ### End of OS specific checks add_subdirectory(mono) -if (NOT HOST_IOS AND NOT HOST_ANDROID AND NOT HOST_BROWSER AND NOT HOST_MACCATALYST) +if (NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCATALYST) add_subdirectory(dbi) endif() From 9a9830424702ee41fc506ca65c6b6b430d09b425 Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 22 Feb 2021 16:10:56 -0300 Subject: [PATCH 21/64] Fix compilation on linux --- src/mono/dbi/socket-dbi/socket.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/dbi/socket-dbi/socket.cpp b/src/mono/dbi/socket-dbi/socket.cpp index f1ae3a965a2602..104a280ddf1526 100644 --- a/src/mono/dbi/socket-dbi/socket.cpp +++ b/src/mono/dbi/socket-dbi/socket.cpp @@ -25,7 +25,9 @@ #include #endif #include +#if defined(__APPLE__) #include +#endif #include #include #endif From e3b74f4a5584a7208f0cc573218ac8863309a43f Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 22 Feb 2021 19:34:14 -0300 Subject: [PATCH 22/64] Fix cross compiling --- src/mono/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 8f958e9f81a56e..2a32eaa6f67a3b 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -699,7 +699,7 @@ endif() ### End of OS specific checks add_subdirectory(mono) -if (NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCATALYST) +if (NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCATALYST) add_subdirectory(dbi) endif() From b7de3c87134ad46e014164e60676b0b81856f506 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 00:34:43 -0300 Subject: [PATCH 23/64] Fix compilation x86 windows --- src/mono/dbi/cordb-appdomain.h | 86 ++-- src/mono/dbi/cordb-assembly.h | 89 ++-- src/mono/dbi/cordb-blocking-obj.h | 16 +- src/mono/dbi/cordb-breakpoint.h | 14 +- src/mono/dbi/cordb-chain.h | 53 ++- src/mono/dbi/cordb-class.h | 16 +- src/mono/dbi/cordb-code.h | 29 +- src/mono/dbi/cordb-eval.h | 43 +- src/mono/dbi/cordb-frame.h | 123 +++--- src/mono/dbi/cordb-function.h | 41 +- src/mono/dbi/cordb-process.h | 139 +++---- src/mono/dbi/cordb-register.h | 19 +- src/mono/dbi/cordb-stepper.h | 24 +- src/mono/dbi/cordb-symbol.h | 667 ++++++++++++++++++++++++++++++ src/mono/dbi/cordb-thread.h | 74 ++-- src/mono/dbi/cordb-type.h | 39 +- src/mono/dbi/cordb-value.h | 216 +++++----- src/mono/dbi/cordb.h | 28 +- 18 files changed, 1132 insertions(+), 584 deletions(-) create mode 100644 src/mono/dbi/cordb-symbol.h diff --git a/src/mono/dbi/cordb-appdomain.h b/src/mono/dbi/cordb-appdomain.h index 2d86349825086f..5adbe154575c6e 100644 --- a/src/mono/dbi/cordb-appdomain.h +++ b/src/mono/dbi/cordb-appdomain.h @@ -19,11 +19,11 @@ class CordbAppDomain : public CordbBaseMono, public: CordbAppDomain(Connection* conn, CordbProcess* ppProcess); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -31,49 +31,35 @@ class CordbAppDomain : public CordbBaseMono, { return "CordbAppDomain"; } - HRESULT Stop(DWORD dwTimeoutIgnored); - HRESULT Continue(BOOL fIsOutOfBand); - HRESULT IsRunning(BOOL* pbRunning); - HRESULT HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued); - HRESULT - EnumerateThreads(ICorDebugThreadEnum** ppThreads); - HRESULT - SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread); - HRESULT Detach(void); - HRESULT Terminate(UINT exitCode); - HRESULT - CanCommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); - HRESULT - CommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface); - HRESULT - GetProcess(ICorDebugProcess** ppProcess); - HRESULT - EnumerateAssemblies(ICorDebugAssemblyEnum** ppAssemblies); - HRESULT GetModuleFromMetaDataInterface(IUnknown* pIMetaData, ICorDebugModule** ppModule); - HRESULT - EnumerateBreakpoints(ICorDebugBreakpointEnum** ppBreakpoints); - HRESULT - EnumerateSteppers(ICorDebugStepperEnum** ppSteppers); - HRESULT IsAttached(BOOL* pbAttached); - HRESULT - GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); - HRESULT GetObject(ICorDebugValue** ppObject); - HRESULT Attach(void); - HRESULT GetID(ULONG32* pId); - HRESULT GetArrayOrPointerType(CorElementType elementType, + HRESULT STDMETHODCALLTYPE Stop(DWORD dwTimeoutIgnored); + HRESULT STDMETHODCALLTYPE Continue(BOOL fIsOutOfBand); + HRESULT STDMETHODCALLTYPE IsRunning(BOOL* pbRunning); + HRESULT STDMETHODCALLTYPE HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued); + HRESULT STDMETHODCALLTYPE EnumerateThreads(ICorDebugThreadEnum** ppThreads); + HRESULT STDMETHODCALLTYPE SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread); + HRESULT STDMETHODCALLTYPE Detach(void); + HRESULT STDMETHODCALLTYPE Terminate(UINT exitCode); + HRESULT STDMETHODCALLTYPE CanCommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); + HRESULT STDMETHODCALLTYPE CommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface); + HRESULT STDMETHODCALLTYPE GetProcess(ICorDebugProcess** ppProcess); + HRESULT STDMETHODCALLTYPE EnumerateAssemblies(ICorDebugAssemblyEnum** ppAssemblies); + HRESULT STDMETHODCALLTYPE GetModuleFromMetaDataInterface(IUnknown* pIMetaData, ICorDebugModule** ppModule); + HRESULT STDMETHODCALLTYPE EnumerateBreakpoints(ICorDebugBreakpointEnum** ppBreakpoints); + HRESULT STDMETHODCALLTYPE EnumerateSteppers(ICorDebugStepperEnum** ppSteppers); + HRESULT STDMETHODCALLTYPE IsAttached(BOOL* pbAttached); + HRESULT STDMETHODCALLTYPE GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); + HRESULT STDMETHODCALLTYPE GetObject(ICorDebugValue** ppObject); + HRESULT STDMETHODCALLTYPE Attach(void); + HRESULT STDMETHODCALLTYPE GetID(ULONG32* pId); + HRESULT STDMETHODCALLTYPE GetArrayOrPointerType(CorElementType elementType, ULONG32 nRank, ICorDebugType* pTypeArg, ICorDebugType** ppType); - HRESULT - GetFunctionPointerType(ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[], ICorDebugType** ppType); - HRESULT - GetCachedWinRTTypesForIIDs(ULONG32 cReqTypes, GUID* iidsToResolve, ICorDebugTypeEnum** ppTypesEnum); - HRESULT - GetCachedWinRTTypes(ICorDebugGuidToTypeEnum** ppGuidToTypeEnum); - HRESULT - GetObjectForCCW(CORDB_ADDRESS ccwPointer, ICorDebugValue** ppManagedObject); + HRESULT STDMETHODCALLTYPE GetFunctionPointerType(ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[], ICorDebugType** ppType); + HRESULT STDMETHODCALLTYPE GetCachedWinRTTypesForIIDs(ULONG32 cReqTypes, GUID* iidsToResolve, ICorDebugTypeEnum** ppTypesEnum); + HRESULT STDMETHODCALLTYPE GetCachedWinRTTypes(ICorDebugGuidToTypeEnum** ppGuidToTypeEnum); + HRESULT STDMETHODCALLTYPE GetObjectForCCW(CORDB_ADDRESS ccwPointer, ICorDebugValue** ppManagedObject); }; class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum @@ -83,11 +69,11 @@ class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum public: CordbAppDomainEnum(Connection* conn, CordbProcess* ppProcess); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -95,12 +81,12 @@ class CordbAppDomainEnum : public CordbBaseMono, public ICorDebugAppDomainEnum { return "CordbAppDomainEnum"; } - HRESULT Next(ULONG celt, ICorDebugAppDomain* values[], ULONG* pceltFetched); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum** ppEnum); - HRESULT GetCount(ULONG* pcelt); - HRESULT QueryInterface(REFIID riid, void** ppvObject); + HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugAppDomain* values[], ULONG* pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum** ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG* pcelt); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-assembly.h b/src/mono/dbi/cordb-assembly.h index 632252bee09bba..fac7173d8e0313 100644 --- a/src/mono/dbi/cordb-assembly.h +++ b/src/mono/dbi/cordb-assembly.h @@ -28,11 +28,11 @@ class CordbModule : public CordbBaseMono, public: CordbModule(Connection* conn, CordbProcess* process, CordbAssembly* assembly, int id_assembly); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -42,42 +42,31 @@ class CordbModule : public CordbBaseMono, } ~CordbModule(); - HRESULT QueryInterface(REFIID id, void** pInterface); - HRESULT IsMappedLayout(BOOL* pIsMapped); - HRESULT CreateReaderForInMemorySymbols(REFIID riid, void** ppObj); - HRESULT - SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken pTokens[]); - HRESULT - ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], ULONG cbIL, BYTE pbIL[]); - HRESULT SetJITCompilerFlags(DWORD dwFlags); - HRESULT GetJITCompilerFlags(DWORD* pdwFlags); - HRESULT - ResolveAssembly(mdToken tkAssemblyRef, ICorDebugAssembly** ppAssembly); - HRESULT - GetProcess(ICorDebugProcess** ppProcess); - HRESULT GetBaseAddress(CORDB_ADDRESS* pAddress); - HRESULT - GetAssembly(ICorDebugAssembly** ppAssembly); - HRESULT - GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); - HRESULT EnableJITDebugging(BOOL bTrackJITInfo, BOOL bAllowJitOpts); - HRESULT - EnableClassLoadCallbacks(BOOL bClassLoadCallbacks); - HRESULT - GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction** ppFunction); - HRESULT - GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction** ppFunction); - HRESULT GetClassFromToken(mdTypeDef typeDef, ICorDebugClass** ppClass); - HRESULT - CreateBreakpoint(ICorDebugModuleBreakpoint** ppBreakpoint); - HRESULT GetEditAndContinueSnapshot(ICorDebugEditAndContinueSnapshot** ppEditAndContinueSnapshot); - HRESULT GetMetaDataInterface(REFIID riid, IUnknown** ppObj); - HRESULT GetToken(mdModule* pToken); - HRESULT IsDynamic(BOOL* pDynamic); - HRESULT - GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue** ppValue); - HRESULT GetSize(ULONG32* pcBytes); - HRESULT IsInMemory(BOOL* pInMemory); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, void** pInterface); + HRESULT STDMETHODCALLTYPE IsMappedLayout(BOOL* pIsMapped); + HRESULT STDMETHODCALLTYPE CreateReaderForInMemorySymbols(REFIID riid, void** ppObj); + HRESULT STDMETHODCALLTYPE SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken pTokens[]); + HRESULT STDMETHODCALLTYPE ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], ULONG cbIL, BYTE pbIL[]); + HRESULT STDMETHODCALLTYPE SetJITCompilerFlags(DWORD dwFlags); + HRESULT STDMETHODCALLTYPE GetJITCompilerFlags(DWORD* pdwFlags); + HRESULT STDMETHODCALLTYPE ResolveAssembly(mdToken tkAssemblyRef, ICorDebugAssembly** ppAssembly); + HRESULT STDMETHODCALLTYPE GetProcess(ICorDebugProcess** ppProcess); + HRESULT STDMETHODCALLTYPE GetBaseAddress(CORDB_ADDRESS* pAddress); + HRESULT STDMETHODCALLTYPE GetAssembly(ICorDebugAssembly** ppAssembly); + HRESULT STDMETHODCALLTYPE GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); + HRESULT STDMETHODCALLTYPE EnableJITDebugging(BOOL bTrackJITInfo, BOOL bAllowJitOpts); + HRESULT STDMETHODCALLTYPE EnableClassLoadCallbacks(BOOL bClassLoadCallbacks); + HRESULT STDMETHODCALLTYPE GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetClassFromToken(mdTypeDef typeDef, ICorDebugClass** ppClass); + HRESULT STDMETHODCALLTYPE CreateBreakpoint(ICorDebugModuleBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetEditAndContinueSnapshot(ICorDebugEditAndContinueSnapshot** ppEditAndContinueSnapshot); + HRESULT STDMETHODCALLTYPE GetMetaDataInterface(REFIID riid, IUnknown** ppObj); + HRESULT STDMETHODCALLTYPE GetToken(mdModule* pToken); + HRESULT STDMETHODCALLTYPE IsDynamic(BOOL* pDynamic); + HRESULT STDMETHODCALLTYPE GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32* pcBytes); + HRESULT STDMETHODCALLTYPE IsInMemory(BOOL* pInMemory); int GetDebuggerId() const { return m_debuggerId; @@ -92,11 +81,11 @@ class CordbAssembly : public CordbBaseMono, public ICorDebugAssembly, public ICo public: CordbAssembly(Connection* conn, CordbProcess* process, CordbAppDomain* appDomain, int id_assembly); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -105,19 +94,13 @@ class CordbAssembly : public CordbBaseMono, public ICorDebugAssembly, public ICo return "CordbAssembly"; } ~CordbAssembly(); - HRESULT IsFullyTrusted(BOOL* pbFullyTrusted); - HRESULT - GetProcess(ICorDebugProcess** ppProcess); - HRESULT - GetAppDomain(ICorDebugAppDomain** ppAppDomain); - HRESULT - EnumerateModules(ICorDebugModuleEnum** ppModules); - HRESULT - GetCodeBase(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); - HRESULT - GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface); + HRESULT STDMETHODCALLTYPE IsFullyTrusted(BOOL* pbFullyTrusted); + HRESULT STDMETHODCALLTYPE GetProcess(ICorDebugProcess** ppProcess); + HRESULT STDMETHODCALLTYPE GetAppDomain(ICorDebugAppDomain** ppAppDomain); + HRESULT STDMETHODCALLTYPE EnumerateModules(ICorDebugModuleEnum** ppModules); + HRESULT STDMETHODCALLTYPE GetCodeBase(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); + HRESULT STDMETHODCALLTYPE GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface); }; #endif diff --git a/src/mono/dbi/cordb-blocking-obj.h b/src/mono/dbi/cordb-blocking-obj.h index 7997db8139af63..b7d49b002d4a06 100644 --- a/src/mono/dbi/cordb-blocking-obj.h +++ b/src/mono/dbi/cordb-blocking-obj.h @@ -13,11 +13,11 @@ class CordbBlockingObjectEnum : public CordbBaseMono, public ICorDebugBlockingOb { public: CordbBlockingObjectEnum(Connection* conn); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -25,12 +25,12 @@ class CordbBlockingObjectEnum : public CordbBaseMono, public ICorDebugBlockingOb { return "CordbBlockingObjectEnum"; } - HRESULT Next(ULONG celt, CorDebugBlockingObject values[], ULONG* pceltFetched); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum** ppEnum); - HRESULT GetCount(ULONG* pcelt); - HRESULT QueryInterface(REFIID riid, void** ppvObject); + HRESULT STDMETHODCALLTYPE Next(ULONG celt, CorDebugBlockingObject values[], ULONG* pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum** ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG* pcelt); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-breakpoint.h b/src/mono/dbi/cordb-breakpoint.h index c7aa1b32127407..614e564bc47fd0 100644 --- a/src/mono/dbi/cordb-breakpoint.h +++ b/src/mono/dbi/cordb-breakpoint.h @@ -16,11 +16,11 @@ class CordbFunctionBreakpoint : public CordbBaseMono, public ICorDebugFunctionBr public: CordbFunctionBreakpoint(Connection* conn, CordbCode* code, ULONG32 offset); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -37,11 +37,11 @@ class CordbFunctionBreakpoint : public CordbBaseMono, public ICorDebugFunctionBr return "CordbFunctionBreakpoint"; } ~CordbFunctionBreakpoint(); - HRESULT GetFunction(ICorDebugFunction** ppFunction); - HRESULT GetOffset(ULONG32* pnOffset); - HRESULT Activate(BOOL bActive); - HRESULT IsActive(BOOL* pbActive); - HRESULT QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetOffset(ULONG32* pnOffset); + HRESULT STDMETHODCALLTYPE Activate(BOOL bActive); + HRESULT STDMETHODCALLTYPE IsActive(BOOL* pbActive); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); }; #endif diff --git a/src/mono/dbi/cordb-chain.h b/src/mono/dbi/cordb-chain.h index 9011ebc1d646d3..ce23f46f198d6b 100644 --- a/src/mono/dbi/cordb-chain.h +++ b/src/mono/dbi/cordb-chain.h @@ -15,11 +15,11 @@ class CordbChainEnum : public CordbBaseMono, public ICorDebugChainEnum public: CordbChainEnum(Connection* conn, CordbThread* thread); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -27,15 +27,13 @@ class CordbChainEnum : public CordbBaseMono, public ICorDebugChainEnum { return "CordbChainEnum"; } - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum** ppEnum); - HRESULT GetCount(ULONG* pcelt); - HRESULT - Next(ULONG celt, ICorDebugChain* chains[], ULONG* pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum** ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG* pcelt); + HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugChain* chains[], ULONG* pceltFetched); }; class CordbChain : public CordbBaseMono, public ICorDebugChain @@ -46,11 +44,11 @@ class CordbChain : public CordbBaseMono, public ICorDebugChain public: CordbChain(Connection* conn, CordbThread* thread, CorDebugChainReason chain_reason, bool is_managed); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -58,24 +56,19 @@ class CordbChain : public CordbBaseMono, public ICorDebugChain { return "CordbChain"; } - HRESULT GetThread(ICorDebugThread** ppThread); - HRESULT GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); - HRESULT - GetContext(ICorDebugContext** ppContext); - HRESULT GetCaller(ICorDebugChain** ppChain); - HRESULT GetCallee(ICorDebugChain** ppChain); - HRESULT GetPrevious(ICorDebugChain** ppChain); - HRESULT GetNext(ICorDebugChain** ppChain); - HRESULT IsManaged(BOOL* pManaged); - HRESULT - EnumerateFrames(ICorDebugFrameEnum** ppFrames); - HRESULT - GetActiveFrame(ICorDebugFrame** ppFrame); - HRESULT - GetRegisterSet(ICorDebugRegisterSet** ppRegisters); - HRESULT GetReason(CorDebugChainReason* pReason); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE GetThread(ICorDebugThread** ppThread); + HRESULT STDMETHODCALLTYPE GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); + HRESULT STDMETHODCALLTYPE GetContext(ICorDebugContext** ppContext); + HRESULT STDMETHODCALLTYPE GetCaller(ICorDebugChain** ppChain); + HRESULT STDMETHODCALLTYPE GetCallee(ICorDebugChain** ppChain); + HRESULT STDMETHODCALLTYPE GetPrevious(ICorDebugChain** ppChain); + HRESULT STDMETHODCALLTYPE GetNext(ICorDebugChain** ppChain); + HRESULT STDMETHODCALLTYPE IsManaged(BOOL* pManaged); + HRESULT STDMETHODCALLTYPE EnumerateFrames(ICorDebugFrameEnum** ppFrames); + HRESULT STDMETHODCALLTYPE GetActiveFrame(ICorDebugFrame** ppFrame); + HRESULT STDMETHODCALLTYPE GetRegisterSet(ICorDebugRegisterSet** ppRegisters); + HRESULT STDMETHODCALLTYPE GetReason(CorDebugChainReason* pReason); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); }; #endif diff --git a/src/mono/dbi/cordb-class.h b/src/mono/dbi/cordb-class.h index f501586d13b4c0..041fc11c6b11e0 100644 --- a/src/mono/dbi/cordb-class.h +++ b/src/mono/dbi/cordb-class.h @@ -16,11 +16,11 @@ class CordbClass : public CordbBaseMono, public ICorDebugClass, public ICorDebug public: CordbClass(Connection* conn, mdToken token, int module_id); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -28,16 +28,16 @@ class CordbClass : public CordbBaseMono, public ICorDebugClass, public ICorDebug { return "CordbClass"; } - HRESULT GetModule(ICorDebugModule** pModule); - HRESULT GetToken(mdTypeDef* pTypeDef); - HRESULT GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame* pFrame, ICorDebugValue** ppValue); - HRESULT QueryInterface(REFIID riid, void** ppvObject); + HRESULT STDMETHODCALLTYPE GetModule(ICorDebugModule** pModule); + HRESULT STDMETHODCALLTYPE GetToken(mdTypeDef* pTypeDef); + HRESULT STDMETHODCALLTYPE GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame* pFrame, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); - HRESULT GetParameterizedType(CorElementType elementType, + HRESULT STDMETHODCALLTYPE GetParameterizedType(CorElementType elementType, ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[], ICorDebugType** ppType); - HRESULT SetJMCStatus(BOOL bIsJustMyCode); + HRESULT STDMETHODCALLTYPE SetJMCStatus(BOOL bIsJustMyCode); }; #endif diff --git a/src/mono/dbi/cordb-code.h b/src/mono/dbi/cordb-code.h index 4108d051a51a18..8fc9a225eff5f5 100644 --- a/src/mono/dbi/cordb-code.h +++ b/src/mono/dbi/cordb-code.h @@ -15,11 +15,11 @@ class CordbCode : public CordbBaseMono, public ICorDebugCode public: CordbCode(Connection* conn, CordbFunction* func); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -27,24 +27,19 @@ class CordbCode : public CordbBaseMono, public ICorDebugCode { return "CordbCode"; } - HRESULT IsIL(BOOL* pbIL); - HRESULT - GetFunction(ICorDebugFunction** ppFunction); - HRESULT GetAddress(CORDB_ADDRESS* pStart); - HRESULT GetSize(ULONG32* pcBytes); - HRESULT - CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint** ppBreakpoint); - HRESULT GetCode(ULONG32 startOffset, ULONG32 endOffset, ULONG32 cBufferAlloc, BYTE buffer[], ULONG32* pcBufferSize); - HRESULT GetVersionNumber(ULONG32* nVersion); - HRESULT - GetILToNativeMapping(ULONG32 cMap, + HRESULT STDMETHODCALLTYPE IsIL(BOOL* pbIL); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS* pStart); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32* pcBytes); + HRESULT STDMETHODCALLTYPE CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetCode(ULONG32 startOffset, ULONG32 endOffset, ULONG32 cBufferAlloc, BYTE buffer[], ULONG32* pcBufferSize); + HRESULT STDMETHODCALLTYPE GetVersionNumber(ULONG32* nVersion); + HRESULT STDMETHODCALLTYPE GetILToNativeMapping(ULONG32 cMap, ULONG32* pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]); - HRESULT - GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32* pcMap, ULONG32 offsets[]); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32* pcMap, ULONG32 offsets[]); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); CordbFunction* GetFunction() const { diff --git a/src/mono/dbi/cordb-eval.h b/src/mono/dbi/cordb-eval.h index b1772087736aa9..87c87b6c1b257d 100644 --- a/src/mono/dbi/cordb-eval.h +++ b/src/mono/dbi/cordb-eval.h @@ -20,41 +20,38 @@ class CordbEval : public CordbBaseMono, public ICorDebugEval, public ICorDebugEv ~CordbEval(); void EvalComplete(MdbgProtBuffer* pReply); - HRESULT CallParameterizedFunction(ICorDebugFunction* pFunction, + HRESULT STDMETHODCALLTYPE CallParameterizedFunction(ICorDebugFunction* pFunction, ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[], ULONG32 nArgs, ICorDebugValue* ppArgs[]); - HRESULT NewParameterizedObject(ICorDebugFunction* pConstructor, + HRESULT STDMETHODCALLTYPE NewParameterizedObject(ICorDebugFunction* pConstructor, ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[], ULONG32 nArgs, ICorDebugValue* ppArgs[]); - HRESULT NewParameterizedObjectNoConstructor(ICorDebugClass* pClass, ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[]); - HRESULT CallFunction(ICorDebugFunction* pFunction, ULONG32 nArgs, ICorDebugValue* ppArgs[]); - HRESULT NewObject(ICorDebugFunction* pConstructor, ULONG32 nArgs, ICorDebugValue* ppArgs[]); - HRESULT - NewObjectNoConstructor(ICorDebugClass* pClass); - HRESULT NewString(LPCWSTR string); - HRESULT NewArray( + HRESULT STDMETHODCALLTYPE NewParameterizedObjectNoConstructor(ICorDebugClass* pClass, ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[]); + HRESULT STDMETHODCALLTYPE CallFunction(ICorDebugFunction* pFunction, ULONG32 nArgs, ICorDebugValue* ppArgs[]); + HRESULT STDMETHODCALLTYPE NewObject(ICorDebugFunction* pConstructor, ULONG32 nArgs, ICorDebugValue* ppArgs[]); + HRESULT STDMETHODCALLTYPE NewObjectNoConstructor(ICorDebugClass* pClass); + HRESULT STDMETHODCALLTYPE NewString(LPCWSTR string); + HRESULT STDMETHODCALLTYPE NewArray( CorElementType elementType, ICorDebugClass* pElementClass, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]); - HRESULT IsActive(BOOL* pbActive); - HRESULT Abort(void); - HRESULT GetResult(ICorDebugValue** ppResult); - HRESULT GetThread(ICorDebugThread** ppThread); - HRESULT CreateValue(CorElementType elementType, ICorDebugClass* pElementClass, ICorDebugValue** ppValue); - HRESULT - CreateValueForType(ICorDebugType* pType, ICorDebugValue** ppValue); - HRESULT - NewParameterizedArray(ICorDebugType* pElementType, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]); - HRESULT NewStringWithLength(LPCWSTR string, UINT uiLength); - HRESULT RudeAbort(void); - HRESULT QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject); - ULONG AddRef(void) + HRESULT STDMETHODCALLTYPE IsActive(BOOL* pbActive); + HRESULT STDMETHODCALLTYPE Abort(void); + HRESULT STDMETHODCALLTYPE GetResult(ICorDebugValue** ppResult); + HRESULT STDMETHODCALLTYPE GetThread(ICorDebugThread** ppThread); + HRESULT STDMETHODCALLTYPE CreateValue(CorElementType elementType, ICorDebugClass* pElementClass, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE CreateValueForType(ICorDebugType* pType, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE NewParameterizedArray(ICorDebugType* pElementType, ULONG32 rank, ULONG32 dims[], ULONG32 lowBounds[]); + HRESULT STDMETHODCALLTYPE NewStringWithLength(LPCWSTR string, UINT uiLength); + HRESULT STDMETHODCALLTYPE RudeAbort(void); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject); + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } diff --git a/src/mono/dbi/cordb-frame.h b/src/mono/dbi/cordb-frame.h index 1e6464c82809f5..ea2bf232025297 100644 --- a/src/mono/dbi/cordb-frame.h +++ b/src/mono/dbi/cordb-frame.h @@ -23,11 +23,11 @@ class CordbJITILFrame : public CordbBaseMono, public: CordbJITILFrame(Connection* conn, int frameid, int methodId, int il_offset, int flags, CordbThread* thread); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -35,40 +35,31 @@ class CordbJITILFrame : public CordbBaseMono, { return "CordbJITILFrame"; } - HRESULT GetChain(ICorDebugChain** ppChain); - HRESULT GetCode(ICorDebugCode** ppCode); - HRESULT - GetFunction(ICorDebugFunction** ppFunction); - HRESULT GetFunctionToken(mdMethodDef* pToken); - HRESULT GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); - HRESULT GetCaller(ICorDebugFrame** ppFrame); - HRESULT GetCallee(ICorDebugFrame** ppFrame); - HRESULT - CreateStepper(ICorDebugStepper** ppStepper); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE GetChain(ICorDebugChain** ppChain); + HRESULT STDMETHODCALLTYPE GetCode(ICorDebugCode** ppCode); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetFunctionToken(mdMethodDef* pToken); + HRESULT STDMETHODCALLTYPE GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); + HRESULT STDMETHODCALLTYPE GetCaller(ICorDebugFrame** ppFrame); + HRESULT STDMETHODCALLTYPE GetCallee(ICorDebugFrame** ppFrame); + HRESULT STDMETHODCALLTYPE CreateStepper(ICorDebugStepper** ppStepper); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT - GetIP(ULONG32* pnOffset, CorDebugMappingResult* pMappingResult); - HRESULT SetIP(ULONG32 nOffset); - HRESULT - EnumerateLocalVariables(ICorDebugValueEnum** ppValueEnum); - HRESULT GetLocalVariable(DWORD dwIndex, ICorDebugValue** ppValue); - HRESULT - EnumerateArguments(ICorDebugValueEnum** ppValueEnum); - HRESULT GetArgument(DWORD dwIndex, ICorDebugValue** ppValue); - HRESULT GetStackDepth(ULONG32* pDepth); - HRESULT GetStackValue(DWORD dwIndex, ICorDebugValue** ppValue); - HRESULT CanSetIP(ULONG32 nOffset); - HRESULT RemapFunction(ULONG32 newILOffset); - HRESULT - EnumerateTypeParameters(ICorDebugTypeEnum** ppTyParEnum); - HRESULT - GetReturnValueForILOffset(ULONG32 ILoffset, ICorDebugValue** ppReturnValue); - HRESULT - EnumerateLocalVariablesEx(ILCodeKind flags, ICorDebugValueEnum** ppValueEnum); - HRESULT GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, ICorDebugValue** ppValue); - HRESULT GetCodeEx(ILCodeKind flags, ICorDebugCode** ppCode); + HRESULT STDMETHODCALLTYPE GetIP(ULONG32* pnOffset, CorDebugMappingResult* pMappingResult); + HRESULT STDMETHODCALLTYPE SetIP(ULONG32 nOffset); + HRESULT STDMETHODCALLTYPE EnumerateLocalVariables(ICorDebugValueEnum** ppValueEnum); + HRESULT STDMETHODCALLTYPE GetLocalVariable(DWORD dwIndex, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE EnumerateArguments(ICorDebugValueEnum** ppValueEnum); + HRESULT STDMETHODCALLTYPE GetArgument(DWORD dwIndex, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetStackDepth(ULONG32* pDepth); + HRESULT STDMETHODCALLTYPE GetStackValue(DWORD dwIndex, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE CanSetIP(ULONG32 nOffset); + HRESULT STDMETHODCALLTYPE RemapFunction(ULONG32 newILOffset); + HRESULT STDMETHODCALLTYPE EnumerateTypeParameters(ICorDebugTypeEnum** ppTyParEnum); + HRESULT STDMETHODCALLTYPE GetReturnValueForILOffset(ULONG32 ILoffset, ICorDebugValue** ppReturnValue); + HRESULT STDMETHODCALLTYPE EnumerateLocalVariablesEx(ILCodeKind flags, ICorDebugValueEnum** ppValueEnum); + HRESULT STDMETHODCALLTYPE GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetCodeEx(ILCodeKind flags, ICorDebugCode** ppCode); }; class CordbNativeFrame : public CordbBaseMono, public ICorDebugNativeFrame, public ICorDebugNativeFrame2 @@ -78,11 +69,11 @@ class CordbNativeFrame : public CordbBaseMono, public ICorDebugNativeFrame, publ public: CordbNativeFrame(Connection* conn, int frameid, int methodId, int il_offset, int flags, CordbThread* thread); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -91,46 +82,46 @@ class CordbNativeFrame : public CordbBaseMono, public ICorDebugNativeFrame, publ return "CordbNativeFrame"; } ~CordbNativeFrame(); - HRESULT GetIP(ULONG32* pnOffset); - HRESULT SetIP(ULONG32 nOffset); - HRESULT GetRegisterSet(ICorDebugRegisterSet** ppRegisters); - HRESULT GetLocalRegisterValue(CorDebugRegister reg, + HRESULT STDMETHODCALLTYPE GetIP(ULONG32* pnOffset); + HRESULT STDMETHODCALLTYPE SetIP(ULONG32 nOffset); + HRESULT STDMETHODCALLTYPE GetRegisterSet(ICorDebugRegisterSet** ppRegisters); + HRESULT STDMETHODCALLTYPE GetLocalRegisterValue(CorDebugRegister reg, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue** ppValue); - HRESULT GetLocalDoubleRegisterValue(CorDebugRegister highWordReg, + HRESULT STDMETHODCALLTYPE GetLocalDoubleRegisterValue(CorDebugRegister highWordReg, CorDebugRegister lowWordReg, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue** ppValue); - HRESULT GetLocalMemoryValue(CORDB_ADDRESS address, + HRESULT STDMETHODCALLTYPE GetLocalMemoryValue(CORDB_ADDRESS address, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue** ppValue); - HRESULT GetLocalRegisterMemoryValue(CorDebugRegister highWordReg, + HRESULT STDMETHODCALLTYPE GetLocalRegisterMemoryValue(CorDebugRegister highWordReg, CORDB_ADDRESS lowWordAddress, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue** ppValue); - HRESULT GetLocalMemoryRegisterValue(CORDB_ADDRESS highWordAddress, + HRESULT STDMETHODCALLTYPE GetLocalMemoryRegisterValue(CORDB_ADDRESS highWordAddress, CorDebugRegister lowWordRegister, ULONG cbSigBlob, PCCOR_SIGNATURE pvSigBlob, ICorDebugValue** ppValue); - HRESULT CanSetIP(ULONG32 nOffset); - HRESULT GetChain(ICorDebugChain** ppChain); - HRESULT GetCode(ICorDebugCode** ppCode); - HRESULT GetFunction(ICorDebugFunction** ppFunction); - HRESULT GetFunctionToken(mdMethodDef* pToken); - HRESULT GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); - HRESULT GetCaller(ICorDebugFrame** ppFrame); - HRESULT GetCallee(ICorDebugFrame** ppFrame); - HRESULT CreateStepper(ICorDebugStepper** ppStepper); - HRESULT QueryInterface(REFIID riid, void** ppvObject); + HRESULT STDMETHODCALLTYPE CanSetIP(ULONG32 nOffset); + HRESULT STDMETHODCALLTYPE GetChain(ICorDebugChain** ppChain); + HRESULT STDMETHODCALLTYPE GetCode(ICorDebugCode** ppCode); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetFunctionToken(mdMethodDef* pToken); + HRESULT STDMETHODCALLTYPE GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd); + HRESULT STDMETHODCALLTYPE GetCaller(ICorDebugFrame** ppFrame); + HRESULT STDMETHODCALLTYPE GetCallee(ICorDebugFrame** ppFrame); + HRESULT STDMETHODCALLTYPE CreateStepper(ICorDebugStepper** ppStepper); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); - HRESULT IsChild(BOOL* pIsChild); - HRESULT IsMatchingParentFrame(ICorDebugNativeFrame2* pPotentialParentFrame, BOOL* pIsParent); - HRESULT GetStackParameterSize(ULONG32* pSize); + HRESULT STDMETHODCALLTYPE IsChild(BOOL* pIsChild); + HRESULT STDMETHODCALLTYPE IsMatchingParentFrame(ICorDebugNativeFrame2* pPotentialParentFrame, BOOL* pIsParent); + HRESULT STDMETHODCALLTYPE GetStackParameterSize(ULONG32* pSize); }; class CordbFrameEnum : public CordbBaseMono, public ICorDebugFrameEnum @@ -141,11 +132,11 @@ class CordbFrameEnum : public CordbBaseMono, public ICorDebugFrameEnum public: CordbFrameEnum(Connection* conn, CordbThread* thread); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -154,12 +145,12 @@ class CordbFrameEnum : public CordbBaseMono, public ICorDebugFrameEnum return "CordbFrameEnum"; } ~CordbFrameEnum(); - HRESULT Next(ULONG celt, ICorDebugFrame* frames[], ULONG* pceltFetched); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum** ppEnum); - HRESULT GetCount(ULONG* pcelt); - HRESULT QueryInterface(REFIID riid, void** ppvObject); + HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugFrame* frames[], ULONG* pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum** ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG* pcelt); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-function.h b/src/mono/dbi/cordb-function.h index b2c44ac73c4bc7..7b74fb0bd54a73 100644 --- a/src/mono/dbi/cordb-function.h +++ b/src/mono/dbi/cordb-function.h @@ -23,11 +23,11 @@ class CordbFunction : public CordbBaseMono, public: CordbFunction(Connection* conn, mdToken token, int id, CordbModule* module); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -40,29 +40,22 @@ class CordbFunction : public CordbBaseMono, { return m_debuggerId; } - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT GetModule(ICorDebugModule** ppModule); - HRESULT GetClass(ICorDebugClass** ppClass); - HRESULT GetToken(mdMethodDef* pMethodDef); - HRESULT GetILCode(ICorDebugCode** ppCode); - HRESULT GetNativeCode(ICorDebugCode** ppCode); - HRESULT - CreateBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint); - HRESULT - GetLocalVarSigToken(mdSignature* pmdSig); - HRESULT - GetCurrentVersionNumber(ULONG32* pnCurrentVersion); - HRESULT SetJMCStatus(BOOL bIsJustMyCode); - HRESULT GetJMCStatus(BOOL* pbIsJustMyCode); - HRESULT - EnumerateNativeCode(ICorDebugCodeEnum** ppCodeEnum); - HRESULT GetVersionNumber(ULONG32* pnVersion); - HRESULT - GetActiveReJitRequestILCode(ICorDebugILCode** ppReJitedILCode); - HRESULT - CreateNativeBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetModule(ICorDebugModule** ppModule); + HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass** ppClass); + HRESULT STDMETHODCALLTYPE GetToken(mdMethodDef* pMethodDef); + HRESULT STDMETHODCALLTYPE GetILCode(ICorDebugCode** ppCode); + HRESULT STDMETHODCALLTYPE GetNativeCode(ICorDebugCode** ppCode); + HRESULT STDMETHODCALLTYPE CreateBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetLocalVarSigToken(mdSignature* pmdSig); + HRESULT STDMETHODCALLTYPE GetCurrentVersionNumber(ULONG32* pnCurrentVersion); + HRESULT STDMETHODCALLTYPE SetJMCStatus(BOOL bIsJustMyCode); + HRESULT STDMETHODCALLTYPE GetJMCStatus(BOOL* pbIsJustMyCode); + HRESULT STDMETHODCALLTYPE EnumerateNativeCode(ICorDebugCodeEnum** ppCodeEnum); + HRESULT STDMETHODCALLTYPE GetVersionNumber(ULONG32* pnVersion); + HRESULT STDMETHODCALLTYPE GetActiveReJitRequestILCode(ICorDebugILCode** ppReJitedILCode); + HRESULT STDMETHODCALLTYPE CreateNativeBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint); mdToken GetMetadataToken() const { return m_metadataToken; diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index e0604c7df7ba05..386b070225e722 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -32,11 +32,11 @@ class CordbProcess : public CordbBaseMono, public: ArrayList* appDomains; CordbProcess(Cordb* cordb); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -49,94 +49,67 @@ class CordbProcess : public CordbBaseMono, return m_pCordb; } ~CordbProcess(); - HRESULT EnumerateLoaderHeapMemoryRegions(ICorDebugMemoryRangeEnum** ppRanges); - HRESULT EnableGCNotificationEvents(BOOL fEnable); - HRESULT - EnableExceptionCallbacksOutsideOfMyCode(BOOL enableExceptionsOutsideOfJMC); - HRESULT - SetWriteableMetadataUpdateMode(WriteableMetadataUpdateMode flags); - HRESULT - GetGCHeapInformation(COR_HEAPINFO* pHeapInfo); - HRESULT - EnumerateHeap(ICorDebugHeapEnum** ppObjects); - HRESULT - EnumerateHeapRegions(ICorDebugHeapSegmentEnum** ppRegions); - HRESULT - GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue** pObject); - HRESULT - EnumerateGCReferences(BOOL enumerateWeakReferences, ICorDebugGCReferenceEnum** ppEnum); - HRESULT - EnumerateHandles(CorGCReferenceType types, ICorDebugGCReferenceEnum** ppEnum); - HRESULT GetTypeID(CORDB_ADDRESS obj, COR_TYPEID* pId); - HRESULT GetTypeForTypeID(COR_TYPEID id, ICorDebugType** ppType); - HRESULT GetArrayLayout(COR_TYPEID id, COR_ARRAY_LAYOUT* pLayout); - HRESULT GetTypeLayout(COR_TYPEID id, COR_TYPE_LAYOUT* pLayout); - HRESULT GetTypeFields(COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], ULONG32* pceltNeeded); - HRESULT - EnableNGENPolicy(CorDebugNGENPolicy ePolicy); - HRESULT - Filter(const BYTE pRecord[], + HRESULT STDMETHODCALLTYPE EnumerateLoaderHeapMemoryRegions(ICorDebugMemoryRangeEnum** ppRanges); + HRESULT STDMETHODCALLTYPE EnableGCNotificationEvents(BOOL fEnable); + HRESULT STDMETHODCALLTYPE EnableExceptionCallbacksOutsideOfMyCode(BOOL enableExceptionsOutsideOfJMC); + HRESULT STDMETHODCALLTYPE SetWriteableMetadataUpdateMode(WriteableMetadataUpdateMode flags); + HRESULT STDMETHODCALLTYPE GetGCHeapInformation(COR_HEAPINFO* pHeapInfo); + HRESULT STDMETHODCALLTYPE EnumerateHeap(ICorDebugHeapEnum** ppObjects); + HRESULT STDMETHODCALLTYPE EnumerateHeapRegions(ICorDebugHeapSegmentEnum** ppRegions); + HRESULT STDMETHODCALLTYPE GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue** pObject); + HRESULT STDMETHODCALLTYPE EnumerateGCReferences(BOOL enumerateWeakReferences, ICorDebugGCReferenceEnum** ppEnum); + HRESULT STDMETHODCALLTYPE EnumerateHandles(CorGCReferenceType types, ICorDebugGCReferenceEnum** ppEnum); + HRESULT STDMETHODCALLTYPE GetTypeID(CORDB_ADDRESS obj, COR_TYPEID* pId); + HRESULT STDMETHODCALLTYPE GetTypeForTypeID(COR_TYPEID id, ICorDebugType** ppType); + HRESULT STDMETHODCALLTYPE GetArrayLayout(COR_TYPEID id, COR_ARRAY_LAYOUT* pLayout); + HRESULT STDMETHODCALLTYPE GetTypeLayout(COR_TYPEID id, COR_TYPE_LAYOUT* pLayout); + HRESULT STDMETHODCALLTYPE GetTypeFields(COR_TYPEID id, ULONG32 celt, COR_FIELD fields[], ULONG32* pceltNeeded); + HRESULT STDMETHODCALLTYPE EnableNGENPolicy(CorDebugNGENPolicy ePolicy); + HRESULT STDMETHODCALLTYPE Filter(const BYTE pRecord[], DWORD countBytes, CorDebugRecordFormat format, DWORD dwFlags, DWORD dwThreadId, ICorDebugManagedCallback* pCallback, CORDB_CONTINUE_STATUS* pContinueStatus); - HRESULT - ProcessStateChanged(CorDebugStateChange eChange); - HRESULT SetEnableCustomNotification(ICorDebugClass* pClass, BOOL fEnable); - HRESULT GetID(DWORD* pdwProcessId); - HRESULT GetHandle(HPROCESS* phProcessHandle); - HRESULT GetThread(DWORD dwThreadId, ICorDebugThread** ppThread); - HRESULT - EnumerateObjects(ICorDebugObjectEnum** ppObjects); - HRESULT IsTransitionStub(CORDB_ADDRESS address, BOOL* pbTransitionStub); - HRESULT IsOSSuspended(DWORD threadID, BOOL* pbSuspended); - HRESULT - GetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); - HRESULT - SetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); - HRESULT - ReadMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* read); - HRESULT - WriteMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* written); - HRESULT ClearCurrentException(DWORD threadID); - HRESULT EnableLogMessages(BOOL fOnOff); - HRESULT - ModifyLogSwitch(_In_ WCHAR* pLogSwitchName, LONG lLevel); - HRESULT - EnumerateAppDomains(ICorDebugAppDomainEnum** ppAppDomains); - HRESULT GetObject(ICorDebugValue** ppObject); - HRESULT ThreadForFiberCookie(DWORD fiberCookie, ICorDebugThread** ppThread); - HRESULT GetHelperThreadID(DWORD* pThreadID); - HRESULT GetThreadForTaskID(TASKID taskid, ICorDebugThread2** ppThread); - HRESULT GetVersion(COR_VERSION* version); - HRESULT SetUnmanagedBreakpoint(CORDB_ADDRESS address, ULONG32 bufsize, BYTE buffer[], ULONG32* bufLen); - HRESULT - ClearUnmanagedBreakpoint(CORDB_ADDRESS address); - HRESULT - SetDesiredNGENCompilerFlags(DWORD pdwFlags); - HRESULT - GetDesiredNGENCompilerFlags(DWORD* pdwFlags); - HRESULT - GetReferenceValueFromGCHandle(UINT_PTR handle, ICorDebugReferenceValue** pOutValue); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE ProcessStateChanged(CorDebugStateChange eChange); + HRESULT STDMETHODCALLTYPE SetEnableCustomNotification(ICorDebugClass* pClass, BOOL fEnable); + HRESULT STDMETHODCALLTYPE GetID(DWORD* pdwProcessId); + HRESULT STDMETHODCALLTYPE GetHandle(HPROCESS* phProcessHandle); + HRESULT STDMETHODCALLTYPE GetThread(DWORD dwThreadId, ICorDebugThread** ppThread); + HRESULT STDMETHODCALLTYPE EnumerateObjects(ICorDebugObjectEnum** ppObjects); + HRESULT STDMETHODCALLTYPE IsTransitionStub(CORDB_ADDRESS address, BOOL* pbTransitionStub); + HRESULT STDMETHODCALLTYPE IsOSSuspended(DWORD threadID, BOOL* pbSuspended); + HRESULT STDMETHODCALLTYPE GetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); + HRESULT STDMETHODCALLTYPE SetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE context[]); + HRESULT STDMETHODCALLTYPE ReadMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* read); + HRESULT STDMETHODCALLTYPE WriteMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* written); + HRESULT STDMETHODCALLTYPE ClearCurrentException(DWORD threadID); + HRESULT STDMETHODCALLTYPE EnableLogMessages(BOOL fOnOff); + HRESULT STDMETHODCALLTYPE ModifyLogSwitch(_In_ WCHAR* pLogSwitchName, LONG lLevel); + HRESULT STDMETHODCALLTYPE EnumerateAppDomains(ICorDebugAppDomainEnum** ppAppDomains); + HRESULT STDMETHODCALLTYPE GetObject(ICorDebugValue** ppObject); + HRESULT STDMETHODCALLTYPE ThreadForFiberCookie(DWORD fiberCookie, ICorDebugThread** ppThread); + HRESULT STDMETHODCALLTYPE GetHelperThreadID(DWORD* pThreadID); + HRESULT STDMETHODCALLTYPE GetThreadForTaskID(TASKID taskid, ICorDebugThread2** ppThread); + HRESULT STDMETHODCALLTYPE GetVersion(COR_VERSION* version); + HRESULT STDMETHODCALLTYPE SetUnmanagedBreakpoint(CORDB_ADDRESS address, ULONG32 bufsize, BYTE buffer[], ULONG32* bufLen); + HRESULT STDMETHODCALLTYPE ClearUnmanagedBreakpoint(CORDB_ADDRESS address); + HRESULT STDMETHODCALLTYPE SetDesiredNGENCompilerFlags(DWORD pdwFlags); + HRESULT STDMETHODCALLTYPE GetDesiredNGENCompilerFlags(DWORD* pdwFlags); + HRESULT STDMETHODCALLTYPE GetReferenceValueFromGCHandle(UINT_PTR handle, ICorDebugReferenceValue** pOutValue); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT Stop(DWORD dwTimeoutIgnored); - HRESULT Continue(BOOL fIsOutOfBand); - HRESULT IsRunning(BOOL* pbRunning); - HRESULT HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued); - HRESULT - EnumerateThreads(ICorDebugThreadEnum** ppThreads); - HRESULT - SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread); - HRESULT Detach(void); - HRESULT Terminate(UINT exitCode); - HRESULT - CanCommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); - HRESULT - CommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); + HRESULT STDMETHODCALLTYPE Stop(DWORD dwTimeoutIgnored); + HRESULT STDMETHODCALLTYPE Continue(BOOL fIsOutOfBand); + HRESULT STDMETHODCALLTYPE IsRunning(BOOL* pbRunning); + HRESULT STDMETHODCALLTYPE HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued); + HRESULT STDMETHODCALLTYPE EnumerateThreads(ICorDebugThreadEnum** ppThreads); + HRESULT STDMETHODCALLTYPE SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread); + HRESULT STDMETHODCALLTYPE Detach(void); + HRESULT STDMETHODCALLTYPE Terminate(UINT exitCode); + HRESULT STDMETHODCALLTYPE CanCommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); + HRESULT STDMETHODCALLTYPE CommitChanges(ULONG cSnapshots, ICorDebugEditAndContinueSnapshot* pSnapshots[], ICorDebugErrorInfoEnum** pError); void AddThread(CordbThread* thread); void AddFunction(CordbFunction* function); diff --git a/src/mono/dbi/cordb-register.h b/src/mono/dbi/cordb-register.h index 1c136307a18587..58f452b428a862 100644 --- a/src/mono/dbi/cordb-register.h +++ b/src/mono/dbi/cordb-register.h @@ -16,11 +16,11 @@ class CordbRegisterSet : public CordbBaseMono, public ICorDebugRegisterSet public: CordbRegisterSet(Connection* conn, uint8_t* ctx, uint32_t ctx_len); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -28,16 +28,13 @@ class CordbRegisterSet : public CordbBaseMono, public ICorDebugRegisterSet { return "CordbRegisterSet"; } - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); - HRESULT - GetRegistersAvailable(ULONG64* pAvailable); - HRESULT - GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]); - HRESULT SetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]); - HRESULT GetThreadContext(ULONG32 contextSize, BYTE context[]); - HRESULT SetThreadContext(ULONG32 contextSize, BYTE context[]); + HRESULT STDMETHODCALLTYPE GetRegistersAvailable(ULONG64* pAvailable); + HRESULT STDMETHODCALLTYPE GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]); + HRESULT STDMETHODCALLTYPE SetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]); + HRESULT STDMETHODCALLTYPE GetThreadContext(ULONG32 contextSize, BYTE context[]); + HRESULT STDMETHODCALLTYPE SetThreadContext(ULONG32 contextSize, BYTE context[]); }; #endif diff --git a/src/mono/dbi/cordb-stepper.h b/src/mono/dbi/cordb-stepper.h index 3aec9c473e1f4c..e3a9d5ebe93fc2 100644 --- a/src/mono/dbi/cordb-stepper.h +++ b/src/mono/dbi/cordb-stepper.h @@ -17,11 +17,11 @@ class CordbStepper : public CordbBaseMono, public ICorDebugStepper, public ICorD public: CordbStepper(Connection* conn, CordbThread* thread); ~CordbStepper(); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -29,17 +29,17 @@ class CordbStepper : public CordbBaseMono, public ICorDebugStepper, public ICorD { return "CordbStepper"; } - HRESULT IsActive(BOOL* pbActive); - HRESULT Deactivate(void); - HRESULT SetInterceptMask(CorDebugIntercept mask); - HRESULT SetUnmappedStopMask(CorDebugUnmappedStop mask); - HRESULT Step(BOOL bStepIn); - HRESULT StepRange(BOOL bStepIn, COR_DEBUG_STEP_RANGE ranges[], ULONG32 cRangeCount); - HRESULT StepOut(void); - HRESULT SetRangeIL(BOOL bIL); - HRESULT QueryInterface(REFIID riid, void** ppvObject); + HRESULT STDMETHODCALLTYPE IsActive(BOOL* pbActive); + HRESULT STDMETHODCALLTYPE Deactivate(void); + HRESULT STDMETHODCALLTYPE SetInterceptMask(CorDebugIntercept mask); + HRESULT STDMETHODCALLTYPE SetUnmappedStopMask(CorDebugUnmappedStop mask); + HRESULT STDMETHODCALLTYPE Step(BOOL bStepIn); + HRESULT STDMETHODCALLTYPE StepRange(BOOL bStepIn, COR_DEBUG_STEP_RANGE ranges[], ULONG32 cRangeCount); + HRESULT STDMETHODCALLTYPE StepOut(void); + HRESULT STDMETHODCALLTYPE SetRangeIL(BOOL bIL); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); - HRESULT SetJMC(BOOL fIsJMCStepper); + HRESULT STDMETHODCALLTYPE SetJMC(BOOL fIsJMCStepper); }; #endif diff --git a/src/mono/dbi/cordb-symbol.h b/src/mono/dbi/cordb-symbol.h new file mode 100644 index 00000000000000..8dfde91e47cdc0 --- /dev/null +++ b/src/mono/dbi/cordb-symbol.h @@ -0,0 +1,667 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// File: CORDB-SYMBOL.H +// + +#ifndef __MONO_DEBUGGER_CORDB_SYMBOL_H__ +#define __MONO_DEBUGGER_CORDB_SYMBOL_H__ + +#include +#include + +#define COR_GLOBAL_PARENT_TOKEN TokenFromRid(1, mdtTypeDef) + +class CLiteWeightStgdbRW; + +class RegMeta : public CordbBaseMono, + public IMetaDataImport2, + public IMetaDataAssemblyImport { + CLiteWeightStgdbRW *m_pStgdb; + +public: + RegMeta(CordbAssembly *cordbAssembly, CordbModule *cordbModule); + ~RegMeta(); + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } + const char *GetClassName() { return "CordbRegMeta"; } + + inline int IsGlobalMethodParentTk(mdTypeDef td) { + return (td == mdTypeDefNil || td == mdTokenNil); + } + + int inline IsGlobalMethodParent(mdTypeDef *ptd) { + if (IsGlobalMethodParentTk(*ptd)) { + *ptd = COR_GLOBAL_PARENT_TOKEN; + return (true); + } + return (false); + } + + int inline IsGlobalMethodParentToken(mdTypeDef td) { + return (td == COR_GLOBAL_PARENT_TOKEN); + } + + STDMETHOD(EnumGenericParams) + (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken + tk, // [IN] TypeDef or MethodDef whose generic parameters are requested + mdGenericParam rGenericParams[], // [OUT] Put GenericParams here. + ULONG cMax, // [IN] Max GenericParams to put. + ULONG *pcGenericParams); + + STDMETHOD(GetGenericParamProps) + ( // S_OK or error. + mdGenericParam gp, // [IN] GenericParam + ULONG *pulParamSeq, // [OUT] Index of the type parameter + DWORD *pdwParamFlags, // [OUT] Flags, for future use (e.g. variance) + mdToken *ptOwner, // [OUT] Owner (TypeDef or MethodDef) + DWORD *reserved, // [OUT] For future use (e.g. non-type parameters) + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR wzname, // [OUT] Put name here + ULONG cchName, // [IN] Size of buffer + ULONG *pchName); // [OUT] Put size of name (wide chars) here. + + STDMETHOD(GetMethodSpecProps) + (mdMethodSpec mi, // [IN] The method instantiation + mdToken *tkParent, // [OUT] MethodDef or MemberRef + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob); // [OUT] actual size of signature blob + + STDMETHOD(EnumGenericParamConstraints) + (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdGenericParam tk, // [IN] GenericParam whose constraints are requested + mdGenericParamConstraint + rGenericParamConstraints[], // [OUT] Put GenericParamConstraints here. + ULONG cMax, // [IN] Max GenericParamConstraints to put. + ULONG *pcGenericParamConstraints); // [OUT] Put # put here. + + STDMETHOD(GetGenericParamConstraintProps) + ( // S_OK or error. + mdGenericParamConstraint gpc, // [IN] GenericParamConstraint + mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained + mdToken *ptkConstraintType); // [OUT] TypeDef/Ref/Spec constraint + + STDMETHOD(GetPEKind) + ( // S_OK or error. + DWORD *pdwPEKind, // [OUT] The kind of PE (0 - not a PE) + DWORD *pdwMAchine); // [OUT] Machine as defined in NT header + + STDMETHOD(GetVersionString) + ( // S_OK or error. + _Out_writes_to_opt_(ccBufSize, *pccBufSize) + LPWSTR pwzBuf, // [OUT] Put version string here. + DWORD ccBufSize, // [IN] size of the buffer, in wide chars + DWORD *pccBufSize); // [OUT] Size of the version string, wide chars, + // including terminating nul. + + STDMETHOD(EnumMethodSpecs) + (HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tk, // [IN] MethodDef or MemberRef whose MethodSpecs are requested + mdMethodSpec rMethodSpecs[], // [OUT] Put MethodSpecs here. + ULONG cMax, // [IN] Max tokens to put. + ULONG *pcMethodSpecs); // [OUT] Put actual count here. + + STDMETHOD(GetAssemblyProps) + ( // S_OK or error. + mdAssembly mda, // [IN] The Assembly for which to get the properties. + const void **ppbPublicKey, // [OUT] Pointer to the public key. + ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. + ULONG *pulHashAlgId, // [OUT] Hash Algorithm. + _Out_writes_to_opt_(cchName, *pchName) LPWSTR + szName, // [OUT] MdbgProtBuffer to fill with assembly's simply name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. + DWORD *pdwAssemblyFlags); // [OUT] Flags. + + STDMETHOD(GetAssemblyRefProps) + ( // S_OK or error. + mdAssemblyRef + mdar, // [IN] The AssemblyRef for which to get the properties. + const void * + *ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token. + ULONG *pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or + // token. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData. + const void **ppbHashValue, // [OUT] Hash blob. + ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob. + DWORD *pdwAssemblyRefFlags); // [OUT] Flags. + + STDMETHOD(GetFileProps) + ( // S_OK or error. + mdFile mdf, // [IN] The File for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob. + ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob. + DWORD *pdwFileFlags); // [OUT] Flags. + + STDMETHOD(GetExportedTypeProps) + ( // S_OK or error. + mdExportedType + mdct, // [IN] The ExportedType for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + mdToken * + ptkImplementation, // [OUT] mdFile or mdAssemblyRef or mdExportedType. + mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file. + DWORD *pdwExportedTypeFlags); // [OUT] Flags. + + STDMETHOD(GetManifestResourceProps) + ( // S_OK or error. + mdManifestResource + mdmr, // [IN] The ManifestResource for which to get the properties. + _Out_writes_to_opt_(cchName, *pchName) + LPWSTR szName, // [OUT] MdbgProtBuffer to fill with name. + ULONG cchName, // [IN] Size of buffer in wide chars. + ULONG *pchName, // [OUT] Actual # of wide chars in name. + mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides + // the ManifestResource. + DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within + // the file. + DWORD *pdwResourceFlags); // [OUT] Flags. + + STDMETHOD(EnumAssemblyRefs) + ( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdAssemblyRef rAssemblyRefs[], // [OUT] Put AssemblyRefs here. + ULONG cMax, // [IN] Max AssemblyRefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + STDMETHOD(EnumFiles) + ( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdFile rFiles[], // [OUT] Put Files here. + ULONG cMax, // [IN] Max Files to put. + ULONG *pcTokens); // [OUT] Put # put here. + + STDMETHOD(EnumExportedTypes) + ( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdExportedType rExportedTypes[], // [OUT] Put ExportedTypes here. + ULONG cMax, // [IN] Max ExportedTypes to put. + ULONG *pcTokens); // [OUT] Put # put here. + + STDMETHOD(EnumManifestResources) + ( // S_OK or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdManifestResource + rManifestResources[], // [OUT] Put ManifestResources here. + ULONG cMax, // [IN] Max Resources to put. + ULONG *pcTokens); // [OUT] Put # put here. + + STDMETHOD(GetAssemblyFromScope) + ( // S_OK or error + mdAssembly *ptkAssembly); + + STDMETHOD(FindExportedTypeByName) + ( // S_OK or error + LPCWSTR szName, // [IN] Name of the ExportedType. + mdToken mdtExportedType, // [IN] ExportedType for the enclosing class. + mdExportedType + *ptkExportedType); // [OUT] Put the ExportedType token here. + + STDMETHOD(FindManifestResourceByName) + ( // S_OK or error + LPCWSTR szName, // [IN] Name of the ManifestResource. + mdManifestResource + *ptkManifestResource); // [OUT] Put the ManifestResource token here. + + STDMETHOD(FindAssembliesByName) + ( // S_OK or error + LPCWSTR szAppBase, // [IN] optional - can be NULL + LPCWSTR szPrivateBin, // [IN] optional - can be NULL + LPCWSTR szAssemblyName, // [IN] required - this is the assembly you are + // requesting + IUnknown *ppIUnk[], // [OUT] put IMetaDataAssemblyImport pointers here + ULONG cMax, // [IN] The max number to put + ULONG *pcAssemblies); // [OUT] The number of assemblies returned. + + // IUnknown methods + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppvObj); + + // IMetaDataImport functions + + void CloseEnum(HCORENUM hEnum); + HRESULT STDMETHODCALLTYPE CountEnum(HCORENUM hEnum, ULONG *pulCount); + HRESULT STDMETHODCALLTYPE ResetEnum(HCORENUM hEnum, ULONG ulPos); + HRESULT STDMETHODCALLTYPE EnumTypeDefs(HCORENUM *phEnum, mdTypeDef rTypeDefs[], ULONG cMax, + ULONG *pcTypeDefs); + HRESULT STDMETHODCALLTYPE EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td, + mdInterfaceImpl rImpls[], ULONG cMax, + ULONG *pcImpls); + HRESULT STDMETHODCALLTYPE EnumTypeRefs(HCORENUM *phEnum, mdTypeRef rTypeRefs[], ULONG cMax, + ULONG *pcTypeRefs); + + HRESULT STDMETHODCALLTYPE FindTypeDefByName( // S_OK or error. + LPCWSTR szTypeDef, // [IN] Name of the Type. + mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class. + mdTypeDef *ptd); // [OUT] Put the TypeDef token here. + + HRESULT STDMETHODCALLTYPE GetScopeProps( // S_OK or error. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] Put the name here. + ULONG cchName, // [IN] Size of name buffer in wide chars. + ULONG *pchName, // [OUT] Put size of name (wide chars) here. + GUID *pmvid); // [OUT, OPTIONAL] Put MVID here. + + HRESULT STDMETHODCALLTYPE GetModuleFromScope( // S_OK. + mdModule *pmd); // [OUT] Put mdModule token here. + + HRESULT STDMETHODCALLTYPE GetTypeDefProps( // S_OK or error. + mdTypeDef td, // [IN] TypeDef token for inquiry. + __out_ecount_part_opt(cchTypeDef, *pchTypeDef) + LPWSTR szTypeDef, // [OUT] Put name here. + ULONG cchTypeDef, // [IN] size of name buffer in wide chars. + ULONG *pchTypeDef, // [OUT] put size of name (wide chars) here. + DWORD *pdwTypeDefFlags, // [OUT] Put flags here. + mdToken *ptkExtends); // [OUT] Put base class TypeDef/TypeRef here. + + HRESULT STDMETHODCALLTYPE GetInterfaceImplProps( // S_OK or error. + mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token. + mdTypeDef *pClass, // [OUT] Put implementing class token here. + mdToken *ptkIface); // [OUT] Put implemented interface token here. + + HRESULT STDMETHODCALLTYPE GetTypeRefProps( // S_OK or error. + mdTypeRef tr, // [IN] TypeRef token. + mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or + // AssemblyRef. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] Name of the TypeRef. + ULONG cchName, // [IN] Size of buffer. + ULONG *pchName); // [OUT] Size of Name. + + HRESULT STDMETHODCALLTYPE ResolveTypeRef(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, + mdTypeDef *ptd); + + HRESULT STDMETHODCALLTYPE EnumMembers( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + mdToken rMembers[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMembersWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdToken rMembers[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMethods( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + mdMethodDef rMethods[], // [OUT] Put MethodDefs here. + ULONG cMax, // [IN] Max MethodDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMethodsWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdMethodDef rMethods[], // [OU] Put MethodDefs here. + ULONG cMax, // [IN] Max MethodDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumFields( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + mdFieldDef rFields[], // [OUT] Put FieldDefs here. + ULONG cMax, // [IN] Max FieldDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumFieldsWithName( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef cl, // [IN] TypeDef to scope the enumeration. + LPCWSTR szName, // [IN] Limit results to those with this name. + mdFieldDef rFields[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumParams( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdMethodDef mb, // [IN] MethodDef to scope the enumeration. + mdParamDef rParams[], // [OUT] Put ParamDefs here. + ULONG cMax, // [IN] Max ParamDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMemberRefs( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tkParent, // [IN] Parent token to scope the enumeration. + mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here. + ULONG cMax, // [IN] Max MemberRefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumMethodImpls( // S_OK, S_FALSE, or error + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdToken rMethodBody[], // [OUT] Put Method Body tokens here. + mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here. + ULONG cMax, // [IN] Max tokens to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumPermissionSets( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken tk, // [IN] if !NIL, token to scope the enumeration. + DWORD dwActions, // [IN] if !0, return only these actions. + mdPermission rPermission[], // [OUT] Put Permissions here. + ULONG cMax, // [IN] Max Permissions to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE FindMember( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdToken *pmb); // [OUT] matching memberdef + + HRESULT STDMETHODCALLTYPE FindMethod( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdMethodDef *pmb); // [OUT] matching memberdef + + HRESULT STDMETHODCALLTYPE FindField( + mdTypeDef td, // [IN] given typedef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdFieldDef *pmb); // [OUT] matching memberdef + + HRESULT STDMETHODCALLTYPE FindMemberRef( + mdTypeRef td, // [IN] given typeRef + LPCWSTR szName, // [IN] member name + PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature + ULONG cbSigBlob, // [IN] count of bytes in the signature blob + mdMemberRef *pmr); // [OUT] matching memberref + + HRESULT STDMETHODCALLTYPE GetMethodProps( + mdMethodDef mb, // The method for which to get props. + mdTypeDef *pClass, // Put method's class here. + __out_ecount_part_opt(cchMethod, *pchMethod) + LPWSTR szMethod, // Put method's name here. + ULONG cchMethod, // Size of szMethod buffer in wide chars. + ULONG *pchMethod, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + ULONG *pulCodeRVA, // [OUT] codeRVA + DWORD *pdwImplFlags); // [OUT] Impl. Flags + + HRESULT STDMETHODCALLTYPE GetMemberRefProps( // S_OK or error. + mdMemberRef mr, // [IN] given memberref + mdToken *ptk, // [OUT] Put classref or classdef here. + __out_ecount_part_opt(cchMember, *pchMember) + LPWSTR szMember, // [OUT] buffer to fill for member's name + ULONG cchMember, // [IN] the count of char of szMember + ULONG *pchMember, // [OUT] actual count of char in member name + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value + ULONG *pbSig); // [OUT] actual size of signature blob + + HRESULT STDMETHODCALLTYPE EnumProperties( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdProperty rProperties[], // [OUT] Put Properties here. + ULONG cMax, // [IN] Max properties to put. + ULONG *pcProperties); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE EnumEvents( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdTypeDef td, // [IN] TypeDef to scope the enumeration. + mdEvent rEvents[], // [OUT] Put events here. + ULONG cMax, // [IN] Max events to put. + ULONG *pcEvents); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE GetEventProps( // S_OK, S_FALSE, or error. + mdEvent ev, // [IN] event token + mdTypeDef *pClass, // [OUT] typedef containing the event declarion. + LPCWSTR szEvent, // [OUT] Event name + ULONG cchEvent, // [IN] the count of wchar of szEvent + ULONG *pchEvent, // [OUT] actual count of wchar for event's name + DWORD *pdwEventFlags, // [OUT] Event flags. + mdToken *ptkEventType, // [OUT] EventType class + mdMethodDef *pmdAddOn, // [OUT] AddOn method of the event + mdMethodDef *pmdRemoveOn, // [OUT] RemoveOn method of the event + mdMethodDef *pmdFire, // [OUT] Fire method of the event + mdMethodDef rmdOtherMethod[], // [OUT] other method of the event + ULONG cMax, // [IN] size of rmdOtherMethod + ULONG *pcOtherMethod); // [OUT] total number of other method of this event + + HRESULT STDMETHODCALLTYPE EnumMethodSemantics( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdMethodDef mb, // [IN] MethodDef to scope the enumeration. + mdToken rEventProp[], // [OUT] Put Event/Property here. + ULONG cMax, // [IN] Max properties to put. + ULONG *pcEventProp); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE GetMethodSemantics( // S_OK, S_FALSE, or error. + mdMethodDef mb, // [IN] method token + mdToken tkEventProp, // [IN] event/property token. + DWORD *pdwSemanticsFlags); // [OUT] the role flags for the + // method/propevent pair + + HRESULT + GetClassLayout(mdTypeDef td, // [IN] give typedef + DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16 + COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array + ULONG cMax, // [IN] size of the array + ULONG *pcFieldOffset, // [OUT] needed array size + ULONG *pulClassSize); // [OUT] the size of the class + + HRESULT STDMETHODCALLTYPE GetFieldMarshal( + mdToken tk, // [IN] given a field's memberdef + PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field + ULONG *pcbNativeType); // [OUT] the count of bytes of *ppvNativeType + + HRESULT STDMETHODCALLTYPE GetRVA( // S_OK or error. + mdToken tk, // Member for which to set offset + ULONG *pulCodeRVA, // The offset + DWORD *pdwImplFlags); // the implementation flags + + HRESULT STDMETHODCALLTYPE GetPermissionSetProps( + mdPermission pm, // [IN] the permission token. + DWORD *pdwAction, // [OUT] CorDeclSecurity. + void const **ppvPermission, // [OUT] permission blob. + ULONG *pcbPermission); // [OUT] count of bytes of pvPermission. + + HRESULT STDMETHODCALLTYPE GetSigFromToken( // S_OK or error. + mdSignature mdSig, // [IN] Signature token. + PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. + ULONG *pcbSig); // [OUT] return size of signature. + + HRESULT STDMETHODCALLTYPE GetModuleRefProps( // S_OK or error. + mdModuleRef mur, // [IN] moduleref token. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] buffer to fill with the moduleref name. + ULONG cchName, // [IN] size of szName in wide characters. + ULONG *pchName); // [OUT] actual count of characters in the name. + + HRESULT STDMETHODCALLTYPE EnumModuleRefs( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdModuleRef rModuleRefs[], // [OUT] put modulerefs here. + ULONG cmax, // [IN] max memberrefs to put. + ULONG *pcModuleRefs); // [OUT] put # put here. + + HRESULT STDMETHODCALLTYPE GetTypeSpecFromToken( // S_OK or error. + mdTypeSpec typespec, // [IN] TypeSpec token. + PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature + ULONG *pcbSig); // [OUT] return size of signature. + + HRESULT + GetNameFromToken( // Not Recommended! May be removed! + mdToken tk, // [IN] Token to get name from. Must have a name. + MDUTF8CSTR *pszUtf8NamePtr); // [OUT] Return pointer to UTF8 name in heap. + + HRESULT STDMETHODCALLTYPE EnumUnresolvedMethods( // S_OK, S_FALSE, or error. + HCORENUM *phEnum, // [IN|OUT] Pointer to the enum. + mdToken rMethods[], // [OUT] Put MemberDefs here. + ULONG cMax, // [IN] Max MemberDefs to put. + ULONG *pcTokens); // [OUT] Put # put here. + + HRESULT STDMETHODCALLTYPE GetUserString( // S_OK or error. + mdString stk, // [IN] String token. + __out_ecount_part_opt(cchString, *pchString) + LPWSTR szString, // [OUT] Copy of string. + ULONG cchString, // [IN] Max chars of room in szString. + ULONG *pchString); // [OUT] How many chars in actual string. + + HRESULT STDMETHODCALLTYPE GetPinvokeMap( // S_OK or error. + mdToken tk, // [IN] FieldDef or MethodDef. + DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. + __out_ecount_part_opt(cchImportName, *pchImportName) + LPWSTR szImportName, // [OUT] Import name. + ULONG cchImportName, // [IN] Size of the name buffer. + ULONG *pchImportName, // [OUT] Actual number of characters stored. + mdModuleRef *pmrImportDLL); // [OUT] ModuleRef token for the target DLL. + + HRESULT STDMETHODCALLTYPE EnumSignatures( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdSignature rSignatures[], // [OUT] put signatures here. + ULONG cmax, // [IN] max signatures to put. + ULONG *pcSignatures); // [OUT] put # put here. + + HRESULT STDMETHODCALLTYPE EnumTypeSpecs( // S_OK or error. + HCORENUM *phEnum, // [IN|OUT] pointer to the enum. + mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here. + ULONG cmax, // [IN] max TypeSpecs to put. + ULONG *pcTypeSpecs); // [OUT] put # put here. + + HRESULT STDMETHODCALLTYPE EnumUserStrings( // S_OK or error. + HCORENUM *phEnum, // [IN/OUT] pointer to the enum. + mdString rStrings[], // [OUT] put Strings here. + ULONG cmax, // [IN] max Strings to put. + ULONG *pcStrings); // [OUT] put # put here. + + HRESULT STDMETHODCALLTYPE GetParamForMethodIndex( // S_OK or error. + mdMethodDef md, // [IN] Method token. + ULONG ulParamSeq, // [IN] Parameter sequence. + mdParamDef *ppd); // [IN] Put Param token here. + + HRESULT STDMETHODCALLTYPE EnumCustomAttributes( // S_OK or error. + HCORENUM *phEnum, // [IN, OUT] COR enumerator. + mdToken tk, // [IN] Token to scope the enumeration, 0 for all. + mdToken tkType, // [IN] Type of interest, 0 for all. + mdCustomAttribute + rCustomAttributes[], // [OUT] Put custom attribute tokens here. + ULONG cMax, // [IN] Size of rCustomAttributes. + ULONG *pcCustomAttributes); // [OUT, OPTIONAL] Put count of token values + // here. + + HRESULT STDMETHODCALLTYPE GetCustomAttributeProps( // S_OK or error. + mdCustomAttribute cv, // [IN] CustomAttribute token. + mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here. + mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here. + void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here. + ULONG *pcbSize); // [OUT, OPTIONAL] Put size of date here. + + HRESULT STDMETHODCALLTYPE FindTypeRef( + mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef. + LPCWSTR szName, // [IN] TypeRef Name. + mdTypeRef *ptr); // [OUT] matching TypeRef. + + HRESULT STDMETHODCALLTYPE GetMemberProps( + mdToken mb, // The member for which to get props. + mdTypeDef *pClass, // Put member's class here. + __out_ecount_part_opt(cchMember, *pchMember) + LPWSTR szMember, // Put member's name here. + ULONG cchMember, // Size of szMember buffer in wide chars. + ULONG *pchMember, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + ULONG *pulCodeRVA, // [OUT] codeRVA + DWORD *pdwImplFlags, // [OUT] Impl. Flags + DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected + // ELEMENT_TYPE_* + UVCP_CONSTANT *ppValue, // [OUT] constant value + ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for + // non-strings. + + HRESULT STDMETHODCALLTYPE GetFieldProps( + mdFieldDef mb, // The field for which to get props. + mdTypeDef *pClass, // Put field's class here. + __out_ecount_part_opt(cchField, *pchField) + LPWSTR szField, // Put field's name here. + ULONG cchField, // Size of szField buffer in wide chars. + ULONG *pchField, // Put actual size here + DWORD *pdwAttr, // Put flags here. + PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data + ULONG *pcbSigBlob, // [OUT] actual size of signature blob + DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected + // ELEMENT_TYPE_* + UVCP_CONSTANT *ppValue, // [OUT] constant value + ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for + // non-strings. + + HRESULT STDMETHODCALLTYPE GetPropertyProps( // S_OK, S_FALSE, or error. + mdProperty prop, // [IN] property token + mdTypeDef *pClass, // [OUT] typedef containing the property declarion. + LPCWSTR szProperty, // [OUT] Property name + ULONG cchProperty, // [IN] the count of wchar of szProperty + ULONG *pchProperty, // [OUT] actual count of wchar for property name + DWORD *pdwPropFlags, // [OUT] property flags. + PCCOR_SIGNATURE + *ppvSig, // [OUT] property type. pointing to meta data internal blob + ULONG *pbSig, // [OUT] count of bytes in *ppvSig + DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected + // ELEMENT_TYPE_* + UVCP_CONSTANT *ppDefaultValue, // [OUT] constant value + ULONG *pcchDefaultValue, // [OUT] size of constant string in chars, 0 for + // non-strings. + mdMethodDef *pmdSetter, // [OUT] setter method of the property + mdMethodDef *pmdGetter, // [OUT] getter method of the property + mdMethodDef rmdOtherMethod[], // [OUT] other method of the property + ULONG cMax, // [IN] size of rmdOtherMethod + ULONG * + pcOtherMethod); // [OUT] total number of other method of this property + + HRESULT STDMETHODCALLTYPE GetParamProps( // S_OK or error. + mdParamDef tk, // [IN]The Parameter. + mdMethodDef *pmd, // [OUT] Parent Method token. + ULONG *pulSequence, // [OUT] Parameter sequence. + __out_ecount_part_opt(cchName, *pchName) + LPWSTR szName, // [OUT] Put name here. + ULONG cchName, // [OUT] Size of name buffer. + ULONG *pchName, // [OUT] Put actual size of name here. + DWORD *pdwAttr, // [OUT] Put flags here. + DWORD *pdwCPlusTypeFlag, // [OUT] Flag for value type. selected + // ELEMENT_TYPE_*. + UVCP_CONSTANT *ppValue, // [OUT] Constant value. + ULONG *pcchValue); // [OUT] size of constant string in chars, 0 for + // non-strings. + + HRESULT STDMETHODCALLTYPE GetCustomAttributeByName( // S_OK or error. + mdToken tkObj, // [IN] Object with Custom Attribute. + LPCWSTR szName, // [IN] Name of desired Custom Attribute. + const void **ppData, // [OUT] Put pointer to data here. + ULONG *pcbData); // [OUT] Put size of data here. + + BOOL IsValidToken( // True or False. + mdToken tk); // [IN] Given token. + + HRESULT STDMETHODCALLTYPE GetNestedClassProps( // S_OK or error. + mdTypeDef tdNestedClass, // [IN] NestedClass token. + mdTypeDef *ptdEnclosingClass); // [OUT] EnclosingClass token. + + HRESULT STDMETHODCALLTYPE GetNativeCallConvFromSig( // S_OK or error. + void const *pvSig, // [IN] Pointer to signature. + ULONG cbSig, // [IN] Count of signature bytes. + ULONG *pCallConv); // [OUT] Put calling conv here (see CorPinvokemap). + + HRESULT STDMETHODCALLTYPE IsGlobal( // S_OK or error. + mdToken pd, // [IN] Type, Field, or Method token. + int *pbGlobal); // [OUT] Put 1 if global, 0 otherwise. +}; + +#endif diff --git a/src/mono/dbi/cordb-thread.h b/src/mono/dbi/cordb-thread.h index 91629f0d67889e..25ec76fc33c60f 100644 --- a/src/mono/dbi/cordb-thread.h +++ b/src/mono/dbi/cordb-thread.h @@ -24,11 +24,11 @@ class CordbThread : public CordbBaseMono, public: CordbThread(Connection* conn, CordbProcess* ppProcess, long thread_id); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -38,51 +38,35 @@ class CordbThread : public CordbBaseMono, } ~CordbThread(); void SetRegisterSet(CordbRegisterSet* rs); - HRESULT HasUnhandledException(void); - HRESULT - GetBlockingObjects(ICorDebugBlockingObjectEnum** ppBlockingObjectEnum); - HRESULT - GetCurrentCustomDebuggerNotification(ICorDebugValue** ppNotificationObject); - HRESULT - CreateStackWalk(ICorDebugStackWalk** ppStackWalk); - HRESULT - GetActiveInternalFrames(ULONG32 cInternalFrames, + HRESULT STDMETHODCALLTYPE HasUnhandledException(void); + HRESULT STDMETHODCALLTYPE GetBlockingObjects(ICorDebugBlockingObjectEnum** ppBlockingObjectEnum); + HRESULT STDMETHODCALLTYPE GetCurrentCustomDebuggerNotification(ICorDebugValue** ppNotificationObject); + HRESULT STDMETHODCALLTYPE CreateStackWalk(ICorDebugStackWalk** ppStackWalk); + HRESULT STDMETHODCALLTYPE GetActiveInternalFrames(ULONG32 cInternalFrames, ULONG32* pcInternalFrames, ICorDebugInternalFrame2* ppInternalFrames[]); - HRESULT GetActiveFunctions(ULONG32 cFunctions, ULONG32* pcFunctions, COR_ACTIVE_FUNCTION pFunctions[]); - HRESULT - GetConnectionID(CONNID* pdwConnectionId); - HRESULT GetTaskID(TASKID* pTaskId); - HRESULT GetVolatileOSThreadID(DWORD* pdwTid); - HRESULT - InterceptCurrentException(ICorDebugFrame* pFrame); - HRESULT - GetProcess(ICorDebugProcess** ppProcess); - HRESULT GetID(DWORD* pdwThreadId); - HRESULT GetHandle(HTHREAD* phThreadHandle); - HRESULT - GetAppDomain(ICorDebugAppDomain** ppAppDomain); - HRESULT SetDebugState(CorDebugThreadState state); - HRESULT - GetDebugState(CorDebugThreadState* pState); - HRESULT GetUserState(CorDebugUserState* pState); - HRESULT - GetCurrentException(ICorDebugValue** ppExceptionObject); - HRESULT ClearCurrentException(void); - HRESULT - CreateStepper(ICorDebugStepper** ppStepper); - HRESULT - EnumerateChains(ICorDebugChainEnum** ppChains); - HRESULT - GetActiveChain(ICorDebugChain** ppChain); - HRESULT - GetActiveFrame(ICorDebugFrame** ppFrame); - HRESULT - GetRegisterSet(ICorDebugRegisterSet** ppRegisters); - HRESULT CreateEval(ICorDebugEval** ppEval); - HRESULT GetObject(ICorDebugValue** ppObject); - HRESULT - QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + HRESULT STDMETHODCALLTYPE GetActiveFunctions(ULONG32 cFunctions, ULONG32* pcFunctions, COR_ACTIVE_FUNCTION pFunctions[]); + HRESULT STDMETHODCALLTYPE GetConnectionID(CONNID* pdwConnectionId); + HRESULT STDMETHODCALLTYPE GetTaskID(TASKID* pTaskId); + HRESULT STDMETHODCALLTYPE GetVolatileOSThreadID(DWORD* pdwTid); + HRESULT STDMETHODCALLTYPE InterceptCurrentException(ICorDebugFrame* pFrame); + HRESULT STDMETHODCALLTYPE GetProcess(ICorDebugProcess** ppProcess); + HRESULT STDMETHODCALLTYPE GetID(DWORD* pdwThreadId); + HRESULT STDMETHODCALLTYPE GetHandle(HTHREAD* phThreadHandle); + HRESULT STDMETHODCALLTYPE GetAppDomain(ICorDebugAppDomain** ppAppDomain); + HRESULT STDMETHODCALLTYPE SetDebugState(CorDebugThreadState state); + HRESULT STDMETHODCALLTYPE GetDebugState(CorDebugThreadState* pState); + HRESULT STDMETHODCALLTYPE GetUserState(CorDebugUserState* pState); + HRESULT STDMETHODCALLTYPE GetCurrentException(ICorDebugValue** ppExceptionObject); + HRESULT STDMETHODCALLTYPE ClearCurrentException(void); + HRESULT STDMETHODCALLTYPE CreateStepper(ICorDebugStepper** ppStepper); + HRESULT STDMETHODCALLTYPE EnumerateChains(ICorDebugChainEnum** ppChains); + HRESULT STDMETHODCALLTYPE GetActiveChain(ICorDebugChain** ppChain); + HRESULT STDMETHODCALLTYPE GetActiveFrame(ICorDebugFrame** ppFrame); + HRESULT STDMETHODCALLTYPE GetRegisterSet(ICorDebugRegisterSet** ppRegisters); + HRESULT STDMETHODCALLTYPE CreateEval(ICorDebugEval** ppEval); + HRESULT STDMETHODCALLTYPE GetObject(ICorDebugValue** ppObject); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); long GetThreadId() const { diff --git a/src/mono/dbi/cordb-type.h b/src/mono/dbi/cordb-type.h index 1ad0f622956a5c..a2601b237c93e6 100644 --- a/src/mono/dbi/cordb-type.h +++ b/src/mono/dbi/cordb-type.h @@ -18,11 +18,11 @@ class CordbType : public CordbBaseMono, public ICorDebugType, public ICorDebugTy public: CordbType(CorElementType type, Connection* conn, CordbClass* klass = NULL, CordbType* typeParameter = NULL); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -31,17 +31,16 @@ class CordbType : public CordbBaseMono, public ICorDebugType, public ICorDebugTy return "CordbType"; } ~CordbType(); - HRESULT GetType(CorElementType* ty); - HRESULT GetClass(ICorDebugClass** ppClass); - HRESULT - EnumerateTypeParameters(ICorDebugTypeEnum** ppTyParEnum); - HRESULT GetFirstTypeParameter(ICorDebugType** value); - HRESULT GetBase(ICorDebugType** pBase); - HRESULT GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame* pFrame, ICorDebugValue** ppValue); - HRESULT GetRank(ULONG32* pnRank); - HRESULT QueryInterface(REFIID riid, void** ppvObject); + HRESULT STDMETHODCALLTYPE GetType(CorElementType* ty); + HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass** ppClass); + HRESULT STDMETHODCALLTYPE EnumerateTypeParameters(ICorDebugTypeEnum** ppTyParEnum); + HRESULT STDMETHODCALLTYPE GetFirstTypeParameter(ICorDebugType** value); + HRESULT STDMETHODCALLTYPE GetBase(ICorDebugType** pBase); + HRESULT STDMETHODCALLTYPE GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame* pFrame, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetRank(ULONG32* pnRank); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); - HRESULT GetTypeID(COR_TYPEID* id); + HRESULT STDMETHODCALLTYPE GetTypeID(COR_TYPEID* id); }; class CordbTypeEnum : public CordbBaseMono, public ICorDebugTypeEnum @@ -50,11 +49,11 @@ class CordbTypeEnum : public CordbBaseMono, public ICorDebugTypeEnum public: CordbTypeEnum(Connection* conn, CordbType* type); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -63,12 +62,12 @@ class CordbTypeEnum : public CordbBaseMono, public ICorDebugTypeEnum return "CordbTypeEnum"; } ~CordbTypeEnum(); - virtual HRESULT Next(ULONG celt, ICorDebugType* values[], ULONG* pceltFetched); - HRESULT Skip(ULONG celt); - HRESULT Reset(void); - HRESULT Clone(ICorDebugEnum** ppEnum); - HRESULT GetCount(ULONG* pcelt); - HRESULT QueryInterface(REFIID riid, void** ppvObject); + virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, ICorDebugType* values[], ULONG* pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(void); + HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum** ppEnum); + HRESULT STDMETHODCALLTYPE GetCount(ULONG* pcelt); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); }; #endif diff --git a/src/mono/dbi/cordb-value.h b/src/mono/dbi/cordb-value.h index 81feef882ae69e..8d964605d73924 100644 --- a/src/mono/dbi/cordb-value.h +++ b/src/mono/dbi/cordb-value.h @@ -28,11 +28,11 @@ class CordbValue : public CordbBaseMono, public ICorDebugValue2, public ICorDebu public: CordbValue(Connection* conn, CorElementType type, CordbContent value, int size); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -41,17 +41,16 @@ class CordbValue : public CordbBaseMono, public ICorDebugValue2, public ICorDebu return "CordbValue"; } ~CordbValue(); - HRESULT GetType(CorElementType* pType); - HRESULT GetSize(ULONG32* pSize); - HRESULT GetAddress(CORDB_ADDRESS* pAddress); - HRESULT - CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); - HRESULT QueryInterface(REFIID riid, void** ppvObject); - - HRESULT GetExactType(ICorDebugType** ppType); - HRESULT GetSize64(ULONG64* pSize); - HRESULT GetValue(void* pTo); - HRESULT SetValue(void* pFrom); + HRESULT STDMETHODCALLTYPE GetType(CorElementType* pType); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32* pSize); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS* pAddress); + HRESULT STDMETHODCALLTYPE CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); + + HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType** ppType); + HRESULT STDMETHODCALLTYPE GetSize64(ULONG64* pSize); + HRESULT STDMETHODCALLTYPE GetValue(void* pTo); + HRESULT STDMETHODCALLTYPE SetValue(void* pFrom); }; class CordbReferenceValue : public CordbBaseMono, @@ -68,11 +67,11 @@ class CordbReferenceValue : public CordbBaseMono, public: CordbReferenceValue( Connection* conn, CorElementType type, int object_id, CordbClass* klass = NULL, CordbType* cordbType = NULL); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -81,22 +80,21 @@ class CordbReferenceValue : public CordbBaseMono, return "CordbReferenceValue"; } ~CordbReferenceValue(); - HRESULT GetType(CorElementType* pType); - HRESULT GetSize(ULONG32* pSize); - HRESULT GetAddress(CORDB_ADDRESS* pAddress); - HRESULT - CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); - HRESULT QueryInterface(REFIID riid, void** ppvObject); - - HRESULT GetExactType(ICorDebugType** ppType); - HRESULT GetSize64(ULONG64* pSize); - HRESULT GetValue(void* pTo); - HRESULT SetValue(void* pFrom); - HRESULT IsNull(BOOL* pbNull); - HRESULT GetValue(CORDB_ADDRESS* pValue); - HRESULT SetValue(CORDB_ADDRESS value); - HRESULT Dereference(ICorDebugValue** ppValue); - HRESULT DereferenceStrong(ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetType(CorElementType* pType); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32* pSize); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS* pAddress); + HRESULT STDMETHODCALLTYPE CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); + + HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType** ppType); + HRESULT STDMETHODCALLTYPE GetSize64(ULONG64* pSize); + HRESULT STDMETHODCALLTYPE GetValue(void* pTo); + HRESULT STDMETHODCALLTYPE SetValue(void* pFrom); + HRESULT STDMETHODCALLTYPE IsNull(BOOL* pbNull); + HRESULT STDMETHODCALLTYPE GetValue(CORDB_ADDRESS* pValue); + HRESULT STDMETHODCALLTYPE SetValue(CORDB_ADDRESS value); + HRESULT STDMETHODCALLTYPE Dereference(ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE DereferenceStrong(ICorDebugValue** ppValue); }; class CordbObjectValue : public CordbBaseMono, @@ -119,11 +117,11 @@ class CordbObjectValue : public CordbBaseMono, public: CordbObjectValue(Connection* conn, CorElementType type, int object_id, CordbClass* klass); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -132,45 +130,41 @@ class CordbObjectValue : public CordbBaseMono, return "CordbObjectValue"; } ~CordbObjectValue(); - HRESULT GetClass(ICorDebugClass** ppClass); - HRESULT GetFieldValue(ICorDebugClass* pClass, mdFieldDef fieldDef, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass** ppClass); + HRESULT STDMETHODCALLTYPE GetFieldValue(ICorDebugClass* pClass, mdFieldDef fieldDef, ICorDebugValue** ppValue); static HRESULT CreateCordbValue(Connection* conn, MdbgProtBuffer* pReply, ICorDebugValue** ppValue); - static int GetTypeSize(int type); - HRESULT GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction); - HRESULT GetContext(ICorDebugContext** ppContext); - HRESULT IsValueClass(BOOL* pbIsValueClass); - HRESULT GetManagedCopy(IUnknown** ppObject); - HRESULT SetFromManagedCopy(IUnknown* pObject); - HRESULT IsValid(BOOL* pbValid); - HRESULT - CreateRelocBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); - HRESULT GetType(CorElementType* pType); - HRESULT GetSize(ULONG32* pSize); - HRESULT GetAddress(CORDB_ADDRESS* pAddress); - HRESULT - CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); - HRESULT QueryInterface(REFIID riid, void** ppvObject); - - HRESULT GetExactType(ICorDebugType** ppType); - HRESULT GetSize64(ULONG64* pSize); - HRESULT GetValue(void* pTo); - HRESULT SetValue(void* pFrom); - HRESULT - GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction** ppFunction, ICorDebugType** ppType); - HRESULT GetLength(ULONG32* pcchString); - HRESULT GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]); - HRESULT CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle); - HRESULT GetThreadOwningMonitorLock(ICorDebugThread** ppThread, DWORD* pAcquisitionCount); - HRESULT - GetMonitorEventWaitList(ICorDebugThreadEnum** ppThreadEnum); - HRESULT EnumerateExceptionCallStack(ICorDebugExceptionObjectCallStackEnum** ppCallStackEnum); - HRESULT GetCachedInterfaceTypes(BOOL bIInspectableOnly, ICorDebugTypeEnum** ppInterfacesEnum); - HRESULT GetCachedInterfacePointers(BOOL bIInspectableOnly, + static int GetTypeSize(int type); + HRESULT STDMETHODCALLTYPE GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetContext(ICorDebugContext** ppContext); + HRESULT STDMETHODCALLTYPE IsValueClass(BOOL* pbIsValueClass); + HRESULT STDMETHODCALLTYPE GetManagedCopy(IUnknown** ppObject); + HRESULT STDMETHODCALLTYPE SetFromManagedCopy(IUnknown* pObject); + HRESULT STDMETHODCALLTYPE IsValid(BOOL* pbValid); + HRESULT STDMETHODCALLTYPE CreateRelocBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetType(CorElementType* pType); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32* pSize); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS* pAddress); + HRESULT STDMETHODCALLTYPE CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); + + HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType** ppType); + HRESULT STDMETHODCALLTYPE GetSize64(ULONG64* pSize); + HRESULT STDMETHODCALLTYPE GetValue(void* pTo); + HRESULT STDMETHODCALLTYPE SetValue(void* pFrom); + HRESULT STDMETHODCALLTYPE GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction** ppFunction, ICorDebugType** ppType); + HRESULT STDMETHODCALLTYPE GetLength(ULONG32* pcchString); + HRESULT STDMETHODCALLTYPE GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]); + HRESULT STDMETHODCALLTYPE CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle); + HRESULT STDMETHODCALLTYPE GetThreadOwningMonitorLock(ICorDebugThread** ppThread, DWORD* pAcquisitionCount); + HRESULT STDMETHODCALLTYPE GetMonitorEventWaitList(ICorDebugThreadEnum** ppThreadEnum); + HRESULT STDMETHODCALLTYPE EnumerateExceptionCallStack(ICorDebugExceptionObjectCallStackEnum** ppCallStackEnum); + HRESULT STDMETHODCALLTYPE GetCachedInterfaceTypes(BOOL bIInspectableOnly, ICorDebugTypeEnum** ppInterfacesEnum); + HRESULT STDMETHODCALLTYPE GetCachedInterfacePointers(BOOL bIInspectableOnly, ULONG32 celt, ULONG32* pcEltFetched, CORDB_ADDRESS* ptrs); - HRESULT GetTarget(ICorDebugReferenceValue** ppObject); - HRESULT GetFunction(ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetTarget(ICorDebugReferenceValue** ppObject); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction** ppFunction); }; class CordbArrayValue : public CordbBaseMono, @@ -194,11 +188,11 @@ class CordbArrayValue : public CordbBaseMono, public: CordbArrayValue(Connection* conn, CordbType* type, int object_id, CordbClass* klass); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -207,51 +201,47 @@ class CordbArrayValue : public CordbBaseMono, return "CordbArrayValue"; } ~CordbArrayValue(); - HRESULT GetClass(ICorDebugClass** ppClass); - HRESULT GetFieldValue(ICorDebugClass* pClass, mdFieldDef fieldDef, ICorDebugValue** ppValue); - HRESULT GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction); - HRESULT GetContext(ICorDebugContext** ppContext); - HRESULT IsValueClass(BOOL* pbIsValueClass); - HRESULT GetManagedCopy(IUnknown** ppObject); - HRESULT SetFromManagedCopy(IUnknown* pObject); - HRESULT GetType(CorElementType* pType); - HRESULT GetSize(ULONG32* pSize); - HRESULT GetAddress(CORDB_ADDRESS* pAddress); - HRESULT - CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); - HRESULT QueryInterface(REFIID riid, void** ppvObject); - - HRESULT - GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction** ppFunction, ICorDebugType** ppType); - HRESULT GetValue(void* pTo); - HRESULT SetValue(void* pFrom); - HRESULT GetLength(ULONG32* pcchString); - HRESULT GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]); - HRESULT IsValid(BOOL* pbValid); - HRESULT - CreateRelocBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); - HRESULT GetExactType(ICorDebugType** ppType); - HRESULT GetSize64(ULONG64* pSize); - HRESULT CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle); - HRESULT GetThreadOwningMonitorLock(ICorDebugThread** ppThread, DWORD* pAcquisitionCount); - HRESULT - GetMonitorEventWaitList(ICorDebugThreadEnum** ppThreadEnum); - HRESULT EnumerateExceptionCallStack(ICorDebugExceptionObjectCallStackEnum** ppCallStackEnum); - HRESULT GetCachedInterfaceTypes(BOOL bIInspectableOnly, ICorDebugTypeEnum** ppInterfacesEnum); - HRESULT GetCachedInterfacePointers(BOOL bIInspectableOnly, + HRESULT STDMETHODCALLTYPE GetClass(ICorDebugClass** ppClass); + HRESULT STDMETHODCALLTYPE GetFieldValue(ICorDebugClass* pClass, mdFieldDef fieldDef, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction); + HRESULT STDMETHODCALLTYPE GetContext(ICorDebugContext** ppContext); + HRESULT STDMETHODCALLTYPE IsValueClass(BOOL* pbIsValueClass); + HRESULT STDMETHODCALLTYPE GetManagedCopy(IUnknown** ppObject); + HRESULT STDMETHODCALLTYPE SetFromManagedCopy(IUnknown* pObject); + HRESULT STDMETHODCALLTYPE GetType(CorElementType* pType); + HRESULT STDMETHODCALLTYPE GetSize(ULONG32* pSize); + HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS* pAddress); + HRESULT STDMETHODCALLTYPE CreateBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); + + HRESULT STDMETHODCALLTYPE GetVirtualMethodAndType(mdMemberRef memberRef, ICorDebugFunction** ppFunction, ICorDebugType** ppType); + HRESULT STDMETHODCALLTYPE GetValue(void* pTo); + HRESULT STDMETHODCALLTYPE SetValue(void* pFrom); + HRESULT STDMETHODCALLTYPE GetLength(ULONG32* pcchString); + HRESULT STDMETHODCALLTYPE GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]); + HRESULT STDMETHODCALLTYPE IsValid(BOOL* pbValid); + HRESULT STDMETHODCALLTYPE CreateRelocBreakpoint(ICorDebugValueBreakpoint** ppBreakpoint); + HRESULT STDMETHODCALLTYPE GetExactType(ICorDebugType** ppType); + HRESULT STDMETHODCALLTYPE GetSize64(ULONG64* pSize); + HRESULT STDMETHODCALLTYPE CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle); + HRESULT STDMETHODCALLTYPE GetThreadOwningMonitorLock(ICorDebugThread** ppThread, DWORD* pAcquisitionCount); + HRESULT STDMETHODCALLTYPE GetMonitorEventWaitList(ICorDebugThreadEnum** ppThreadEnum); + HRESULT STDMETHODCALLTYPE EnumerateExceptionCallStack(ICorDebugExceptionObjectCallStackEnum** ppCallStackEnum); + HRESULT STDMETHODCALLTYPE GetCachedInterfaceTypes(BOOL bIInspectableOnly, ICorDebugTypeEnum** ppInterfacesEnum); + HRESULT STDMETHODCALLTYPE GetCachedInterfacePointers(BOOL bIInspectableOnly, ULONG32 celt, ULONG32* pcEltFetched, CORDB_ADDRESS* ptrs); - HRESULT GetTarget(ICorDebugReferenceValue** ppObject); - HRESULT GetFunction(ICorDebugFunction** ppFunction); - - HRESULT GetElementType(CorElementType* pType); - HRESULT GetRank(ULONG32* pnRank); - HRESULT GetCount(ULONG32* pnCount); - HRESULT GetDimensions(ULONG32 cdim, ULONG32 dims[]); - HRESULT HasBaseIndicies(BOOL* pbHasBaseIndicies); - HRESULT GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]); - HRESULT GetElement(ULONG32 cdim, ULONG32 indices[], ICorDebugValue** ppValue); - HRESULT GetElementAtPosition(ULONG32 nPosition, ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetTarget(ICorDebugReferenceValue** ppObject); + HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction** ppFunction); + + HRESULT STDMETHODCALLTYPE GetElementType(CorElementType* pType); + HRESULT STDMETHODCALLTYPE GetRank(ULONG32* pnRank); + HRESULT STDMETHODCALLTYPE GetCount(ULONG32* pnCount); + HRESULT STDMETHODCALLTYPE GetDimensions(ULONG32 cdim, ULONG32 dims[]); + HRESULT STDMETHODCALLTYPE HasBaseIndicies(BOOL* pbHasBaseIndicies); + HRESULT STDMETHODCALLTYPE GetBaseIndicies(ULONG32 cdim, ULONG32 indicies[]); + HRESULT STDMETHODCALLTYPE GetElement(ULONG32 cdim, ULONG32 indices[], ICorDebugValue** ppValue); + HRESULT STDMETHODCALLTYPE GetElementAtPosition(ULONG32 nPosition, ICorDebugValue** ppValue); }; #endif diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index bcbbe545079d61..f8a2028f880995 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -162,11 +162,11 @@ class Cordb : public ICorDebug, public ICorDebugRemote, public CordbBaseMono return m_pCallback; } Cordb(); - ULONG AddRef(void) + ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); } - ULONG Release(void) + ULONG STDMETHODCALLTYPE Release(void) { return (BaseRelease()); } @@ -176,15 +176,15 @@ class Cordb : public ICorDebug, public ICorDebugRemote, public CordbBaseMono } ~Cordb(); - HRESULT Initialize(void); + HRESULT STDMETHODCALLTYPE Initialize(void); - HRESULT Terminate(void); + HRESULT STDMETHODCALLTYPE Terminate(void); - HRESULT SetManagedHandler(ICorDebugManagedCallback* pCallback); + HRESULT STDMETHODCALLTYPE SetManagedHandler(ICorDebugManagedCallback* pCallback); - HRESULT SetUnmanagedHandler(ICorDebugUnmanagedCallback* pCallback); + HRESULT STDMETHODCALLTYPE SetUnmanagedHandler(ICorDebugUnmanagedCallback* pCallback); - HRESULT CreateProcess(LPCWSTR lpApplicationName, + HRESULT STDMETHODCALLTYPE CreateProcess(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, @@ -197,14 +197,14 @@ class Cordb : public ICorDebug, public ICorDebugRemote, public CordbBaseMono CorDebugCreateProcessFlags debuggingFlags, ICorDebugProcess** ppProcess); - HRESULT DebugActiveProcess(DWORD id, BOOL win32Attach, ICorDebugProcess** ppProcess); - HRESULT EnumerateProcesses(ICorDebugProcessEnum** ppProcess); + HRESULT STDMETHODCALLTYPE DebugActiveProcess(DWORD id, BOOL win32Attach, ICorDebugProcess** ppProcess); + HRESULT STDMETHODCALLTYPE EnumerateProcesses(ICorDebugProcessEnum** ppProcess); - HRESULT GetProcess(DWORD dwProcessId, ICorDebugProcess** ppProcess); + HRESULT STDMETHODCALLTYPE GetProcess(DWORD dwProcessId, ICorDebugProcess** ppProcess); - HRESULT CanLaunchOrAttach(DWORD dwProcessId, BOOL win32DebuggingEnabled); - HRESULT QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject); - HRESULT CreateProcessEx(ICorDebugRemoteTarget* pRemoteTarget, + HRESULT STDMETHODCALLTYPE CanLaunchOrAttach(DWORD dwProcessId, BOOL win32DebuggingEnabled); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject); + HRESULT STDMETHODCALLTYPE CreateProcessEx(ICorDebugRemoteTarget* pRemoteTarget, LPCWSTR lpApplicationName, _In_ LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, @@ -218,7 +218,7 @@ class Cordb : public ICorDebug, public ICorDebugRemote, public CordbBaseMono CorDebugCreateProcessFlags debuggingFlags, ICorDebugProcess** ppProcess); - HRESULT DebugActiveProcessEx(ICorDebugRemoteTarget* pRemoteTarget, + HRESULT STDMETHODCALLTYPE DebugActiveProcessEx(ICorDebugRemoteTarget* pRemoteTarget, DWORD dwProcessId, BOOL fWin32Attach, ICorDebugProcess** ppProcess); From 8e54659eb764bcabbc1e1378d5370b67706ad1ce Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 10:09:11 -0300 Subject: [PATCH 24/64] Fix x86 compilation --- src/mono/mono/mini/debugger-protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/debugger-protocol.c b/src/mono/mono/mini/debugger-protocol.c index 8afa9f2c39e784..276da364474cf4 100644 --- a/src/mono/mono/mini/debugger-protocol.c +++ b/src/mono/mono/mini/debugger-protocol.c @@ -141,7 +141,7 @@ m_dbgprot_buffer_len (MdbgProtBuffer *buf) void m_dbgprot_buffer_make_room (MdbgProtBuffer *buf, uint32_t size) { - if (buf->end - buf->p < size) { + if (((uint32_t)(buf->end - buf->p)) < size) { int64_t new_size = buf->end - buf->buf + size + 32; uint8_t *p = (uint8_t *)g_realloc (buf->buf, new_size); size = (uint32_t) (buf->p - buf->buf); From cc38142d5caf9a8aca1edcd10dbbf99c25b6b103 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 11:16:10 -0300 Subject: [PATCH 25/64] Fix compilation on windows --- src/mono/dbi/CMakeLists.txt | 5 ++++- src/mono/mono/mini/debugger-protocol.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 597d518f9ac272..8ca7f6eab7c424 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -106,7 +106,10 @@ endif (CLR_CMAKE_HOST_UNIX) include_directories("../../coreclr/pal/prebuilt/inc") include_directories("../../coreclr/nativeresources") -add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/nativeresources nativeresources) +if (CLR_CMAKE_HOST_UNIX) + add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/nativeresources nativeresources) +endif() + add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/md/runtime md/runtime) add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/md/compiler md/compiler) diff --git a/src/mono/mono/mini/debugger-protocol.c b/src/mono/mono/mini/debugger-protocol.c index 276da364474cf4..4495d756cf896a 100644 --- a/src/mono/mono/mini/debugger-protocol.c +++ b/src/mono/mono/mini/debugger-protocol.c @@ -142,7 +142,7 @@ void m_dbgprot_buffer_make_room (MdbgProtBuffer *buf, uint32_t size) { if (((uint32_t)(buf->end - buf->p)) < size) { - int64_t new_size = buf->end - buf->buf + size + 32; + size_t new_size = buf->end - buf->buf + size + 32; uint8_t *p = (uint8_t *)g_realloc (buf->buf, new_size); size = (uint32_t) (buf->p - buf->buf); buf->buf = p; From 9fdaaa2aec5f5f20e87a9d3d57c4d95d0a2a63b1 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 11:58:02 -0300 Subject: [PATCH 26/64] Fix cmake error --- src/coreclr/CMakeLists.txt | 1 - src/coreclr/clrdefinitions.cmake | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 0894588ed1075d..9c9ba76da063ea 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -117,7 +117,6 @@ endif(CLR_CMAKE_HOST_WIN32) # - all clr specific compile definitions should be included in this file # - all clr specific feature variable should also be added in this file #---------------------------------- -include(clrfeatures.cmake) include(clrdefinitions.cmake) if(FEATURE_STANDALONE_GC) diff --git a/src/coreclr/clrdefinitions.cmake b/src/coreclr/clrdefinitions.cmake index 915e359f686182..db667817d20329 100644 --- a/src/coreclr/clrdefinitions.cmake +++ b/src/coreclr/clrdefinitions.cmake @@ -1,3 +1,5 @@ +include(${CMAKE_CURRENT_LIST_DIR}/clrfeatures.cmake) + add_compile_definitions($<$>:DACCESS_COMPILE>) add_compile_definitions($<$>:CROSSGEN_COMPILE>) add_compile_definitions($<$>:CROSS_COMPILE>) From 6e53c1ab3746b2e0aa3519f7d41c5119e2b2ec0b Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 23 Feb 2021 12:46:38 -0300 Subject: [PATCH 27/64] Fix cmake --- src/mono/dbi/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 8ca7f6eab7c424..9a0c2367e072df 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -12,6 +12,7 @@ set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR}) set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") set(CLR_CMAKE_HOST_ARCH ${CMAKE_GENERATOR_PLATFORM}) +set(FEATURE_EVENT_TRACE 0) if(HOST_WIN32) if(HOST_X86) From a9d86efb94be46c48eeb5f28c4072af786087a30 Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 23 Feb 2021 13:22:26 -0300 Subject: [PATCH 28/64] Fix arm64 mac --- src/coreclr/pal/src/synchmgr/synchmanager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coreclr/pal/src/synchmgr/synchmanager.cpp b/src/coreclr/pal/src/synchmgr/synchmanager.cpp index b1fdb82adf76a8..55a343de4d6695 100644 --- a/src/coreclr/pal/src/synchmgr/synchmanager.cpp +++ b/src/coreclr/pal/src/synchmgr/synchmanager.cpp @@ -4623,7 +4623,11 @@ namespace CorUnix ptsAbsTmo->tv_nsec = tv.tv_usec * tccMicroSecondsToNanoSeconds; } #else - #error "Don't know how to get hi-res current time on this platform" +#ifdef DBI_COMPONENT_MONO + return ERROR_INTERNAL_ERROR; +#else + #error "Don't know how to get hi-res current time on this platform" +#endif #endif // HAVE_WORKING_CLOCK_GETTIME, HAVE_WORKING_GETTIMEOFDAY #if HAVE_CLOCK_MONOTONIC && HAVE_PTHREAD_CONDATTR_SETCLOCK } From 785d53c498ec2a5e11e687c32471d41944367cfb Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 14:10:52 -0300 Subject: [PATCH 29/64] Fix windows compilation --- src/mono/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 2a32eaa6f67a3b..32667f185c97ba 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -6,6 +6,18 @@ endif() project(mono) +set(CMAKE_C_FLAGS_CHECKED "") +set(CMAKE_CXX_FLAGS_CHECKED "") +set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") +set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") + +set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "") +set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "") +set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") +set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "") + include(GNUInstallDirs) include(CheckIncludeFile) include(CheckFunctionExists) From f1de772964d7684fb510bdfed589bb1b8080a58c Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 15:48:24 -0300 Subject: [PATCH 30/64] Fix memory leak --- src/mono/dbi/cordb.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 2af8338e2f71cc..2aeb55dc1da910 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -17,7 +17,7 @@ #include #define DEBUG_ADDRESS "127.0.0.1" -#define DEBUG_PORT "4712" +#define DEBUG_PORT "4713" MONO_API HRESULT CoreCLRCreateCordbObjectEx( int iDebuggerVersion, DWORD pid, LPCWSTR lpApplicationGroupId, HMODULE hmodTargetCLR, void** ppCordb) @@ -212,7 +212,7 @@ Connection::~Connection() if (buf) { m_dbgprot_buffer_free(buf); - free(buf); + delete buf; } i++; } @@ -232,6 +232,7 @@ void Connection::Receive() if (iResult == -1) { + m_dbgprot_buffer_free(&recvbuf_header); pCordb->GetCallback()->ExitProcess(static_cast(GetProcess())); break; } @@ -244,16 +245,15 @@ void Connection::Receive() } MdbgProtHeader header; - MdbgProtBuffer* recvbuf = new MdbgProtBuffer(); m_dbgprot_decode_command_header(&recvbuf_header, &header); m_dbgprot_buffer_free(&recvbuf_header); - m_dbgprot_buffer_init(recvbuf, header.len - HEADER_LENGTH); - if (header.len < HEADER_LENGTH) { return; } + MdbgProtBuffer* recvbuf = new MdbgProtBuffer(); + m_dbgprot_buffer_init(recvbuf, header.len - HEADER_LENGTH); if (header.len - HEADER_LENGTH != 0) { iResult = socket->Receive((char*)recvbuf->p, header.len - HEADER_LENGTH); @@ -438,6 +438,7 @@ void Connection::ProcessPacketFromQueue() dbg_lock(); receivedPacketsToProcess->Set(i, NULL); dbg_unlock(); + m_dbgprot_buffer_free(req); delete req; } i++; @@ -553,8 +554,9 @@ void Connection::SendPacket(MdbgProtBuffer& sendbuf) int Connection::SendEvent(int cmd_set, int cmd, MdbgProtBuffer* sendbuf) { MdbgProtBuffer outbuf; - int ret = m_dbgprot_buffer_add_command_header(sendbuf, cmd_set, cmd, &outbuf); + int ret = m_dbgprot_buffer_add_command_header(sendbuf, cmd_set, cmd, &outbuf); SendPacket(outbuf); + m_dbgprot_buffer_free(&outbuf); return ret; } From 5939ca50ad499290e864dee48ca0028d878e0a64 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 17:36:13 -0300 Subject: [PATCH 31/64] Returning E_NOTIMPL where it was possible and it's not implemented as suggested by @cshung --- src/mono/dbi/cordb-appdomain.cpp | 48 ++++++++--------- src/mono/dbi/cordb-assembly.cpp | 28 +++++----- src/mono/dbi/cordb.cpp | 93 +++++++++++++------------------- src/mono/dbi/cordb.h | 17 +++--- 4 files changed, 83 insertions(+), 103 deletions(-) diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp index ea2aaa890937a8..74f8c73914508b 100644 --- a/src/mono/dbi/cordb-appdomain.cpp +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -19,13 +19,12 @@ CordbAppDomain::CordbAppDomain(Connection* conn, CordbProcess* ppProcess) : Cord HRESULT CordbAppDomain::Stop(DWORD dwTimeoutIgnored) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Stop - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::Continue(BOOL fIsOutOfBand) { - LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Continue - NOT IMPLEMENTED\n")); - + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Continue - IMPLEMENTED\n")); pProcess->Continue(fIsOutOfBand); return S_OK; } @@ -33,39 +32,39 @@ HRESULT CordbAppDomain::Continue(BOOL fIsOutOfBand) HRESULT CordbAppDomain::IsRunning(BOOL* pbRunning) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - IsRunning - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::HasQueuedCallbacks(ICorDebugThread* pThread, BOOL* pbQueued) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - HasQueuedCallbacks - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::EnumerateThreads(ICorDebugThreadEnum** ppThreads) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateThreads - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::SetAllThreadsDebugState(CorDebugThreadState state, ICorDebugThread* pExceptThisThread) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - SetAllThreadsDebugState - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::Detach(void) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Detach - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::Terminate(UINT exitCode) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Terminate - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT @@ -74,7 +73,7 @@ CordbAppDomain::CanCommitChanges(ULONG cSnapshots, ICorDebugErrorInfoEnum** pError) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - CanCommitChanges - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT @@ -83,7 +82,7 @@ CordbAppDomain::CommitChanges(ULONG cSnapshots, ICorDebugErrorInfoEnum** pError) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - CommitChanges - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface) @@ -119,7 +118,7 @@ HRESULT CordbAppDomain::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* _ HRESULT CordbAppDomain::GetProcess(ICorDebugProcess** ppProcess) { - LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetProcess - NOT IMPLEMENTED\n")); + LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetProcess - IMPLEMENTED\n")); pProcess->QueryInterface(IID_ICorDebugProcess, (void**)ppProcess); return S_OK; } @@ -128,33 +127,33 @@ HRESULT CordbAppDomain::EnumerateAssemblies(ICorDebugAssemblyEnum** ppAssemblies) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateAssemblies - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::GetModuleFromMetaDataInterface(IUnknown* pIMetaData, ICorDebugModule** ppModule) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetModuleFromMetaDataInterface - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::EnumerateBreakpoints(ICorDebugBreakpointEnum** ppBreakpoints) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateBreakpoints - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::EnumerateSteppers(ICorDebugStepperEnum** ppSteppers) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - EnumerateSteppers - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::IsAttached(BOOL* pbAttached) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - IsAttached - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT @@ -174,13 +173,13 @@ CordbAppDomain::GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) HRESULT CordbAppDomain::GetObject(ICorDebugValue** ppObject) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetObject - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::Attach(void) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - Attach - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::GetID(ULONG32* pId) @@ -197,13 +196,13 @@ HRESULT CordbAppDomain::GetArrayOrPointerType(CorElementType elementType, ICorDebugType** ppType) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetArrayOrPointerType - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::GetFunctionPointerType(ULONG32 nTypeArgs, ICorDebugType* ppTypeArgs[], ICorDebugType** ppType) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetFunctionPointerType - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::GetCachedWinRTTypesForIIDs(ULONG32 cReqTypes, @@ -211,20 +210,20 @@ HRESULT CordbAppDomain::GetCachedWinRTTypesForIIDs(ULONG32 cReqTypes ICorDebugTypeEnum** ppTypesEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetCachedWinRTTypesForIIDs - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::GetCachedWinRTTypes(ICorDebugGuidToTypeEnum** ppGuidToTypeEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetCachedWinRTTypes - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAppDomain::GetObjectForCCW(CORDB_ADDRESS ccwPointer, ICorDebugValue** ppManagedObject) { LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - GetObjectForCCW - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, ICorDebugAppDomain* values[], ULONG* pceltFetched) @@ -281,7 +280,6 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::QueryInterface(REFIID id, void** p *pInterface = static_cast(this); else { - LOG((LF_CORDB, LL_INFO100000, "CordbAppDomain - QueryInterface - NOT IMPLEMENTED\n")); return E_NOINTERFACE; } AddRef(); diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 00b60bb90a0981..be304aa4c9733a 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -57,19 +57,19 @@ HRESULT CordbAssembly::GetAppDomain(ICorDebugAppDomain** ppAppDomain) HRESULT CordbAssembly::EnumerateModules(ICorDebugModuleEnum** ppModules) { LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - EnumerateModules - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAssembly::GetCodeBase(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) { LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - GetCodeBase - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAssembly::GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) { LOG((LF_CORDB, LL_INFO100000, "CorDebugAssembly - GetName - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbAssembly::QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppInterface) @@ -158,7 +158,7 @@ HRESULT CordbModule::IsMappedLayout(BOOL* pIsMapped) HRESULT CordbModule::CreateReaderForInMemorySymbols(REFIID riid, void** ppObj) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - CreateReaderForInMemorySymbols - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken pTokens[]) @@ -170,7 +170,7 @@ HRESULT CordbModule::SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken p HRESULT CordbModule::ApplyChanges(ULONG cbMetadata, BYTE pbMetadata[], ULONG cbIL, BYTE pbIL[]) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - ApplyChanges - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::SetJITCompilerFlags(DWORD dwFlags) @@ -190,12 +190,12 @@ HRESULT CordbModule::GetJITCompilerFlags(DWORD* pdwFlags) HRESULT CordbModule::ResolveAssembly(mdToken tkAssemblyRef, ICorDebugAssembly** ppAssembly) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - ResolveAssembly - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::GetProcess(ICorDebugProcess** ppProcess) { - LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetProcess - NOT IMPLEMENTED\n")); + LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetProcess - IMPLEMENTED\n")); conn->GetProcess()->QueryInterface(IID_ICorDebugProcess, (void**)ppProcess); return S_OK; } @@ -250,13 +250,13 @@ HRESULT CordbModule::GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) HRESULT CordbModule::EnableJITDebugging(BOOL bTrackJITInfo, BOOL bAllowJitOpts) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - EnableJITDebugging - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::EnableClassLoadCallbacks(BOOL bClassLoadCallbacks) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - EnableClassLoadCallbacks - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction** ppFunction) @@ -288,7 +288,7 @@ HRESULT CordbModule::GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFuncti HRESULT CordbModule::GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction** ppFunction) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetFunctionFromRVA - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::GetClassFromToken(mdTypeDef typeDef, ICorDebugClass** ppClass) @@ -302,13 +302,13 @@ HRESULT CordbModule::CreateBreakpoint(ICorDebugModuleBreakpoint** ppBreakpoint) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - CreateBreakpoint - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::GetEditAndContinueSnapshot(ICorDebugEditAndContinueSnapshot** ppEditAndContinueSnapshot) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetEditAndContinueSnapshot - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::GetMetaDataInterface(REFIID riid, IUnknown** ppObj) @@ -338,7 +338,7 @@ HRESULT CordbModule::GetMetaDataInterface(REFIID riid, IUnknown** ppObj) HRESULT CordbModule::GetToken(mdModule* pToken) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetToken - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::IsDynamic(BOOL* pDynamic) @@ -350,7 +350,7 @@ HRESULT CordbModule::IsDynamic(BOOL* pDynamic) HRESULT CordbModule::GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue** ppValue) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetGlobalVariableValue - NOT IMPLEMENTED\n")); - return S_OK; + return E_NOTIMPL; } HRESULT CordbModule::GetSize(ULONG32* pcBytes) diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 2aeb55dc1da910..b6625770bafae5 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -187,18 +187,18 @@ ReceivedReplyPacket::~ReceivedReplyPacket() Connection::Connection(CordbProcess* proc, Cordb* cordb) { - pProcess = proc; - pCordb = cordb; - receiveReplies = new ArrayList(); - receivedPacketsToProcess = new ArrayList(); + m_pProcess = proc; + m_pCordb = cordb; + m_pReceiveReplies = new ArrayList(); + m_pReceivedPacketsToProcess = new ArrayList(); } Connection::~Connection() { DWORD i = 0; - while (i < receiveReplies->GetCount()) + while (i < m_pReceiveReplies->GetCount()) { - ReceivedReplyPacket* rrp = (ReceivedReplyPacket*)receiveReplies->Get(i); + ReceivedReplyPacket* rrp = (ReceivedReplyPacket*)m_pReceiveReplies->Get(i); if (rrp) { delete rrp; @@ -206,9 +206,9 @@ Connection::~Connection() i++; } i = 0; - while (i < receivedPacketsToProcess->GetCount()) + while (i < m_pReceivedPacketsToProcess->GetCount()) { - MdbgProtBuffer* buf = (MdbgProtBuffer*)receivedPacketsToProcess->Get(i); + MdbgProtBuffer* buf = (MdbgProtBuffer*)m_pReceivedPacketsToProcess->Get(i); if (buf) { m_dbgprot_buffer_free(buf); @@ -216,9 +216,9 @@ Connection::~Connection() } i++; } - delete socket; - delete receiveReplies; - delete receivedPacketsToProcess; + delete m_socket; + delete m_pReceiveReplies; + delete m_pReceivedPacketsToProcess; } void Connection::Receive() @@ -228,19 +228,19 @@ void Connection::Receive() MdbgProtBuffer recvbuf_header; m_dbgprot_buffer_init(&recvbuf_header, HEADER_LENGTH); - int iResult = socket->Receive((char*)recvbuf_header.buf, HEADER_LENGTH); + int iResult = m_socket->Receive((char*)recvbuf_header.buf, HEADER_LENGTH); if (iResult == -1) { m_dbgprot_buffer_free(&recvbuf_header); - pCordb->GetCallback()->ExitProcess(static_cast(GetProcess())); + m_pCordb->GetCallback()->ExitProcess(static_cast(GetProcess())); break; } while (iResult == 0) { LOG((LF_CORDB, LL_INFO100000, "transport_recv () sleep returned %d, expected %d.\n", iResult, HEADER_LENGTH)); - iResult = socket->Receive((char*)recvbuf_header.buf, HEADER_LENGTH); + iResult = m_socket->Receive((char*)recvbuf_header.buf, HEADER_LENGTH); Sleep(1000); } @@ -256,11 +256,11 @@ void Connection::Receive() m_dbgprot_buffer_init(recvbuf, header.len - HEADER_LENGTH); if (header.len - HEADER_LENGTH != 0) { - iResult = socket->Receive((char*)recvbuf->p, header.len - HEADER_LENGTH); + iResult = m_socket->Receive((char*)recvbuf->p, header.len - HEADER_LENGTH); int totalRead = iResult; while (totalRead < header.len - HEADER_LENGTH) { - iResult = socket->Receive((char*)recvbuf->p + totalRead, (header.len - HEADER_LENGTH) - totalRead); + iResult = m_socket->Receive((char*)recvbuf->p + totalRead, (header.len - HEADER_LENGTH) - totalRead); totalRead += iResult; } } @@ -269,42 +269,25 @@ void Connection::Receive() if (header.flags == REPLY_PACKET) { ReceivedReplyPacket* rp = new ReceivedReplyPacket(header.error, header.error_2, header.id, recvbuf); - receiveReplies->Append(rp); + m_pReceiveReplies->Append(rp); } else { - receivedPacketsToProcess->Append(recvbuf); + m_pReceivedPacketsToProcess->Append(recvbuf); } dbg_unlock(); } } -MdbgProtBuffer* Connection::GetReply(int cmdId) -{ - ReceivedReplyPacket* rrp = NULL; - while (rrp == NULL || rrp->Id() != cmdId) - { - dbg_lock(); - for (int i = receiveReplies->GetCount() - 1; i >= 0; i--) - { - rrp = (ReceivedReplyPacket*)receiveReplies->Get(i); - if (rrp->Id() == cmdId) - break; - } - dbg_unlock(); - } - return rrp->Buffer(); -} - ReceivedReplyPacket* Connection::GetReplyWithError(int cmdId) { ReceivedReplyPacket* rrp = NULL; while (rrp == NULL || rrp->Id() != cmdId) { dbg_lock(); - for (int i = receiveReplies->GetCount() - 1; i >= 0; i--) + for (int i = m_pReceiveReplies->GetCount() - 1; i >= 0; i--) { - rrp = (ReceivedReplyPacket*)receiveReplies->Get(i); + rrp = (ReceivedReplyPacket*)m_pReceiveReplies->Get(i); if (rrp->Id() == cmdId) break; } @@ -340,18 +323,18 @@ void Connection::ProcessPacketInternal(MdbgProtBuffer* recvbuf) { case MDBGPROT_EVENT_KIND_VM_START: { - pCordb->GetCallback()->CreateProcess(static_cast(GetProcess())); + m_pCordb->GetCallback()->CreateProcess(static_cast(GetProcess())); } break; case MDBGPROT_EVENT_KIND_VM_DEATH: { - pCordb->GetCallback()->ExitProcess(static_cast(GetProcess())); + m_pCordb->GetCallback()->ExitProcess(static_cast(GetProcess())); } break; case MDBGPROT_EVENT_KIND_THREAD_START: { CordbThread* thread = new CordbThread(this, GetProcess(), thread_id); - pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); + m_pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); } break; case MDBGPROT_EVENT_KIND_APPDOMAIN_CREATE: @@ -367,16 +350,16 @@ void Connection::ProcessPacketInternal(MdbgProtBuffer* recvbuf) { pCorDebugAppDomain = new CordbAppDomain(this, GetProcess()); GetProcess()->Stop(false); - pCordb->GetCallback()->CreateAppDomain(static_cast(GetProcess()), + m_pCordb->GetCallback()->CreateAppDomain(static_cast(GetProcess()), pCorDebugAppDomain); } CordbAssembly* pAssembly = new CordbAssembly(this, GetProcess(), pCorDebugAppDomain, assembly_id); CordbModule* pModule = new CordbModule(this, GetProcess(), (CordbAssembly*)pAssembly, assembly_id); GetProcess()->Stop(false); - pCordb->GetCallback()->LoadAssembly(pCorDebugAppDomain, pAssembly); + m_pCordb->GetCallback()->LoadAssembly(pCorDebugAppDomain, pAssembly); - pCordb->GetCallback()->LoadModule(pCorDebugAppDomain, pModule); + m_pCordb->GetCallback()->LoadModule(pCorDebugAppDomain, pModule); } break; case MDBGPROT_EVENT_KIND_BREAKPOINT: @@ -388,11 +371,11 @@ void Connection::ProcessPacketInternal(MdbgProtBuffer* recvbuf) { thread = new CordbThread(this, GetProcess(), thread_id); GetProcess()->Stop(false); - pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); + m_pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); } DWORD i = 0; CordbFunctionBreakpoint* breakpoint = GetProcess()->GetBreakpointByOffsetAndFuncId(offset, method_id); - pCordb->GetCallback()->Breakpoint(pCorDebugAppDomain, thread, + m_pCordb->GetCallback()->Breakpoint(pCorDebugAppDomain, thread, static_cast(breakpoint)); } break; @@ -405,9 +388,9 @@ void Connection::ProcessPacketInternal(MdbgProtBuffer* recvbuf) { thread = new CordbThread(this, GetProcess(), thread_id); GetProcess()->Stop(false); - pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); + m_pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); } - pCordb->GetCallback()->StepComplete(pCorDebugAppDomain, thread, thread->GetStepper(), STEP_NORMAL); + m_pCordb->GetCallback()->StepComplete(pCorDebugAppDomain, thread, thread->GetStepper(), STEP_NORMAL); } break; default: @@ -429,14 +412,14 @@ int Connection::ProcessPacket(bool is_answer) void Connection::ProcessPacketFromQueue() { DWORD i = 0; - while (i < receivedPacketsToProcess->GetCount()) + while (i < m_pReceivedPacketsToProcess->GetCount()) { - MdbgProtBuffer* req = (MdbgProtBuffer*)receivedPacketsToProcess->Get(i); + MdbgProtBuffer* req = (MdbgProtBuffer*)m_pReceivedPacketsToProcess->Get(i); if (req) { ProcessPacketInternal(req); dbg_lock(); - receivedPacketsToProcess->Set(i, NULL); + m_pReceivedPacketsToProcess->Set(i, NULL); dbg_unlock(); m_dbgprot_buffer_free(req); delete req; @@ -504,18 +487,18 @@ void Connection::EnableEvent(MdbgProtEventKind eventKind) void Connection::CloseConnection() { - socket->Close(); + m_socket->Close(); } void Connection::StartConnection() { LOG((LF_CORDB, LL_INFO100000, "Start Connection\n")); - socket = new Socket(); + m_socket = new Socket(); LOG((LF_CORDB, LL_INFO100000, "Listening to %s:%s\n", DEBUG_ADDRESS, DEBUG_PORT)); - int ret = socket->OpenSocketAcceptConnection(DEBUG_ADDRESS, DEBUG_PORT); + int ret = m_socket->OpenSocketAcceptConnection(DEBUG_ADDRESS, DEBUG_PORT); if (ret == -1) exit(1); @@ -533,7 +516,7 @@ void Connection::TransportHandshake() m_dbgprot_buffer_init(&recvbuf, buflen); int iResult; - iResult = socket->Receive((char*)recvbuf.buf, buflen); + iResult = m_socket->Receive((char*)recvbuf.buf, buflen); // Send an initial buffer m_dbgprot_buffer_add_data(&sendbuf, (uint8_t*)"DWP-Handshake", 13); @@ -544,7 +527,7 @@ void Connection::TransportHandshake() void Connection::SendPacket(MdbgProtBuffer& sendbuf) { - int iResult = socket->Send((const char*)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf)); + int iResult = m_socket->Send((const char*)sendbuf.buf, m_dbgprot_buffer_len(&sendbuf)); if (iResult == -1) { return; diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index f8a2028f880995..f0f0f8d4d4ead1 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -95,12 +95,12 @@ class ReceivedReplyPacket class Connection { - Socket* socket; - CordbProcess* pProcess; - Cordb* pCordb; - ArrayList* receiveReplies; // TODO use hashmap - ArrayList* pendingEval; // TODO use hashmap - ArrayList* receivedPacketsToProcess; // TODO use hashmap + Socket* m_socket; + CordbProcess* m_pProcess; + Cordb* m_pCordb; + ArrayList* m_pReceiveReplies; // TODO use hashmap + ArrayList* m_pReceivedPacketsToProcess; + void ProcessPacketInternal(MdbgProtBuffer* recvbuf); void ProcessPacketFromQueue(); void EnableEvent(MdbgProtEventKind eventKind); @@ -110,11 +110,11 @@ class Connection public: CordbProcess* GetProcess() const { - return pProcess; + return m_pProcess; } Cordb* GetCordb() const { - return pCordb; + return m_pCordb; } Connection(CordbProcess* proc, Cordb* cordb); ~Connection(); @@ -126,7 +126,6 @@ class Connection void Receive(); int SendEvent(int cmd_set, int cmd, MdbgProtBuffer* sendbuf); - MdbgProtBuffer* GetReply(int cmdId); ReceivedReplyPacket* GetReplyWithError(int cmdId); CordbAppDomain* GetCurrentAppDomain(); }; From 8a6f3e9132abf615bec71ab1071a5c65b27b729d Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 18:21:21 -0300 Subject: [PATCH 32/64] Fix what @cshung --- src/mono/dbi/cordb-assembly.cpp | 55 ++++++++++++----------- src/mono/dbi/cordb-assembly.h | 1 + src/mono/dbi/cordb-breakpoint.cpp | 10 ++--- src/mono/dbi/cordb-chain.cpp | 6 +-- src/mono/dbi/cordb-code.cpp | 72 ++++++++++++++++++++----------- src/mono/dbi/cordb-code.h | 3 +- src/mono/dbi/cordb-function.cpp | 30 ++++++------- src/mono/dbi/cordb-register.cpp | 6 +-- 8 files changed, 105 insertions(+), 78 deletions(-) diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index be304aa4c9733a..b876cc67f63926 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -107,6 +107,7 @@ CordbModule::CordbModule(Connection* conn, CordbProcess* process, CordbAssembly* dwFlags = 0; conn->GetProcess()->AddModule(this); m_pAssemblyMetadataBlob = NULL; + m_pAssemblyName = NULL; } CordbModule::~CordbModule() @@ -115,6 +116,8 @@ CordbModule::~CordbModule() m_pAssembly->InternalRelease(); if (m_pAssemblyMetadataBlob) free(m_pAssemblyMetadataBlob); + if (m_pAssemblyName) + free(m_pAssemblyName); } HRESULT CordbModule::QueryInterface(REFIID id, void** pInterface) @@ -202,18 +205,19 @@ HRESULT CordbModule::GetProcess(ICorDebugProcess** ppProcess) HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS* pAddress) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + if (!m_pAssemblyMetadataBlob) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); + m_dbgprot_buffer_free(&localbuf); - m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); + } LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); *pAddress = (CORDB_ADDRESS)m_pAssemblyMetadataBlob; @@ -222,28 +226,29 @@ HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS* pAddress) HRESULT CordbModule::GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetName - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); - m_dbgprot_buffer_free(&localbuf); + if (!m_pAssemblyName) { + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetName - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - char* assembly_name = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + m_pAssemblyName = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + } - if (cchName < strlen(assembly_name) + 1) + if (cchName < strlen(m_pAssemblyName) + 1) { - *pcchName = (ULONG32)strlen(assembly_name) + 1; - free(assembly_name); + *pcchName = (ULONG32)strlen(m_pAssemblyName) + 1; return S_OK; } - MultiByteToWideChar(CP_UTF8, 0, assembly_name, -1, szName, cchName); + + MultiByteToWideChar(CP_UTF8, 0, m_pAssemblyName, -1, szName, cchName); *pcchName = cchName; - free(assembly_name); return S_OK; } diff --git a/src/mono/dbi/cordb-assembly.h b/src/mono/dbi/cordb-assembly.h index fac7173d8e0313..b878414b96323b 100644 --- a/src/mono/dbi/cordb-assembly.h +++ b/src/mono/dbi/cordb-assembly.h @@ -25,6 +25,7 @@ class CordbModule : public CordbBaseMono, uint8_t* m_pAssemblyMetadataBlob; int32_t m_assemblyMetadataLen; unsigned long dwFlags; + char * m_pAssemblyName; public: CordbModule(Connection* conn, CordbProcess* process, CordbAssembly* assembly, int id_assembly); diff --git a/src/mono/dbi/cordb-breakpoint.cpp b/src/mono/dbi/cordb-breakpoint.cpp index f5f31dc9d3d41e..a12e9def98c3b5 100644 --- a/src/mono/dbi/cordb-breakpoint.cpp +++ b/src/mono/dbi/cordb-breakpoint.cpp @@ -22,20 +22,20 @@ CordbFunctionBreakpoint::CordbFunctionBreakpoint(Connection* conn, CordbCode* co CordbFunctionBreakpoint::~CordbFunctionBreakpoint() {} -HRESULT __stdcall CordbFunctionBreakpoint::GetFunction(ICorDebugFunction** ppFunction) +HRESULT CordbFunctionBreakpoint::GetFunction(ICorDebugFunction** ppFunction) { GetCode()->GetFunction()->QueryInterface(IID_ICorDebugFunction, (void**)ppFunction); LOG((LF_CORDB, LL_INFO1000000, "CordbFunctionBreakpoint - GetFunction - IMPLEMENTED\n")); return S_OK; } -HRESULT __stdcall CordbFunctionBreakpoint::GetOffset(ULONG32* pnOffset) +HRESULT CordbFunctionBreakpoint::GetOffset(ULONG32* pnOffset) { LOG((LF_CORDB, LL_INFO100000, "CordbFunctionBreakpoint - GetOffset - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunctionBreakpoint::Activate(BOOL bActive) +HRESULT CordbFunctionBreakpoint::Activate(BOOL bActive) { if (bActive) { @@ -59,13 +59,13 @@ HRESULT __stdcall CordbFunctionBreakpoint::Activate(BOOL bActive) return S_OK; } -HRESULT __stdcall CordbFunctionBreakpoint::IsActive(BOOL* pbActive) +HRESULT CordbFunctionBreakpoint::IsActive(BOOL* pbActive) { LOG((LF_CORDB, LL_INFO100000, "CordbFunctionBreakpoint - IsActive - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunctionBreakpoint::QueryInterface(REFIID id, void** pInterface) +HRESULT CordbFunctionBreakpoint::QueryInterface(REFIID id, void** pInterface) { if (id == IID_ICorDebugFunctionBreakpoint) { diff --git a/src/mono/dbi/cordb-chain.cpp b/src/mono/dbi/cordb-chain.cpp index e1702ef9862c07..5d6a67a3488816 100644 --- a/src/mono/dbi/cordb-chain.cpp +++ b/src/mono/dbi/cordb-chain.cpp @@ -12,7 +12,7 @@ using namespace std; -HRESULT __stdcall CordbChainEnum::Next(ULONG celt, ICorDebugChain* chains[], ULONG* pceltFetched) +HRESULT CordbChainEnum::Next(ULONG celt, ICorDebugChain* chains[], ULONG* pceltFetched) { LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Next - NOT IMPLEMENTED\n")); @@ -29,13 +29,13 @@ CordbChainEnum::CordbChainEnum(Connection* conn, CordbThread* thread) : CordbBas this->m_pThread = thread; } -HRESULT __stdcall CordbChainEnum::QueryInterface(REFIID id, void** pInterface) +HRESULT CordbChainEnum::QueryInterface(REFIID id, void** pInterface) { LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbChainEnum::Skip(ULONG celt) +HRESULT CordbChainEnum::Skip(ULONG celt) { LOG((LF_CORDB, LL_INFO100000, "CordbChainEnum - Skip - NOT IMPLEMENTED\n")); return E_NOTIMPL; diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index 98e434a8f3ce04..5935d4680ab9a6 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -16,46 +16,53 @@ using namespace std; CordbCode::CordbCode(Connection* conn, CordbFunction* func) : CordbBaseMono(conn) { this->m_pFunction = func; + m_nSize = -1; } -HRESULT __stdcall CordbCode::IsIL(BOOL* pbIL) +HRESULT CordbCode::IsIL(BOOL* pbIL) { LOG((LF_CORDB, LL_INFO100000, "CordbCode - IsIL - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbCode::GetFunction(ICorDebugFunction** ppFunction) +HRESULT CordbCode::GetFunction(ICorDebugFunction** ppFunction) { LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetFunction - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbCode::GetAddress(CORDB_ADDRESS* pStart) +HRESULT CordbCode::GetAddress(CORDB_ADDRESS* pStart) { LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetAddress - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbCode::GetSize(ULONG32* pcBytes) -{ - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); +ULONG32 CordbCode::GetSize() { + if (m_nSize == -1) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); - m_dbgprot_buffer_free(&localbuf); + m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_nSize = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + } + return m_nSize; +} - int code_size = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - *pcBytes = code_size; +HRESULT CordbCode::GetSize(ULONG32* pcBytes) +{ + *pcBytes = GetSize(); LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetSize - IMPLEMENTED\n")); return S_OK; } -HRESULT __stdcall CordbCode::CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint** ppBreakpoint) +HRESULT CordbCode::CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint** ppBreakpoint) { // add it in a list to not recreate a already created breakpoint CordbFunctionBreakpoint* bp = new CordbFunctionBreakpoint(conn, this, offset); @@ -64,7 +71,7 @@ HRESULT __stdcall CordbCode::CreateBreakpoint(ULONG32 offset, ICorDebugFunctionB return S_OK; } -HRESULT __stdcall CordbCode::GetCode( +HRESULT CordbCode::GetCode( ULONG32 startOffset, ULONG32 endOffset, ULONG32 cBufferAlloc, BYTE buffer[], ULONG32* pcBufferSize) { MdbgProtBuffer localbuf; @@ -77,35 +84,48 @@ HRESULT __stdcall CordbCode::GetCode( ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); CHECK_ERROR_RETURN_FALSE(received_reply_packet); MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - uint8_t* code = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, (int32_t*)pcBufferSize); - - memcpy(buffer, code, *pcBufferSize); - free(code); + + ULONG32 totalSize = GetSize(); + + if (cBufferAlloc < endOffset - startOffset) + endOffset = startOffset + cBufferAlloc; + + if (endOffset > totalSize) + endOffset = totalSize; + + if (startOffset > totalSize) + startOffset = totalSize; + + uint8_t* m_rgbCode = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, (int32_t*)pcBufferSize); + memcpy(buffer, + m_rgbCode+startOffset, + endOffset - startOffset); + free(m_rgbCode); + LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetCode - IMPLEMENTED\n")); return S_OK; } -HRESULT __stdcall CordbCode::GetVersionNumber(ULONG32* nVersion) +HRESULT CordbCode::GetVersionNumber(ULONG32* nVersion) { *nVersion = 1; LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetVersionNumber - NOT IMPLEMENTED\n")); return S_OK; } -HRESULT __stdcall CordbCode::GetILToNativeMapping(ULONG32 cMap, ULONG32* pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) +HRESULT CordbCode::GetILToNativeMapping(ULONG32 cMap, ULONG32* pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) { LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetILToNativeMapping - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbCode::GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32* pcMap, ULONG32 offsets[]) +HRESULT CordbCode::GetEnCRemapSequencePoints(ULONG32 cMap, ULONG32* pcMap, ULONG32 offsets[]) { LOG((LF_CORDB, LL_INFO100000, "CordbCode - GetEnCRemapSequencePoints - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbCode::QueryInterface(REFIID id, void** pInterface) +HRESULT CordbCode::QueryInterface(REFIID id, void** pInterface) { if (id == IID_ICorDebugCode) { diff --git a/src/mono/dbi/cordb-code.h b/src/mono/dbi/cordb-code.h index 8fc9a225eff5f5..eb052fceff7ba3 100644 --- a/src/mono/dbi/cordb-code.h +++ b/src/mono/dbi/cordb-code.h @@ -12,7 +12,7 @@ class CordbCode : public CordbBaseMono, public ICorDebugCode { CordbFunction* m_pFunction; - + ULONG32 m_nSize; public: CordbCode(Connection* conn, CordbFunction* func); ULONG STDMETHODCALLTYPE AddRef(void) @@ -27,6 +27,7 @@ class CordbCode : public CordbBaseMono, public ICorDebugCode { return "CordbCode"; } + ULONG32 GetSize(); HRESULT STDMETHODCALLTYPE IsIL(BOOL* pbIL); HRESULT STDMETHODCALLTYPE GetFunction(ICorDebugFunction** ppFunction); HRESULT STDMETHODCALLTYPE GetAddress(CORDB_ADDRESS* pStart); diff --git a/src/mono/dbi/cordb-function.cpp b/src/mono/dbi/cordb-function.cpp index 3914640e6019fc..5ad727e0f22be3 100644 --- a/src/mono/dbi/cordb-function.cpp +++ b/src/mono/dbi/cordb-function.cpp @@ -31,7 +31,7 @@ CordbFunction::~CordbFunction() m_pModule->InternalRelease(); } -HRESULT __stdcall CordbFunction::QueryInterface(REFIID id, void** pInterface) +HRESULT CordbFunction::QueryInterface(REFIID id, void** pInterface) { if (id == IID_ICorDebugFunction) { @@ -62,7 +62,7 @@ HRESULT __stdcall CordbFunction::QueryInterface(REFIID id, void** pInterface) return S_OK; } -HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule** ppModule) +HRESULT CordbFunction::GetModule(ICorDebugModule** ppModule) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetModule - IMPLEMENTED\n")); MdbgProtBuffer localbuf; @@ -91,13 +91,13 @@ HRESULT __stdcall CordbFunction::GetModule(ICorDebugModule** ppModule) return S_OK; } -HRESULT __stdcall CordbFunction::GetClass(ICorDebugClass** ppClass) +HRESULT CordbFunction::GetClass(ICorDebugClass** ppClass) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetClass - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetToken(mdMethodDef* pMethodDef) +HRESULT CordbFunction::GetToken(mdMethodDef* pMethodDef) { if (this->GetMetadataToken() == 0) { @@ -118,7 +118,7 @@ HRESULT __stdcall CordbFunction::GetToken(mdMethodDef* pMethodDef) return S_OK; } -HRESULT __stdcall CordbFunction::GetILCode(ICorDebugCode** ppCode) +HRESULT CordbFunction::GetILCode(ICorDebugCode** ppCode) { if (m_pCode == NULL) { @@ -130,7 +130,7 @@ HRESULT __stdcall CordbFunction::GetILCode(ICorDebugCode** ppCode) return S_OK; } -HRESULT __stdcall CordbFunction::GetNativeCode(ICorDebugCode** ppCode) +HRESULT CordbFunction::GetNativeCode(ICorDebugCode** ppCode) { if (m_pCode == NULL) { @@ -142,57 +142,57 @@ HRESULT __stdcall CordbFunction::GetNativeCode(ICorDebugCode** ppCode) return S_OK; } -HRESULT __stdcall CordbFunction::CreateBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint) +HRESULT CordbFunction::CreateBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - CreateBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetLocalVarSigToken(mdSignature* pmdSig) +HRESULT CordbFunction::GetLocalVarSigToken(mdSignature* pmdSig) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetLocalVarSigToken - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetCurrentVersionNumber(ULONG32* pnCurrentVersion) +HRESULT CordbFunction::GetCurrentVersionNumber(ULONG32* pnCurrentVersion) { *pnCurrentVersion = 1; LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetCurrentVersionNumber - IMPLEMENTED\n")); return S_OK; } -HRESULT __stdcall CordbFunction::SetJMCStatus(BOOL bIsJustMyCode) +HRESULT CordbFunction::SetJMCStatus(BOOL bIsJustMyCode) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - SetJMCStatus - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetJMCStatus(BOOL* pbIsJustMyCode) +HRESULT CordbFunction::GetJMCStatus(BOOL* pbIsJustMyCode) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetJMCStatus - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::EnumerateNativeCode(ICorDebugCodeEnum** ppCodeEnum) +HRESULT CordbFunction::EnumerateNativeCode(ICorDebugCodeEnum** ppCodeEnum) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - EnumerateNativeCode - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::GetVersionNumber(ULONG32* pnVersion) +HRESULT CordbFunction::GetVersionNumber(ULONG32* pnVersion) { *pnVersion = 1; LOG((LF_CORDB, LL_INFO1000000, "CordbFunction - GetVersionNumber - IMPLEMENTED\n")); return S_OK; } -HRESULT __stdcall CordbFunction::GetActiveReJitRequestILCode(ICorDebugILCode** ppReJitedILCode) +HRESULT CordbFunction::GetActiveReJitRequestILCode(ICorDebugILCode** ppReJitedILCode) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetActiveReJitRequestILCode - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbFunction::CreateNativeBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint) +HRESULT CordbFunction::CreateNativeBreakpoint(ICorDebugFunctionBreakpoint** ppBreakpoint) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - CreateNativeBreakpoint - NOT IMPLEMENTED\n")); return E_NOTIMPL; diff --git a/src/mono/dbi/cordb-register.cpp b/src/mono/dbi/cordb-register.cpp index 32f6014b3efca6..78b5d43af2c798 100644 --- a/src/mono/dbi/cordb-register.cpp +++ b/src/mono/dbi/cordb-register.cpp @@ -10,7 +10,7 @@ using namespace std; -HRESULT __stdcall CordbRegisterSet::GetRegistersAvailable(ULONG64* pAvailable) +HRESULT CordbRegisterSet::GetRegistersAvailable(ULONG64* pAvailable) { LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - GetRegistersAvailable - NOT IMPLEMENTED\n")); return E_NOTIMPL; @@ -22,13 +22,13 @@ CordbRegisterSet::CordbRegisterSet(Connection* conn, uint8_t* ctx, uint32_t ctx_ this->m_ctxLen = ctx_len; } -HRESULT __stdcall CordbRegisterSet::QueryInterface(REFIID id, void** pInterface) +HRESULT CordbRegisterSet::QueryInterface(REFIID id, void** pInterface) { LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - QueryInterface - NOT IMPLEMENTED\n")); return E_NOTIMPL; } -HRESULT __stdcall CordbRegisterSet::GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]) +HRESULT CordbRegisterSet::GetRegisters(ULONG64 mask, ULONG32 regCount, CORDB_REGISTER regBuffer[]) { LOG((LF_CORDB, LL_INFO100000, "CordbRegisterSet - GetRegisters - NOT IMPLEMENTED\n")); return E_NOTIMPL; From 768b5e9cfd65234bceac2f31864b20b7d8e6c956 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 18:44:04 -0300 Subject: [PATCH 33/64] Use only one ref count --- src/mono/dbi/cordb.cpp | 12 +++--------- src/mono/dbi/cordb.h | 1 - 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index b6625770bafae5..e0b2c911f9c82c 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -559,24 +559,18 @@ CordbBaseMono::CordbBaseMono(Connection* conn) { this->conn = conn; m_cRef = 0; - m_cRefInternal = 0; } CordbBaseMono::~CordbBaseMono() {} ULONG CordbBaseMono::InternalAddRef() { - return InterlockedIncrement((volatile LONG*)&m_cRefInternal); + return BaseAddRef(); } ULONG CordbBaseMono::InternalRelease() { - ULONG cRef = InterlockedDecrement((volatile LONG*)&m_cRefInternal); - if (cRef == 0 && m_cRef == 0) - { - delete this; - } - return cRef; + return BaseRelease(); } ULONG CordbBaseMono::BaseAddRef() @@ -587,7 +581,7 @@ ULONG CordbBaseMono::BaseAddRef() ULONG CordbBaseMono::BaseRelease() { ULONG cRef = InterlockedDecrement((volatile LONG*)&m_cRef); - if (cRef == 0 && m_cRefInternal == 0) + if (cRef == 0) { delete this; } diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index f0f0f8d4d4ead1..13c44f934cbde2 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -135,7 +135,6 @@ class CordbBaseMono protected: Connection* conn; ULONG m_cRef; // Ref count. - ULONG m_cRefInternal; // Ref count. public: CordbBaseMono(Connection* conn); virtual ~CordbBaseMono(); From cdcbe2dc7ba93c28c8701ecba7a511f1b0bf5b1d Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 19:30:38 -0300 Subject: [PATCH 34/64] Adding ex_try everywhere that we could have an allocation failure. --- src/mono/dbi/cordb-assembly.cpp | 132 ++++---- src/mono/dbi/cordb-code.cpp | 65 ++-- src/mono/dbi/cordb-eval.cpp | 43 +-- src/mono/dbi/cordb-frame.cpp | 127 ++++---- src/mono/dbi/cordb-function.cpp | 89 ++--- src/mono/dbi/cordb-stepper.cpp | 96 +++--- src/mono/dbi/cordb-thread.cpp | 60 ++-- src/mono/dbi/cordb-value.cpp | 561 +++++++++++++++++--------------- src/mono/dbi/cordb.h | 8 +- 9 files changed, 644 insertions(+), 537 deletions(-) diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index b876cc67f63926..395342cc2b89b5 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -23,6 +23,7 @@ #include "mdlog.h" #include "mdperf.h" #include "regmeta.h" +#include "ex.h" using namespace std; @@ -205,51 +206,62 @@ HRESULT CordbModule::GetProcess(ICorDebugProcess** ppProcess) HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS* pAddress) { - if (!m_pAssemblyMetadataBlob) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); + HRESULT hr = S_OK; + EX_TRY + { + if (!m_pAssemblyMetadataBlob) { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); + } + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); + + *pAddress = (CORDB_ADDRESS)m_pAssemblyMetadataBlob; } - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); - - *pAddress = (CORDB_ADDRESS)m_pAssemblyMetadataBlob; - return S_OK; + EX_CATCH_HRESULT(hr); + return hr; } HRESULT CordbModule::GetName(ULONG32 cchName, ULONG32* pcchName, WCHAR szName[]) { - if (!m_pAssemblyName) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetName - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - m_pAssemblyName = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - } - - if (cchName < strlen(m_pAssemblyName) + 1) + HRESULT hr = S_OK; + EX_TRY { - *pcchName = (ULONG32)strlen(m_pAssemblyName) + 1; - return S_OK; + if (!m_pAssemblyName) { + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetName - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_LOCATION, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_pAssemblyName = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + } + + if (cchName < strlen(m_pAssemblyName) + 1) + { + *pcchName = (ULONG32)strlen(m_pAssemblyName) + 1; + } + else + { + MultiByteToWideChar(CP_UTF8, 0, m_pAssemblyName, -1, szName, cchName); + *pcchName = cchName; + } } - - MultiByteToWideChar(CP_UTF8, 0, m_pAssemblyName, -1, szName, cchName); - *pcchName = cchName; - return S_OK; + EX_CATCH_HRESULT(hr); + return hr; } HRESULT CordbModule::EnableJITDebugging(BOOL bTrackJITInfo, BOOL bAllowJitOpts) @@ -266,28 +278,32 @@ HRESULT CordbModule::EnableClassLoadCallbacks(BOOL bClassLoadCallbacks) HRESULT CordbModule::GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction** ppFunction) { - // check in a cache before talk to mono runtime to get info - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetFunctionFromToken - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - m_dbgprot_buffer_add_int(&localbuf, methodDef); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - int id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - CordbFunction* func = NULL; - func = m_pProcess->FindFunction(id); - if (func == NULL) + HRESULT hr = S_OK; + EX_TRY { - func = new CordbFunction(conn, methodDef, id, this); + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetFunctionFromToken - IMPLEMENTED\n")); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + m_dbgprot_buffer_add_int(&localbuf, methodDef); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + CordbFunction* func = NULL; + func = m_pProcess->FindFunction(id); + if (func == NULL) + { + func = new CordbFunction(conn, methodDef, id, this); + } + func->QueryInterface(IID_ICorDebugFunction, (void**)ppFunction); } - func->QueryInterface(IID_ICorDebugFunction, (void**)ppFunction); - return S_OK; + EX_CATCH_HRESULT(hr); + return hr; } HRESULT CordbModule::GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction** ppFunction) diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index 5935d4680ab9a6..1bc59777b6e625 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -47,7 +47,8 @@ ULONG32 CordbCode::GetSize() { m_dbgprot_buffer_free(&localbuf); ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); + if (received_reply_packet->Error() > 0 || received_reply_packet->Error2() > 0) + return 0; MdbgProtBuffer* pReply = received_reply_packet->Buffer(); m_nSize = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); @@ -74,36 +75,40 @@ HRESULT CordbCode::CreateBreakpoint(ULONG32 offset, ICorDebugFunctionBreakpoint* HRESULT CordbCode::GetCode( ULONG32 startOffset, ULONG32 endOffset, ULONG32 cBufferAlloc, BYTE buffer[], ULONG32* pcBufferSize) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - - m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - ULONG32 totalSize = GetSize(); - - if (cBufferAlloc < endOffset - startOffset) - endOffset = startOffset + cBufferAlloc; - - if (endOffset > totalSize) - endOffset = totalSize; - - if (startOffset > totalSize) - startOffset = totalSize; - - uint8_t* m_rgbCode = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, (int32_t*)pcBufferSize); - memcpy(buffer, - m_rgbCode+startOffset, - endOffset - startOffset); - free(m_rgbCode); - LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetCode - IMPLEMENTED\n")); - return S_OK; + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + + m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + ULONG32 totalSize = GetSize(); + + if (cBufferAlloc < endOffset - startOffset) + endOffset = startOffset + cBufferAlloc; + + if (endOffset > totalSize) + endOffset = totalSize; + + if (startOffset > totalSize) + startOffset = totalSize; + + uint8_t* m_rgbCode = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, (int32_t*)pcBufferSize); + memcpy(buffer, + m_rgbCode+startOffset, + endOffset - startOffset); + free(m_rgbCode); + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT CordbCode::GetVersionNumber(ULONG32* nVersion) diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index 7915dd73b0c28e..4d0705aaabdb4e 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -135,29 +135,34 @@ HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedArray(ICorDebugType* pEleme HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, UINT uiLength) { - conn->GetProcess()->Stop(false); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); - m_dbgprot_buffer_free(&localbuf); + HRESULT hr = S_OK; + EX_TRY + { + conn->GetProcess()->Stop(false); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_APPDOMAIN, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - int domainId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int domainId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - LPSTR szString; - UTF8STR(string, szString); + LPSTR szString; + UTF8STR(string, szString); - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, domainId); - m_dbgprot_buffer_add_string(&localbuf, szString); - this->m_commandId = conn->SendEvent(MDBGPROT_CMD_SET_APPDOMAIN, MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); - m_dbgprot_buffer_free(&localbuf); - conn->GetProcess()->AddPendingEval(this); - return S_OK; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, domainId); + m_dbgprot_buffer_add_string(&localbuf, szString); + this->m_commandId = conn->SendEvent(MDBGPROT_CMD_SET_APPDOMAIN, MDBGPROT_CMD_APPDOMAIN_CREATE_STRING, &localbuf); + m_dbgprot_buffer_free(&localbuf); + conn->GetProcess()->AddPendingEval(this); + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbEval::RudeAbort(void) diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index d08ae9e6bbeef3..3785d86d27e3ab 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -63,42 +63,46 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::Clone(ICorDebugEnum** ppEnum) HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG* pcelt) { - Reset(); - LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - GetCount - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_int(&localbuf, 0); - m_dbgprot_buffer_add_int(&localbuf, -1); + HRESULT hr = S_OK; + EX_TRY + { + Reset(); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_int(&localbuf, 0); + m_dbgprot_buffer_add_int(&localbuf, -1); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); - m_dbgprot_buffer_free(&localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - m_nFrames = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_ppFrames = (CordbNativeFrame**)malloc(sizeof(CordbNativeFrame*) * m_nFrames); + m_nFrames = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_ppFrames = (CordbNativeFrame**)malloc(sizeof(CordbNativeFrame*) * m_nFrames); - for (int i = 0; i < m_nFrames; i++) - { - int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - - CordbNativeFrame* frame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, m_pThread); - frame->InternalAddRef(); - m_ppFrames[i] = frame; - } + for (int i = 0; i < m_nFrames; i++) + { + int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + + CordbNativeFrame* frame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, m_pThread); + frame->InternalAddRef(); + m_ppFrames[i] = frame; + } - if (!m_pThread->GetStepper()) - m_pThread->SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); + if (!m_pThread->GetStepper()) + m_pThread->SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); - *pcelt = m_nFrames; - return S_OK; + *pcelt = m_nFrames; + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbFrameEnum::QueryInterface(REFIID riid, void** ppvObject) @@ -268,21 +272,26 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateLocalVariables(ICorDebugValu HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetLocalVariable(DWORD dwIndex, ICorDebugValue** ppValue) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); - m_dbgprot_buffer_add_int(&localbuf, 1); - m_dbgprot_buffer_add_int(&localbuf, dwIndex); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, MDBGPROT_CMD_STACK_FRAME_GET_VALUES, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - return CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); + m_dbgprot_buffer_add_int(&localbuf, 1); + m_dbgprot_buffer_add_int(&localbuf, dwIndex); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, MDBGPROT_CMD_STACK_FRAME_GET_VALUES, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + hr = CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateArguments(ICorDebugValueEnum** ppValueEnum) @@ -293,21 +302,27 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::EnumerateArguments(ICorDebugValueEnum HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetArgument(DWORD dwIndex, ICorDebugValue** ppValue) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); + LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetArgument - IMPLEMENTED\n")); + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerFrameId); - m_dbgprot_buffer_add_int(&localbuf, dwIndex); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); - m_dbgprot_buffer_free(&localbuf); + m_dbgprot_buffer_add_int(&localbuf, dwIndex); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STACK_FRAME, MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENT, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - LOG((LF_CORDB, LL_INFO1000000, "CordbFrame - GetArgument - IMPLEMENTED\n")); - return CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); + hr = CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackDepth(ULONG32* pDepth) diff --git a/src/mono/dbi/cordb-function.cpp b/src/mono/dbi/cordb-function.cpp index 5ad727e0f22be3..4757db41fa9add 100644 --- a/src/mono/dbi/cordb-function.cpp +++ b/src/mono/dbi/cordb-function.cpp @@ -65,30 +65,36 @@ HRESULT CordbFunction::QueryInterface(REFIID id, void** pInterface) HRESULT CordbFunction::GetModule(ICorDebugModule** ppModule) { LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetModule - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - if (!m_pModule) - { - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - m_pModule = conn->GetProcess()->GetModule(module_id); - if (m_pModule) - m_pModule->InternalAddRef(); + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + if (!m_pModule) + { + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_ASSEMBLY, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + m_pModule = conn->GetProcess()->GetModule(module_id); + if (m_pModule) + m_pModule->InternalAddRef(); + } + + if (!m_pModule) + hr = S_FALSE; + else { + m_pModule->AddRef(); + *ppModule = static_cast(m_pModule); + } } - - if (!m_pModule) - return S_FALSE; - - m_pModule->AddRef(); - *ppModule = static_cast(m_pModule); - return S_OK; + EX_CATCH_HRESULT(hr); + return hr; } HRESULT CordbFunction::GetClass(ICorDebugClass** ppClass) @@ -99,23 +105,28 @@ HRESULT CordbFunction::GetClass(ICorDebugClass** ppClass) HRESULT CordbFunction::GetToken(mdMethodDef* pMethodDef) { - if (this->GetMetadataToken() == 0) - { - LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetToken - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_TOKEN, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - this->m_metadataToken = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + LOG((LF_CORDB, LL_INFO100000, "CordbFunction - GetToken - IMPLEMENTED\n")); + HRESULT hr = S_OK; + EX_TRY + { + if (this->GetMetadataToken() == 0) + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_TOKEN, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + this->m_metadataToken = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + } + *pMethodDef = this->GetMetadataToken(); } - *pMethodDef = this->GetMetadataToken(); - return S_OK; + EX_CATCH_HRESULT(hr); + return hr; } HRESULT CordbFunction::GetILCode(ICorDebugCode** ppCode) diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index 96c188544f40e6..5d76e1f451eb34 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -58,56 +58,64 @@ HRESULT STDMETHODCALLTYPE CordbStepper::Step(BOOL bStepIn) HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, COR_DEBUG_STEP_RANGE ranges[], ULONG32 cRangeCount) { - MdbgProtBuffer sendbuf; - int buflen = 128; - m_dbgprot_buffer_init(&sendbuf, buflen); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); - m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); - - m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); - m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO : MDBGPROT_STEP_DEPTH_OVER); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - m_commandId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepRange - IMPLEMENTED\n")); - return S_OK; + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); + + m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); + m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO : MDBGPROT_STEP_DEPTH_OVER); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_commandId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbStepper::StepOut(void) { - MdbgProtBuffer sendbuf; - int buflen = 128; - m_dbgprot_buffer_init(&sendbuf, buflen); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); - m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers - m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); - - m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_DEPTH_OUT); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); - m_dbgprot_buffer_free(&sendbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - LOG((LF_CORDB, LL_INFO1000000, "CordbStepper - StepOut - IMPLEMENTED\n")); - return S_OK; + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer sendbuf; + int buflen = 128; + m_dbgprot_buffer_init(&sendbuf, buflen); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_SUSPEND_POLICY_ALL); + m_dbgprot_buffer_add_byte(&sendbuf, 1); // modifiers + m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_STEP); + + m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_DEPTH_OUT); + m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + m_dbgprot_buffer_free(&sendbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbStepper::SetRangeIL(BOOL bIL) diff --git a/src/mono/dbi/cordb-thread.cpp b/src/mono/dbi/cordb-thread.cpp index 2539520582cf5a..97d48dad7c8c86 100644 --- a/src/mono/dbi/cordb-thread.cpp +++ b/src/mono/dbi/cordb-thread.cpp @@ -212,35 +212,39 @@ HRESULT STDMETHODCALLTYPE CordbThread::GetActiveChain(ICorDebugChain** ppChain) HRESULT STDMETHODCALLTYPE CordbThread::GetActiveFrame(ICorDebugFrame** ppFrame) { LOG((LF_CORDB, LL_INFO1000000, "CordbThread - GetActiveFrame - IMPLEMENTED\n")); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, GetThreadId()); - m_dbgprot_buffer_add_int(&localbuf, 0); - m_dbgprot_buffer_add_int(&localbuf, -1); - - int cmdId = this->conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - int nframes = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - if (nframes > 0) - { - int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - if (m_pCurrentFrame) - m_pCurrentFrame->InternalRelease(); - m_pCurrentFrame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, this); - m_pCurrentFrame->InternalAddRef(); - m_pCurrentFrame->QueryInterface(IID_ICorDebugFrame, (void**)ppFrame); + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetThreadId()); + m_dbgprot_buffer_add_int(&localbuf, 0); + m_dbgprot_buffer_add_int(&localbuf, -1); + + int cmdId = this->conn->SendEvent(MDBGPROT_CMD_SET_THREAD, MDBGPROT_CMD_THREAD_GET_FRAME_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int nframes = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + if (nframes > 0) + { + int frameid = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int methodId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int il_offset = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int flags = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + if (m_pCurrentFrame) + m_pCurrentFrame->InternalRelease(); + m_pCurrentFrame = new CordbNativeFrame(conn, frameid, methodId, il_offset, flags, this); + m_pCurrentFrame->InternalAddRef(); + m_pCurrentFrame->QueryInterface(IID_ICorDebugFrame, (void**)ppFrame); + } + SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); } - SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); - - return S_OK; + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbThread::GetRegisterSet(ICorDebugRegisterSet** ppRegisters) diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index 2d35986638b07e..ce05783204c1a8 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -175,83 +175,38 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::QueryInterface(REFIID id, void** HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppType) { LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetExactType - IMPLEMENTED\n")); - if (m_pCordbType) - { - m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); - return S_OK; - } - if (m_pClass != NULL) - { - m_pCordbType = new CordbType(m_type, conn, m_pClass); - m_pCordbType->InternalAddRef(); - m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); - return S_OK; - } - if (m_type == ELEMENT_TYPE_CLASS && m_debuggerId != -1) - { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_TYPE, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - - int type_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, type_id); - - cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); - m_dbgprot_buffer_free(&localbuf); - - received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - pReply = received_reply_packet->Buffer(); - - char* namespace_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char* class_name_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_pClass = new CordbClass(conn, token, assembly_id); - m_pClass->InternalAddRef(); - m_pCordbType = new CordbType(m_type, conn, m_pClass); - m_pCordbType->InternalAddRef(); - m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); - free(namespace_str); - free(class_name_str); - free(class_fullname_str); - return S_OK; - } - if (m_type == ELEMENT_TYPE_SZARRAY && m_debuggerId != -1) - { - m_pClass = NULL; - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + HRESULT hr = S_OK; + EX_TRY + { + if (m_pCordbType) + { + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + goto __Exit; + } + if (m_pClass != NULL) + { + m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + goto __Exit; + } + if (m_type == ELEMENT_TYPE_CLASS && m_debuggerId != -1) + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); - m_dbgprot_buffer_free(&localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_TYPE, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - int type_id = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - if (type_id == ELEMENT_TYPE_CLASS) - { - int klass_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int type_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, klass_id); + m_dbgprot_buffer_add_id(&localbuf, type_id); cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); m_dbgprot_buffer_free(&localbuf); @@ -265,25 +220,76 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppTy char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_pClass = new CordbClass(conn, token, module_id); + type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_pClass = new CordbClass(conn, token, assembly_id); m_pClass->InternalAddRef(); + m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); free(namespace_str); free(class_name_str); free(class_fullname_str); + goto __Exit; } + if (m_type == ELEMENT_TYPE_SZARRAY && m_debuggerId != -1) + { + m_pClass = NULL; + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - m_pCordbType = new CordbType(m_type, conn, NULL, new CordbType((CorElementType)type_id, conn, m_pClass)); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_TYPE, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int type_id = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + if (type_id == ELEMENT_TYPE_CLASS) + { + int klass_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, klass_id); + + cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + pReply = received_reply_packet->Buffer(); + + char* namespace_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_name_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_pClass = new CordbClass(conn, token, module_id); + m_pClass->InternalAddRef(); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); + } + + m_pCordbType = new CordbType(m_type, conn, NULL, new CordbType((CorElementType)type_id, conn, m_pClass)); + m_pCordbType->InternalAddRef(); + m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); + goto __Exit; + } + m_pCordbType = new CordbType(m_type, conn); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); - return S_OK; } - m_pCordbType = new CordbType(m_type, conn); - m_pCordbType->InternalAddRef(); - m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); - return S_OK; + EX_CATCH_HRESULT(hr); +__Exit: + return hr; } HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize64(ULONG64* pSize) @@ -461,64 +467,77 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethodAndType(mdMemberRef HRESULT STDMETHODCALLTYPE CordbObjectValue::GetLength(ULONG32* pcchString) { - if (m_debuggerId == -1) - return S_OK; - if (m_type == ELEMENT_TYPE_STRING) - { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + HRESULT hr = S_OK; + EX_TRY + { + if (m_debuggerId == -1) + hr = S_FALSE; + else if (m_type == ELEMENT_TYPE_STRING) + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); - m_dbgprot_buffer_free(&localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_LENGTH, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - *pcchString = (ULONG32)m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); - return S_OK; + *pcchString = (ULONG32)m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); + } + else + hr = E_NOTIMPL; } - return E_NOTIMPL; + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetString(ULONG32 cchString, ULONG32* pcchString, WCHAR szString[]) { - if (m_debuggerId == -1) - return S_OK; - if (m_type == ELEMENT_TYPE_STRING) - { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + HRESULT hr = S_OK; + EX_TRY + { + if (m_debuggerId == -1) + hr = S_FALSE; + else if (m_type == ELEMENT_TYPE_STRING) + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_VALUE, &localbuf); - m_dbgprot_buffer_free(&localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_STRING_REF, MDBGPROT_CMD_STRING_REF_GET_VALUE, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - *pcchString = cchString; - int use_utf16 = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - if (use_utf16) - { - LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n")); - } - else - { - char* value = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetString - IMPLEMENTED\n")); - if (cchString >= strlen(value)) + *pcchString = cchString; + int use_utf16 = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + if (use_utf16) + { + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetString - NOT IMPLEMENTED - use_utf16\n")); + } + else { - MultiByteToWideChar(CP_UTF8, 0, value, -1, szString, cchString); - *pcchString = cchString; + char* value = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetString - IMPLEMENTED\n")); + if (cchString >= strlen(value)) + { + MultiByteToWideChar(CP_UTF8, 0, value, -1, szString, cchString); + *pcchString = cchString; + } + free(value); } - free(value); + hr = S_OK; } - return S_OK; + else + hr = E_NOTIMPL; } - return E_NOTIMPL; + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbObjectValue::CreateHandle(CorDebugHandleType type, ICorDebugHandleValue** ppHandle) @@ -585,24 +604,30 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue(ICorDebugClass* pClas mdFieldDef fieldDef, ICorDebugValue** ppValue) { - LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetFieldValue - IMPLEMENTED\n")); - if (m_debuggerId == -1) - return S_FALSE; - - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - m_dbgprot_buffer_add_int(&localbuf, fieldDef); + HRESULT hr = S_OK; + EX_TRY + { + if (m_debuggerId == -1) + hr = S_FALSE; + else { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + m_dbgprot_buffer_add_int(&localbuf, fieldDef); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); - m_dbgprot_buffer_free(&localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_OBJECT_REF, MDBGPROT_CMD_OBJECT_REF_GET_VALUES_ICORDBG, &localbuf); + m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - return CreateCordbValue(conn, pReply, ppValue); + hr = CreateCordbValue(conn, pReply, ppValue); + } + } + EX_CATCH_HRESULT(hr); + return hr; } int CordbObjectValue::GetTypeSize(int type) @@ -634,47 +659,18 @@ int CordbObjectValue::GetTypeSize(int type) HRESULT CordbObjectValue::CreateCordbValue(Connection* conn, MdbgProtBuffer* pReply, ICorDebugValue** ppValue) { - CorElementType type = (CorElementType)m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - CordbContent value; - - if ((MdbgProtValueTypeId)type == MDBGPROT_VALUE_TYPE_ID_NULL) - { + HRESULT hr = S_OK; + EX_TRY + { CorElementType type = (CorElementType)m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - if (type == ELEMENT_TYPE_CLASS || type == ELEMENT_TYPE_STRING) - { - int klass_id = (CorElementType)m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + CordbContent value; - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, klass_id); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - char* namespace_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char* class_name_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); - int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - - CordbClass* klass = new CordbClass(conn, token, module_id); - CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass); - refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); - free(namespace_str); - free(class_name_str); - free(class_fullname_str); - } - if (type == ELEMENT_TYPE_SZARRAY) + if ((MdbgProtValueTypeId)type == MDBGPROT_VALUE_TYPE_ID_NULL) { - CordbClass* klass = NULL; - int type_id = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); - if (type_id == ELEMENT_TYPE_CLASS) + CorElementType type = (CorElementType)m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + if (type == ELEMENT_TYPE_CLASS || type == ELEMENT_TYPE_STRING) { - int klass_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + int klass_id = (CorElementType)m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); @@ -689,60 +685,95 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection* conn, MdbgProtBuffer* pRe char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - klass = new CordbClass(conn, token, module_id); + + CordbClass* klass = new CordbClass(conn, token, module_id); + CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass); + refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); free(namespace_str); free(class_name_str); free(class_fullname_str); } - CordbType* cordbtype = new CordbType(type, conn, NULL, new CordbType((CorElementType)type_id, conn, klass)); - CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass, cordbtype); - refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + if (type == ELEMENT_TYPE_SZARRAY) + { + CordbClass* klass = NULL; + int type_id = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + if (type_id == ELEMENT_TYPE_CLASS) + { + int klass_id = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, klass_id); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_TYPE, MDBGPROT_CMD_TYPE_GET_INFO, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + char* namespace_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_name_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + char* class_fullname_str = m_dbgprot_decode_string(pReply->p, &pReply->p, pReply->end); + int assembly_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int module_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + klass = new CordbClass(conn, token, module_id); + free(namespace_str); + free(class_name_str); + free(class_fullname_str); + } + CordbType* cordbtype = new CordbType(type, conn, NULL, new CordbType((CorElementType)type_id, conn, klass)); + CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass, cordbtype); + refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + } + goto __Exit; } - return S_OK; - } - switch (type) - { - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_I1: - case ELEMENT_TYPE_U1: - value.booleanValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; - case ELEMENT_TYPE_CHAR: - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - value.charValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - case ELEMENT_TYPE_R4: - value.intValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - case ELEMENT_TYPE_R8: - value.longValue = m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); - break; - case ELEMENT_TYPE_CLASS: - case ELEMENT_TYPE_SZARRAY: - case ELEMENT_TYPE_STRING: + switch (type) { - int object_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, object_id); - refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); - return S_OK; + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + value.booleanValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + break; + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + value.charValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + break; + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_R4: + value.intValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + break; + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R8: + value.longValue = m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); + break; + case ELEMENT_TYPE_CLASS: + case ELEMENT_TYPE_SZARRAY: + case ELEMENT_TYPE_STRING: + { + int object_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, object_id); + refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); + goto __Exit; + } + default: + LOG((LF_CORDB, LL_INFO100000, "default value - %d", type)); + hr = E_FAIL; + goto __Exit; } - default: - LOG((LF_CORDB, LL_INFO100000, "default value - %d", type)); - return S_FALSE; + *ppValue = new CordbValue(conn, type, value, GetTypeSize(type)); + (*ppValue)->AddRef(); } - - *ppValue = new CordbValue(conn, type, value, GetTypeSize(type)); - (*ppValue)->AddRef(); - return S_OK; + EX_CATCH_HRESULT(hr); +__Exit: + return hr; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetVirtualMethod(mdMemberRef memberRef, ICorDebugFunction** ppFunction) @@ -1092,37 +1123,47 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElementType(CorElementType* pType) HRESULT STDMETHODCALLTYPE CordbArrayValue::GetRank(ULONG32* pnRank) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetRank - IMPLEMENTED\n")); - *pnRank = rank; - return S_OK; + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + *pnRank = rank; + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetCount(ULONG32* pnCount) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_nCount = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetCount - IMPLEMENTED\n")); - *pnCount = m_nCount; - return S_OK; + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_LENGTH, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + int rank = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + m_nCount = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); + LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetCount - IMPLEMENTED\n")); + *pnCount = m_nCount; + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetDimensions(ULONG32 cdim, ULONG32 dims[]) @@ -1147,20 +1188,24 @@ HRESULT STDMETHODCALLTYPE CordbArrayValue::GetBaseIndicies(ULONG32 cdim, ULONG32 HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElement(ULONG32 cdim, ULONG32 indices[], ICorDebugValue** ppValue) { LOG((LF_CORDB, LL_INFO1000000, "CordbArrayValue - GetElement - IMPLEMENTED\n")); + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); + m_dbgprot_buffer_add_int(&localbuf, indices[cdim - 1]); + m_dbgprot_buffer_add_int(&localbuf, 1); - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); - m_dbgprot_buffer_add_id(&localbuf, m_debuggerId); - m_dbgprot_buffer_add_int(&localbuf, indices[cdim - 1]); - m_dbgprot_buffer_add_int(&localbuf, 1); - - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); - m_dbgprot_buffer_free(&localbuf); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - CHECK_ERROR_RETURN_FALSE(received_reply_packet); - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); - return S_OK; + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ARRAY_REF, MDBGPROT_CMD_ARRAY_REF_GET_VALUES, &localbuf); + m_dbgprot_buffer_free(&localbuf); + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + hr = CordbObjectValue::CreateCordbValue(conn, pReply, ppValue); + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT STDMETHODCALLTYPE CordbArrayValue::GetElementAtPosition(ULONG32 nPosition, ICorDebugValue** ppValue) diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 13c44f934cbde2..018b82e9582097 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -17,6 +17,8 @@ #include "arraylist.h" #include "utsem.h" +#include "ex.h" +#include "log.h" #ifdef HOST_WIN32 #include @@ -39,10 +41,6 @@ static UTSemReadWrite* m_pSemReadWrite; #define LOGGING #endif -#include "log.h" - -#include "arraylist.h" - #define CreateProcess CreateProcessW class Socket; @@ -228,7 +226,7 @@ class Cordb : public ICorDebug, public ICorDebugRemote, public CordbBaseMono if (localbuf->Error() > 0 || localbuf->Error2() > 0) \ { \ LOG((LF_CORDB, LL_INFO100000, "ERROR RECEIVED\n")); \ - return S_FALSE; \ + EX_THROW(HRException, (E_FAIL)); \ } \ } while (0) From 7cc409c2f3f7707bf74d7048b657b1eedbd952c2 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 23 Feb 2021 19:40:00 -0300 Subject: [PATCH 35/64] Implementing get class --- src/mono/dbi/cordb-value.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index ce05783204c1a8..c74bab2db3945b 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -596,8 +596,12 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFunction(ICorDebugFunction** ppFu HRESULT STDMETHODCALLTYPE CordbObjectValue::GetClass(ICorDebugClass** ppClass) { - LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetClass - NOT IMPLEMENTED\n")); - return E_NOTIMPL; + LOG((LF_CORDB, LL_INFO100000, "CordbObjectValue - GetClass - IMPLEMENTED\n")); + if (m_pClass) { + m_pClass->QueryInterface(IID_ICorDebugClass, (void**)ppClass); + return S_OK; + } + return S_FALSE; } HRESULT STDMETHODCALLTYPE CordbObjectValue::GetFieldValue(ICorDebugClass* pClass, From abc2aa31c4bfc3952349a909b303994dcee3fbf3 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 24 Feb 2021 10:11:52 -0300 Subject: [PATCH 36/64] Apply suggestions from code review Co-authored-by: Noah Falk --- src/mono/dbi/cordb-assembly.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 395342cc2b89b5..09800a11cc156a 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -365,6 +365,7 @@ HRESULT CordbModule::GetToken(mdModule* pToken) HRESULT CordbModule::IsDynamic(BOOL* pDynamic) { LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); + *pDynamic = FALSE; return S_OK; } @@ -384,6 +385,7 @@ HRESULT CordbModule::GetSize(ULONG32* pcBytes) HRESULT CordbModule::IsInMemory(BOOL* pInMemory) { LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsInMemory - IMPLEMENTED\n")); + *pInMemory = FALSE; return S_OK; } From 208d2220ac5153bd9080cb22cdd39cfc8b8d7fd2 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Wed, 24 Feb 2021 11:20:30 -0300 Subject: [PATCH 37/64] Fix what @noahfalk suggested in his review. --- src/mono/dbi/cordb-assembly.cpp | 39 ++++++++++++++++++++++++++++----- src/mono/dbi/cordb-process.cpp | 14 +++++++++++- src/mono/dbi/cordb-process.h | 4 +++- src/mono/dbi/cordb-stepper.cpp | 3 ++- 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 09800a11cc156a..340492291a0b56 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -165,9 +165,17 @@ HRESULT CordbModule::CreateReaderForInMemorySymbols(REFIID riid, void** ppObj) return E_NOTIMPL; } -HRESULT CordbModule::SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cTokens, mdToken pTokens[]) +HRESULT CordbModule::SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cOthers, mdToken pTokens[]) { - LOG((LF_CORDB, LL_INFO100000, "CordbModule - SetJMCStatus - NOT IMPLEMENTED\n")); + if (cOthers != 0) + { + _ASSERTE(!"not yet impl for cOthers != 0"); + return E_NOTIMPL; + } + LOG((LF_CORDB, LL_INFO100000, "CordbModule - SetJMCStatus - IMPLEMENTED\n")); + //on mono JMC is not by module, for now receiving this for one module, will affect all. + if (bIsJustMyCode) + conn->GetProcess()->SetJMCStatus(bIsJustMyCode); return S_OK; } @@ -336,7 +344,12 @@ HRESULT CordbModule::GetMetaDataInterface(REFIID riid, IUnknown** ppObj) { if (m_pRegMeta == NULL) { + OptionValue optionForNewScope; + memset(&optionForNewScope, 0, sizeof(OptionValue)); + optionForNewScope.m_ThreadSafetyOptions = MDThreadSafetyOn; + m_pRegMeta = new RegMeta(); + m_pRegMeta->SetOption(&optionForNewScope); m_pStgdbRW = new CLiteWeightStgdbRW(); ULONG32 pcchName = 0; @@ -364,9 +377,25 @@ HRESULT CordbModule::GetToken(mdModule* pToken) HRESULT CordbModule::IsDynamic(BOOL* pDynamic) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); - *pDynamic = FALSE; - return S_OK; + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_IS_DYNAMIC, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + int m_bIsDynamic = m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); + *pDynamic = m_bIsDynamic; + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT CordbModule::GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue** ppValue) diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index dd072b1c1aaa54..acc5ae981d4cf4 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -26,6 +26,7 @@ CordbProcess::CordbProcess(Cordb* cordb) : CordbBaseMono(NULL) appDomains = new ArrayList(); m_pPendingEval = new ArrayList(); this->m_pCordb = cordb; + m_bIsJustMyCode = false; } CordbProcess::~CordbProcess() @@ -88,7 +89,7 @@ CordbProcess::~CordbProcess() void CordbProcess::CheckPendingEval() { DWORD i = 0; - while (i < m_pPendingEval->GetCount()) + while (m_pPendingEval && i < m_pPendingEval->GetCount()) { CordbEval* eval = (CordbEval*)m_pPendingEval->Get(i); if (eval) @@ -643,3 +644,14 @@ CordbFunctionBreakpoint* CordbProcess::GetBreakpointByOffsetAndFuncId(int64_t of } return NULL; } + +void CordbProcess::SetJMCStatus(BOOL bIsJustMyCode) +{ + m_bIsJustMyCode = bIsJustMyCode; +} + +BOOL CordbProcess::GetJMCStatus() +{ + return m_bIsJustMyCode; +} + diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index 386b070225e722..a8f9be03ca40cb 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -28,7 +28,7 @@ class CordbProcess : public CordbBaseMono, ArrayList* m_pPendingEval; CordbAppDomainEnum* m_pAppDomainEnum; Cordb* m_pCordb; - + BOOL m_bIsJustMyCode; public: ArrayList* appDomains; CordbProcess(Cordb* cordb); @@ -124,6 +124,8 @@ class CordbProcess : public CordbBaseMono, CordbThread* FindThread(long thread_id); CordbFunctionBreakpoint* GetBreakpointByOffsetAndFuncId(int64_t offset, int method_id); void CheckPendingEval(); + void SetJMCStatus(BOOL bIsJustMyCode); + BOOL GetJMCStatus(); }; #endif diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index 5d76e1f451eb34..070980a85eaeff 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include using namespace std; @@ -73,7 +74,7 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, COR_DEBUG_STEP_R m_dbgprot_buffer_add_id(&sendbuf, m_pThread->GetThreadId()); m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_SIZE_MIN); m_dbgprot_buffer_add_int(&sendbuf, bStepIn ? MDBGPROT_STEP_DEPTH_INTO : MDBGPROT_STEP_DEPTH_OVER); - m_dbgprot_buffer_add_int(&sendbuf, MDBGPROT_STEP_FILTER_NONE); + m_dbgprot_buffer_add_int(&sendbuf, conn->GetProcess()->GetJMCStatus() ? MDBGPROT_STEP_FILTER_DEBUGGER_NON_USER_CODE : MDBGPROT_STEP_FILTER_NONE); int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); From 5363bce11fc60c14e7fd0b30df28da0def3e97c1 Mon Sep 17 00:00:00 2001 From: Thays Date: Wed, 24 Feb 2021 15:06:06 -0300 Subject: [PATCH 38/64] Fixing what was suggested by @viniciusjarina --- src/mono/dbi/cordb-code.cpp | 34 ++++++++++++++++++---------------- src/mono/dbi/cordb-eval.cpp | 3 +-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index 1bc59777b6e625..9c9697a20489d0 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -37,22 +37,24 @@ HRESULT CordbCode::GetAddress(CORDB_ADDRESS* pStart) return E_NOTIMPL; } -ULONG32 CordbCode::GetSize() { - if (m_nSize == -1) { - MdbgProtBuffer localbuf; - m_dbgprot_buffer_init(&localbuf, 128); +ULONG32 CordbCode::GetSize() +{ + if (m_nSize != -1) + return m_nSize; - m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); - m_dbgprot_buffer_free(&localbuf); + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); - ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); - if (received_reply_packet->Error() > 0 || received_reply_packet->Error2() > 0) - return 0; - MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + m_dbgprot_buffer_add_id(&localbuf, this->GetFunction()->GetDebuggerId()); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_METHOD, MDBGPROT_CMD_METHOD_GET_BODY, &localbuf); + m_dbgprot_buffer_free(&localbuf); - m_nSize = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - } + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + if (received_reply_packet->Error() > 0 || received_reply_packet->Error2() > 0) + return 0; + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_nSize = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); return m_nSize; } @@ -77,7 +79,7 @@ HRESULT CordbCode::GetCode( { LOG((LF_CORDB, LL_INFO1000000, "CordbCode - GetCode - IMPLEMENTED\n")); HRESULT hr = S_OK; - EX_TRY + EX_TRY { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); @@ -89,9 +91,9 @@ HRESULT CordbCode::GetCode( ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); CHECK_ERROR_RETURN_FALSE(received_reply_packet); MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - + ULONG32 totalSize = GetSize(); - + if (cBufferAlloc < endOffset - startOffset) endOffset = startOffset + cBufferAlloc; diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index 4d0705aaabdb4e..cd3ca87645afa8 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -93,7 +93,6 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction(ICorDebugFunction void CordbEval::EvalComplete(MdbgProtBuffer* pReply) { - m_dbgprot_decode_byte(pReply->p, &pReply->p, pReply->end); CordbObjectValue::CreateCordbValue(conn, pReply, &m_pValue); @@ -136,7 +135,7 @@ HRESULT STDMETHODCALLTYPE CordbEval::NewParameterizedArray(ICorDebugType* pEleme HRESULT STDMETHODCALLTYPE CordbEval::NewStringWithLength(LPCWSTR string, UINT uiLength) { HRESULT hr = S_OK; - EX_TRY + EX_TRY { conn->GetProcess()->Stop(false); MdbgProtBuffer localbuf; From 24bccdb053730350c0a8f6d26818d05aebeda3e2 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Wed, 24 Feb 2021 15:47:38 -0300 Subject: [PATCH 39/64] Fix what was suggested by @viniciusjarina --- src/mono/dbi/cordb-appdomain.cpp | 6 +-- src/mono/dbi/cordb-assembly.cpp | 1 - src/mono/dbi/cordb-frame.cpp | 4 +- src/mono/dbi/cordb-process.cpp | 72 +++++++++++++++----------------- src/mono/dbi/cordb-process.h | 2 +- 5 files changed, 39 insertions(+), 46 deletions(-) diff --git a/src/mono/dbi/cordb-appdomain.cpp b/src/mono/dbi/cordb-appdomain.cpp index 74f8c73914508b..d59b942fdcf535 100644 --- a/src/mono/dbi/cordb-appdomain.cpp +++ b/src/mono/dbi/cordb-appdomain.cpp @@ -232,12 +232,12 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Next(ULONG celt, ICorDebugAppDomai *pceltFetched = celt; for (ULONG i = 0; i < celt; i++) { - if (current_pos >= pProcess->appDomains->GetCount()) + if (current_pos >= pProcess->m_pAddDomains->GetCount()) { *pceltFetched = 0; return S_FALSE; } - CordbAppDomain* appdomain = (CordbAppDomain*)pProcess->appDomains->Get(current_pos); + CordbAppDomain* appdomain = (CordbAppDomain*)pProcess->m_pAddDomains->Get(current_pos); appdomain->QueryInterface(IID_ICorDebugAppDomain, (void**)values + current_pos); current_pos++; } @@ -266,7 +266,7 @@ HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::Clone(ICorDebugEnum** ppEnum) HRESULT STDMETHODCALLTYPE CordbAppDomainEnum::GetCount(ULONG* pcelt) { LOG((LF_CORDB, LL_INFO1000000, "CordbAppDomainEnum - GetCount - IMPLEMENTED\n")); - *pcelt = pProcess->appDomains->GetCount(); + *pcelt = pProcess->m_pAddDomains->GetCount(); return S_OK; } diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 340492291a0b56..cea8d538274c75 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -231,7 +231,6 @@ HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS* pAddress) m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); } LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); - *pAddress = (CORDB_ADDRESS)m_pAssemblyMetadataBlob; } EX_CATCH_HRESULT(hr); diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index 3785d86d27e3ab..2ca27fc99c3910 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -154,8 +154,8 @@ HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetFunctionToken(mdMethodDef* pToken) HRESULT STDMETHODCALLTYPE CordbJITILFrame::GetStackRange(CORDB_ADDRESS* pStart, CORDB_ADDRESS* pEnd) { - *pStart = 4096; - *pEnd = 8192; + *pStart = 0; //forced value, only to make vs work, I'm not sure which value should returned from mono runtime + *pEnd = 1; //forced value, only to make vs work, I'm not sure which value should returned from mono runtime LOG((LF_CORDB, LL_INFO100000, "CordbFrame - GetStackRange - NOT IMPLEMENTED\n")); return S_OK; } diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index acc5ae981d4cf4..ea2375bdf986b4 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -23,7 +23,7 @@ CordbProcess::CordbProcess(Cordb* cordb) : CordbBaseMono(NULL) m_pThreads = new ArrayList(); m_pFunctions = new ArrayList(); m_pModules = new ArrayList(); - appDomains = new ArrayList(); + m_pAddDomains = new ArrayList(); m_pPendingEval = new ArrayList(); this->m_pCordb = cordb; m_bIsJustMyCode = false; @@ -33,80 +33,74 @@ CordbProcess::~CordbProcess() { if (m_pAppDomainEnum) m_pAppDomainEnum->InternalRelease(); - DWORD i = 0; - while (i < m_pBreakpoints->GetCount()) + + for (DWORD i = 0; i < m_pBreakpoints->GetCount(); i++) { CordbFunctionBreakpoint* breakpoint = (CordbFunctionBreakpoint*)m_pBreakpoints->Get(i); if (breakpoint) breakpoint->InternalRelease(); - i++; } - i = 0; - while (i < m_pThreads->GetCount()) + + for (DWORD i = 0; i < m_pThreads->GetCount(); i++) { CordbThread* thread = (CordbThread*)m_pThreads->Get(i); thread->InternalRelease(); - i++; } - i = 0; - while (i < m_pFunctions->GetCount()) + + for (DWORD i = 0; i < m_pFunctions->GetCount(); i++) { CordbFunction* function = (CordbFunction*)m_pFunctions->Get(i); function->InternalRelease(); - i++; } - i = 0; - while (i < appDomains->GetCount()) + + for (DWORD i = 0; i < m_pAddDomains->GetCount(); i++) { - CordbAppDomain* appdomain = (CordbAppDomain*)appDomains->Get(i); + CordbAppDomain* appdomain = (CordbAppDomain*)m_pAddDomains->Get(i); appdomain->InternalRelease(); - i++; } - i = 0; - while (i < m_pModules->GetCount()) + + for (DWORD i = 0; i < m_pModules->GetCount(); i++) { CordbModule* module = (CordbModule*)m_pModules->Get(i); module->InternalRelease(); - i++; } - i = 0; - while (i < m_pPendingEval->GetCount()) + + for (DWORD i = 0; i < m_pPendingEval->GetCount(); i++) { CordbEval* eval = (CordbEval*)m_pPendingEval->Get(i); if (eval) eval->InternalRelease(); - i++; } + delete m_pBreakpoints; delete m_pThreads; delete m_pFunctions; delete m_pModules; - delete appDomains; + delete m_pAddDomains; delete m_pPendingEval; delete conn; } void CordbProcess::CheckPendingEval() { - DWORD i = 0; - while (m_pPendingEval && i < m_pPendingEval->GetCount()) + if (!m_pPendingEval) + return; + for (DWORD i = 0; i < m_pPendingEval->GetCount(); i++) { CordbEval* eval = (CordbEval*)m_pPendingEval->Get(i); - if (eval) - { - ReceivedReplyPacket* recvbuf = conn->GetReplyWithError(eval->GetCommandId()); - if (recvbuf) - { - eval->EvalComplete(recvbuf->Buffer()); - eval->InternalRelease(); - dbg_lock(); - m_pPendingEval->Set(i, NULL); - dbg_unlock(); - } - } - i++; + if (!eval) + continue; + ReceivedReplyPacket* recvbuf = conn->GetReplyWithError(eval->GetCommandId()); + if (!recvbuf) + continue; + eval->EvalComplete(recvbuf->Buffer()); + eval->InternalRelease(); + dbg_lock(); + m_pPendingEval->Set(i, NULL); + dbg_unlock(); } } + HRESULT CordbProcess::EnumerateLoaderHeapMemoryRegions(ICorDebugMemoryRangeEnum** ppRanges) { LOG((LF_CORDB, LL_INFO100000, "CordbProcess - EnumerateLoaderHeapMemoryRegions - NOT IMPLEMENTED\n")); @@ -549,7 +543,7 @@ void CordbProcess::AddModule(CordbModule* module) void CordbProcess::AddAppDomain(CordbAppDomain* appDomain) { - appDomains->Append(appDomain); + m_pAddDomains->Append(appDomain); appDomain->InternalAddRef(); } @@ -609,8 +603,8 @@ CordbModule* CordbProcess::GetModule(int module_id) CordbAppDomain* CordbProcess::GetCurrentAppDomain() { - if (appDomains->GetCount() > 0) - return (CordbAppDomain*)appDomains->Get(0); + if (m_pAddDomains->GetCount() > 0) + return (CordbAppDomain*)m_pAddDomains->Get(0); return NULL; } diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index a8f9be03ca40cb..d15549a51239e4 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -30,7 +30,7 @@ class CordbProcess : public CordbBaseMono, Cordb* m_pCordb; BOOL m_bIsJustMyCode; public: - ArrayList* appDomains; + ArrayList* m_pAddDomains; CordbProcess(Cordb* cordb); ULONG STDMETHODCALLTYPE AddRef(void) { From bafe8ee5cbb02024c8037d3bee6b488bcf4838ef Mon Sep 17 00:00:00 2001 From: Thays Date: Thu, 25 Feb 2021 12:23:52 -0300 Subject: [PATCH 40/64] Changing what @noahfalk suggested --- src/mono/dbi/cordb-assembly.cpp | 24 ++++++++++++------------ src/mono/dbi/cordb-assembly.h | 4 ++-- src/mono/dbi/cordb-process.cpp | 17 +---------------- src/mono/dbi/cordb-process.h | 1 - 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index cea8d538274c75..9bbef0b7525151 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -107,7 +107,7 @@ CordbModule::CordbModule(Connection* conn, CordbProcess* process, CordbAssembly* m_pAssembly->InternalAddRef(); dwFlags = 0; conn->GetProcess()->AddModule(this); - m_pAssemblyMetadataBlob = NULL; + m_pPeImage = NULL; m_pAssemblyName = NULL; } @@ -115,8 +115,8 @@ CordbModule::~CordbModule() { if (m_pAssembly) m_pAssembly->InternalRelease(); - if (m_pAssemblyMetadataBlob) - free(m_pAssemblyMetadataBlob); + if (m_pPeImage) + free(m_pPeImage); if (m_pAssemblyName) free(m_pAssemblyName); } @@ -172,7 +172,7 @@ HRESULT CordbModule::SetJMCStatus(BOOL bIsJustMyCode, ULONG32 cOthers, mdToken p _ASSERTE(!"not yet impl for cOthers != 0"); return E_NOTIMPL; } - LOG((LF_CORDB, LL_INFO100000, "CordbModule - SetJMCStatus - IMPLEMENTED\n")); + LOG((LF_CORDB, LL_INFO100000, "CordbModule - SetJMCStatus - IMPLEMENTED\n")); //on mono JMC is not by module, for now receiving this for one module, will affect all. if (bIsJustMyCode) conn->GetProcess()->SetJMCStatus(bIsJustMyCode); @@ -215,9 +215,9 @@ HRESULT CordbModule::GetProcess(ICorDebugProcess** ppProcess) HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS* pAddress) { HRESULT hr = S_OK; - EX_TRY + EX_TRY { - if (!m_pAssemblyMetadataBlob) { + if (!m_pPeImage) { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); @@ -228,10 +228,10 @@ HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS* pAddress) CHECK_ERROR_RETURN_FALSE(received_reply_packet); MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - m_pAssemblyMetadataBlob = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_assemblyMetadataLen); + m_pPeImage = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_nPeImageSize); } LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); - *pAddress = (CORDB_ADDRESS)m_pAssemblyMetadataBlob; + *pAddress = (CORDB_ADDRESS)m_pPeImage; } EX_CATCH_HRESULT(hr); return hr; @@ -286,7 +286,7 @@ HRESULT CordbModule::EnableClassLoadCallbacks(BOOL bClassLoadCallbacks) HRESULT CordbModule::GetFunctionFromToken(mdMethodDef methodDef, ICorDebugFunction** ppFunction) { HRESULT hr = S_OK; - EX_TRY + EX_TRY { LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetFunctionFromToken - IMPLEMENTED\n")); MdbgProtBuffer localbuf; @@ -376,9 +376,9 @@ HRESULT CordbModule::GetToken(mdModule* pToken) HRESULT CordbModule::IsDynamic(BOOL* pDynamic) { - LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); + LOG((LF_CORDB, LL_INFO1000000, "CordbModule - IsDynamic - IMPLEMENTED\n")); HRESULT hr = S_OK; - EX_TRY + EX_TRY { MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); @@ -406,7 +406,7 @@ HRESULT CordbModule::GetGlobalVariableValue(mdFieldDef fieldDef, ICorDebugValue* HRESULT CordbModule::GetSize(ULONG32* pcBytes) { LOG((LF_CORDB, LL_INFO100000, "CordbModule - GetSize -IMPLEMENTED\n")); - *pcBytes = m_assemblyMetadataLen; + *pcBytes = m_nPeImageSize; return S_OK; } diff --git a/src/mono/dbi/cordb-assembly.h b/src/mono/dbi/cordb-assembly.h index b878414b96323b..e2b22e5bd7c906 100644 --- a/src/mono/dbi/cordb-assembly.h +++ b/src/mono/dbi/cordb-assembly.h @@ -22,8 +22,8 @@ class CordbModule : public CordbBaseMono, RegMeta* m_pRegMeta; CordbAssembly* m_pAssembly; CLiteWeightStgdbRW* m_pStgdbRW; - uint8_t* m_pAssemblyMetadataBlob; - int32_t m_assemblyMetadataLen; + uint8_t* m_pPeImage; + int32_t m_nPeImageSize; unsigned long dwFlags; char * m_pAssemblyName; diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index ea2375bdf986b4..3b3c2e3e0f758f 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -33,7 +33,7 @@ CordbProcess::~CordbProcess() { if (m_pAppDomainEnum) m_pAppDomainEnum->InternalRelease(); - + for (DWORD i = 0; i < m_pBreakpoints->GetCount(); i++) { CordbFunctionBreakpoint* breakpoint = (CordbFunctionBreakpoint*)m_pBreakpoints->Get(i); @@ -573,21 +573,6 @@ CordbFunction* CordbProcess::FindFunction(int id) return NULL; } -CordbFunction* CordbProcess::FindFunctionByToken(int token) -{ - DWORD i = 0; - while (i < m_pFunctions->GetCount()) - { - CordbFunction* function = (CordbFunction*)m_pFunctions->Get(i); - if (function->GetMetadataToken() == token) - { - return function; - } - i++; - } - return NULL; -} - CordbModule* CordbProcess::GetModule(int module_id) { for (DWORD i = 0; i < m_pModules->GetCount(); i++) diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index d15549a51239e4..d3567558a6ee93 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -118,7 +118,6 @@ class CordbProcess : public CordbBaseMono, void AddBreakpoint(CordbFunctionBreakpoint* bp); void AddPendingEval(CordbEval* eval); CordbFunction* FindFunction(int id); - CordbFunction* FindFunctionByToken(int token); CordbModule* GetModule(int module_id); CordbAppDomain* GetCurrentAppDomain(); CordbThread* FindThread(long thread_id); From 5682529f25c5f3201d0ea7697d7e2520744dbfff Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Mon, 1 Mar 2021 18:31:39 -0300 Subject: [PATCH 41/64] Accept more than 1 stepper per thread --- src/mono/dbi/cordb-breakpoint.cpp | 9 +++++- src/mono/dbi/cordb-breakpoint.h | 5 ++++ src/mono/dbi/cordb-frame.cpp | 3 -- src/mono/dbi/cordb-process.cpp | 48 +++++++++++++++++++++++-------- src/mono/dbi/cordb-process.h | 5 +++- src/mono/dbi/cordb-stepper.cpp | 7 +++-- src/mono/dbi/cordb-stepper.h | 7 +++-- src/mono/dbi/cordb-thread.cpp | 5 ---- src/mono/dbi/cordb-thread.h | 4 --- src/mono/dbi/cordb.cpp | 5 ++-- 10 files changed, 65 insertions(+), 33 deletions(-) diff --git a/src/mono/dbi/cordb-breakpoint.cpp b/src/mono/dbi/cordb-breakpoint.cpp index a12e9def98c3b5..1d45b6e0fb6d3a 100644 --- a/src/mono/dbi/cordb-breakpoint.cpp +++ b/src/mono/dbi/cordb-breakpoint.cpp @@ -18,6 +18,7 @@ CordbFunctionBreakpoint::CordbFunctionBreakpoint(Connection* conn, CordbCode* co this->m_pCode = code; this->m_offset = offset; conn->GetProcess()->AddBreakpoint(this); + m_debuggerId = -1; } CordbFunctionBreakpoint::~CordbFunctionBreakpoint() {} @@ -48,9 +49,15 @@ HRESULT CordbFunctionBreakpoint::Activate(BOOL bActive) m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_MOD_KIND_LOCATION_ONLY); m_dbgprot_buffer_add_id(&sendbuf, this->GetCode()->GetFunction()->GetDebuggerId()); m_dbgprot_buffer_add_long(&sendbuf, m_offset); - conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_SET, &sendbuf); m_dbgprot_buffer_free(&sendbuf); LOG((LF_CORDB, LL_INFO1000000, "CordbFunctionBreakpoint - Activate - IMPLEMENTED\n")); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + + m_debuggerId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); } else { diff --git a/src/mono/dbi/cordb-breakpoint.h b/src/mono/dbi/cordb-breakpoint.h index 614e564bc47fd0..ad3444551d5042 100644 --- a/src/mono/dbi/cordb-breakpoint.h +++ b/src/mono/dbi/cordb-breakpoint.h @@ -13,6 +13,7 @@ class CordbFunctionBreakpoint : public CordbBaseMono, public ICorDebugFunctionBr { CordbCode* m_pCode; ULONG32 m_offset; + int m_debuggerId; public: CordbFunctionBreakpoint(Connection* conn, CordbCode* code, ULONG32 offset); @@ -42,6 +43,10 @@ class CordbFunctionBreakpoint : public CordbBaseMono, public ICorDebugFunctionBr HRESULT STDMETHODCALLTYPE Activate(BOOL bActive); HRESULT STDMETHODCALLTYPE IsActive(BOOL* pbActive); HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* pInterface); + int GetDebuggerId() const + { + return m_debuggerId; + } }; #endif diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index 2ca27fc99c3910..bbf713effdce22 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -96,9 +96,6 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG* pcelt) m_ppFrames[i] = frame; } - if (!m_pThread->GetStepper()) - m_pThread->SetRegisterSet(new CordbRegisterSet(conn, 0, 0)); - *pcelt = m_nFrames; } EX_CATCH_HRESULT(hr); diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index 3b3c2e3e0f758f..43432da735ff54 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include using namespace std; @@ -23,8 +24,9 @@ CordbProcess::CordbProcess(Cordb* cordb) : CordbBaseMono(NULL) m_pThreads = new ArrayList(); m_pFunctions = new ArrayList(); m_pModules = new ArrayList(); - m_pAddDomains = new ArrayList(); + m_pAddDomains = new ArrayList(); m_pPendingEval = new ArrayList(); + m_pSteppers = new ArrayList(); this->m_pCordb = cordb; m_bIsJustMyCode = false; } @@ -41,6 +43,13 @@ CordbProcess::~CordbProcess() breakpoint->InternalRelease(); } + for (DWORD i = 0; i < m_pSteppers->GetCount(); i++) + { + CordbStepper* stepper = (CordbStepper*)m_pSteppers->Get(i); + if (stepper) + stepper->InternalRelease(); + } + for (DWORD i = 0; i < m_pThreads->GetCount(); i++) { CordbThread* thread = (CordbThread*)m_pThreads->Get(i); @@ -552,23 +561,41 @@ void CordbProcess::AddPendingEval(CordbEval* eval) m_pPendingEval->Append(eval); eval->InternalAddRef(); } + void CordbProcess::AddBreakpoint(CordbFunctionBreakpoint* bp) { m_pBreakpoints->Append(bp); bp->InternalAddRef(); } +void CordbProcess::AddStepper(CordbStepper* step) +{ + m_pSteppers->Append(step); + step->InternalAddRef(); +} + CordbFunction* CordbProcess::FindFunction(int id) { - DWORD i = 0; - while (i < m_pFunctions->GetCount()) + for (DWORD i = 0; i < m_pFunctions->GetCount(); i++) { CordbFunction* function = (CordbFunction*)m_pFunctions->Get(i); if (function->GetDebuggerId() == id) { return function; } - i++; + } + return NULL; +} + +CordbStepper* CordbProcess::GetStepper(int id) +{ + for (DWORD i = 0; i < m_pSteppers->GetCount(); i++) + { + CordbStepper* stepper = (CordbStepper*)m_pSteppers->Get(i); + if (stepper->GetDebuggerId() == id) + { + return stepper; + } } return NULL; } @@ -608,18 +635,15 @@ CordbThread* CordbProcess::FindThread(long thread_id) return NULL; } -CordbFunctionBreakpoint* CordbProcess::GetBreakpointByOffsetAndFuncId(int64_t offset, int method_id) +CordbFunctionBreakpoint* CordbProcess::GetBreakpoint(int id) { - DWORD i = 0; - CordbFunctionBreakpoint* breakpoint = NULL; - while (i < m_pBreakpoints->GetCount()) + for (DWORD i = 0; i < m_pBreakpoints->GetCount(); i++) { - breakpoint = (CordbFunctionBreakpoint*)m_pBreakpoints->Get(i); - if (breakpoint->GetOffset() == offset && breakpoint->GetCode()->GetFunction()->GetDebuggerId() == method_id) + CordbFunctionBreakpoint* bp = (CordbFunctionBreakpoint*)m_pBreakpoints->Get(i); + if (bp->GetDebuggerId() == id) { - return breakpoint; + return bp; } - i++; } return NULL; } diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index d3567558a6ee93..0eb8a10338e332 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -26,6 +26,7 @@ class CordbProcess : public CordbBaseMono, ArrayList* m_pFunctions; ArrayList* m_pModules; ArrayList* m_pPendingEval; + ArrayList* m_pSteppers; CordbAppDomainEnum* m_pAppDomainEnum; Cordb* m_pCordb; BOOL m_bIsJustMyCode; @@ -117,11 +118,13 @@ class CordbProcess : public CordbBaseMono, void AddAppDomain(CordbAppDomain* appDomain); void AddBreakpoint(CordbFunctionBreakpoint* bp); void AddPendingEval(CordbEval* eval); + void AddStepper(CordbStepper* step); CordbFunction* FindFunction(int id); CordbModule* GetModule(int module_id); + CordbStepper* GetStepper(int id); CordbAppDomain* GetCurrentAppDomain(); CordbThread* FindThread(long thread_id); - CordbFunctionBreakpoint* GetBreakpointByOffsetAndFuncId(int64_t offset, int method_id); + CordbFunctionBreakpoint* GetBreakpoint(int id); void CheckPendingEval(); void SetJMCStatus(BOOL bIsJustMyCode); BOOL GetJMCStatus(); diff --git a/src/mono/dbi/cordb-stepper.cpp b/src/mono/dbi/cordb-stepper.cpp index 070980a85eaeff..fba5d4c278a750 100644 --- a/src/mono/dbi/cordb-stepper.cpp +++ b/src/mono/dbi/cordb-stepper.cpp @@ -15,7 +15,8 @@ using namespace std; CordbStepper::CordbStepper(Connection* conn, CordbThread* thread) : CordbBaseMono(conn) { m_pThread = thread; - m_commandId = -1; + m_debuggerId = -1; + conn->GetProcess()->AddStepper(this); } CordbStepper::~CordbStepper() {} @@ -33,7 +34,7 @@ HRESULT STDMETHODCALLTYPE CordbStepper::Deactivate(void) int buflen = 128; m_dbgprot_buffer_init(&sendbuf, buflen); m_dbgprot_buffer_add_byte(&sendbuf, MDBGPROT_EVENT_KIND_STEP); - m_dbgprot_buffer_add_int(&sendbuf, m_commandId); + m_dbgprot_buffer_add_int(&sendbuf, m_debuggerId); conn->SendEvent(MDBGPROT_CMD_SET_EVENT_REQUEST, MDBGPROT_CMD_EVENT_REQUEST_CLEAR, &sendbuf); m_dbgprot_buffer_free(&sendbuf); return S_OK; @@ -83,7 +84,7 @@ HRESULT STDMETHODCALLTYPE CordbStepper::StepRange(BOOL bStepIn, COR_DEBUG_STEP_R CHECK_ERROR_RETURN_FALSE(received_reply_packet); MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - m_commandId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); + m_debuggerId = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); } EX_CATCH_HRESULT(hr); return hr; diff --git a/src/mono/dbi/cordb-stepper.h b/src/mono/dbi/cordb-stepper.h index e3a9d5ebe93fc2..c8d031bec52a9b 100644 --- a/src/mono/dbi/cordb-stepper.h +++ b/src/mono/dbi/cordb-stepper.h @@ -12,7 +12,7 @@ class CordbStepper : public CordbBaseMono, public ICorDebugStepper, public ICorDebugStepper2 { CordbThread* m_pThread; - int m_commandId; + int m_debuggerId; public: CordbStepper(Connection* conn, CordbThread* thread); @@ -38,8 +38,11 @@ class CordbStepper : public CordbBaseMono, public ICorDebugStepper, public ICorD HRESULT STDMETHODCALLTYPE StepOut(void); HRESULT STDMETHODCALLTYPE SetRangeIL(BOOL bIL); HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); - HRESULT STDMETHODCALLTYPE SetJMC(BOOL fIsJMCStepper); + int GetDebuggerId() const + { + return m_debuggerId; + } }; #endif diff --git a/src/mono/dbi/cordb-thread.cpp b/src/mono/dbi/cordb-thread.cpp index 97d48dad7c8c86..d7eccbbc3978f2 100644 --- a/src/mono/dbi/cordb-thread.cpp +++ b/src/mono/dbi/cordb-thread.cpp @@ -21,7 +21,6 @@ CordbThread::CordbThread(Connection* conn, CordbProcess* ppProcess, long thread_ { this->m_pProcess = ppProcess; this->m_threadId = thread_id; - m_pStepper = NULL; m_pRegisterSet = NULL; m_pCurrentFrame = NULL; m_pBlockingObject = NULL; @@ -36,8 +35,6 @@ CordbThread::~CordbThread() m_pBlockingObject->InternalRelease(); if (m_pRegisterSet) m_pRegisterSet->InternalRelease(); - if (m_pStepper) - m_pStepper->InternalRelease(); } void CordbThread::SetRegisterSet(CordbRegisterSet* rs) @@ -184,8 +181,6 @@ HRESULT STDMETHODCALLTYPE CordbThread::ClearCurrentException(void) HRESULT STDMETHODCALLTYPE CordbThread::CreateStepper(ICorDebugStepper** ppStepper) { - if (m_pStepper) - m_pStepper->InternalRelease(); m_pStepper = new CordbStepper(conn, this); m_pStepper->InternalAddRef(); m_pStepper->QueryInterface(IID_ICorDebugStepper, (void**)ppStepper); diff --git a/src/mono/dbi/cordb-thread.h b/src/mono/dbi/cordb-thread.h index 25ec76fc33c60f..cb133ddc29b95a 100644 --- a/src/mono/dbi/cordb-thread.h +++ b/src/mono/dbi/cordb-thread.h @@ -72,10 +72,6 @@ class CordbThread : public CordbBaseMono, { return m_threadId; } - CordbStepper* GetStepper() const - { - return m_pStepper; - } }; #endif diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index e0b2c911f9c82c..96866ecd7e8c26 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -374,7 +374,7 @@ void Connection::ProcessPacketInternal(MdbgProtBuffer* recvbuf) m_pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); } DWORD i = 0; - CordbFunctionBreakpoint* breakpoint = GetProcess()->GetBreakpointByOffsetAndFuncId(offset, method_id); + CordbFunctionBreakpoint* breakpoint = GetProcess()->GetBreakpoint(req_id); m_pCordb->GetCallback()->Breakpoint(pCorDebugAppDomain, thread, static_cast(breakpoint)); } @@ -390,7 +390,8 @@ void Connection::ProcessPacketInternal(MdbgProtBuffer* recvbuf) GetProcess()->Stop(false); m_pCordb->GetCallback()->CreateThread(pCorDebugAppDomain, thread); } - m_pCordb->GetCallback()->StepComplete(pCorDebugAppDomain, thread, thread->GetStepper(), STEP_NORMAL); + CordbStepper* stepper = GetProcess()->GetStepper(req_id); + m_pCordb->GetCallback()->StepComplete(pCorDebugAppDomain, thread, stepper, STEP_NORMAL); } break; default: From 8627c1a178d0be2bcc415671a55e56966cf323b8 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Tue, 2 Mar 2021 14:36:29 -0300 Subject: [PATCH 42/64] Changing what was suggested by @noahfalk --- src/mono/dbi/cordb-frame.cpp | 20 +++++++--- src/mono/dbi/cordb-frame.h | 2 + src/mono/dbi/cordb-process.cpp | 67 ++++++++++++++++++++++++++-------- 3 files changed, 69 insertions(+), 20 deletions(-) diff --git a/src/mono/dbi/cordb-frame.cpp b/src/mono/dbi/cordb-frame.cpp index bbf713effdce22..32c2a53c11ed09 100644 --- a/src/mono/dbi/cordb-frame.cpp +++ b/src/mono/dbi/cordb-frame.cpp @@ -28,6 +28,7 @@ CordbFrameEnum::~CordbFrameEnum() HRESULT STDMETHODCALLTYPE CordbFrameEnum::Next(ULONG celt, ICorDebugFrame* frames[], ULONG* pceltFetched) { + GetCount(); for (int i = 0; i < m_nFrames; i++) { this->m_ppFrames[i]->QueryInterface(IID_ICorDebugFrame, (void**)&frames[i]); @@ -61,10 +62,10 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::Clone(ICorDebugEnum** ppEnum) return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG* pcelt) -{ - LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - GetCount - IMPLEMENTED\n")); +HRESULT CordbFrameEnum::GetCount() { HRESULT hr = S_OK; + if (m_nFrames != 0) + return hr; EX_TRY { Reset(); @@ -95,13 +96,22 @@ HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG* pcelt) frame->InternalAddRef(); m_ppFrames[i] = frame; } - - *pcelt = m_nFrames; } EX_CATCH_HRESULT(hr); return hr; } +HRESULT STDMETHODCALLTYPE CordbFrameEnum::GetCount(ULONG* pcelt) +{ + LOG((LF_CORDB, LL_INFO1000000, "CordbFrameEnum - GetCount - IMPLEMENTED\n")); + HRESULT hr = S_OK; + + hr = GetCount(); + *pcelt = m_nFrames; + + return hr; +} + HRESULT STDMETHODCALLTYPE CordbFrameEnum::QueryInterface(REFIID riid, void** ppvObject) { LOG((LF_CORDB, LL_INFO100000, "CordbFrameEnum - QueryInterface - NOT IMPLEMENTED\n")); diff --git a/src/mono/dbi/cordb-frame.h b/src/mono/dbi/cordb-frame.h index ea2bf232025297..167aeda240b2c0 100644 --- a/src/mono/dbi/cordb-frame.h +++ b/src/mono/dbi/cordb-frame.h @@ -151,6 +151,8 @@ class CordbFrameEnum : public CordbBaseMono, public ICorDebugFrameEnum HRESULT STDMETHODCALLTYPE Clone(ICorDebugEnum** ppEnum); HRESULT STDMETHODCALLTYPE GetCount(ULONG* pcelt); HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); + + HRESULT GetCount(); }; #endif diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index 43432da735ff54..e2c525cc427440 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -29,10 +29,12 @@ CordbProcess::CordbProcess(Cordb* cordb) : CordbBaseMono(NULL) m_pSteppers = new ArrayList(); this->m_pCordb = cordb; m_bIsJustMyCode = false; + m_pSemReadWrite = new UTSemReadWrite(); } CordbProcess::~CordbProcess() { + delete m_pSemReadWrite; if (m_pAppDomainEnum) m_pAppDomainEnum->InternalRelease(); @@ -534,118 +536,153 @@ CordbProcess::CommitChanges(ULONG cSnapshots, void CordbProcess::AddThread(CordbThread* thread) { + dbg_lock(); m_pThreads->Append(thread); thread->InternalAddRef(); + dbg_unlock(); } void CordbProcess::AddFunction(CordbFunction* function) { + dbg_lock(); m_pFunctions->Append(function); function->InternalAddRef(); + dbg_unlock(); } void CordbProcess::AddModule(CordbModule* module) { + dbg_lock(); m_pModules->Append(module); module->InternalAddRef(); + dbg_unlock(); } void CordbProcess::AddAppDomain(CordbAppDomain* appDomain) { + dbg_lock(); m_pAddDomains->Append(appDomain); appDomain->InternalAddRef(); + dbg_unlock(); } void CordbProcess::AddPendingEval(CordbEval* eval) { + dbg_lock(); m_pPendingEval->Append(eval); eval->InternalAddRef(); + dbg_unlock(); } void CordbProcess::AddBreakpoint(CordbFunctionBreakpoint* bp) { + dbg_lock(); m_pBreakpoints->Append(bp); bp->InternalAddRef(); + dbg_unlock(); } void CordbProcess::AddStepper(CordbStepper* step) { + dbg_lock(); m_pSteppers->Append(step); step->InternalAddRef(); + dbg_unlock(); } CordbFunction* CordbProcess::FindFunction(int id) { + CordbFunction* ret = NULL; + dbg_lock(); for (DWORD i = 0; i < m_pFunctions->GetCount(); i++) { CordbFunction* function = (CordbFunction*)m_pFunctions->Get(i); if (function->GetDebuggerId() == id) { - return function; + ret = function; + break; } } - return NULL; + dbg_unlock(); + return ret; } CordbStepper* CordbProcess::GetStepper(int id) { + CordbStepper *ret = NULL; + dbg_lock(); for (DWORD i = 0; i < m_pSteppers->GetCount(); i++) { CordbStepper* stepper = (CordbStepper*)m_pSteppers->Get(i); if (stepper->GetDebuggerId() == id) { - return stepper; + ret = stepper; + break; } } - return NULL; + dbg_unlock(); + return ret; } CordbModule* CordbProcess::GetModule(int module_id) { + CordbModule* ret = NULL; + dbg_lock(); for (DWORD i = 0; i < m_pModules->GetCount(); i++) { CordbModule* module = (CordbModule*)m_pModules->Get(i); if (module->GetDebuggerId() == module_id) { - return module; + ret = module; + break; } } - return NULL; + dbg_unlock(); + return ret; } CordbAppDomain* CordbProcess::GetCurrentAppDomain() { + CordbAppDomain* ret = NULL; + dbg_lock(); if (m_pAddDomains->GetCount() > 0) - return (CordbAppDomain*)m_pAddDomains->Get(0); - return NULL; + ret = (CordbAppDomain*)m_pAddDomains->Get(0); + dbg_unlock(); + return ret; } CordbThread* CordbProcess::FindThread(long thread_id) { - DWORD i = 0; - while (i < m_pThreads->GetCount()) + CordbThread* ret = NULL; + dbg_lock(); + for (DWORD i = 0; i < m_pThreads->GetCount(); i++) { CordbThread* thread = (CordbThread*)m_pThreads->Get(i); if (thread->GetThreadId() == thread_id) { - return thread; + ret = thread; + break; } - i++; } - return NULL; + dbg_unlock(); + return ret; } CordbFunctionBreakpoint* CordbProcess::GetBreakpoint(int id) { + CordbFunctionBreakpoint* ret = NULL; + dbg_lock(); for (DWORD i = 0; i < m_pBreakpoints->GetCount(); i++) { CordbFunctionBreakpoint* bp = (CordbFunctionBreakpoint*)m_pBreakpoints->Get(i); if (bp->GetDebuggerId() == id) { - return bp; + ret = bp; + break; } } - return NULL; + dbg_unlock(); + return ret; } void CordbProcess::SetJMCStatus(BOOL bIsJustMyCode) From 02488125f6acb4baf692014baf5c84c278cece9c Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Thu, 4 Mar 2021 11:34:59 -0300 Subject: [PATCH 43/64] Using CORDB_ADDRESS to return addresses from debugged process --- src/mono/dbi/cordb-assembly.cpp | 9 +++-- src/mono/dbi/cordb-assembly.h | 2 +- src/mono/dbi/cordb-class.cpp | 6 +-- src/mono/dbi/cordb-process.cpp | 26 +++++++++++-- src/mono/dbi/cordb-value.cpp | 19 ++++------ src/mono/dbi/cordb-value.h | 7 ++-- src/mono/dbi/cordb.cpp | 5 +++ src/mono/mono/mini/debugger-agent.c | 51 ++++++++++++++++++++++++-- src/mono/mono/mini/debugger-protocol.h | 8 +++- src/mono/mono/mini/mini-amd64.c | 6 +++ src/mono/mono/mini/mini-arm.c | 6 +++ src/mono/mono/mini/mini-arm64.c | 6 +++ src/mono/mono/mini/mini-mips.c | 6 +++ src/mono/mono/mini/mini-ppc.c | 9 +++++ src/mono/mono/mini/mini-riscv.c | 6 +++ src/mono/mono/mini/mini-s390x.c | 6 +++ src/mono/mono/mini/mini-sparc.c | 7 ++++ src/mono/mono/mini/mini-wasm.c | 7 ++++ src/mono/mono/mini/mini-x86.c | 18 +++++++++ src/mono/mono/mini/mini.h | 1 + 20 files changed, 175 insertions(+), 36 deletions(-) diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index 9bbef0b7525151..fc9bc436bf09c8 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -115,8 +115,8 @@ CordbModule::~CordbModule() { if (m_pAssembly) m_pAssembly->InternalRelease(); - if (m_pPeImage) - free(m_pPeImage); + /*if (m_pPeImage) + free(m_pPeImage);*/ if (m_pAssemblyName) free(m_pAssemblyName); } @@ -221,14 +221,15 @@ HRESULT CordbModule::GetBaseAddress(CORDB_ADDRESS* pAddress) MdbgProtBuffer localbuf; m_dbgprot_buffer_init(&localbuf, 128); m_dbgprot_buffer_add_id(&localbuf, GetDebuggerId()); - int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_METADATA_BLOB, &localbuf); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_ASSEMBLY, MDBGPROT_CMD_ASSEMBLY_GET_PEIMAGE_ADDRESS, &localbuf); m_dbgprot_buffer_free(&localbuf); ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); CHECK_ERROR_RETURN_FALSE(received_reply_packet); MdbgProtBuffer* pReply = received_reply_packet->Buffer(); - m_pPeImage = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, &m_nPeImageSize); + m_pPeImage = m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); + m_nPeImageSize = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); } LOG((LF_CORDB, LL_INFO1000000, "CordbModule - GetBaseAddress - IMPLEMENTED\n")); *pAddress = (CORDB_ADDRESS)m_pPeImage; diff --git a/src/mono/dbi/cordb-assembly.h b/src/mono/dbi/cordb-assembly.h index e2b22e5bd7c906..b5397bbe60e569 100644 --- a/src/mono/dbi/cordb-assembly.h +++ b/src/mono/dbi/cordb-assembly.h @@ -22,7 +22,7 @@ class CordbModule : public CordbBaseMono, RegMeta* m_pRegMeta; CordbAssembly* m_pAssembly; CLiteWeightStgdbRW* m_pStgdbRW; - uint8_t* m_pPeImage; + CORDB_ADDRESS m_pPeImage; int32_t m_nPeImageSize; unsigned long dwFlags; char * m_pAssemblyName; diff --git a/src/mono/dbi/cordb-class.cpp b/src/mono/dbi/cordb-class.cpp index 0f08f17dc608b0..700ac210279ae1 100644 --- a/src/mono/dbi/cordb-class.cpp +++ b/src/mono/dbi/cordb-class.cpp @@ -48,11 +48,7 @@ HRESULT STDMETHODCALLTYPE CordbClass::GetStaticFieldValue(mdFieldDef field ICorDebugValue** ppValue) { LOG((LF_CORDB, LL_INFO100000, "CordbClass - GetStaticFieldValue - NOT IMPLEMENTED\n")); - CordbContent content_value; - content_value.booleanValue = 0; - CordbValue* value = new CordbValue(conn, ELEMENT_TYPE_BOOLEAN, content_value, 1); - value->QueryInterface(IID_ICorDebugValue, (void**)ppValue); - return S_OK; + return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CordbClass::QueryInterface(REFIID id, void** pInterface) diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index e2c525cc427440..cc2bcc7244a4d5 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -290,11 +290,29 @@ HRESULT CordbProcess::SetThreadContext(DWORD threadID, ULONG32 contextSize, BYTE HRESULT CordbProcess::ReadMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* read) { - memcpy(buffer, (void*)address, size); - if (read != NULL) - *read = size; LOG((LF_CORDB, LL_INFO1000000, "CordbProcess - ReadMemory - IMPLEMENTED\n")); - return S_OK; + HRESULT hr = S_OK; + EX_TRY + { + MdbgProtBuffer localbuf; + m_dbgprot_buffer_init(&localbuf, 128); + m_dbgprot_buffer_add_long(&localbuf, address); + m_dbgprot_buffer_add_int(&localbuf, size); + int cmdId = conn->SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_READ_MEMORY, &localbuf); + m_dbgprot_buffer_free(&localbuf); + + ReceivedReplyPacket* received_reply_packet = conn->GetReplyWithError(cmdId); + CHECK_ERROR_RETURN_FALSE(received_reply_packet); + MdbgProtBuffer* pReply = received_reply_packet->Buffer(); + int memoryReadSize = 0; + uint8_t* memoryRead = m_dbgprot_decode_byte_array(pReply->p, &pReply->p, pReply->end, (int32_t*)&memoryReadSize); + memcpy(buffer, (void*)memoryRead, memoryReadSize); + if (read != NULL) + *read = memoryReadSize; + free(memoryRead); + } + EX_CATCH_HRESULT(hr); + return hr; } HRESULT CordbProcess::WriteMemory(CORDB_ADDRESS address, DWORD size, BYTE buffer[], SIZE_T* written) diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index c74bab2db3945b..8a903bf8b21401 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -41,7 +41,7 @@ HRESULT STDMETHODCALLTYPE CordbValue::GetSize(ULONG32* pSize) HRESULT STDMETHODCALLTYPE CordbValue::GetAddress(CORDB_ADDRESS* pAddress) { - *pAddress = (CORDB_ADDRESS)&m_value; + *pAddress = (CORDB_ADDRESS)m_value.pointerValue; LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetAddress - IMPLEMENTED\n")); return S_OK; } @@ -130,7 +130,7 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetSize(ULONG32* pSize) HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetAddress(CORDB_ADDRESS* pAddress) { - *pAddress = (CORDB_ADDRESS)&m_debuggerId; + *pAddress = (CORDB_ADDRESS)m_pAddress; LOG((LF_CORDB, LL_INFO1000000, "CordbReferenceValue - GetAddress - IMPLEMENTED\n")); return S_OK; } @@ -358,8 +358,7 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::DereferenceStrong(ICorDebugValue* return E_NOTIMPL; } -CordbReferenceValue::CordbReferenceValue( - Connection* conn, CorElementType type, int object_id, CordbClass* klass, CordbType* cordbType) +CordbReferenceValue::CordbReferenceValue(Connection* conn, CorElementType type, int object_id, CordbClass* klass, CordbType* cordbType, CORDB_ADDRESS cordbAddress) : CordbBaseMono(conn) { this->m_type = type; @@ -367,6 +366,7 @@ CordbReferenceValue::CordbReferenceValue( this->conn = conn; this->m_pClass = klass; this->m_pCordbType = cordbType; + this->m_pAddress = cordbAddress; if (cordbType) cordbType->InternalAddRef(); if (klass) @@ -741,29 +741,24 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection* conn, MdbgProtBuffer* pRe case ELEMENT_TYPE_BOOLEAN: case ELEMENT_TYPE_I1: case ELEMENT_TYPE_U1: - value.booleanValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; case ELEMENT_TYPE_CHAR: case ELEMENT_TYPE_I2: case ELEMENT_TYPE_U2: - value.charValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: case ELEMENT_TYPE_R4: - value.intValue = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: case ELEMENT_TYPE_R8: - value.longValue = m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); + value.pointerValue = m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); break; case ELEMENT_TYPE_CLASS: case ELEMENT_TYPE_SZARRAY: case ELEMENT_TYPE_STRING: { int object_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); - CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, object_id); + CORDB_ADDRESS address = m_dbgprot_decode_long(pReply->p, &pReply->p, pReply->end); + CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, object_id, NULL, NULL, address); refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); goto __Exit; } diff --git a/src/mono/dbi/cordb-value.h b/src/mono/dbi/cordb-value.h index 8d964605d73924..8be392498948f0 100644 --- a/src/mono/dbi/cordb-value.h +++ b/src/mono/dbi/cordb-value.h @@ -16,7 +16,7 @@ union CordbContent int8_t booleanValue; int32_t intValue; int64_t longValue; - void* pointerValue; + CORDB_ADDRESS pointerValue; }; class CordbValue : public CordbBaseMono, public ICorDebugValue2, public ICorDebugValue3, public ICorDebugGenericValue @@ -63,10 +63,9 @@ class CordbReferenceValue : public CordbBaseMono, int m_debuggerId; CordbClass* m_pClass; CordbType* m_pCordbType; - + CORDB_ADDRESS m_pAddress; public: - CordbReferenceValue( - Connection* conn, CorElementType type, int object_id, CordbClass* klass = NULL, CordbType* cordbType = NULL); + CordbReferenceValue(Connection* conn, CorElementType type, int object_id, CordbClass* klass = NULL, CordbType* cordbType = NULL, CORDB_ADDRESS cordbAddress = NULL); ULONG STDMETHODCALLTYPE AddRef(void) { return (BaseAddRef()); diff --git a/src/mono/dbi/cordb.cpp b/src/mono/dbi/cordb.cpp index 96866ecd7e8c26..0c1517900fabd9 100644 --- a/src/mono/dbi/cordb.cpp +++ b/src/mono/dbi/cordb.cpp @@ -465,6 +465,11 @@ void Connection::LoopSendReceive() LOG((LF_CORDB, LL_INFO100000, "Protocol version %d.%d, server protocol version %d.%d.\n", MAJOR_VERSION, MINOR_VERSION, major_version, minor_version)); free(vm_version); + + m_dbgprot_buffer_init(&localbuf, 128); + SendEvent(MDBGPROT_CMD_SET_VM, MDBGPROT_CMD_VM_SET_USING_ICORDBG, &localbuf); + m_dbgprot_buffer_free(&localbuf); + int iResult = 0; // Receive until the peer closes the connection do diff --git a/src/mono/mono/mini/debugger-agent.c b/src/mono/mono/mini/debugger-agent.c index 5129d6589c4cfc..f651cfe1547d39 100644 --- a/src/mono/mono/mini/debugger-agent.c +++ b/src/mono/mono/mini/debugger-agent.c @@ -135,6 +135,7 @@ typedef struct { gboolean defer; int keepalive; gboolean setpgid; + gboolean using_icordbg; } AgentConfig; typedef struct _InvokeData InvokeData; @@ -4962,6 +4963,28 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, buffer_add_fixed_array(buf, t, addr, domain, as_vtype, parent_vtypes, len_fixed_array); return; } + + if (agent_config.using_icordbg) { + switch (t->type) { + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_I1: + case MONO_TYPE_U1: + case MONO_TYPE_CHAR: + case MONO_TYPE_I2: + case MONO_TYPE_U2: + case MONO_TYPE_I4: + case MONO_TYPE_U4: + case MONO_TYPE_R4: + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_R8: + case MONO_TYPE_PTR: + buffer_add_byte (buf, t->type); + buffer_add_long (buf, (uint64_t) addr); + return; + } + } + switch (t->type) { case MONO_TYPE_VOID: buffer_add_byte (buf, t->type); @@ -5031,6 +5054,8 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, buffer_add_byte (buf, m_class_get_byval_arg (obj->vtable->klass)->type); } buffer_add_objid (buf, obj); + if (agent_config.using_icordbg) + buffer_add_long (buf, (gssize) addr); } break; handle_vtype: @@ -5468,16 +5493,14 @@ add_var (Buffer *buf, MonoDebugMethodJitInfo *jit, MonoType *t, MonoDebugVarInfo guint32 flags; int reg; guint8 *addr, *gaddr; - host_mgreg_t reg_val; flags = var->index & MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS; reg = var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS; switch (flags) { case MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER: - reg_val = mono_arch_context_get_int_reg (ctx, reg); - - buffer_add_value_full (buf, t, ®_val, domain, as_vtype, NULL, 1); + addr = (guint8 *)mono_arch_context_get_int_reg_address (ctx, reg); + buffer_add_value_full (buf, t, addr, domain, as_vtype, NULL, 1); break; case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET: addr = (guint8 *)mono_arch_context_get_int_reg (ctx, reg); @@ -6847,6 +6870,16 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) case CMD_VM_STOP_BUFFERING: /* Handled in the main loop */ break; + case MDBGPROT_CMD_VM_READ_MEMORY: { + guint8* memory = (guint8*) decode_long (p, &p, end); + int size = decode_int (p, &p, end); + buffer_add_byte_array (buf, memory, size); + break; + } + case MDBGPROT_CMD_VM_SET_USING_ICORDBG: { + agent_config.using_icordbg = TRUE; + break; + } default: return ERR_NOT_IMPLEMENTED; } @@ -7455,6 +7488,15 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return err; break; } + case MDBGPROT_CMD_ASSEMBLY_GET_PEIMAGE_ADDRESS: { + MonoImage* image = ass->image; + if (ass->dynamic) { + return ERR_NOT_IMPLEMENTED; + } + buffer_add_long (buf, (guint64)(gsize)image->raw_data); + buffer_add_int (buf, image->raw_data_len); + break; + } default: return ERR_NOT_IMPLEMENTED; } @@ -9473,6 +9515,7 @@ static const char* assembly_cmds_str[] = { "GET_METHOD_FROM_TOKEN", "HAS_DEBUG_INFO", "GET_CUSTOM_ATTRIBUTES", + "GET_PEIMAGE_ADDRESS" }; static const char* module_cmds_str[] = { diff --git a/src/mono/mono/mini/debugger-protocol.h b/src/mono/mono/mini/debugger-protocol.h index c726ca494d3bbb..c3021c333c861c 100644 --- a/src/mono/mono/mini/debugger-protocol.h +++ b/src/mono/mono/mini/debugger-protocol.h @@ -32,7 +32,10 @@ typedef enum { MDBGPROT_CMD_VM_GET_TYPES = 12, MDBGPROT_CMD_VM_INVOKE_METHODS = 13, MDBGPROT_CMD_VM_START_BUFFERING = 14, - MDBGPROT_CMD_VM_STOP_BUFFERING = 15 + MDBGPROT_CMD_VM_STOP_BUFFERING = 15, + MDBGPROT_CMD_VM_READ_MEMORY = 16, + MDBGPROT_CMD_VM_WRITE_MEMORY = 17, + MDBGPROT_CMD_VM_SET_USING_ICORDBG = 18 } MdbgProtCmdVM; typedef enum { @@ -139,7 +142,8 @@ typedef enum { MDBGPROT_CMD_ASSEMBLY_GET_METHOD_FROM_TOKEN = 12, MDBGPROT_CMD_ASSEMBLY_HAS_DEBUG_INFO = 13, MDBGPROT_CMD_ASSEMBLY_GET_CATTRS = 14, - MDBGPROT_CMD_ASSEMBLY_GET_CUSTOM_ATTRIBUTES = 15 + MDBGPROT_CMD_ASSEMBLY_GET_CUSTOM_ATTRIBUTES = 15, + MDBGPROT_CMD_ASSEMBLY_GET_PEIMAGE_ADDRESS = 16, } MdbgProtCmdAssembly; typedef enum { diff --git a/src/mono/mono/mini/mini-amd64.c b/src/mono/mono/mini/mini-amd64.c index b9fc116f4d45e2..7c9cec3b0a5061 100644 --- a/src/mono/mono/mini/mini-amd64.c +++ b/src/mono/mono/mini/mini-amd64.c @@ -8886,6 +8886,12 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) return ctx->gregs [reg]; } +host_mgreg_t * +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + return &ctx->gregs [reg]; +} + void mono_arch_context_set_int_reg (MonoContext *ctx, int reg, host_mgreg_t val) { diff --git a/src/mono/mono/mini/mini-arm.c b/src/mono/mono/mini/mini-arm.c index e6cadc81c4c8d6..5a59bc5df5a048 100644 --- a/src/mono/mono/mini/mini-arm.c +++ b/src/mono/mono/mini/mini-arm.c @@ -7168,6 +7168,12 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) return ctx->regs [reg]; } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + return &ctx->regs [reg]; +} + void mono_arch_context_set_int_reg (MonoContext *ctx, int reg, host_mgreg_t val) { diff --git a/src/mono/mono/mini/mini-arm64.c b/src/mono/mono/mini/mini-arm64.c index 1958a9d41c5f6a..2623b9b60ac5e4 100644 --- a/src/mono/mono/mini/mini-arm64.c +++ b/src/mono/mono/mini/mini-arm64.c @@ -1058,6 +1058,12 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) return ctx->regs [reg]; } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + return &ctx->regs [reg]; +} + void mono_arch_context_set_int_reg (MonoContext *ctx, int reg, host_mgreg_t val) { diff --git a/src/mono/mono/mini/mini-mips.c b/src/mono/mono/mini/mini-mips.c index c8e24dff5b8851..ef71a820491449 100644 --- a/src/mono/mono/mini/mini-mips.c +++ b/src/mono/mono/mini/mini-mips.c @@ -5276,6 +5276,12 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) return ctx->sc_regs [reg]; } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + return &ctx->sc_regs [reg]; +} + #define ENABLE_WRONG_METHOD_CHECK 0 #define MIPS_LOAD_SEQUENCE_LENGTH 8 diff --git a/src/mono/mono/mini/mini-ppc.c b/src/mono/mono/mini/mini-ppc.c index ee43f5b7c4641b..d87a9b7d6de750 100644 --- a/src/mono/mono/mini/mini-ppc.c +++ b/src/mono/mono/mini/mini-ppc.c @@ -5755,6 +5755,15 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) return ctx->regs [reg]; } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + if (reg == ppc_r1) + return (host_mgreg_t)(gsize)&MONO_CONTEXT_GET_SP (ctx); + + return &ctx->regs [reg]; +} + guint32 mono_arch_get_patch_offset (guint8 *code) { diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 39648e08e6f418..44eef239da88f2 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -248,6 +248,12 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) return ctx->gregs [reg]; } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + return &ctx->gregs [reg]; +} + void mono_arch_context_set_int_reg (MonoContext *ctx, int reg, host_mgreg_t val) { diff --git a/src/mono/mono/mini/mini-s390x.c b/src/mono/mono/mini/mini-s390x.c index a6bbd3ce983f4b..7e147f48e975d6 100644 --- a/src/mono/mono/mini/mini-s390x.c +++ b/src/mono/mono/mini/mini-s390x.c @@ -6182,6 +6182,12 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) return ctx->uc_mcontext.gregs[reg]; } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + return &ctx->uc_mcontext.gregs[reg]; +} + /*========================= End of Function ========================*/ /** diff --git a/src/mono/mono/mini/mini-sparc.c b/src/mono/mono/mini/mini-sparc.c index decdcbc09cf653..448f150c5505b8 100644 --- a/src/mono/mono/mini/mini-sparc.c +++ b/src/mono/mono/mini/mini-sparc.c @@ -4386,6 +4386,13 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) g_assert_not_reached (); } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + /* FIXME: implement */ + g_assert_not_reached (); +} + gboolean mono_arch_opcode_supported (int opcode) { diff --git a/src/mono/mono/mini/mini-wasm.c b/src/mono/mono/mini/mini-wasm.c index 05d0b82e271f1b..1c79a44f5d9ad3 100644 --- a/src/mono/mono/mini/mini-wasm.c +++ b/src/mono/mono/mini/mini-wasm.c @@ -487,6 +487,13 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) return 0; } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + g_error ("mono_arch_context_get_int_reg_address"); + return 0; +} + #ifdef HOST_WASM void diff --git a/src/mono/mono/mini/mini-x86.c b/src/mono/mono/mini/mini-x86.c index e083d2cb62ca4e..84ad369977ec6c 100644 --- a/src/mono/mono/mini/mini-x86.c +++ b/src/mono/mono/mini/mini-x86.c @@ -6075,6 +6075,24 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg) } } +host_mgreg_t* +mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) +{ + switch (reg) { + case X86_EAX: return &ctx->eax; + case X86_EBX: return &ctx->ebx; + case X86_ECX: return &ctx->ecx; + case X86_EDX: return &ctx->edx; + case X86_ESP: return &ctx->esp; + case X86_EBP: return &ctx->ebp; + case X86_ESI: return &ctx->esi; + case X86_EDI: return &ctx->edi; + default: + g_assert_not_reached (); + return 0; + } +} + void mono_arch_context_set_int_reg (MonoContext *ctx, int reg, host_mgreg_t val) { diff --git a/src/mono/mono/mini/mini.h b/src/mono/mono/mini/mini.h index f30fdae9e60616..7252ea7e9d0abb 100644 --- a/src/mono/mono/mini/mini.h +++ b/src/mono/mono/mini/mini.h @@ -2447,6 +2447,7 @@ void mono_arch_undo_ip_adjustment (MonoContext *ctx); void mono_arch_do_ip_adjustment (MonoContext *ctx); gpointer mono_arch_ip_from_context (void *sigctx); host_mgreg_t mono_arch_context_get_int_reg (MonoContext *ctx, int reg); +host_mgreg_t*mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg); void mono_arch_context_set_int_reg (MonoContext *ctx, int reg, host_mgreg_t val); void mono_arch_flush_register_windows (void); gboolean mono_arch_is_inst_imm (int opcode, int imm_opcode, gint64 imm); From 10389fdb8817b68916251464c0b13d6509ef1db0 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Thu, 4 Mar 2021 12:35:40 -0300 Subject: [PATCH 44/64] Fix eval --- src/mono/dbi/cordb-eval.cpp | 2 +- src/mono/dbi/cordb-value.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/dbi/cordb-eval.cpp b/src/mono/dbi/cordb-eval.cpp index cd3ca87645afa8..a09628c5e9ba48 100644 --- a/src/mono/dbi/cordb-eval.cpp +++ b/src/mono/dbi/cordb-eval.cpp @@ -52,7 +52,7 @@ HRESULT STDMETHODCALLTYPE CordbEval::CallParameterizedFunction(ICorDebugFunction CorElementType ty; ppArgs[i]->GetType(&ty); CordbContent* cc; - ppArgs[i]->GetAddress((CORDB_ADDRESS*)&cc); + cc = ((CordbValue*)ppArgs[i])->GetValue(); m_dbgprot_buffer_add_byte(&localbuf, ty); switch (ty) { diff --git a/src/mono/dbi/cordb-value.h b/src/mono/dbi/cordb-value.h index 8be392498948f0..e31573c8d6e2a5 100644 --- a/src/mono/dbi/cordb-value.h +++ b/src/mono/dbi/cordb-value.h @@ -51,6 +51,7 @@ class CordbValue : public CordbBaseMono, public ICorDebugValue2, public ICorDebu HRESULT STDMETHODCALLTYPE GetSize64(ULONG64* pSize); HRESULT STDMETHODCALLTYPE GetValue(void* pTo); HRESULT STDMETHODCALLTYPE SetValue(void* pFrom); + CordbContent* GetValue() {return &m_value;} }; class CordbReferenceValue : public CordbBaseMono, From 3ebfdd8d24c2ae608ba1883ef33de7bea6bfc082 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Thu, 4 Mar 2021 14:01:34 -0300 Subject: [PATCH 45/64] Update src/mono/mono/mini/debugger-agent.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aleksey Kliger (λgeek) --- src/mono/mono/mini/debugger-agent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/debugger-agent.c b/src/mono/mono/mini/debugger-agent.c index f651cfe1547d39..f3322f5b179b70 100644 --- a/src/mono/mono/mini/debugger-agent.c +++ b/src/mono/mono/mini/debugger-agent.c @@ -4980,7 +4980,7 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, case MONO_TYPE_R8: case MONO_TYPE_PTR: buffer_add_byte (buf, t->type); - buffer_add_long (buf, (uint64_t) addr); + buffer_add_long (buf, (gssize) addr); return; } } From c5b4d4cc0b2ff4547e80fd9e61e48f67242b3df8 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Fri, 5 Mar 2021 16:27:39 -0300 Subject: [PATCH 46/64] Using 1:1 with runtime for cordbtype and cordbclass --- src/mono/dbi/cordb-assembly.cpp | 2 +- src/mono/dbi/cordb-class.cpp | 4 +- src/mono/dbi/cordb-class.h | 2 +- src/mono/dbi/cordb-process.cpp | 96 ++++++++++++++++++++++++++++++++- src/mono/dbi/cordb-process.h | 9 ++++ src/mono/dbi/cordb-value.cpp | 23 ++++---- src/mono/dbi/cordb.h | 8 +++ 7 files changed, 128 insertions(+), 16 deletions(-) diff --git a/src/mono/dbi/cordb-assembly.cpp b/src/mono/dbi/cordb-assembly.cpp index fc9bc436bf09c8..95add50bb3b479 100644 --- a/src/mono/dbi/cordb-assembly.cpp +++ b/src/mono/dbi/cordb-assembly.cpp @@ -322,7 +322,7 @@ HRESULT CordbModule::GetFunctionFromRVA(CORDB_ADDRESS rva, ICorDebugFunction** p HRESULT CordbModule::GetClassFromToken(mdTypeDef typeDef, ICorDebugClass** ppClass) { - CordbClass* pClass = new CordbClass(conn, typeDef, GetDebuggerId()); + CordbClass* pClass = conn->GetProcess()->FindOrAddClass(typeDef, GetDebuggerId()); pClass->QueryInterface(IID_ICorDebugClass, (void**)ppClass); return S_OK; } diff --git a/src/mono/dbi/cordb-class.cpp b/src/mono/dbi/cordb-class.cpp index 700ac210279ae1..61574859c11b87 100644 --- a/src/mono/dbi/cordb-class.cpp +++ b/src/mono/dbi/cordb-class.cpp @@ -17,7 +17,7 @@ using namespace std; CordbClass::CordbClass(Connection* conn, mdToken token, int module_id) : CordbBaseMono(conn) { this->m_metadataToken = token; - this->m_debuggerId = module_id; + this->m_debuggerModuleId = module_id; } HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule** pModule) @@ -25,7 +25,7 @@ HRESULT STDMETHODCALLTYPE CordbClass::GetModule(ICorDebugModule** pModule) LOG((LF_CORDB, LL_INFO1000000, "CordbClass - GetModule - IMPLEMENTED\n")); if (pModule) { - CordbModule* module = conn->GetProcess()->GetModule(m_debuggerId); + CordbModule* module = conn->GetProcess()->GetModule(m_debuggerModuleId); if (module) { *pModule = static_cast(module); diff --git a/src/mono/dbi/cordb-class.h b/src/mono/dbi/cordb-class.h index 041fc11c6b11e0..d02daf05dabd5a 100644 --- a/src/mono/dbi/cordb-class.h +++ b/src/mono/dbi/cordb-class.h @@ -12,7 +12,7 @@ class CordbClass : public CordbBaseMono, public ICorDebugClass, public ICorDebugClass2 { mdToken m_metadataToken; - int m_debuggerId; + int m_debuggerModuleId; public: CordbClass(Connection* conn, mdToken token, int module_id); diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index cc2bcc7244a4d5..1cb8965cb91348 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -7,12 +7,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include using namespace std; @@ -29,7 +31,12 @@ CordbProcess::CordbProcess(Cordb* cordb) : CordbBaseMono(NULL) m_pSteppers = new ArrayList(); this->m_pCordb = cordb; m_bIsJustMyCode = false; - m_pSemReadWrite = new UTSemReadWrite(); + m_pSemReadWrite = new UTSemReadWrite(); + m_pTypeMapArray = new ArrayList(); + for (DWORD i = 0; i < CordbTypeKindTotal; i++) + { + m_pTypeMapArray->Append(new MapSHashWithRemove()); + } } CordbProcess::~CordbProcess() @@ -83,12 +90,29 @@ CordbProcess::~CordbProcess() eval->InternalRelease(); } + for (MapSHashWithRemove::Iterator iter = m_classMap.Begin(), end = m_classMap.End(); iter != end; iter++) + { + iter->Value()->InternalRelease(); + } + + + for (DWORD i = 0; i < m_pTypeMapArray->GetCount(); i++) + { + MapSHashWithRemove* typeMap = (MapSHashWithRemove*)m_pTypeMapArray->Get(i); + for (MapSHashWithRemove::Iterator iter = typeMap->Begin(), end = typeMap->End(); iter != end; iter++) + { + if (iter->Value()) + iter->Value()->InternalRelease(); + } + } + delete m_pBreakpoints; delete m_pThreads; delete m_pFunctions; delete m_pModules; delete m_pAddDomains; delete m_pPendingEval; + delete m_pTypeMapArray; delete conn; } @@ -608,6 +632,76 @@ void CordbProcess::AddStepper(CordbStepper* step) dbg_unlock(); } +CordbClass* CordbProcess::FindOrAddClass(mdToken token, int module_id) +{ + CordbClass *ret = NULL; + dbg_lock(); + if (!m_classMap.Lookup(token, &ret)) { + ret = new CordbClass(conn, token, module_id); + m_classMap.Add(token, ret); + ret->InternalAddRef(); + } + dbg_unlock(); + return ret; +} + +CordbType* CordbProcess::FindOrAddType(CorElementType type) +{ + CordbType* ret = NULL; + MapSHashWithRemove* typeMap = (MapSHashWithRemove*) m_pTypeMapArray->Get(CordbTypeKindSimpleType); + dbg_lock(); + if (!typeMap->Lookup(type, &ret)) { + ret = new CordbType(type, conn); + typeMap->Add(type, ret); + ret->InternalAddRef(); + } + dbg_unlock(); + return ret; +} + +CordbType* CordbProcess::FindOrAddType(CorElementType type, CordbClass *klass) +{ + CordbType* ret = NULL; + mdToken token; + if (klass == NULL) + return FindOrAddType(type); + MapSHashWithRemove* typeMap = (MapSHashWithRemove*) m_pTypeMapArray->Get(CordbTypeKindClassType); + dbg_lock(); + klass->GetToken(&token); + if (!typeMap->Lookup(token, &ret)) { + ret = new CordbType(type, conn, klass); + typeMap->Add(token, ret); + ret->InternalAddRef(); + } + dbg_unlock(); + return ret; +} + +CordbType* CordbProcess::FindOrAddType(CorElementType type, CordbType* arrayType) +{ + CordbType* ret = NULL; + long hash = 0; + MapSHashWithRemove* typeMap = (MapSHashWithRemove*) m_pTypeMapArray->Get(CordbTypeKindArrayType); + dbg_lock(); + CorElementType eleType; + ICorDebugClass *eleClass = 0; + mdTypeDef eleToken = 0; + arrayType->GetType(&eleType); + if (eleType == ELEMENT_TYPE_CLASS) + { + arrayType->GetClass(&eleClass); + eleClass->GetToken(&eleToken); + } + hash = (long)(pow(2, eleToken & 0xffffff) * pow(3, type) * pow(5, eleType)); //TODO: define a better hash + if (!typeMap->Lookup(hash, &ret)) { + ret = new CordbType(type, conn, NULL, arrayType); + typeMap->Add(hash, ret); + ret->InternalAddRef(); + } + dbg_unlock(); + return ret; +} + CordbFunction* CordbProcess::FindFunction(int id) { CordbFunction* ret = NULL; diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index 0eb8a10338e332..3128364d877dce 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -8,8 +8,11 @@ #define __MONO_DEBUGGER_CORDB_PROCESS_H__ #include +#include #include + + class CordbProcess : public CordbBaseMono, public ICorDebugProcess, public ICorDebugProcess2, @@ -30,6 +33,8 @@ class CordbProcess : public CordbBaseMono, CordbAppDomainEnum* m_pAppDomainEnum; Cordb* m_pCordb; BOOL m_bIsJustMyCode; + ArrayList* m_pTypeMapArray; //TODO: define a better data structure to find CordbType + MapSHashWithRemove m_classMap; public: ArrayList* m_pAddDomains; CordbProcess(Cordb* cordb); @@ -119,6 +124,10 @@ class CordbProcess : public CordbBaseMono, void AddBreakpoint(CordbFunctionBreakpoint* bp); void AddPendingEval(CordbEval* eval); void AddStepper(CordbStepper* step); + CordbClass* FindOrAddClass(mdToken token, int module_id); + CordbType* FindOrAddType(CorElementType type); + CordbType* FindOrAddType(CorElementType type, CordbClass *klass); //use variadic ??? + CordbType* FindOrAddType(CorElementType type, CordbType* arrayType); //use variadic ??? CordbFunction* FindFunction(int id); CordbModule* GetModule(int module_id); CordbStepper* GetStepper(int id); diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index 8a903bf8b21401..8ce2cc638abb3b 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include using namespace std; @@ -88,7 +89,7 @@ HRESULT STDMETHODCALLTYPE CordbValue::GetExactType(ICorDebugType** ppType) LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetExactType - IMPLEMENTED\n")); if (m_pType == NULL) { - m_pType = new CordbType(m_type, conn); + m_pType = conn->GetProcess()->FindOrAddType(m_type); m_pType->InternalAddRef(); } m_pType->QueryInterface(IID_ICorDebugType, (void**)ppType); @@ -185,7 +186,7 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppTy } if (m_pClass != NULL) { - m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType = conn->GetProcess()->FindOrAddType(m_type, m_pClass); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); goto __Exit; @@ -223,9 +224,9 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppTy type_id = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_pClass = new CordbClass(conn, token, assembly_id); + m_pClass = conn->GetProcess()->FindOrAddClass(token, module_id); m_pClass->InternalAddRef(); - m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType = conn->GetProcess()->FindOrAddType(m_type, m_pClass); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); free(namespace_str); @@ -271,19 +272,19 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppTy int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - m_pClass = new CordbClass(conn, token, module_id); + m_pClass = conn->GetProcess()->FindOrAddClass(token, module_id); m_pClass->InternalAddRef(); free(namespace_str); free(class_name_str); free(class_fullname_str); } - m_pCordbType = new CordbType(m_type, conn, NULL, new CordbType((CorElementType)type_id, conn, m_pClass)); + m_pCordbType = conn->GetProcess()->FindOrAddType(m_type, conn->GetProcess()->FindOrAddType((CorElementType)type_id, m_pClass)); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); goto __Exit; } - m_pCordbType = new CordbType(m_type, conn); + m_pCordbType = conn->GetProcess()->FindOrAddType(m_type); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); } @@ -432,7 +433,7 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetExactType(ICorDebugType** ppType) LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetExactType - IMPLEMENTED\n")); if (m_pCordbType == NULL) { - m_pCordbType = new CordbType(m_type, conn, m_pClass); + m_pCordbType = conn->GetProcess()->FindOrAddType(m_type, m_pClass); m_pCordbType->InternalAddRef(); } m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); @@ -693,7 +694,7 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection* conn, MdbgProtBuffer* pRe int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - CordbClass* klass = new CordbClass(conn, token, module_id); + CordbClass* klass = conn->GetProcess()->FindOrAddClass(token, module_id); CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass); refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); free(namespace_str); @@ -724,12 +725,12 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection* conn, MdbgProtBuffer* pRe int type_id3 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int type_id2 = m_dbgprot_decode_id(pReply->p, &pReply->p, pReply->end); int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); - klass = new CordbClass(conn, token, module_id); + klass = conn->GetProcess()->FindOrAddClass(token, module_id); free(namespace_str); free(class_name_str); free(class_fullname_str); } - CordbType* cordbtype = new CordbType(type, conn, NULL, new CordbType((CorElementType)type_id, conn, klass)); + CordbType* cordbtype = conn->GetProcess()->FindOrAddType(type, conn->GetProcess()->FindOrAddType((CorElementType)type_id, klass)); CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass, cordbtype); refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); } diff --git a/src/mono/dbi/cordb.h b/src/mono/dbi/cordb.h index 018b82e9582097..2bb47cbe7c312c 100644 --- a/src/mono/dbi/cordb.h +++ b/src/mono/dbi/cordb.h @@ -62,6 +62,14 @@ class CordbTypeEnum; class CordbBlockingObjectEnum; class CordbFunctionBreakpoint; class CordbEval; +class CordbType; + +enum CordbTypeKind { + CordbTypeKindSimpleType, + CordbTypeKindClassType, + CordbTypeKindArrayType, + CordbTypeKindTotal +}; class ReceivedReplyPacket { From 02349c376e7e027a2011756ad1f7a8c985a055e6 Mon Sep 17 00:00:00 2001 From: "SOUTHAMERICA\\thtaglia" Date: Fri, 5 Mar 2021 18:05:15 -0300 Subject: [PATCH 47/64] Rnaming methods as suggested by @lambdageek --- src/mono/dbi/cordb-process.cpp | 8 ++++---- src/mono/dbi/cordb-process.h | 7 ++++--- src/mono/dbi/cordb-value.cpp | 14 +++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/mono/dbi/cordb-process.cpp b/src/mono/dbi/cordb-process.cpp index 1cb8965cb91348..422fd02495fc0c 100644 --- a/src/mono/dbi/cordb-process.cpp +++ b/src/mono/dbi/cordb-process.cpp @@ -645,7 +645,7 @@ CordbClass* CordbProcess::FindOrAddClass(mdToken token, int module_id) return ret; } -CordbType* CordbProcess::FindOrAddType(CorElementType type) +CordbType* CordbProcess::FindOrAddPrimitiveType(CorElementType type) { CordbType* ret = NULL; MapSHashWithRemove* typeMap = (MapSHashWithRemove*) m_pTypeMapArray->Get(CordbTypeKindSimpleType); @@ -659,12 +659,12 @@ CordbType* CordbProcess::FindOrAddType(CorElementType type) return ret; } -CordbType* CordbProcess::FindOrAddType(CorElementType type, CordbClass *klass) +CordbType* CordbProcess::FindOrAddClassType(CorElementType type, CordbClass *klass) { CordbType* ret = NULL; mdToken token; if (klass == NULL) - return FindOrAddType(type); + return FindOrAddPrimitiveType(type); MapSHashWithRemove* typeMap = (MapSHashWithRemove*) m_pTypeMapArray->Get(CordbTypeKindClassType); dbg_lock(); klass->GetToken(&token); @@ -677,7 +677,7 @@ CordbType* CordbProcess::FindOrAddType(CorElementType type, CordbClass *klass) return ret; } -CordbType* CordbProcess::FindOrAddType(CorElementType type, CordbType* arrayType) +CordbType* CordbProcess::FindOrAddArrayType(CorElementType type, CordbType* arrayType) { CordbType* ret = NULL; long hash = 0; diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index 3128364d877dce..903189f57123dc 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -125,9 +125,10 @@ class CordbProcess : public CordbBaseMono, void AddPendingEval(CordbEval* eval); void AddStepper(CordbStepper* step); CordbClass* FindOrAddClass(mdToken token, int module_id); - CordbType* FindOrAddType(CorElementType type); - CordbType* FindOrAddType(CorElementType type, CordbClass *klass); //use variadic ??? - CordbType* FindOrAddType(CorElementType type, CordbType* arrayType); //use variadic ??? + CordbType* FindOrAddPrimitiveType(CorElementType type); + CordbType* FindOrAddClassType(CorElementType type, CordbClass *klass); + CordbType* FindOrAddArrayType(CorElementType type, CordbType* arrayType); + //CordbType* FindOrAddGenericInstanceType(CorElementType type, std::initializer_list arrayType); //use std::initializer_list for generic instances CordbFunction* FindFunction(int id); CordbModule* GetModule(int module_id); CordbStepper* GetStepper(int id); diff --git a/src/mono/dbi/cordb-value.cpp b/src/mono/dbi/cordb-value.cpp index 8ce2cc638abb3b..55943e53d1c712 100644 --- a/src/mono/dbi/cordb-value.cpp +++ b/src/mono/dbi/cordb-value.cpp @@ -89,7 +89,7 @@ HRESULT STDMETHODCALLTYPE CordbValue::GetExactType(ICorDebugType** ppType) LOG((LF_CORDB, LL_INFO1000000, "CordbValue - GetExactType - IMPLEMENTED\n")); if (m_pType == NULL) { - m_pType = conn->GetProcess()->FindOrAddType(m_type); + m_pType = conn->GetProcess()->FindOrAddPrimitiveType(m_type); m_pType->InternalAddRef(); } m_pType->QueryInterface(IID_ICorDebugType, (void**)ppType); @@ -186,7 +186,7 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppTy } if (m_pClass != NULL) { - m_pCordbType = conn->GetProcess()->FindOrAddType(m_type, m_pClass); + m_pCordbType = conn->GetProcess()->FindOrAddClassType(m_type, m_pClass); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); goto __Exit; @@ -226,7 +226,7 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppTy int token = m_dbgprot_decode_int(pReply->p, &pReply->p, pReply->end); m_pClass = conn->GetProcess()->FindOrAddClass(token, module_id); m_pClass->InternalAddRef(); - m_pCordbType = conn->GetProcess()->FindOrAddType(m_type, m_pClass); + m_pCordbType = conn->GetProcess()->FindOrAddClassType(m_type, m_pClass); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); free(namespace_str); @@ -279,12 +279,12 @@ HRESULT STDMETHODCALLTYPE CordbReferenceValue::GetExactType(ICorDebugType** ppTy free(class_fullname_str); } - m_pCordbType = conn->GetProcess()->FindOrAddType(m_type, conn->GetProcess()->FindOrAddType((CorElementType)type_id, m_pClass)); + m_pCordbType = conn->GetProcess()->FindOrAddArrayType(m_type, conn->GetProcess()->FindOrAddClassType((CorElementType)type_id, m_pClass)); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); goto __Exit; } - m_pCordbType = conn->GetProcess()->FindOrAddType(m_type); + m_pCordbType = conn->GetProcess()->FindOrAddPrimitiveType(m_type); m_pCordbType->InternalAddRef(); m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); } @@ -433,7 +433,7 @@ HRESULT STDMETHODCALLTYPE CordbObjectValue::GetExactType(ICorDebugType** ppType) LOG((LF_CORDB, LL_INFO1000000, "CordbObjectValue - GetExactType - IMPLEMENTED\n")); if (m_pCordbType == NULL) { - m_pCordbType = conn->GetProcess()->FindOrAddType(m_type, m_pClass); + m_pCordbType = conn->GetProcess()->FindOrAddClassType(m_type, m_pClass); m_pCordbType->InternalAddRef(); } m_pCordbType->QueryInterface(IID_ICorDebugType, (void**)ppType); @@ -730,7 +730,7 @@ HRESULT CordbObjectValue::CreateCordbValue(Connection* conn, MdbgProtBuffer* pRe free(class_name_str); free(class_fullname_str); } - CordbType* cordbtype = conn->GetProcess()->FindOrAddType(type, conn->GetProcess()->FindOrAddType((CorElementType)type_id, klass)); + CordbType* cordbtype = conn->GetProcess()->FindOrAddArrayType(type, conn->GetProcess()->FindOrAddClassType((CorElementType)type_id, klass)); CordbReferenceValue* refValue = new CordbReferenceValue(conn, type, -1, klass, cordbtype); refValue->QueryInterface(IID_ICorDebugValue, (void**)ppValue); } From c02a256714767283fe84f966549aaa984f585066 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 8 Mar 2021 14:16:50 -0300 Subject: [PATCH 48/64] Update src/mono/dbi/cordb-process.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aleksey Kliger (λgeek) --- src/mono/dbi/cordb-process.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/dbi/cordb-process.h b/src/mono/dbi/cordb-process.h index 903189f57123dc..8506c2097c92f6 100644 --- a/src/mono/dbi/cordb-process.h +++ b/src/mono/dbi/cordb-process.h @@ -127,7 +127,7 @@ class CordbProcess : public CordbBaseMono, CordbClass* FindOrAddClass(mdToken token, int module_id); CordbType* FindOrAddPrimitiveType(CorElementType type); CordbType* FindOrAddClassType(CorElementType type, CordbClass *klass); - CordbType* FindOrAddArrayType(CorElementType type, CordbType* arrayType); + CordbType* FindOrAddArrayType(CorElementType type, CordbType* elementType); //CordbType* FindOrAddGenericInstanceType(CorElementType type, std::initializer_list arrayType); //use std::initializer_list for generic instances CordbFunction* FindFunction(int id); CordbModule* GetModule(int module_id); From a16ce8e7a274b96330928830e514b1967315dddd Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 8 Mar 2021 15:07:36 -0300 Subject: [PATCH 49/64] Update CMakeLists.txt --- src/mono/CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 32667f185c97ba..c1f98583992df5 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -11,13 +11,6 @@ set(CMAKE_CXX_FLAGS_CHECKED "") set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") -set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "") -set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "") -set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") -set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "") - include(GNUInstallDirs) include(CheckIncludeFile) include(CheckFunctionExists) From 94d957c7416a900c9e90dec53900a104572ea6a1 Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 8 Mar 2021 21:50:16 -0300 Subject: [PATCH 50/64] Fix arm64 compilation --- src/mono/dbi/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 9a0c2367e072df..24e939b34abeac 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -96,8 +96,10 @@ if (CLR_CMAKE_HOST_UNIX) include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc/rt") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/src/safecrt") - - append("-Wno-missing-prototypes -Wno-pointer-arith -Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wno-missing-prototypes -Wno-pointer-arith -Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + if(TARGET_ARCH STREQUAL "arm64") + append("-Wno-missing-declarations" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + endif() add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) include_directories("../../coreclr/pal/inc/rt/cpp") From ae5f701589c3bd8ca04b9d9369af2b285a5d9bd0 Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 9 Mar 2021 10:43:40 -0300 Subject: [PATCH 51/64] Fix arm64 compilation --- eng/native/configurecompiler.cmake | 2 +- src/mono/dbi/CMakeLists.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index a5dac887902eb3..66fe1d60767ed5 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -332,7 +332,6 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wno-unused-variable) add_compile_options(-Wno-unused-value) add_compile_options(-Wno-unused-function) - add_compile_options(-Wno-tautological-compare) check_cxx_compiler_flag(-Wimplicit-fallthrough COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH) if (COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH) @@ -346,6 +345,7 @@ if (CLR_CMAKE_HOST_UNIX) # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop # after hitting just about 20 errors. add_compile_options(-ferror-limit=4096) + add_compile_options(-Wno-tautological-compare) # Disabled warnings add_compile_options(-Wno-unused-private-field) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 24e939b34abeac..927c1c50ccd066 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -96,9 +96,11 @@ if (CLR_CMAKE_HOST_UNIX) include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc/rt") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/src/safecrt") - append("-Wno-missing-prototypes -Wno-pointer-arith -Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wno-missing-prototypes -Wno-pointer-arith" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) if(TARGET_ARCH STREQUAL "arm64") append("-Wno-missing-declarations" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + else() + append("-Wno-macro-redefined") endif() add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) From 2aae4636499d073ca5aa6fb9319d84875be6e08e Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 9 Mar 2021 11:06:53 -0300 Subject: [PATCH 52/64] Fix error cmake --- src/mono/dbi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 927c1c50ccd066..fc3257e58260eb 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -100,7 +100,7 @@ if (CLR_CMAKE_HOST_UNIX) if(TARGET_ARCH STREQUAL "arm64") append("-Wno-missing-declarations" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) else() - append("-Wno-macro-redefined") + append("-Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) From b5de06dcf00bf296f2c8f4b47aa2492afbd73acd Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 9 Mar 2021 13:49:09 -0300 Subject: [PATCH 53/64] fix arm64 compilation --- src/coreclr/pal/src/exception/remote-unwind.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/pal/src/exception/remote-unwind.cpp b/src/coreclr/pal/src/exception/remote-unwind.cpp index aff77f2e79aa23..d31f0abbdadb53 100644 --- a/src/coreclr/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/pal/src/exception/remote-unwind.cpp @@ -47,7 +47,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pal/debug.h" #include "pal_endian.h" #include "pal.h" +#ifndef DBI_COMPONENT_MONO #define __STDC_FORMAT_MACROS +#endif #include #include From a8f0318881d7b3e6b5a69b1b56c17478a71fdb4f Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 9 Mar 2021 16:33:02 -0300 Subject: [PATCH 54/64] Fix arm64 compilation --- src/coreclr/debug/createdump/createdump.h | 2 ++ src/coreclr/debug/dbgutil/elfreader.cpp | 2 ++ src/coreclr/debug/dbgutil/machoreader.cpp | 6 ++++-- src/coreclr/gc/unix/gcenv.unix.cpp | 2 ++ src/coreclr/pal/src/exception/remote-unwind.cpp | 4 +++- src/coreclr/pal/src/exception/seh-unwind.cpp | 2 ++ src/coreclr/pal/src/misc/sysinfo.cpp | 2 ++ 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/coreclr/debug/createdump/createdump.h b/src/coreclr/debug/createdump/createdump.h index 41cb93414374dd..b18348459c2e99 100644 --- a/src/coreclr/debug/createdump/createdump.h +++ b/src/coreclr/debug/createdump/createdump.h @@ -70,7 +70,9 @@ typedef int T_CONTEXT; #include #include #endif +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #include #else #include diff --git a/src/coreclr/debug/dbgutil/elfreader.cpp b/src/coreclr/debug/dbgutil/elfreader.cpp index 5cbb4ca0efd684..5beb84a482ef96 100644 --- a/src/coreclr/debug/dbgutil/elfreader.cpp +++ b/src/coreclr/debug/dbgutil/elfreader.cpp @@ -5,7 +5,9 @@ #include #include #include +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #include #include "elfreader.h" diff --git a/src/coreclr/debug/dbgutil/machoreader.cpp b/src/coreclr/debug/dbgutil/machoreader.cpp index fa94b49b8d4a40..7ea7ba115e44a6 100644 --- a/src/coreclr/debug/dbgutil/machoreader.cpp +++ b/src/coreclr/debug/dbgutil/machoreader.cpp @@ -5,7 +5,9 @@ #include #include #include +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #include #include #include "machoreader.h" @@ -72,7 +74,7 @@ TryGetSymbol(ICorDebugDataTarget* dataTarget, uint64_t baseAddress, const char* } //-------------------------------------------------------------------- -// MachO module +// MachO module //-------------------------------------------------------------------- MachOModule::MachOModule(MachOReader& reader, mach_vm_address_t baseAddress, mach_header_64* header, std::string* name) : @@ -202,7 +204,7 @@ MachOModule::ReadLoadCommands() m_segments.push_back(segment); // Calculate the load bias for the module. This is the value to add to the vmaddr of a - // segment to get the actual address. + // segment to get the actual address. if (strcmp(segment->segname, SEG_TEXT) == 0) { m_loadBias = m_baseAddress - segment->vmaddr; diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index ecef15208124c3..2b3c00a3d4065e 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -6,7 +6,9 @@ #include #include #include +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #include #include #include diff --git a/src/coreclr/pal/src/exception/remote-unwind.cpp b/src/coreclr/pal/src/exception/remote-unwind.cpp index d31f0abbdadb53..93a6b8a874de20 100644 --- a/src/coreclr/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/pal/src/exception/remote-unwind.cpp @@ -47,7 +47,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pal/debug.h" #include "pal_endian.h" #include "pal.h" -#ifndef DBI_COMPONENT_MONO +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif #include @@ -85,7 +85,9 @@ SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); #else // HOST_UNIX #include +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #include #include #include "debugmacros.h" diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index 5f4df9ae4dc781..a305a246e096a3 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -38,7 +38,9 @@ Module Name: #else // HOST_UNIX #include +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #include #include #include "debugmacros.h" diff --git a/src/coreclr/pal/src/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index 1a9ca8fbfba72e..25fa40f3d72f13 100644 --- a/src/coreclr/pal/src/misc/sysinfo.cpp +++ b/src/coreclr/pal/src/misc/sysinfo.cpp @@ -24,7 +24,9 @@ Revision History: #include #include #include +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #include #include From 25f24bc7ac66966fe59805e54e4009c909608b2c Mon Sep 17 00:00:00 2001 From: Thays Date: Wed, 10 Mar 2021 11:09:46 -0300 Subject: [PATCH 55/64] Fix arm64 compilation --- src/coreclr/pal/src/safecrt/safecrt_output_l.cpp | 2 ++ src/coreclr/pal/src/safecrt/safecrt_output_s.cpp | 2 ++ src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp b/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp index a59bfaaf54301d..075709a05db04e 100644 --- a/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp +++ b/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp @@ -20,7 +20,9 @@ #define _SAFECRT_IMPL +#ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS +#endif #include "pal/palinternal.h" #include #include diff --git a/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp b/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp index ed93e0b92b97f2..9dc6473086f958 100644 --- a/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp +++ b/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp @@ -20,7 +20,9 @@ #define _SAFECRT_IMPL +#ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS +#endif #include "pal/palinternal.h" #include #include diff --git a/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp b/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp index c0911193eb757f..673bf0b7cac569 100644 --- a/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp +++ b/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp @@ -19,7 +19,9 @@ #define _SAFECRT_IMPL +#ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS +#endif #include "pal/palinternal.h" #include From 6032aa332225762cb5d6e43833dc622d0a9f9e72 Mon Sep 17 00:00:00 2001 From: Thays Date: Wed, 10 Mar 2021 14:02:25 -0300 Subject: [PATCH 56/64] Fix arm64 compilation --- src/mono/dbi/cordb-code.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/dbi/cordb-code.cpp b/src/mono/dbi/cordb-code.cpp index 9c9697a20489d0..10b8301cb596e0 100644 --- a/src/mono/dbi/cordb-code.cpp +++ b/src/mono/dbi/cordb-code.cpp @@ -16,7 +16,7 @@ using namespace std; CordbCode::CordbCode(Connection* conn, CordbFunction* func) : CordbBaseMono(conn) { this->m_pFunction = func; - m_nSize = -1; + m_nSize = 0; } HRESULT CordbCode::IsIL(BOOL* pbIL) @@ -39,7 +39,7 @@ HRESULT CordbCode::GetAddress(CORDB_ADDRESS* pStart) ULONG32 CordbCode::GetSize() { - if (m_nSize != -1) + if (m_nSize != 0) return m_nSize; MdbgProtBuffer localbuf; From 8be3bfd5d8284d7c838e189aaa4a24222d0f8687 Mon Sep 17 00:00:00 2001 From: Thays Date: Thu, 11 Mar 2021 00:04:54 -0300 Subject: [PATCH 57/64] Revert "Fix arm64 compilation" This reverts commit 25f24bc7ac66966fe59805e54e4009c909608b2c. --- src/coreclr/pal/src/safecrt/safecrt_output_l.cpp | 2 -- src/coreclr/pal/src/safecrt/safecrt_output_s.cpp | 2 -- src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp b/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp index 075709a05db04e..a59bfaaf54301d 100644 --- a/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp +++ b/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp @@ -20,9 +20,7 @@ #define _SAFECRT_IMPL -#ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS -#endif #include "pal/palinternal.h" #include #include diff --git a/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp b/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp index 9dc6473086f958..ed93e0b92b97f2 100644 --- a/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp +++ b/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp @@ -20,9 +20,7 @@ #define _SAFECRT_IMPL -#ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS -#endif #include "pal/palinternal.h" #include #include diff --git a/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp b/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp index 673bf0b7cac569..c0911193eb757f 100644 --- a/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp +++ b/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp @@ -19,9 +19,7 @@ #define _SAFECRT_IMPL -#ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS -#endif #include "pal/palinternal.h" #include From 946f27a060be987512164456105cbe249bc190d4 Mon Sep 17 00:00:00 2001 From: Thays Date: Thu, 11 Mar 2021 00:05:05 -0300 Subject: [PATCH 58/64] Revert "Fix arm64 compilation" This reverts commit a8f0318881d7b3e6b5a69b1b56c17478a71fdb4f. --- src/coreclr/debug/createdump/createdump.h | 2 -- src/coreclr/debug/dbgutil/elfreader.cpp | 2 -- src/coreclr/debug/dbgutil/machoreader.cpp | 6 ++---- src/coreclr/gc/unix/gcenv.unix.cpp | 2 -- src/coreclr/pal/src/exception/remote-unwind.cpp | 4 +--- src/coreclr/pal/src/exception/seh-unwind.cpp | 2 -- src/coreclr/pal/src/misc/sysinfo.cpp | 2 -- 7 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/coreclr/debug/createdump/createdump.h b/src/coreclr/debug/createdump/createdump.h index b18348459c2e99..41cb93414374dd 100644 --- a/src/coreclr/debug/createdump/createdump.h +++ b/src/coreclr/debug/createdump/createdump.h @@ -70,9 +70,7 @@ typedef int T_CONTEXT; #include #include #endif -#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS -#endif #include #else #include diff --git a/src/coreclr/debug/dbgutil/elfreader.cpp b/src/coreclr/debug/dbgutil/elfreader.cpp index 5beb84a482ef96..5cbb4ca0efd684 100644 --- a/src/coreclr/debug/dbgutil/elfreader.cpp +++ b/src/coreclr/debug/dbgutil/elfreader.cpp @@ -5,9 +5,7 @@ #include #include #include -#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS -#endif #include #include "elfreader.h" diff --git a/src/coreclr/debug/dbgutil/machoreader.cpp b/src/coreclr/debug/dbgutil/machoreader.cpp index 7ea7ba115e44a6..fa94b49b8d4a40 100644 --- a/src/coreclr/debug/dbgutil/machoreader.cpp +++ b/src/coreclr/debug/dbgutil/machoreader.cpp @@ -5,9 +5,7 @@ #include #include #include -#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS -#endif #include #include #include "machoreader.h" @@ -74,7 +72,7 @@ TryGetSymbol(ICorDebugDataTarget* dataTarget, uint64_t baseAddress, const char* } //-------------------------------------------------------------------- -// MachO module +// MachO module //-------------------------------------------------------------------- MachOModule::MachOModule(MachOReader& reader, mach_vm_address_t baseAddress, mach_header_64* header, std::string* name) : @@ -204,7 +202,7 @@ MachOModule::ReadLoadCommands() m_segments.push_back(segment); // Calculate the load bias for the module. This is the value to add to the vmaddr of a - // segment to get the actual address. + // segment to get the actual address. if (strcmp(segment->segname, SEG_TEXT) == 0) { m_loadBias = m_baseAddress - segment->vmaddr; diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 2b3c00a3d4065e..ecef15208124c3 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -6,9 +6,7 @@ #include #include #include -#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS -#endif #include #include #include diff --git a/src/coreclr/pal/src/exception/remote-unwind.cpp b/src/coreclr/pal/src/exception/remote-unwind.cpp index 93a6b8a874de20..d31f0abbdadb53 100644 --- a/src/coreclr/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/pal/src/exception/remote-unwind.cpp @@ -47,7 +47,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pal/debug.h" #include "pal_endian.h" #include "pal.h" -#ifndef __STDC_FORMAT_MACROS +#ifndef DBI_COMPONENT_MONO #define __STDC_FORMAT_MACROS #endif #include @@ -85,9 +85,7 @@ SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); #else // HOST_UNIX #include -#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS -#endif #include #include #include "debugmacros.h" diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index a305a246e096a3..5f4df9ae4dc781 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -38,9 +38,7 @@ Module Name: #else // HOST_UNIX #include -#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS -#endif #include #include #include "debugmacros.h" diff --git a/src/coreclr/pal/src/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index 25fa40f3d72f13..1a9ca8fbfba72e 100644 --- a/src/coreclr/pal/src/misc/sysinfo.cpp +++ b/src/coreclr/pal/src/misc/sysinfo.cpp @@ -24,9 +24,7 @@ Revision History: #include #include #include -#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS -#endif #include #include From df1ac59df11573807b9de35400e09f66168d3da8 Mon Sep 17 00:00:00 2001 From: Thays Date: Thu, 11 Mar 2021 00:05:52 -0300 Subject: [PATCH 59/64] Revert "fix arm64 compilation" This reverts commit b5de06dcf00bf296f2c8f4b47aa2492afbd73acd. --- src/coreclr/pal/src/exception/remote-unwind.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/pal/src/exception/remote-unwind.cpp b/src/coreclr/pal/src/exception/remote-unwind.cpp index d31f0abbdadb53..aff77f2e79aa23 100644 --- a/src/coreclr/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/pal/src/exception/remote-unwind.cpp @@ -47,9 +47,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pal/debug.h" #include "pal_endian.h" #include "pal.h" -#ifndef DBI_COMPONENT_MONO #define __STDC_FORMAT_MACROS -#endif #include #include From 1886964e42abd4a980fa538e5281c9de686d77b9 Mon Sep 17 00:00:00 2001 From: Thays Date: Thu, 11 Mar 2021 00:06:00 -0300 Subject: [PATCH 60/64] Revert "Fix error cmake" This reverts commit 2aae4636499d073ca5aa6fb9319d84875be6e08e. --- src/mono/dbi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index fc3257e58260eb..927c1c50ccd066 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -100,7 +100,7 @@ if (CLR_CMAKE_HOST_UNIX) if(TARGET_ARCH STREQUAL "arm64") append("-Wno-missing-declarations" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) else() - append("-Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wno-macro-redefined") endif() add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) From 5082ae4548534e1a7f962ca870c14ff8a1282d77 Mon Sep 17 00:00:00 2001 From: Thays Date: Thu, 11 Mar 2021 00:06:37 -0300 Subject: [PATCH 61/64] Revert "Fix arm64 compilation" This reverts commit ae5f701589c3bd8ca04b9d9369af2b285a5d9bd0. --- eng/native/configurecompiler.cmake | 2 +- src/mono/dbi/CMakeLists.txt | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 66fe1d60767ed5..a5dac887902eb3 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -332,6 +332,7 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wno-unused-variable) add_compile_options(-Wno-unused-value) add_compile_options(-Wno-unused-function) + add_compile_options(-Wno-tautological-compare) check_cxx_compiler_flag(-Wimplicit-fallthrough COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH) if (COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH) @@ -345,7 +346,6 @@ if (CLR_CMAKE_HOST_UNIX) # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop # after hitting just about 20 errors. add_compile_options(-ferror-limit=4096) - add_compile_options(-Wno-tautological-compare) # Disabled warnings add_compile_options(-Wno-unused-private-field) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 927c1c50ccd066..24e939b34abeac 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -96,11 +96,9 @@ if (CLR_CMAKE_HOST_UNIX) include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc/rt") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/src/safecrt") - append("-Wno-missing-prototypes -Wno-pointer-arith" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wno-missing-prototypes -Wno-pointer-arith -Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) if(TARGET_ARCH STREQUAL "arm64") append("-Wno-missing-declarations" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) - else() - append("-Wno-macro-redefined") endif() add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) From eb474437cd37e2385a15e6b798004b5a8cd29c1a Mon Sep 17 00:00:00 2001 From: Thays Date: Thu, 11 Mar 2021 00:06:49 -0300 Subject: [PATCH 62/64] Revert "Fix arm64 compilation" This reverts commit 94d957c7416a900c9e90dec53900a104572ea6a1. --- src/mono/dbi/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mono/dbi/CMakeLists.txt b/src/mono/dbi/CMakeLists.txt index 24e939b34abeac..9a0c2367e072df 100644 --- a/src/mono/dbi/CMakeLists.txt +++ b/src/mono/dbi/CMakeLists.txt @@ -96,10 +96,8 @@ if (CLR_CMAKE_HOST_UNIX) include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/inc/rt") include_directories("${PROJECT_SOURCE_DIR}/../../coreclr/pal/src/safecrt") - append("-Wno-missing-prototypes -Wno-pointer-arith -Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) - if(TARGET_ARCH STREQUAL "arm64") - append("-Wno-missing-declarations" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) - endif() + + append("-Wno-missing-prototypes -Wno-pointer-arith -Wno-macro-redefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) add_subdirectory(${PROJECT_SOURCE_DIR}/../../coreclr/pal pal) include_directories("../../coreclr/pal/inc/rt/cpp") From 88f5021b1dec00421a0bf699a669d2545377ce26 Mon Sep 17 00:00:00 2001 From: Thays Date: Thu, 11 Mar 2021 00:08:51 -0300 Subject: [PATCH 63/64] Removing arm64 compilation --- src/mono/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index c1f98583992df5..e695034453250c 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -704,7 +704,7 @@ endif() ### End of OS specific checks add_subdirectory(mono) -if (NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCATALYST) +if (NOT HOST_ARM64 AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCATALYST) add_subdirectory(dbi) endif() From 82781210fbfbbe6b0a2a7f0d8120c0da772a74de Mon Sep 17 00:00:00 2001 From: Thays Date: Fri, 12 Mar 2021 00:17:44 -0300 Subject: [PATCH 64/64] Remove arm64 compilation --- src/mono/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index e695034453250c..08f6b0f82dcf2d 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -704,7 +704,7 @@ endif() ### End of OS specific checks add_subdirectory(mono) -if (NOT HOST_ARM64 AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCATALYST) +if (NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCATALYST) add_subdirectory(dbi) endif()