PING: Re: [PATCH] Print for unavailable registers

Andrew Burgess
2013-09-18T14:48:52Z

On 06/08/2013 2:09 PM, Andrew Burgess wrote:
> 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>".

I've re-written this patch, here's the latest version.

OK to apply?

Thanks,
Andrew

gdb/ChangeLog

2013-09-18 Andrew Burgess <aburgess@broadcom.com>

* infcmd.c (default_print_one_register_info): Print unavailable
registers using val_print_uavailable.

gdb/testsuite/ChangeLog

2013-09-18 Andrew Burgess <aburgess@broadcom.com>

* gdb.trace/unavailable.exp (gdb_unavailable_registers_test):
Change pattern to expect <unavailable> string.

Index: ./gdb/infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.335
diff -u -p -r1.335 infcmd.c
--- ./gdb/infcmd.c 18 Sep 2013 14:02:31 -0000 1.335
+++ ./gdb/infcmd.c 18 Sep 2013 14:43:13 -0000
@@ -2030,7 +2030,8 @@ default_print_one_register_info (struct

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))
Index: ./gdb/testsuite/gdb.trace/unavailable.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.trace/unavailable.exp,v
retrieving revision 1.23
diff -u -p -r1.23 unavailable.exp
--- ./gdb/testsuite/gdb.trace/unavailable.exp 15 Mar 2013 01:41:29 -0000 1.23
+++ ./gdb/testsuite/gdb.trace/unavailable.exp 18 Sep 2013 14:43:13 -0000
@@ -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"

>
> 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"
>
>
>
>