{"thread":{"id":"46995","subject":"How can I debug git source code interactively with debugger like gdb?","startedAt":"2017-10-18T19:42:54Z","lastAt":"2017-10-18T19:57:47Z","messageCount":3,"participants":["小川恭史","Brandon Williams","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"330606","messageId":"CAC2JkrLR=RUN01AeYGd1YpOPMv=kArm9LWGtMvJ7DS5sz7c3nw@mail.gmail.com","threadId":"46995","inReplyTo":null,"subject":"How can I debug git source code interactively with debugger like gdb?","fromName":"小川恭史","fromEmail":"aiueogawa217@gmail.com","sentAt":"2017-10-18T19:42:48Z","receivedAt":"2017-10-18T19:42:54Z","isPatch":false,"sender":{"key":"aiueogawa217@gmail.com","avatar":null},"body":"I wanna learn how daily git command works when I run specific git command.\n\nI wanna know which function is actually called then, how variables\nchanges its value, and how some object is stored into database.\n\nHow can I debug git source code interactively with debugger like gdb?\n"},{"id":"330608","messageId":"20171018195602.GB155019@google.com","threadId":"46995","inReplyTo":"CAC2JkrLR=RUN01AeYGd1YpOPMv=kArm9LWGtMvJ7DS5sz7c3nw@mail.gmail.com","subject":"Re: How can I debug git source code interactively with debugger like gdb?","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-18T19:56:02Z","receivedAt":"2017-10-18T19:56:10Z","isPatch":false,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/19, 小川恭史 wrote:\n> I wanna learn how daily git command works when I run specific git command.\n> \n> I wanna know which function is actually called then, how variables\n> changes its value, and how some object is stored into database.\n> \n> How can I debug git source code interactively with debugger like gdb?\n\nI have had to do this in the past when trying to track down particularly\nnasty bugs.  If you build git from source (you may need to turn on\ndebugging info) you'll be able to find a script '/bin-wrappers/git'\nwhich you can use by making sure the environment variable 'GIT_TEST_GDB'\nis set.  This will launch it under gdb.  For example:\n\n  GIT_TEST_GDB=1 ./bin-wrappers/git status\n\n-- \nBrandon Williams\n"},{"id":"330609","messageId":"CAGZ79kZD4gCBcttU8aTAyb0susP3j1BqnF_ad=EfVXbh+ymbgA@mail.gmail.com","threadId":"46995","inReplyTo":"CAC2JkrLR=RUN01AeYGd1YpOPMv=kArm9LWGtMvJ7DS5sz7c3nw@mail.gmail.com","subject":"Re: How can I debug git source code interactively with debugger like gdb?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-18T19:57:41Z","receivedAt":"2017-10-18T19:57:47Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Oct 18, 2017 at 12:42 PM, 小川恭史 <aiueogawa217@gmail.com> wrote:\n> I wanna learn how daily git command works when I run specific git command.\n\n1. Obtain the sources and compile Git yourself\n    (git clone https://kernel.googlesource.com/pub/scm/git/git\n     cd git && make && make install).\n   Documentation/* and the Makefile are pretty verbose if you want\n   to compile for some non-mainstream hardware or OS.\n2. \"gdb git\" and debug away.\n  Note, that some Git commands call other git commands,\n  So running the command with \"GIT_TRACE=1 git <cmd>\"\n  first may be helpful for diagnosis as well.\n  (See the general git man page that has a couple of env vars\n   that aid in debugging)\n\n> I wanna know which function is actually called then, how variables\n> changes its value, and how some object is stored into database.\n\nFor understanding Gits model, it may be easier to read a book, such\nas \"git from the bottom up\" as that conveys the concepts better.\n\nThe source code is riddled with handling corner cases, error handling\nand other implementation details that are usually not interesting but\nrather tedious.\n\n> How can I debug git source code interactively with debugger like gdb?\n\nAlso checkout ddd, a graphical frontend of gdb.\n\nCheers,\nStefan\n"}]}