To debug a Rust application or C++ application, you can use the CodeLLDB DAP server.
Let's debug the following main.rs Rust file:
fn main() {
let name = "world";
println!("Hello, {}!", name);
}You will need to install cargo, which is used to create a Rust application with cargo init and to build an executable with cargo build.
The executable is required for debugging.
cargo initThis command generates a Rust application with a src/main.rs file. Update this file with the following content:
fn main() {
let name = "world";
println!("Hello, {}!", name);
}To debug the Rust application, you first need to build the executable that will be used by the debugger. In the project directory, run:
cargo buildThis will generate an executable in the target/debug folder.
-
Create a DAP Run/Debug configuration:
-
In the
Servertab, click oncreate a new server: -
A new dialog will open to create a DAP server. Select the
CodeLLDBtemplate: -
After clicking the
OKbutton, the new server will be selected and the configuration automatically pre-filled:
- Enable DAP server traces
If you wish to show DAP request/response traces when you will debug:
you need to select Trace with verbose.
To allows settings breakpoints to Rust files, you need configure mappings in the Mappings tab.
As you have selected CodeLLDB server, it will automatically populate the file mappings like this:
Since you selected the CodeLLDB server, the Launch configuration will be automatically populated like this:
LaunchasDebug modeshould be selected.- The DAP parameters of the launch should look like this:
{
"type": "lldb",
"name": "Launch Rust file",
"request": "launch",
"program": "${file}",
"cwd": "${workspaceFolder}"
}You also need to select the executable in the File field:
After applying the run configuration, set breakpoints in files that match the file mappings.
For example, set a breakpoint in the main.rs file:
You can start the run configuration in either Run or Debug mode.
The first time you run it, CodeLLDB, the DAP server, will be downloaded and installed:
If you encounter an error during installation, go to the Installer tab, update the
Installer Descriptor
, and run Run Installation again:
Once started, you should see DAP traces in the console:
You will also see Threads and Variables:
You can open the Disassembly view to debug step-by-step instructions at the assembly level:
If you need language support for Rust (completion, validation, etc.), you can configure the Rust Language Server.
TODO
If you need language support for C++ files (completion, validation, etc.), you can configure the Clangd Language Server.














