Skip to content

add support for debugging child process enabled by delve backend #3712

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

Open
Lslightly opened this issue Mar 12, 2025 · 1 comment
Open

add support for debugging child process enabled by delve backend #3712

Lslightly opened this issue Mar 12, 2025 · 1 comment

Comments

@Lslightly
Copy link
Contributor

Lslightly commented Mar 12, 2025

Problem demo:
The demo repository is Lslightly/delve-dbg-child-proc, where I can debug child process in delve. But I can't debug child process in vscode-go.

Although most go projects are organized as package and support of single process with multiple goroutines is enough, there are projects like golang/go where the cmd/go can invoke cmd/compile tool as the child process. The command arguments passed to cmd/compile tool is complicated. It will be convenient to debug cmd/compile through debugging go build -a . command instead of debugging go tool compile ... ... ... command. So demand of multiple process debugging feature exist.
Besides, this scenario(use case) is different from the client/server architecture which may run the process for a long time and you can connect to the delve server at any time(or make the child process sleep for some seconds).

Related issues and blogs:

Describe the solution you'd like
A clear and concise description of what you want to happen.

  1. Enable target follow-exec -on by default or provide an option to enable child process debug. (--init option of delve is disabled when combining with --headless option)
  2. Allow setting breakpoint whose location is not found yet but will be found in child process. There are some mistakes. See the comment
    • This needs support in delve to answer yes when the breakpoint is not found to set a suspended breakpoint(in delve but not in vscode-go. vscode-go can always set the breakpoint on since there is no side effect).
    • The source code location of yesno decision is pkg/terminal/command.go#L1868
  3. Reuse the Call Stack for debugging child process. (low priority. Since attach remote and substitutePath(I haven't succeeded in using this feature yet) can be used to debug child process in different vscode window.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

I will upload a demo video later.

@gopherbot gopherbot added this to the Untriaged milestone Mar 12, 2025
@Lslightly
Copy link
Contributor Author

Lslightly commented Mar 12, 2025

  1. Allow setting breakpoint whose location is not found yet but will be found in child process.
    • This needs support in delve to answer yes when the breakpoint is not found to set a suspended breakpoint(in delve but not in vscode-go. vscode-go can always set the breakpoint on since there is no side effect).
    • The source code location of yesno decision is pkg/terminal/command.go#L1868

Sorry, I made some mistakes.

  1. vscode-go interacts with service/debugger/debugger.go CreateBreakpoint instead of yesno in pkg/terminal/command.go, which is the terminal client/frontend of delve.

  2. vscode-go successfully set breakpoints whose location is not found through CreateBreakpoint

Delve provides RPCServer.FollowExec which is equal to target follow-exec -on/-off command. However, now vscode-go does not use this API.

The only thing left is to make calling RPCServer.FollowExec possible.

@Lslightly Lslightly changed the title add support for target exec -on to debug child process add support for target follow-exec -on to debug child process Mar 12, 2025
@Lslightly Lslightly changed the title add support for target follow-exec -on to debug child process add support for debugging child process enabled by delve backend Mar 12, 2025
@jba jba modified the milestones: Untriaged, vscode-go/backlog Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants