* configure.host: Add x86_64-*-freebsd*.
[deliverable/binutils-gdb.git] / gdb / amd64fbsd-tdep.c
CommitLineData
68cc0bfb
MK
1/* Target-dependent code for FreeBSD/amd64.
2 Copyright 2003 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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.
15
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. */
20
21#include "defs.h"
22#include "arch-utils.h"
23#include "frame.h"
24#include "gdbcore.h"
25#include "regcache.h"
26#include "osabi.h"
27
28#include "gdb_string.h"
29
30#include "x86-64-tdep.h"
31
32/* Support for signal handlers. */
33
34/* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
35 routine, return the address of the associated sigcontext structure. */
36
37static CORE_ADDR
38amd64fbsd_sigcontext_addr (struct frame_info *next_frame)
39{
40 char buf[8];
41 CORE_ADDR sp;
42
43 frame_unwind_register (next_frame, X86_64_RSP_REGNUM, buf);
44 sp = extract_unsigned_integer (buf, 8);
45
46 return read_memory_unsigned_integer (sp + 16, 8);
47}
48\f
49/* FreeBSD 5.1-RELEASE or later. */
50
51/* Location of the signal trampoline. */
52CORE_ADDR amd64fbsd_sigtramp_start = 0x7fffffffc0;
53CORE_ADDR amd64fbsd_sigtramp_end = 0x7fffffffe0;
54
55/* From <machine/signal.h>. */
56int amd64fbsd_sc_reg_offset[X86_64_NUM_GREGS] =
57{
58 24 + 14 * 8, /* %rax */
59 24 + 11 * 8, /* %rbx */
60 24 + 13 * 8, /* %rcx */
61 24 + 12 * 8, /* %rdx */
62 24 + 9 * 8, /* %rsi */
63 24 + 8 * 8, /* %rdi */
64 24 + 10 * 8, /* %rbp */
65 24 + 20 * 8, /* %rsp */
66 24 + 7 * 8, /* %r8 */
67 24 + 6 * 8, /* %r9 */
68 24 + 5 * 8, /* %r10 */
69 24 + 4 * 8, /* %r11 */
70 24 + 3 * 8, /* %r12 */
71 24 + 2 * 8, /* %r13 */
72 24 + 1 * 8, /* %r14 */
73 24 + 0 * 8, /* %r15 */
74 24 + 17 * 8, /* %rip */
75 24 + 19 * 8, /* %eflags */
76 -1, /* %ds */
77 -1, /* %es */
78 -1, /* %fs */
79 -1 /* %gs */
80};
81
82void
83amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
84{
85 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
86
87 /* Obviously FreeBSD is BSD-based. */
88 i386bsd_init_abi (info, gdbarch);
89
90 x86_64_init_abi (info, gdbarch);
91
92 tdep->sigtramp_start = amd64fbsd_sigtramp_start;
93 tdep->sigtramp_end = amd64fbsd_sigtramp_start;
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;
97}
98\f
99
100/* Provide a prototype to silence -Wmissing-prototypes. */
101void _initialize_amd64fbsd_tdep (void);
102
103void
104_initialize_amd64fbsd_tdep (void)
105{
106 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
107 GDB_OSABI_FREEBSD_ELF, amd64fbsd_init_abi);
108}
This page took 0.028988 seconds and 4 git commands to generate.