-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gdbinit
292 lines (271 loc) · 6.79 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
set height unlimited
set pagination off
set confirm off
set max-value-size unlimited
#set trace-commands on
#set print inferior-events on
#file /bin/bash
directory ~/staging/glibc-2.31
directory ~/staging/glibc-2.31/elf
directory ~/staging/glibc-2.31/nptl
directory ~/staging/glibc-2.31/dlfcn
directory ~/staging/glibc-2.31/misc
directory ~/staging/glibc-2.31/csu
directory ~/staging/glibc-2.31/ctype
directory ~/staging/glibc-2.31/stdlib
directory ~/staging/glibc-2.31/sysdeps
directory ~/staging/glibc-2.31/support
directory ~/staging/glibc-2.31/signal
directory ~/staging/glibc-2.31/string
directory ~/staging/glibc-2.31/stdio-common
directory ~/staging/readline-8.0
directory ~/staging/gcc-9-9.4.0/src/libsanitizer/sanitizer_common
directory ~/staging/gcc-9-9.4.0/src/libsanitizer/asan
directory ~/staging/gcc-9-9.4.0/src/libsanitizer/ubsan
directory ~/staging/bash-5.0
set sysroot /
set breakpoint pending on
br main
br gather_here_documents
br parse.y: 2807
br eval.c:347
br make_here_document
br wait_sigint_handler
catch fork
set mem inaccessible-by-default off
#set detach-on-fork on
set detach-on-fork off
#set follow-fork-mode parent
set follow-fork-mode child
set follow-exec-mode new
#set follow-exec-mode same
#handle SIGWINCH nostop pass
handle SIGQUIT nostop pass
handle SIGINT stop pass
handle SIGCHLD print stop pass
handle SIGTSTP print nostop pass
define info signal-dispositions
__isd_print_tbl_hdr
if $argc == 0
__isd_info_all_signal_dispositions
else
# Looping over args 0..$argc and using eval to extract the current
# arg doesn't work, because "eval" command misses replacing $argN.
# See <https://sourceware.org/bugzilla/show_bug.cgi?id=20559>. We
# get to unroll the loop manually.
if $argc >= 1
__isd_info_signal_disposition $arg0
end
if $argc >= 2
__isd_info_signal_disposition $arg1
end
if $argc >= 3
__isd_info_signal_disposition $arg2
end
if $argc >= 4
__isd_info_signal_disposition $arg3
end
if $argc >= 5
__isd_info_signal_disposition $arg4
end
if $argc >= 6
__isd_info_signal_disposition $arg5
end
if $argc >= 7
__isd_info_signal_disposition $arg6
end
if $argc >= 8
__isd_info_signal_disposition $arg7
end
if $argc >= 9
__isd_info_signal_disposition $arg8
end
if $argc >= 10
__isd_info_signal_disposition $arg9
end
end
end
# Helpers go below.
# Print the disposition of a single signal, given by $arg0.
define __isd_info_signal_disposition
set $_isd_size = sizeof (struct sigaction)
__isd_mmap $_isd_size
if $_isd_mmap_res != (void *) -1
set $_isd_p = (struct sigaction *) $_isd_mmap_res
__isd_print_disposition $arg0 $_isd_p
__isd_munmap $_isd_p $_isd_size
end
end
# Prints the disposition of all signals.
define __isd_info_all_signal_dispositions
set $_isd_size = sizeof (struct sigaction)
__isd_mmap $_isd_size
if $_isd_mmap_res != (void *) -1
set $_isd_p = (struct sigaction *) $_isd_mmap_res
set $_isd_i = 1
set $_isd_nsig = 64
while $_isd_i < $_isd_nsig
__isd_print_disposition $_isd_i $_isd_p
set $_isd_i = $_isd_i + 1
end
__isd_munmap $_isd_p $_isd_size
end
end
# Call mmap in the inferior. $arg0 is the requested size. Returns in $_isd_mmap_res
define __isd_mmap
set $_isd_size = $arg0
# PROT_READ(1) | PROT_WRITE(2)
set $_isd_prot = 0x1 | 0x2
# MAP_PRIVATE(2) | MAP_ANONYMOUS(0x20)
set $_isd_flags = 0x2 | 0x20
set $_isd_mmap = (void *(*) (void *, size_t, int, int, int, off_t)) mmap
set $_isd_mmap_res = $_isd_mmap (0, $_isd_size, $_isd_prot, $_isd_flags, -1, 0)
end
# Call munmap in the inferior. $arg0 is address, and $arg1 is the size.
define __isd_munmap
set $_isd_munmap = (int (*) (void *, size_t)) munmap
call (void) $_isd_munmap ($arg0, $arg1)
end
# Print the table header.
define __isd_print_tbl_hdr
printf "%s\t%-9s\t%-24s\t%s\n", "Number", "Name", "Description", "Disposition"
end
# Helper that prints the disposition of a single signal. First arg is
# signal number, second is sigaction pointer.
define __isd_print_disposition
set $_isd_sig = $arg0
set $_isd_p = $arg1
set $_isd_res = __sigaction ($arg0, 0, $_isd_p)
if $_isd_res == 0
printf "%d\t", $_isd_sig
if $_isd_sig < 32
__isd_signame $_isd_sig
else
printf "SIG%d ", $_isd_sig
end
printf "\t"
if _new_sys_siglist[$arg0] != 0
printf "%-24s", _new_sys_siglist[$arg0]
else
if $arg0 >= 34
printf "Real-time signal %d", $arg0 - 34
printf "%10s", ""
else
printf "Unknown signal %d", $arg0
printf "%10s", ""
end
end
printf "\t"
# Avoid "__sigaction_handler.sa_handler" because of
# #define sa_handler __sigaction_handler.sa_handler
if (long) $_isd_p->__sigaction_handler == 0
printf "SIG_DFL\n"
else
if (long) $_isd_p->__sigaction_handler == 1
printf "SIG_IGN\n"
else
info symbol (long) $_isd_p->__sigaction_handler
end
end
end
end
# Mapping of signal numbers to names.
define __isd_signame
if $arg0 == 1
printf "%-9s", "SIGHUP"
end
if $arg0 == 2
printf "%-9s", "SIGINT"
end
if $arg0 == 3
printf "%-9s", "SIGQUIT"
end
if $arg0 == 4
printf "%-9s", "SIGILL"
end
if $arg0 == 5
printf "%-9s", "SIGTRAP"
end
if $arg0 == 6
printf "%-9s", "SIGABRT"
end
if $arg0 == 7
printf "%-9s", "SIGBUS"
end
if $arg0 == 8
printf "%-9s", "SIGFPE"
end
if $arg0 == 9
printf "%-9s", "SIGKILL"
end
if $arg0 == 10
printf "%-9s", "SIGUSR1"
end
if $arg0 == 11
printf "%-9s", "SIGSEGV"
end
if $arg0 == 12
printf "%-9s", "SIGUSR2"
end
if $arg0 == 13
printf "%-9s", "SIGPIPE"
end
if $arg0 == 14
printf "%-9s", "SIGALRM"
end
if $arg0 == 15
printf "%-9s", "SIGTERM"
end
if $arg0 == 16
printf "%-9s", "SIGSTKFLT"
end
if $arg0 == 17
printf "%-9s", "SIGCHLD"
end
if $arg0 == 18
printf "%-9s", "SIGCONT"
end
if $arg0 == 19
printf "%-9s", "SIGSTOP"
end
if $arg0 == 20
printf "%-9s", "SIGTSTP"
end
if $arg0 == 21
printf "%-9s", "SIGTTIN"
end
if $arg0 == 22
printf "%-9s", "SIGTTOU"
end
if $arg0 == 23
printf "%-9s", "SIGURG"
end
if $arg0 == 24
printf "%-9s", "SIGXCPU"
end
if $arg0 == 25
printf "%-9s", "SIGXFSZ"
end
if $arg0 == 26
printf "%-9s", "SIGVTALRM"
end
if $arg0 == 27
printf "%-9s", "SIGPROF"
end
if $arg0 == 28
printf "%-9s", "SIGWINCH"
end
if $arg0 == 29
printf "%-9s", "SIGIO"
end
if $arg0 == 30
printf "%-9s", "SIGPWR"
end
if $arg0 == 31
printf "%-9s", "SIGSYS"
end
end
#Links:
# - https://sourceware.org/gdb/onlinedocs/gdb/Forks.html
# - https://sourceware.org/gdb/onlinedocs/gdb/Inferiors-and-Programs.html
# - https://www.qnx.com/developers/docs/8.0/com.qnx.doc.ide.userguide/topic/debugging_child.html