[PATCH]: Make fp0_regnum a multi-arch variable.

msnyder@cygnus.com msnyder@cygnus.com
Mon May 8 18:28:00 GMT 2000


The macro FP0_REGNUM is used widely as a test of whether the target
architecture has an FPU.  This has to be a runtime test for multi-arch.

2000-05-08  Michael Snyder  <msnyder@seadog.cygnus.com>

        * gdbarch.sh: Add FP0_REGNUM to list of multi-arched register numbers.
        * gdbarch.c, gdbarch.h: Regenerate.
        * core-regset.c: Change FP0_REGNUM to a runtime test.
        * procfs.c: Ditto.
        * sun3-nat.c: Ditto.
        * sparc-tdep.c: Ditto.

        * i386mach-nat.c: Remove unnecessary ifdef for FP0_REGNUM.
        * ptx4-nat.c: Ditto.

Index: core-regset.c
===================================================================
RCS file: /cvs/src/src/gdb/core-regset.c,v
retrieving revision 1.1.1.3
diff -p -r1.1.1.3 core-regset.c
*** core-regset.c	1999/10/05 23:08:06	1.1.1.3
--- core-regset.c	2000/05/09 01:01:27
*************** fetch_core_registers (core_reg_sect, cor
*** 109,117 ****
        else
  	{
  	  memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset));
! #if defined (FP0_REGNUM)
! 	  supply_fpregset (&fpregset);
! #endif
  	}
      }
  #endif /* defined(HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T) */
--- 109,116 ----
        else
  	{
  	  memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset));
! 	  if (FP0_REGNUM >= 0)
! 	    supply_fpregset (&fpregset);
  	}
      }
  #endif /* defined(HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T) */
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.20
diff -p -r1.20 gdbarch.c
*** gdbarch.c	2000/05/02 09:36:56	1.20
--- gdbarch.c	2000/05/09 01:01:27
*************** struct gdbarch
*** 146,151 ****
--- 146,152 ----
    int sp_regnum;
    int fp_regnum;
    int pc_regnum;
+   int fp0_regnum;
    int npc_regnum;
    int nnpc_regnum;
    gdbarch_register_name_ftype *register_name;
