Update copyright year in most headers.
[deliverable/binutils-gdb.git] / gdb / i386bsd-tdep.c
CommitLineData
b7247919 1/* Target-dependent code for i386 BSD's.
8a96bc77 2
4c38e0a4 3 Copyright (C) 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010
9b254dd1 4 Free Software Foundation, Inc.
b7247919
MK
5
6 This file is part of GDB.
7
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
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
b7247919
MK
11 (at your option) any later version.
12
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.
17
18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
b7247919
MK
20
21#include "defs.h"
9c5045b5 22#include "arch-utils.h"
b7247919
MK
23#include "frame.h"
24#include "gdbcore.h"
25#include "regcache.h"
4be87837 26#include "osabi.h"
b7247919 27
ca39387d
MK
28#include "gdb_string.h"
29
8201327c 30#include "i386-tdep.h"
b7247919 31
8201327c 32/* Support for signal handlers. */
b7247919 33
10458914
DJ
34/* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
35 address of the associated sigcontext structure. */
b7247919 36
acd5c798 37static CORE_ADDR
10458914 38i386bsd_sigcontext_addr (struct frame_info *this_frame)
b7247919 39{
e17a4113
UW
40 struct gdbarch *gdbarch = get_frame_arch (this_frame);
41 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
63c0089f 42 gdb_byte buf[4];
acd5c798 43 CORE_ADDR sp;
b4700d91 44
10458914 45 get_frame_register (this_frame, I386_ESP_REGNUM, buf);
e17a4113 46 sp = extract_unsigned_integer (buf, 4, byte_order);
b7247919 47
e17a4113 48 return read_memory_unsigned_integer (sp + 8, 4, byte_order);
b7247919 49}
8201327c
MK
50\f
51
9c5045b5
MK
52/* Support for shared libraries. */
53
8201327c
MK
54/* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
55
56/* From <machine/signal.h>. */
155c1d33 57int i386bsd_sc_reg_offset[] =
a3386186
MK
58{
59 -1, /* %eax */
60 -1, /* %ecx */
61 -1, /* %edx */
62 -1, /* %ebx */
63 8 + 0 * 4, /* %esp */
64 8 + 1 * 4, /* %ebp */
65 -1, /* %esi */
66 -1, /* %edi */
67 8 + 3 * 4, /* %eip */
68 8 + 4 * 4, /* %eflags */
69 -1, /* %cs */
70 -1, /* %ss */
71 -1, /* %ds */
72 -1, /* %es */
73 -1, /* %fs */
74 -1 /* %gs */
75};
8201327c 76
3cac699e 77void
8201327c
MK
78i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
79{
80 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
81
8201327c
MK
82 tdep->jb_pc_offset = 0;
83
8201327c
MK
84 tdep->sigtramp_start = 0xfdbfdfc0;
85 tdep->sigtramp_end = 0xfdbfe000;
21d0e8a4 86 tdep->sigcontext_addr = i386bsd_sigcontext_addr;
a3386186 87 tdep->sc_reg_offset = i386bsd_sc_reg_offset;
155c1d33 88 tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset);
8201327c
MK
89}
90
8201327c
MK
91\f
92static enum gdb_osabi
93i386bsd_aout_osabi_sniffer (bfd *abfd)
94{
95 if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0)
96 return GDB_OSABI_NETBSD_AOUT;
97
98 if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0)
99 return GDB_OSABI_FREEBSD_AOUT;
100
101 return GDB_OSABI_UNKNOWN;
102}
103
f6943e4a
MK
104static enum gdb_osabi
105i386bsd_core_osabi_sniffer (bfd *abfd)
106{
107 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
108 return GDB_OSABI_NETBSD_AOUT;
109
110 return GDB_OSABI_UNKNOWN;
111}
112
8201327c
MK
113\f
114/* Provide a prototype to silence -Wmissing-prototypes. */
115void _initialize_i386bsd_tdep (void);
116
117void
118_initialize_i386bsd_tdep (void)
119{
120 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
121 i386bsd_aout_osabi_sniffer);
f6943e4a 122
8b0c3633
MK
123 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
124 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_unknown_flavour,
f6943e4a 125 i386bsd_core_osabi_sniffer);
8201327c 126}
This page took 0.638167 seconds and 4 git commands to generate.