Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@wins.uva.nl>
To: eliz@is.elta.co.il
Cc: gdb@sources.redhat.com
Subject: Re: Register cache
Date: Fri, 16 Feb 2001 15:21:00 -0000	[thread overview]
Message-ID: <200102162321.f1GNL9q08272@delius.kettenis.local> (raw)
In-Reply-To: <200102121837.NAA07780@indy.delorie.com>

   Date: Mon, 12 Feb 2001 13:37:25 -0500 (EST)
   From: Eli Zaretskii <eliz@delorie.com>

   > However,
   > that's really a coding philosophy issue, and since Mark wrote i387-nat.c,
   > I'm inclined to bow to his opinion on how it gets changed.

   Perhaps Mark could take your opinion into consideration ;-).

How about the attached patch?  Just give a yell and I'll check it in

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* i387-nat.c: Use regnum instead of regno consistently.  Fix
	comments accordingly.
	(i387_supply_register): New function.
	(i387_supply_fsave): Implement using i387_supply_register.
	* i387-nat.h: Use regnum instead of regno consistently.  Fix
	comments accordingly.

Index: i387-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i387-nat.c,v
retrieving revision 1.2
diff -u -p -r1.2 i387-nat.c
--- i387-nat.c 2000/08/10 14:54:51 1.2
+++ i387-nat.c 2001/02/16 23:19:48
@@ -1,5 +1,5 @@
 /* Native-dependent code for the i387.
-   Copyright 2000 Free Software Foundation, Inc.
+   Copyright 2000, 2001 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -22,15 +22,17 @@
 #include "inferior.h"
 #include "value.h"
 
+#include "i387-nat.h"
+
 /* FIXME: kettenis/2000-05-21: Right now more than a few i386 targets
    define their own routines to manage the floating-point registers in
    GDB's register array.  Most (if not all) of these targets use the
    format used by the "fsave" instruction in their communication with
    the OS.  They should all be converted to use the routines below.  */
 
-/* At fsave_offset[REGNO] you'll find the offset to the location in
+/* At fsave_offset[REGNUM] you'll find the offset to the location in
    the data structure used by the "fsave" instruction where GDB
-   register REGNO is stored.  */
+   register REGNUM is stored.  */
 
 static int fsave_offset[] =
 {
@@ -55,6 +57,32 @@ static int fsave_offset[] =
 #define FSAVE_ADDR(fsave, regnum) (fsave + fsave_offset[regnum - FP0_REGNUM])
 \f
 
+/* Fill register REGNUM in GDB's register array with the appropriate
+   value from *FSAVE.  This function masks off any of the reserved
+   bits in *FSAVE.  */
+
+void
+i387_supply_register (int regnum, char *fsave)
+{
+  /* Most of the FPU control registers occupy only 16 bits in
+     the fsave area.  Give those a special treatment.  */
+  if (regnum >= FIRST_FPU_CTRL_REGNUM
+      && regnum != FCOFF_REGNUM && regnum != FDOFF_REGNUM)
+    {
+      unsigned int val = *(unsigned short *) (FSAVE_ADDR (fsave, regnum));
+
+      if (regnum == FOP_REGNUM)
+	{
+	  val &= ((1 << 11) - 1);
+	  supply_register (regnum, (char *) &val);
+	}
+      else
+	supply_register (regnum, (char *) &val);
+    }
+  else
+    supply_register (regnum, FSAVE_ADDR (fsave, regnum));
+}
+
 /* Fill GDB's register array with the floating-point register values
    in *FSAVE.  This function masks off any of the reserved
    bits in *FSAVE.  */
@@ -65,39 +93,21 @@ i387_supply_fsave (char *fsave)
   int i;
 
   for (i = FP0_REGNUM; i <= LAST_FPU_CTRL_REGNUM; i++)
-    {
-      /* Most of the FPU control registers occupy only 16 bits in
-	 the fsave area.  Give those a special treatment.  */
-      if (i >= FIRST_FPU_CTRL_REGNUM
-	  && i != FCOFF_REGNUM && i != FDOFF_REGNUM)
-	{
-	  unsigned int val = *(unsigned short *) (FSAVE_ADDR (fsave, i));
-
-	  if (i == FOP_REGNUM)
-	    {
-	      val &= ((1 << 11) - 1);
-	      supply_register (i, (char *) &val);
-	    }
-	  else
-	    supply_register (i, (char *) &val);
-	}
-      else
-	supply_register (i, FSAVE_ADDR (fsave, i));
-    }
+    i387_supply_register (i, fsave);
 }
 
-/* Fill register REGNO (if it is a floating-point register) in *FSAVE
-   with the value in GDB's register array.  If REGNO is -1, do this
+/* Fill register REGNUM (if it is a floating-point register) in *FSAVE
+   with the value in GDB's register array.  If REGNUM is -1, do this
    for all registers.  This function doesn't touch any of the reserved
    bits in *FSAVE.  */
 
 void
