* tm-rs6000.h (AIX_BUGGY_PTRACE_CALL): Zap, we think we fixed it.
[deliverable/binutils-gdb.git] / gdb / i386-xdep.c
index 0815320de348f821da916c1c283195a305d2a5d2..67e904b83421fa6febfb91b9fed34ba5f79e1b4b 100644 (file)
@@ -1,5 +1,5 @@
 /* Intel 386 stuff.
-   Copyright (C) 1988, 1989 Free Software Foundation, Inc.
+   Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -17,11 +17,10 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
-#include <stdio.h>
 #include "defs.h"
-#include "param.h"
 #include "frame.h"
 #include "inferior.h"
+#include "language.h"
 #include "gdbcore.h"
 
 #ifdef USG
@@ -39,8 +38,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <sys/stat.h>
 
 #include <sys/reg.h>
+#include "ieee-float.h"
+
+#include "target.h"
+
+extern struct ext_format ext_format_i387;
 \f
-/* this table must line up with REGISTER_NAMES in m-i386.h */
+/* this table must line up with REGISTER_NAMES in tm-i386v.h */
 /* symbols like 'EAX' come from <sys/reg.h> */
 static int regmap[] = 
 {
@@ -53,7 +57,11 @@ static int regmap[] =
 /* blockend is the value of u.u_ar0, and points to the
  * place where GS is stored
  */
+
+int
 i386_register_u_addr (blockend, regnum)
+     int blockend;
+     int regnum;
 {
 #if 0
   /* this will be needed if fp registers are reinstated */
@@ -74,68 +82,9 @@ i386_register_u_addr (blockend, regnum)
   
 }
 
-/* This is broken for cross debugging.  Possible solutions are:
-
-1.  Don't worry about whether the thing compiles for cross-debugging.
-Go ahead and call them from i386-tdep.c.
-1a.  Same thing but use some macros in xm-i386.h so that gdb will
-compile for cross-debugging but just give an error (or some such behavior)
-when you attempt to convert floats.
-
-2.  Write a portable (in the sense of running on any machine; it would
-always be for i387 floating-point formats) extended<->double converter
-(which just deals with the values as arrays of char).
-
-3.  Assume the host machine has *some* IEEE chip.  However, IEEE does
-not standardize formats for extended floats (387 is 10 bytes, 68881 is
-12 bytes), so this won't work.  */
-
-i387_to_double (from, to)
-     char *from;
-     char *to;
-{
-  long *lp;
-  /* push extended mode on 387 stack, then pop in double mode
-   *
-   * first, set exception masks so no error is generated -
-   * number will be rounded to inf or 0, if necessary 
-   */
-  asm ("pushl %eax");          /* grab a stack slot */
-  asm ("fstcw (%esp)");                /* get 387 control word */
-  asm ("movl (%esp),%eax");    /* save old value */
-  asm ("orl $0x3f,%eax");              /* mask all exceptions */
-  asm ("pushl %eax");
-  asm ("fldcw (%esp)");                /* load new value into 387 */
-  
-  asm ("movl 8(%ebp),%eax");
-  asm ("fldt (%eax)");         /* push extended number on 387 stack */
-  asm ("fwait");
-  asm ("movl 12(%ebp),%eax");
-  asm ("fstpl (%eax)");                /* pop double */
-  asm ("fwait");
-  
-  asm ("popl %eax");           /* flush modified control word */
-  asm ("fnclex");                      /* clear exceptions */
-  asm ("fldcw (%esp)");                /* restore original control word */
-  asm ("popl %eax");           /* flush saved copy */
-}
-
-double_to_i387 (from, to)
-     char *from;
-     char *to;
-{
-  /* push double mode on 387 stack, then pop in extended mode
-   * no errors are possible because every 64-bit pattern
-   * can be converted to an extended
-   */
-  asm ("movl 8(%ebp),%eax");
-  asm ("fldl (%eax)");
-  asm ("fwait");
-  asm ("movl 12(%ebp),%eax");
-  asm ("fstpt (%eax)");
-  asm ("fwait");
-}
-
+#if 0
+/* mauro@olympus 1991.10.20 -- compiling the following code causes
+   undefined symbols at link time, specifically: corechan, have_inferior_p */
 struct env387 
 {
   unsigned short control;
@@ -153,69 +102,6 @@ struct env387
   unsigned char regs[8][10];
 };
 
-static
-print_387_control_word (control)
-unsigned short control;
-{
-  printf ("control 0x%04x: ", control);
-  printf ("compute to ");
-  switch ((control >> 8) & 3) 
-    {
-    case 0: printf ("24 bits; "); break;
-    case 1: printf ("(bad); "); break;
-    case 2: printf ("53 bits; "); break;
-    case 3: printf ("64 bits; "); break;
-    }
-  printf ("round ");
-  switch ((control >> 10) & 3) 
-    {
-    case 0: printf ("NEAREST; "); break;
-    case 1: printf ("DOWN; "); break;
-    case 2: printf ("UP; "); break;
-    case 3: printf ("CHOP; "); break;
-    }
-  if (control & 0x3f) 
-    {
-      printf ("mask:");
-      if (control & 0x0001) printf (" INVALID");
-      if (control & 0x0002) printf (" DENORM");
-      if (control & 0x0004) printf (" DIVZ");
-      if (control & 0x0008) printf (" OVERF");
-      if (control & 0x0010) printf (" UNDERF");
-      if (control & 0x0020) printf (" LOS");
-      printf (";");
-    }
-  printf ("\n");
-  if (control & 0xe080) printf ("warning: reserved bits on 0x%x\n",
-                               control & 0xe080);
-}
-
-static
-print_387_status_word (status)
-     unsigned short status;
-{
-  printf ("status 0x%04x: ", status);
-  if (status & 0xff) 
-    {
-      printf ("exceptions:");
-      if (status & 0x0001) printf (" INVALID");
-      if (status & 0x0002) printf (" DENORM");
-      if (status & 0x0004) printf (" DIVZ");
-      if (status & 0x0008) printf (" OVERF");
-      if (status & 0x0010) printf (" UNDERF");
-      if (status & 0x0020) printf (" LOS");
-      if (status & 0x0040) printf (" FPSTACK");
-      printf ("; ");
-    }
-  printf ("flags: %d%d%d%d; ",
-         (status & 0x4000) != 0,
-         (status & 0x0400) != 0,
-         (status & 0x0200) != 0,
-         (status & 0x0100) != 0);
-  
-  printf ("top %d\n", (status >> 11) & 7);
-}
-
 static
 print_387_status (status, ep)
      unsigned short status;
@@ -244,9 +130,11 @@ print_387_status (status, ep)
   
   print_387_control_word (ep->control);
   printf ("last exception: ");
-  printf ("opcode 0x%x; ", ep->opcode);
-  printf ("pc 0x%x:0x%x; ", ep->code_seg, ep->eip);
-  printf ("operand 0x%x:0x%x\n", ep->operand_seg, ep->operand);
+  printf ("opcode %s; ", local_hex_string(ep->opcode));
+  printf ("pc %s:", local_hex_string(ep->code_seg));
+  printf ("%s; ", local_hex_string(ep->eip));
+  printf ("operand %s", local_hex_string(ep->operand_seg));
+  printf (":%s\n", local_hex_string(ep->operand));
   
   top = (ep->status >> 11) & 7;
   
@@ -267,17 +155,18 @@ print_387_status (status, ep)
       for (i = 9; i >= 0; i--)
        printf ("%02x", ep->regs[fpreg][i]);
       
-      i387_to_double (ep->regs[fpreg], (char *)&val);
+      ieee_extended_to_double (&ext_format_i387, (char *)ep->regs[fpreg],
+                              &val);
       printf ("  %g\n", val);
     }
   if (ep->r0)
