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/ppc64] Fix obvious 64-bit ppc-linux-tdep problems


Hello,

This fixes two "obvious" problems in ppc-linux-tdep.c where the code was assuming 32-bit registers.

ok for mainline?
Andrew
2003-11-25  Andrew Cagney  <cagney@redhat.com>

	* ppc-linux-tdep.c (ppc_linux_supply_gregset): Use tdep's
	wordsize, instead of 4, as the size of each gregset register.
	(ELF_GREGSET_SIZE): Delete.
	(fetch_core_registers): Use tdep's wordsize to compute the
	expected size of the the gregset.

Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.49
diff -u -r1.49 ppc-linux-tdep.c
--- ppc-linux-tdep.c	14 Nov 2003 14:16:29 -0000	1.49
+++ ppc-linux-tdep.c	25 Nov 2003 21:57:55 -0000
@@ -959,7 +959,6 @@
 };
 
 enum {
-  ELF_GREGSET_SIZE = (ELF_NGREG * 4),
   ELF_FPREGSET_SIZE = (ELF_NFPREG * 8)
 };
 
@@ -967,19 +966,20 @@
 ppc_linux_supply_gregset (char *buf)
 {
   int regi;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  const int wordsize = tdep->wordsize;
 
   for (regi = 0; regi < 32; regi++)
-    supply_register (regi, buf + 4 * regi);
+    supply_register (regi, buf + wordsize * regi);
 
-  supply_register (PC_REGNUM, buf + 4 * PPC_LINUX_PT_NIP);
-  supply_register (tdep->ppc_lr_regnum, buf + 4 * PPC_LINUX_PT_LNK);
-  supply_register (tdep->ppc_cr_regnum, buf + 4 * PPC_LINUX_PT_CCR);
-  supply_register (tdep->ppc_xer_regnum, buf + 4 * PPC_LINUX_PT_XER);
-  supply_register (tdep->ppc_ctr_regnum, buf + 4 * PPC_LINUX_PT_CTR);
+  supply_register (PC_REGNUM, buf + wordsize * PPC_LINUX_PT_NIP);
+  supply_register (tdep->ppc_lr_regnum, buf + wordsize * PPC_LINUX_PT_LNK);
+  supply_register (tdep->ppc_cr_regnum, buf + wordsize * PPC_LINUX_PT_CCR);
+  supply_register (tdep->ppc_xer_regnum, buf + wordsize * PPC_LINUX_PT_XER);
+  supply_register (tdep->ppc_ctr_regnum, buf + wordsize * PPC_LINUX_PT_CTR);
   if (tdep->ppc_mq_regnum != -1)
-    supply_register (tdep->ppc_mq_regnum, buf + 4 * PPC_LINUX_PT_MQ);
-  supply_register (tdep->ppc_ps_regnum, buf + 4 * PPC_LINUX_PT_MSR);
+    supply_register (tdep->ppc_mq_regnum, buf + wordsize * PPC_LINUX_PT_MQ);
+  supply_register (tdep->ppc_ps_regnum, buf + wordsize * PPC_LINUX_PT_MSR);
 }
 
 void
@@ -1008,7 +1008,8 @@
 {
   if (which == 0)
     {
-      if (core_reg_size == ELF_GREGSET_SIZE)
+      const int wordsize = gdbarch_tdep (current_gdbarch)->wordsize;
+      if (core_reg_size == (ELF_NGREG * wordsize))
 	ppc_linux_supply_gregset (core_reg_sect);
       else
 	warning ("wrong size gregset struct in core file");

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