git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/6] Facilitate debugging Git executables in tests with gdb

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 27, 2015, 09:42 UTC
Message-ID
<alpine.DEB.1.00.1510271036100.31610@s15462909.onlinehome-server.info>
In-Reply-To
<20151026191724.GE7881@google.com>
Hi Jonathan,
On Mon, 26 Oct 2015, Jonathan Nieder wrote:
Show 15 quoted lines
> Johannes Schindelin wrote:
> 
> > --- a/wrap-for-bin.sh
> > +++ b/wrap-for-bin.sh
> > @@ -19,4 +19,11 @@ GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
> >  PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
> >  export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
> >  
> > +if test -n "$TEST_GDB_GIT"
> > +then
> > +	exec gdb -args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
> 
> Most TEST_ environment variables that git respects are under
> GIT_TEST_* --- e.g., GIT_TEST_OPTS.  Should this match that pattern
> as well, for easier debugging with commands like 'env | grep GIT_'?

I dunno. This variable is most useful when inserted into the shell scripts in t/ themselves, not when specified via the command line. For example, if you have something like

	test_expect_success '123' '
		...
		# This Git call somehow fails and I have no clue why
		git push remote HEAD
		...
	'

then prefixing the `git push` command with `TEST_GDB_GIT=1` lets you use `gdb` when running the test with the `-i` and `-v` flags.

Please note that `TEST_GDB_GIT` is already a major step up from my initial `DDD`.

> What happens if the child in turn calls git again?  Should this
> unset TEST_GDB_GIT in gdb's environment?

It probably would call gdb again. Which is sometimes useful. But I have to admit that I do not know whether that works.

> The gdb manual and --help output advertise "--args".  Has "-args"
> (with a single dash) always worked?

I always used it with a single dash... So I assume that it worked for a long time (IIRC I used it first in 1994).

Show 13 quoted lines
> > +	echo "Could not run gdb -args ${GIT_EXEC_PATH}/@@PROG@@ $*" >&2
> > +	exit 1
> 
> Does the 'exec' after the fi need this as well?  exec is supposed to
> itself print a message and exit when it runs into an error.  Would
> including an 'else' with the if make the control flow clearer?  E.g.
> 
> 	if test -n "$TEST_GDB_GIT"
> 	then
> 		exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
> 	else
> 		exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
> 	fi

I suppose you're right! The `exec` can fail easily, e.g. when `gdb` was not found.

Ciao, Johannes

Previous: Jonathan NiederNext: Junio C Hamano
Message 19 of 48 in “Miscellaneous platform-independent patches from Git for Windows”
  1. 0/6 Miscellaneous platform-independent patches from Git for WindowsJohannes Schindelin, Oct 26, 2015
  2. 1/6 Only use CURLOPT_LOGIN_OPTIONS if it is actually availableJohannes Schindelin, Oct 26, 2015
  3. Junio C HamanoOct 26, 2015
  4. 2/6 remote-http(s): Support SOCKS proxiesJohannes Schindelin, Oct 26, 2015
  5. Junio C HamanoOct 26, 2015
  6. James McCoyOct 27, 2015
  7. Junio C HamanoOct 27, 2015
  8. Johannes SchindelinOct 27, 2015
  9. Johannes SchindelinOct 27, 2015
  10. Junio C HamanoOct 27, 2015
  11. Junio C HamanoOct 27, 2015
  12. Junio C HamanoOct 27, 2015
  13. Johannes SchindelinOct 30, 2015
  14. Pat ThoytsNov 9, 2015
  15. Johannes SchindelinNov 16, 2015
  16. Junio C HamanoNov 18, 2015
  17. 3/6 Facilitate debugging Git executables in tests with gdbJohannes Schindelin, Oct 26, 2015
  18. Jonathan NiederOct 26, 2015
  19. Johannes SchindelinOct 27, 2015
  20. Junio C HamanoOct 27, 2015
  21. Jeff KingOct 27, 2015
  22. Stefan BellerOct 27, 2015
  23. Jeff KingOct 27, 2015
  24. Johannes SchindelinOct 30, 2015
  25. Jeff KingOct 30, 2015
  26. Johannes SchindelinOct 30, 2015
  27. Junio C HamanoOct 30, 2015
  28. Jonathan NiederOct 30, 2015
  29. Johannes SchindelinOct 30, 2015
  30. Jeff KingOct 30, 2015
  31. Jonathan NiederOct 30, 2015
  32. Junio C HamanoOct 30, 2015
  33. Johannes SchindelinOct 30, 2015
  34. Jonathan NiederOct 30, 2015
  35. Duy NguyenOct 27, 2015
  36. Junio C HamanoOct 29, 2015
  37. Victor LeschukOct 29, 2015
  38. Johannes SchindelinOct 30, 2015
  39. Victor LeschukNov 1, 2015
  40. Johannes SchindelinNov 1, 2015
  41. 4/6 Squelch warning about an integer overflowJohannes Schindelin, Oct 26, 2015
  42. Junio C HamanoOct 26, 2015
  43. Johannes SchindelinOct 30, 2015
  44. Junio C HamanoOct 30, 2015
  45. 5/6 Silence GCC's "cast of pointer to integer of a different size" warningJohannes Schindelin, Oct 26, 2015
  46. Junio C HamanoOct 26, 2015
  47. 6/6 Correct fscanf formatting string for I64u valuesJohannes Schindelin, Oct 26, 2015
  48. Junio C HamanoOct 26, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.