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
|
|
|
|
|
2005-12-18 06:34:03 +08:00
|
|
|
|
Copyright (C) 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
|
2005-12-18 06:34:03 +08:00
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, 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))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +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))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +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
|
|
|
|
{
|
2004-04-22 01:47:10 +08:00
|
|
|
|
deprecated_add_core_fns (®set_core_fns);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|