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: Don't assume PPC regs are numbered contiguously


This is a step towards tolerating PPC variants lacking floating-point
registers.

Tested with no regressions on powerpc-unknown-linux-gnu (Fedora Core 2).

2004-04-20  Jim Blandy  <jimb@redhat.com>

	* ppc-linux-nat.c (fetch_ppc_registers, store_ppc_registers):
	Don't assume that the gprs, fprs, and UISA sprs are
	contiguous, start at register number zero, and end with fpscr.
	Instead, use the numbers from the tdep structure, FP0_REGNUM,
	and FPLAST_REGNUM.

Index: gdb/ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.29
diff -c -r1.29 ppc-linux-nat.c
*** gdb/ppc-linux-nat.c	15 Mar 2004 21:35:25 -0000	1.29
--- gdb/ppc-linux-nat.c	21 Apr 2004 15:58:41 -0000
***************
*** 310,319 ****
    int i;
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
!   for (i = 0; i <= tdep->ppc_fpscr_regnum; i++)
      fetch_register (tid, i);
    if (tdep->ppc_mq_regnum != -1)
      fetch_register (tid, tdep->ppc_mq_regnum);
    if (have_ptrace_getvrregs)
      if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
        fetch_altivec_registers (tid);
--- 310,335 ----
    int i;
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
!   for (i = tdep->ppc_gp0_regnum; i <= tdep->ppc_gplast_regnum; i++)
      fetch_register (tid, i);
+   if (tdep->ppc_fpscr_regnum != -1)
+     for (i = FP0_REGNUM; i < FPLAST_REGNUM; i++)
+       fetch_register (tid, 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)
+     fetch_register (tid, tdep->ppc_lr_regnum);
+   if (tdep->ppc_ctr_regnum != -1)
+     fetch_register (tid, tdep->ppc_ctr_regnum);
+   if (tdep->ppc_xer_regnum != -1)
+     fetch_register (tid, tdep->ppc_xer_regnum);
    if (tdep->ppc_mq_regnum != -1)
      fetch_register (tid, tdep->ppc_mq_regnum);
+   if (tdep->ppc_fpscr_regnum != -1)
+     fetch_register (tid, tdep->ppc_fpscr_regnum);
    if (have_ptrace_getvrregs)
      if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
        fetch_altivec_registers (tid);
***************
*** 479,488 ****
    int i;
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
    
!   for (i = 0; i <= tdep->ppc_fpscr_regnum; i++)
      store_register (tid, i);
    if (tdep->ppc_mq_regnum != -1)
      store_register (tid, tdep->ppc_mq_regnum);
    if (have_ptrace_getvrregs)
      if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
        store_altivec_registers (tid);
--- 495,520 ----
    int i;
    struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
    
!   for (i = tdep->ppc_gp0_regnum; i <= tdep->ppc_gplast_regnum; i++)
      store_register (tid, i);
+   if (tdep->ppc_fpscr_regnum != -1)
+     for (i = FP0_REGNUM; i < FPLAST_REGNUM; i++)
+       store_register (tid, 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)
+     store_register (tid, tdep->ppc_lr_regnum);
+   if (tdep->ppc_ctr_regnum != -1)
+     store_register (tid, tdep->ppc_ctr_regnum);
+   if (tdep->ppc_xer_regnum != -1)
+     store_register (tid, tdep->ppc_xer_regnum);
    if (tdep->ppc_mq_regnum != -1)
      store_register (tid, tdep->ppc_mq_regnum);
+   if (tdep->ppc_fpscr_regnum != -1)
+     store_register (tid, tdep->ppc_fpscr_regnum);
    if (have_ptrace_getvrregs)
      if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
        store_altivec_registers (tid);


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