When you set "miDebuggerPath": "/usr/bin/sudo"
and "miDebuggerArgs": "/usr/bin/gdb"
, CMake Tools (or the Microsoft C++ debug adapter) then appends extra GDB flags like --interpreter=mi
– but those end up being passed to sudo rather than gdb. Sudo complains about unrecognized options (anything starting with a dash), and so it fails.
You need a way for sudo itself to ignore those GDB options, so that they pass through to gdb. There are two main workarounds:
One of the simplest solutions is to create a one-line shell script that runs gdb under sudo, and then reference that script as your debugger path. This way, the extra flags appended by VS Code or CMake Tools go to gdb correctly.