Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Testing REGISTER_NAME in mips-linux-nat.c
@ 2003-06-27 17:20 Fred Fish
  2003-06-27 19:31 ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Fred Fish @ 2003-06-27 17:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Fred Fish

A recent change to mips_register_name to return a empty string for
register numbers < NUM_REGS is causing problems with the native mips
linux port.  The change in mips_register_name is:

  +   /* Map [NUM_REGS .. 2*NUM_REGS) onto the raw registers, but then
  +      don't make the raw register names visible.  */
  +   int rawnum = regno % NUM_REGS;
  +   if (regno < NUM_REGS)
  +     return "";

Now for example when mips_linux_cannot_fetch_register() is called with
regno == PC_REGNUM, it will return 1 and reading of the PC will return
zero as the PC value.

I think this is the correct patch, but I'm not 100% sure.  Perhaps we
can just eliminate the REGISTER_NAME check completely.

-Fred

============================================================================


2003-06-27  Fred Fish  <fnf@intrinsity.com>

	* mips-linux-nat.c (mips_linux_cannot_fetch_register): Only test
	register name if it is a pseudo register.
 

Index: mips-linux-nat.c
===================================================================
RCS file: /mips/newtools/fsf/gdb/gdb/mips-linux-nat.c,v
retrieving revision 1.2
diff -c -p -r1.2 mips-linux-nat.c
*** mips-linux-nat.c	2003/02/18 21:36:24	1.2
--- mips-linux-nat.c	2003/06/27 17:11:38
***************
*** 29,35 ****
  int
  mips_linux_cannot_fetch_register (int regno)
  {
!   if (REGISTER_NAME (regno)[0] == 0)
      return 1;
    if (regno == PS_REGNUM)
      return 1;
--- 29,35 ----
  int
  mips_linux_cannot_fetch_register (int regno)
  {
!   if (regno >= NUM_REGS && REGISTER_NAME (regno)[0] == 0)
      return 1;
    if (regno == PS_REGNUM)
      return 1;
*************** mips_linux_cannot_fetch_register (int re
*** 42,48 ****
  int
  mips_linux_cannot_store_register (int regno)
  {
!   if (REGISTER_NAME (regno)[0] == 0)
      return 1;
    if (regno == PS_REGNUM)
      return 1;
--- 42,48 ----
  int
  mips_linux_cannot_store_register (int regno)
  {
!   if (regno >= NUM_REGS && REGISTER_NAME (regno)[0] == 0)
      return 1;
    if (regno == PS_REGNUM)
      return 1;


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

* Re: [RFA] Testing REGISTER_NAME in mips-linux-nat.c
  2003-06-27 17:20 [RFA] Testing REGISTER_NAME in mips-linux-nat.c Fred Fish
@ 2003-06-27 19:31 ` Andrew Cagney
  2003-06-28 18:36   ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-06-27 19:31 UTC (permalink / raw)
  To: Fred Fish, Daniel Jacobowitz; +Cc: gdb-patches

> A recent change to mips_register_name to return a empty string for
> register numbers < NUM_REGS is causing problems with the native mips
> linux port.  The change in mips_register_name is:

Arrgh, they keep turning up :-(

>   +   /* Map [NUM_REGS .. 2*NUM_REGS) onto the raw registers, but then
>   +      don't make the raw register names visible.  */
>   +   int rawnum = regno % NUM_REGS;
>   +   if (regno < NUM_REGS)
>   +     return "";
> 
> Now for example when mips_linux_cannot_fetch_register() is called with
> regno == PC_REGNUM, it will return 1 and reading of the PC will return
> zero as the PC value.
> 
> I think this is the correct patch, but I'm not 100% sure.  Perhaps we
> can just eliminate the REGISTER_NAME check completely.

The assertion:

	gdb_assert (regno >= 0 && regno < NUM_REGS);

holds so, yes, eliminating REGISTER_NAME would make sense.

Hmm, how come this doesn't just use PTRACE_GETREGS?

Daniel?

Andrew



> ============================================================================
> 
> 
> 2003-06-27  Fred Fish  <fnf@intrinsity.com>
> 
> 	* mips-linux-nat.c (mips_linux_cannot_fetch_register): Only test
> 	register name if it is a pseudo register.
>  
> 
> Index: mips-linux-nat.c
> ===================================================================
> RCS file: /mips/newtools/fsf/gdb/gdb/mips-linux-nat.c,v
> retrieving revision 1.2
> diff -c -p -r1.2 mips-linux-nat.c
> *** mips-linux-nat.c	2003/02/18 21:36:24	1.2
> --- mips-linux-nat.c	2003/06/27 17:11:38
> ***************
> *** 29,35 ****
>   int
>   mips_linux_cannot_fetch_register (int regno)
>   {
> !   if (REGISTER_NAME (regno)[0] == 0)
>       return 1;
>     if (regno == PS_REGNUM)
>       return 1;
> --- 29,35 ----
>   int
>   mips_linux_cannot_fetch_register (int regno)
>   {
> !   if (regno >= NUM_REGS && REGISTER_NAME (regno)[0] == 0)
>       return 1;
>     if (regno == PS_REGNUM)
>       return 1;
> *************** mips_linux_cannot_fetch_register (int re
> *** 42,48 ****
>   int
>   mips_linux_cannot_store_register (int regno)
>   {
> !   if (REGISTER_NAME (regno)[0] == 0)
>       return 1;
>     if (regno == PS_REGNUM)
>       return 1;
> --- 42,48 ----
>   int
>   mips_linux_cannot_store_register (int regno)
>   {
> !   if (regno >= NUM_REGS && REGISTER_NAME (regno)[0] == 0)
>       return 1;
>     if (regno == PS_REGNUM)
>       return 1;
> 



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

* Re: [RFA] Testing REGISTER_NAME in mips-linux-nat.c
  2003-06-27 19:31 ` Andrew Cagney
@ 2003-06-28 18:36   ` Daniel Jacobowitz
  2003-07-03  0:44     ` Fred Fish
  2003-07-07 18:09     ` Daniel Jacobowitz
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-06-28 18:36 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Fred Fish, gdb-patches

On Fri, Jun 27, 2003 at 03:31:18PM -0400, Andrew Cagney wrote:
> >A recent change to mips_register_name to return a empty string for
> >register numbers < NUM_REGS is causing problems with the native mips
> >linux port.  The change in mips_register_name is:
> 
> Arrgh, they keep turning up :-(
> 
> >  +   /* Map [NUM_REGS .. 2*NUM_REGS) onto the raw registers, but then
> >  +      don't make the raw register names visible.  */
> >  +   int rawnum = regno % NUM_REGS;
> >  +   if (regno < NUM_REGS)
> >  +     return "";
> >
> >Now for example when mips_linux_cannot_fetch_register() is called with
> >regno == PC_REGNUM, it will return 1 and reading of the PC will return
> >zero as the PC value.
> >
> >I think this is the correct patch, but I'm not 100% sure.  Perhaps we
> >can just eliminate the REGISTER_NAME check completely.
> 
> The assertion:
> 
> 	gdb_assert (regno >= 0 && regno < NUM_REGS);
> 
> holds so, yes, eliminating REGISTER_NAME would make sense.

Take a look at MIPS_REGISTER_NAMES in tm-mips.h, which is the generic
registers.  Note lots of empty (unnamed) entries in there - we can't
fetch or store those.  That's what the check is trying to avoid.

I don't think Fred's patch is right either, because this function
shouldn't even be called for regno > NUM_REGS, so it just disables the
check.  I think the right thing to do is either (ugh!) to call
REGISTER_NAME (regno + NUM_REGS), or to switch to an inclusive list of
available registers.  Which is easier, and cleaner.

Fred, my mips-linux box is offline at the moment, so I can't test this. 
Could you try the attached patch and let me know if it works?

I think I'm going to try to get my own breed of automated testing
going to cover this...

> Hmm, how come this doesn't just use PTRACE_GETREGS?

Because mips-linux doesn't implement that yet.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-06-28  Daniel Jacobowitz  <drow@mvista.com>

	* mips-linux-nat.c (mips_linux_cannot_fetch_register)
	(mips_linux_cannot_store_register): List supported instead of
	unsupported registers.

Index: mips-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-linux-nat.c,v
retrieving revision 1.4
diff -u -p -r1.4 mips-linux-nat.c
--- mips-linux-nat.c	30 Oct 2002 04:10:06 -0000	1.4
+++ mips-linux-nat.c	28 Jun 2003 18:34:04 -0000
@@ -1,6 +1,6 @@
 /* Native-dependent code for GNU/Linux on MIPS processors.
 
-   Copyright 2001, 2002 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -29,31 +29,42 @@
 int
 mips_linux_cannot_fetch_register (int regno)
 {
-  if (REGISTER_NAME (regno)[0] == 0)
-    return 1;
-  if (regno == PS_REGNUM)
-    return 1;
-  else if (regno == ZERO_REGNUM)
-    return 1;
-  else
+  if (regno > ZERO_REGNUM && regno < ZERO_REGNUM + 32)
     return 0;
+  else if (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 32)
+    return 0;
+
+  switch (regno)
+    {
+    case LO_REGNUM:
+    case HI_REGNUM:
+    case BADVADDR_REGNUM:
+    case CAUSE_REGNUM:
+    case PC_REGNUM:
+    case FCRCS_REGNUM:
+    case FCRIR_REGNUM:
+      return 0;
+    }
+
+  return 1;
 }
 
 int
 mips_linux_cannot_store_register (int regno)
 {
-  if (REGISTER_NAME (regno)[0] == 0)
-    return 1;
-  if (regno == PS_REGNUM)
-    return 1;
-  else if (regno == ZERO_REGNUM)
-    return 1;
-  else if (regno == BADVADDR_REGNUM)
-    return 1;
-  else if (regno == CAUSE_REGNUM)
-    return 1;
-  else if (regno == FCRIR_REGNUM)
-    return 1;
-  else
+  if (regno > ZERO_REGNUM && regno < ZERO_REGNUM + 32)
     return 0;
+  else if (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 32)
+    return 0;
+
+  switch (regno)
+    {
+    case LO_REGNUM:
+    case HI_REGNUM:
+    case PC_REGNUM:
+    case FCRCS_REGNUM:
+      return 0;
+    }
+
+  return 1;
 }


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

* Re: [RFA] Testing REGISTER_NAME in mips-linux-nat.c
  2003-06-28 18:36   ` Daniel Jacobowitz
@ 2003-07-03  0:44     ` Fred Fish
  2003-07-07 18:09     ` Daniel Jacobowitz
  1 sibling, 0 replies; 5+ messages in thread
From: Fred Fish @ 2003-07-03  0:44 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Andrew Cagney, Fred Fish, gdb-patches

> Fred, my mips-linux box is offline at the moment, so I can't test
> this.  Could you try the attached patch and let me know if it works?

Sorry it took so long, I was having some issues with my test
environment also.  I ran the gdb testsuite with my patch installed and
then with your patch, and the results are much better with yours.

Here are the differences in the resulting gdb.sum files:

                    === gdb Summary ===
      
    ! # of expected passes          8375
    ! # of unexpected failures      596
      # of expected failures        51
    ! # of known failures           24
    ! # of unresolved testcases     18
      # of untested testcases       9
      # of unsupported tests        2
    
    --- 9416,9425 ----
      
                    === gdb Summary ===
      
    ! # of expected passes          8958
    ! # of unexpected failures      99
      # of expected failures        51
    ! # of known failures           26
      # of untested testcases       9
      # of unsupported tests        2
    
    
-Fred


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

* Re: [RFA] Testing REGISTER_NAME in mips-linux-nat.c
  2003-06-28 18:36   ` Daniel Jacobowitz
  2003-07-03  0:44     ` Fred Fish
@ 2003-07-07 18:09     ` Daniel Jacobowitz
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-07-07 18:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Cagney, Fred Fish

On Sat, Jun 28, 2003 at 02:36:31PM -0400, Daniel Jacobowitz wrote:
> On Fri, Jun 27, 2003 at 03:31:18PM -0400, Andrew Cagney wrote:
> > >A recent change to mips_register_name to return a empty string for
> > >register numbers < NUM_REGS is causing problems with the native mips
> > >linux port.  The change in mips_register_name is:
> > 
> > Arrgh, they keep turning up :-(
> > 
> > >  +   /* Map [NUM_REGS .. 2*NUM_REGS) onto the raw registers, but then
> > >  +      don't make the raw register names visible.  */
> > >  +   int rawnum = regno % NUM_REGS;
> > >  +   if (regno < NUM_REGS)
> > >  +     return "";
> > >
> > >Now for example when mips_linux_cannot_fetch_register() is called with
> > >regno == PC_REGNUM, it will return 1 and reading of the PC will return
> > >zero as the PC value.
> > >
> > >I think this is the correct patch, but I'm not 100% sure.  Perhaps we
> > >can just eliminate the REGISTER_NAME check completely.
> > 
> > The assertion:
> > 
> > 	gdb_assert (regno >= 0 && regno < NUM_REGS);
> > 
> > holds so, yes, eliminating REGISTER_NAME would make sense.
> 
> Take a look at MIPS_REGISTER_NAMES in tm-mips.h, which is the generic
> registers.  Note lots of empty (unnamed) entries in there - we can't
> fetch or store those.  That's what the check is trying to avoid.
> 
> I don't think Fred's patch is right either, because this function
> shouldn't even be called for regno > NUM_REGS, so it just disables the
> check.  I think the right thing to do is either (ugh!) to call
> REGISTER_NAME (regno + NUM_REGS), or to switch to an inclusive list of
> available registers.  Which is easier, and cleaner.
> 
> Fred, my mips-linux box is offline at the moment, so I can't test this. 
> Could you try the attached patch and let me know if it works?
> 
> I think I'm going to try to get my own breed of automated testing
> going to cover this...
> 
> > Hmm, how come this doesn't just use PTRACE_GETREGS?
> 
> Because mips-linux doesn't implement that yet.
> 
> -- 
> Daniel Jacobowitz
> MontaVista Software                         Debian GNU/Linux Developer
> 
> 2003-06-28  Daniel Jacobowitz  <drow@mvista.com>
> 
> 	* mips-linux-nat.c (mips_linux_cannot_fetch_register)
> 	(mips_linux_cannot_store_register): List supported instead of
> 	unsupported registers.

I've checked this in everywhere.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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

end of thread, other threads:[~2003-07-07 18:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-27 17:20 [RFA] Testing REGISTER_NAME in mips-linux-nat.c Fred Fish
2003-06-27 19:31 ` Andrew Cagney
2003-06-28 18:36   ` Daniel Jacobowitz
2003-07-03  0:44     ` Fred Fish
2003-07-07 18:09     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox