diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2004-12-27 21:11:09 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2004-12-27 21:11:09 +0000 |
commit | 46c30d4a399f499a342a15f45269d8fe17496f2a (patch) | |
tree | 63bac207f81ff150ccb3939dca619f495ab9a054 /gnu/usr.bin | |
parent | 67cb69af36063d98fe1c83f32f89dcbd285a956d (diff) |
Add sgi support.
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/binutils/Makefile.bsd-wrapper | 4 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/config/mips/obsd64.mh | 2 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/config/mips/obsd64.mt | 3 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/configure.host | 1 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/configure.tgt | 1 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/mips64obsd-nat.c | 125 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/mips64obsd-tdep.c | 161 |
7 files changed, 294 insertions, 3 deletions
diff --git a/gnu/usr.bin/binutils/Makefile.bsd-wrapper b/gnu/usr.bin/binutils/Makefile.bsd-wrapper index a120c378fe3..083c3e72f88 100644 --- a/gnu/usr.bin/binutils/Makefile.bsd-wrapper +++ b/gnu/usr.bin/binutils/Makefile.bsd-wrapper @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.61 2004/11/10 22:31:33 drahn Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.62 2004/12/27 21:11:07 kettenis Exp $ NEW_BINUTILS=amd64 alpha arm hppa i386 mips64 powerpc sparc sparc64 @@ -35,14 +35,12 @@ MANDIR=${PREFIX}/share/man/cat MAN= binutils/objdump.1 c++filt.1 -.if (${MACHINE_ARCH} != "mips64") CONF_SUBDIRS+= gdb SUBDIRS+= gdb INST_SUBDIRS+= gdb MAN+= gdb/gdb.1 ALL_X11_MODULES+=all-gdb INSTALL_X11_MODULES+=install-gdb -.endif .if ${USING_NEW_BINUTILS} == "yes" diff --git a/gnu/usr.bin/binutils/gdb/config/mips/obsd64.mh b/gnu/usr.bin/binutils/gdb/config/mips/obsd64.mh new file mode 100644 index 00000000000..b41b2ee61f1 --- /dev/null +++ b/gnu/usr.bin/binutils/gdb/config/mips/obsd64.mh @@ -0,0 +1,2 @@ +# Host: OpenBSD/mips64 +NATDEPFILES= fork-child.o inf-ptrace.o mips64obsd-nat.o diff --git a/gnu/usr.bin/binutils/gdb/config/mips/obsd64.mt b/gnu/usr.bin/binutils/gdb/config/mips/obsd64.mt new file mode 100644 index 00000000000..de54a2fb74f --- /dev/null +++ b/gnu/usr.bin/binutils/gdb/config/mips/obsd64.mt @@ -0,0 +1,3 @@ +# Target: OpenBSD/mips64 +TDEPFILES= mips-tdep.o mips64obsd-tdep.o corelow.o solib.o solib-svr4.o +DEPRECATED_TM_FILE= solib.h diff --git a/gnu/usr.bin/binutils/gdb/configure.host b/gnu/usr.bin/binutils/gdb/configure.host index dc27841aeaa..559973ee3cb 100644 --- a/gnu/usr.bin/binutils/gdb/configure.host +++ b/gnu/usr.bin/binutils/gdb/configure.host @@ -104,6 +104,7 @@ mips-sgi-irix6*) gdb_host=irix6 ;; mips*-*-linux*) gdb_host=linux ;; mips*-*-netbsd* | mips*-*-knetbsd*-gnu) gdb_host=nbsd ;; +mips64*-*-openbsd*) gdb_host=obsd64 ;; ns32k-*-netbsd*) gdb_host=nbsdaout ;; diff --git a/gnu/usr.bin/binutils/gdb/configure.tgt b/gnu/usr.bin/binutils/gdb/configure.tgt index bc70fbe0a6b..ea0ef9da4cf 100644 --- a/gnu/usr.bin/binutils/gdb/configure.tgt +++ b/gnu/usr.bin/binutils/gdb/configure.tgt @@ -140,6 +140,7 @@ mips*-*-linux*) gdb_target=linux ;; mips*-*-netbsd* | mips*-*-knetbsd*-gnu) gdb_target=nbsd ;; +mips64*-*-openbsd*) gdb_target=obsd64 ;; mips*-*-vxworks*) gdb_target=vxmips ;; mips*-*-*) gdb_target=embed ;; diff --git a/gnu/usr.bin/binutils/gdb/mips64obsd-nat.c b/gnu/usr.bin/binutils/gdb/mips64obsd-nat.c new file mode 100644 index 00000000000..d3f1d690f2e --- /dev/null +++ b/gnu/usr.bin/binutils/gdb/mips64obsd-nat.c @@ -0,0 +1,125 @@ +/* Native-dependent code for OpenBSD/mips64. + + Copyright 2004 Free Software Foundation, Inc. + + This file is part of GDB. + + 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. + + 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. + + 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. */ + +#include "defs.h" +#include "inferior.h" +#include "regcache.h" +#include "target.h" + +#include <sys/types.h> +#include <sys/ptrace.h> +#include <machine/reg.h> + +#include "mips-tdep.h" +#include "inf-ptrace.h" + +/* Shorthand for some register numbers used below. */ +#define MIPS_PC_REGNUM MIPS_EMBED_PC_REGNUM +#define MIPS_FP0_REGNUM MIPS_EMBED_FP0_REGNUM +#define MIPS_FSR_REGNUM MIPS_EMBED_FP0_REGNUM + 32 + +/* Supply the general-purpose registers stored in GREGS to REGCACHE. */ + +static void +mips64obsd_supply_gregset (struct regcache *regcache, const void *gregs) +{ + const char *regs = gregs; + int regnum; + + for (regnum = MIPS_ZERO_REGNUM; regnum <= MIPS_PC_REGNUM; regnum++) + regcache_raw_supply (regcache, regnum, regs + regnum * 8); + + for (regnum = MIPS_FP0_REGNUM; regnum <= MIPS_FSR_REGNUM; regnum++) + regcache_raw_supply (regcache, regnum, regs + (regnum + 2) * 8); +} + +/* Collect the general-purpose registers from REGCACHE and store them + in GREGS. */ + +static void +mips64obsd_collect_gregset (const struct regcache *regcache, + void *gregs, int regnum) +{ + char *regs = gregs; + int i; + + for (i = MIPS_ZERO_REGNUM; i <= MIPS_PC_REGNUM; i++) + { + if (regnum == -1 || regnum == i) + regcache_raw_collect (regcache, i, regs + i * 8); + } + + for (i = MIPS_FP0_REGNUM; i <= MIPS_FSR_REGNUM; i++) + { + if (regnum == -1 || regnum == i) + regcache_raw_collect (regcache, i, regs + (i + 2) * 8); + } +} + + +/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this + for all registers. */ + +static void +mips64obsd_fetch_inferior_registers (int regnum) +{ + struct reg regs; + + if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_TYPE_ARG3) ®s, 0) == -1) + perror_with_name ("Couldn't get registers"); + + mips64obsd_supply_gregset (current_regcache, ®s); +} + +/* Store register REGNUM back into the inferior. If REGNUM is -1, do + this for all registers. */ + +static void +mips64obsd_store_inferior_registers (int regnum) +{ + struct reg regs; + + if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_TYPE_ARG3) ®s, 0) == -1) + perror_with_name ("Couldn't get registers"); + + mips64obsd_collect_gregset (current_regcache, ®s, regnum); + + if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), + (PTRACE_TYPE_ARG3) ®s, 0) == -1) + perror_with_name ("Couldn't write registers"); +} + + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_mips64obsd_nat (void); + +void +_initialize_mips64obsd_nat (void) +{ + struct target_ops *t; + + t = inf_ptrace_target (); + t->to_fetch_registers = mips64obsd_fetch_inferior_registers; + t->to_store_registers = mips64obsd_store_inferior_registers; + add_target (t); +} diff --git a/gnu/usr.bin/binutils/gdb/mips64obsd-tdep.c b/gnu/usr.bin/binutils/gdb/mips64obsd-tdep.c new file mode 100644 index 00000000000..9f4b0684f9e --- /dev/null +++ b/gnu/usr.bin/binutils/gdb/mips64obsd-tdep.c @@ -0,0 +1,161 @@ +/* Target-dependent code for OpenBSD/mips64. + + Copyright 2004 Free Software Foundation, Inc. + + This file is part of GDB. + + 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. + + 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. + + 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. */ + +#include "defs.h" +#include "osabi.h" +#include "regcache.h" +#include "regset.h" +#include "trad-frame.h" +#include "tramp-frame.h" + +#include "gdb_assert.h" +#include "gdb_string.h" + +#include "mips-tdep.h" +#include "solib-svr4.h" + +#define MIPS64OBSD_NUM_REGS 73 + +/* Core file support. */ + +/* Supply register REGNUM from the buffer specified by GREGS and LEN + in the general-purpose register set REGSET to register cache + REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ + +static void +mips64obsd_supply_gregset (const struct regset *regset, + struct regcache *regcache, int regnum, + const void *gregs, size_t len) +{ + const char *regs = gregs; + int i; + + for (i = 0; i < MIPS64OBSD_NUM_REGS; i++) + { + if (regnum == i || regnum == -1) + regcache_raw_supply (regcache, i, regs + i * 8); + } +} + +/* OpenBSD/mips64 register set. */ + +static struct regset mips64obsd_gregset = +{ + NULL, + mips64obsd_supply_gregset +}; + +/* Return the appropriate register set for the core section identified + by SECT_NAME and SECT_SIZE. */ + +static const struct regset * +mips64obsd_regset_from_core_section (struct gdbarch *gdbarch, + const char *sect_name, size_t sect_size) +{ + if (strcmp (sect_name, ".reg") == 0 && sect_size >= MIPS64OBSD_NUM_REGS * 8) + return &mips64obsd_gregset; + + return NULL; +} + + +/* Signal trampolines. */ + +static void +mips64obsd_sigframe_init (const struct tramp_frame *self, + struct frame_info *next_frame, + struct trad_frame_cache *cache, + CORE_ADDR func) +{ + struct gdbarch *gdbarch = get_frame_arch (next_frame); + CORE_ADDR sp, sigcontext_addr, addr; + int regnum; + + /* We find the appropriate instance of `struct sigcontext' at a + fixed offset in the signal frame. */ + sp = frame_unwind_register_signed (next_frame, MIPS_SP_REGNUM + NUM_REGS); + sigcontext_addr = sp + 32; + + /* PC. */ + regnum = mips_regnum (gdbarch)->pc; + trad_frame_set_reg_addr (cache, regnum + NUM_REGS, sigcontext_addr + 16); + + /* GPRs. */ + for (regnum = MIPS_AT_REGNUM, addr = sigcontext_addr + 32; + regnum <= MIPS_RA_REGNUM; regnum++, addr += 8) + trad_frame_set_reg_addr (cache, regnum + NUM_REGS, addr); + + /* HI and LO. */ + regnum = mips_regnum (gdbarch)->lo; + trad_frame_set_reg_addr (cache, regnum + NUM_REGS, sigcontext_addr + 280); + regnum = mips_regnum (gdbarch)->hi; + trad_frame_set_reg_addr (cache, regnum + NUM_REGS, sigcontext_addr + 288); + + /* TODO: Handle the floating-point registers. */ + + trad_frame_set_id (cache, frame_id_build (sp, func)); +} + +static const struct tramp_frame mips64obsd_sigframe = +{ + SIGTRAMP_FRAME, + MIPS_INSN32_SIZE, + { + { 0x67a40020, -1 }, /* daddiu a0,sp,32 */ + { 0x24020067, -1 }, /* li v0,103 */ + { 0x0000000c, -1 }, /* syscall */ + { 0x0000000d, -1 }, /* break */ + { TRAMP_SENTINEL_INSN, -1 } + }, + mips64obsd_sigframe_init +}; + + +static void +mips64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + /* OpenBSD/mips64 only supports the n64 ABI, but the braindamaged + way GDB works, forces us to pretend we can handle them all. */ + + set_gdbarch_regset_from_core_section + (gdbarch, mips64obsd_regset_from_core_section); + + tramp_frame_prepend_unwinder (gdbarch, &mips64obsd_sigframe); + +#if 0 + set_gdbarch_software_single_step (gdbarch, mips_software_single_step); +#endif + + /* OpenBSD/mips64 has SVR4-style shared libraries. */ + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_lp64_fetch_link_map_offsets); +} + + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_mips64obsd_tdep (void); + +void +_initialize_mips64obsd_tdep (void) +{ + gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_OPENBSD_ELF, + mips64obsd_init_abi); +} |