This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Use tdep->ppc_gp0_regnum where appropriate


2004-05-11  Jim Blandy  <jimb@redhat.com>

	* aix-thread.c (supply_gprs64, fetch_regs_user_thread)
	(store_regs_user_thread): Use tdep->ppc_gp0_regnum, instead
	of assuming that the gprs are numbered starting with zero.
	* ppc-linux-nat.c (fill_gregset): Same.
	* ppc-linux-tdep.c (ppc_linux_supply_gregset): Same.
	* ppcnbsd-nat.c (getregs_supplies): Same.
	* ppcnbsd-tdep.c (ppcnbsd_supply_reg, ppcnbsd_fill_reg): Same.
	* rs6000-nat.c (fetch_core_registers): Same.
	* rs6000-tdep.c (ppc_supply_gregset, ppc_collect_gregset): Same.

Index: gdb/aix-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/aix-thread.c,v
retrieving revision 1.23
diff -c -p -r1.23 aix-thread.c
*** gdb/aix-thread.c	11 May 2004 04:55:31 -0000	1.23
--- gdb/aix-thread.c	11 May 2004 16:06:35 -0000
*************** aix_thread_wait (ptid_t ptid, struct tar
*** 1001,1010 ****
  static void
  supply_gprs64 (uint64_t *vals)
  {
    int regno;
  
    for (regno = 0; regno < 32; regno++)
!     supply_register (regno, (char *) (vals + regno));
  }
  
  /* Record that 32-bit register REGNO contains VAL.  */
--- 1001,1011 ----
  static void
  supply_gprs64 (uint64_t *vals)
  {
+   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
    int regno;
  
    for (regno = 0; regno < 32; regno++)
!     supply_register (tdep->ppc_gp0_regnum + regno, (char *) (vals + regno));
  }
  
  /* Record that 32-bit register REGNO contains VAL.  */
*************** supply_sprs32 (uint32_t iar, uint32_t ms
*** 1098,1103 ****
--- 1099,1105 ----
  static void
  fetch_regs_user_thread (pthdb_pthread_t pdtid)
  {
+   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
    int status, i;
    pthdb_context_t ctx;
  
*************** fetch_regs_user_thread (pthdb_pthread_t 
*** 1115,1121 ****
      supply_gprs64 (ctx.gpr);
    else
      for (i = 0; i < 32; i++)
!       supply_reg32 (i, ctx.gpr[i]);
  
    /* Floating-point registers.  */
  
--- 1117,1123 ----
      supply_gprs64 (ctx.gpr);
    else
      for (i = 0; i < 32; i++)
!       supply_reg32 (tdep->ppc_gp0_regnum + i, ctx.gpr[i]);
  
    /* Floating-point registers.  */
  
*************** fetch_regs_kernel_thread (int regno, pth
*** 1180,1186 ****
  	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
  	    memset (gprs32, 0, sizeof (gprs32));
  	  for (i = 0; i < 32; i++)
! 	    supply_reg32 (i, gprs32[i]);
  	}
      }
  
--- 1182,1188 ----
  	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
  	    memset (gprs32, 0, sizeof (gprs32));
  	  for (i = 0; i < 32; i++)
! 	    supply_reg32 (tdep->ppc_gp0_regnum + i, gprs32[i]);
  	}
      }
  
*************** fill_sprs32 (unsigned long *iar, unsigne
*** 1369,1374 ****
--- 1371,1377 ----
  static void
  store_regs_user_thread (pthdb_pthread_t pdtid)
  {
+   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
    int status, i;
    pthdb_context_t ctx;
    uint32_t int32;
*************** store_regs_user_thread (pthdb_pthread_t 
*** 1389,1404 ****
    /* Collect general-purpose register values from the regcache.  */
  
    for (i = 0; i < 32; i++)
!     if (register_cached (i))
        {
  	if (arch64)
  	  {
! 	    regcache_collect (i, (void *) &int64);
  	    ctx.gpr[i] = int64;
  	  }
  	else
  	  {
! 	    regcache_collect (i, (void *) &int32);
  	    ctx.gpr[i] = int32;
  	  }
        }
--- 1392,1407 ----
    /* Collect general-purpose register values from the regcache.  */
  
    for (i = 0; i < 32; i++)
!     if (register_cached (tdep->ppc_gp0_regnum + i))
        {
  	if (arch64)
  	  {
! 	    regcache_collect (tdep->ppc_gp0_regnum + i, (void *) &int64);
  	    ctx.gpr[i] = int64;
  	  }
  	else
  	  {
! 	    regcache_collect (tdep->ppc_gp0_regnum + i, (void *) &int32);
  	    ctx.gpr[i] = int32;
  	  }
        }
*************** store_regs_user_thread (pthdb_pthread_t 
*** 1421,1427 ****
  	 happens, GDB needs to be reconfigured so that longs are 32-bits.)  */
        unsigned long tmp_iar, tmp_msr, tmp_cr, tmp_lr, tmp_ctr, tmp_xer,
                      tmp_fpscr;
-       struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
        fill_sprs32 (&tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr, &tmp_ctr, &tmp_xer,
                     &tmp_fpscr);
--- 1424,1429 ----
Index: gdb/ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.37
diff -c -p -r1.37 ppc-linux-nat.c
*** gdb/ppc-linux-nat.c	11 May 2004 04:55:31 -0000	1.37
--- gdb/ppc-linux-nat.c	11 May 2004 16:06:36 -0000
*************** fill_gregset (gdb_gregset_t *gregsetp, i
*** 592,599 ****
  
    for (regi = 0; regi < 32; regi++)
      {
!       if ((regno == -1) || regno == regi)
! 	right_fill_reg (regi, (regp + PT_R0 + regi));
      }
  
    if ((regno == -1) || regno == PC_REGNUM)
--- 592,599 ----
  
    for (regi = 0; regi < 32; regi++)
      {
!       if ((regno == -1) || regno == tdep->ppc_gp0_regnum + regi)
! 	right_fill_reg (tdep->ppc_gp0_regnum + regi, (regp + PT_R0 + regi));
      }
  
    if ((regno == -1) || regno == PC_REGNUM)
Index: gdb/ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.61
diff -c -p -r1.61 ppc-linux-tdep.c
*** gdb/ppc-linux-tdep.c	11 May 2004 04:55:31 -0000	1.61
--- gdb/ppc-linux-tdep.c	11 May 2004 16:06:37 -0000
*************** ppc_linux_supply_gregset (struct regcach
*** 861,867 ****
    const bfd_byte *buf = gregs;
  
    for (regi = 0; regi < 32; regi++)
!     right_supply_register (regcache, wordsize, regi, buf + wordsize * regi);
  
    right_supply_register (regcache, wordsize, gdbarch_pc_regnum (regcache_arch),
  			 buf + wordsize * PPC_LINUX_PT_NIP);
--- 861,869 ----
    const bfd_byte *buf = gregs;
  
    for (regi = 0; regi < 32; regi++)
!     right_supply_register (regcache, wordsize,
!                            regcache_tdep->ppc_gp0_regnum + regi,
!                            buf + wordsize * regi);
  
    right_supply_register (regcache, wordsize, gdbarch_pc_regnum (regcache_arch),
  			 buf + wordsize * PPC_LINUX_PT_NIP);
Index: gdb/ppcnbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcnbsd-nat.c,v
retrieving revision 1.14
diff -c -p -r1.14 ppcnbsd-nat.c
*** gdb/ppcnbsd-nat.c	11 May 2004 04:55:32 -0000	1.14
--- gdb/ppcnbsd-nat.c	11 May 2004 16:06:37 -0000
*************** getregs_supplies (int regno)
*** 36,42 ****
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
!   return ((regno >= 0 && regno <= 31)
            || regno == tdep->ppc_lr_regnum
            || regno == tdep->ppc_cr_regnum
            || regno == tdep->ppc_xer_regnum
--- 36,43 ----
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
!   return ((regno >= tdep->ppc_gp0_regnum
!            && regno < tdep->ppc_gp0_regnum + ppc_num_gprs)
            || regno == tdep->ppc_lr_regnum
            || regno == tdep->ppc_cr_regnum
            || regno == tdep->ppc_xer_regnum
Index: gdb/ppcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v
retrieving revision 1.19
diff -c -p -r1.19 ppcnbsd-tdep.c
*** gdb/ppcnbsd-tdep.c	11 May 2004 04:55:32 -0000	1.19
--- gdb/ppcnbsd-tdep.c	11 May 2004 16:06:37 -0000
*************** ppcnbsd_supply_reg (char *regs, int regn
*** 57,64 ****
  
    for (i = 0; i <= 31; i++)
      {
!       if (regno == i || regno == -1)
! 	supply_register (i, regs + REG_FIXREG_OFFSET (i));
      }
  
    if (regno == tdep->ppc_lr_regnum || regno == -1)
--- 57,65 ----
  
    for (i = 0; i <= 31; i++)
      {
!       if (regno == tdep->ppc_gp0_regnum + i || regno == -1)
! 	supply_register (tdep->ppc_gp0_regnum + i,
!                          regs + REG_FIXREG_OFFSET (i));
      }
  
    if (regno == tdep->ppc_lr_regnum || regno == -1)
*************** ppcnbsd_fill_reg (char *regs, int regno)
*** 85,92 ****
  
    for (i = 0; i <= 31; i++)
      {
!       if (regno == i || regno == -1)
! 	regcache_collect (i, regs + REG_FIXREG_OFFSET (i));
      }
  
    if (regno == tdep->ppc_lr_regnum || regno == -1)
--- 86,94 ----
  
    for (i = 0; i <= 31; i++)
      {
!       if (regno == tdep->ppc_gp0_regnum + i || regno == -1)
! 	regcache_collect (tdep->ppc_gp0_regnum + i,
!                           regs + REG_FIXREG_OFFSET (i));
      }
  
    if (regno == tdep->ppc_lr_regnum || regno == -1)
Index: gdb/rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.46
diff -c -p -r1.46 rs6000-nat.c
*** gdb/rs6000-nat.c	11 May 2004 04:55:32 -0000	1.46
--- gdb/rs6000-nat.c	11 May 2004 16:06:38 -0000
*************** fetch_core_registers (char *core_reg_sec
*** 587,593 ****
    if (ARCH64 ())
      {
        for (regi = 0; regi < 32; regi++)
!         supply_register (regi, (char *) &regs->r64.gpr[regi]);
  
        if (tdep->ppc_fp0_regnum >= 0)
          for (regi = 0; regi < 32; regi++)
--- 587,594 ----
    if (ARCH64 ())
      {
        for (regi = 0; regi < 32; regi++)
!         supply_register (tdep->ppc_gp0_regnum + regi,
!                          (char *) &regs->r64.gpr[regi]);
  
        if (tdep->ppc_fp0_regnum >= 0)
          for (regi = 0; regi < 32; regi++)
*************** fetch_core_registers (char *core_reg_sec
*** 606,612 ****
    else
      {
        for (regi = 0; regi < 32; regi++)
!         supply_register (regi, (char *) &regs->r32.gpr[regi]);
  
        if (tdep->ppc_fp0_regnum >= 0)
          for (regi = 0; regi < 32; regi++)
--- 607,614 ----
    else
      {
        for (regi = 0; regi < 32; regi++)
!         supply_register (tdep->ppc_gp0_regnum + regi,
!                          (char *) &regs->r32.gpr[regi]);
  
        if (tdep->ppc_fp0_regnum >= 0)
          for (regi = 0; regi < 32; regi++)
Index: gdb/rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.202
diff -c -p -r1.202 rs6000-tdep.c
*** gdb/rs6000-tdep.c	11 May 2004 04:55:32 -0000	1.202
--- gdb/rs6000-tdep.c	11 May 2004 16:06:40 -0000
*************** ppc_supply_gregset (const struct regset 
*** 185,191 ****
    size_t offset;
    int i;
  
!   for (i = 0, offset = offsets->r0_offset; i < 32; i++, offset += 4)
      {
        if (regnum == -1 || regnum == i)
  	ppc_supply_reg (regcache, i, gregs, offset);
--- 185,193 ----
    size_t offset;
    int i;
  
!   for (i = tdep->ppc_gp0_regnum, offset = offsets->r0_offset;
!        i < tdep->ppc_gp0_regnum + 32;
!        i++, offset += 4)
      {
        if (regnum == -1 || regnum == i)
  	ppc_supply_reg (regcache, i, gregs, offset);
*************** ppc_collect_gregset (const struct regset
*** 259,265 ****
    int i;
  
    offset = offsets->r0_offset;
!   for (i = 0; i < 32; i++, offset += 4)
      {
        if (regnum == -1 || regnum == i)
  	ppc_collect_reg (regcache, i, gregs, offset);
--- 261,269 ----
    int i;
  
    offset = offsets->r0_offset;
!   for (i = tdep->ppc_gp0_regnum;
!        i < tdep->ppc_gp0_regnum + 32;
!        i++, offset += 4)
      {
        if (regnum == -1 || regnum == i)
  	ppc_collect_reg (regcache, i, gregs, offset);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]