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