Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][SH] info registers
@ 2005-11-16 16:48 Andrew STUBBS
  2005-11-16 16:54 ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew STUBBS @ 2005-11-16 16:48 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 5913 bytes --]

Hi,

sh-tdep.c contains quite a lot of code to implement the 'info registers' 
command (and friends).

It has a number of issues:
  - The double and vector registers are only in hex.
  - Invalid registers are still printed for some types (not that GDB 
knows which registers are invalid - that's my next patch).
  - The double registers are incorrectly named dr0..dr7, and the vector 
registers incorrectly named fv0..fv3. They should be dr0,dr2,dr4... and 
fv0,fv4,...

I have discovered that the default code (when the architecture may 
override) does everything the SH code does right and yet does not do 
everything it does wrong. Specifically all the above problems are 
addressed.

I therefore propose removing all this garbage entirely.

Before

   (gdb) info all-registers
   r0             0x0      0
   r1             0x0      0
   r2             0x0      0
   r3             0x0      0
   r4             0x0      0
   r5             0x0      0
   r6             0x0      0
   r7             0x0      0
   r8             0x0      0
   r9             0x0      0
   r10            0x0      0
   r11            0x0      0
   r12            0x0      0
   r13            0x0      0
   r14            0x0      0
   r15            0x0      0
   pc             0x0      0
   pr             0x0      0
   gbr            0x0      0
   vbr            0x0      0
   mach           0x0      0
   macl           0x0      0
   sr             0x0      0
   fpul           0                (raw 0x00000000)
   fpscr          0x0      0
   fr0            0                (raw 0x00000000)
   fr1            0                (raw 0x00000000)
   fr2            0                (raw 0x00000000)
   fr3            0                (raw 0x00000000)
   fr4            0                (raw 0x00000000)
   fr5            0                (raw 0x00000000)
   fr6            0                (raw 0x00000000)
   fr7            0                (raw 0x00000000)
   fr8            0                (raw 0x00000000)
   fr9            0                (raw 0x00000000)
   fr10           0                (raw 0x00000000)
   fr11           0                (raw 0x00000000)
   fr12           0                (raw 0x00000000)
   fr13           0                (raw 0x00000000)
   fr14           0                (raw 0x00000000)
   fr15           0                (raw 0x00000000)
   ssr            0x0      0
   spc            0x0      0
   r0b0           0x0      0
   r1b0           0x0      0
   r2b0           0x0      0
   r3b0           0x0      0
   r4b0           0x0      0
   r5b0           0x0      0
   r6b0           0x0      0
   r7b0           0x0      0
   r0b1           0x0      0
   r1b1           0x0      0
   r2b1           0x0      0
   r3b1           0x0      0
   r4b1           0x0      0
   r5b1           0x0      0
   r6b1           0x0      0
   r7b1           0x0      0
   bank           0
   dr0     0x0000000000000000
   dr1     0x0000000000000000
   dr2     0x0000000000000000
   dr3     0x0000000000000000
   dr4     0x0000000000000000
   dr5     0x0000000000000000
   dr6     0x0000000000000000
   dr7     0x0000000000000000
   fv0     0x00000000      0x00000000      0x00000000      0x00000000
   fv1     0x00000000      0x00000000      0x00000000      0x00000000
   fv2     0x00000000      0x00000000      0x00000000      0x00000000
   fv3     0x00000000      0x00000000      0x00000000      0x00000000

After

   (gdb) info all-registers
   r0             0x0      0
   r1             0x0      0
   r2             0x0      0
   r3             0x0      0
   r4             0x0      0
   r5             0x0      0
   r6             0x0      0
   r7             0x0      0
   r8             0x0      0
   r9             0x0      0
   r10            0x0      0
   r11            0x0      0
   r12            0x0      0
   r13            0x0      0
   r14            0x0      0
   r15            0x0      0
   pc             0x0      0
   pr             0x0      0
   gbr            0x0      0
   vbr            0x0      0
   mach           0x0      0
   macl           0x0      0
   sr             0x0      0
   fpul           0 (raw 0x00000000)
   fpscr          0x0      0
   fr0            0 (raw 0x00000000)
   fr1            0 (raw 0x00000000)
   fr2            0 (raw 0x00000000)
   fr3            0 (raw 0x00000000)
   fr4            0 (raw 0x00000000)
   fr5            0 (raw 0x00000000)
   fr6            0 (raw 0x00000000)
   fr7            0 (raw 0x00000000)
   fr8            0 (raw 0x00000000)
   fr9            0 (raw 0x00000000)
   fr10           0 (raw 0x00000000)
   fr11           0 (raw 0x00000000)
   fr12           0 (raw 0x00000000)
   fr13           0 (raw 0x00000000)
   fr14           0 (raw 0x00000000)
   fr15           0 (raw 0x00000000)
   ssr            0x0      0
   spc            0x0      0
   r0b0           0x0      0
   r1b0           0x0      0
   r2b0           0x0      0
   r3b0           0x0      0
   r4b0           0x0      0
   r5b0           0x0      0
   r6b0           0x0      0
   r7b0           0x0      0
   r0b1           0x0      0
   r1b1           0x0      0
   r2b1           0x0      0
   r3b1           0x0      0
   r4b1           0x0      0
   r5b1           0x0      0
   r6b1           0x0      0
   r7b1           0x0      0
   dr0            0 (raw 0x0000000000000000)
   dr2            0 (raw 0x0000000000000000)
   dr4            0 (raw 0x0000000000000000)
   dr6            0 (raw 0x0000000000000000)
   dr8            0 (raw 0x0000000000000000)
   dr10           0 (raw 0x0000000000000000)
   dr12           0 (raw 0x0000000000000000)
   dr14           0 (raw 0x0000000000000000)
   fv0            {0x0, 0x0, 0x0, 0x0}     {0, 0, 0, 0}
   fv4            {0x0, 0x0, 0x0, 0x0}     {0, 0, 0, 0}
   fv8            {0x0, 0x0, 0x0, 0x0}     {0, 0, 0, 0}
   fv12           {0x0, 0x0, 0x0, 0x0}     {0, 0, 0, 0}

Thanks

Andrew Stubbs

[-- Attachment #2: info_register.patch --]
[-- Type: text/plain, Size: 6901 bytes --]

2005-11-16  Andrew Stubbs  <andrew.stubbs@st.com>

	* sh-tdep.c (do_fv_register_info, do_dr_register_info): Delete function.
	(do_bank_register_info, do_bank_register_info): Likewise.
	(sh_print_pseudo_register, sh_do_fp_register): Likewise.
	(sh_do_register, sh_print_register, sh_print_registers_info): Likewise.
	(sh_gdbarch_init): Remove call to set_gdbarch_print_registers_info().

Index: src/gdb/sh-tdep.c
===================================================================
--- src.orig/gdb/sh-tdep.c	2005-11-04 14:20:18.000000000 +0000
+++ src/gdb/sh-tdep.c	2005-11-04 16:57:00.000000000 +0000
@@ -2071,184 +2071,6 @@ sh_pseudo_register_write (struct gdbarch
     }
 }
 
-/* Floating point vector of 4 float registers. */
-static void
-do_fv_register_info (struct gdbarch *gdbarch, struct ui_file *file,
-		     int fv_regnum)
-{
-  int first_fp_reg_num = fv_reg_base_num (fv_regnum);
-  fprintf_filtered (file, "fv%d\t0x%08x\t0x%08x\t0x%08x\t0x%08x\n",
-		    fv_regnum - FV0_REGNUM,
-		    (int) read_register (first_fp_reg_num),
-		    (int) read_register (first_fp_reg_num + 1),
-		    (int) read_register (first_fp_reg_num + 2),
-		    (int) read_register (first_fp_reg_num + 3));
-}
-
-/* Double precision registers. */
-static void
-do_dr_register_info (struct gdbarch *gdbarch, struct ui_file *file,
-		     int dr_regnum)
-{
-  int first_fp_reg_num = dr_reg_base_num (dr_regnum);
-
-  fprintf_filtered (file, "dr%d\t0x%08x%08x\n",
-		    dr_regnum - DR0_REGNUM,
-		    (int) read_register (first_fp_reg_num),
-		    (int) read_register (first_fp_reg_num + 1));
-}
-static void
-do_bank_register_info (struct gdbarch *gdbarch, struct ui_file *file)
-{
-  fprintf_filtered (file, "bank           %d\n",
-		    (int) read_register (BANK_REGNUM));
-}
-
-static void
-sh_print_pseudo_register (struct gdbarch *gdbarch, struct ui_file *file,
-			  int regnum)
-{
-  if (regnum < NUM_REGS || regnum >= NUM_REGS + NUM_PSEUDO_REGS)
-    internal_error (__FILE__, __LINE__,
-		    _("Invalid pseudo register number %d\n"), regnum);
-  else if (regnum == PSEUDO_BANK_REGNUM)
-    do_bank_register_info (gdbarch, file);
-  else if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
-    do_dr_register_info (gdbarch, file, regnum);
-  else if (regnum >= FV0_REGNUM && regnum <= FV_LAST_REGNUM)
-    do_fv_register_info (gdbarch, file, regnum);
-}
-
-static void
-sh_do_fp_register (struct gdbarch *gdbarch, struct ui_file *file, int regnum)
-{				/* do values for FP (float) regs */
-  char *raw_buffer;
-  double flt;			/* double extracted from raw hex data */
-  int inv;
-  int j;
-
-  /* Allocate space for the float. */
-  raw_buffer = (char *) alloca (register_size (gdbarch, FP0_REGNUM));
-
-  /* Get the data in raw format.  */
-  if (!frame_register_read (get_selected_frame (NULL), regnum, raw_buffer))
-    error (_("can't read register %d (%s)"), regnum, REGISTER_NAME (regnum));
-
-  /* Get the register as a number */
-  flt = unpack_double (builtin_type_float, raw_buffer, &inv);
-
-  /* Print the name and some spaces. */
-  fputs_filtered (REGISTER_NAME (regnum), file);
-  print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
-
-  /* Print the value. */
-  if (inv)
-    fprintf_filtered (file, "<invalid float>");
-  else
-    fprintf_filtered (file, "%-10.9g", flt);
-
-  /* Print the fp register as hex. */
-  fprintf_filtered (file, "\t(raw 0x");
-  for (j = 0; j < register_size (gdbarch, regnum); j++)
-    {
-      int idx = (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
-		 ? j
-		 : register_size (gdbarch, regnum) - 1 - j);
-      fprintf_filtered (file, "%02x", (unsigned char) raw_buffer[idx]);
-    }
-  fprintf_filtered (file, ")");
-  fprintf_filtered (file, "\n");
-}
-
-static void
-sh_do_register (struct gdbarch *gdbarch, struct ui_file *file, int regnum)
-{
-  char raw_buffer[MAX_REGISTER_SIZE];
-
-  fputs_filtered (REGISTER_NAME (regnum), file);
-  print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
-
-  /* Get the data in raw format.  */
-  if (!frame_register_read (get_selected_frame (NULL), regnum, raw_buffer))
-    fprintf_filtered (file, "*value not available*\n");
-
-  val_print (gdbarch_register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 'x', 1, 0, Val_pretty_default);
-  fprintf_filtered (file, "\t");
-  val_print (gdbarch_register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 0, 1, 0, Val_pretty_default);
-  fprintf_filtered (file, "\n");
-}
-
-static void
-sh_print_register (struct gdbarch *gdbarch, struct ui_file *file, int regnum)
-{
-  if (regnum < 0 || regnum >= NUM_REGS + NUM_PSEUDO_REGS)
-    internal_error (__FILE__, __LINE__,
-		    _("Invalid register number %d\n"), regnum);
-
-  else if (regnum >= 0 && regnum < NUM_REGS)
-    {
-      if (TYPE_CODE (gdbarch_register_type (gdbarch, regnum)) ==
-	  TYPE_CODE_FLT)
-	sh_do_fp_register (gdbarch, file, regnum);	/* FP regs */
-      else
-	sh_do_register (gdbarch, file, regnum);	/* All other regs */
-    }
-
-  else if (regnum < NUM_REGS + NUM_PSEUDO_REGS)
-    {
-      sh_print_pseudo_register (gdbarch, file, regnum);
-    }
-}
-
-static void
-sh_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
-			 struct frame_info *frame, int regnum, int fpregs)
-{
-  if (regnum != -1)		/* do one specified register */
-    {
-      if (*(REGISTER_NAME (regnum)) == '\0')
-	error (_("Not a valid register for the current processor type"));
-
-      sh_print_register (gdbarch, file, regnum);
-    }
-  else
-    /* do all (or most) registers */
-    {
-      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')
-	    continue;
-
-	  if (TYPE_CODE (gdbarch_register_type (gdbarch, regnum)) ==
-	      TYPE_CODE_FLT)
-	    {
-	      /* true for "INFO ALL-REGISTERS" command */
-	      if (fpregs)
-		sh_do_fp_register (gdbarch, file, regnum);	/* FP regs */
-	    }
-	  else
-	    sh_do_register (gdbarch, file, regnum);	/* All other regs */
-	}
-
-      if (regnum == PSEUDO_BANK_REGNUM
-      	  && REGISTER_NAME (regnum)
-	  && *REGISTER_NAME (regnum))
-	sh_print_pseudo_register (gdbarch, file, regnum++);
-
-      if (fpregs)
-	while (regnum < NUM_REGS + NUM_PSEUDO_REGS)
-	  {
-	    sh_print_pseudo_register (gdbarch, file, regnum);
-	    regnum++;
-	  }
-    }
-}
-
 static int
 sh_dsp_register_sim_regno (int nr)
 {
@@ -2654,8 +2476,6 @@ sh_gdbarch_init (struct gdbarch_info inf
   set_gdbarch_register_type (gdbarch, sh_default_register_type);
   set_gdbarch_register_reggroup_p (gdbarch, sh_register_reggroup_p);
 
-  set_gdbarch_print_registers_info (gdbarch, sh_print_registers_info);
-
   set_gdbarch_breakpoint_from_pc (gdbarch, sh_breakpoint_from_pc);
 
   set_gdbarch_print_insn (gdbarch, gdb_print_insn_sh);

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

* Re: [PATCH][SH] info registers
  2005-11-16 16:48 [PATCH][SH] info registers Andrew STUBBS
@ 2005-11-16 16:54 ` Mark Kettenis
  2005-11-23 18:39   ` Andrew STUBBS
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2005-11-16 16:54 UTC (permalink / raw)
  To: andrew.stubbs; +Cc: gdb-patches

> Date: Wed, 16 Nov 2005 15:51:09 +0000
> From: Andrew STUBBS <andrew.stubbs@st.com>
> 
> Hi,
> 
> sh-tdep.c contains quite a lot of code to implement the 'info registers' 
> command (and friends).
> 
> It has a number of issues:
>   - The double and vector registers are only in hex.
>   - Invalid registers are still printed for some types (not that GDB 
> knows which registers are invalid - that's my next patch).
>   - The double registers are incorrectly named dr0..dr7, and the vector 
> registers incorrectly named fv0..fv3. They should be dr0,dr2,dr4... and 
> fv0,fv4,...
> 
> I have discovered that the default code (when the architecture may 
> override) does everything the SH code does right and yet does not do 
> everything it does wrong. Specifically all the above problems are 
> addressed.
> 
> I therefore propose removing all this garbage entirely.

I'm very much in favour of this, but please wait a week or so with
checking this in to give people who actually use gdb for the SH the
opportunity to object.

Mark


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

* Re: [PATCH][SH] info registers
  2005-11-16 16:54 ` Mark Kettenis
@ 2005-11-23 18:39   ` Andrew STUBBS
  2005-11-23 18:39     ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew STUBBS @ 2005-11-23 18:39 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

Mark Kettenis wrote:
> I'm very much in favour of this, but please wait a week or so with
> checking this in to give people who actually use gdb for the SH the
> opportunity to object.
> 
> Mark
> 

No objections after a week.

May I commit this patch?

Thanks

Andrew Stubbs


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

* Re: [PATCH][SH] info registers
  2005-11-23 18:39   ` Andrew STUBBS
@ 2005-11-23 18:39     ` Daniel Jacobowitz
  2005-11-23 19:08       ` Andrew STUBBS
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2005-11-23 18:39 UTC (permalink / raw)
  To: Andrew STUBBS; +Cc: Mark Kettenis, gdb-patches

On Wed, Nov 23, 2005 at 01:02:54PM +0000, Andrew STUBBS wrote:
> Mark Kettenis wrote:
> >I'm very much in favour of this, but please wait a week or so with
> >checking this in to give people who actually use gdb for the SH the
> >opportunity to object.
> >
> >Mark
> >
> 
> No objections after a week.
> 
> May I commit this patch?

Yes, you may.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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

* Re: [PATCH][SH] info registers
  2005-11-23 18:39     ` Daniel Jacobowitz
@ 2005-11-23 19:08       ` Andrew STUBBS
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew STUBBS @ 2005-11-23 19:08 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Mark Kettenis, gdb-patches

Daniel Jacobowitz wrote:
> Yes, you may.

Thanks, commited.

Andrew


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

end of thread, other threads:[~2005-11-23 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-16 16:48 [PATCH][SH] info registers Andrew STUBBS
2005-11-16 16:54 ` Mark Kettenis
2005-11-23 18:39   ` Andrew STUBBS
2005-11-23 18:39     ` Daniel Jacobowitz
2005-11-23 19:08       ` Andrew STUBBS

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