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

Re: Using Visual Studio Code to Debug/Trace Git?

From
Jon Forrest <nobozo@gmail.com>
Date
Jan 13, 2025, 17:03 UTC
Message-ID
<b94df609-372e-4227-8674-a05a67161a15@gmail.com>
In-Reply-To
<Z4TJIzVc4Ib2QyPV@pks.im>
On 1/13/25 12:04 AM, Patrick Steinhardt wrote:
Show 18 quoted lines
> There are two ways to realize what you want right now:
> 
>    - Import the CMake build instructions that we have in
>      "contrib/buildsystems". It has existed for a rather long time, but
>      is not an officially supported way to build Git. It's also lacking a
>      couple of features that you can expect from our Makefile, like
>      building docs. It may be good enough though.
> 
>    - Generate a Visual Studio solution via Meson by installing Meson and
>      then running `meson setup --backend=vs2022 build-msvc`. This has
>      only landed in Git v2.48 and is thus really new. As such it is still
>      marked experimental, but will become an official way to build Git
>      and is more feature complete.
> 
> I'm aware of an issue with Visual Studio right now though when using it
> with Meson that keeps it from working -- I'll send a patch series later
> today to fix that issue, and then it should be a good way to build Git
> on Windows via MSVC.
Thanks for your thoughtful reply. I'll look into what you describe.

In the mean time, I've discovered another method that seems to be working, for the very limited execution tracing I'm doing. What I do, on Fedora 41 Workstation, is to build Git from source using the standard method. This has the side effect of generating various .h files that themselves aren't part of the distribution. Then, using Visual Studio Code, I open the Git source directory, open common-main.c, and then set a breakpoint at main(). I can then click on Run->Start Debugging which starts git and breaks at main(). From there I can set whatever additional breakpoints I want.

This method has allowed me to trace various things but I'm not sure if it's a complete solution, especially when forking new processes or using threads. The one very minor problem I've noticed so far is that the executable file generated by VSC isn't called 'git'.

I welcome corrections or comments.
I hope this helps other people.

Cordially, Jon Forrest

Previous: Patrick SteinhardtNext: Jon Forrest
Message 4 of 5 in “Using Visual Studio Code to Debug/Trace Git?”
  1. Jon ForrestJan 10, 2025
  2. Ben KnobleJan 10, 2025
  3. Patrick SteinhardtJan 13, 2025
  4. Jon ForrestJan 13, 2025
  5. Jon ForrestFeb 12, 2025

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.