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] ppc/rs6000: use gdbarch_ps_regnum


Hi guys,

I just happened to notice this.  Gdbarch implements PS_REGNUM,
so there's no reason to keep it privately in the tdep struct.

Tested on powerpc-eabi, but not on the native platforms.

Michael

2004-10-15  Michael Snyder  <msnyder@redhat.com>

	* ppc-tdep.h (struct gdbarch_tdep): Remove ppc_ps_regnum.
	* rs6000-tdep.c (rs6000_gdbarch_init): Use set_gdbarch_ps_regnum
	instead of putting it in the tdep struct.
	* rs6000-nat.c: Use PS_REGNUM instead of the tdep.
	* ppc-linux-nat.c: Ditto.
	* ppc-linux-tdep.c: Ditto.
	* aix-thread.c: Ditto.

Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.45
diff -p -r1.45 ppc-tdep.h
*** ppc-tdep.h	4 Aug 2004 17:17:55 -0000	1.45
--- ppc-tdep.h	16 Oct 2004 00:32:50 -0000
*************** struct gdbarch_tdep
*** 145,151 ****
      const struct reg *regs;    /* from current variant */
      int ppc_gp0_regnum;		/* GPR register 0 */
      int ppc_toc_regnum;		/* TOC register */
-     int ppc_ps_regnum;	        /* Processor (or machine) status (%msr) */
      int ppc_cr_regnum;		/* Condition register */
      int ppc_lr_regnum;		/* Link register */
      int ppc_ctr_regnum;		/* Count register */
