From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Style history variable output
Date: Mon, 12 Jun 2023 17:11:00 -0600 [thread overview]
Message-ID: <20230612231100.18608-1-tom@tromey.com> (raw)
When printing a value, I think the history reference -- the "$1" in
the output -- should be styled using the "variable" style. This patch
implements this.
---
gdb/printcmd.c | 3 ++-
gdb/testsuite/gdb.base/style.exp | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index d8d97493bab..204dbfc8219 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1253,7 +1253,8 @@ print_value (value *val, const value_print_options &opts)
annotate_value_history_begin (histindex, val->type ());
- gdb_printf ("$%d = ", histindex);
+ gdb_printf ("%p[$%d%p] = ", variable_name_style.style ().ptr (),
+ histindex, nullptr);
annotate_value_history_value ();
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 0370550d251..0e64ed35c2b 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -196,8 +196,12 @@ proc run_style_tests { } {
set sfield [limited_style string_field variable]
set efield [limited_style e_field variable]
set evalue [limited_style VALUE_TWO variable]
+ # The two parts of the left hand side are styled separately.
+ # This is just an oddity of the current implementation.
+ set lhs \
+ [limited_style "\\\$" variable][limited_style "$decimal" variable]
gdb_test "print struct_value" \
- "\{$ifield = 23,.*$sfield = .*,.*$efield = $evalue.*"
+ "$lhs = \{$ifield = 23,.*$sfield = .*,.*$efield = $evalue.*"
set ffield [limited_style field variable]
set cstart [string_to_regexp "/* XXX "]
--
2.39.2
next reply other threads:[~2023-06-12 23:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 23:11 Tom Tromey [this message]
2023-06-14 12:11 ` Andrew Burgess
2023-10-22 15:01 ` Tom Tromey
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=20230612231100.18608-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@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: link
Be 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).