public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Style history variable output
@ 2023-06-12 23:11 Tom Tromey
  2023-06-14 12:11 ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-06-12 23:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-22 15:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 23:11 [PATCH] Style history variable output Tom Tromey
2023-06-14 12:11 ` Andrew Burgess
2023-10-22 15:01   ` Tom Tromey

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).