| 1 | #!/bin/sh |
| 2 | set -e |
| 3 | |
| 4 | # For example, put this in x.gdb |
| 5 | # break adns__revparse_label |
| 6 | # break adns__revparse_done |
| 7 | # run |
| 8 | # and then |
| 9 | # ADNS_TEST_DEBUG='./gdbwrap -n x.gdb' ./r1test tcpptr |
| 10 | # |
| 11 | # gdbwrap can be passed arguments like |
| 12 | # *.gdb passed to gdb with -x |
| 13 | # -n exit with exit status 5 which makes r1test think "skipped" |
| 14 | # |
| 15 | # other arguments are taken to be the program name provided by |
| 16 | # whatever has been told to use gdbwrap (eg r1test) |
| 17 | |
| 18 | while true; do |
| 19 | case "$1" in |
| 20 | *.gdb) xgdb="-x $1"; shift;; |
| 21 | -n) x5='exit 5'; shift;; |
| 22 | *) break;; |
| 23 | esac |
| 24 | done |
| 25 | |
| 26 | exe=$1; shift |
| 27 | |
| 28 | exec 5<&0 6>&1 7>&2 |
| 29 | exec 0<>/dev/tty 1>&0 2>&0 |
| 30 | |
| 31 | set +e |
| 32 | ex="set args <&5 >&6 2>&7" |
| 33 | for a in "$@"; do |
| 34 | ex="$ex '$a'" |
| 35 | done |
| 36 | gdb --return-child-result -ex "$ex" $xgdb $exe |
| 37 | $x5 |