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

Commit d2fe1f2

Browse files
Dmitri-BotcharnikovEvgeny Pavlov
authored andcommitted
Add GDB JIT support for source line debug information.
1 parent 9f74aff commit d2fe1f2

File tree

7 files changed

+1661
-3
lines changed

7 files changed

+1661
-3
lines changed

src/coreclr/hosts/inc/coreclrhost.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,22 @@ CORECLR_HOSTING_API(coreclr_execute_assembly,
4646
unsigned int* exitCode);
4747

4848
#undef CORECLR_HOSTING_API
49-
49+
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+
5065
#endif // __CORECLR_HOST_H__
66+
67+

src/coreclr/hosts/unixcoreruncommon/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ project(unixcoreruncommon)
22

33
add_compile_options(-fPIC)
44

5+
if(FEATURE_GDBJIT)
6+
add_definitions(-DFEATURE_GDBJIT)
7+
endif(FEATURE_GDBJIT)
8+
59
_add_library(unixcoreruncommon
610
STATIC
711
coreruncommon.cpp

src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
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-
37+
GetInfoForMethodDelegate getInfoForMethodDelegate = NULL;
3838
#if defined(__linux__)
3939
#define symlinkEntrypointExecutable "/proc/self/exe"
4040
#elif !defined(__APPLE__)
@@ -402,6 +402,24 @@ int ExecuteManagedAssembly(
402402
}
403403
else
404404
{
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
405423
st = executeAssembly(
406424
hostHandle,
407425
domainId,

src/vm/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ if(CLR_CMAKE_PLATFORM_UNIX)
2727
add_compile_options(-fPIC)
2828
endif(CLR_CMAKE_PLATFORM_UNIX)
2929

30+
if(FEATURE_GDBJIT)
31+
set(VM_SOURCES_GDBJIT
32+
../gc/gccommon.cpp
33+
../gc/gcscan.cpp
34+
../gc/gcsvr.cpp
35+
../gc/gcwks.cpp
36+
gdbjit.cpp
37+
)
38+
add_definitions(-DFEATURE_GDBJIT)
39+
endif(FEATURE_GDBJIT)
40+
3041
set(VM_SOURCES_DAC_AND_WKS_COMMON
3142
appdomain.cpp
3243
array.cpp
@@ -109,6 +120,7 @@ set(VM_SOURCES_DAC_AND_WKS_COMMON
109120
virtualcallstub.cpp
110121
win32threadpool.cpp
111122
zapsig.cpp
123+
${VM_SOURCES_GDBJIT}
112124
)
113125

114126
if(FEATURE_READYTORUN)

0 commit comments

Comments
 (0)