From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: johannes.schindelin@gmx.de, Elijah Newren <newren@gmail.com>
Subject: [PATCH v2] Make running git under other debugger-like programs easy
Date: Mon, 9 Apr 2018 11:51:36 -0700 [thread overview]
Message-ID: <20180409185136.4880-1-newren@gmail.com> (raw)
In-Reply-To: <20180405174935.598-1-newren@gmail.com>
This allows us to run git, when using the script from bin-wrappers, under
other programs. A few examples for usage within testsuite scripts:
debug git checkout master
debug --debugger=nemiver git $ARGS
debug -d "valgrind --tool-memcheck --track-origins=yes" git $ARGS
Or, if someone has bin-wrappers/ in their $PATH and is executing git
outside the testsuite:
GIT_DEBUGGER="gdb --args" git $ARGS
GIT_DEBUGGER=nemiver git $ARGS
GIT_DEBUGGER="valgrind --tool=memcheck --track-origins=yes" git $ARGS
There is also a handy shortcut of GIT_DEBUGGER=1 meaning the same as
GIT_DEBUGGER="gdb --args"
Original-patch-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
t/test-lib-functions.sh | 24 ++++++++++++++++++++----
wrap-for-bin.sh | 19 +++++++++++++------
2 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 1701fe2a06..0591d9a7f8 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -145,12 +145,28 @@ test_pause () {
"$SHELL_PATH" <&6 >&5 2>&7
}
-# Wrap git in gdb. Adding this to a command can make it easier to
-# understand what is going on in a failing test.
+# Wrap git with a debugger. Adding this to a command can make it easier
+# to understand what is going on in a failing test.
#
-# Example: "debug git checkout master".
+# Examples:
+# debug git checkout master
+# debug --debugger=nemiver git $ARGS
+# debug -d "valgrind --tool=memcheck --track-origins=yes" git $ARGS
debug () {
- GIT_TEST_GDB=1 "$@" <&6 >&5 2>&7
+ case "$1" in
+ -d)
+ DBG_FLAGS="$2" &&
+ shift 2
+ ;;
+ --debugger=*)
+ DBG_FLAGS="${1#*=}" &&
+ shift 1
+ ;;
+ *)
+ DBG_FLAGS=1
+ ;;
+ esac &&
+ GIT_DEBUGGER="${DBG_FLAGS}" "$@" <&6 >&5 2>&7
}
# Call test_commit with the arguments
diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh
index 22b6e4948f..376c056842 100644
--- a/wrap-for-bin.sh
+++ b/wrap-for-bin.sh
@@ -20,10 +20,17 @@ PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
-if test -n "$GIT_TEST_GDB"
-then
- unset GIT_TEST_GDB
- exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
-else
+case "$GIT_DEBUGGER" in
+'')
exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
-fi
+ ;;
+1)
+ unset GIT_DEBUGGER
+ exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+ ;;
+*)
+ GIT_DEBUGGER_ARGS="$GIT_DEBUGGER"
+ unset GIT_DEBUGGER
+ exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+ ;;
+esac
--
2.15.0.1.gcd9d12fc4a.dirty
next prev parent reply other threads:[~2018-04-09 18:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-05 17:49 [PATCH] Make running git under other debugger-like programs easy Elijah Newren
2018-04-05 19:57 ` Johannes Schindelin
2018-04-05 21:16 ` Elijah Newren
2018-04-06 10:38 ` Johannes Schindelin
2018-04-06 22:36 ` Elijah Newren
2018-04-09 18:51 ` Elijah Newren [this message]
2018-04-09 21:19 ` [PATCH v2] " Johannes Schindelin
2018-04-10 0:48 ` Elijah Newren
2018-04-10 8:26 ` Johannes Schindelin
2018-04-24 23:46 ` [PATCH v3] " Elijah Newren
2018-04-25 7:25 ` Johannes Schindelin
2018-04-26 1:56 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180409185136.4880-1-newren@gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.