1 /* Target-dependent code for FreeBSD/amd64.
3 Copyright 2003, 2004 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 2 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, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "arch-utils.h"
29 #include "gdb_string.h"
31 #include "x86-64-tdep.h"
32 #include "solib-svr4.h"
34 /* Support for signal handlers. */
36 /* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
37 routine, return the address of the associated sigcontext structure. */
40 amd64fbsd_sigcontext_addr (struct frame_info *next_frame)
44 /* The `struct sigcontext' (which really is an `ucontext_t' on
45 FreeBSD/amd64) lives at a fixed offset in the signal frame. See
46 <machine/sigframe.h>. */
47 sp = frame_unwind_register_unsigned (next_frame, X86_64_RSP_REGNUM);
51 /* FreeBSD 5.1-RELEASE or later. */
53 /* Mapping between the general-purpose registers in `struct reg'
54 format and GDB's register cache layout.
56 Note that some registers are 32-bit, but since we're little-endian
57 we get away with that. */
59 /* From <machine/reg.h>. */
60 static int amd64fbsd_r_reg_offset[] =
88 /* Location of the signal trampoline. */
89 CORE_ADDR amd64fbsd_sigtramp_start_addr = 0x7fffffffffc0;
90 CORE_ADDR amd64fbsd_sigtramp_end_addr = 0x7fffffffffe0;
92 /* From <machine/signal.h>. */
93 int amd64fbsd_sc_reg_offset[] =
95 24 + 6 * 8, /* %rax */
96 24 + 7 * 8, /* %rbx */
97 24 + 3 * 8, /* %rcx */
98 24 + 2 * 8, /* %rdx */
99 24 + 1 * 8, /* %rsi */
100 24 + 0 * 8, /* %rdi */
101 24 + 8 * 8, /* %rbp */
102 24 + 22 * 8, /* %rsp */
103 24 + 4 * 8, /* %r8 ... */
110 24 + 14 * 8, /* ... %r15 */
111 24 + 19 * 8, /* %rip */
112 24 + 21 * 8, /* %eflags */
113 24 + 20 * 8, /* %cs */
114 24 + 23 * 8, /* %ss */
122 amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
124 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
126 /* Obviously FreeBSD is BSD-based. */
127 i386bsd_init_abi (info, gdbarch);
129 tdep->gregset_reg_offset = amd64fbsd_r_reg_offset;
130 tdep->gregset_num_regs = ARRAY_SIZE (amd64fbsd_r_reg_offset);
131 tdep->sizeof_gregset = 22 * 8;
133 x86_64_init_abi (info, gdbarch);
135 tdep->sigtramp_start = amd64fbsd_sigtramp_start_addr;
136 tdep->sigtramp_end = amd64fbsd_sigtramp_end_addr;
137 tdep->sigcontext_addr = amd64fbsd_sigcontext_addr;
138 tdep->sc_reg_offset = amd64fbsd_sc_reg_offset;
139 tdep->sc_num_regs = ARRAY_SIZE (amd64fbsd_sc_reg_offset);
141 /* FreeBSD uses SVR4-style shared libraries. */
142 set_solib_svr4_fetch_link_map_offsets
143 (gdbarch, svr4_lp64_fetch_link_map_offsets);
147 /* Provide a prototype to silence -Wmissing-prototypes. */
148 void _initialize_amd64fbsd_tdep (void);
151 _initialize_amd64fbsd_tdep (void)
153 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
154 GDB_OSABI_FREEBSD_ELF, amd64fbsd_init_abi);