Skip to content

Commit fdfac75

Browse files
committed
allow users to enable GDB JIT integration on release builds
1 parent fdbc86e commit fdfac75

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

doc/src/manual/environment-variables.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ event listener for just-in-time (JIT) profiling.
314314
* [OProfile](http://oprofile.sourceforge.net/news/) (`USE_OPROFILE_JITEVENTS` set to `1`
315315
in the build configuration).
316316

317+
### `ENABLE_GDBLISTENER`
318+
319+
If set to anything besides `0` enables GDB registration of Julia code on release builds.
320+
On debug builds of Julia this is always enabled. Recommended to use with `-g 2`.
321+
322+
317323
### `JULIA_LLVM_ARGS`
318324

319325
Arguments to be passed to the LLVM backend.

src/codegen.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7728,10 +7728,9 @@ extern "C" void jl_init_llvm(void)
77287728
std::string DL = jl_data_layout.getStringRepresentation() + "-ni:10:11:12:13";
77297729
jl_data_layout.reset(DL);
77307730

7731-
// Register GDB event listener
7732-
#ifdef JL_DEBUG_BUILD
7733-
jl_ExecutionEngine->RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
7734-
#endif
7731+
// Register GDB event listener
7732+
if(jl_using_gdb_jitevents)
7733+
jl_ExecutionEngine->RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
77357734

77367735
#ifdef JL_USE_INTEL_JITEVENTS
77377736
if (jl_using_intel_jitevents)

src/init.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ char jl_using_oprofile_jitevents = 0; // Non-zero if running under OProfile
436436
char jl_using_perf_jitevents = 0;
437437
#endif
438438

439+
char jl_using_gdb_jitevents = 0;
440+
439441
int isabspath(const char *in) JL_NOTSAFEPOINT
440442
{
441443
#ifdef _OS_WINDOWS_
@@ -692,6 +694,15 @@ void _julia_init(JL_IMAGE_SEARCH rel)
692694
}
693695
#endif
694696

697+
#if defined(JL_DEBUG_BUILD)
698+
jl_using_gdb_jitevents = 1;
699+
# else
700+
const char *jit_gdb = getenv("ENABLE_GDBLISTENER");
701+
if (jit_gdb && atoi(jit_gdb)) {
702+
jl_using_gdb_jitevents = 1;
703+
}
704+
#endif
705+
695706
if ((jl_options.outputo || jl_options.outputbc || jl_options.outputasm) &&
696707
(jl_options.code_coverage || jl_options.malloc_log)) {
697708
jl_error("cannot generate code-coverage or track allocation information while generating a .o, .bc, or .s output file");

src/julia_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ extern char jl_using_oprofile_jitevents;
595595
#ifdef JL_USE_PERF_JITEVENTS
596596
extern char jl_using_perf_jitevents;
597597
#endif
598+
extern char jl_using_gdb_jitevents;
598599
extern size_t jl_arr_xtralloc_limit;
599600

600601
// -- init.c -- //

0 commit comments

Comments
 (0)