1999-04-16 09:35:26 +08:00
|
|
|
|
/* Machine independent GDB support for core files on systems using "regsets".
|
2003-04-19 20:00:48 +08:00
|
|
|
|
|
|
|
|
|
Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003
|
2001-03-06 16:22:02 +08:00
|
|
|
|
Free Software Foundation, Inc.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
/* This file is used by most systems that use ELF for their core
|
|
|
|
|
dumps. This includes most systems that have SVR4-ish variant of
|
|
|
|
|
/proc. For these systems, the registers are laid out the same way
|
|
|
|
|
in core files as in the gregset_t and fpregset_t structures that
|
|
|
|
|
are used in the interaction with /proc (Irix 4 is an exception and
|
|
|
|
|
therefore doesn't use this file). Quite a few systems without a
|
|
|
|
|
SVR4-ish /proc define these structures too, and can make use of
|
|
|
|
|
this code too. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
2003-04-19 20:00:48 +08:00
|
|
|
|
#include "command.h"
|
|
|
|
|
#include "gdbcore.h"
|
|
|
|
|
#include "inferior.h"
|
|
|
|
|
#include "target.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include "gdb_string.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
|
#include <time.h>
|
|
|
|
|
#ifdef HAVE_SYS_PROCFS_H
|
|
|
|
|
#include <sys/procfs.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
/* Prototypes for supply_gregset etc. */
|
2000-05-26 Michael Snyder <msnyder@seadog.cygnus.com>
* gregset.h: New file. Typedefs for gdb_gregset_t and
gdb_fpregset_t, prototypes for supply_gregset and friends.
* procfs.c: Include gregset.h. Delete local prototypes for
supply_gregset etc., and local typedef gdb_gregset_t etc.
* sol-thread.c: Include gregset.h, delete local prototypes,
add appropriate casts to gdb_gregset_t.
* uw-thread.c, lin-thread.c, core-sol2.c, core-regset.c,
sparc-tdep.c, ptx4-nat.c, ppc-linux-nat.c, mipsv4-nat.c,
m88k-nat.c, m68klinux-nat.c, m68k-tdep.c, irix5-nat.c,
irix4-nat.c, ia64-linux-nat.c, i386v4-nat.c, cxux-nat.c,
arm-linux-nat.c, alpha-nat.c: Include gregset.h.
* config/nm-linux.h: Define GDB_GREGSET_T, GDB_FPREGET_T.
* config/sparc/tm-sun4sol2.h: Ditto.
2000-05-27 07:22:41 +08:00
|
|
|
|
#include "gregset.h"
|
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
/* Provide registers to GDB from a core file.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
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.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
WHICH says which register set corelow suspects this is:
|
|
|
|
|
0 --- the general-purpose register set, in gregset_t format
|
|
|
|
|
2 --- the floating-point register set, in fpregset_t format
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
REG_ADDR is ignored. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
static void
|
2000-08-07 11:07:59 +08:00
|
|
|
|
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
|
|
|
|
|
CORE_ADDR reg_addr)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
2001-08-04 05:34:01 +08:00
|
|
|
|
gdb_gregset_t gregset;
|
|
|
|
|
gdb_fpregset_t fpregset;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
switch (which)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
2003-04-19 20:00:48 +08:00
|
|
|
|
case 0:
|
1999-04-16 09:35:26 +08:00
|
|
|
|
if (core_reg_size != sizeof (gregset))
|
2003-04-19 20:00:48 +08:00
|
|
|
|
warning ("Wrong size gregset in core file.");
|
1999-04-16 09:35:26 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2003-04-19 20:00:48 +08:00
|
|
|
|
memcpy (&gregset, core_reg_sect, sizeof (gregset));
|
1999-04-16 09:35:26 +08:00
|
|
|
|
supply_gregset (&gregset);
|
|
|
|
|
}
|
2003-04-19 20:00:48 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
1999-04-16 09:35:26 +08:00
|
|
|
|
if (core_reg_size != sizeof (fpregset))
|
2003-04-19 20:00:48 +08:00
|
|
|
|
warning ("Wrong size fpregset in core file.");
|
1999-04-16 09:35:26 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2003-04-19 20:00:48 +08:00
|
|
|
|
memcpy (&fpregset, core_reg_sect, sizeof (fpregset));
|
2000-05-11 01:38:16 +08:00
|
|
|
|
if (FP0_REGNUM >= 0)
|
|
|
|
|
supply_fpregset (&fpregset);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
2003-04-19 20:00:48 +08:00
|
|
|
|
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;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
/* Register that we are able to handle ELF core file formats using
|
|
|
|
|
standard procfs "regset" structures. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
static struct core_fns regset_core_fns =
|
|
|
|
|
{
|
1999-10-06 07:13:56 +08:00
|
|
|
|
bfd_target_elf_flavour, /* core_flavour */
|
|
|
|
|
default_check_format, /* check_format */
|
|
|
|
|
default_core_sniffer, /* core_sniffer */
|
|
|
|
|
fetch_core_registers, /* core_read_registers */
|
|
|
|
|
NULL /* next */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
};
|
|
|
|
|
|
2003-04-19 20:00:48 +08:00
|
|
|
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
|
|
|
|
extern void _initialize_core_regset (void);
|
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
void
|
2000-07-30 09:48:28 +08:00
|
|
|
|
_initialize_core_regset (void)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
add_core_fns (®set_core_fns);
|
|
|
|
|
}
|