* config/irix3.mh (NATDEPFILES): nat-mips.o => mips-nat.o.
[deliverable/binutils-gdb.git] / gdb / sparc-xdep.c
index 89fcb8d0a97795193515f9540185fcc9dab518a5..a040bf5ffb3717ff12cddacf2bd406c2a21023e9 100644 (file)
@@ -1,41 +1,49 @@
-/* Machine-dependent code which would otherwise be in inflow.c and core.c,
-   for GDB, the GNU debugger, for SPARC host systems.
-
-   Copyright (C) 1986, 1987, 1989, 1990  Free Software Foundation, Inc.
+/* Host-dependent code for SPARC host systems, for GDB, the GNU debugger.
+   Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
-GDB is free software; you can redistribute it and/or modify
+This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
-GDB is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GDB; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+/* This code only compiles when we have the definitions in tm-sparc.h.  */
 
-#include <stdio.h>
+#define        TM_FILE_OVERRIDE
 #include "defs.h"
 #include "tm-sparc.h"
-#include "param-no-tm.h"
+
 #include "inferior.h"
 #include "target.h"
 
 #include <sys/param.h>
-#include <sys/file.h>          /* For L_SET */
-
 #include <sys/ptrace.h>
 #include <machine/reg.h>
 
 #include "gdbcore.h"
 #include <sys/core.h>
 
-extern char register_valid[];
+/* We don't store all registers immediately when requested, since they
+   get sent over in large chunks anyway.  Instead, we accumulate most
+   of the changes and send them over once.  "deferred_stores" keeps
+   track of which sets of registers we have locally-changed copies of,
+   so we only need send the groups that have changed.  */
+
+#define        INT_REGS        1
+#define        STACK_REGS      2
+#define        FP_REGS         4
+
+/* The variable deferred_stores itself is defined in sparc-tdep.c.  */
 
 /* Fetch one or more registers from the inferior.  REGNO == -1 to get
    them all.  We actually fetch more than requested, when convenient,
@@ -63,11 +71,13 @@ fetch_inferior_registers (regno)
       || regno >= Y_REGNUM
       || (!register_valid[SP_REGNUM] && regno < I7_REGNUM))
     {
-      if (0 != ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers))
-           perror("ptrace_getregs");
+      if (0 != ptrace (PTRACE_GETREGS, inferior_pid,
+                      (PTRACE_ARG3_TYPE) &inferior_registers, 0))
+       perror("ptrace_getregs");
       
       registers[REGISTER_BYTE (0)] = 0;
-      bcopy (&inferior_registers.r_g1, &registers[REGISTER_BYTE (1)], 15 * REGISTER_RAW_SIZE (G0_REGNUM));
+      memcpy (&registers[REGISTER_BYTE (1)], &inferior_registers.r_g1,
+             15 * REGISTER_RAW_SIZE (G0_REGNUM));
       *(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; 
       *(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
       *(int *)&registers[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc;
@@ -90,10 +100,12 @@ fetch_inferior_registers (regno)
   /* Floating point registers */
   if (regno == -1 || (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 31))
     {
-      if (0 != ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers))
+      if (0 != ptrace (PTRACE_GETFPREGS, inferior_pid,
+                      (PTRACE_ARG3_TYPE) &inferior_fp_registers,
+                      0))
            perror("ptrace_getfpregs");
-      bcopy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
-            sizeof inferior_fp_registers.fpu_fr);
+      memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
+             sizeof inferior_fp_registers.fpu_fr);
       /* bcopy (&inferior_fp_registers.Fpu_fsr,
             &registers[REGISTER_BYTE (FPS_REGNUM)],
             sizeof (FPU_FSR_TYPE));  FIXME???  -- gnu@cyg */
@@ -128,12 +140,7 @@ fetch_inferior_registers (regno)
    If REGNO is -1, do this for all registers.
    Otherwise, REGNO specifies which register (so we can save time).  */
 
-#define        INT_REGS        1
-#define        STACK_REGS      2
-#define        FP_REGS         4
-int deferred_stores = 0;       /* Cumulates stores we want to do eventually. */
-
-int
+void
 store_inferior_registers (regno)
      int regno;
 {
@@ -174,7 +181,7 @@ store_inferior_registers (regno)
       else
        {
          deferred_stores |= wanna_store;
-         return 0;
+         return;
        }
     }
 
