Description
I tried this code:
fn main() {
let a = Some((0u32, 1u32));
dbg!(a);
}
When debugging in gdb, I expect to be able to write an expression to access a value inside a tuple, inside an enum. I want to do that so that I can e.g. dereference a pointer stored in such a tuple. It seems that a.0
accesses the Some
branch of my option, so I would expect a.0.0
to access the first tuple elem.
Instead, a.0.0
triggers a gdb expression syntax error. Note that it does work to append .0
to a gdb variable storing a.0
to access the tuple, which further suggests that a.0.0
should work.
Breakpoint 2.1, gdb_tuple::main () at src/main.rs:3
3 dbg!(a);
(gdb) p a
$1 = core::option::Option<(u32, u32)>::Some((
0,
1
))
(gdb) p a.0
$2 = (
0,
1
)
(gdb) p a.0.0
field name expected
(gdb) p $2.0
$3 = 0
a.0
to access the Some
admittedly seems like a bit of black magic. Helper functions like unwrap
are consistently not available in the binaries that I've tried to debug thus far, so I'm not sure what else I should be doing.
Meta
rustc --version --verbose
:
rustc 1.84.0-nightly (439284741 2024-10-21)
binary: rustc
commit-hash: 4392847410ddd67f6734dd9845f9742ff9e85c83
commit-date: 2024-10-21
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1