Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] sh-tdep.c: Fix erroneus register skipping in sh_print_registers_info
@ 2004-02-18 14:00 Corinna Vinschen
  2004-02-26  9:49 ` Corinna Vinschen
  2004-03-19  0:09 ` Elena Zannoni
  0 siblings, 2 replies; 6+ messages in thread
From: Corinna Vinschen @ 2004-02-18 14:00 UTC (permalink / raw)
  To: gdb-patches

Hi,

the below patch fixes a long standing bug in sh_print_registers_info.
When the print loop encounters a float type register and fpregs is
not set, then the loop counter (regnum) is not just incremented by
one, but instead it's incremented by FP_LAST_REGNUM - FP0_REGNUM.

The problem with this is, that FPUL is also a float type register.
FPUL is two register numbers below FP0_REGNUM.  So when the loop
arrives at FPUL, it skips the next 16 registers.  The next evaluated
register then (fr14) is still a float type register, so the loop
skips again 16 registers.  As a result, the register set is never
printed completely when calling `info registers'.

The below patch fixes that and shortens the code slightly by using
a "for" loop instead of "while".


Corinna


ChangeLog:

	* sh-tdep.c (sh_print_registers_info): Use for loop.
	Don't skip multiple registers when a float register is encountered.

Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.156
diff -u -p -r1.156 sh-tdep.c
--- sh-tdep.c	26 Jan 2004 20:52:12 -0000	1.156
+++ sh-tdep.c	18 Feb 2004 13:41:21 -0000
@@ -1799,35 +1799,23 @@ sh_print_registers_info (struct gdbarch 
   else
     /* do all (or most) registers */
     {
-      regnum = 0;
-      while (regnum < NUM_REGS)
+      for (regnum = 0; regnum < NUM_REGS; ++regnum)
 	{
 	  /* If the register name is empty, it is undefined for this
 	     processor, so don't display anything.  */
 	  if (REGISTER_NAME (regnum) == NULL
 	      || *(REGISTER_NAME (regnum)) == '\0')
-	    {
-	      regnum++;
-	      continue;
-	    }
+	    continue;
 
 	  if (TYPE_CODE (gdbarch_register_type (gdbarch, regnum)) ==
 	      TYPE_CODE_FLT)
 	    {
+	      /* true for "INFO ALL-REGISTERS" command */
 	      if (fpregs)
-		{
-		  /* true for "INFO ALL-REGISTERS" command */
-		  sh_do_fp_register (gdbarch, file, regnum);	/* FP regs */
-		  regnum++;
-		}
-	      else
-		regnum += (FP_LAST_REGNUM - FP0_REGNUM);	/* skip FP regs */
+		sh_do_fp_register (gdbarch, file, regnum);	/* FP regs */
 	    }
 	  else
-	    {
-	      sh_do_register (gdbarch, file, regnum);	/* All other regs */
-	      regnum++;
-	    }
+	    sh_do_register (gdbarch, file, regnum);	/* All other regs */
 	}
 
       if (fpregs)

-- 
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.


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

end of thread, other threads:[~2004-03-08 10:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-18 14:00 [RFA] sh-tdep.c: Fix erroneus register skipping in sh_print_registers_info Corinna Vinschen
2004-02-26  9:49 ` Corinna Vinschen
2004-03-19  0:09 ` Elena Zannoni
2004-03-05 22:36   ` Elena Zannoni
2004-03-08 10:18   ` Corinna Vinschen
2004-03-19  0:09     ` Corinna Vinschen

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