This is the mail archive of the gdb-patches@sourceware.org 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]

Re: powerpc-linux biarch corefile support


On Mon, Jan 22, 2007 at 06:11:54PM +0100, Mark Kettenis wrote:
> 1. You use C99 structure initialization syntax; GDB still uses C90.

OK.

> 2. The use of memset() in ppc_collect_gregset()/ppc_collect_fpregset()
>    is wrong.  These functions should leave the contents of the buffer
>    you're collecting the registers in alone, except for the registers
>    that are actually being collected.  The special value -1, means
>    "all registers GDB supports" not "all registers the operating
>    system supports".  In some cases the OS will store some additional
>    bits in the data structure used by ptrace(PT_GETREGS, ...) and we
>    want to pass those back unchanged in the matching

I see.  My patch might have broken bsd..

>    ptrace(PT_SETREGS, ...).  I guess you need this for zero-extending
>    the GPR's to 64-bits, but I think you should do that explicitly for
>    each register, even if REGNUM isn't -1.

Yes, it is for zero extending, and also for initializing unused
fields.  Random values in unused fields (eg. orig_gpr3) look odd in
core dumps.  I could cure that particular problem by clearing the
buffer in linux-nat.c:linux_nat_do_thread_registers, but that doesn't
help ps_lgetregs.  I'm sure we'll need to clear the high word of regs
for libthread_db when the inferior is 32-bit and gdb is 64-bit.  So
that would seem to mean we need the rather messy business of clearing
individual registers, except that fill_gregset and fill_fpregset
are always called with regno == -1 and are not used in the powerpc
linux store_inferior_registers.  (That code needs cleaning up to use
ppc_collect_gregset et al too.  Maybe for my next gdb patch..)
ie. fill_gregset and fill_fpregset are always storing into an
uninitialised buffer.  How about we just clear the buffers in
fill_gregset and fill_fpregset?

> Also, I'd probably use gpr_size instead of gpr_step, since that
> expresses more clearly that the registers in the set are really that
> size.

OK, and thanks for the review.  How does this look?

	* ppc-linux-nat.c (supply_gregset): Use ppc_supply_gregset.
	(right_fill_reg): Delete.
	(fill_gregset): Use ppc_collect_gregset and clear buffer.
	(supply_fpregset): Use ppc_supply_fpregset.
	(fill_fpregset): Use ppc_collect_fpregset and clear buffer.
	* ppc-linux-tdep.c (PPC_LINUX_PT_*): Don't define.
	(right_supply_register, ppc_linux_supply_gregset): Delete.
	(ppc32_linux_supply_gregset, ppc64_linux_supply_gregset): Delete.
	(ppc_linux_supply_fpregset): Delete.
	(ppc32_linux_reg_offsets, ppc64_linux_reg_offsets): New.
	(ppc64_32_linux_reg_offsets): New.
	(ppc32_linux_gregset, ppc64_linux_gregset): Update to use reg offsets,
	ppc_supply_gregset, and ppc_collect_gregset.
	(ppc64_32_linux_gregset): New.
	(ppc_linux_fpregset): Rename to ppc32_linux_fpregset and update.
	(ppc_linux_gregset, ppc_linux_fpregset): New functions.
	(ppc_linux_regset_from_core_section): Update.
	* ppc-tdep.h (ppc_linux_gregset, ppc_linux_fpregset): Declare.
	(ppc_linux_supply_gregset, ppc_linux_supply_fpregset): Delete.
	(struct ppc_reg_offsets): Add "gpr_size" field.
	* ppcnbsd-tdep.c (_initialize_ppcnbsd_tdep): Init gpr_size.
	* ppcobsd-tdep.c (_initialize_ppcobsd_tdep): Likewise.
	* rs6000-tdep.c (ppc_collect_gregset): Heed gpr_size.
	(ppc_supply_gregset): Likewise.  Fix xer reg offset typo.


Index: gdb/ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.62
diff -u -p -r1.62 ppc-linux-nat.c
--- gdb/ppc-linux-nat.c	9 Jan 2007 17:58:55 -0000	1.62
+++ gdb/ppc-linux-nat.c	23 Jan 2007 05:57:32 -0000
@@ -909,97 +909,60 @@ ppc_linux_store_inferior_registers (int 
     store_ppc_registers (tid);
 }
 