*************** struct gdbarch startup_gdbarch = {
*** 283,288 ****
--- 284,290 ----
    0,
    0,
    0,
+   0,
    generic_get_saved_register,
    0,
    0,
*************** gdbarch_alloc (const struct gdbarch_info
*** 353,358 ****
--- 355,361 ----
    gdbarch->sp_regnum = -1;
    gdbarch->fp_regnum = -1;
    gdbarch->pc_regnum = -1;
+   gdbarch->fp0_regnum = -1;
    gdbarch->npc_regnum = -1;
    gdbarch->nnpc_regnum = -1;
    gdbarch->register_name = legacy_register_name;
*************** verify_gdbarch (struct gdbarch *gdbarch)
*** 472,477 ****
--- 475,481 ----
    if ((GDB_MULTI_ARCH >= 2)
        && (gdbarch->pc_regnum == -1))
      internal_error ("gdbarch: verify_gdbarch: pc_regnum invalid");
+   /* Skip verify of fp0_regnum, invalid_p == 0 */
    /* Skip verify of npc_regnum, invalid_p == 0 */
    /* Skip verify of nnpc_regnum, invalid_p == 0 */
    /* Skip verify of register_name, invalid_p == 0 */
*************** gdbarch_dump (void)
*** 712,717 ****
--- 716,724 ----
                        "gdbarch_update: PC_REGNUM = %ld\n",
                        (long) PC_REGNUM);
    fprintf_unfiltered (gdb_stdlog,
+                       "gdbarch_update: FP0_REGNUM = %ld\n",
+                       (long) FP0_REGNUM);
+   fprintf_unfiltered (gdb_stdlog,
                        "gdbarch_update: NPC_REGNUM = %ld\n",
                        (long) NPC_REGNUM);
    fprintf_unfiltered (gdb_stdlog,
*************** set_gdbarch_pc_regnum (struct gdbarch *g
*** 1346,1351 ****
--- 1353,1374 ----
                         int pc_regnum)
  {
    gdbarch->pc_regnum = pc_regnum;
+ }
+ 
+ int
+ gdbarch_fp0_regnum (struct gdbarch *gdbarch)
+ {
+   /* Skip verify of fp0_regnum, invalid_p == 0 */
+   if (gdbarch_debug >= 2)
+     fprintf_unfiltered (gdb_stdlog, "gdbarch_fp0_regnum called\n");
+   return gdbarch->fp0_regnum;
+ }
+ 
+ void
+ set_gdbarch_fp0_regnum (struct gdbarch *gdbarch,
+                         int fp0_regnum)
+ {
+   gdbarch->fp0_regnum = fp0_regnum;
  }
  
  int
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.16
diff -p -r1.16 gdbarch.h
*** gdbarch.h	2000/05/02 09:36:56	1.16
--- gdbarch.h	2000/05/09 01:01:27
*************** extern void set_gdbarch_pc_regnum (struc
*** 264,269 ****
--- 264,282 ----
  #endif
  
  /* Default (value) for non- multi-arch platforms. */
+ #if (GDB_MULTI_ARCH == 0) && !defined (FP0_REGNUM)
+ #define FP0_REGNUM (-1)
+ #endif
+ 
+ extern int gdbarch_fp0_regnum (struct gdbarch *gdbarch);
+ extern void set_gdbarch_fp0_regnum (struct gdbarch *gdbarch, int fp0_regnum);
+ #if GDB_MULTI_ARCH
+ #if (GDB_MULTI_ARCH > 1) || !defined (FP0_REGNUM)
+ #define FP0_REGNUM (gdbarch_fp0_regnum (current_gdbarch))
+ #endif
+ #endif
+ 
+ /* Default (value) for non- multi-arch platforms. */
  #if (GDB_MULTI_ARCH == 0) && !defined (NPC_REGNUM)
  #define NPC_REGNUM (-1)
  #endif
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.19
diff -p -r1.19 gdbarch.sh
*** gdbarch.sh	2000/05/02 09:36:56	1.19
--- gdbarch.sh	2000/05/09 01:01:27
*************** v:2:NUM_REGS:int:num_regs::::0:-1
*** 241,246 ****
--- 241,247 ----
  v:2:SP_REGNUM:int:sp_regnum::::0:-1
  v:2:FP_REGNUM:int:fp_regnum::::0:-1
  v:2:PC_REGNUM:int:pc_regnum::::0:-1
+ v:2:FP0_REGNUM:int:fp0_regnum::::0:-1:0
  v:2:NPC_REGNUM:int:npc_regnum::::0:-1:0
  v:2:NNPC_REGNUM:int:nnpc_regnum::::0:-1:0
  f:2:REGISTER_NAME:char *:register_name:int regnr:regnr:::legacy_register_name:0
Index: i386mach-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386mach-nat.c,v
retrieving revision 1.1.1.4
diff -p -r1.1.1.4 i386mach-nat.c
*** i386mach-nat.c	1999/10/05 23:08:20	1.1.1.4
--- i386mach-nat.c	2000/05/09 01:01:27
*************** fetch_core_registers (core_reg_sect, cor
*** 129,139 ****
        break;
  
      case 2:
- #ifdef FP0_REGNUM
        memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)],
  	      core_reg_sect,
  	      core_reg_size);	/* FIXME, probably bogus */
- #endif
  #ifdef FPC_REGNUM
        memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
  	      &corestr.c_fpu.f_fpstatus.f_ctrl,
--- 129,137 ----
Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.9
diff -p -r1.9 procfs.c
*** procfs.c	2000/05/05 20:56:10	1.9
--- procfs.c	2000/05/09 01:01:27
*************** procfs_fetch_registers (regno)
*** 3503,3521 ****
  
    supply_gregset (gregs);
  
! #if defined (FP0_REGNUM)	/* need floating point? */
!   if ((regno >= 0 && regno < FP0_REGNUM) ||
!       regno == PC_REGNUM  ||
!       (NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
!       regno == FP_REGNUM  ||
!       regno == SP_REGNUM)
!     return;			/* not a floating point register */
  
!   if ((fpregs = proc_get_fpregs (pi)) == NULL)
!     proc_error (pi, "fetch_registers, get_fpregs", __LINE__);
  
!   supply_fpregset (fpregs);
! #endif
  }
  
  /* Get ready to modify the registers array.  On machines which store
--- 3503,3522 ----
  
    supply_gregset (gregs);
  
!   if (FP0_REGNUM >= 0)	/* need floating point? */
!     {
!       if ((regno >= 0 && regno < FP0_REGNUM) ||
! 	  regno == PC_REGNUM  ||
! 	  (NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
! 	  regno == FP_REGNUM  ||
! 	  regno == SP_REGNUM)
! 	return;			/* not a floating point register */
  
!       if ((fpregs = proc_get_fpregs (pi)) == NULL)
! 	proc_error (pi, "fetch_registers, get_fpregs", __LINE__);
  
!       supply_fpregset (fpregs);
!     }
  }
  
  /* Get ready to modify the registers array.  On machines which store
*************** procfs_store_registers (regno)
*** 3577,3597 ****
    if (!proc_set_gregs (pi))
      proc_error (pi, "store_registers, set_gregs", __LINE__);
  
! #if defined (FP0_REGNUM)	/* need floating point? */
!   if ((regno >= 0 && regno < FP0_REGNUM) ||
!       regno == PC_REGNUM  ||
!       (NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
!       regno == FP_REGNUM  ||
!       regno == SP_REGNUM)
!     return;			/* not a floating point register */
! 
!   if ((fpregs = proc_get_fpregs (pi)) == NULL)
!     proc_error (pi, "store_registers, get_fpregs", __LINE__);
! 
!   fill_fpregset (fpregs, regno);
!   if (!proc_set_fpregs (pi))
!     proc_error (pi, "store_registers, set_fpregs", __LINE__);
! #endif
  }
  
  /*
--- 3578,3599 ----
    if (!proc_set_gregs (pi))
      proc_error (pi, "store_registers, set_gregs", __LINE__);
  
!   if (FP0_REGNUM >= 0)		/* need floating point? */
!     {
!       if ((regno >= 0 && regno < FP0_REGNUM) ||
! 	  regno == PC_REGNUM  ||
! 	  (NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
! 	  regno == FP_REGNUM  ||
! 	  regno == SP_REGNUM)
! 	return;			/* not a floating point register */
! 
!       if ((fpregs = proc_get_fpregs (pi)) == NULL)
! 	proc_error (pi, "store_registers, get_fpregs", __LINE__);
! 
!       fill_fpregset (fpregs, regno);
!       if (!proc_set_fpregs (pi))
! 	proc_error (pi, "store_registers, set_fpregs", __LINE__);
!     }
  }
  
  /*
*************** invalidate_cache (parent, pi, ptr)
*** 4112,4125 ****
        if (!proc_set_gregs (pi))	/* flush gregs cache */
  	proc_warn (pi, "target_resume, set_gregs",
  		   __LINE__);
! #ifdef FP0_REGNUM
!   if (pi->fpregs_dirty)
!     if (parent == NULL ||
! 	proc_get_current_thread (parent) != pi->tid)
!       if (!proc_set_fpregs (pi))	/* flush fpregs cache */
! 	proc_warn (pi, "target_resume, set_fpregs", 
! 		   __LINE__);
! #endif
  #endif
  
    if (parent != NULL)
--- 4114,4126 ----
        if (!proc_set_gregs (pi))	/* flush gregs cache */
  	proc_warn (pi, "target_resume, set_gregs",
  		   __LINE__);
!   if (FP0_REGNUM >= 0)
!     if (pi->fpregs_dirty)
!       if (parent == NULL ||
! 	  proc_get_current_thread (parent) != pi->tid)
! 	if (!proc_set_fpregs (pi))	/* flush fpregs cache */
! 	  proc_warn (pi, "target_resume, set_fpregs", 
! 		     __LINE__);
  #endif
  
    if (parent != NULL)
Index: ptx4-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ptx4-nat.c,v
retrieving revision 1.1.1.3
diff -p -r1.1.1.3 ptx4-nat.c
*** ptx4-nat.c  1999/07/07 20:08:48     1.1.1.3
--- ptx4-nat.c  2000/05/09 01:08:01
*************** fill_gregset (gregsetp, regno)
*** 62,69 ****
      }
  }
  
