Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: improve workflow of attaching to process #183

Closed
stamblerre opened this issue Jun 7, 2020 · 8 comments
Closed

debug: improve workflow of attaching to process #183

stamblerre opened this issue Jun 7, 2020 · 8 comments
Labels
Debug Issues related to the debugging functionality of the extension. FeatureRequest FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@stamblerre
Copy link
Contributor

See the original report: microsoft/vscode-go#2780.

Taking note of the PID and updating the launch.json file with it every time I want to attach a debugger is a bit tedious.

Is there a way I could make this a bit easier?

For example, I can get the PID by running:

pidof go

And attach the Delve debugger to the process manually:

dlv attach $(pidof go) --headless --listen=:2345 --api-version=2

And then use the "Connect to server" launch configuration, but then I'll have to detach manually (instead of pressing a button in VS Code).

In the built-in Node.js debugger there's an option to pick a process from a list by specifying ${command:PickProcess} in the processId field. Maybe something similar is possible?

@stamblerre stamblerre added FeatureRequest Debug Issues related to the debugging functionality of the extension. labels Jun 7, 2020
@hyangah hyangah added this to the Backlog milestone Aug 7, 2020
@hyangah hyangah added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 30, 2020
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/287312 mentions this issue: src/pickProcess.ts: add pick process command for local attach

gopherbot pushed a commit that referenced this issue Jan 29, 2021
Add a command to pick a process from the running processes
when attaching to a local process.

This uses the code from the vscode-python extension to parse
the output of 'ps' and 'wmic'.

Updates #183

Change-Id: Ib742dd0ecf0610a9a30fe9d6f86e5ada03c1b388
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/287312
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/287872 mentions this issue: src/pickProcess.ts: add linux cmd for go process

gopherbot pushed a commit that referenced this issue Jan 29, 2021
Add a command that allows the user to pick between
processes that are running Go. This implementation
is only available on linux for now.

Updates #183

Change-Id: Ic7c6e76258cfdeec014021895d447cc826082d53
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/287872
Trust: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/288172 mentions this issue: src/utils/wmicProcessParser.ts: get exe path from wmic

gopherbot pushed a commit that referenced this issue Jan 29, 2021
Get the executable path from the wmic output to be used
to determine if process is running go.

Updates #183

Change-Id: I6894897d8a4744498f14154b03da89110a7ef567
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/288172
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@suzmue suzmue modified the milestones: Backlog, v0.23.0 Feb 1, 2021
@hyangah
Copy link
Contributor

hyangah commented Feb 2, 2021

This feature is available in Go Nightly for testing.

@suzmue If a user does not pick any process from the quick pick menu, I think the extension needs to give up and terminate the debugging session. Currently, it continues and lets the debug adapter start delve with insufficient info and results in crash.

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/288953 mentions this issue: src/goDebugConfiguration.ts: invoke pick process for local attach

gopherbot pushed a commit that referenced this issue Feb 4, 2021
When the processId is undefined or 0 for a local attach debug config,
we automatically invoke the quick pick to allow the user to choose
which process to attach to.

Additionally, we also throw an error when the user does not select a
process, since the debug configuration will fail.

Updates #183

Change-Id: I58c321125c8f96a3219a8ee7639779bea5dca76e
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/288953
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/289909 mentions this issue: src/pickProcess.ts: use lsof to find process exes on darwin

gopherbot pushed a commit that referenced this issue Feb 9, 2021
There is not a standard way to find all of the executable paths
for processes running on darwin os. The options I have found
include:
1. inspecting environment variables
2. using lsof to find files open by the process which includes exe
3. using the libproc.h library

Prototyping 1 revealed that there were many processes missed by this
simple inspection. Implementing 3 involves calling a C library from
our typescript code, or bundling in an executable that does so. These
are possible but were more difficult to implement and messy.

This change implements option 2 and appears when running locally seems
to have found all Go programs (including ones that 1 missed).

The potential downside to this implementation is that running lsof will
take more time.

When running locally with 1000 processes (half Go), pickGoProcess
was definitely usable. Filtering using flags '-Pnl' and '-d txt'
both help with the runtime.

Update #183

Change-Id: I8397f0c942243c6bd2f8941a53ff71ffbc26d28a
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/289909
Trust: Suzy Mueller <suzmue@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/290751 mentions this issue: src/pickProcess.ts: add attach by process name command

gopherbot pushed a commit that referenced this issue Feb 9, 2021
If a user specifies the name of a process, the process picker will
identify the process with the same name. If there is only a single
process that matches, it will automatically choose that pid.
Otherwise, it will show the processes filtered by the process name.

Updates #183

Change-Id: Ibc8cdf41bda6f3f0e3e0b82407f002d7423865b1
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/290751
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/290753 mentions this issue: docs/debugging.md: update documentation for processId

gopherbot pushed a commit that referenced this issue Feb 16, 2021
Update the documentation to include information about the new
features available for picking a processId to attach to.

Update #183

Change-Id: Ifea85a4047e81c0390f5fd0c560545190670f290
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/290753
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@suzmue suzmue closed this as completed Feb 16, 2021
@golang golang locked and limited conversation to collaborators Feb 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Debug Issues related to the debugging functionality of the extension. FeatureRequest FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants