What do you use to debug Rust (particularly in Emacs?

I use all of the packages you use, except for company (switched to corfu) and hs-minor-mode. Actually using rust-gdb is not "good", but at least is decent. Moreover, since it is just a wrapper around GDB, I'd say that should be possible to integrate with RealGUD (I still have problems in using dap-mode even for the simplest program).

However (and that is a question open to everyone) I have an [Option] array in a Rust program, with values mixed between the two variants Some(i32) and None. Are you able to view it from the debuggers? Because apparently rust-gdb panics if I try to print it! And rust-lldb simply prints an empty array. Here:

  • source file (snippet):
fn main() {
    let v = [Some(1), Some(2), None];
    dbg!(v);
}
  • rust-gdb trace:
// GDB initialization
(gdb) b main.rs:14
Breakpoint 1 at 0x875f: file src/main.rs, line 14.
(gdb) r
Starting program: /tmp/rust-gdb/target/debug/rust-gdb 

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.archlinux.org 
Enable debuginfod for this session? (y or [n]) 
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Breakpoint 1, rust_gdb::main () at src/main.rs:14
14	    dbg!(v);
(gdb) p v
$1 = [core::option::Option<i32>::Some(
../../gdb/gdbtypes.h:1064: internal-error: field: Assertion `idx >= 0 && idx < num_fields ()' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0x557961575b0b ???
0x5579618b3cb4 ???
0x557961976c23 ???
0x5579614f5ed1 ???
0x5579618c5d93 ???
0x5579617f942c ???
0x5579618c104b ???
0x5579618c68a5 ???
0x5579618c7adb ???
0x5579617f901b ???
0x5579618c104b ???
0x5579615995c8 ???
0x5579618c2926 ???
0x557961784310 ???
0x557961785fc2 ???
0x5579615abd84 ???
0x55796187b782 ???
0x557961671bac ???
0x557961671c4d ???
0x557961662fcf ???
0x7f6a8543a246 ???
0x5579616669eb ???
0x557961666bd3 ???
0x557961671adf ???
0x557961977895 ???
0x557961977c69 ???
0x557961735c74 ???
0x5579614e1c14 ???
0x7f6a8471528f ???
0x7f6a84715349 ???
0x5579614e81f4 ???
0xffffffffffffffff ???
---------------------
../../gdb/gdbtypes.h:1064: internal-error: field: Assertion `idx >= 0 && idx < num_fields ()' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) 
  • rust-lldb trace:
// LLDB initialization

(lldb) target create "./rust-gdb"
Current executable set to '/tmp/rust-gdb/target/debug/rust-gdb' (x86_64).
(lldb) b main.rs:14
Breakpoint 1: 3 locations.
(lldb) r
Process 6127 launched: '/tmp/rust-gdb/target/debug/rust-gdb' (x86_64)
Process 6127 stopped
* thread #1, name = 'rust-gdb', stop reason = breakpoint 1.1
    frame #0: 0x000055555555c75f rust-gdb`rust_gdb::main::hf28a340875d6686e at main.rs:14:5
   11  	    let v = [Some(1), Some(2), None];
   12  	    
   13  	
-> 14  	    dbg!(v);
   15  	}
(lldb) p v
(core::option::Option<>[3]) $0 = {
  [0] =
  [1] =
  [2] =
}
(lldb) 

Is this a bug on the Rust side? Or a GDB one? Is the LLDB script flawed? I'm losing my mind after this thing, it really annoys me :smiling_face_with_tear:


EDIT: since this may be relevant but OT, I'm moving it to a new thread