- #if defined (FP0_REGNUM)
- 
  /*  Given a pointer to a floating point register set in /proc format
     (fpregset_t *), unpack the register contents and supply them as gdb's
     idea of the current floating point register values. */
--- 62,67 ----
*************** fill_fpregset (fpregsetp, regno)
*** 92,99 ****
  
    /* FIXME: see m68k-tdep.c for an example, for the m68k. */
  }
- 
- #endif /* defined (FP0_REGNUM) */
  
  /*
   * This doesn't quite do the same thing as the procfs.c version, but give
--- 90,95 ----
Index: sun3-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/sun3-nat.c,v
retrieving revision 1.1.1.4
diff -p -r1.1.1.4 sun3-nat.c
*** sun3-nat.c	1999/10/05 23:08:54	1.1.1.4
--- sun3-nat.c	2000/05/09 01:01:28
*************** fetch_inferior_registers (regno)
*** 33,63 ****
       int regno;
  {
    struct regs inferior_registers;
- #ifdef FP0_REGNUM
    struct fp_status inferior_fp_registers;
- #endif
  
    registers_fetched ();
  
    ptrace (PTRACE_GETREGS, inferior_pid,
  	  (PTRACE_ARG3_TYPE) & inferior_registers);
- #ifdef FP0_REGNUM
-   ptrace (PTRACE_GETFPREGS, inferior_pid,
- 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers);
- #endif
  
    memcpy (registers, &inferior_registers, 16 * 4);
! #ifdef FP0_REGNUM
!   memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
! 	  sizeof inferior_fp_registers.fps_regs);
! #endif
    *(int *) &registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
    *(int *) &registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
! #ifdef FP0_REGNUM
!   memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
! 	  &inferior_fp_registers.fps_control,
!       sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
! #endif
  }
  
  /* Store our register values back into the inferior.
--- 33,61 ----
       int regno;
  {
    struct regs inferior_registers;
    struct fp_status inferior_fp_registers;
  
    registers_fetched ();
  
    ptrace (PTRACE_GETREGS, inferior_pid,
  	  (PTRACE_ARG3_TYPE) & inferior_registers);
  
+   if (FP0_REGNUM >= 0)
+     ptrace (PTRACE_GETFPREGS, inferior_pid,
+ 	    (PTRACE_ARG3_TYPE) & inferior_fp_registers);
+ 
    memcpy (registers, &inferior_registers, 16 * 4);
!   if (FP0_REGNUM >= 0)
!     memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
! 	    sizeof inferior_fp_registers.fps_regs);
! 
    *(int *) &registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
    *(int *) &registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
!   if (FP0_REGNUM >= 0)
!     memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
! 	    &inferior_fp_registers.fps_control,
! 	    sizeof inferior_fp_registers - 
! 	    sizeof inferior_fp_registers.fps_regs);
  }
  
  /* Store our register values back into the inferior.
*************** store_inferior_registers (regno)
*** 69,98 ****
       int regno;
  {
    struct regs inferior_registers;
- #ifdef FP0_REGNUM
    struct fp_status inferior_fp_registers;
- #endif
  
    memcpy (&inferior_registers, registers, 16 * 4);
! #ifdef FP0_REGNUM
!   memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
! 	  sizeof inferior_fp_registers.fps_regs);
! #endif
    inferior_registers.r_ps = *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
    inferior_registers.r_pc = *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
  
! #ifdef FP0_REGNUM
!   memcpy (&inferior_fp_registers.fps_control,
! 	  &registers[REGISTER_BYTE (FPC_REGNUM)],
!       sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
! #endif
  
    ptrace (PTRACE_SETREGS, inferior_pid,
  	  (PTRACE_ARG3_TYPE) & inferior_registers);
! #if FP0_REGNUM
!   ptrace (PTRACE_SETFPREGS, inferior_pid,
! 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers);
! #endif
  }
  
  
--- 67,93 ----
       int regno;
  {
    struct regs inferior_registers;
    struct fp_status inferior_fp_registers;
  
    memcpy (&inferior_registers, registers, 16 * 4);
!   if (FP0_REGNUM >= 0)
!     memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
! 	    sizeof inferior_fp_registers.fps_regs);
! 
    inferior_registers.r_ps = *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
    inferior_registers.r_pc = *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
  
!   if (FP0_REGNUM >= 0)
!     memcpy (&inferior_fp_registers.fps_control,
! 	    &registers[REGISTER_BYTE (FPC_REGNUM)],
! 	    sizeof inferior_fp_registers - 
! 	    sizeof inferior_fp_registers.fps_regs);
  
    ptrace (PTRACE_SETREGS, inferior_pid,
  	  (PTRACE_ARG3_TYPE) & inferior_registers);
!   if (FP0_REGNUM >= 0)
!     ptrace (PTRACE_SETFPREGS, inferior_pid,
! 	    (PTRACE_ARG3_TYPE) & inferior_fp_registers);
  }
  
  
*************** fetch_core_registers (core_reg_sect, cor
*** 125,142 ****
  
        if (core_reg_size >= sizeof (struct fpu))
  	{
! #ifdef FP0_REGNUM
! 	  memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)],
! 		  fpustruct->f_fpstatus.fps_regs,
! 		  sizeof fpustruct->f_fpstatus.fps_regs);
! 	  memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
! 		  &fpustruct->f_fpstatus.fps_control,
! 		  sizeof fpustruct->f_fpstatus -
! 		  sizeof fpustruct->f_fpstatus.fps_regs);
! #endif
  	}
        else
! 	fprintf_unfiltered (gdb_stderr, "Couldn't read float regs from core file\n");
      }
  }
  
--- 120,139 ----
  
        if (core_reg_size >= sizeof (struct fpu))
  	{
! 	  if (FP0_REGNUM >= 0)
! 	    {
! 	      memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)],
! 		      fpustruct->f_fpstatus.fps_regs,
! 		      sizeof fpustruct->f_fpstatus.fps_regs);
! 	      memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
! 		      &fpustruct->f_fpstatus.fps_control,
! 		      sizeof fpustruct->f_fpstatus -
! 		      sizeof fpustruct->f_fpstatus.fps_regs);
! 	    }
  	}
        else
! 	fprintf_unfiltered (gdb_stderr, 
! 			    "Couldn't read float regs from core file\n");
      }
  }
  
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.1.1.7
diff -p -r1.1.1.7 sparc-tdep.c
*** sparc-tdep.c	1999/10/05 23:08:51	1.1.1.7
--- sparc-tdep.c	2000/05/09 01:22:24
***************
*** 44,52 ****
  
  #ifdef GDB_TARGET_IS_SPARC64
  #define FP_REGISTER_BYTES (64 * 4)
! #else
  #define FP_REGISTER_BYTES (32 * 4)
  #endif
  
  /* If not defined, assume 32 bit sparc.  */
  #ifndef FP_MAX_REGNUM
