From 2f44025563c4d2a8807f2ea6b591482c677d2120 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 24 Jul 2014 00:52:51 +0100 Subject: [PATCH 1/1] regress/gdbwrap: Provide a convenience script This lets you run gdb from within r1test with appropriate fd plumbing. (It's a shame gdb doesn't have a way to simply tell it to take its commands from /dev/tty.) Add the suggested example gdb script file, x.gdb, to .gitignore. Signed-off-by: Ian Jackson --- .gitignore | 1 + regress/gdbwrap | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 regress/gdbwrap diff --git a/.gitignore b/.gitignore index 258e160..aea004a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ settings.make *.so *.a *~ +x.gdb client/Makefile client/adnstest_s client/fanftest_s diff --git a/regress/gdbwrap b/regress/gdbwrap new file mode 100755 index 0000000..a01178b --- /dev/null +++ b/regress/gdbwrap @@ -0,0 +1,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 -- 2.30.2