Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] MIPS: Ignore invalid regs during info registers all
@ 2014-09-30 14:43 James Hogan
  2014-09-30 15:01 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: James Hogan @ 2014-09-30 14:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: James Hogan

The "info registers all" command causes mips_print_registers_info () to be
called for all register numbers, including invalid ones such as unused DSP
register numbers. This triggers an error () call which prevents further
register values being printed. Just silently return without printing
anything or erroring, so that all valid registers can be printed.

For example, before this patch:
  (gdb) info registers all
  zero: 0x0
  ...
  fir: 0x30f30320
  Not a valid register for the current processor type
  (gdb)

After this patch:
  (gdb) info registers all
  zero: 0x0
  ...
  fir: 0x30f30320
  restart: 0x0
  (gdb)

gdb/ChangeLog:

	* mips-tdep.c (mips_print_registers_info): Replace error for
	single invalid register with silent return.
---
 gdb/ChangeLog   | 5 +++++
 gdb/mips-tdep.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f3282144c303..5da8415c3ca0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-30  James Hogan  <james.hogan@imgtec.com>
+
+	* mips-tdep.c (mips_print_registers_info): Replace error for
+	single invalid register with silent return.
+
 2014-09-30  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
 	* gdbarch.sh (regset_from_core_section): Remove gdbarch method.
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 188580f2ebdc..3c4665457552 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -6332,7 +6332,7 @@ mips_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
     {
       gdb_assert (regnum >= gdbarch_num_regs (gdbarch));
       if (*(gdbarch_register_name (gdbarch, regnum)) == '\0')
-	error (_("Not a valid register for the current processor type"));
+	return;
 
       mips_print_register (file, frame, regnum);
       fprintf_filtered (file, "\n");
-- 
1.8.5.5


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

* Re: [PATCH] MIPS: Ignore invalid regs during info registers all
  2014-09-30 14:43 [PATCH] MIPS: Ignore invalid regs during info registers all James Hogan
@ 2014-09-30 15:01 ` Pedro Alves
  2014-09-30 15:05   ` James Hogan
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2014-09-30 15:01 UTC (permalink / raw)
  To: James Hogan, gdb-patches

On 09/30/2014 03:43 PM, James Hogan wrote:
> The "info registers all" command causes mips_print_registers_info () to be
> called for all register numbers, including invalid ones such as unused DSP
> register numbers. This triggers an error () call which prevents further
> register values being printed. Just silently return without printing
> anything or erroring, so that all valid registers can be printed.

What happens when the user does "info registers that-unused-register" ?

Thanks,
Pedro Alves

> 
> For example, before this patch:
>   (gdb) info registers all
>   zero: 0x0
>   ...
>   fir: 0x30f30320
>   Not a valid register for the current processor type
>   (gdb)
> 
> After this patch:
>   (gdb) info registers all
>   zero: 0x0
>   ...
>   fir: 0x30f30320
>   restart: 0x0
>   (gdb)
> 
> gdb/ChangeLog:
> 
> 	* mips-tdep.c (mips_print_registers_info): Replace error for
> 	single invalid register with silent return.
> ---
>  gdb/ChangeLog   | 5 +++++
>  gdb/mips-tdep.c | 2 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index f3282144c303..5da8415c3ca0 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,8 @@
> +2014-09-30  James Hogan  <james.hogan@imgtec.com>
> +
> +	* mips-tdep.c (mips_print_registers_info): Replace error for
> +	single invalid register with silent return.
> +
>  2014-09-30  Andreas Arnez  <arnez@linux.vnet.ibm.com>
>  
>  	* gdbarch.sh (regset_from_core_section): Remove gdbarch method.
> diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
> index 188580f2ebdc..3c4665457552 100644
> --- a/gdb/mips-tdep.c
> +++ b/gdb/mips-tdep.c
> @@ -6332,7 +6332,7 @@ mips_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
>      {
>        gdb_assert (regnum >= gdbarch_num_regs (gdbarch));
>        if (*(gdbarch_register_name (gdbarch, regnum)) == '\0')
> -	error (_("Not a valid register for the current processor type"));
> +	return;
>  
>        mips_print_register (file, frame, regnum);
>        fprintf_filtered (file, "\n");
> 



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

* Re: [PATCH] MIPS: Ignore invalid regs during info registers all
  2014-09-30 15:01 ` Pedro Alves
@ 2014-09-30 15:05   ` James Hogan
  2014-09-30 15:36     ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: James Hogan @ 2014-09-30 15:05 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 30/09/14 16:00, Pedro Alves wrote:
> On 09/30/2014 03:43 PM, James Hogan wrote:
>> The "info registers all" command causes mips_print_registers_info () to be
>> called for all register numbers, including invalid ones such as unused DSP
>> register numbers. This triggers an error () call which prevents further
>> register values being printed. Just silently return without printing
>> anything or erroring, so that all valid registers can be printed.
> 
> What happens when the user does "info registers that-unused-register" ?

I don't think that's possible, because the check is:
if (*(gdbarch_register_name (gdbarch, regnum)) == '\0')

So any such register already has no name by which to refer to it.

Cheers
James


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

* Re: [PATCH] MIPS: Ignore invalid regs during info registers all
  2014-09-30 15:05   ` James Hogan
@ 2014-09-30 15:36     ` Pedro Alves
  2014-10-03 16:32       ` Maciej W. Rozycki
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2014-09-30 15:36 UTC (permalink / raw)
  To: James Hogan, gdb-patches

On 09/30/2014 04:05 PM, James Hogan wrote:
> On 30/09/14 16:00, Pedro Alves wrote:
>> On 09/30/2014 03:43 PM, James Hogan wrote:
>>> The "info registers all" command causes mips_print_registers_info () to be
>>> called for all register numbers, including invalid ones such as unused DSP
>>> register numbers. This triggers an error () call which prevents further
>>> register values being printed. Just silently return without printing
>>> anything or erroring, so that all valid registers can be printed.
>>
>> What happens when the user does "info registers that-unused-register" ?
> 
> I don't think that's possible, because the check is:
> if (*(gdbarch_register_name (gdbarch, regnum)) == '\0')
> 
> So any such register already has no name by which to refer to it.

Indeed.  :-)  I'll leave it to Maciej to approve.

I see that sh64-tdep.c:sh64_media_print_registers_info has the
same problem.

A bit silly that we force each arch backend to do this.

I guess the loop in registers_info could/should already skip
empty-named registers, like default_print_registers_info does.

Thanks,
Pedro Alves


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

* Re: [PATCH] MIPS: Ignore invalid regs during info registers all
  2014-09-30 15:36     ` Pedro Alves
@ 2014-10-03 16:32       ` Maciej W. Rozycki
  0 siblings, 0 replies; 5+ messages in thread
From: Maciej W. Rozycki @ 2014-10-03 16:32 UTC (permalink / raw)
  To: Pedro Alves, James Hogan; +Cc: gdb-patches

On Tue, 30 Sep 2014, Pedro Alves wrote:

> >>> The "info registers all" command causes mips_print_registers_info () to be
> >>> called for all register numbers, including invalid ones such as unused DSP
> >>> register numbers. This triggers an error () call which prevents further
> >>> register values being printed. Just silently return without printing
> >>> anything or erroring, so that all valid registers can be printed.
> >>
> >> What happens when the user does "info registers that-unused-register" ?
> > 
> > I don't think that's possible, because the check is:
> > if (*(gdbarch_register_name (gdbarch, regnum)) == '\0')
> > 
> > So any such register already has no name by which to refer to it.
> 
> Indeed.  :-)  I'll leave it to Maciej to approve.

 I didn't know `info registers' (and `info all-registers' presumably as 
well) supported further arguments; I'll experiment with the patch a bit 
and see what comes out.

 James, did you push your change through regression testing?  If so, then 
how?  Please always state precisely how changes you submit have been 
validated.

  Maciej


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

end of thread, other threads:[~2014-10-03 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-30 14:43 [PATCH] MIPS: Ignore invalid regs during info registers all James Hogan
2014-09-30 15:01 ` Pedro Alves
2014-09-30 15:05   ` James Hogan
2014-09-30 15:36     ` Pedro Alves
2014-10-03 16:32       ` 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