--- 44,56 ----
  
  #ifdef GDB_TARGET_IS_SPARC64
  #define FP_REGISTER_BYTES (64 * 4)
! #else 
! #if (SPARC_HAS_FPU)
  #define FP_REGISTER_BYTES (32 * 4)
+ #else
+ #define FP_REGISTER_BYTES 0
  #endif
+ #endif
  
  /* If not defined, assume 32 bit sparc.  */
  #ifndef FP_MAX_REGNUM
*************** sparc_get_saved_register (raw_buffer, op
*** 749,764 ****
  	  else if (regnum >= O0_REGNUM && regnum < O0_REGNUM + 8)
  	    addr = frame1->frame + (regnum - O0_REGNUM) * SPARC_INTREG_SIZE
  	      - (FP_REGISTER_BYTES + 16 * SPARC_INTREG_SIZE);
! #ifdef FP0_REGNUM
! 	  else if (regnum >= FP0_REGNUM && regnum < FP0_REGNUM + 32)
  	    addr = frame1->frame + (regnum - FP0_REGNUM) * 4
  	      - (FP_REGISTER_BYTES);
  #ifdef GDB_TARGET_IS_SPARC64
! 	  else if (regnum >= FP0_REGNUM + 32 && regnum < FP_MAX_REGNUM)
  	    addr = frame1->frame + 32 * 4 + (regnum - FP0_REGNUM - 32) * 8
  	      - (FP_REGISTER_BYTES);
  #endif
- #endif /* FP0_REGNUM */
  	  else if (regnum >= Y_REGNUM && regnum < NUM_REGS)
  	    addr = frame1->frame + (regnum - Y_REGNUM) * SPARC_INTREG_SIZE
  	      - (FP_REGISTER_BYTES + 24 * SPARC_INTREG_SIZE);
--- 753,768 ----
  	  else if (regnum >= O0_REGNUM && regnum < O0_REGNUM + 8)
  	    addr = frame1->frame + (regnum - O0_REGNUM) * SPARC_INTREG_SIZE
  	      - (FP_REGISTER_BYTES + 16 * SPARC_INTREG_SIZE);
! 	  else if (FP0_REGNUM >= 0 &&
! 		   regnum >= FP0_REGNUM && regnum < FP0_REGNUM + 32)
  	    addr = frame1->frame + (regnum - FP0_REGNUM) * 4
  	      - (FP_REGISTER_BYTES);
  #ifdef GDB_TARGET_IS_SPARC64
! 	  else if (FP0_REGNUM >= 0 &&
! 		   regnum >= FP0_REGNUM + 32 && regnum < FP_MAX_REGNUM)
  	    addr = frame1->frame + 32 * 4 + (regnum - FP0_REGNUM - 32) * 8
  	      - (FP_REGISTER_BYTES);
  #endif
  	  else if (regnum >= Y_REGNUM && regnum < NUM_REGS)
  	    addr = frame1->frame + (regnum - Y_REGNUM) * SPARC_INTREG_SIZE
  	      - (FP_REGISTER_BYTES + 24 * SPARC_INTREG_SIZE);
*************** sparc_get_saved_register (raw_buffer, op
*** 849,861 ****
  #endif
  
  /* See tm-sparc.h for how this is calculated.  */
- #ifdef FP0_REGNUM
  #define DUMMY_STACK_REG_BUF_SIZE \
! (((8+8+8) * SPARC_INTREG_SIZE) + FP_REGISTER_BYTES)
! #else
! #define DUMMY_STACK_REG_BUF_SIZE \
! (((8+8+8) * SPARC_INTREG_SIZE) )
! #endif /* FP0_REGNUM */
  #define DUMMY_STACK_SIZE (DUMMY_STACK_REG_BUF_SIZE + DUMMY_REG_SAVE_OFFSET)
  
  void
--- 853,860 ----
  #endif
  
  /* See tm-sparc.h for how this is calculated.  */
  #define DUMMY_STACK_REG_BUF_SIZE \
!      (((8+8+8) * SPARC_INTREG_SIZE) + FP_REGISTER_BYTES)
  #define DUMMY_STACK_SIZE (DUMMY_STACK_REG_BUF_SIZE + DUMMY_REG_SAVE_OFFSET)
  
  void
*************** sparc_push_dummy_frame ()
*** 887,897 ****
  		       &register_temp[16 * SPARC_INTREG_SIZE],
  		       SPARC_INTREG_SIZE * 8);
  
! #ifdef FP0_REGNUM
!   read_register_bytes (REGISTER_BYTE (FP0_REGNUM),
! 		       &register_temp[24 * SPARC_INTREG_SIZE],
! 		       FP_REGISTER_BYTES);
! #endif /* FP0_REGNUM */
  
    sp -= DUMMY_STACK_SIZE;
  
--- 886,895 ----
  		       &register_temp[16 * SPARC_INTREG_SIZE],
  		       SPARC_INTREG_SIZE * 8);
  
