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

Re: contrib/vscode/: debugging with vscode and gdb

From
Derrick Stolee <derrickstolee@github.com>
Date
Mar 25, 2022, 13:19 UTC
Message-ID
<f6afa542-cd97-2af9-a07f-6c2a3721a200@github.com>
In-Reply-To
<CANteD_wDSRmwLQiYV1x133WEtVaRK__c584E3CbXN1tPOquitg@mail.gmail.com>
On 3/24/2022 4:16 AM, Jonathan Bressat wrote:
Show 7 quoted lines
> Hello
> In contrib/vscode/ the script init.sh create launch.json with the
> option "external console" to true but actually this option make gdb
> didn't work so we passed to false and then it works.
> Is there any reasons why it is set to true, do we not use this properly ?
> Then would it be nice to correct it in contrib/vscode and to talk
> about it in that doc : https://git-scm.com/docs/MyFirstContribution ?
Hi Jonathan and Guillaume,

I use VS Code to work on Git (using Remote SSH from a Windows machine to a Linux machine) but I've always used command-line gdb for debugging.

However, your request here got me interested. I confirmed that running the debugger from the VS Code UI did not show any output or show that a breakpoint was hit. Performing the update you recommend made the debuggin UI populate with all the necessary info (stack trace, variables, showing the breakpoint line in the editor).

Here is a patch that makes the change as you suggest. I tried to research the setting appropriately, so please let me know if there is anything you think is incorrect here.

Thanks, -Stolee

--- >8 ---
From b053b797cf8585d2b0212cd2576fe05c2d1a5432 Mon Sep 17 00:00:00 2001
From: Derrick Stolee <derrickstolee@github.com>
Date: Fri, 25 Mar 2022 09:07:11 -0400
Subject: [PATCH] contrib/vscode: fix interaction with UI debugger

The contrib/vscode/init.sh script helps Git developers using Visual Studio Code to hook up the proper settings to work on Git using the UI features of that editor environment. This should include the debugger integration, but that is currently broken.

One thing this script does is create a .vscode/launch.json file, which provides the information for how VS Code should launch the built executable. This defaults to the Git executable at the root of the repository (with no arguments). Among the initial settings, the "externalConsole" setting is set to "true". This has been the case since the script was created in 54c06c6013 (contrib: add a script to initialize VS Code configuration, 2018-07-30).

Jonathan and Guillame reported that flipping this setting to "false" allows the VS Code debugger to work with Git. I verified that the debugger did not work by default but now does with this change.

The VS Code reference [1] mentions that this setting is only used when debugging, so should not affect the "Run Without Debugging" feature. Other than making the UI debugger work, this will also change the Git output to appear in the "Debug Console" tab instead of a new window.

[1] https://code.visualstudio.com/docs/cpp/launch-json-reference

In cases such as using the Remote SSH capability, this setting is necessary to have any success executing Git via the "Run" menu, since the external console is not visible at all from the VS Code window.

Reported-by: Jonathan Bressat <git.jonathan.bressat@gmail.com>
Reported-by: Cogoni Guillaume <cogoni.guillaume@gmail.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 contrib/vscode/init.sh  |  2 +-
 t/test-lib-functions.sh | 34 ----------------------------------
 2 files changed, 1 insertion(+), 35 deletions(-)
diff --git a/contrib/vscode/init.sh b/contrib/vscode/init.sh
index 27de94994b5..0b7ebc12668 100755
--- a/contrib/vscode/init.sh
+++ b/contrib/vscode/init.sh
@@ -271,7 +271,7 @@ cat >.vscode/launch.json.new <<EOF ||
             "stopAtEntry": false,
             "cwd": "\${workspaceFolder}",
             "environment": [],
-            "externalConsole": true,
+            "externalConsole": false,
             "MIMode": "gdb",
             "miDebuggerPath": "$GDBPATH",
             "setupCommands": [
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 8f0e5da8727..2501fc5706f 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1788,40 +1788,6 @@ test_subcommand () {
 	fi
 }
 
-# Check that the given command was invoked as part of the
-# trace2-format trace on stdin, but without an exact set of
-# arguments.
-#
-#	test_subcommand [!] <command> <args>... < <trace>
-#
-# For example, to look for an invocation of "git pack-objects"
-# with the "--honor-pack-keep" argument, use
-#
-#	GIT_TRACE2_EVENT=event.log git repack ... &&
-#	test_subcommand git pack-objects --honor-pack-keep <event.log
-#
-# If the first parameter passed is !, this instead checks that
-# the given command was not called.
-#
-test_subcommand_inexact () {
-	local negate=
-	if test "$1" = "!"
-	then
-		negate=t
-		shift
-	fi
-
-	local expr=$(printf '"%s",' "$@")
-	expr="${expr%,}.*"
-
-	if test -n "$negate"
-	then
-		! grep "\"event\":\"child_start\".*\[$expr\]"
-	else
-		grep "\"event\":\"child_start\".*\[$expr\]"
-	fi
-}
-
 # Check that the given command was invoked as part of the
 # trace2-format trace on stdin.
 #
-- 
2.35.1.138.gfc5de29e9e6
Previous: Jonathan BressatNext: Matthieu Moy
Message 2 of 24 in “contrib/vscode/: debugging with vscode and gdb”
  1. Jonathan BressatMar 24, 2022
  2. Derrick StoleeMar 25, 2022
  3. Matthieu MoyMar 25, 2022
  4. Derrick StoleeMar 25, 2022
  5. Jonathan BressatMar 26, 2022
  6. Guillaume CogoniApr 3, 2022
  7. Matthieu MoyApr 5, 2022
  8. 0/1 contrib/vscode/: debugging with VS Code and gdbCOGONI Guillaume, Apr 5, 2022
  9. 1/1 contrib/vscode/: debugging with VS Code and gdbCOGONI Guillaume, Apr 5, 2022
  10. Ævar Arnfjörð BjarmasonApr 6, 2022
  11. Matthieu MoyApr 6, 2022
  12. Matthieu MoyApr 6, 2022
  13. 0/1 contrib/vscode/: debugging with VS Code and gdbCOGONI Guillaume, Apr 6, 2022
  14. 1/1 contrib/vscode/: debugging with VS Code and gdbCOGONI Guillaume, Apr 6, 2022
  15. Derrick StoleeApr 6, 2022
  16. Junio C HamanoApr 6, 2022
  17. 0/1 contrib/vscode/: debugging with VS Code and gdbCOGONI Guillaume, Apr 6, 2022
  18. 1/1 contrib/vscode/: debugging with VS Code and gdbCOGONI Guillaume, Apr 6, 2022
  19. Ævar Arnfjörð BjarmasonApr 7, 2022
  20. Derrick StoleeApr 7, 2022
  21. Junio C HamanoApr 7, 2022
  22. 0/1 contrib/vscode/: debugging with VS Code and gdbCOGONI Guillaume, Apr 7, 2022
  23. 1/1 contrib/vscode/: debugging with VS Code and gdbCOGONI Guillaume, Apr 7, 2022
  24. Matthieu MoyApr 7, 2022

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.