* elfxx-ia64.c: (elfNN_ia64_modify_segment_map): Properly scan
[binutils-gdb.git] / gdb / i386gnu-nat.c
index cc7d6e5ffc7828c8cf73b976dcecd7d6e9c518f5..3fa99a34d884facf47f02e08cd6bf2bed8599d6c 100644 (file)
 #include <mach/message.h>
 #include <mach/exception.h>
 
+#include "i386-tdep.h"
+
 #include "gnu-nat.h"
-#include "i387-nat.h"
+#include "i387-tdep.h"
 
+#ifdef HAVE_SYS_PROCFS_H
+# include <sys/procfs.h>
+# include "gregset.h"
+#endif
 
 /* Offset to the thread_state_t location where REG is stored.  */
 #define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg)
@@ -76,9 +82,7 @@ fetch_fpregs (struct proc *thread)
     {
       int i;
 
-      for (i = FP0_REGNUM; i <= FP7_REGNUM; i++)
-       supply_register (i, NULL);
-      for (i = FCTRL_REGNUM; i <= FOP_REGNUM; i++)
+      for (i = FP0_REGNUM; i <= FOP_REGNUM; i++)
        supply_register (i, NULL);
 
       return;
@@ -88,6 +92,24 @@ fetch_fpregs (struct proc *thread)
   i387_supply_fsave (state.hw_state);
 }
 
+#ifdef HAVE_SYS_PROCFS_H
+/* These two calls are used by the core-regset.c code for
+   reading ELF core files.  */
+void
+supply_gregset (gdb_gregset_t *gregs)
+{
+  int i;
+  for (i = 0; i < I386_NUM_GREGS; i++)
+    supply_register (i, REG_ADDR (gregs, i));
+}
+
+void
+supply_fpregset (gdb_fpregset_t *fpregs)
+{
+  i387_supply_fsave ((char *) fpregs);
+}
+#endif
+
 /* Fetch register REGNO, or all regs if REGNO is -1.  */
 void
 gnu_fetch_registers (int regno)
@@ -102,7 +124,7 @@ gnu_fetch_registers (int regno)
     error ("Can't fetch registers from thread %d: No such thread",
           PIDGET (inferior_ptid));
 
-  if (regno < NUM_GREGS || regno == -1)
+  if (regno < I386_NUM_GREGS || regno == -1)
     {
       thread_state_t state;
 
@@ -121,7 +143,7 @@ gnu_fetch_registers (int regno)
 
          proc_debug (thread, "fetching all register");
 
-         for (i = 0; i < NUM_GREGS; i++)
+         for (i = 0; i < I386_NUM_GREGS; i++)
            supply_register (i, REG_ADDR (state, i));
          thread->fetched_regs = ~0;
        }
@@ -134,7 +156,7 @@ gnu_fetch_registers (int regno)
        }
     }
 
-  if (regno >= NUM_GREGS || regno == -1)
+  if (regno >= I386_NUM_GREGS || regno == -1)
     {
       proc_debug (thread, "fetching floating-point registers");
 
@@ -189,7 +211,7 @@ gnu_store_registers (int regno)
     error ("Couldn't store registers into thread %d: No such thread",
           PIDGET (inferior_ptid));
 
-  if (regno < NUM_GREGS || regno == -1)
+  if (regno < I386_NUM_GREGS || regno == -1)
     {
       thread_state_t state;
       thread_state_data_t old_state;
@@ -216,7 +238,7 @@ gnu_store_registers (int regno)
        {
          int check_regno;
 
-         for (check_regno = 0; check_regno < NUM_GREGS; check_regno++)
+         for (check_regno = 0; check_regno < I386_NUM_GREGS; check_regno++)
            if ((thread->fetched_regs & (1 << check_regno))
                && memcpy (REG_ADDR (&old_state, check_regno),
                           REG_ADDR (state, check_regno),
@@ -243,7 +265,7 @@ gnu_store_registers (int regno)
 
          proc_debug (thread, "storing all registers");
 
-         for (i = 0; i < NUM_GREGS; i++)
+         for (i = 0; i < I386_NUM_GREGS; i++)
            if (register_valid[i])
              fill (state, i);
        }
@@ -262,7 +284,7 @@ gnu_store_registers (int regno)
 
 #undef fill
 
-  if (regno >= NUM_GREGS || regno == -1)
+  if (regno >= I386_NUM_GREGS || regno == -1)
     {
       proc_debug (thread, "storing floating-point registers");