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

Re: How can I debug git source code interactively with debugger like gdb?

From
Stefan Beller <sbeller@google.com>
Date
Oct 18, 2017, 19:57 UTC
Message-ID
<CAGZ79kZD4gCBcttU8aTAyb0susP3j1BqnF_ad=EfVXbh+ymbgA@mail.gmail.com>
In-Reply-To
<CAC2JkrLR=RUN01AeYGd1YpOPMv=kArm9LWGtMvJ7DS5sz7c3nw@mail.gmail.com>
On Wed, Oct 18, 2017 at 12:42 PM, 小川恭史 <aiueogawa217@gmail.com> wrote:
> I wanna learn how daily git command works when I run specific git command.
1. Obtain the sources and compile Git yourself
    (git clone https://kernel.googlesource.com/pub/scm/git/git
     cd git && make && make install).
   Documentation/* and the Makefile are pretty verbose if you want
   to compile for some non-mainstream hardware or OS.
2. "gdb git" and debug away.
  Note, that some Git commands call other git commands,
  So running the command with "GIT_TRACE=1 git <cmd>"
  first may be helpful for diagnosis as well.
  (See the general git man page that has a couple of env vars
   that aid in debugging)
> I wanna know which function is actually called then, how variables
> changes its value, and how some object is stored into database.

For understanding Gits model, it may be easier to read a book, such as "git from the bottom up" as that conveys the concepts better.

The source code is riddled with handling corner cases, error handling and other implementation details that are usually not interesting but rather tedious.

> How can I debug git source code interactively with debugger like gdb?
Also checkout ddd, a graphical frontend of gdb.

Cheers, Stefan

Previous: Brandon Williams
Message 3 of 3 in “How can I debug git source code interactively with debugger like gdb?”
  1. 小川恭史Oct 18, 2017
  2. Brandon WilliamsOct 18, 2017
  3. Stefan BellerOct 18, 2017

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.