forked from strycore/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug
executable file
·41 lines (33 loc) · 821 Bytes
/
debug
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
#---------------------------------------------------------------------
usage() {
cat<<EOF
Usage: ${0} program_name [program_args]
Trace a given program using gdb.
EOF
}
log() {
echo "${*}" 1>&2
}
die() {
usage
log 'error:' ${*}'.'
exit 1
}
#---------------------------------------------------------------------
test "x${*}" = "x" && die 'no process given'
LOG="/tmp/gdb-`basename ${1}`.txt"
log "outputting trace to '${LOG}'"
exec gdb \
-ex 'set logging overwrite on' \
-ex "set logging file ${LOG}" \
-ex 'set logging on' \
-ex 'handle SIG33 pass nostop noprint' \
-ex 'set pagination 0' \
-ex 'run' \
-ex 'backtrace full' \
-ex 'info registers' \
-ex 'x/16i $pc' \
-ex 'thread apply all backtrace' \
-ex 'quit' \
--args ${*} \
< /dev/null