Re: [PATCH] tests: create an interactive gdb session with the 'debug' helper
- From
Jeff King <peff@peff.net>
- Date
- Mar 17, 2017, 14:55 UTC
- Message-ID
- <20170317145504.utysxd4qqaqetm7t@sigill.intra.peff.net>
- In-Reply-To
- <20170317144646.9349-1-szeder.dev@gmail.com>
On Fri, Mar 17, 2017 at 03:46:46PM +0100, SZEDER Gábor wrote:
Show 9 quoted lines
> The 'debug' test helper is supposed to facilitate debugging by running > a command of the test suite under gdb. Unfortunately, its usefulness > is severely limited, because that gdb session is not interactive, > since the test's, and thus gdb's standard input is attached to > /dev/null (for a good reason, see 781f76b15 (test-lib: redirect stdin > of tests, 2011-12-15)). > > Re-attach the original standard input in the debug helper, thus > creating an interactive gdb session, which is much much more useful.
Yeah, I think I've had to do a similar hack manually. This is an obvious improvement. Though...
Show 11 quoted lines
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index bd357704c..9567dc986 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -154,7 +154,7 @@ test_pause () {
> #
> # Example: "debug git checkout master".
> debug () {
> - GIT_TEST_GDB=1 "$@"
> + GIT_TEST_GDB=1 "$@" <&6
> }Your stderr and stdout may be redirected, too. That's usually not a big problem because you'll be using "-v", but perhaps this should add:
>&3 2>&4
to be on the safe side. That covers running without "-v", as well as cases where the test script is redirecting output (I _actually_ wish gdb behaved like perl's debugger and unconditionally used the terminal, retaining existing redirections, but I AFAIK there's no easy way to get it to do that).
-Peff