This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Print <unavailable> for unavailable registers


Following on from (but unrelated to) this mail:
  http://sourceware.org/ml/gdb-patches/2013-08/msg00170.html

Printing "*value not available*" for unavailable values within
"info registers" seems inconsistent to me, if we just print an
unavailable register we'll get "<unavailable>".

The patch below makes "info registers" print "<unavailable>".

Taking a look around we also had code in the sh64-tdep.c file that
printed "*value not available*", I've changed this to also print
"<unavailable>", however, (1) this is being printed for unavailable,
and optimized out registers, but it was kind-of broken in this regard
already, (2) I don't use this target so don't know if this is really
the best change, but it felt like it probably was, and (3) I've also
made the sh64 code return early after printing "<unavailable>", it
previously fell through and tried to print the value anyway, I'm
guessing this was a bug, but the code has been that way for a long
time now.... I'd be happy to drop the sh64 changes if that was
preferred.

OK to apply?

Thanks,
Andrew

gdb/ChangeLog

2013-08-06  Andrew Burgess  <aburgess@broadcom.com>

	* infcmd.c (default_print_one_register_info): use
	val_print_unavailable for unavailable values.
	* sh64-tdep.c (sh64_do_register): Use val_print_unavailable for
	unreadable registers.  Return early for unreadable registers.

gdb/testsuite/ChangeLog

2013-08-06  Andrew Burgess  <aburgess@broadcom.com>

	* gdb.trace/unavailable.exp (gdb_unavailable_registers_test):
	Change expected pattern for unavailable registers to
	<unavailable>.


diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index f6a5290..297dad0 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2030,7 +2030,8 @@ default_print_one_register_info (struct ui_file *file,
 
   if (!value_entirely_available (val))
     {
-      fprintf_filtered (file, "*value not available*\n");
+      val_print_unavailable (file);
+      fprintf_filtered (file, "\n");
       return;
     }
   else if (value_optimized_out (val))
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index b640b1d..37fb72f 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -2045,7 +2045,11 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
 
   /* Get the data in raw format.  */
   if (!deprecated_frame_register_read (frame, regnum, raw_buffer))
-    fprintf_filtered (file, "*value not available*\n");
+    {
+      val_print_unavailable (file);
+      fprintf_filtered (file, "\n");
+      return;
+    }
 
   get_formatted_print_options (&opts, 'x');
   opts.deref_ref = 1;
diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp
index 8e2e105..ed14798 100644
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -297,11 +297,11 @@ proc gdb_unavailable_registers_test { } {
 	test_register "\$pc"
 
 	gdb_test "info registers" \
-	    "\\*value not available\\*.*\\*value not available\\*" \
+	    "<unavailable>.*<unavailable>" \
 	    "info registers, multiple registers not available"
 
 	gdb_test "info registers \$$spreg" \
-	    "\\*value not available\\*" \
+	    "<unavailable>" \
 	    "info registers \$$spreg reports not available"
 
 	gdb_test "tfind none" "#0  end .*" "cease trace debugging"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]