!   if (FP0_REGNUM >= 0)
!     read_register_bytes (REGISTER_BYTE (FP0_REGNUM),
! 			 &register_temp[24 * SPARC_INTREG_SIZE],
! 			 FP_REGISTER_BYTES);
  
    sp -= DUMMY_STACK_SIZE;
  
*************** sparc_frame_find_saved_regs (fi, saved_r
*** 991,1008 ****
  	saved_regs_addr->regs[regnum] =
  	  frame_addr + (regnum - I0_REGNUM) * SPARC_INTREG_SIZE
  	  - DUMMY_STACK_REG_BUF_SIZE + 8 * SPARC_INTREG_SIZE;
! #ifdef FP0_REGNUM
!       for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 32; regnum++)
! 	saved_regs_addr->regs[regnum] =
! 	  frame_addr + (regnum - FP0_REGNUM) * 4
! 	  - DUMMY_STACK_REG_BUF_SIZE + 24 * SPARC_INTREG_SIZE;
  #ifdef GDB_TARGET_IS_SPARC64
!       for (regnum = FP0_REGNUM + 32; regnum < FP_MAX_REGNUM; regnum++)
! 	saved_regs_addr->regs[regnum] =
! 	  frame_addr + 32 * 4 + (regnum - FP0_REGNUM - 32) * 4
! 	  - DUMMY_STACK_REG_BUF_SIZE + 24 * SPARC_INTREG_SIZE;
  #endif
