From 1c9cc05244f67c4e5a888394b2c9a309164ca02d Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 27 Mar 2022 15:29:28 -0600 Subject: Implement value_print for Rust This adds an implementation of the value_print method to Rust. As described in PR rust/22254, this removes a bit of weird-looking output from some "print"s -- because c_value_print is bypassed. I don't have a test for the bug that inspired this patch, because I only know how to reproduce it when using a relatively old Rust compiler. However, the new "cast-printing" code in value_print is required, because omitting this causes some existing tests to fail. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22254 --- gdb/rust-lang.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gdb/rust-lang.c') diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index d4a221a..bf8dba9 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -624,6 +624,27 @@ rust_language::value_print_inner } } +/* See language.h. */ + +void +rust_language::value_print + (struct value *val, struct ui_file *stream, + const struct value_print_options *options) const +{ + value_print_options opts = *options; + opts.deref_ref = true; + + struct type *type = check_typedef (value_type (val)); + if (type->is_pointer_or_reference ()) + { + gdb_printf (stream, "("); + type_print (value_type (val), "", stream, -1); + gdb_printf (stream, ") "); + } + + return common_val_print (val, stream, 0, &opts, this); +} + static void -- cgit v1.1