vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

debug: show only user goroutines by default

Open hyangah opened this issue 4 years ago • 6 comments

Discussed in https://github.com/golang/vscode-go/discussions/1754

Originally posted by suzmue September 7, 2021 Using a debugger to debug a Go program reveals a lot of the Go runtime implementation details to the user. Several goroutines that belong to the runtime appear in the call stack, cluttering the view and making a simple program seem very complicated.

For example when debugging a simple hello world program, 5 different goroutines appear in the callstack: Program stopped on a breakpoint in main.go: Screen Shot 2021-09-03 at 2 28 41 PM

Call stack: Screen Shot 2021-09-03 at 2 28 48 PM

This proposal is to (by default) only show the user goroutines in the call stack. When using this new default, the call stack for hello world will only show a single goroutine, as would be expected from a simple program with no concurrency:

Screen Shot 2021-09-07 at 12 36 41 PM

This would be controlled by a setting to allow users that really want to see the system goroutines to include them using the launch configuration.

hyangah avatar Sep 22 '21 22:09 hyangah

https://go-review.googlesource.com/c/vscode-go/+/359402 was submitted to enable this in Nightly

suzmue avatar Oct 28 '21 20:10 suzmue

Should we enable this in the stable release?

polinasok avatar Apr 07 '22 18:04 polinasok

Is there a way to enable this by default for all debugging sessions? 90% of my debugging is done via tests - I'd really like to be able to enable this when debugging a test, without having to create a launch.json entry for the test.

firelizzard18 avatar Apr 25 '23 20:04 firelizzard18

Change https://go.dev/cl/534955 mentions this issue: package.json: allow updating hideSystemGoroutines from stack context

gopherbot avatar Oct 12 '23 16:10 gopherbot

@firelizzard18 sorry for the delay but adding the hideSystemGoroutines to the user settings in go.delveConfig should do this for all tests:

"go.delveConfig": {
  "hideSystemGoroutines": true
}

Added the feature to be able to toggle the threads from the context menu:

Screenshot 2023-10-13 at 1 10 06 PM

suzmue avatar Oct 13 '23 20:10 suzmue

@suzmue Is there any extra work you planned to do during this cycle? cl/534955 made the feature accessible. Do you want to hide the system goroutines by default?

hyangah avatar Oct 31 '23 16:10 hyangah