Skip to content

Add a page with hints about debugging Git #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
phil-blain opened this issue Jun 2, 2020 · 5 comments
Closed

Add a page with hints about debugging Git #435

phil-blain opened this issue Jun 2, 2020 · 5 comments

Comments

@phil-blain
Copy link
Contributor

Could start with:
gitgitgadget/git#582 (comment)

Hi @ParthGala2k !

Also I'm having trouble running the program on gdb, is there any reference for that?

The CodingGuidelines document also has some guidance for using the system-installed GDB.

If you compiled GDB yourself you will need to invoke it like this:

GIT_DEBUGGER="/path/to/gdb --args" ./bin-wrappers/git <command> <args...>

I you are on macOS and want to use LLDB, that would be:

GIT_DEBUGGER="lldb --" ./bin-wrappers/git <command> <args...>

Sometimes Git command spawn other Git commands under the hood, using fork+exec. You will recognize this by a call to either run_command or more rarely directly to start_command.

If the code your are trying to debug is in an instance of git spawned (fork+exec) by the main git process, you will need to use the set detach-on-fork off option in GDB, which works on Linux but not on macOS (I don't know about anything about Windows). I had success doing that on Ubuntu 17.10 using a self-compiled GDB 8.3.1, but not with the system-installed GDB 7.1.2.

Another option is to put a call to sleep() just after the fork in start_command, then open another instance of GDB and attach to the new process, e.g. with

gdb -p $(pgrep -n git)

Then you can control both instances independently.

Addendum: there is also some interesting guidelines on the old wiki, that might still be useful for debugging tests: https://git.wiki.kernel.org/index.php/What_to_do_when_a_test_fails

maybe also add pointers to configure VScode for debugging.

also : gitgitgadget/git#582 (comment)

also of interest: https://github.com/git-for-windows/git/wiki/Debugging-Git

@chriscool
Copy link
Collaborator

You are welcome to start such a page! What is in your above comment is a good starting point, so I encourage you to contribute it!

@phil-blain
Copy link
Contributor Author

thanks @chriscool. I might get to this some day. I guess another question is does it make sense to put some of that info in git.git somewhere...

@chriscool
Copy link
Collaborator

@chriscool
Copy link
Collaborator

@phil-blain feel free to contribute to the above page :-)

@chriscool
Copy link
Collaborator

Let's close this for now and maybe open more specific issues to improve the above page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants