Attaching a debugger to a running Julia program and printing local variables

I have a long-running Julia (nightly) script that seems to enter an infinite loop sometimes after running for several hours. Julia is started with ENABLE_GDBLISTENER=1 and with -g2.

Attaching with GDB (gdb -p PID) works fine, backtraces and breakpoints work fine. Even the GDB TUI mode (interactive source view) works!

However, I’m not sure how to print local Julia variables. For example, I’m currently in a large Julia function that has the local variable step::Int. How do I print the value of step? Doing p step in GDB works, but seems to refer to some C function named step, instead of to my local variable.

Any ideas?

BTW, if I’m on Linux, is it better to use GDB or LLDB? Any other debuggers that allow attaching to a running Julia program?

1 Like

Perhaps you might use instructions for logging events.

1 Like