Manually Setup GDB debug session for Rust?

Is there possibly a way to setup GDB for Rust without using the rust-gdb alias? The problem with the alias approach is that, a GDB UI that wraps GDB and wants to do so seamlessly, will have to manage that up front which becomes cumbersome really quickly, and requiring of it's users to specify debugger path obsessively is also very bad, from an ergonomics perspective.

GDB can determine languages based on the debug information (particularly when that debug information is DWARF; which rustc emits).

The requirement to have to say rust-gdb is a terrible way (viewed, selflishly here, from a UI & ergonomics-perspective).

I've tried doing the add-auto-load-safe-path and the substitute path once I've gotten GDB spawned, but that doesn't seem to do it, so there's something else inside the python directory that does something under the debugger's feet, as it were.

Could someone please describe how one would do the setup after gdb has spawned, and not before, as it is now?

I only ever use vanilla gdb for debugging Rust and it works fine. Do you need something in particular from rust-gdb?

rust-gdb is a pretty small script that just adds a few initialization options to an inner gdb command. It adds the autoload path for pretty printers, and I think in 1.70 it will also have a substitution path for the standard library sources. These settings are completely optional, but also easy to reproduce manually if you're running straight gdb.

Quick edit: sorry, I see that you did try to set those yourself. Can you give details of what you tried? Wild guess for the python trouble, maybe you're missing the PYTHONPATH addition?

1 Like

Hi guys and thanks for the quick responses, @cuviper and @Michael-F-Bryan !

It's sort of difficult to explain; however, I have filed a github issue (as well as sent a PR solving the problem); which can be found here: Make GDB Python Pretty Printers loadable after spawning GDB, avoiding required `rust-gdb` by theIDinside · Pull Request #111962 · rust-lang/rust · GitHub