During development, it is handy to use the ./nbdkit script to
automatically pick up the just-built binaries without having
to install things; but using gdb on a script does not work.
Similar to how we already support $NBDKIT_VALGRIND, add support
for $NBDKIT_GDB; and also make the script robust to a value
of $prefix inherited from the environment.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
nbdkit.in | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/nbdkit.in b/nbdkit.in
index 167d512..6be89ec 100644
--- a/nbdkit.in
+++ b/nbdkit.in
@@ -99,11 +99,16 @@ if [ $verbose ]; then
echo $b/src/nbdkit "${args[@]}"
fi
+prefix=
# If NBDKIT_VALGRIND=1 is set in the environment, then we run
# the program under valgrind. This is used by the tests.
+# Similarly, if NBDKIT_GDB=1 is set in the environment, we run
+# the program under gdb, useful during development.
if [ "$NBDKIT_VALGRIND" ]; then
- valgrind="@VALGRIND@ --vgdb=no --leak-check=full --error-exitcode=119
--suppressions=$s/valgrind-suppressions --trace-children=no --child-silent-after-fork=yes
--run-libc-freeres=no"
+ prefix="@VALGRIND@ --vgdb=no --leak-check=full --error-exitcode=119
--suppressions=$s/valgrind-suppressions --trace-children=no --child-silent-after-fork=yes
--run-libc-freeres=no"
+elif [ "$NBDKIT_GDB" ]; then
+ prefix="gdb --args"
fi
# Run the final command.
-exec $valgrind $b/src/nbdkit "${args[@]}"
+exec $prefix $b/src/nbdkit "${args[@]}"
--
2.13.6