+/* Functions for transferring registers between a gregset_t or fpregset_t
+   (see sys/ucontext.h) and gdb's regcache.  The word size is that used
+   by the ptrace interface, not the current program's ABI.  eg. If a
+   powerpc64-linux gdb is being used to debug a powerpc32-linux app, we
+   read or write 64-bit gregsets.  This is to suit the host libthread_db.
+
+   Note that the fill_gregset and fill_fpregset functions allow for
+   writing just one register into a gregset_t or fpregset_t buffer.
+   If it so happens that the field in the buffer is larger than gdb's
+   idea of the register size, then the high order bits of the field
+   will not be written.  Currently, we always write the whole regset.  */
+
 void
 supply_gregset (gdb_gregset_t *gregsetp)
 {
-  /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
-     interface, and not the wordsize of the program's ABI.  */
-  int wordsize = sizeof (long);
-  ppc_linux_supply_gregset (current_regcache, -1, gregsetp,
-			    sizeof (gdb_gregset_t), wordsize);
-}
+  const struct regset *regset = ppc_linux_gregset (current_gdbarch);
 
-static void
-right_fill_reg (int regnum, void *reg)
-{
-  /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
-     interface, and not the wordsize of the program's ABI.  */
-  int wordsize = sizeof (long);
-  /* Right fill the register.  */
-  regcache_raw_collect (current_regcache, regnum,
-			((bfd_byte *) reg
-			 + wordsize
-			 - register_size (current_gdbarch, regnum)));
+  ppc_supply_gregset (regset, current_regcache, -1,
+		      gregsetp, sizeof (*gregsetp));
 }
 
 void
 fill_gregset (gdb_gregset_t *gregsetp, int regno)
 {
-  int regi;
-  elf_greg_t *regp = (elf_greg_t *) gregsetp;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 
-  const int elf_ngreg = 48;
-
-
-  /* Start with zeros.  */
-  memset (regp, 0, elf_ngreg * sizeof (*regp));
-
-  for (regi = 0; regi < ppc_num_gprs; 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)
-    right_fill_reg (PC_REGNUM, regp + PT_NIP);
-  if ((regno == -1) || regno == tdep->ppc_lr_regnum)
-    right_fill_reg (tdep->ppc_lr_regnum, regp + PT_LNK);
-  if ((regno == -1) || regno == tdep->ppc_cr_regnum)
-    regcache_raw_collect (current_regcache, tdep->ppc_cr_regnum,
-			  regp + PT_CCR);
-  if ((regno == -1) || regno == tdep->ppc_xer_regnum)
-    regcache_raw_collect (current_regcache, tdep->ppc_xer_regnum,
-			  regp + PT_XER);
-  if ((regno == -1) || regno == tdep->ppc_ctr_regnum)
-    right_fill_reg (tdep->ppc_ctr_regnum, regp + PT_CTR);
-#ifdef PT_MQ
-  if (((regno == -1) || regno == tdep->ppc_mq_regnum)
-      && (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);
+  const struct regset *regset = ppc_linux_gregset (current_gdbarch);
+
+  gdb_assert (regno == -1);
+  if (regno == -1)
+    memset (gregsetp, 0, sizeof (*gregsetp));
+
+  ppc_collect_gregset (regset, current_regcache, regno,
+		       gregsetp, sizeof (*gregsetp));
 }
 
 void
-supply_fpregset (gdb_fpregset_t * fpregsetp)
+supply_fpregset (gdb_fpregset_t *fpregsetp)
 {
-  ppc_linux_supply_fpregset (NULL, current_regcache, -1, fpregsetp,
-			     sizeof (gdb_fpregset_t));
+  const struct regset *regset = ppc_linux_fpregset (current_gdbarch);
+
+  ppc_supply_fpregset (regset, current_regcache, -1,
+		       fpregsetp, sizeof (*fpregsetp));
 }
 
-/* Given a pointer to a floating point register set in /proc format
-   (fpregset_t *), update the register specified by REGNO from gdb's
-   idea of the current floating point register set.  If REGNO is -1,
-   update them all.  */
 void
 fill_fpregset (gdb_fpregset_t *fpregsetp, int regno)
 {
-  int regi;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 
-  bfd_byte *fpp = (void *) fpregsetp;
-  
-  if (ppc_floating_point_unit_p (current_gdbarch))
-    {
-      for (regi = 0; regi < ppc_num_fprs; regi++)
-        {
-          if ((regno == -1) || (regno == tdep->ppc_fp0_regnum + regi))
-            regcache_raw_collect (current_regcache, tdep->ppc_fp0_regnum + regi,
-				  fpp + 8 * regi);
-        }
-      if (regno == -1 || regno == tdep->ppc_fpscr_regnum)
-        right_fill_reg (tdep->ppc_fpscr_regnum, (fpp + 8 * 32));
-    }
+  const struct regset *regset = ppc_linux_fpregset (current_gdbarch);
+
+  gdb_assert (regno == -1);
+  if (regno == -1)
+    memset (fpregsetp, 0, sizeof (*fpregsetp));
+
+  ppc_collect_fpregset (regset, current_regcache, regno,
+			fpregsetp, sizeof (*fpregsetp));
 }
 
 void _initialize_ppc_linux_nat (void);
Index: gdb/ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.81
diff -u -p -r1.81 ppc-linux-tdep.c
--- gdb/ppc-linux-tdep.c	9 Jan 2007 17:58:55 -0000	1.81
+++ gdb/ppc-linux-tdep.c	23 Jan 2007 05:57:32 -0000
@@ -67,50 +67,6 @@
    offsetof(struct sigcontext_struct, handler) == 0x14 */
 #define PPC_LINUX_HANDLER_PTR_OFFSET (PPC_LINUX_SIGNAL_FRAMESIZE + 0x14)
 
-/* From <asm/ptrace.h>, values for PT_NIP, PT_R1, and PT_LNK */
-#define PPC_LINUX_PT_R0		0
-#define PPC_LINUX_PT_R1		1
-#define PPC_LINUX_PT_R2		2
-#define PPC_LINUX_PT_R3		3
-#define PPC_LINUX_PT_R4		4
-#define PPC_LINUX_PT_R5		5
-#define PPC_LINUX_PT_R6		6
-#define PPC_LINUX_PT_R7		7
-#define PPC_LINUX_PT_R8		8
-#define PPC_LINUX_PT_R9		9
-#define PPC_LINUX_PT_R10	10
-#define PPC_LINUX_PT_R11	11
-#define PPC_LINUX_PT_R12	12
-#define PPC_LINUX_PT_R13	13
-#define PPC_LINUX_PT_R14	14
-#define PPC_LINUX_PT_R15	15
-#define PPC_LINUX_PT_R16	16
-#define PPC_LINUX_PT_R17	17
-#define PPC_LINUX_PT_R18	18
-#define PPC_LINUX_PT_R19	19
-#define PPC_LINUX_PT_R20	20
-#define PPC_LINUX_PT_R21	21
-#define PPC_LINUX_PT_R22	22
-#define PPC_LINUX_PT_R23	23
-#define PPC_LINUX_PT_R24	24
-#define PPC_LINUX_PT_R25	25
-#define PPC_LINUX_PT_R26	26
-#define PPC_LINUX_PT_R27	27
-#define PPC_LINUX_PT_R28	28
-#define PPC_LINUX_PT_R29	29
-#define PPC_LINUX_PT_R30	30
-#define PPC_LINUX_PT_R31	31
-#define PPC_LINUX_PT_NIP	32
-#define PPC_LINUX_PT_MSR	33
-#define PPC_LINUX_PT_CTR	35
-#define PPC_LINUX_PT_LNK	36
-#define PPC_LINUX_PT_XER	37
-#define PPC_LINUX_PT_CCR	38
-#define PPC_LINUX_PT_MQ		39
-#define PPC_LINUX_PT_FPR0	48	/* each FP reg occupies 2 slots in this space */
-#define PPC_LINUX_PT_FPR31 (PPC_LINUX_PT_FPR0 + 2*31)
-#define PPC_LINUX_PT_FPSCR (PPC_LINUX_PT_FPR0 + 2*32 + 1)
-
 static int ppc_linux_at_sigtramp_return_path (CORE_ADDR pc);
 
 /* Determine if pc is in a signal trampoline...
@@ -762,99 +718,120 @@ ppc64_linux_convert_from_func_ptr_addr (
   return addr;
 }
 
-static void
-right_supply_register (struct regcache *regcache, int wordsize, int regnum,
-		       const bfd_byte *buf)
-{
-  regcache_raw_supply (regcache, regnum,
-		       (buf + wordsize - register_size (current_gdbarch, regnum)));
-}
-
-/* Extract the register values found in the WORDSIZED ABI GREGSET,
-   storing their values in REGCACHE.  Note that some are left-aligned,
-   while others are right aligned.  */
+/* Regset descriptions.  */
+static const struct ppc_reg_offsets ppc32_linux_reg_offsets =
+  {
+    /* General-purpose registers.  */
+    /* .r0_offset = */ 0,
+    /* .gpr_size = */ 4,
+    /* .pc_offset = */ 128,
+    /* .ps_offset = */ 132,
+    /* .cr_offset = */ 152,
+    /* .lr_offset = */ 144,
+    /* .ctr_offset = */ 140,
+    /* .xer_offset = */ 148,
+    /* .mq_offset = */ 156,
+
+    /* Floating-point registers.  */
+    /* .f0_offset = */ 0,
+    /* .fpscr_offset = */ 256 + 4,
+
+    /* AltiVec registers.  */
+    /* .vr0_offset = */ 0,
+    /* .vrsave_offset = */ 512,
+    /* .vscr_offset = */ 512 + 12
+  };
 
-void
-ppc_linux_supply_gregset (struct regcache *regcache,
-			  int regnum, const void *gregs, size_t size,
-			  int wordsize)
-{
-  int regi;
-  struct gdbarch *regcache_arch = get_regcache_arch (regcache); 
-  struct gdbarch_tdep *regcache_tdep = gdbarch_tdep (regcache_arch);
-  const bfd_byte *buf = gregs;
-
-  for (regi = 0; regi < ppc_num_gprs; 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);
-  right_supply_register (regcache, wordsize, regcache_tdep->ppc_lr_regnum,
-			 buf + wordsize * PPC_LINUX_PT_LNK);
-  regcache_raw_supply (regcache, regcache_tdep->ppc_cr_regnum,
-		       buf + wordsize * PPC_LINUX_PT_CCR);
-  regcache_raw_supply (regcache, regcache_tdep->ppc_xer_regnum,
-		       buf + wordsize * PPC_LINUX_PT_XER);
-  regcache_raw_supply (regcache, regcache_tdep->ppc_ctr_regnum,
-		       buf + wordsize * PPC_LINUX_PT_CTR);
-  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);
-}
+static const struct ppc_reg_offsets ppc64_linux_reg_offsets =
+  {
+    /* General-purpose registers.  */
+    /* .r0_offset = */ 0,
+    /* .gpr_size = */ 8,
+    /* .pc_offset = */ 256,
+    /* .ps_offset = */ 264,
+    /* .cr_offset = */ 304 + 4,
+    /* .lr_offset = */ 288,
+    /* .ctr_offset = */ 280,
+    /* .xer_offset = */ 296 + 4,
+    /* .mq_offset = */ 312 + 4,
+
+    /* Floating-point registers.  */
+    /* .f0_offset = */ 0,
+    /* .fpscr_offset = */ 256 + 4,
+
+    /* AltiVec registers.  */
+    /* .vr0_offset = */ 0,
+    /* .vrsave_offset = */ 528,
+    /* .vscr_offset = */ 512 + 12
+  };
 
