Re: PING: [PATCH] Print for unavailable registers

Andrew Burgess
2013-08-28T15:26:27Z

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

The original patch was supposed to be applied after [1],
however I never managed to get [1] accepted. I've flipped
the ordering, so that this patch can be applied first, if
this gets merged I'll post a revised version of [1] later,
just for the record.

To my reading, Mark seems to imply in this mail:
http://sourceware.org/ml/gdb-patches/2013-08/msg00322.html
that he does not disagree with displaying registers as
"<unavailable>", so I feel it's acceptable to push this
patch forward.

After this patch "info registers" will display unavailable
(for example, not collected by tracing) as <unavailable>,
while optimized out register values will still be displayed
using the old "*value not available*" string.

The previous version of this patch included some sh64 changes,
I've removed them from this patch to try and increase the chance
of acceptance.

[1] http://sourceware.org/ml/gdb-patches/2013-08/msg00170.html

OK?
Andrew

gdb/ChangeLog

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

* infcmd.c (default_print_one_register_info): use
val_print_unavailable for unavailable register values, continue as
before for optimized out register values.
(default_print_registers_info): Switch to using
get_frame_register_value.

gdb/testsuite/ChangeLog

2013-08-19 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 154cde2..83e0323 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2030,6 +2030,12 @@ default_print_one_register_info (struct ui_file *file,

if (!value_entirely_available (val))
{
+ val_print_unavailable (file);
+ fprintf_filtered (file, "\n");
+ return;
+ }
+ else if (value_optimized_out (val))
+ {
fprintf_filtered (file, "*value not available*\n");
return;
}
@@ -2107,9 +2113,6 @@ default_print_registers_info (struct gdbarch *gdbarch,

for (i = 0; i < numregs; i++)
{
- struct type *regtype;
- struct value *val;
-
/* Decide between printing all regs, non-float / vector regs, or
specific reg. */
if (regnum == -1)
@@ -2137,16 +2140,9 @@ default_print_registers_info (struct gdbarch *gdbarch,
|| *(gdbarch_register_name (gdbarch, i)) == '\0')
continue;

- regtype = register_type (gdbarch, i);
- val = allocate_value (regtype);
-
- /* Get the data in raw format. */
- if (! deprecated_frame_register_read (frame, i, value_contents_raw (val)))
- mark_value_bytes_unavailable (val, 0, TYPE_LENGTH (value_type (val)));
-
default_print_one_register_info (file,
gdbarch_register_name (gdbarch, i),
- val);
+ get_frame_register_value (frame, i));
}
}

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 { } {