--- 145,150 ----
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.230
diff -p -r1.230 rs6000-tdep.c
*** rs6000-tdep.c	13 Oct 2004 16:38:22 -0000	1.230
--- rs6000-tdep.c	16 Oct 2004 00:32:51 -0000
*************** init_sim_regno_table (struct gdbarch *ar
*** 241,247 ****
      set_sim_regno (sim_regno, tdep->ppc_fpscr_regnum, sim_ppc_fpscr_regnum);
  
    set_sim_regno (sim_regno, gdbarch_pc_regnum (arch), sim_ppc_pc_regnum);
!   set_sim_regno (sim_regno, tdep->ppc_ps_regnum, sim_ppc_ps_regnum);
    set_sim_regno (sim_regno, tdep->ppc_cr_regnum, sim_ppc_cr_regnum);
  
    /* Segment registers.  */
--- 241,247 ----
      set_sim_regno (sim_regno, tdep->ppc_fpscr_regnum, sim_ppc_fpscr_regnum);
  
    set_sim_regno (sim_regno, gdbarch_pc_regnum (arch), sim_ppc_pc_regnum);
!   set_sim_regno (sim_regno, gdbarch_ps_regnum (arch), sim_ppc_ps_regnum);
    set_sim_regno (sim_regno, tdep->ppc_cr_regnum, sim_ppc_cr_regnum);
  
    /* Segment registers.  */
*************** ppc_supply_gregset (const struct regset 
*** 355,362 ****
  
    if (regnum == -1 || regnum == PC_REGNUM)
      ppc_supply_reg (regcache, PC_REGNUM, gregs, offsets->pc_offset);
!   if (regnum == -1 || regnum == tdep->ppc_ps_regnum)
!     ppc_supply_reg (regcache, tdep->ppc_ps_regnum,
  		    gregs, offsets->ps_offset);
    if (regnum == -1 || regnum == tdep->ppc_cr_regnum)
      ppc_supply_reg (regcache, tdep->ppc_cr_regnum,
--- 355,362 ----
  
    if (regnum == -1 || regnum == PC_REGNUM)
      ppc_supply_reg (regcache, PC_REGNUM, gregs, offsets->pc_offset);
!   if (regnum == -1 || regnum == PS_REGNUM)
!     ppc_supply_reg (regcache, PS_REGNUM,
  		    gregs, offsets->ps_offset);
    if (regnum == -1 || regnum == tdep->ppc_cr_regnum)
      ppc_supply_reg (regcache, tdep->ppc_cr_regnum,
*************** ppc_collect_gregset (const struct regset
*** 431,438 ****
  
    if (regnum == -1 || regnum == PC_REGNUM)
      ppc_collect_reg (regcache, PC_REGNUM, gregs, offsets->pc_offset);
!   if (regnum == -1 || regnum == tdep->ppc_ps_regnum)
!     ppc_collect_reg (regcache, tdep->ppc_ps_regnum,
  		     gregs, offsets->ps_offset);
    if (regnum == -1 || regnum == tdep->ppc_cr_regnum)
      ppc_collect_reg (regcache, tdep->ppc_cr_regnum,
--- 431,438 ----
  
    if (regnum == -1 || regnum == PC_REGNUM)
      ppc_collect_reg (regcache, PC_REGNUM, gregs, offsets->pc_offset);
!   if (regnum == -1 || regnum == PS_REGNUM)
!     ppc_collect_reg (regcache, PS_REGNUM,
  		     gregs, offsets->ps_offset);
    if (regnum == -1 || regnum == tdep->ppc_cr_regnum)
      ppc_collect_reg (regcache, tdep->ppc_cr_regnum,
*************** rs6000_gdbarch_init (struct gdbarch_info
*** 3099,3105 ****
  
    tdep->ppc_gp0_regnum = 0;
    tdep->ppc_toc_regnum = 2;
!   tdep->ppc_ps_regnum = 65;
    tdep->ppc_cr_regnum = 66;
    tdep->ppc_lr_regnum = 67;
    tdep->ppc_ctr_regnum = 68;
--- 3099,3105 ----
  
    tdep->ppc_gp0_regnum = 0;
    tdep->ppc_toc_regnum = 2;
!   set_gdbarch_ps_regnum (gdbarch, 65);
    tdep->ppc_cr_regnum = 66;
    tdep->ppc_lr_regnum = 67;
    tdep->ppc_ctr_regnum = 68;
Index: rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.54
diff -p -r1.54 rs6000-nat.c
*** rs6000-nat.c	5 Oct 2004 21:53:33 -0000	1.54
--- rs6000-nat.c	16 Oct 2004 00:32:51 -0000
*************** regmap (int regno, int *isfloat)
*** 167,173 ****
      }
    else if (regno == PC_REGNUM)
      return IAR;
!   else if (regno == tdep->ppc_ps_regnum)
      return MSR;
    else if (regno == tdep->ppc_cr_regnum)
      return CR;
--- 167,173 ----
      }
    else if (regno == PC_REGNUM)
      return IAR;
!   else if (regno == PS_REGNUM)
      return MSR;
    else if (regno == tdep->ppc_cr_regnum)
      return CR;
*************** fetch_inferior_registers (int regno)
*** 366,372 ****
  
        /* Read special registers.  */
        fetch_register (PC_REGNUM);
!       fetch_register (tdep->ppc_ps_regnum);
        fetch_register (tdep->ppc_cr_regnum);
        fetch_register (tdep->ppc_lr_regnum);
        fetch_register (tdep->ppc_ctr_regnum);
--- 366,372 ----
  
        /* Read special registers.  */
        fetch_register (PC_REGNUM);
!       fetch_register (PS_REGNUM);
        fetch_register (tdep->ppc_cr_regnum);
        fetch_register (tdep->ppc_lr_regnum);
        fetch_register (tdep->ppc_ctr_regnum);
*************** store_inferior_registers (int regno)
*** 407,413 ****
  
        /* Write special registers.  */
        store_register (PC_REGNUM);
!       store_register (tdep->ppc_ps_regnum);
        store_register (tdep->ppc_cr_regnum);
        store_register (tdep->ppc_lr_regnum);
        store_register (tdep->ppc_ctr_regnum);
--- 407,413 ----
  
        /* Write special registers.  */
        store_register (PC_REGNUM);
!       store_register (PS_REGNUM);
        store_register (tdep->ppc_cr_regnum);
        store_register (tdep->ppc_lr_regnum);
        store_register (tdep->ppc_ctr_regnum);
*************** fetch_core_registers (char *core_reg_sec
*** 596,602 ****
  
        regcache_raw_supply (current_regcache, PC_REGNUM,
  			   (char *) &regs->r64.iar);
!       regcache_raw_supply (current_regcache, tdep->ppc_ps_regnum,
  			   (char *) &regs->r64.msr);
        regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum,
  			   (char *) &regs->r64.cr);
--- 596,602 ----
  
        regcache_raw_supply (current_regcache, PC_REGNUM,
  			   (char *) &regs->r64.iar);
!       regcache_raw_supply (current_regcache, PS_REGNUM,
  			   (char *) &regs->r64.msr);
        regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum,
  			   (char *) &regs->r64.cr);
*************** fetch_core_registers (char *core_reg_sec
*** 623,629 ****
  
        regcache_raw_supply (current_regcache, PC_REGNUM,
  			   (char *) &regs->r32.iar);
!       regcache_raw_supply (current_regcache, tdep->ppc_ps_regnum,
  			   (char *) &regs->r32.msr);
        regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum,
  			   (char *) &regs->r32.cr);
--- 623,629 ----
  
        regcache_raw_supply (current_regcache, PC_REGNUM,
  			   (char *) &regs->r32.iar);
!       regcache_raw_supply (current_regcache, PS_REGNUM,
  			   (char *) &regs->r32.msr);
        regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum,
  			   (char *) &regs->r32.cr);
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.52
diff -p -r1.52 ppc-linux-nat.c
*** ppc-linux-nat.c	4 Aug 2004 17:45:30 -0000	1.52
--- ppc-linux-nat.c	16 Oct 2004 00:32:52 -0000
*************** ppc_register_u_addr (int regno)
*** 208,214 ****
    if (regno == tdep->ppc_mq_regnum)
      u_addr = PT_MQ * wordsize;
  #endif
!   if (regno == tdep->ppc_ps_regnum)
      u_addr = PT_MSR * wordsize;
    if (tdep->ppc_fpscr_regnum >= 0
        && regno == tdep->ppc_fpscr_regnum)
--- 208,214 ----
    if (regno == tdep->ppc_mq_regnum)
      u_addr = PT_MQ * wordsize;
  #endif
!   if (regno == PS_REGNUM)
      u_addr = PT_MSR * wordsize;
    if (tdep->ppc_fpscr_regnum >= 0
        && regno == tdep->ppc_fpscr_regnum)
*************** fetch_ppc_registers (int tid)
*** 459,466 ****
      for (i = 0; i < ppc_num_fprs; i++)
        fetch_register (tid, tdep->ppc_fp0_regnum + i);
    fetch_register (tid, PC_REGNUM);
!   if (tdep->ppc_ps_regnum != -1)
!     fetch_register (tid, tdep->ppc_ps_regnum);
    if (tdep->ppc_cr_regnum != -1)
      fetch_register (tid, tdep->ppc_cr_regnum);
    if (tdep->ppc_lr_regnum != -1)
--- 459,466 ----
      for (i = 0; i < ppc_num_fprs; i++)
        fetch_register (tid, tdep->ppc_fp0_regnum + i);
    fetch_register (tid, PC_REGNUM);
!   if (PS_REGNUM != -1)
!     fetch_register (tid, PS_REGNUM);
    if (tdep->ppc_cr_regnum != -1)
      fetch_register (tid, tdep->ppc_cr_regnum);
    if (tdep->ppc_lr_regnum != -1)
*************** store_ppc_registers (int tid)
*** 743,750 ****
      for (i = 0; i < ppc_num_fprs; i++)
        store_register (tid, tdep->ppc_fp0_regnum + i);
    store_register (tid, PC_REGNUM);
!   if (tdep->ppc_ps_regnum != -1)
!     store_register (tid, tdep->ppc_ps_regnum);
    if (tdep->ppc_cr_regnum != -1)
      store_register (tid, tdep->ppc_cr_regnum);
    if (tdep->ppc_lr_regnum != -1)
--- 743,750 ----
      for (i = 0; i < ppc_num_fprs; i++)
        store_register (tid, tdep->ppc_fp0_regnum + i);
    store_register (tid, PC_REGNUM);
!   if (PS_REGNUM != -1)
!     store_register (tid, PS_REGNUM);
    if (tdep->ppc_cr_regnum != -1)
      store_register (tid, tdep->ppc_cr_regnum);
    if (tdep->ppc_lr_regnum != -1)
*************** fill_gregset (gdb_gregset_t *gregsetp, i
*** 838,845 ****
        && (tdep->ppc_mq_regnum != -1))
      right_fill_reg (tdep->ppc_mq_regnum, regp + PT_MQ);
  #endif
!   if ((regno == -1) || regno == tdep->ppc_ps_regnum)
!     right_fill_reg (tdep->ppc_ps_regnum, regp + PT_MSR);
  }
  
  void
--- 838,845 ----
        && (tdep->ppc_mq_regnum != -1))
      right_fill_reg (tdep->ppc_mq_regnum, regp + PT_MQ);
  #endif
!   if ((regno == -1) || regno == PS_REGNUM)
!     right_fill_reg (PS_REGNUM, regp + PT_MSR);
  }
  
  void
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.66
diff -p -r1.66 ppc-linux-tdep.c
*** ppc-linux-tdep.c	31 Jul 2004 21:53:17 -0000	1.66
--- ppc-linux-tdep.c	16 Oct 2004 00:32:52 -0000
*************** ppc_linux_supply_gregset (struct regcach
*** 877,883 ****
    if (regcache_tdep->ppc_mq_regnum != -1)
      right_supply_register (regcache, wordsize, regcache_tdep->ppc_mq_regnum,
  			   buf + wordsize * PPC_LINUX_PT_MQ);
!   right_supply_register (regcache, wordsize, regcache_tdep->ppc_ps_regnum,
  			 buf + wordsize * PPC_LINUX_PT_MSR);
  }
  
--- 877,883 ----
    if (regcache_tdep->ppc_mq_regnum != -1)
      right_supply_register (regcache, wordsize, regcache_tdep->ppc_mq_regnum,
  			   buf + wordsize * PPC_LINUX_PT_MQ);
!   right_supply_register (regcache, wordsize, PS_REGNUM,
  			 buf + wordsize * PPC_LINUX_PT_MSR);
  }
  
