Midas is a debug adapter that utilizes the GDB/MI interface while also integrating into the experience an ease of use of rr. It also aims to be as fast as GDB/rr allows for non-trivial applications and as such uses GDB's great Python integration to be faster than some debug adapters, where possible.
Be sure to check out non-self documenting Midas-features if this document doesn't interest you! It explains how to use things like subscript operators, find first operators, debug console, hexadecimal formatting, etc!
Midas defines a set of debug sessions. A "normal debug session" is launching a new session with a specified program to debug. The "attach debug session" launches a debug session that attaches to currently running program. A "replayable debug session" consists of launching a RR replay and debug that. All of these debug sessions also come with the additional "remote session" flavor which consists of connecting to a remote target machine to debug there.
Changes to 0.19.0 pre-release (and coming 0.20.0 release)
In the coming releases, Midas will start using it's custom DAP implementation inside GDB, as a polyfill for those who can't use the very newest GDB, which itself will have a built in DAP interpreter (hopefully) in release 14.0. This pretty major refactor aims to achieve 2 things, the aforementioned polyfill as well as being a more stable debug adapter as this relieves Midas of much it's responsibility since we don't have to work around some of the more quirky parts of GDB to maintain an acceptable debugging experience as far as performance goes.
As such, users can (should) set the
RR session configuration change
Starting with this version all
Attach configuration change
Debugging remote targets has changed to look more like how one would do it naturally in GDB. As such the
Q & A
Join the matrix room https://chat.mozilla.org/#/room/#midas:mozilla.org for questions. Office hours are every waking moment of the day ;)
Midas is developed exclusively for GDB with Python integration in mind. If you are running a GDB which does not support it, or hasn't been built with Python functionality, Midas will not work, at all.
And as it's developed with rr in mind, Linux is also a requirement.
To check whether or not GDB has been built with Python, from a terminal write
This will give you a list of GDB features built in. In this list, something like this should be shown:
Midas has been tested with the following GDB versions
Currently Midas will only work for GDB versions above 9.1 due to the nature of the Python implementation of earlier GDB versions. There might be some work put into getting earlier versions to work. But it might not be possible depending on how far back Python support exists in GDB.
Midas aims to be able to support full toolchain management for debugging. At the moment, it currently only supports management of RR.
If you don't have RR installed, Midas provides 3 ways of installing it for you. You execute the midas function
This will install RR and also make it available from the VSCode terminal by simply entering
Currently, all three ways require that you run a Linux system that uses either
N.B! You will be required to input your sudo password for all three of these to work. A message box will ask you if this is OK. Midas does not store your password nor any other information about you.
In the future, the idea is that GDB should also be managed to be able to keep up with all the new features and optimization work that is being put into GDB by the great developers who are working on GDB. The justification for this, is that just in version 12 of GDB, debug symbol parsing was greatly optimized making life a lot better for people working on non-trivial applications of millions of lines of code. Midas wants to be able to make the process of staying on "current" as much as possible, as an opt-in feature.
Midas defines different debug sessions; "normal", "attach", and "replayable" and all three also come with an additional "remote" flavor, where the actual program is being run on a remote target.
The quickest way to configure is to open up the
Normal debug session
Required values are
Default values for non-required (or non-set) properties:
All stop mode, means that all stop / continue actions halt or start threads in unison.
Trace has the following settings:
The log files will be found where the extension is installed (typically at $HOME/.vscode/extensions/...). These are currently very bare bones though.
To "run" the inferior (debugged program) in an external console, add the
Since the rr debug session relies on rr running, closing the terminal where it's running externally, will end the debug session. These fields are described in the UI when setting up a launch.json.
However, currently this is only tested on Ubuntu, thus it uses
Replayable RR debug session
A minimum required launch config for RR is really simple as Midas will query RR for it's traces in
This requires that
Configuration example, for a rr debug session of for example a
However, you shouldn't have to fill out a placeholder for yourself, VSCode should be able to provide auto-completion like it normally does (default trigger usually is
Attaching to a running process is basically done and setup the same way. Midas will provide a default setting:
Leave PID field as is (or remove the field entirely) and you will be asked for it at debug session launch where you can type either the PID directly or the process name and get a list of PID's to choose from (if only 1 exists, it automatically gets picked).
Remote debug sessions
To use Midas to debug an application running on a remote target, the user must have first started a gdbserver that is running the application and listening for connections on some address. To connect to a gdbserver at address
If the remote session is an RR replay, just replace
Another field that can be added is the
Since VSCode is aimed to be as general as possible, some functionality might never be represented in the UI - as such it might appear unintuitive. Describing such functionality is found here, like setting watch points, formatting displayed values etc. It's recommended to skim through, to get to know useful Midas features.
If Midas behaves strangely, there exists a midas command (
To package extension, run the alias
Can be found here
Can be found here