aboutsummaryrefslogtreecommitdiff
path: root/gdb/rust-lang.h
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-01-30 10:06:46 -0700
committerTom Tromey <tromey@adacore.com>2024-02-20 13:51:30 -0700
commitb0dd661fa16a424f059b1e1d80e779508b1a9a12 (patch)
tree7d1c9253ab0284c90ab7859d402a7140980e23c3 /gdb/rust-lang.h
parent94a75b0363b1e09416e9bd24cac72d98864688d8 (diff)
downloadgdb-b0dd661fa16a424f059b1e1d80e779508b1a9a12.zip
gdb-b0dd661fa16a424f059b1e1d80e779508b1a9a12.tar.gz
gdb-b0dd661fa16a424f059b1e1d80e779508b1a9a12.tar.bz2
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
Diffstat (limited to 'gdb/rust-lang.h')
-rw-r--r--gdb/rust-lang.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index e76a63e..9ae5961 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -34,9 +34,6 @@ extern bool rust_tuple_type_p (struct type *type);
/* Return true if TYPE is a tuple struct type; otherwise false. */
extern bool rust_tuple_struct_type_p (struct type *type);
-/* Return true if TYPE is a slice type, otherwise false. */
-extern bool rust_slice_type_p (const struct type *type);
-
/* Given a block, find the name of the block's crate. Returns an empty
stringif no crate name can be found. */
extern std::string rust_crate_for_block (const struct block *block);
@@ -196,8 +193,7 @@ public:
/* See language.h. */
- bool is_array_like (struct type *type) const override
- { return rust_slice_type_p (type); }
+ bool is_array_like (struct type *type) const override;
/* See language.h. */
@@ -212,6 +208,13 @@ public:
private:
/* Helper for value_print_inner, arguments are as for that function.
+ Prints a slice. */
+
+ void val_print_slice (struct value *val, struct ui_file *stream,
+ int recurse,
+ const struct value_print_options *options) const;
+
+ /* Helper for value_print_inner, arguments are as for that function.
Prints structs and untagged unions. */
void val_print_struct (struct value *val, struct ui_file *stream,