-static void
-ppc32_linux_supply_gregset (const struct regset *regset,
-			    struct regcache *regcache,
-			    int regnum, const void *gregs, size_t size)
-{
-  ppc_linux_supply_gregset (regcache, regnum, gregs, size, 4);
-}
+static const struct ppc_reg_offsets ppc64_32_linux_reg_offsets =
+  {
+    /* General-purpose registers.  */
+    /* .r0_offset = */ 0 + 4,
+    /* .gpr_size = */ 8,
+    /* .pc_offset = */ 256 + 4,
+    /* .ps_offset = */ 264 + 4,
+    /* .cr_offset = */ 304 + 4,
+    /* .lr_offset = */ 288 + 4,
+    /* .ctr_offset = */ 280 + 4,
+    /* .xer_offset = */ 296 + 4,
+    /* .mq_offset = */ 312 + 4,
+
+    /* Floating-point registers.  */
+    /* .f0_offset = */ 0,
+    /* .fpscr_offset = */ 256 + 4,
+
+    /* AltiVec registers.  */
+    /* .vr0_offset = */ 0,
+    /* .vrsave_offset = */ 528,
+    /* .vscr_offset = */ 512 + 12
+  };
 
 static struct regset ppc32_linux_gregset = {
-  NULL, ppc32_linux_supply_gregset
+  &ppc32_linux_reg_offsets,
+  ppc_supply_gregset,
+  ppc_collect_gregset,
+  NULL
 };
 