-i387_fill_fsave (char *fsave, int regno)
+i387_fill_fsave (char *fsave, int regnum)
 {
   int i;
 
   for (i = FP0_REGNUM; i <= LAST_FPU_CTRL_REGNUM; i++)
-    if (regno == -1 || regno == i)
+    if (regnum == -1 || regnum == i)
       {
 	/* Most of the FPU control registers occupy only 16 bits in
            the fsave area.  Give those a special treatment.  */
@@ -125,9 +135,9 @@ i387_fill_fsave (char *fsave, int regno)
 }
 \f
 
-/* At fxsave_offset[REGNO] you'll find the offset to the location in
+/* At fxsave_offset[REGNUM] you'll find the offset to the location in
    the data structure used by the "fxsave" instruction where GDB
-   register REGNO is stored.  */
+   register REGNUM is stored.  */
 
 static int fxsave_offset[] =
 {
@@ -223,18 +233,18 @@ i387_supply_fxsave (char *fxsave)
     }
 }
 
-/* Fill register REGNO (if it is a floating-point or SSE register) in
-   *FXSAVE with the value in GDB's register array.  If REGNO is -1, do
+/* Fill register REGNUM (if it is a floating-point or SSE register) in
+   *FXSAVE with the value in GDB's register array.  If REGNUM is -1, do
    this for all registers.  This function doesn't touch any of the
    reserved bits in *FXSAVE.  */
 
 void
-i387_fill_fxsave (char *fxsave, int regno)
+i387_fill_fxsave (char *fxsave, int regnum)
 {
   int i;
 
   for (i = FP0_REGNUM; i <= MXCSR_REGNUM; i++)
-    if (regno == -1 || regno == i)
+    if (regnum == -1 || regnum == i)
       {
 	/* Most of the FPU control registers occupy only 16 bits in
            the fxsave area.  Give those a special treatment.  */
Index: i387-nat.h
===================================================================
RCS file: /cvs/src/src/gdb/i387-nat.h,v
retrieving revision 1.2
diff -u -p -r1.2 i387-nat.h
--- i387-nat.h 2000/08/10 14:54:51 1.2
+++ i387-nat.h 2001/02/16 23:19:48
@@ -1,5 +1,5 @@
 /* Native-dependent code for the i387.
-   Copyright 2000 Free Software Foundation, Inc.
+   Copyright 2000, 2001 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,18 +21,24 @@
 #ifndef I387_NAT_H
 #define I387_NAT_H
 
+/* Fill register REGNO in GDB's register array with the appropriate
+   value from *FSAVE.  This function masks off any of the reserved
+   bits in *FSAVE.  */
+
+extern void i387_supply_register (int regnum, char *fsave);
+
 /* Fill GDB's register array with the floating-point register values
    in *FSAVE.  This function masks off any of the reserved
    bits in *FSAVE.  */
 
 extern void i387_supply_fsave (char *fsave);
 
-/* Fill register REGNO (if it is a floating-point register) in *FSAVE
-   with the value in GDB's register array.  If REGNO is -1, do this
+/* Fill register REGNUM (if it is a floating-point register) in *FSAVE
+   with the value in GDB's register array.  If REGNUM is -1, do this
    for all registers.  This function doesn't touch any of the reserved
    bits in *FSAVE.  */
 
-extern void i387_fill_fsave (char *fsave, int regno);
+extern void i387_fill_fsave (char *fsave, int regnum);
 
 /* Fill GDB's register array with the floating-point and SSE register
    values in *FXSAVE.  This function masks off any of the reserved
@@ -40,11 +46,11 @@ extern void i387_fill_fsave (char *fsave
 
 extern void i387_supply_fxsave (char *fxsave);
 
-/* Fill register REGNO (if it is a floating-point or SSE register) in
-   *FXSAVE with the value in GDB's register array.  If REGNO is -1, do
+/* Fill register REGNUM (if it is a floating-point or SSE register) in
+   *FXSAVE with the value in GDB's register array.  If REGNUM is -1, do
    this for all registers.  This function doesn't touch any of the
    reserved bits in *FXSAVE.  */
 
-extern void i387_fill_fxsave (char *fxsave, int regno);
+extern void i387_fill_fxsave (char *fxsave, int regnum);
 
 #endif /* i387-nat.h */


  reply	other threads:[~2001-02-16 15:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-10 14:37 Mark Kettenis
2001-02-11 12:07 ` Nick Duffek
2001-02-11 23:26   ` Eli Zaretskii
     [not found]     ` <200102121753.f1CHr9t11723@rtl.cygnus.com>
2001-02-12 10:37       ` Eli Zaretskii
2001-02-16 15:21         ` Mark Kettenis [this message]
2001-02-17  0:28           ` Eli Zaretskii
2001-02-17  3:19             ` Mark Kettenis
2001-02-13 13:38 ` Andrew Cagney
     [not found] <8AE4B526B977D411841F00A0CC334020052C28@cuz-exchange.sdesigns.net>
     [not found] ` <39AC598A.DFAF67E9@ozemail.com.au>
2001-03-26  6:46   ` Register Cache Andrew Cagney
2001-03-26  7:22     ` Fernando Nasser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200102162321.f1GNL9q08272@delius.kettenis.local \
    --to=kettenis@wins.uva.nl \
    --cc=eliz@is.elta.co.il \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox