]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Rewrite Rust slice type handling
authorTom Tromey <tromey@adacore.com>
Tue, 30 Jan 2024 17:06:46 +0000 (10:06 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 20 Feb 2024 20:51:30 +0000 (13:51 -0700)
commitb0dd661fa16a424f059b1e1d80e779508b1a9a12
tree7d1c9253ab0284c90ab7859d402a7140980e23c3
parent94a75b0363b1e09416e9bd24cac72d98864688d8
Rewrite Rust slice type handling

This patch rewrites the handling of slice types in Rust.

More recent versions of the Rust compiler changed how unsized types
were emitted, letting gdb inspect them more nicely.  However, gdb did
not do this, and in fact treated all such types as if they were slices
of arrays, which is incorrect.

This patch rewrites this handling and removes the restriction that
unsized types must be array slices.  I've added a comment explaining
how unsized types are represented to rust-lang.c as well.

I looked into a different approach, namely changing the DWARF reader
to fix up slice types to have a dynamic type.  However, the approach
taken here turned out to be simpler.

Tested on x86-64 Fedora 38 with a variety of Rust compiler versions.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30330
gdb/rust-lang.c
gdb/rust-lang.h
gdb/testsuite/gdb.rust/simple.exp
gdb/testsuite/gdb.rust/unsized.exp
gdb/testsuite/gdb.rust/unsized2.exp [new file with mode: 0644]
gdb/testsuite/gdb.rust/unsized2.rs [new file with mode: 0644]