* inf-ptrace.c (inf_ptrace_kill_inferior): Call ptrace directly
[deliverable/binutils-gdb.git] / gdb / i386bsd-tdep.c
CommitLineData
b7247919 1/* Target-dependent code for i386 BSD's.
8a96bc77 2
5d93ae8c 3 Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
b7247919
MK
4
5 This file is part of GDB.
6
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.
11
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.
16
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. */
21
22#include "defs.h"
9c5045b5 23#include "arch-utils.h"
b7247919
MK
24#include "frame.h"
25#include "gdbcore.h"
26#include "regcache.h"
4be87837 27#include "osabi.h"
b7247919 28
ca39387d
MK
29#include "gdb_string.h"
30
8201327c 31#include "i386-tdep.h"
b7247919 32
8201327c 33/* Support for signal handlers. */
b7247919 34
acd5c798
MK
35/* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
36 routine, return the address of the associated sigcontext structure. */
b7247919 37
acd5c798
MK
38static CORE_ADDR
39i386bsd_sigcontext_addr (struct frame_info *next_frame)
b7247919 40{
acd5c798
MK
41 char buf[4];
42 CORE_ADDR sp;
b4700d91 43
c7f16359 44 frame_unwind_register (next_frame, I386_ESP_REGNUM, buf);
acd5c798 45 sp = extract_unsigned_integer (buf, 4);
b7247919 46
acd5c798 47 return read_memory_unsigned_integer (sp + 8, 4);
b7247919 48}
8201327c
MK
49\f
50
9c5045b5
MK
51/* Support for shared libraries. */
52
53/* Return non-zero if we are in a shared library trampoline code stub. */
54
55int
56i386bsd_aout_in_solib_call_trampoline (CORE_ADDR pc, char *name)
57{
58 return (name && !strcmp (name, "_DYNAMIC"));
59}
60
8201327c
MK
61/* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
62
63/* From <machine/signal.h>. */
155c1d33 64int i386bsd_sc_reg_offset[] =
a3386186
MK
65{
66 -1, /* %eax */
67 -1, /* %ecx */
68 -1, /* %edx */
69 -1, /* %ebx */
70 8 + 0 * 4, /* %esp */
71 8 + 1 * 4, /* %ebp */
72 -1, /* %esi */
73 -1, /* %edi */
74 8 + 3 * 4, /* %eip */
75 8 + 4 * 4, /* %eflags */
76 -1, /* %cs */
77 -1, /* %ss */
78 -1, /* %ds */
79 -1, /* %es */
80 -1, /* %fs */
81 -1 /* %gs */
82};
8201327c 83
3cac699e 84void
8201327c
MK
85i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
86{
87 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
88
9c5045b5
MK
89 /* Assume SunOS-style shared libraries. */
90 set_gdbarch_in_solib_call_trampoline (gdbarch,
91 i386bsd_aout_in_solib_call_trampoline);
92
8201327c
MK
93 tdep->jb_pc_offset = 0;
94
8201327c
MK
95 tdep->sigtramp_start = 0xfdbfdfc0;
96 tdep->sigtramp_end = 0xfdbfe000;
21d0e8a4 97 tdep->sigcontext_addr = i386bsd_sigcontext_addr;
a3386186 98 tdep->sc_reg_offset = i386bsd_sc_reg_offset;
155c1d33 99 tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset);
8201327c
MK
100}
101
8201327c
MK
102\f
103static enum gdb_osabi
104i386bsd_aout_osabi_sniffer (bfd *abfd)
105{
106 if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0)
107 return GDB_OSABI_NETBSD_AOUT;
108
109 if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0)
110 return GDB_OSABI_FREEBSD_AOUT;
111
112 return GDB_OSABI_UNKNOWN;
113}
114
f6943e4a
MK
115static enum gdb_osabi
116i386bsd_core_osabi_sniffer (bfd *abfd)
117{
118 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
119 return GDB_OSABI_NETBSD_AOUT;
120
121 return GDB_OSABI_UNKNOWN;
122}
123
8201327c
MK
124\f
125/* Provide a prototype to silence -Wmissing-prototypes. */
126void _initialize_i386bsd_tdep (void);
127
128void
129_initialize_i386bsd_tdep (void)
130{
131 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
132 i386bsd_aout_osabi_sniffer);
f6943e4a 133
8b0c3633
MK
134 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
135 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_unknown_flavour,
f6943e4a 136 i386bsd_core_osabi_sniffer);
8201327c 137}
This page took 0.314042 seconds and 4 git commands to generate.