From 72904eb62dd8dbed5929598e1ab800907c9c0d26 Mon Sep 17 00:00:00 2001 From: Evgeny Pavlov Date: Mon, 18 Jul 2016 15:19:26 +0300 Subject: [PATCH] Create coreclr delegate inside coreclr_initialize Commit migrated from https://github.com/dotnet/coreclr/commit/24066e1427bbb6be7e95449302040daf2fcddfd7 --- src/coreclr/src/coreclr/hosts/inc/coreclrhost.h | 15 --------------- .../hosts/unixcoreruncommon/coreruncommon.cpp | 19 ------------------- src/coreclr/src/dlls/mscoree/CMakeLists.txt | 4 ++++ src/coreclr/src/dlls/mscoree/unixinterface.cpp | 20 +++++++++++++++++++- src/coreclr/src/inc/utilcode.h | 17 +++++++++++++++++ src/coreclr/src/vm/gdbjit.cpp | 4 ++-- 6 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/coreclr/src/coreclr/hosts/inc/coreclrhost.h b/src/coreclr/src/coreclr/hosts/inc/coreclrhost.h index 733174b..8c9f3a3 100644 --- a/src/coreclr/src/coreclr/hosts/inc/coreclrhost.h +++ b/src/coreclr/src/coreclr/hosts/inc/coreclrhost.h @@ -47,21 +47,6 @@ CORECLR_HOSTING_API(coreclr_execute_assembly, #undef CORECLR_HOSTING_API -struct SequencePointInfo -{ - int lineNumber, ilOffset; - char16_t* fileName; -}; - -struct MethodDebugInfo -{ - SequencePointInfo* points; - int size; -}; - -typedef int (*GetInfoForMethodDelegate)(const char*, unsigned int, MethodDebugInfo& methodDebugInfo); -extern GetInfoForMethodDelegate getInfoForMethodDelegate; - #endif // __CORECLR_HOST_H__ diff --git a/src/coreclr/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp b/src/coreclr/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp index ae2d49c..29f2772 100644 --- a/src/coreclr/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp +++ b/src/coreclr/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp @@ -34,7 +34,6 @@ // If set to 1, server GC is enabled on startup. If 0, server GC is // disabled. Server GC is off by default. static const char* serverGcVar = "CORECLR_SERVER_GC"; -GetInfoForMethodDelegate getInfoForMethodDelegate = NULL; #if defined(__linux__) #define symlinkEntrypointExecutable "/proc/self/exe" #elif !defined(__APPLE__) @@ -402,24 +401,6 @@ int ExecuteManagedAssembly( } else { -#ifdef FEATURE_GDBJIT - coreclr_create_delegate_ptr CreateDelegate = - (coreclr_create_delegate_ptr)dlsym(coreclrLib, - "coreclr_create_delegate"); - - // st = CreateDelegate(hostHandle, domainId, "System.Diagnostics.Debug.SymbolReader", - // "System.Diagnostics.Debug.SymbolReader.SymbolReader", "GetLineByILOffset", - // (void **)&getLineByILOffsetDelegate); - st = CreateDelegate(hostHandle, domainId, "System.Diagnostics.Debug.SymbolReader", - "System.Diagnostics.Debug.SymbolReader.SymbolReader", "GetInfoForMethod", - (void **)&getInfoForMethodDelegate); - - if (!SUCCEEDED(st)) - { - fprintf(stderr, "coreclr_create_delegate failed - status: 0x%08x\n", st); - exitCode = -1; - } -#endif // FEATURE_GDBJIT st = executeAssembly( hostHandle, domainId, diff --git a/src/coreclr/src/dlls/mscoree/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/CMakeLists.txt index 7af76fb..6a157e4 100644 --- a/src/coreclr/src/dlls/mscoree/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscoree/CMakeLists.txt @@ -1,5 +1,9 @@ include_directories("../../inc") +if(FEATURE_GDBJIT) + add_definitions(-DFEATURE_GDBJIT) +endif(FEATURE_GDBJIT) + set(CLR_SOURCES mscoree.cpp unixinterface.cpp diff --git a/src/coreclr/src/dlls/mscoree/unixinterface.cpp b/src/coreclr/src/dlls/mscoree/unixinterface.cpp index be345b3..f48b021 100644 --- a/src/coreclr/src/dlls/mscoree/unixinterface.cpp +++ b/src/coreclr/src/dlls/mscoree/unixinterface.cpp @@ -137,6 +137,11 @@ static void ConvertConfigPropertiesToUnicode( extern "C" LPCWSTR g_CLRJITPath; #endif // !defined(FEATURE_MERGE_JIT_AND_ENGINE) +#ifdef FEATURE_GDBJIT +GetInfoForMethodDelegate getInfoForMethodDelegate = NULL; +extern "C" int coreclr_create_delegate(void*, unsigned int, const char*, const char*, const char*, void**); +#endif //FEATURE_GDBJIT + // // Initialize the CoreCLR. Creates and starts CoreCLR host and creates an app domain // @@ -238,8 +243,21 @@ int coreclr_initialize( { host.SuppressRelease(); *hostHandle = host; - } +#ifdef FEATURE_GDBJIT + hr = coreclr_create_delegate(*hostHandle, + *domainId, + "System.Diagnostics.Debug.SymbolReader", + "System.Diagnostics.Debug.SymbolReader.SymbolReader", + "GetInfoForMethod", + (void**)&getInfoForMethodDelegate); + + if (!SUCCEEDED(hr)) + { + fprintf(stderr, "coreclr_create_delegate failed - status: 0x%08x\n", hr); + } +#endif + } return hr; } diff --git a/src/coreclr/src/inc/utilcode.h b/src/coreclr/src/inc/utilcode.h index 993d87d..79bdc69 100644 --- a/src/coreclr/src/inc/utilcode.h +++ b/src/coreclr/src/inc/utilcode.h @@ -5750,4 +5750,21 @@ extern SpinConstants g_SpinConstants; // ====================================================================================== +#ifdef FEATURE_GDBJIT +struct SequencePointInfo +{ + int lineNumber, ilOffset; + char16_t* fileName; +}; + +struct MethodDebugInfo +{ + SequencePointInfo* points; + int size; +}; + +typedef int (*GetInfoForMethodDelegate)(const char*, unsigned int, MethodDebugInfo& methodDebugInfo); +extern GetInfoForMethodDelegate getInfoForMethodDelegate; +#endif // FEATURE_GDBJIT + #endif // __UtilCode_h__ diff --git a/src/coreclr/src/vm/gdbjit.cpp b/src/coreclr/src/vm/gdbjit.cpp index c60f349..d3a6574 100644 --- a/src/coreclr/src/vm/gdbjit.cpp +++ b/src/coreclr/src/vm/gdbjit.cpp @@ -11,7 +11,7 @@ //***************************************************************************** #include "common.h" -#include "../coreclr/hosts/inc/coreclrhost.h" +#include "../inc/utilcode.h" #include "gdbjit.h" struct DebuggerILToNativeMap @@ -102,7 +102,7 @@ GetDebugInfoFromPDB(MethodDesc* MethodDescPtr, SymbolsInfo** symInfo, unsigned i StackScratchBuffer scratch; const char* szModName = modName.GetUTF8(scratch); - MethodDebugInfo *methodDebugInfo = new (nothrow )MethodDebugInfo(); + MethodDebugInfo* methodDebugInfo = new (nothrow) MethodDebugInfo(); if (methodDebugInfo == nullptr) return E_OUTOFMEMORY; methodDebugInfo->points = (SequencePointInfo*) CoTaskMemAlloc(sizeof(SequencePointInfo) * numMap); -- 2.7.4