Index: aix-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/aix-thread.c,v
retrieving revision 1.37
diff -p -r1.37 aix-thread.c
*** aix-thread.c	8 Oct 2004 20:29:45 -0000	1.37
--- aix-thread.c	16 Oct 2004 00:32:52 -0000
*************** special_register_p (int regno)
*** 1060,1066 ****
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
    return regno == PC_REGNUM
!       || regno == tdep->ppc_ps_regnum
        || regno == tdep->ppc_cr_regnum
        || regno == tdep->ppc_lr_regnum
        || regno == tdep->ppc_ctr_regnum
--- 1060,1066 ----
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
    return regno == PC_REGNUM
!       || regno == PS_REGNUM
        || regno == tdep->ppc_cr_regnum
        || regno == tdep->ppc_lr_regnum
        || regno == tdep->ppc_ctr_regnum
*************** supply_sprs64 (uint64_t iar, uint64_t ms
*** 1081,1087 ****
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
    regcache_raw_supply (current_regcache, PC_REGNUM, (char *) &iar);
!   regcache_raw_supply (current_regcache, tdep->ppc_ps_regnum, (char *) &msr);
    regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum, (char *) &cr);
    regcache_raw_supply (current_regcache, tdep->ppc_lr_regnum, (char *) &lr);
    regcache_raw_supply (current_regcache, tdep->ppc_ctr_regnum, (char *) &ctr);
