From 03b62bbbce3dc5f15131d9e78f77d035cd1cffb3 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 22 Nov 2016 16:14:24 -0500 Subject: Normalize names of some source files Most tdep/nat files are named: --tdep.c --nat.c A few files do not respect this scheme. This patch renames them so that they are consistent with the rest of the files. It builds fine with --enable-targets=all, but that doesn't test the nat files. I can only hope that my grep skill is good enough. gdb/ChangeLog: * Makefile.in (ALL_64_TARGET_OBS, ALL_TARGET_OBS, HFILES_NO_SRCDIR, ALLDEPFILES): Rename files. * alphabsd-nat.c: Rename to ... * alpha-bsd-nat.c: ... this, adjust include. * alphabsd-tdep.c: Rename to ... * alpha-bsd-tdep.c: ... this, adjust include. * alphabsd-tdep.h: Rename to ... * alpha-bsd-tdep.h: ... this, adjust include barrier and comment. * alphafbsd-tdep.c: Rename to ... * alpha-fbsd-tdep.c: ... this. * alphanbsd-tdep.c: Rename to ... * alpha-nbsd-tdep.c: ... this, adjust include. * alphaobsd-tdep.c: Rename to ... * alpha-obsd-tdep.c: ... this, adjust include. * amd64bsd-nat.c: Rename to ... * amd64-bsd-nat.c: ... this, adjust include. * amd64fbsd-nat.c: Rename to ... * amd64-fbsd-nat.c: ... this, adjust include. * amd64fbsd-tdep.c: Rename to ... * amd64-fbsd-tdep.c: ... this, adjust include. * amd64nbsd-nat.c: Rename to ... * amd64-nbsd-nat.c: ... this. * amd64nbsd-tdep.c: Rename to ... * amd64-nbsd-tdep.c: ... this. * amd64obsd-nat.c: Rename to ... * amd64-obsd-nat.c: ... this. * amd64obsd-tdep.c: Rename to ... * amd64-obsd-tdep.c: ... this. * amd64-tdep.h: Update comments. * armbsd-tdep.c: Rename to ... * arm-bsd-tdep.c: ... this. * armnbsd-nat.c: Rename to ... * arm-nbsd-nat.c: ... this. * armnbsd-tdep.c: Rename to ... * arm-nbsd-tdep.c: ... this. * armobsd-tdep.c: Rename to ... * arm-obsd-tdep.c: ... this. * arm-tdep.h: Update comments. * hppabsd-tdep.c: Rename to ... * hppa-bsd-tdep.c: ... this, adjust include. * hppabsd-tdep.h: Rename to ... * hppa-bsd-tdep.h: ... this, adjust include barrier and comment. * hppanbsd-nat.c: Rename to ... * hppa-nbsd-nat.c: ... this. * hppanbsd-tdep.c: Rename to ... * hppa-nbsd-tdep.c: ... this, adjust include. * hppaobsd-nat.c: Rename to ... * hppa-obsd-nat.c: ... this. * hppaobsd-tdep.c: Rename to ... * hppa-obsd-tdep.c: ... this, adjust include. * i386bsd-nat.c: Rename to ... * i386-bsd-nat.c: ... this, adjust include. * i386bsd-nat.h: Rename to ... * i386-bsd-nat.h: ... this, adjust include barrier and comment. * i386bsd-tdep.c: Rename to ... * i386-bsd-tdep.c: ... this. * i386fbsd-nat.c: Rename to ... * i386-fbsd-nat.c: ... this, adjust include. * i386fbsd-tdep.c: Rename to ... * i386-fbsd-tdep.c: ... this, adjust include. * i386fbsd-tdep.h: Rename to ... * i386-fbsd-tdep.h: ... this, adjust include barrier and comment. * i386gnu-nat.c: Rename to ... * i386-gnu-nat.c: ... this. * i386gnu-tdep.c: Rename to ... * i386-gnu-tdep.c: ... this. * i386nbsd-nat.c: Rename to ... * i386-nbsd-nat.c: ... this, adjust include. * i386nbsd-tdep.c: Rename to ... * i386-nbsd-tdep.c: ... this. * i386obsd-nat.c: Rename to ... * i386-obsd-nat.c: ... this, adjust include. * i386obsd-tdep.c: Rename to ... * i386-obsd-tdep.c: ... this. * i386v4-nat.c: Rename to ... * i386-v4-nat.c: ... this. * i386-tdep.h: Update comments. * m68k-tdep.h: Update comments. * m68kbsd-nat.c: Rename to ... * m68k-bsd-nat.c: ... this. * m68kbsd-tdep.c: Rename to ... * m68k-bsd-tdep.c: ... this. * m68klinux-nat.c: Rename to ... * m68k-linux-nat.c: ... this. * m68klinux-tdep.c: Rename to ... * m68k-linux-tdep.c: ... this. * m88kbsd-nat.c: Rename to ... * m88k-bsd-nat.c: ... this. * mipsnbsd-nat.c: Rename to ... * mips-nbsd-nat.c: ... this, adjust include. * mipsnbsd-tdep.c: Rename to ... * mips-nbsd-tdep.c: ... this, adjust include. * mipsnbsd-tdep.h: Rename to ... * mips-nbsd-tdep.h: ... this, adjust include barrier and comment. * mips64obsd-nat.c: Rename to ... * mips64-obsd-nat.c: ... this. * mips64obsd-tdep.c: Rename to ... * mips64-obsd-tdep.c: ... this. * ppcfbsd-nat.c: Rename to ... * ppc-fbsd-nat.c: ... this, adjust include. * ppcfbsd-tdep.c: Rename to ... * ppc-fbsd-tdep.c: ... this, adjust include. * ppcfbsd-tdep.h: Rename to ... * ppc-fbsd-tdep.h: ... this, adjust include barrier and comment. * ppcnbsd-nat.c: Rename to ... * ppc-nbsd-nat.c: ... this, adjust include. * ppcnbsd-tdep.c: Rename to ... * ppc-nbsd-tdep.c: ... this, adjust include. * ppcnbsd-tdep.h: Rename to ... * ppc-nbsd-tdep.h: ... this, adjust include barrier and comment. * ppcobsd-nat.c: Rename to ... * ppc-obsd-nat.c: ... this, adjust include. * ppcobsd-tdep.c: Rename to ... * ppc-obsd-tdep.c: ... this, adjust include. * ppcobsd-tdep.h: Rename to ... * ppc-obsd-tdep.h: ... this, adjust include barrier and comment. * shnbsd-nat.c: Rename to ... * sh-nbsd-nat.c: ... this. * shnbsd-tdep.c: Rename to ... * sh-nbsd-tdep.c: ... this. * sparcnbsd-nat.c: Rename to ... * sparc-nbsd-nat.c: ... this. * sparcnbsd-tdep.c: Rename to ... * sparc-nbsd-tdep.c: ... this. * sparcobsd-tdep.c: Rename to ... * sparc-obsd-tdep.c: ... this. * sparc64fbsd-nat.c: Rename to ... * sparc64-fbsd-nat.c: ... this. * sparc64fbsd-tdep.c: Rename to ... * sparc64-fbsd-tdep.c: ... this. * sparc64nbsd-nat.c: Rename to ... * sparc64-nbsd-nat.c: ... this. * sparc64nbsd-tdep.c: Rename to ... * sparc64-nbsd-tdep.c: ... this. * sparc64obsd-nat.c: Rename to ... * sparc64-obsd-nat.c: ... this. * sparc64obsd-tdep.c: Rename to ... * sparc64-obsd-tdep.c: ... this. * sparc64-tdep.h: Update comments. * vaxbsd-nat.c: Rename to ... * vax-bsd-nat.c: ... this. * vaxnbsd-tdep.c: Rename to ... * vax-nbsd-tdep.c: ... this. * vaxobsd-tdep.c: Rename to ... * vax-obsd-tdep.c: ... this. * x86bsd-nat.h: Rename to ... * x86-bsd-nat.h: ... this, adjust include barrier and comment. * x86bsd-nat.c: Rename to ... * x86-bsd-nat.c: ... this, adjust include. * configure.tgt: Update renamed files. * config/alpha/fbsd.mh: Update renamed files. * config/alpha/nbsd.mh: Update renamed files. * config/arm/nbsdelf.mh: Update renamed files. * config/djgpp/fnchange.lst: Update renamed files. * config/i386/fbsd.mh: Update renamed files. * config/i386/fbsd64.mh: Update renamed files. * config/i386/i386gnu.mh: Update renamed files. * config/i386/i386sol2.mh: Update renamed files. * config/i386/nbsd64.mh: Update renamed files. * config/i386/nbsdelf.mh: Update renamed files. * config/i386/obsd.mh: Update renamed files. * config/i386/obsd64.mh: Update renamed files. * config/i386/sol2-64.mh: Update renamed files. * config/m68k/linux.mh: Update renamed files. * config/m68k/nbsdelf.mh: Update renamed files. * config/m68k/obsd.mh: Update renamed files. * config/m88k/obsd.mh: Update renamed files. * config/mips/nbsd.mh: Update renamed files. * config/mips/obsd64.mh: Update renamed files. * config/pa/nbsd.mh: Update renamed files. * config/pa/obsd.mh: Update renamed files. * config/powerpc/fbsd.mh: Update renamed files. * config/powerpc/nbsd.mh: Update renamed files. * config/powerpc/obsd.mh: Update renamed files. * config/sh/nbsd.mh: Update renamed files. * config/sparc/fbsd.mh: Update renamed files. * config/sparc/nbsd64.mh: Update renamed files. * config/sparc/nbsdelf.mh: Update renamed files. * config/sparc/obsd64.mh: Update renamed files. * config/vax/nbsdelf.mh: Update renamed files. * config/vax/obsd.mh: Update renamed files. --- gdb/m68k-bsd-tdep.c | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 gdb/m68k-bsd-tdep.c (limited to 'gdb/m68k-bsd-tdep.c') diff --git a/gdb/m68k-bsd-tdep.c b/gdb/m68k-bsd-tdep.c new file mode 100644 index 0000000000..0d2a4e9577 --- /dev/null +++ b/gdb/m68k-bsd-tdep.c @@ -0,0 +1,270 @@ +/* Target-dependent code for Motorola 68000 BSD's. + + Copyright (C) 2004-2016 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 3 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, see . */ + +#include "defs.h" +#include "arch-utils.h" +#include "frame.h" +#include "osabi.h" +#include "regcache.h" +#include "regset.h" +#include "trad-frame.h" +#include "tramp-frame.h" +#include "gdbtypes.h" + +#include "m68k-tdep.h" +#include "solib-svr4.h" + +/* Core file support. */ + +/* Sizeof `struct reg' in . */ +#define M68KBSD_SIZEOF_GREGS (18 * 4) + +/* Sizeof `struct fpreg' in = M68K_FPC_REGNUM) + return 8 * fp_len + (regnum - M68K_FPC_REGNUM) * 4; + + return (regnum - M68K_FP0_REGNUM) * fp_len; +} + +/* Supply register REGNUM from the buffer specified by FPREGS and LEN + in the floating-point register set REGSET to register cache + REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ + +static void +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 = (const gdb_byte *) fpregs; + int i; + + gdb_assert (len >= M68KBSD_SIZEOF_FPREGS); + + for (i = M68K_FP0_REGNUM; i <= M68K_PC_REGNUM; i++) + { + if (regnum == i || regnum == -1) + regcache_raw_supply (regcache, i, + regs + m68kbsd_fpreg_offset (gdbarch, i)); + } +} + +/* 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 +m68kbsd_supply_gregset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *gregs, size_t len) +{ + const gdb_byte *regs = (const gdb_byte *) gregs; + int i; + + gdb_assert (len >= M68KBSD_SIZEOF_GREGS); + + for (i = M68K_D0_REGNUM; i <= M68K_PC_REGNUM; i++) + { + if (regnum == i || regnum == -1) + regcache_raw_supply (regcache, i, regs + i * 4); + } + + if (len >= M68KBSD_SIZEOF_GREGS + M68KBSD_SIZEOF_FPREGS) + { + regs += M68KBSD_SIZEOF_GREGS; + len -= M68KBSD_SIZEOF_GREGS; + m68kbsd_supply_fpregset (regset, regcache, regnum, regs, len); + } +} + +/* Motorola 68000 register sets. */ + +static const struct regset m68kbsd_gregset = +{ + NULL, + m68kbsd_supply_gregset, + NULL, + REGSET_VARIABLE_SIZE +}; + +static const struct regset m68kbsd_fpregset = +{ + NULL, + m68kbsd_supply_fpregset +}; + +/* Iterate over core file register note sections. */ + +static void +m68kbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, + iterate_over_regset_sections_cb *cb, + void *cb_data, + const struct regcache *regcache) +{ + cb (".reg", M68KBSD_SIZEOF_GREGS, &m68kbsd_gregset, NULL, cb_data); + cb (".reg2", M68KBSD_SIZEOF_FPREGS, &m68kbsd_fpregset, NULL, cb_data); +} + + +/* Signal trampolines. */ + +static void +m68kobsd_sigtramp_cache_init (const struct tramp_frame *self, + struct frame_info *this_frame, + struct trad_frame_cache *this_cache, + CORE_ADDR func) +{ + CORE_ADDR addr, base, pc; + int 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 = 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 (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); + trad_frame_set_reg_addr (this_cache, M68K_PS_REGNUM, addr + 24); + + /* The sc_ap member of `struct sigcontext' points to additional + hardware state. Here we find the missing registers. */ + 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); + + /* Construct the frame ID using the function start. */ + trad_frame_set_id (this_cache, frame_id_build (base, func)); +} + +static const struct tramp_frame m68kobsd_sigtramp = { + SIGTRAMP_FRAME, + 2, + { + { 0x206f, -1 }, { 0x000c, -1}, /* moveal %sp@(12),%a0 */ + { 0x4e90, -1 }, /* jsr %a0@ */ + { 0x588f, -1 }, /* addql #4,%sp */ + { 0x4e41, -1 }, /* trap #1 */ + { 0x2f40, -1 }, { 0x0004, -1 }, /* moveal %d0,%sp@(4) */ + { 0x7001, -1 }, /* moveq #SYS_exit,%d0 */ + { 0x4e40, -1 }, /* trap #0 */ + { TRAMP_SENTINEL_INSN, -1 } + }, + m68kobsd_sigtramp_cache_init +}; + + +static void +m68kbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + tdep->jb_pc = 5; + tdep->jb_elt_size = 4; + + set_gdbarch_decr_pc_after_break (gdbarch, 2); + + set_gdbarch_iterate_over_regset_sections + (gdbarch, m68kbsd_iterate_over_regset_sections); +} + +/* OpenBSD and NetBSD a.out. */ + +static void +m68kbsd_aout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + m68kbsd_init_abi (info, gdbarch); + + tdep->struct_return = reg_struct_return; + + tramp_frame_prepend_unwinder (gdbarch, &m68kobsd_sigtramp); +} + +/* NetBSD ELF. */ + +static void +m68kbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + m68kbsd_init_abi (info, gdbarch); + + /* NetBSD ELF uses the SVR4 ABI. */ + m68k_svr4_init_abi (info, gdbarch); + tdep->struct_return = pcc_struct_return; + + /* NetBSD ELF uses SVR4-style shared libraries. */ + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_ilp32_fetch_link_map_offsets); +} + + +static enum gdb_osabi +m68kbsd_aout_osabi_sniffer (bfd *abfd) +{ + if (strcmp (bfd_get_target (abfd), "a.out-m68k-netbsd") == 0 + || strcmp (bfd_get_target (abfd), "a.out-m68k4k-netbsd") == 0) + return GDB_OSABI_NETBSD_AOUT; + + return GDB_OSABI_UNKNOWN; +} + +static enum gdb_osabi +m68kbsd_core_osabi_sniffer (bfd *abfd) +{ + if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) + return GDB_OSABI_NETBSD_AOUT; + + return GDB_OSABI_UNKNOWN; +} + + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_m68kbsd_tdep (void); + +void +_initialize_m68kbsd_tdep (void) +{ + gdbarch_register_osabi_sniffer (bfd_arch_m68k, bfd_target_aout_flavour, + m68kbsd_aout_osabi_sniffer); + + /* BFD doesn't set a flavour for NetBSD style a.out core files. */ + gdbarch_register_osabi_sniffer (bfd_arch_m68k, bfd_target_unknown_flavour, + m68kbsd_core_osabi_sniffer); + + gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_NETBSD_AOUT, + m68kbsd_aout_init_abi); + gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_NETBSD_ELF, + m68kbsd_elf_init_abi); +} -- cgit v1.2.3