-
Notifications
You must be signed in to change notification settings - Fork 763
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: debugging session terminates before the debugee finishes its exit job #2137
Comments
I see you also asked at https://stackoverflow.com/questions/71602708/what-os-signal-does-the-vscode-go-debugger-send-to-delve-dap-when-i-terminate-de, and I suspect that the advice there is accurate. @polinasok or @suzmue might know if it is possible to catch the debugger exit. |
Yeah I also asked at stackoverflow and got some advice which however actually do not solve my problem. I still want to know if there's any way to figure it out. |
@ztibeike In theory you need to start a headless dlv server in a terminal and connect to it with a client. In that terminal, the debuggee will be foregrounded, so it can receive the signals. It looks like when that happens vscode-go both with legacy and with dlv-dap adapter does the wrong thing. Execution is paused on an error and the rest of the code doesn't get executed. I need to debug a bit more to understand why this happens. In the meantime, you can use dlv terminal client instead:
|
@polinasok Thanks a lot! It works! Instead of manually running "dlv debug ...", I configure a pre-launch-task in tasks.json to start the debug mode of delve server as below. // tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "start dlv",
"type": "shell",
"command": "/root/go/bin/dlv",
"isBackground": true,
"args": [
"debug",
"${workspaceFolder}/main.go",
"--headless",
"--listen=:54321",
"--check-go-version=false",
"--api-version=2"
]
}
]
} Then attach to it . I think it's more efficient. But there's still a little problem as you got, I can catch the exit and run the rest of code by pressing "ctrl+c", but can't to do so by clicking the UI button. The error log is:
I think the debugger just shut down it's listening port to close the connection, then delve server crashes, the golang program exit along with the delve. |
I've found that such prelaunch task is unnecessary. I can get the same result when I set "request" to "launch" and "console" to "integratedTerminal" in launch.json . |
Good to hear that |
@polinasok pointed out the issue is not resolved. We need to investigate what causes Seems similar to #120 (even though the original issue was open when we were using legacy debug adapter). |
yeah, i always got the error |
I want to capture the OS signal and do some exit jobs when I terminate the vscode golang debugger.
I have code as below:
but it doesn't work. Anyone can tell me how to figure it out? Maybe the signal type is not SIGINT or SIGTERM?
The text was updated successfully, but these errors were encountered: