I'm using VS Code to debug a c++ program. Sometimes the debugger will hang when I type an inappropriate debugger command, for example, printing an un-initialized variable (a shared_ptr
, which causes a wait of several minutes). In this case, I have to wait for a very long time or restart the program. I'm wondering if I can set a timeout for debugger commands.
I'm using VS Code remote debug mode (the program runs on a remote SSH machine).
I would try setting GDB's remotetimeout
setting in your VS Code launch config, which you can do by inserting the following into the VS Code launch config:
"setupCommands": [
{
"text": "set remotetimeout <num>" # TODO pick a <num> value.
}
],
From GDB's docs:
Set the timeout limit to wait for the remote target to respond to num seconds. The default is 2 seconds.
From the VS Code launch config setupCommands
field description:
One or more GDB/LLDB commands to execute in order to setup the underlying debugger. Example: "setupCommands": [ { "text": "-enable-pretty-printing", "description": "Enable GDB pretty printing", "ignoreFailures": true }].