Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 24066e1

Browse files
author
Evgeny Pavlov
committed
Create coreclr delegate inside coreclr_initialize
1 parent d2fe1f2 commit 24066e1

File tree

6 files changed

+42
-37
lines changed

6 files changed

+42
-37
lines changed

src/coreclr/hosts/inc/coreclrhost.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,6 @@ CORECLR_HOSTING_API(coreclr_execute_assembly,
4747

4848
#undef CORECLR_HOSTING_API
4949

50-
struct SequencePointInfo
51-
{
52-
int lineNumber, ilOffset;
53-
char16_t* fileName;
54-
};
55-
56-
struct MethodDebugInfo
57-
{
58-
SequencePointInfo* points;
59-
int size;
60-
};
61-
62-
typedef int (*GetInfoForMethodDelegate)(const char*, unsigned int, MethodDebugInfo& methodDebugInfo);
63-
extern GetInfoForMethodDelegate getInfoForMethodDelegate;
64-
6550
#endif // __CORECLR_HOST_H__
6651

6752

src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
// If set to 1, server GC is enabled on startup. If 0, server GC is
3535
// disabled. Server GC is off by default.
3636
static const char* serverGcVar = "CORECLR_SERVER_GC";
37-
GetInfoForMethodDelegate getInfoForMethodDelegate = NULL;
3837
#if defined(__linux__)
3938
#define symlinkEntrypointExecutable "/proc/self/exe"
4039
#elif !defined(__APPLE__)
@@ -402,24 +401,6 @@ int ExecuteManagedAssembly(
402401
}
403402
else
404403
{
405-
#ifdef FEATURE_GDBJIT
406-
coreclr_create_delegate_ptr CreateDelegate =
407-
(coreclr_create_delegate_ptr)dlsym(coreclrLib,
408-
"coreclr_create_delegate");
409-
410-
// st = CreateDelegate(hostHandle, domainId, "System.Diagnostics.Debug.SymbolReader",
411-
// "System.Diagnostics.Debug.SymbolReader.SymbolReader", "GetLineByILOffset",
412-
// (void **)&getLineByILOffsetDelegate);
413-
st = CreateDelegate(hostHandle, domainId, "System.Diagnostics.Debug.SymbolReader",
414-
"System.Diagnostics.Debug.SymbolReader.SymbolReader", "GetInfoForMethod",
415-
(void **)&getInfoForMethodDelegate);
416-
417-
if (!SUCCEEDED(st))
418-
{
419-
fprintf(stderr, "coreclr_create_delegate failed - status: 0x%08x\n", st);
420-
exitCode = -1;
421-
}
422-
#endif // FEATURE_GDBJIT
423404
st = executeAssembly(
424405
hostHandle,
425406
domainId,

src/dlls/mscoree/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
include_directories("../../inc")
22

3+
if(FEATURE_GDBJIT)
4+
add_definitions(-DFEATURE_GDBJIT)
5+
endif(FEATURE_GDBJIT)
6+
37
set(CLR_SOURCES
48
mscoree.cpp
59
unixinterface.cpp

src/dlls/mscoree/unixinterface.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ static void ConvertConfigPropertiesToUnicode(
137137
extern "C" LPCWSTR g_CLRJITPath;
138138
#endif // !defined(FEATURE_MERGE_JIT_AND_ENGINE)
139139

140+
#ifdef FEATURE_GDBJIT
141+
GetInfoForMethodDelegate getInfoForMethodDelegate = NULL;
142+
extern "C" int coreclr_create_delegate(void*, unsigned int, const char*, const char*, const char*, void**);
143+
#endif //FEATURE_GDBJIT
144+
140145
//
141146
// Initialize the CoreCLR. Creates and starts CoreCLR host and creates an app domain
142147
//
@@ -238,8 +243,21 @@ int coreclr_initialize(
238243
{
239244
host.SuppressRelease();
240245
*hostHandle = host;
241-
}
246+
#ifdef FEATURE_GDBJIT
242247

248+
hr = coreclr_create_delegate(*hostHandle,
249+
*domainId,
250+
"System.Diagnostics.Debug.SymbolReader",
251+
"System.Diagnostics.Debug.SymbolReader.SymbolReader",
252+
"GetInfoForMethod",
253+
(void**)&getInfoForMethodDelegate);
254+
255+
if (!SUCCEEDED(hr))
256+
{
257+
fprintf(stderr, "coreclr_create_delegate failed - status: 0x%08x\n", hr);
258+
}
259+
#endif
260+
}
243261
return hr;
244262
}
245263

src/inc/utilcode.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5750,4 +5750,21 @@ extern SpinConstants g_SpinConstants;
57505750

57515751
// ======================================================================================
57525752

5753+
#ifdef FEATURE_GDBJIT
5754+
struct SequencePointInfo
5755+
{
5756+
int lineNumber, ilOffset;
5757+
char16_t* fileName;
5758+
};
5759+
5760+
struct MethodDebugInfo
5761+
{
5762+
SequencePointInfo* points;
5763+
int size;
5764+
};
5765+
5766+
typedef int (*GetInfoForMethodDelegate)(const char*, unsigned int, MethodDebugInfo& methodDebugInfo);
5767+
extern GetInfoForMethodDelegate getInfoForMethodDelegate;
5768+
#endif // FEATURE_GDBJIT
5769+
57535770
#endif // __UtilCode_h__

src/vm/gdbjit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//*****************************************************************************
1212

1313
#include "common.h"
14-
#include "../coreclr/hosts/inc/coreclrhost.h"
14+
#include "../inc/utilcode.h"
1515
#include "gdbjit.h"
1616

1717
struct DebuggerILToNativeMap
@@ -102,7 +102,7 @@ GetDebugInfoFromPDB(MethodDesc* MethodDescPtr, SymbolsInfo** symInfo, unsigned i
102102
StackScratchBuffer scratch;
103103
const char* szModName = modName.GetUTF8(scratch);
104104

105-
MethodDebugInfo *methodDebugInfo = new (nothrow )MethodDebugInfo();
105+
MethodDebugInfo* methodDebugInfo = new (nothrow) MethodDebugInfo();
106106
if (methodDebugInfo == nullptr)
107107
return E_OUTOFMEMORY;
108108
methodDebugInfo->points = (SequencePointInfo*) CoTaskMemAlloc(sizeof(SequencePointInfo) * numMap);

0 commit comments

Comments
 (0)