-static void
-ppc64_linux_supply_gregset (const struct regset *regset,
-			    struct regcache * regcache,
-			    int regnum, const void *gregs, size_t size)
-{
-  ppc_linux_supply_gregset (regcache, regnum, gregs, size, 8);
-}
-
 static struct regset ppc64_linux_gregset = {
-  NULL, ppc64_linux_supply_gregset
+  &ppc64_linux_reg_offsets,
+  ppc_supply_gregset,
+  ppc_collect_gregset,
+  NULL
 };
 
-void
-ppc_linux_supply_fpregset (const struct regset *regset,
-			   struct regcache * regcache,
-			   int regnum, const void *fpset, size_t size)
-{
-  int regi;
-  struct gdbarch *regcache_arch = get_regcache_arch (regcache); 
-  struct gdbarch_tdep *regcache_tdep = gdbarch_tdep (regcache_arch);
-  const bfd_byte *buf = fpset;
-
-  if (! ppc_floating_point_unit_p (regcache_arch))
-    return;
-
-  for (regi = 0; regi < ppc_num_fprs; regi++)
-    regcache_raw_supply (regcache, 
-                         regcache_tdep->ppc_fp0_regnum + regi,
-                         buf + 8 * regi);
-
-  /* The FPSCR is stored in the low order word of the last
-     doubleword in the fpregset.  */
-  regcache_raw_supply (regcache, regcache_tdep->ppc_fpscr_regnum,
-                       buf + 8 * 32 + 4);
+static struct regset ppc64_32_linux_gregset = {
+  &ppc64_32_linux_reg_offsets,
+  ppc_supply_gregset,
+  ppc_collect_gregset,
+  NULL
+};
+
+static struct regset ppc32_linux_fpregset = {
+  &ppc32_linux_reg_offsets,
+  ppc_supply_fpregset,
+  ppc_collect_fpregset,
+  NULL
+};
+
+const struct regset *
+ppc_linux_gregset (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  if (tdep->wordsize == 8)
+    return &ppc64_linux_gregset;
+  if (sizeof (long) == 8)
+    return &ppc64_32_linux_gregset;
+  return &ppc32_linux_gregset;
 }
 
-static struct regset ppc_linux_fpregset = { NULL, ppc_linux_supply_fpregset };
+const struct regset *
+ppc_linux_fpregset (struct gdbarch *gdbarch)
+{
+  return &ppc32_linux_fpregset;
+}
 
 static const struct regset *
 ppc_linux_regset_from_core_section (struct gdbarch *core_arch,
@@ -869,7 +846,7 @@ ppc_linux_regset_from_core_section (stru
 	return &ppc64_linux_gregset;
     }
   if (strcmp (sect_name, ".reg2") == 0)
-    return &ppc_linux_fpregset;
+    return &ppc32_linux_fpregset;
   return NULL;
 }
 
Index: gdb/ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.52
diff -u -p -r1.52 ppc-tdep.h
--- gdb/ppc-tdep.h	9 Jan 2007 17:58:55 -0000	1.52
+++ gdb/ppc-tdep.h	23 Jan 2007 05:57:32 -0000
@@ -58,12 +58,8 @@ CORE_ADDR ppc64_sysv_abi_adjust_breakpoi
 						    CORE_ADDR bpaddr);
 int ppc_linux_memory_remove_breakpoint (struct bp_target_info *bp_tgt);
 struct link_map_offsets *ppc_linux_svr4_fetch_link_map_offsets (void);
