Debugging hell with Rust and LLDB

I'm using VS Code and LLDB plugin for debugging. When I want to analyze the variable contents I often run into the problem that the pretty printers fail, so that I see something like:

foo: size=3, capacity=4
    : <error: No value>
  > [raw]: std::collection::hash::map::HashMap<u32, alloc::vec::Vec<DirEntry>, std::collection::hash::map::RandomState>

Is this a known problem? Are there any solution, but adding println statements to the code or write variable contents to files for debugging purpose?

1 Like

I've been disappointed with the debugger in VS Code for this reason (and more). I used better dashboard style debuggers on home computers back in the eighties than the ones we now have in browsers and modern IDEs, and the Rust debugger in VS Code is too limited for most things.

So although I generally like a dashboard debugger, most of the time I'm using println and log, or just now while working in on an app with a terminal UI, I direct the output to an extra window in the terminal display.

There's a team working on a Rust debugger called headcrab, but I don't know what style of UI they plan.

println is an acceptable solution as long as the data is small. But I have in my projects big and complex structures. So println and logging is not a solution. I think that LLDB is not so bad, but the pretty printers are very limitted. Unfortunately I don't have enough knowledge about the pretty printers so that I can extend them myself. I've tried it, but I would need some debugging support within the pretty printers so that I can see how to extend them. But this was also very cumbersome and in the end I gave up :frowning:

Is there any tutorial about how to extend the pretty printers for lldb? Couldn't find any yet.

The plan is for headcrab to be a library that could be used by different debugger UI's or even other kinds of programs like strace. I contributed two interfaces. A terminal based one and one using dear imgui. https://github.com/headcrab-rs/headcrab/tree/master/examples On the headcrab zulip there is also a topic to gather all kinds of debugging user interfaces: https://headcrab.zulipchat.com/#narrow/stream/248589-learning/topic/user.20interface.20resources/near/206127496

2 Likes

headcrab seems to still in a very eary stage. Not usable for me yet, but I hope it will mature soon :wink:
The current situation with debugging is really bad, but nevertheless I love Rust very much.