{"thread":{"id":"62782","subject":"Using Visual Studio Code to Debug/Trace Git?","startedAt":"2025-01-10T17:16:26Z","lastAt":"2025-02-12T18:32:07Z","messageCount":5,"participants":["Jon Forrest","Ben Knoble","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"510333","messageId":"vlrkbd$a0r$1@ciao.gmane.io","threadId":"62782","inReplyTo":null,"subject":"Using Visual Studio Code to Debug/Trace Git?","fromName":"Jon Forrest","fromEmail":"nobozo@gmail.com","sentAt":"2025-01-10T17:11:09Z","receivedAt":"2025-01-10T17:16:26Z","isPatch":false,"sender":{"key":"nobozo@gmail.com","avatar":"https://gravatar.com/avatar/37c6a7b57f29b3f35c6a9016537907c52f15bbf98575617dc046bcec6bf06372?d=mp&s=160"},"body":"I'm interested in using Visual Studio Code to help understand\nhow git works. I'm thinking it would make it easy to see what\nactually happens when git commands are run.\n\nWhat I don't know is how to integrate git's build system into\nVisual Studio Code. Has anybody tried this? If not, what tools\ndo you use to debug git?\n\nPlease note that I'm *not* interested in running git from\nVisual Studio Code. That's another topic entirely that seems\nto be well covered on the Web.\n\nCordially,\nJon Forrest\n\n\n"},{"id":"510342","messageId":"A53D82B2-4F5F-4BCA-9C85-88B2A89139DC@gmail.com","threadId":"62782","inReplyTo":"vlrkbd$a0r$1@ciao.gmane.io","subject":"Re: Using Visual Studio Code to Debug/Trace Git?","fromName":"Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-01-10T20:38:51Z","receivedAt":"2025-01-10T20:39:04Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"\n> \n> Le 10 janv. 2025 à 12:16, Jon Forrest <nobozo@gmail.com> a écrit :\n> \n> ﻿I'm interested in using Visual Studio Code to help understand\n> how git works. I'm thinking it would make it easy to see what\n> actually happens when git commands are run.\n> \n> What I don't know is how to integrate git's build system into\n> Visual Studio Code. Has anybody tried this? If not, what tools\n> do you use to debug git?\n\nAFAIK, 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.\n\nBest,\nD. Ben Knoble"},{"id":"510391","messageId":"Z4TJIzVc4Ib2QyPV@pks.im","threadId":"62782","inReplyTo":"A53D82B2-4F5F-4BCA-9C85-88B2A89139DC@gmail.com","subject":"Re: Using Visual Studio Code to Debug/Trace Git?","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-13T08:04:59Z","receivedAt":"2025-01-13T08:05:05Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Jan 10, 2025 at 03:38:51PM -0500, Ben Knoble wrote:\n> \n> > \n> > Le 10 janv. 2025 à 12:16, Jon Forrest <nobozo@gmail.com> a écrit :\n> > \n> > ﻿I'm interested in using Visual Studio Code to help understand\n> > how git works. I'm thinking it would make it easy to see what\n> > actually happens when git commands are run.\n> > \n> > What I don't know is how to integrate git's build system into\n> > Visual Studio Code. Has anybody tried this? If not, what tools\n> > do you use to debug git?\n> \n> AFAIK, it’s make (with some autoconf stuff) and C debuggers like\n> gdb/lldb. But maybe someone has a better answer. I’d expect VS Code to\n> support this pretty easily.\n\nThere are two ways to realize what you want right now:\n\n  - Import the CMake build instructions that we have in\n    \"contrib/buildsystems\". It has existed for a rather long time, but\n    is not an officially supported way to build Git. It's also lacking a\n    couple of features that you can expect from our Makefile, like\n    building docs. It may be good enough though.\n\n  - Generate a Visual Studio solution via Meson by installing Meson and\n    then running `meson setup --backend=vs2022 build-msvc`. This has\n    only landed in Git v2.48 and is thus really new. As such it is still\n    marked experimental, but will become an official way to build Git\n    and is more feature complete.\n\nI'm aware of an issue with Visual Studio right now though when using it\nwith Meson that keeps it from working -- I'll send a patch series later\ntoday to fix that issue, and then it should be a good way to build Git\non Windows via MSVC.\n\nPatrick\n"},{"id":"510434","messageId":"b94df609-372e-4227-8674-a05a67161a15@gmail.com","threadId":"62782","inReplyTo":"Z4TJIzVc4Ib2QyPV@pks.im","subject":"Re: Using Visual Studio Code to Debug/Trace Git?","fromName":"Jon Forrest","fromEmail":"nobozo@gmail.com","sentAt":"2025-01-13T17:03:05Z","receivedAt":"2025-01-13T17:03:07Z","isPatch":false,"sender":{"key":"nobozo@gmail.com","avatar":"https://gravatar.com/avatar/37c6a7b57f29b3f35c6a9016537907c52f15bbf98575617dc046bcec6bf06372?d=mp&s=160"},"body":"\n\nOn 1/13/25 12:04 AM, Patrick Steinhardt wrote:\n\n> There are two ways to realize what you want right now:\n> \n>    - Import the CMake build instructions that we have in\n>      \"contrib/buildsystems\". It has existed for a rather long time, but\n>      is not an officially supported way to build Git. It's also lacking a\n>      couple of features that you can expect from our Makefile, like\n>      building docs. It may be good enough though.\n> \n>    - Generate a Visual Studio solution via Meson by installing Meson and\n>      then running `meson setup --backend=vs2022 build-msvc`. This has\n>      only landed in Git v2.48 and is thus really new. As such it is still\n>      marked experimental, but will become an official way to build Git\n>      and is more feature complete.\n> \n> I'm aware of an issue with Visual Studio right now though when using it\n> with Meson that keeps it from working -- I'll send a patch series later\n> today to fix that issue, and then it should be a good way to build Git\n> on Windows via MSVC.\n\nThanks for your thoughtful reply. I'll look into what you describe.\n\nIn the mean time, I've discovered another method that seems\nto be working, for the very limited execution tracing I'm\ndoing. What I do, on Fedora 41 Workstation, is to build\nGit from source using the standard method. This has the side\neffect of generating various .h files that themselves aren't\npart of the distribution. Then, using Visual Studio Code,\nI open the Git source directory, open common-main.c, and then\nset a breakpoint at main(). I can then click on Run->Start Debugging\nwhich starts git and breaks at main(). From there I can set whatever\nadditional breakpoints I want.\n\nThis method has allowed me to trace various things but I'm not sure\nif it's a complete solution, especially when forking new processes\nor using threads. The one very minor problem I've noticed so far\nis that the executable file generated by VSC isn't called 'git'.\n\nI welcome corrections or comments.\n\nI hope this helps other people.\n\nCordially,\nJon Forrest\n\n"},{"id":"512327","messageId":"09049b05-ed3f-4673-9d10-34870a70e2b3@gmail.com","threadId":"62782","inReplyTo":"Z4TJIzVc4Ib2QyPV@pks.im","subject":"Re: Using Visual Studio Code to Debug/Trace Git?","fromName":"Jon Forrest","fromEmail":"nobozo@gmail.com","sentAt":"2025-02-12T18:32:05Z","receivedAt":"2025-02-12T18:32:07Z","isPatch":false,"sender":{"key":"nobozo@gmail.com","avatar":"https://gravatar.com/avatar/37c6a7b57f29b3f35c6a9016537907c52f15bbf98575617dc046bcec6bf06372?d=mp&s=160"},"body":"Just to follow up on this, I've had surprising success by\nsimply building git the normal way (e.g. make),\nhaving VSCode open the directory contain the Git source\ncode, opening common-main.c, and then executing \"Start Debugging\".\nI'm able to do full source-level debugging this way.\n\nI'm not entirely sure why this works but it's good enough\nfor me.\n\nI'll be interested in seeing if the new Meson build system\nworks any better in VSCode.\n\nCordially,\nJon Forrest\n\n"}]}