-
Notifications
You must be signed in to change notification settings - Fork 10
/
.gdbinit
75 lines (63 loc) · 1.97 KB
/
.gdbinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# This gdb script contains some useful settings and functions for
# debugging Prolog using gdb. Link or copy this as `.gdbinit` to the
# directory where you want to debug Prolog.
# Trap some functions. trap_gdb() is a dummy function that you may call
# conditionally at a place where you want to stop in gdb. This is
# similar to GDB breakpoint conditions, but these are quite slow.
set breakpoint pending on
break trap_gdb
break sysError
break __assert_fail
set breakpoint pending off
# Pass signals that are commonly used and not needed for debugging
handle SIGPIPE noprint nostop pass
handle SIGUSR1 noprint nostop pass
handle SIGUSR2 noprint nostop pass
handle SIGTERM noprint nostop pass
# Be silent on threads and processes created.
set print thread-events off
set print inferior-events off
# Fedora debug info daemon. See https://debuginfod.fedoraproject.org/
set debuginfod enabled on
# Allow debugging ASAN events.
set environment ASAN_OPTIONS=abort_on_error=1
# Print a Prolog backtrace to the current terminal. With one argument,
# change the depth. With two, also set the flags. The (only) useful flag
# is `1`. This prints VM locations rather than Prolog arguments for the
# goals on the stack and almost always works, even if the Prolog data is
# corrupted.
define pl-bt
if $argc == 0
printf "%s\n", PL_backtrace_string(10, 0)
end
if $argc == 1
printf "%s\n", PL_backtrace_string($arg0, 0)
end
if $argc == 2
printf "%s\n", PL_backtrace_string($arg0, $arg1)
end
end
# Print Prolog thread id for the current thread
define pl-tid
p ((PL_local_data_t*)pthread_getspecific(PL_ldata))->thread.info->pl_tid
end
define ninja
if $argc == 0
shell ninja
end
if $argc == 1
shell ninja $arg0
end
end
# Re-run the current program until it crashes. Not SWI-Prolog specific,
# but too easy to forget.
define forever
set pagination off
set breakpoint pending on
break _exit
set breakpoint pending off
commands
run
end
run
end