[rfa/ppc/branch too] Fix PowerPC/Linux cores

Daniel Jacobowitz
2001-07-30T14:23:00Z

I figure it would be nice if core files for Linux/PPC worked on the branch.
Linux/PPC doesn't have gregset_t or fpregset_t in its headers, so the body
of fetch_core_registers in core-regset.c gets #if'd out by autoconf. Cores
load but are absolutely useless. I have the feeling those #if's ought to be
outside the function rather than inside... but in any case, for now, this
patch fixes it the same way most other Linux targets do. I'll get back to
my rework of core support in the next few weeks now that we've branched.

OK to commit, trunk and branch?

--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer

2001-07-30 Daniel Jacobowitz <drow@mvista.com>

* config/powerpc/linux.mh (NATDEPFILES): Remove core-regset.o.
* ppc-linux-nat.c (fetch_core_registers): New function.
(regset_core_fns): New structure.
(_initialize_ppc_linux_nat): New function.

Index: config/powerpc/linux.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/powerpc/linux.mh,v
retrieving revision 1.6
diff -u -r1.6 linux.mh
--- gdb/gdb/config/powerpc/linux.mh 2000/10/30 22:33:32 1.6
+++ gdb/gdb/config/powerpc/linux.mh 2001/07/30 19:30:59
@@ -6,7 +6,7 @@

NAT_FILE= nm-linux.h
NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o \
-core-aout.o core-regset.o ppc-linux-nat.o proc-service.o thread-db.o lin-lwp.o
+core-aout.o ppc-linux-nat.o proc-service.o thread-db.o lin-lwp.o

LOADLIBES = -ldl -rdynamic

Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.9
diff -u -r1.9 ppc-linux-nat.c
--- gdb/gdb/ppc-linux-nat.c 2001/07/05 23:22:04 1.9
+++ gdb/gdb/ppc-linux-nat.c 2001/07/30 19:44:38
@@ -126,3 +126,57 @@
}
}
}
+
+/* Use a local version of this function to get the correct types for
+ regsets, until multi-arch core support is ready. */
+
+static void
+fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
+ int which, CORE_ADDR reg_addr)
+{
+ elf_gregset_t gregset;
+ elf_fpregset_t fpregset;
+
+ if (which == 0)
+ {
+ if (core_reg_size != sizeof (gregset))
+ {
+ warning ("wrong size gregset struct in core file");
+ }
+ else
+ {
+ memcpy ((char *) &gregset, core_reg_sect, sizeof (gregset));
+ supply_gregset (&gregset);
+ }
+ }
+ else if (which == 2)
+ {
+ if (core_reg_size != sizeof (fpregset))
+ {
+ warning ("wrong size fpregset struct in core file");
+ }
+ else
+ {
+ memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset));
+ supply_fpregset (&fpregset);
+ }
+ }
+}
+
+/* Register that we are able to handle ELF file formats using standard
+ procfs "regset" structures. */
+
+static struct core_fns regset_core_fns =
+{
+ bfd_target_elf_flavour, /* core_flavour */
+ default_check_format, /* check_format */
+ default_core_sniffer, /* core_sniffer */
+ fetch_core_registers, /* core_read_registers */
+ NULL /* next */
+};
+
+void
+_initialize_ppc_linux_nat (void)
+{
+ add_core_fns (&regset_core_fns);
+}