@@ -203,8 +210,8 @@ store_inferior_registers (regno)
     {
       if (!register_valid[G1_REGNUM]) abort();
 
-      bcopy (&registers[REGISTER_BYTE (G1_REGNUM)],
-            &inferior_registers.r_g1, 15 * REGISTER_RAW_SIZE (G1_REGNUM));
+      memcpy (&inferior_registers.r_g1, &registers[REGISTER_BYTE (G1_REGNUM)],
+             15 * REGISTER_RAW_SIZE (G1_REGNUM));
 
       inferior_registers.r_ps =
        *(int *)&registers[REGISTER_BYTE (PS_REGNUM)];
@@ -215,33 +222,33 @@ store_inferior_registers (regno)
       inferior_registers.r_y =
        *(int *)&registers[REGISTER_BYTE (Y_REGNUM)];
 
-      if (0 != ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers))
+      if (0 != ptrace (PTRACE_SETREGS, inferior_pid,
+                      (PTRACE_ARG3_TYPE) &inferior_registers, 0))
        perror("ptrace_setregs");
     }
 
   if (wanna_store & FP_REGS)
     {
       if (!register_valid[FP0_REGNUM+9]) abort();
-      bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)],
-            &inferior_fp_registers,
-            sizeof inferior_fp_registers.fpu_fr);
+      memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
+             sizeof inferior_fp_registers.fpu_fr);
 
-/*      bcopy (&registers[REGISTER_BYTE (FPS_REGNUM)],
-            &inferior_fp_registers.Fpu_fsr,
-            sizeof (FPU_FSR_TYPE));
+/*    memcpy (&inferior_fp_registers.Fpu_fsr, 
+             &registers[REGISTER_BYTE (FPS_REGNUM)], sizeof (FPU_FSR_TYPE));
 ****/
       if (0 !=
-        ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers))
+        ptrace (PTRACE_SETFPREGS, inferior_pid,
+                (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0))
         perror("ptrace_setfpregs");
     }
-    return 0;
 }
 \f
 void
-fetch_core_registers (core_reg_sect, core_reg_size, which)
+fetch_core_registers (core_reg_sect, core_reg_size, which, ignore)
   char *core_reg_sect;
   unsigned core_reg_size;
   int which;
+  unsigned int ignore; /* reg addr, unused in this version */
 {
 
   if (which == 0) {
@@ -253,9 +260,8 @@ fetch_core_registers (core_reg_sect, core_reg_size, which)
     *(int *)&registers[REGISTER_BYTE (0)] = 0;
 
     /* The globals and output registers.  */
-    bcopy (&gregs->r_g1, 
-          &registers[REGISTER_BYTE (G1_REGNUM)],
-          15 * REGISTER_RAW_SIZE (G1_REGNUM));
+    memcpy (&registers[REGISTER_BYTE (G1_REGNUM)], &gregs->r_g1, 
+           15 * REGISTER_RAW_SIZE (G1_REGNUM));
     *(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps;
     *(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc;
     *(int *)&registers[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc;
@@ -285,12 +291,10 @@ fetch_core_registers (core_reg_sect, core_reg_size, which)
 #define fpuregs  ((struct fpu *) core_reg_sect)
     if (core_reg_size >= sizeof (struct fpu))
       {
-       bcopy (fpuregs->fpu_regs,
-              &registers[REGISTER_BYTE (FP0_REGNUM)],
-              sizeof (fpuregs->fpu_regs));
-       bcopy (&fpuregs->fpu_fsr,
-              &registers[REGISTER_BYTE (FPS_REGNUM)],
-              sizeof (FPU_FSR_TYPE));
+       memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], fpuregs->fpu_regs,
+               sizeof (fpuregs->fpu_regs));
+       memcpy (&registers[REGISTER_BYTE (FPS_REGNUM)], &fpuregs->fpu_fsr,
+               sizeof (FPU_FSR_TYPE));
       }
     else
       fprintf (stderr, "Couldn't read float regs from core file\n");
This page took 0.027045 seconds and 4 git commands to generate.