--- 1081,1087 ----
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
    regcache_raw_supply (current_regcache, PC_REGNUM, (char *) &iar);
!   regcache_raw_supply (current_regcache, PS_REGNUM, (char *) &msr);
    regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum, (char *) &cr);
    regcache_raw_supply (current_regcache, tdep->ppc_lr_regnum, (char *) &lr);
    regcache_raw_supply (current_regcache, tdep->ppc_ctr_regnum, (char *) &ctr);
*************** supply_sprs32 (uint32_t iar, uint32_t ms
*** 1102,1108 ****
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
    regcache_raw_supply (current_regcache, PC_REGNUM, (char *) &iar);
!   regcache_raw_supply (current_regcache, tdep->ppc_ps_regnum, (char *) &msr);
    regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum, (char *) &cr);
    regcache_raw_supply (current_regcache, tdep->ppc_lr_regnum, (char *) &lr);
    regcache_raw_supply (current_regcache, tdep->ppc_ctr_regnum, (char *) &ctr);
--- 1102,1108 ----
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
    regcache_raw_supply (current_regcache, PC_REGNUM, (char *) &iar);
!   regcache_raw_supply (current_regcache, PS_REGNUM, (char *) &msr);
    regcache_raw_supply (current_regcache, tdep->ppc_cr_regnum, (char *) &cr);
    regcache_raw_supply (current_regcache, tdep->ppc_lr_regnum, (char *) &lr);
    regcache_raw_supply (current_regcache, tdep->ppc_ctr_regnum, (char *) &ctr);
