1 /* Target-dependent code for NetBSD/amd64.
3 Copyright (C) 2003-2018 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "arch-utils.h"
27 #include "amd64-tdep.h"
28 #include "x86-xstate.h"
29 #include "nbsd-tdep.h"
30 #include "solib-svr4.h"
32 /* Support for signal handlers. */
34 /* Return whether THIS_FRAME corresponds to a NetBSD sigtramp
38 amd64nbsd_sigtramp_p (struct frame_info *this_frame)
40 CORE_ADDR pc = get_frame_pc (this_frame);
43 find_pc_partial_function (pc, &name, NULL, NULL);
44 return nbsd_pc_in_sigtramp (pc, name);
47 /* Assuming THIS_FRAME corresponds to a NetBSD sigtramp routine,
48 return the address of the associated mcontext structure. */
51 amd64nbsd_mcontext_addr (struct frame_info *this_frame)
55 /* The register %r15 points at `struct ucontext' upon entry of a
57 addr = get_frame_register_unsigned (this_frame, AMD64_R15_REGNUM);
59 /* The mcontext structure lives as offset 56 in `struct ucontext'. */
63 /* NetBSD 2.0 or later. */
65 /* Mapping between the general-purpose registers in `struct reg'
66 format and GDB's register cache layout. */
68 /* From <machine/reg.h>. */
69 int amd64nbsd_r_reg_offset[] =
86 11 * 8, /* ... %r15 */
98 amd64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
100 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
102 /* Initialize general-purpose register set details first. */
103 tdep->gregset_reg_offset = amd64nbsd_r_reg_offset;
104 tdep->gregset_num_regs = ARRAY_SIZE (amd64nbsd_r_reg_offset);
105 tdep->sizeof_gregset = 26 * 8;
107 amd64_init_abi (info, gdbarch,
108 amd64_target_description (X86_XSTATE_SSE_MASK, true));
110 tdep->jb_pc_offset = 7 * 8;
112 /* NetBSD has its own convention for signal trampolines. */
113 tdep->sigtramp_p = amd64nbsd_sigtramp_p;
114 tdep->sigcontext_addr = amd64nbsd_mcontext_addr;
115 tdep->sc_reg_offset = amd64nbsd_r_reg_offset;
116 tdep->sc_num_regs = ARRAY_SIZE (amd64nbsd_r_reg_offset);
118 /* NetBSD uses SVR4-style shared libraries. */
119 set_solib_svr4_fetch_link_map_offsets
120 (gdbarch, svr4_lp64_fetch_link_map_offsets);
124 _initialize_amd64nbsd_tdep (void)
126 /* The NetBSD/amd64 native dependent code makes this assumption. */
127 gdb_assert (ARRAY_SIZE (amd64nbsd_r_reg_offset) == AMD64_NUM_GREGS);
129 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
130 GDB_OSABI_NETBSD, amd64nbsd_init_abi);