git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using Visual Studio Code to Debug/Trace Git?
@ 2025-01-10 17:11 Jon Forrest
  2025-01-10 20:38 ` Ben Knoble
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Forrest @ 2025-01-10 17:11 UTC (permalink / raw)
  To: git

I'm interested in using Visual Studio Code to help understand
how git works. I'm thinking it would make it easy to see what
actually happens when git commands are run.

What I don't know is how to integrate git's build system into
Visual Studio Code. Has anybody tried this? If not, what tools
do you use to debug git?

Please note that I'm *not* interested in running git from
Visual Studio Code. That's another topic entirely that seems
to be well covered on the Web.

Cordially,
Jon Forrest



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using Visual Studio Code to Debug/Trace Git?
  2025-01-10 17:11 Using Visual Studio Code to Debug/Trace Git? Jon Forrest
@ 2025-01-10 20:38 ` Ben Knoble
  2025-01-13  8:04   ` Patrick Steinhardt
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Knoble @ 2025-01-10 20:38 UTC (permalink / raw)
  To: Jon Forrest; +Cc: git


> 
> Le 10 janv. 2025 à 12:16, Jon Forrest <nobozo@gmail.com> a écrit :
> 
> I'm interested in using Visual Studio Code to help understand
> how git works. I'm thinking it would make it easy to see what
> actually happens when git commands are run.
> 
> What I don't know is how to integrate git's build system into
> Visual Studio Code. Has anybody tried this? If not, what tools
> do you use to debug git?

AFAIK, it’s make (with some autoconf stuff) and C debuggers like gdb/lldb. But maybe someone has a better answer. I’d expect VS Code to support this pretty easily.

Best,
D. Ben Knoble

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using Visual Studio Code to Debug/Trace Git?
  2025-01-10 20:38 ` Ben Knoble
@ 2025-01-13  8:04   ` Patrick Steinhardt
  2025-01-13 17:03     ` Jon Forrest
  2025-02-12 18:32     ` Jon Forrest
  0 siblings, 2 replies; 5+ messages in thread
From: Patrick Steinhardt @ 2025-01-13  8:04 UTC (permalink / raw)
  To: Ben Knoble; +Cc: Jon Forrest, git

On Fri, Jan 10, 2025 at 03:38:51PM -0500, Ben Knoble wrote:
> 
> > 
> > Le 10 janv. 2025 à 12:16, Jon Forrest <nobozo@gmail.com> a écrit :
> > 
> > I'm interested in using Visual Studio Code to help understand
> > how git works. I'm thinking it would make it easy to see what
> > actually happens when git commands are run.
> > 
> > What I don't know is how to integrate git's build system into
> > Visual Studio Code. Has anybody tried this? If not, what tools
> > do you use to debug git?
> 
> AFAIK, it’s make (with some autoconf stuff) and C debuggers like
> gdb/lldb. But maybe someone has a better answer. I’d expect VS Code to
> support this pretty easily.

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.

Patrick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using Visual Studio Code to Debug/Trace Git?
  2025-01-13  8:04   ` Patrick Steinhardt
@ 2025-01-13 17:03     ` Jon Forrest
  2025-02-12 18:32     ` Jon Forrest
  1 sibling, 0 replies; 5+ messages in thread
From: Jon Forrest @ 2025-01-13 17:03 UTC (permalink / raw)
  To: Patrick Steinhardt, Ben Knoble; +Cc: git



On 1/13/25 12:04 AM, Patrick Steinhardt wrote:

> 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using Visual Studio Code to Debug/Trace Git?
  2025-01-13  8:04   ` Patrick Steinhardt
  2025-01-13 17:03     ` Jon Forrest
@ 2025-02-12 18:32     ` Jon Forrest
  1 sibling, 0 replies; 5+ messages in thread
From: Jon Forrest @ 2025-02-12 18:32 UTC (permalink / raw)
  To: Patrick Steinhardt, Ben Knoble; +Cc: git

Just to follow up on this, I've had surprising success by
simply building git the normal way (e.g. make),
having VSCode open the directory contain the Git source
code, opening common-main.c, and then executing "Start Debugging".
I'm able to do full source-level debugging this way.

I'm not entirely sure why this works but it's good enough
for me.

I'll be interested in seeing if the new Meson build system
works any better in VSCode.

Cordially,
Jon Forrest


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-02-12 18:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10 17:11 Using Visual Studio Code to Debug/Trace Git? Jon Forrest
2025-01-10 20:38 ` Ben Knoble
2025-01-13  8:04   ` Patrick Steinhardt
2025-01-13 17:03     ` Jon Forrest
2025-02-12 18:32     ` Jon Forrest

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).