X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fm68kbsd-tdep.c;h=ae0cecf2d8993492d3e64e17da9bad4a6e2a081e;hb=73e7610887dfd4313b66f33436bc18570d58b2ac;hp=01208e509ac29adf893b7faeeeee7492f25269fe;hpb=9418f048b53e5afb8fa000bbb410e92c7eacd084;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/m68kbsd-tdep.c b/gdb/m68kbsd-tdep.c index 01208e509a..ae0cecf2d8 100644 --- a/gdb/m68kbsd-tdep.c +++ b/gdb/m68kbsd-tdep.c @@ -1,12 +1,12 @@ /* Target-dependent code for Motorola 68000 BSD's. - Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2004-2015 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,9 +15,7 @@ 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ #include "defs.h" #include "arch-utils.h" @@ -27,9 +25,7 @@ #include "regset.h" #include "trad-frame.h" #include "tramp-frame.h" - -#include "gdb_assert.h" -#include "gdb_string.h" +#include "gdbtypes.h" #include "m68k-tdep.h" #include "solib-svr4.h" @@ -43,12 +39,14 @@ #define M68KBSD_SIZEOF_FPREGS (((8 * 3) + 3) * 4) int -m68kbsd_fpreg_offset (int regnum) +m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum) { + int fp_len = TYPE_LENGTH (gdbarch_register_type (gdbarch, regnum)); + if (regnum >= M68K_FPC_REGNUM) - return 8 * 12 + (regnum - M68K_FPC_REGNUM) * 4; + return 8 * fp_len + (regnum - M68K_FPC_REGNUM) * 4; - return (regnum - M68K_FP0_REGNUM) * 12; + return (regnum - M68K_FP0_REGNUM) * fp_len; } /* Supply register REGNUM from the buffer specified by FPREGS and LEN @@ -60,6 +58,7 @@ m68kbsd_supply_fpregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); const gdb_byte *regs = fpregs; int i; @@ -68,7 +67,8 @@ m68kbsd_supply_fpregset (const struct regset *regset, for (i = M68K_FP0_REGNUM; i <= M68K_PC_REGNUM; i++) { if (regnum == i || regnum == -1) - regcache_raw_supply (regcache, i, regs + m68kbsd_fpreg_offset (i)); + regcache_raw_supply (regcache, i, + regs + m68kbsd_fpreg_offset (gdbarch, i)); } } @@ -102,32 +102,30 @@ m68kbsd_supply_gregset (const struct regset *regset, /* Motorola 68000 register sets. */ -static struct regset m68kbsd_gregset = +static const struct regset m68kbsd_gregset = { NULL, - m68kbsd_supply_gregset + m68kbsd_supply_gregset, + NULL, + REGSET_VARIABLE_SIZE }; -static struct regset m68kbsd_fpregset = +static const struct regset m68kbsd_fpregset = { NULL, m68kbsd_supply_fpregset }; -/* Return the appropriate register set for the core section identified - by SECT_NAME and SECT_SIZE. */ +/* Iterate over core file register note sections. */ -static const struct regset * -m68kbsd_regset_from_core_section (struct gdbarch *gdbarch, - const char *sect_name, size_t sect_size) +static void +m68kbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, + iterate_over_regset_sections_cb *cb, + void *cb_data, + const struct regcache *regcache) { - if (strcmp (sect_name, ".reg") == 0 && sect_size >= M68KBSD_SIZEOF_GREGS) - return &m68kbsd_gregset; - - if (strcmp (sect_name, ".reg2") == 0 && sect_size >= M68KBSD_SIZEOF_FPREGS) - return &m68kbsd_fpregset; - - return NULL; + cb (".reg", M68KBSD_SIZEOF_GREGS, &m68kbsd_gregset, NULL, cb_data); + cb (".reg2", M68KBSD_SIZEOF_FPREGS, &m68kbsd_fpregset, NULL, cb_data); } @@ -135,24 +133,24 @@ m68kbsd_regset_from_core_section (struct gdbarch *gdbarch, static void m68kobsd_sigtramp_cache_init (const struct tramp_frame *self, - struct frame_info *next_frame, + struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func) { CORE_ADDR addr, base, pc; int regnum; - base = frame_unwind_register_unsigned (next_frame, M68K_SP_REGNUM); + base = get_frame_register_unsigned (this_frame, M68K_SP_REGNUM); /* The 'addql #4,%sp' instruction at offset 8 adjusts the stack pointer. Adjust the frame base accordingly. */ - pc = frame_unwind_register_unsigned (next_frame, M68K_PC_REGNUM); + pc = get_frame_register_unsigned (this_frame, M68K_PC_REGNUM); if ((pc - func) > 8) base -= 4; /* Get frame pointer, stack pointer, program counter and processor state from `struct sigcontext'. */ - addr = get_frame_memory_unsigned (next_frame, base + 8, 4); + addr = get_frame_memory_unsigned (this_frame, base + 8, 4); trad_frame_set_reg_addr (this_cache, M68K_FP_REGNUM, addr + 8); trad_frame_set_reg_addr (this_cache, M68K_SP_REGNUM, addr + 12); trad_frame_set_reg_addr (this_cache, M68K_PC_REGNUM, addr + 20); @@ -160,7 +158,7 @@ m68kobsd_sigtramp_cache_init (const struct tramp_frame *self, /* The sc_ap member of `struct sigcontext' points to additional hardware state. Here we find the missing registers. */ - addr = get_frame_memory_unsigned (next_frame, addr + 16, 4) + 4; + addr = get_frame_memory_unsigned (this_frame, addr + 16, 4) + 4; for (regnum = M68K_D0_REGNUM; regnum < M68K_FP_REGNUM; regnum++, addr += 4) trad_frame_set_reg_addr (this_cache, regnum, addr); @@ -195,8 +193,8 @@ m68kbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_decr_pc_after_break (gdbarch, 2); - set_gdbarch_regset_from_core_section - (gdbarch, m68kbsd_regset_from_core_section); + set_gdbarch_iterate_over_regset_sections + (gdbarch, m68kbsd_iterate_over_regset_sections); } /* OpenBSD and NetBSD a.out. */