Autodebug allows you to automatically start debugging sessions when a process starts. This can work with C++, Rust or Python (or really any language with a debugger that can open Unix sockets). It is helpful when the process you want to debug is buried deep within a complex system.
It works like this:
When you start a new integrated terminal the extension creates a Unix socket and sets an environment variable in the terminal (AUTODEBUG_IPC_HANDLE) with the path of the socket.
In your program, YOU add code to read the environment variable and send a debug session command to the Unix socket. An example of how to do this for C/C++ is given in the c directory.
The extension listens on the socket for JSON debug session descriptions, and starts them.
SECURITY NOTE
This extension sets an environment variable AUTODEBUG_SECRET in the integrated terminal. Anything that can read that environment variable and connect to the AUTODEBUG_IPC_HANDLE Unix socket can initiate any debug session. This is very unlikely to be an issue in practice because anything that can do that will almost certainly already be able to run arbitrary code.
How To
For C++:
Install the CodeLLDB extension.
Link your program with c/vscode_debug.c.
In the integrated terminal run CPP_DEBUG=1 ./my_program. It should automatically start a debug session.
Extension Settings
This extension contributes the following settings:
autodebug.enable: Enable/disable this extension.
Limitations
It only works when the program is run from the integrated terminal.