Open simon-p-r opened 6 years ago
Tried adding logging to debugger but no events are being captured for this
What did you try?
Can you please post your launch.json
and which type of application you are debugging?
If you want to send Ctrl+c
you probably need to use the terminal that appears and not the debuggerTerminal in VS Code since we aren't hooked up to that yet.
I am using libuv to trap signals, the debugger spawns a separate console but it is not trapping the key signals. I expect it to handle ctrl-c and ctrl-break signals when pressed. I have created a repo with a demo of bug.
Repo is here https://github.com/simon-p-r/vscode-debugger-signal
There's probably an issue relating to this in just about every Windows terminal project. They've been impossible to make work consistently, and I think most people have given up on them until the PTY API is made stable. The only thing that consistently works is finding the hidden console window and sending it WM_KEYDOWN/WM_KEYUP messages.
@simon-p-r I have your repo but I can't figure out how to build. I installed your tool set items below and then ran vcpkg install libuv
, I set the libuv Library path environment variable. and then tried both cmake and cmake-js's builds.
Sorry that was not clear, you need to run build.js script with node. It needs to find version of libuv installed by vcpkg
I've just noticed the same trying to debug a golang issue where the application would hang on signal. Doesn't seem possible to Ctrl-C in the debug console. This is on OSX.
Bump!
First off, shoutout to the VS Code dev team for making such a badass piece of software! It just keeps getting better and the Go support is so lovely. Thanks so much and and sending y'all good vibes! <3
Anyway, yes, I get the complexity around Ctrl+C mysteriously not arriving to a given debug process. However, maybe it's easy/doable to have SIGINT or SIGTERM make it when coming from the OS? Justing being able to execute kill -s SIGTERM 12345
for a daemon running under the VS Code debugger would be awesome. Otherwise, to simulate a SIGINT (ctrl+c), we have to have painful hack in place (and make sure that code never gets committed, etc). As is, sending a SIGTERM, SIGINT, and SIGHUP never show up (via package signal.Notifiy() handler) when the process is running in the VS Code debugger.
Heeeelp! Kindly get this to this lil but helpful thing!
@drew-512 this is the C++ extension. If you are asking for VS Code to support it for Go, you will need to ask either VS Code or the Go extension you are using.
For C++ this is currently on the list of items to tackle.
Bump. Still happens in 1.44.1 on Windows 10 in nodejs environment
Tried this in 1.47.2 on Ubuntu in python environment, and it's still happening.
Hey @pieandcakes, this issue might need further attention.
@simon-p-r, you can help us out by closing this issue if the problem no longer exists, or adding more information.
This issue has been closed automatically because it needs more information and has not had recent activity.
I think this issue should not have been closed, what information is missing?
I believe that vs code or gdb catch the Ctrl+C and instantly kill the application without sending a signal or giving it time to exit gracefully. That is very annoying if you are debugging an app that needs a signal to gracefully shutdown and clean up.
Thanks for letting us know.
I can repro on an aarch64 Ubuntu 18.04 remote. Local client is Ubuntu 20.04 amd64. Vscode version 1.56.2
(snap)
launch.json
configuration is:
{
"name": "(gdb) test sigint",
"type": "cppdbg",
"request": "launch",
"program": "/usr/bin/python3",
"args": [
"${workspaceFolder}/test_sigint.py"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": []
},
test_sigint.py
is
import time
try:
while(True):
time.sleep(1)
except KeyboardInterrupt:
print("success")
When run directly, with gdb --args python3 ...
and i hit ctrl+c, "success" is printed. When I run the configuration in vscode, the script immediately quits.
~/.gdbinit
is:
handle SIGINT nostop print pass
What's frustrating is this was working last week on the same configuration. It appears this may be a recent regression.
Still in an issue in 1.71.0
Code team, please fix!
Still an issue to this day.
@kmansoft @astralmaster please give :+1: to the top post to support this issue. You can also hit the "Subscribe" button in order to get notifications when someone adds a comment. With those two steps done, I'm not sure there is need to leave a comment and notify everyone that this issue is still present. I believe everyone here is quite aware of that.
I am using this configuration to debug my NodeJS AddOn:
{
"type": "cppvsdbg",
"request": "launch",
"name": "Launch test application",
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"program": "node",
"args": ["test-out/main.js"]
}
Note the "console": "integratedTerminal" line. Pressing Ctrl-C inside the "Debug Console" does not do anything, but as the application is run inside the integrated terminal Ctrl-C works correctly there. I suspect that this might be the intended behavior and the debug console is not same as a terminal. I am working on MS Windows at the moment and have not verified this behavior with gdb, yet.
I'm seeing the same issue. ctrl-c always kills the debuggee:
my launch..json
contains:
"setupCommands": [
{ "text": "-interpreter-exec exec handle SIGINT nostop print pass", "ignoreFailures": true }
]
the debuggee handles SIGINT and normally shuts down gracefully, but when being debugged in vscode it's impossible to debug this shutdown code as it never gets run.
"console": "integratedTerminal",
allows to send Ctrl+C to the app, but debugger terminates the app before it runs all cleanup code.
ChatGPT to the rescue.
Results:
Type: Debugger
OS and Version:
Microsoft Windows [Version 10.0.17134.112]
VS Code Version:
Version 1.24.1 Commit 24f62626b222e9a8313213fb64b10d741a326288 Date 2018-06-13T17:51:32.889Z Shell 1.7.12 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64
C/C++ Extension Version:
Version 0.17.4
Other extensions you installed (and if the issue persists after disabling them):
None
A clear and concise description of what the bug is.
Trying to send ctrl-c to debug console but not triggering console interrupt handler in source code
Additional context
Tried adding logging to debugger but no events are being captured for this