*************** fill_sprs64 (uint64_t *iar, uint64_t *ms
*** 1337,1344 ****
  
    if (register_cached (PC_REGNUM))
      regcache_raw_collect (current_regcache, PC_REGNUM, iar);
!   if (register_cached (tdep->ppc_ps_regnum))
!     regcache_raw_collect (current_regcache, tdep->ppc_ps_regnum, msr);
    if (register_cached (tdep->ppc_cr_regnum))
      regcache_raw_collect (current_regcache, tdep->ppc_cr_regnum, cr);
    if (register_cached (tdep->ppc_lr_regnum))
--- 1337,1344 ----
  
    if (register_cached (PC_REGNUM))
      regcache_raw_collect (current_regcache, PC_REGNUM, iar);
!   if (register_cached (PS_REGNUM))
!     regcache_raw_collect (current_regcache, PS_REGNUM, msr);
    if (register_cached (tdep->ppc_cr_regnum))
      regcache_raw_collect (current_regcache, tdep->ppc_cr_regnum, cr);
    if (register_cached (tdep->ppc_lr_regnum))
*************** fill_sprs32 (unsigned long *iar, unsigne
*** 1373,1380 ****
  
    if (register_cached (PC_REGNUM))
      regcache_raw_collect (current_regcache, PC_REGNUM, iar);
!   if (register_cached (tdep->ppc_ps_regnum))
!     regcache_raw_collect (current_regcache, tdep->ppc_ps_regnum, msr);
    if (register_cached (tdep->ppc_cr_regnum))
      regcache_raw_collect (current_regcache, tdep->ppc_cr_regnum, cr);
    if (register_cached (tdep->ppc_lr_regnum))
--- 1373,1380 ----
  
    if (register_cached (PC_REGNUM))
      regcache_raw_collect (current_regcache, PC_REGNUM, iar);
!   if (register_cached (PS_REGNUM))
!     regcache_raw_collect (current_regcache, PS_REGNUM, msr);
    if (register_cached (tdep->ppc_cr_regnum))
      regcache_raw_collect (current_regcache, tdep->ppc_cr_regnum, cr);
    if (register_cached (tdep->ppc_lr_regnum))
*************** store_regs_user_thread (pthdb_pthread_t 
*** 1457,1463 ****
                     &tmp_fpscr);
        if (register_cached (PC_REGNUM))
  	ctx.iar = tmp_iar;
!       if (register_cached (tdep->ppc_ps_regnum))
  	ctx.msr = tmp_msr;
        if (register_cached (tdep->ppc_cr_regnum))
  	ctx.cr  = tmp_cr;
--- 1457,1463 ----
                     &tmp_fpscr);
        if (register_cached (PC_REGNUM))
  	ctx.iar = tmp_iar;
!       if (register_cached (PS_REGNUM))
  	ctx.msr = tmp_msr;
        if (register_cached (tdep->ppc_cr_regnum))
  	ctx.cr  = tmp_cr;

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