summaryrefslogtreecommitdiff
path: root/regress/gdbwrap
blob: a01178bb72d1ff525ab80c28da3484f2fb1c62d4 (plain)
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
#!/bin/sh
set -e

# For example, put this in x.gdb
#   break adns__revparse_label
#   break adns__revparse_done
#   run
# and then
#   ADNS_TEST_DEBUG='./gdbwrap -n x.gdb' ./r1test tcpptr
#
# gdbwrap can be passed arguments like
#    *.gdb     passed to gdb with -x
#    -n        exit with exit status 5 which makes r1test think "skipped"
#
# other arguments are taken to be the program name provided by
# whatever has been told to use gdbwrap (eg r1test)

while true; do
	case "$1" in
	*.gdb)	  xgdb="-x $1"; shift;;
	-n)	  x5='exit 5'; shift;;
	*)	  break;;
	esac
done

exe=$1; shift

exec 5<&0 6>&1 7>&2
exec 0<>/dev/tty 1>&0 2>&0

set +e
ex="set args <&5 >&6 2>&7"
for a in "$@"; do
	ex="$ex '$a'"
done
gdb --return-child-result -ex "$ex" $xgdb $exe
$x5