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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# gdb
--------------------------------------------------------------------------------
# toc
------
|gdb|
|opts|
|prompt|
|user_commands|
|hooks|
|flows|
# gdb(1) *gdb*
=========
gdb [opts] [exe [coredump | pid]]
gdb [opts] --args exe <exe-args>
opts: *opts*
-p <pid> attach to pid
-x <file> execute script <file> before prompt
-ex <cmd> execute command <cmd> before prompt
--tty <tty> set I/O tty for debugee (see *prompt* for details)
prompt: *prompt*
tty <tty> set <tty> as tty for debugee. make sure nobody
reads from target tty, easiest is to spawn a shell
and run
> while true; do sleep 1024; done
set follow-fork-mode <child | parent>
specify which process to follow on fork(2)
sharedlibrary [regex]
load symbols of shared lib, if REGEX then only symbols
for matching libs
break <sym> thread <tnum>
set a breakpoint only on a specific thread
rbreak <regex> set breakpoints based on symbols matching regex
<regex> is internally expanded to .*<regex>.*
so 'rbreak foo' matches barfoobar()
command [bp_list] define commands to run after breakpoint hit if
BP_LIST not supplied attach command to last
created bp
BP_LIST: space separates list, eg 'command 2 5-8'
to run command for bp 2,5,6,7,8
info functions [regex]
list functions according to REGEX, if REGEX empty,
list all
info variables [regex]
list variables according to REGEX, if REGEX empty,
list all
info handle [signal]
list bevahior for SIGNAL, if SIGNAL empty list all signals
handle signal <action>
configure how gdb handles SIGNAL which is ment for the debugee
<action>:
stop/nostop catch signal in gdb and break
print/noprint print message when gdb catches signal
pass/nopass pass signal down to debugee
noignore/ignore synonyms for
catch signal <signal>
create a catchpoint for SIGNAL
user commands: *user_commands*
define <cmd> defines user command <cmd> to be run
# cmds in prompt or script
end
document <cmd> define documentation for cmd <cmd>
# docu
end
help user-defined list user defined commands
help <cmd> list documentation for command <cmd>
hooks: *hooks*
define hook-<cmd> run commands defined in hook before
# cmds executing <cmd>
end
define hookpost-<cmd> run commands defined in hookpost after
# cmds executing <cmd>
end
flows: *flows*
# catch SIGSEGV and execute some actions once it happends
- script:
catch signal SIGSEGV
command
bt
ct
end
# quickly execute gdb command on running process, eg get backtrace from
# thread 1
- cmd:
$> gdb -ex 'thread 1' -ex 'bt' -p <PID>
# script gdb for automating debugging sessions
- script: run.gdb
set pagination off
break mmap
command
info reg rdi rsi rdx
bt
c
end
#initial drop
c
- cmd:
$> gdb -p <PID> -x ./run.gdb --batch &> run.log
--------------------------------------------------------------------------------
vim:sts=2:et:tw=80:cc=80:fo+=t:ft=help
|