This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Fix m68k-linux build
- To: gdb-patches at sources dot redhat dot com
- Subject: Fix m68k-linux build
- From: Daniel Jacobowitz <dmj+ at andrew dot cmu dot edu>
- Date: Wed, 11 Jul 2001 11:02:29 -0700
I don't have the hardware to test this, but by (exact) analogy with all the
other Linux ports, I'm pretty sure it's correct. And yes, I intend to
eliminate all these copies of fetch_core_registers in one fell swoop some
day soon...
OK to commit this?
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
2001-07-11 Michael Fedrowitz <michael.fedrowitz@informatik.uni-ulm.de>
* config/m68k/linux.mh: Remove core-regset.o.
* m68klinux-nat.c: Fix comment.
(supply_gregset): Change argument to elf_gregset_t *.
(supply_fpregset): Change argument to elf_fpregset_t *.
(fetch_core_registers): New function.
(linux_elf_core_fns): Define.
(_initialize_m68k_linux_nat): New function.
diff -urN gdb-5.0.cvs20010704.orig/gdb/config/m68k/linux.mh gdb-5.0.cvs20010704/gdb/config/m68k/linux.mh
--- gdb-5.0.cvs20010704.orig/gdb/config/m68k/linux.mh Mon Oct 30 23:33:32 2000
+++ gdb-5.0.cvs20010704/gdb/config/m68k/linux.mh Tue Jul 10 22:32:13 2001
@@ -5,6 +5,6 @@
NAT_FILE= nm-linux.h
NATDEPFILES= infptrace.o inftarg.o fork-child.o \
- corelow.o core-aout.o core-regset.o m68klinux-nat.o linux-thread.o
+ corelow.o core-aout.o m68klinux-nat.o linux-thread.o
GDBSERVER_DEPFILES= low-linux.o
diff -urN gdb-5.0.cvs20010704.orig/gdb/m68klinux-nat.c gdb-5.0.cvs20010704/gdb/m68klinux-nat.c
--- gdb-5.0.cvs20010704.orig/gdb/m68klinux-nat.c Tue Mar 6 09:21:09 2001
+++ gdb-5.0.cvs20010704/gdb/m68klinux-nat.c Tue Jul 10 22:34:43 2001
@@ -66,9 +66,9 @@
return (blockend + 4 * regmap[regnum]);
}
-/* Given a pointer to a general register set in /proc format (gregset_t *),
- unpack the register contents and supply them as gdb's idea of the current
- register values. */
+/* Given a pointer to a general register set in /proc format
+ (elf_gregset_t *), unpack the register contents and supply
+ them as gdb's idea of the current register values. */
/* Note both m68k-tdep.c and m68klinux-nat.c contain definitions
@@ -85,7 +85,7 @@
#include "gregset.h"
void
-supply_gregset (gregset_t *gregsetp)
+supply_gregset (elf_gregset_t *gregsetp)
{
int regi;
@@ -100,7 +100,7 @@
idea of the current floating point register values. */
void
-supply_fpregset (fpregset_t *fpregsetp)
+supply_fpregset (elf_fpregset_t *fpregsetp)
{
int regi;
@@ -112,6 +112,62 @@
}
#endif
+
+
+/* Interpreting register set info found in core files. */
+
+/* Provide registers to GDB from a core file.
+
+ (We can't use the generic version of this function in
+ core-regset.c, because we need to use elf_gregset_t instead of
+ gregset_t.)
+
+ CORE_REG_SECT points to an array of bytes, which are the contents
+ of a `note' from a core file which BFD thinks might contain
+ register contents. CORE_REG_SIZE is its size.
+
+ WHICH says which register set corelow suspects this is:
+ 0 --- the general-purpose register set, in elf_gregset_t format
+ 2 --- the floating-point register set, in elf_fpregset_t format
+
+ REG_ADDR isn't used on Linux. */
+
+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;
+
+ switch (which)
+ {
+ case 0:
+ if (core_reg_size != sizeof (gregset))
+ warning ("Wrong size gregset in core file.");
+ else
+ {
+ memcpy (&gregset, core_reg_sect, sizeof (gregset));
+ supply_gregset (&gregset);
+ }
+ break;
+
+ case 2:
+ if (core_reg_size != sizeof (fpregset))
+ warning ("Wrong size fpregset in core file.");
+ else
+ {
+ memcpy (&fpregset, core_reg_sect, sizeof (fpregset));
+ supply_fpregset (&fpregset);
+ }
+ break;
+
+ default:
+ /* We've covered all the kinds of registers we know about here,
+ so this must be something we wouldn't know what to do with
+ anyway. Just ignore it. */
+ break;
+ }
+}
int
@@ -152,4 +208,22 @@
return 1;
return 0;
+}
+
+
+/* Register that we are able to handle Linux ELF core file formats. */
+
+static struct core_fns linux_elf_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_m68k_linux_nat ()
+{
+ add_core_fns (&linux_elf_core_fns);
}