Rust debugger


Are there any plans to build an official debugger for Rust with Rust (i.e.: like in the compiler case)? Or are you going to add support for it on gdb and lldb?


We already have some level of gdb/lldb support

See also: the rust-gdb and rust-lldb scripts that come with the distribution.


Yes, I’ve been using them, but I just wanted to know if Mozilla had any plans to build a debugger from scratch or if it is going to focus on gdb and lldb support.


There’s no need to write an entirely custom debugger from scratch. There’s already plenty of solid debugging engines that are well integrated into a lot of software. At most Rust will be working on improving its integration with those debuggers.


I’m just asking because it seems from the post pointed out by Manishearth that the integration with gdb has some limitations, and I think that having good debugging tools is essential for the productivity of a programming language.


It’s easier to improve the gdb debugging than to write our own; I think.


Yes, as long as it allows you to do all kind of debugging operations. Ok, thank you very much for the info.


I’m pretty sure that there won’t be a Rust debugger written in Rust from the grounds up in the medium term. Writing a debugger (that works on many platforms) involves a lot of low-level and maintenance work.

That being said, GDB has been extended with support for new programming languages (e.g. Go, Java) and there’s no reason that the same couldn’t be done for Rust. For LLDB the story is less clear, as far as I know. Looking at this thread on the LLDB mailing list, however, there seems to be at least some interest in making it possible to add support for new languages.


I agree with you. Extending GDB it’s what makes more sense. I just hope that this topic is not forgotten, and Rust gets full debugging support soon. I tried some time ago to debug Go programs with GDB and it sucked.


Let me start this as a the debugger topic first. I am wondering if a simple interactive environment (not a powerful IDE) can be built, even just text mode. I’d like to be able to type in rust code, which is wrapped in main(), and compiled immediately, then show the output, with variable values. Of course can debug it line by line. Also can define other functions and call them.

This will be a very useful tool for prototyping and actually create working code. It will be very attractive to beginners. A lot of things could be added such as intellisense but a simple start is also good. If a few more people are interested we can see how to start this.


@WatsonJX, it doesn’t sound like you’re looking for a debugger, but instead are looking for a REPL.

There is already such a project, rusti. It’s fairly young, but it does most of what you ask for. Here’s a sample session, where I forgot the return type the first time:

$ cargo run
     Running `target/debug/rusti` 
rusti=> fn factorial(x: i64) {
rusti.>     match x {
rusti.>         0 => 0,
rusti.>         1 => 1,
rusti.>         _ => x * factorial(x - 1)
rusti.>     }
rusti.> }
<anon>:9:14: 9:34 error: type mismatch resolving `<i64 as core::ops::Mul<()>>::Output == _`:
 expected type error,
    found integral variable [E0271]
<anon>:9         _ => x * factorial(x - 1)
<anon>:9:14: 9:34 help: run `rustc --explain E0271` to see a detailed explanation
<anon>:9:14: 9:34 error: the trait `core::ops::Mul<()>` is not implemented for the type `i64` [E0277]
<anon>:9         _ => x * factorial(x - 1)
<anon>:9:14: 9:34 error: the trait `core::ops::Mul<()>` is not implemented for the type `i64` [E0277]
<anon>:9         _ => x * factorial(x - 1)
<anon>:6:5: 10:6 error: mismatched types:
 expected `()`,
    found `_`
(expected (),
    found integral variable) [E0308]
<anon>:6     match x {
<anon>:7         0 => 0,
<anon>:8         1 => 1,
<anon>:9         _ => x * factorial(x - 1)
<anon>:10     }
<anon>:6:5: 10:6 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to 4 previous errors
rusti=> fn factorial(x: i64) -> i64 {
rusti.>     match x {
rusti.>         0 => 0,
rusti.>         1 => 1,
rusti.>         _ => x * factorial(x - 1)
rusti.>     }
rusti.> }
rusti=> factorial(10)


Yah, pretty close. Thanks for the info. I am imaging if I can open a vi editor, a debugger and pipe input to it then it is just a matter of editing, compiling, debugging and show variables. I can manually work like this in multiple terminal window but would be quite nice to do it in an easy way.


This topic is 252 days old and in that time nobody has questioned the premise again that to do programming you also need good debugging capabilities. Of course if you don’t then you won’t debug as effectively or it will take you more time to do so. I am curious what people here think are already good alternatives and solid debugging engines as they have been called in this thread.

Just curious.



GDB works pretty well, and LLDB slightly less so.


Since the windows-msvc triples have PDB debug info I just use Visual Studio to debug my Rust programs. As LLVM improves their CodeView/PDB debug info (like actually having info on local variables would be nice), my debugging experience too shall improve.


FWIW I’ve started writing Rust language support in gdb. You can find it on the “rust” branch in my gdb repository.

So far it doesn’t gain you a huge amount over what is already available. I’d be interested in feedback on what else should be done. Some ideas:

  • Rust expression parser is the obvious missing piece
  • Flesh out type-printing code to be more Rusty (currently only function types are handled here)
  • Likewise for value printing
  • Maybe build some of the basic pretty-printers into the C code
  • Update the gdb test suite (necessary to get this in upstream)


Getting return values to expose real values consistently would be a big win. See this informative comment for background information.


Hi, I have written this guide for using VS Code and vscode-lldb on Linux.