-    printf ("warning: reserved0 is 0x%x\n", ep->r0);
+    warning ("reserved0 is %s\n", local_hex_string(ep->r0));
   if (ep->r1)
-    printf ("warning: reserved1 is 0x%x\n", ep->r1);
+    warning ("reserved1 is %s\n", local_hex_string(ep->r1));
   if (ep->r2)
-    printf ("warning: reserved2 is 0x%x\n", ep->r2);
+    warning ("reserved2 is %s\n", local_hex_string(ep->r2));
   if (ep->r3)
-    printf ("warning: reserved3 is 0x%x\n", ep->r3);
+    warning ("reserved3 is %s\n", local_hex_string(ep->r3));
 }
 
 #ifndef U_FPSTATE
@@ -292,24 +181,25 @@ i386_float_info ()
   struct fpstate *fpstatep;
   char buf[sizeof (struct fpstate) + 2 * sizeof (int)];
   unsigned int uaddr;
-  char fpvalid;
+  char fpvalid = 0;
   unsigned int rounded_addr;
   unsigned int rounded_size;
   extern int corechan;
   int skip;
   
   uaddr = (char *)&u.u_fpvalid - (char *)&u;
-  if (have_inferior_p()) 
+  if (target_has_execution)
     {
       unsigned int data;
       unsigned int mask;
       
       rounded_addr = uaddr & -sizeof (int);
-      data = ptrace (3, inferior_pid, rounded_addr, 0);
+      data = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) rounded_addr, 0);
       mask = 0xff << ((uaddr - rounded_addr) * 8);
       
       fpvalid = ((data & mask) != 0);
     } 
+#if 0
   else 
     {
       if (lseek (corechan, uaddr, 0) < 0)
@@ -318,6 +208,7 @@ i386_float_info ()
        perror ("read on core file");
       
     }
+#endif /* no core support yet */
   
   if (fpvalid == 0) 
     {
@@ -326,7 +217,7 @@ i386_float_info ()
     }
   
   uaddr = (char *)&U_FPSTATE(u) - (char *)&u;
-  if (have_inferior_p ()) 
+  if (target_has_execution)
     {
       int *ip;
       
@@ -338,10 +229,11 @@ i386_float_info ()
       ip = (int *)buf;
       for (i = 0; i < rounded_size; i++) 
        {
-         *ip++ = ptrace (3, inferior_pid, rounded_addr, 0);
+         *ip++ = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) rounded_addr, 0);
          rounded_addr += sizeof (int);
        }
     } 
+#if 0
   else 
     {
       if (lseek (corechan, uaddr, 0) < 0)
@@ -350,8 +242,9 @@ i386_float_info ()
        perror_with_name ("read from core file");
       skip = 0;
     }
-  
+ #endif        /* 0 */ 
+
   fpstatep = (struct fpstate *)(buf + skip);
   print_387_status (fpstatep->status, (struct env387 *)fpstatep->state);
 }
-
+#endif /* mauro@olympus 1991.10.20 */
This page took 0.035229 seconds and 4 git commands to generate.