1 /* Target-dependent code for FreeBSD/amd64.
2 Copyright 2003 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #include "arch-utils.h"
28 #include "gdb_string.h"
30 #include "x86-64-tdep.h"
32 /* Support for signal handlers. */
34 /* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
35 routine, return the address of the associated sigcontext structure. */
38 amd64fbsd_sigcontext_addr (struct frame_info
*next_frame
)
42 /* The `struct sigcontext' (which really is an `ucontext_t' on
43 FreeBSD/amd64) lives at a fixed offset in the signal frame. See
44 <machine/sigframe.h>. */
45 sp
= frame_unwind_register_unsigned (next_frame
, X86_64_RSP_REGNUM
);
49 /* FreeBSD 5.1-RELEASE or later. */
51 /* Location of the signal trampoline. */
52 CORE_ADDR amd64fbsd_sigtramp_start
= 0x7fffffffffc0;
53 CORE_ADDR amd64fbsd_sigtramp_end
= 0x7fffffffffe0;
55 /* From <machine/signal.h>. */
56 int amd64fbsd_sc_reg_offset
[X86_64_NUM_GREGS
] =
58 24 + 6 * 8, /* %rax */
59 24 + 7 * 8, /* %rbx */
60 24 + 3 * 8, /* %rcx */
61 24 + 2 * 8, /* %rdx */
62 24 + 1 * 8, /* %rsi */
63 24 + 0 * 8, /* %rdi */
64 24 + 8 * 8, /* %rbp */
65 24 + 21 * 8, /* %rsp */
68 24 + 9 * 8, /* %r10 */
69 24 + 10 * 8, /* %r11 */
70 24 + 11 * 8, /* %r12 */
71 24 + 12 * 8, /* %r13 */
72 24 + 13 * 8, /* %r14 */
73 24 + 14 * 8, /* %r15 */
74 24 + 18 * 8, /* %rip */
75 24 + 20 * 8, /* %eflags */
83 amd64fbsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
85 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
87 /* Obviously FreeBSD is BSD-based. */
88 i386bsd_init_abi (info
, gdbarch
);
90 x86_64_init_abi (info
, gdbarch
);
92 tdep
->sigtramp_start
= amd64fbsd_sigtramp_start
;
93 tdep
->sigtramp_end
= amd64fbsd_sigtramp_end
;
94 tdep
->sigcontext_addr
= amd64fbsd_sigcontext_addr
;
95 tdep
->sc_reg_offset
= amd64fbsd_sc_reg_offset
;
96 tdep
->sc_num_regs
= X86_64_NUM_GREGS
;
100 /* Provide a prototype to silence -Wmissing-prototypes. */
101 void _initialize_amd64fbsd_tdep (void);
104 _initialize_amd64fbsd_tdep (void)
106 gdbarch_register_osabi (bfd_arch_i386
, bfd_mach_x86_64
,
107 GDB_OSABI_FREEBSD_ELF
, amd64fbsd_init_abi
);