public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Don't throw an error in 'info registers' for unavailable MIPS registers.
@ 2017-06-16 17:10 John Baldwin
  2017-06-16 20:08 ` Maciej W. Rozycki
  0 siblings, 1 reply; 2+ messages in thread
From: John Baldwin @ 2017-06-16 17:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: macro

'info registers' for MIPS throws an error and when it first encounters
an unavailable register.  This does not match other architectures
which annotate unavailable registers and continue to print out the
values of subsequent registers.  Replace the error by displaying an
aligned "<unavailable>".  This string is truncated to "<unavl>" when
displaying a 32-bit register.

gdb/ChangeLog:

	* mips-tdep.c (print_gp_register_row): Don't error for unavailable
	registers.
---
 gdb/ChangeLog   |  5 +++++
 gdb/mips-tdep.c | 10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9062067bcf..26ea6fb8c7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-16  John Baldwin  <jhb@FreeBSD.org>
+
+	* mips-tdep.c (print_gp_register_row): Don't error for unavailable
+	registers.
+
 2017-06-16  Alan Hayward  <alan.hayward@arm.com>
 	    Pedro Alves  <palves@redhat.com>
 	    Yao Qi  <yao.qi@linaro.org>
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 3ff2dab491..adc843a5be 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -6542,8 +6542,14 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
       value = get_frame_register_value (frame, regnum);
       if (value_optimized_out (value)
 	|| !value_entirely_available (value))
-	error (_("can't read register %d (%s)"),
-	       regnum, gdbarch_register_name (gdbarch, regnum));
+	{
+	  fprintf_filtered (file, "%*s ",
+			    (int) mips_abi_regsize (gdbarch) * 2,
+			    mips_abi_regsize (gdbarch) == 4 ? "<unavl>"
+			    : "<unavailable>");
+	  col++;
+	  continue;
+	}
       raw_buffer = value_contents_all (value);
       /* pad small registers */
       for (byte = 0;
-- 
2.11.0

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

* Re: [PATCH v2] Don't throw an error in 'info registers' for unavailable MIPS registers.
  2017-06-16 17:10 [PATCH v2] Don't throw an error in 'info registers' for unavailable MIPS registers John Baldwin
@ 2017-06-16 20:08 ` Maciej W. Rozycki
  0 siblings, 0 replies; 2+ messages in thread
From: Maciej W. Rozycki @ 2017-06-16 20:08 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches

On Fri, 16 Jun 2017, John Baldwin wrote:

> index 3ff2dab491..adc843a5be 100644
> --- a/gdb/mips-tdep.c
> +++ b/gdb/mips-tdep.c
> @@ -6542,8 +6542,14 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
>        value = get_frame_register_value (frame, regnum);
>        if (value_optimized_out (value)
>  	|| !value_entirely_available (value))
> -	error (_("can't read register %d (%s)"),
> -	       regnum, gdbarch_register_name (gdbarch, regnum));
> +	{
> +	  fprintf_filtered (file, "%*s ",
> +			    (int) mips_abi_regsize (gdbarch) * 2,
> +			    mips_abi_regsize (gdbarch) == 4 ? "<unavl>"
> +			    : "<unavailable>");

 Formatting nit here -- you need to wrap an expression in parentheses when 
splitting between lines and indent accordingly, i.e. either:

+			    (mips_abi_regsize (gdbarch) == 4 ? "<unavl>"
+			     : "<unavailable>"));

or:

+			    (mips_abi_regsize (gdbarch) == 4
+			     ? "<unavl>" : "<unavailable>"));

> +	  col++;
> +	  continue;
> +	}

 Otherwise LGTM, so please consider your patch with such a change applied 
preapproved.

 I think that duplicate `col++' could be avoided, as could be the repeated 
calls to `mips_abi_regsize' and `register_size'.  That can be a separate 
clean-up though.

 Thanks for your work on this problem.

  Maciej

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

end of thread, other threads:[~2017-06-16 20:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-16 17:10 [PATCH v2] Don't throw an error in 'info registers' for unavailable MIPS registers John Baldwin
2017-06-16 20:08 ` Maciej W. Rozycki

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