-void ppc_linux_supply_gregset (struct regcache *regcache,
-			       int regnum, const void *gregs, size_t size,
-			       int wordsize);
-void ppc_linux_supply_fpregset (const struct regset *regset,
-				struct regcache *regcache,
-				int regnum, const void *gregs, size_t size);
+const struct regset *ppc_linux_gregset (struct gdbarch *);
+const struct regset *ppc_linux_fpregset (struct gdbarch *);
 
 enum return_value_convention ppc64_sysv_abi_return_value (struct gdbarch *gdbarch,
 							  struct type *valtype,
@@ -85,6 +81,7 @@ struct ppc_reg_offsets
 {
   /* General-purpose registers.  */
   int r0_offset;
+  int gpr_size;
   int pc_offset;
   int ps_offset;
   int cr_offset;
Index: gdb/ppcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v
retrieving revision 1.31
diff -u -p -r1.31 ppcnbsd-tdep.c
--- gdb/ppcnbsd-tdep.c	9 Jan 2007 17:58:55 -0000	1.31
+++ gdb/ppcnbsd-tdep.c	23 Jan 2007 05:57:33 -0000
@@ -212,6 +212,7 @@ _initialize_ppcnbsd_tdep (void)
     {
       /* General-purpose registers.  */
       ppcnbsd_reg_offsets.r0_offset = 0;
+      ppcnbsd_reg_offsets.gpr_size = 4;
       ppcnbsd_reg_offsets.lr_offset = 128;
       ppcnbsd_reg_offsets.cr_offset = 132;
       ppcnbsd_reg_offsets.xer_offset = 136;
Index: gdb/ppcobsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcobsd-tdep.c,v
retrieving revision 1.13
diff -u -p -r1.13 ppcobsd-tdep.c
--- gdb/ppcobsd-tdep.c	9 Jan 2007 17:58:55 -0000	1.13
+++ gdb/ppcobsd-tdep.c	23 Jan 2007 05:57:33 -0000
@@ -331,6 +331,7 @@ _initialize_ppcobsd_tdep (void)
     {
       /* General-purpose registers.  */
       ppcobsd_reg_offsets.r0_offset = 0;
+      ppcobsd_reg_offsets.gpr_size = 4;
       ppcobsd_reg_offsets.pc_offset = 384;
       ppcobsd_reg_offsets.ps_offset = 388;
       ppcobsd_reg_offsets.cr_offset = 392;
Index: gdb/rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.260
diff -u -p -r1.260 rs6000-tdep.c
--- gdb/rs6000-tdep.c	9 Jan 2007 17:58:57 -0000	1.260
+++ gdb/rs6000-tdep.c	23 Jan 2007 05:57:35 -0000
@@ -338,7 +338,7 @@ ppc_supply_gregset (const struct regset 
 
   for (i = tdep->ppc_gp0_regnum, offset = offsets->r0_offset;
        i < tdep->ppc_gp0_regnum + ppc_num_gprs;
-       i++, offset += 4)
+       i++, offset += offsets->gpr_size)
     {
       if (regnum == -1 || regnum == i)
 	ppc_supply_reg (regcache, i, gregs, offset);
@@ -360,7 +360,7 @@ ppc_supply_gregset (const struct regset 
 		    gregs, offsets->ctr_offset);
   if (regnum == -1 || regnum == tdep->ppc_xer_regnum)
     ppc_supply_reg (regcache, tdep->ppc_xer_regnum,
-		    gregs, offsets->cr_offset);
+		    gregs, offsets->xer_offset);
   if (regnum == -1 || regnum == tdep->ppc_mq_regnum)
     ppc_supply_reg (regcache, tdep->ppc_mq_regnum, gregs, offsets->mq_offset);
 }
@@ -396,7 +396,7 @@ ppc_supply_fpregset (const struct regset
 }
 
 /* Collect register REGNUM in the general-purpose register set
-   REGSET. from register cache REGCACHE into the buffer specified by
+   REGSET from register cache REGCACHE into the buffer specified by
    GREGS and LEN.  If REGNUM is -1, do this for all registers in
    REGSET.  */
 
@@ -414,7 +414,7 @@ ppc_collect_gregset (const struct regset
   offset = offsets->r0_offset;
   for (i = tdep->ppc_gp0_regnum;
        i < tdep->ppc_gp0_regnum + ppc_num_gprs;
-       i++, offset += 4)
+       i++, offset += offsets->gpr_size)
     {
       if (regnum == -1 || regnum == i)
 	ppc_collect_reg (regcache, i, gregs, offset);
@@ -443,7 +443,7 @@ ppc_collect_gregset (const struct regset
 }
 
 /* Collect register REGNUM in the floating-point register set
-   REGSET. from register cache REGCACHE into the buffer specified by
+   REGSET from register cache REGCACHE into the buffer specified by
    FPREGS and LEN.  If REGNUM is -1, do this for all registers in
    REGSET.  */
 

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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