gdb.gdb.sol2-core-regset.c.patch revision 2074
6399N/A--- /dev/null 2013-10-06 14:14:47.000000000 -0700
6399N/A+++ gdb-7.6/gdb/sol2-core-regset.c 2013-10-06 13:55:51.348498600 -0700
6399N/A@@ -0,0 +1,147 @@
6399N/A+/* Machine dependent GDB support for core files on Solaris using "regsets".
6399N/A+
6399N/A+ Copyright (C) 2013 Free Software Foundation, Inc.
6399N/A+
6996N/A+ This file is part of GDB.
6996N/A+
6996N/A+ This program is free software; you can redistribute it and/or modify
6996N/A+ it under the terms of the GNU General Public License as published by
6996N/A+ the Free Software Foundation; either version 3 of the License, or
6996N/A+ (at your option) any later version.
6996N/A+
6996N/A+ This program is distributed in the hope that it will be useful,
6996N/A+ but WITHOUT ANY WARRANTY; without even the implied warranty of
6996N/A+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6996N/A+ GNU General Public License for more details.
6996N/A+
6996N/A+ You should have received a copy of the GNU General Public License
6996N/A+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
6996N/A+
6996N/A+/* This file is used by Solaris core dumps. The Solaris /proc filesystem
6996N/A+ * will yield different sizes for prgregset_t prfpregset_t depending
6996N/A+ * on sizeof(void*). We handle these differences in this Solaris-specific
6399N/A+ * core-regset.c file, as opposed to imposing all these Solaris particulars
6399N/A+ * on everyone else.
6399N/A+ */
6399N/A+
6399N/A+#include "defs.h"
6399N/A+#include "command.h"
6399N/A+#include "gdbcore.h"
6399N/A+#include "gdbarch.h"
6399N/A+#include "inferior.h"
6399N/A+#include "target.h"
6399N/A+#include "regcache.h"
6399N/A+#include "elf-bfd.h"
6399N/A+
6399N/A+#include <fcntl.h>
6399N/A+#include <errno.h>
6399N/A+#include "gdb_string.h"
6399N/A+#include <time.h>
6399N/A+#ifdef HAVE_SYS_PROCFS_H
6399N/A+#include <sys/procfs.h>
6399N/A+#endif
6399N/A+
6399N/A+/* Prototypes for supply_gregset etc. */
6399N/A+#include "gregset.h"
6399N/A+
6399N/A+/* Provide registers to GDB from a core file.
6399N/A+
6399N/A+ CORE_REG_SECT points to an array of bytes, which are the contents
6399N/A+ of a `note' from a core file which BFD thinks might contain
6399N/A+ register contents. CORE_REG_SIZE is its size.
6399N/A+
6399N/A+ WHICH says which register set corelow suspects this is:
6399N/A+ 0 --- the general-purpose register set, in gregset_t format
6399N/A+ 2 --- the floating-point register set, in fpregset_t format
6399N/A+
6399N/A+ REG_ADDR is ignored. */
6399N/A+
6399N/A+static void
6399N/A+fetch_core_registers (struct regcache *regcache,
6399N/A+ char *core_reg_sect,
6399N/A+ unsigned core_reg_size,
6399N/A+ int which,
6399N/A+ CORE_ADDR reg_addr)
6399N/A+{
6399N/A+ gdb_gregset_t gregset;
6399N/A+ gdb_fpregset_t fpregset;
6399N/A+ gdb_gregset_t *gregset_p = &gregset;
6399N/A+ gdb_fpregset_t *fpregset_p = &fpregset;
6399N/A+ /* use default sizes on 64-bit Solaris */
6399N/A+ size_t gregset_size = sizeof (gregset);
6399N/A+ size_t fpregset_size = sizeof (fpregset);
6399N/A+ int pointer_size;
6399N/A+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
6399N/A+ enum bfd_endian byte_order;
6399N/A+
6399N/A+ if (gdbarch_osabi (gdbarch) == GDB_OSABI_SOLARIS)
6399N/A+ {
6399N/A+ set_regcache_from_corefile (regcache);
6399N/A+ byte_order = gdbarch_byte_order (gdbarch);
6399N/A+ pointer_size = gdbarch_ptr_bit (gdbarch);
6399N/A+
6399N/A+ if ((byte_order == BFD_ENDIAN_BIG) && (pointer_size == 32))
6399N/A+ {
6399N/A+ gregset_size = 152;
6399N/A+ fpregset_size = 144;
6399N/A+ }
6399N/A+ else if ((byte_order == BFD_ENDIAN_LITTLE) && (pointer_size == 32))
6399N/A+ {
6399N/A+ gregset_size = 76;
6399N/A+ fpregset_size = 380;
6399N/A+ }
6399N/A+ }
6399N/A+
6399N/A+ switch (which)
6399N/A+ {
6399N/A+ case 0:
6399N/A+ if (core_reg_size != gregset_size)
6399N/A+ warning (_("Wrong size gregset in core file."));
6399N/A+ else
6399N/A+ {
6399N/A+ memcpy (&gregset, core_reg_sect, gregset_size);
6399N/A+ supply_gregset (regcache, (const gdb_gregset_t *) gregset_p);
6399N/A+ }
6399N/A+ break;
6399N/A+
6399N/A+ case 2:
6399N/A+ if (core_reg_size != fpregset_size)
6399N/A+ warning (_("Wrong size fpregset in core file."));
6399N/A+ else
6399N/A+ {
6399N/A+ memcpy (&fpregset, core_reg_sect, fpregset_size);
6399N/A+ if (gdbarch_fp0_regnum (get_regcache_arch (regcache)) >= 0)
6399N/A+ supply_fpregset (regcache,
6399N/A+ (const gdb_fpregset_t *) fpregset_p);
6399N/A+ }
6399N/A+ break;
6399N/A+
6399N/A+ default:
6399N/A+ /* We've covered all the kinds of registers we know about here,
6399N/A+ so this must be something we wouldn't know what to do with
6399N/A+ anyway. Just ignore it. */
6399N/A+ break;
6399N/A+ }
6399N/A+}
6399N/A+
6399N/A+
6399N/A+/* Register that we are able to handle ELF core file formats using
6399N/A+ standard procfs "regset" structures. */
6399N/A+
6399N/A+static struct core_fns regset_core_fns =
6399N/A+{
6399N/A+ bfd_target_elf_flavour, /* core_flavour */
6399N/A+ default_check_format, /* check_format */
6399N/A+ default_core_sniffer, /* core_sniffer */
6399N/A+ fetch_core_registers, /* core_read_registers */
6399N/A+ NULL /* next */
6399N/A+};
6399N/A+
6399N/A+/* Provide a prototype to silence -Wmissing-prototypes. */
6399N/A+extern void _initialize_core_regset (void);
6399N/A+
6399N/A+void
6399N/A+_initialize_core_regset (void)
6399N/A+{
6399N/A+ deprecated_add_core_fns (&regset_core_fns);
6399N/A+}
6399N/A