1 /* Target-dependent code for NetBSD/amd64.
3 Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "arch-utils.h"
28 #include "gdb_assert.h"
30 #include "amd64-tdep.h"
31 #include "nbsd-tdep.h"
32 #include "solib-svr4.h"
34 /* Support for signal handlers. */
36 /* Return whether THIS_FRAME corresponds to a NetBSD sigtramp
40 amd64nbsd_sigtramp_p (struct frame_info
*this_frame
)
42 CORE_ADDR pc
= get_frame_pc (this_frame
);
45 find_pc_partial_function (pc
, &name
, NULL
, NULL
);
46 return nbsd_pc_in_sigtramp (pc
, name
);
49 /* Assuming THIS_FRAME corresponds to a NetBSD sigtramp routine,
50 return the address of the associated mcontext structure. */
53 amd64nbsd_mcontext_addr (struct frame_info
*this_frame
)
57 /* The register %r15 points at `struct ucontext' upon entry of a
59 addr
= get_frame_register_unsigned (this_frame
, AMD64_R15_REGNUM
);
61 /* The mcontext structure lives as offset 56 in `struct ucontext'. */
65 /* NetBSD 2.0 or later. */
67 /* Mapping between the general-purpose registers in `struct reg'
68 format and GDB's register cache layout. */
70 /* From <machine/reg.h>. */
71 int amd64nbsd_r_reg_offset
[] =
88 11 * 8, /* ... %r15 */
100 amd64nbsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
102 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
104 /* Initialize general-purpose register set details first. */
105 tdep
->gregset_reg_offset
= amd64nbsd_r_reg_offset
;
106 tdep
->gregset_num_regs
= ARRAY_SIZE (amd64nbsd_r_reg_offset
);
107 tdep
->sizeof_gregset
= 26 * 8;
109 amd64_init_abi (info
, gdbarch
);
111 tdep
->jb_pc_offset
= 7 * 8;
113 /* NetBSD has its own convention for signal trampolines. */
114 tdep
->sigtramp_p
= amd64nbsd_sigtramp_p
;
115 tdep
->sigcontext_addr
= amd64nbsd_mcontext_addr
;
116 tdep
->sc_reg_offset
= amd64nbsd_r_reg_offset
;
117 tdep
->sc_num_regs
= ARRAY_SIZE (amd64nbsd_r_reg_offset
);
119 /* NetBSD uses SVR4-style shared libraries. */
120 set_solib_svr4_fetch_link_map_offsets
121 (gdbarch
, svr4_lp64_fetch_link_map_offsets
);
125 /* Provide a prototype to silence -Wmissing-prototypes. */
126 void _initialize_amd64nbsd_tdep (void);
129 _initialize_amd64nbsd_tdep (void)
131 /* The NetBSD/amd64 native dependent code makes this assumption. */
132 gdb_assert (ARRAY_SIZE (amd64nbsd_r_reg_offset
) == AMD64_NUM_GREGS
);
134 gdbarch_register_osabi (bfd_arch_i386
, bfd_mach_x86_64
,
135 GDB_OSABI_NETBSD_ELF
, amd64nbsd_init_abi
);