! #endif /* FP0_REGNUM */
  #ifdef GDB_TARGET_IS_SPARC64
        for (regnum = PC_REGNUM; regnum < PC_REGNUM + 7; regnum++)
  	{
--- 989,1008 ----
  	saved_regs_addr->regs[regnum] =
  	  frame_addr + (regnum - I0_REGNUM) * SPARC_INTREG_SIZE
  	  - DUMMY_STACK_REG_BUF_SIZE + 8 * SPARC_INTREG_SIZE;
!       if (FP0_REGNUM >= 0)
! 	{
! 	  for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 32; regnum++)
! 	    saved_regs_addr->regs[regnum] =
! 	      frame_addr + (regnum - FP0_REGNUM) * 4
! 	      - DUMMY_STACK_REG_BUF_SIZE + 24 * SPARC_INTREG_SIZE;
  #ifdef GDB_TARGET_IS_SPARC64
! 	  for (regnum = FP0_REGNUM + 32; regnum < FP_MAX_REGNUM; regnum++)
! 	    saved_regs_addr->regs[regnum] =
! 	      frame_addr + 32 * 4 + (regnum - FP0_REGNUM - 32) * 4
! 	      - DUMMY_STACK_REG_BUF_SIZE + 24 * SPARC_INTREG_SIZE;
  #endif
! 	}
! 
  #ifdef GDB_TARGET_IS_SPARC64
        for (regnum = PC_REGNUM; regnum < PC_REGNUM + 7; regnum++)
  	{
*************** sparc_pop_frame ()
*** 1094,1119 ****
    int regnum;
  
    sparc_frame_find_saved_regs (frame, &fsr);
! #ifdef FP0_REGNUM
!   if (fsr.regs[FP0_REGNUM])
      {
!       read_memory (fsr.regs[FP0_REGNUM], raw_buffer, FP_REGISTER_BYTES);
!       write_register_bytes (REGISTER_BYTE (FP0_REGNUM),
! 			    raw_buffer, FP_REGISTER_BYTES);
!     }
  #ifndef GDB_TARGET_IS_SPARC64
!   if (fsr.regs[FPS_REGNUM])
!     {
!       read_memory (fsr.regs[FPS_REGNUM], raw_buffer, 4);
!       write_register_bytes (REGISTER_BYTE (FPS_REGNUM), raw_buffer, 4);
!     }
!   if (fsr.regs[CPS_REGNUM])
!     {
!       read_memory (fsr.regs[CPS_REGNUM], raw_buffer, 4);
!       write_register_bytes (REGISTER_BYTE (CPS_REGNUM), raw_buffer, 4);
!     }
  #endif
! #endif /* FP0_REGNUM */
    if (fsr.regs[G1_REGNUM])
      {
        read_memory (fsr.regs[G1_REGNUM], raw_buffer, 7 * SPARC_INTREG_SIZE);
--- 1094,1120 ----
    int regnum;
  
    sparc_frame_find_saved_regs (frame, &fsr);
!   if (FP0_REGNUM >= 0)
      {
!       if (fsr.regs[FP0_REGNUM])
! 	{
! 	  read_memory (fsr.regs[FP0_REGNUM], raw_buffer, FP_REGISTER_BYTES);
! 	  write_register_bytes (REGISTER_BYTE (FP0_REGNUM),
! 				raw_buffer, FP_REGISTER_BYTES);
! 	}
  #ifndef GDB_TARGET_IS_SPARC64
!       if (fsr.regs[FPS_REGNUM])
! 	{
! 	  read_memory (fsr.regs[FPS_REGNUM], raw_buffer, 4);
! 	  write_register_bytes (REGISTER_BYTE (FPS_REGNUM), raw_buffer, 4);
! 	}
!       if (fsr.regs[CPS_REGNUM])
! 	{
! 	  read_memory (fsr.regs[CPS_REGNUM], raw_buffer, 4);
! 	  write_register_bytes (REGISTER_BYTE (CPS_REGNUM), raw_buffer, 4);
! 	}
  #endif
!     }
    if (fsr.regs[G1_REGNUM])
      {
        read_memory (fsr.regs[G1_REGNUM], raw_buffer, 7 * SPARC_INTREG_SIZE);
*************** fill_gregset (gregsetp, regno)
*** 1388,1395 ****
      }
  }
  
- #if defined (FP0_REGNUM)
- 
  /*  Given a pointer to a floating point register set in /proc format
     (fpregset_t *), unpack the register contents and supply them as gdb's
     idea of the current floating point register values. */
--- 1389,1394 ----
*************** supply_fpregset (fpregsetp)
*** 1401,1406 ****
--- 1400,1408 ----
    register int regi;
    char *from;
  
+   if (FP0_REGNUM < 0)
+     return;
+ 
    for (regi = FP0_REGNUM; regi < FP_MAX_REGNUM; regi++)
      {
        from = (char *) &fpregsetp->pr_fr.pr_regs[regi - FP0_REGNUM];
*************** fill_fpregset (fpregsetp, regno)
*** 1424,1429 ****
--- 1426,1434 ----
    char *to;
    char *from;
  
+   if (FP0_REGNUM < 0)
+     return;
+ 
    for (regi = FP0_REGNUM; regi < FP_MAX_REGNUM; regi++)
      {
        if ((regno == -1) || (regno == regi))
*************** fill_fpregset (fpregsetp, regno)
*** 1438,1445 ****
        fpregsetp->pr_fsr = *(int *) &registers[REGISTER_BYTE (FPS_REGNUM)];
      }
  }
- 
- #endif /* defined (FP0_REGNUM) */
  
  #endif /* USE_PROC_FS */
  
--- 1443,1448 ----


More information about the Gdb-patches mailing list