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

Re: [PATCHv3] refs.c: enable large transactions

From
Jeff King <peff@peff.net>
Date
Apr 25, 2015, 05:24 UTC
Message-ID
<20150425052427.GA20653@peff.net>
In-Reply-To
<20150425050058.GA20256@peff.net>
On Sat, Apr 25, 2015 at 01:00:58AM -0400, Jeff King wrote:
Show 18 quoted lines
> A better solution to what I proposed earlier is perhaps:
> 
>   git config alias.debug '!gdb --quiet \
> 	    -ex "break exit" \
> 	    -ex "run" \
> 	    -ex "bt full" \
> 	    -ex "continue" \
> 	    -ex "quit" \
> 	    --args git \
>   '
>   git debug rev-parse foobar
> 
> It has the minor irritation that gdb will control the process stdio
> (slurping from stdin and polluting stdout, whereas we would prefer no
> input and output to stderr). There might be a way to convince gdb to do
> otherwise, or you could probably go pretty far with some shell fd
> redirects and using "set args" inside gdb. Or maybe something with
> gdbserver.

Just to extend the thought exercise, here is something marginally less horrible. Save as "git-debug" in your PATH and chmod +x.

-- >8 -- #!/bin/sh

if ! type gdb >/dev/null 2>&1; then
	echo >&2 "Sorry, you don't seem to have gdb installed."
	exit 1
fi
args=
for i in "$@"; do
	args="$args '$(printf '%s' "$i" | sed "s/'/'\\\\''/")'"
done
gdb --quiet \
	-ex "set args $args <&7 >&8 2>&9" 7<&0 8>&1 9>&2 </dev/null >&2 \
	-ex 'break exit' \
	-ex 'run' \
	-ex 'bt full' \
	-ex 'continue' \
	-ex 'quit' \
	git
-- 8< --

It's still rather hard to use with sub-programs started by git (e.g., the upload-pack spawned by a fetch), but I think it would work for many simple cases. I'm not sure if I would use it myself. As somebody confident in using gdb, my next step after seeing the backtrace would be to start poking around interactively. Besides the stdio magic, this is not really buying me much beyond running gdb myself.

-Peff
Previous: Jeff King
Message 12 of 12 in “[PATCHv3] refs.c: enable large transactions”
  1. Stefan BellerApr 22, 2015
  2. Junio C HamanoApr 23, 2015
  3. Stefan BellerApr 24, 2015
  4. Junio C HamanoApr 24, 2015
  5. Stefan BellerApr 24, 2015
  6. Jeff KingApr 24, 2015
  7. Jonathan NiederApr 24, 2015
  8. Stefan BellerApr 24, 2015
  9. Jeff KingApr 24, 2015
  10. Junio C HamanoApr 25, 2015
  11. Jeff KingApr 25, 2015
  12. Jeff KingApr 25, 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.