]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/i386v-nat.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gdb / i386v-nat.c
index 07ddc9f7b5de52298b9efe6149502f262ae5f917..5618687a6895d66dae3c756e1059a2a6450865e3 100644 (file)
@@ -1,5 +1,5 @@
 /* Intel 386 native support for SYSV systems (pre-SVR4).
-   Copyright (C) 1988, 1989, 1991, 1992, 1994 Free Software Foundation, Inc.
+   Copyright (C) 1988, 89, 91, 92, 94, 96, 1998 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -15,9 +15,18 @@ GNU General Public License for more details.
 
 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.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+
+#ifdef HAVE_PTRACE_H
+# include <ptrace.h>
+#else
+# ifdef HAVE_SYS_PTRACE_H
+#  include <sys/ptrace.h>
+# endif
+#endif
+
 #include "frame.h"
 #include "inferior.h"
 #include "language.h"
@@ -34,14 +43,26 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <sys/ioctl.h>
 #include <fcntl.h>
 
-#ifdef TARGET_CAN_USE_HARDWARE_WATCHPOINT
-#include <sys/debugreg.h>
+
+/* FIXME: The following used to be just "#include <sys/debugreg.h>", but
+ * the the Linux 2.1.x kernel and glibc 2.0.x are not in sync; including
+ * <sys/debugreg.h> will result in an error.  With luck, these losers
+ * will get their act together and we can trash this hack in the near future.
+ * --jsm 1998-10-21
+ */
+
+#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS
+# ifdef HAVE_ASM_DEBUGREG_H
+#  include <asm/debugreg.h>
+# else
+#  include <sys/debugreg.h>
+# endif
 #endif
 
 #include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
 
-#ifndef NO_SYS_REG_H
+#ifdef HAVE_SYS_REG_H
 #include <sys/reg.h>
 #endif
 
@@ -69,26 +90,37 @@ i386_register_u_addr (blockend, regnum)
      int blockend;
      int regnum;
 {
-#if 0
-  /* this will be needed if fp registers are reinstated */
-  /* for now, you can look at them with 'info float'
-   * sys5 wont let you change them with ptrace anyway
-   */
-  if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM) 
+  struct user u;
+  int fpstate;
+  int ubase;
+
+  ubase = blockend;
+  /* FIXME:  Should have better way to test floating point range */
+  if (regnum >= FP0_REGNUM && regnum <= (FP0_REGNUM + 7)) 
     {
-      int ubase, fpstate;
-      struct user u;
-      ubase = blockend + 4 * (SS + 1) - KSTKSZ;
-      fpstate = ubase + ((char *)&u.u_fpstate - (char *)&u);
+#ifdef KSTKSZ  /* SCO, and others? */
+      ubase += 4 * (SS + 1) - KSTKSZ;
+      fpstate = ubase + ((char *)&u.u_fps.u_fpstate - (char *)&u);
       return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM));
+#else
+      fpstate = ubase + ((char *)&u.i387.st_space - (char *)&u);
+      return (fpstate + 10 * (regnum - FP0_REGNUM));
+#endif
     } 
   else
-#endif
-    return (blockend + 4 * regmap[regnum]);
+    {
+      return (ubase + 4 * regmap[regnum]);
+    }
   
 }
 \f
-#ifdef TARGET_CAN_USE_HARDWARE_WATCHPOINT
+int
+kernel_u_size ()
+{
+  return (sizeof (struct user));
+}
+\f
+#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS
 
 #if !defined (offsetof)
 #define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
@@ -101,11 +133,12 @@ static int debug_control_mirror;
 static CORE_ADDR address_lookup[DR_LASTADDR - DR_FIRSTADDR + 1];
 
 static int
-i386_insert_nonaligned_watchpoint PARAMS ((int, CORE_ADDR, CORE_ADDR, int,
+i386_insert_aligned_watchpoint PARAMS ((int, CORE_ADDR, CORE_ADDR, int,
                                           int));
 
 static int
-i386_insert_aligned_watchpoint PARAMS ((pid, addr, len, rw));
+i386_insert_nonaligned_watchpoint PARAMS ((int, CORE_ADDR, CORE_ADDR, int,
+                                          int));
 
 /* Insert a watchpoint.  */
 
@@ -143,7 +176,7 @@ i386_insert_aligned_watchpoint (pid, waddr, addr, len, rw)
   if (i > DR_LASTADDR)
     return -1;
 
-  read_write_bits = ((rw & 1) ? DR_RW_READ : 0) | ((rw & 2) ? DR_RW_WRITE : 0);
+  read_write_bits = (rw & 1) ? DR_RW_READ : DR_RW_WRITE;
 
   if (len == 1)
     len_bits = DR_LEN_1;
@@ -210,7 +243,7 @@ i386_insert_nonaligned_watchpoint (pid, waddr, addr, len, rw)
       size = (len > 4) ? 3 : len - 1;
       size = size_try_array[size * 4 + align];
 
-      rv = i386_insert_watchpoint (pid, waddr, addr, size, rw);
+      rv = i386_insert_aligned_watchpoint (pid, waddr, addr, size, rw);
       if (rv)
        {
          i386_remove_watchpoint (pid, waddr, size);
@@ -271,7 +304,7 @@ i386_stopped_by_watchpoint (pid)
   return 0;
 }
 
-#endif /* TARGET_CAN_USE_HARDWARE_WATCHPOINT */
+#endif /* TARGET_HAS_HARDWARE_WATCHPOINTS */
 
 #if 0
 /* using FLOAT_INFO as is would be a problem.  FLOAT_INFO is called