public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Implement value_print for Rust Date: Fri, 15 Apr 2022 17:36:02 +0000 (GMT) [thread overview] Message-ID: <20220415173602.51E143857341@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c9cc05244f67c4e5a888394b2c9a309164ca02d commit 1c9cc05244f67c4e5a888394b2c9a309164ca02d Author: Tom Tromey <tom@tromey.com> Date: Sun Mar 27 15:29:28 2022 -0600 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 Diff: --- gdb/rust-lang.c | 21 +++++++++++++++++++++ gdb/rust-lang.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index d4a221abb08..bf8dba99ecd 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); +} + \f static void diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h index 0e89b8822cb..514494a2c82 100644 --- a/gdb/rust-lang.h +++ b/gdb/rust-lang.h @@ -125,6 +125,11 @@ public: /* See language.h. */ + void value_print (struct value *val, struct ui_file *stream, + const struct value_print_options *options) const override; + + /* See language.h. */ + struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, const domain_enum domain) const override
reply other threads:[~2022-04-15 17:36 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220415173602.51E143857341@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).