Skip to content

Commit 11ff232

Browse files
committed
Update debugging tips for gc safepoint and other minor changes.
1 parent 0a4187d commit 11ff232

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

doc/devdocs/debuggingtips.rst

+24-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Similarly, if you're debugging some of julia's internals (e.g.,
2424

2525
This is a good way to circumvent problems that arise from the order in which julia's output streams are initialized.
2626

27-
Julia's flisp interpreter uses ``value_t*`` objects; these can be displayed
27+
Julia's flisp interpreter uses ``value_t`` objects; these can be displayed
2828
with ``call fl_print(ios_stdout, obj)``.
2929

3030
Useful Julia variables for Inspecting
@@ -74,7 +74,7 @@ Another useful frame is ``to_function(jl_lambda_info_t *li, bool cstyle)``. The
7474

7575
#2 0x00007ffff7928bf7 in to_function (li=0x2812060, cstyle=false) at codegen.cpp:584
7676
584 abort();
77-
(gdb) p jl_(jl_uncompress_ast(li, li.ast))
77+
(gdb) p jl_(jl_uncompress_ast(li, li->ast))
7878

7979
Inserting breakpoints upon certain conditions
8080
---------------------------------------------
@@ -91,10 +91,31 @@ Calling a particular method
9191

9292
::
9393

94-
(gdb) break jl_apply_generic if strcmp(F->name->name, "method_to_break")==0
94+
(gdb) break jl_apply_generic if strcmp((char*)(jl_symbol_name)(jl_gf_mtable(F)->name), "method_to_break")==0
9595

9696
Since this function is used for every call, you will make everything 1000x slower if you do this.
9797

98+
Dealing with signals
99+
--------------------
100+
101+
Julia requires a few signal to function property. The profiler uses ``SIGUSR2``
102+
for sampling and the garbage collector uses ``SIGSEGV`` for threads
103+
synchronization. If you are debugging some code that uses the profiler or
104+
multiple julia threads, you may want to let the debugger ignore these signals
105+
since they can be triggered very often during normal operations. The command to
106+
do this in GDB is (replace ``SIGSEGV`` with ``SIGUSRS`` or other signals you
107+
want to ignore)::
108+
109+
(gdb) handle SIGSEGV noprint nostop pass
110+
111+
The corresponding LLDB command is (after the process is started)::
112+
113+
(lldb) pro hand -p true -s false -n false SIGSEGV
114+
115+
If you are debugging a segfault with threaded code, you can set a breakpoint on
116+
``jl_critical_error`` (``sigdie_handler`` should also work on Linux and BSD) in
117+
order to only catch the actual segfault rather than the GC synchronization points.
118+
98119
Debugging during julia's build process (bootstrap)
99120
--------------------------------------------------
100121

0 commit comments

Comments
 (0)