GNU Debugger "GDB" Adds Support For Microsoft's Debug Adapter Protocol
The Debug Adapter Protocol (DAP) is defined by Microsoft as an abstract protocol between IDEs and debuggers. As explained on the protocol's GitHub page:
"The idea behind the Debug Adapter Protocol (DAP) is to abstract the way how the debugging support of development tools communicates with debuggers or runtimes into a protocol. Since it is unrealistic to assume that existing debuggers or runtimes adopt this protocol any time soon, we rather assume that an intermediary component - a so called Debug Adapter - adapts an existing debugger or runtime to the Debug Adapter Protocol.
The Debug Adapter Protocol makes it possible to implement a generic debugger for a development tool that can communicate with different debuggers via Debug Adapters. And Debug Adapters can be re-used across multiple development tools which significantly reduces the effort to support a new debugger in different tools.
The Debug Adapter Protocol is a win for both debugger providers and tooling vendors!"
The Debug Adapter Protocol is widely supported for Microsoft's VS Code, there is also a DAP Server, Eclipse has some DAP support, there is some DAP support integrated into GNU Emacs, and various other projects both for language support and development environments have centered around this JSON-RPC protocol. Now today, the latest GDB Git master code does DAP too.
This DAP implementation is via the debugger's Python API rather than a shim. With the latest GDB development code the support can be enabled with gdb -i=dap.
The DAP code will accept JSON-RPC messages on stdin and print responses to stdout. GDB redirects the inferior's stdout to a new pipe so that output can be encapsulated by the protocol.
The Python code uses multiple threads to do its work. Separate threads are used for reading JSON from the client and for writing JSON to the client. All GDB work is done in the main thread. (The first implementation used asyncio, but this had some limitations, and so I rewrote it to use threads instead.)
This is not a complete implementation of the protocol, but it does implement enough to demonstrate that the overall approach works.
The GDB implementation was worked on by developer Tom Tromey and will be found in the next GDB release.