Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Debug Attach doesn't work #1599

Closed
caibirdme opened this issue Mar 29, 2018 · 26 comments
Closed

Debug Attach doesn't work #1599

caibirdme opened this issue Mar 29, 2018 · 26 comments
Assignees
Labels

Comments

@caibirdme
Copy link

If you have a question, please ask it on https://gitter.im/Microsoft/vscode-go or on the VSCode channel in Gophers Slack(https://invite.slack.golangbridge.org/)

If you have issues around GOPATH, read https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension first.

If you have issues debugging your Go programs

If this is a bug report, please share

  • a sample code which can be used to reproduce the issue
  • any Go related settings you might have added/changed

Steps to Reproduce:

  1. set launch.json
        {
            "name": "Attach",
            "type": "go",
            "request": "attach",
            "mode": "remote",
            "remotePath": "${workspaceRoot}",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}",
            "env": {},
            "args": [],
            "showLog": true
        }
  1. go build && run
  2. get pid && dlv attach pid --headless --listen=:2345 --log
  3. in VSCode, Click begin debug button
  4. Next button isn't available

report

6. change launch.json from "request":"attach" to "request":"launch", everything wil be OK but 7. Everytime I stop the debugging, it also stop the process which is not the same as attach
@AlexRouSg
Copy link

Next is not available cause the program didn't hit a breakpoint, and it didn't hit a breakpoint cause it was already running when you attached and so it missed the first few breakpoints and so the first breakpoint it will hit from the screenshot is line 13 which will only hit when you send a http request after attatching.

@caibirdme
Copy link
Author

caibirdme commented Mar 29, 2018

@AlexRouSg Yes I know it and I did send a request via curl xxxxx and didn't get any response. So I think it might be blocked at somewhere. But In VSCode nothing happened, and the next button was still unavailable

@caibirdme
Copy link
Author

Maybe something related to this?
My VSCode version 1.21.1, vscode-go version 0.6.77
invalid

@AlexRouSg
Copy link

From: https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code#remote-debugging
It says for remote debugging, request is still "launch"

@AlexRouSg
Copy link

So after some checking I found the source of your issue. The problem is not that attach doesn't work, it works just fine. The problem is that you are expecting attach to leave the program running after stopping debug while vscode-go is killing the program.

So to fix this, vscode-go needs to call the "detatch" function instead of the "halt" function on mode remote and maybe add request attach to mean leave program running after stopping debugger.

@caibirdme
Copy link
Author

@AlexRouSg Thanks very much, it is. As so far the only available value of "request" is "launch", and I think it'll be better to add it into the wiki.

@ramya-rao-a
Copy link
Contributor

Sorry for getting to this a little late...

@caibirdme

  • Yes, attach is not a valid mode to use. Can you also add "trace": "verbose" to your debug configuration and share the output. There we can see if the breakpoints were created successfully or not as well as more details
  • Are you able to attach to your program using dlv but not in headless mode and then send requests to create breakpoints, followed by curl to actually hit the breakpoint?

@AlexRouSg

The problem is that you are expecting attach to leave the program running after stopping debug while vscode-go is killing the program.

Nothing in @caibirdme's description talks about issues after stopping debug. Can you elaborate on this?

@AlexRouSg
Copy link

AlexRouSg commented Aug 16, 2018

@ramya-rao-a

Sorry for being vague, from reading the delve docs and source code of the plugin, I found out that the plugin was sending the "halt" command to delve which kills the program. Where if it sent the "detach" command, it would've left the program running.

It's been so long since then I cannot remember where I found the relevant code/docs sorry.

@AlexRouSg
Copy link

Ohh might have misunderstood what you were asking.

He basically said

Everytime I stop the debugging, it also stop the process which is not the same as attach

Which means, he wants the process to remain running after stopping the debugger. i.e. for the plugin to "detach" instead of "halt"

@ramya-rao-a
Copy link
Contributor

Ah! I missed that, thanks.
We can use #1609 to track halt vs detach when remote debugging.

@caibirdme
Copy link
Author

@ramya-rao-a , It's a problem that if I use {"request":"launch"} to start a remote debuging, everytime I stops it, it kills the process. But If I use {"request":"attach"}, it doesn't work. I hope I can attach to a remote process and detach it without killing it

@ramya-rao-a
Copy link
Contributor

@caibirdme When you use {"request":"launch"} to start remote debugging, are you using {"mode": "remote"} as well?

@vscodebot vscodebot bot closed this as completed Aug 28, 2018
@vscodebot
Copy link

vscodebot bot commented Aug 28, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. Thank you for your contributions.

@quoctruong
Copy link
Contributor

@ramya-rao-a Can I ask whether there is any update on this?

@ramya-rao-a
Copy link
Contributor

@quoctruong there is an open PR for this, I will definitely get to it this month.

@vscodebot vscodebot bot closed this as completed Dec 16, 2018
@vscodebot
Copy link

vscodebot bot commented Dec 16, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. Thank you for your contributions.

@caibirdme
Copy link
Author

@caibirdme When you use {"request":"launch"} to start remote debugging, are you using {"mode": "remote"} as well?

@ramya-rao-a Yes I did

@quoctruong
Copy link
Contributor

@ramya-rao-a Any update on this issue?

@ramya-rao-a
Copy link
Contributor

No updates at the moment

@quoctruong
Copy link
Contributor

@ramya-rao-a Is there any new update on this? I see that @BetaXOi has a PR for this fix.

@ramya-rao-a
Copy link
Contributor

We have targeted quite a few debug related features and bug fixes for the next update that I plan to release in a few days.

This issue is in track for the next set of debug related features and bug fixes that we will be targeting.
So, we should have an update in February.

Thanks for your patience!

cc @jhendrixMSFT

@jhendrixMSFT jhendrixMSFT self-assigned this Jan 30, 2019
@quoctruong
Copy link
Contributor

@ramya-rao-a @jhendrixMSFT Sorry for constantly pinging but is this issue still on track to be addressed in the next release?

@jhendrixMSFT
Copy link
Member

@quoctruong sorry for the delay. My hope is to have this fixed in the release for the month of March.

@quoctruong
Copy link
Contributor

@jhendrixMSFT Thanks for the update!

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Mar 13, 2019

@quoctruong, @iantalarico and @pongad Please feel free to review the PR #2125 for this feature

@ramya-rao-a
Copy link
Contributor

The attach feature is now available in the latest update (0.11.0) to the Go extension.
See https://github.com/microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code for details

@vscodebot vscodebot bot locked and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants