GDB (xrefs)
/tmp/gdb-7.10/gdb/i386bsd-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for i386 BSD's.
2 
3  Copyright (C) 2001-2015 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>. */
19 
20 #include "defs.h"
21 #include "arch-utils.h"
22 #include "frame.h"
23 #include "gdbcore.h"
24 #include "regcache.h"
25 #include "osabi.h"
26 
27 #include "i386-tdep.h"
28 
29 /* Support for signal handlers. */
30 
31 /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
32  address of the associated sigcontext structure. */
33 
34 static CORE_ADDR
35 i386bsd_sigcontext_addr (struct frame_info *this_frame)
36 {
37  struct gdbarch *gdbarch = get_frame_arch (this_frame);
38  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
39  gdb_byte buf[4];
40  CORE_ADDR sp;
41 
42  get_frame_register (this_frame, I386_ESP_REGNUM, buf);
43  sp = extract_unsigned_integer (buf, 4, byte_order);
44 
45  return read_memory_unsigned_integer (sp + 8, 4, byte_order);
46 }
47 
48 
49 /* Support for shared libraries. */
50 
51 /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
52 
53 /* From <machine/signal.h>. */
55 {
56  -1, /* %eax */
57  -1, /* %ecx */
58  -1, /* %edx */
59  -1, /* %ebx */
60  8 + 0 * 4, /* %esp */
61  8 + 1 * 4, /* %ebp */
62  -1, /* %esi */
63  -1, /* %edi */
64  8 + 3 * 4, /* %eip */
65  8 + 4 * 4, /* %eflags */
66  -1, /* %cs */
67  -1, /* %ss */
68  -1, /* %ds */
69  -1, /* %es */
70  -1, /* %fs */
71  -1 /* %gs */
72 };
73 
74 void
76 {
77  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
78 
79  tdep->jb_pc_offset = 0;
80 
81  tdep->sigtramp_start = 0xfdbfdfc0;
82  tdep->sigtramp_end = 0xfdbfe000;
85  tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset);
86 }
87 
88 
89 static enum gdb_osabi
91 {
92  if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0)
93  return GDB_OSABI_NETBSD_AOUT;
94 
95  if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0)
97 
98  return GDB_OSABI_UNKNOWN;
99 }
100 
101 static enum gdb_osabi
103 {
104  if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
105  return GDB_OSABI_NETBSD_AOUT;
106 
107  return GDB_OSABI_UNKNOWN;
108 }
109 
110 
111 /* Provide a prototype to silence -Wmissing-prototypes. */
112 void _initialize_i386bsd_tdep (void);
113 
114 void
116 {
117  gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
119 
120  /* BFD doesn't set a flavour for NetBSD style a.out core files. */
121  gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_unknown_flavour,
123 }
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
Definition: findvar.c:84
int jb_pc_offset
Definition: i386-tdep.h:199
static CORE_ADDR i386bsd_sigcontext_addr(struct frame_info *this_frame)
Definition: i386bsd-tdep.c:35
void i386bsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: i386bsd-tdep.c:75
bfd_vma CORE_ADDR
Definition: common-types.h:41
int sc_num_regs
Definition: i386-tdep.h:216
CORE_ADDR sigtramp_start
Definition: i386-tdep.h:205
CORE_ADDR sigtramp_end
Definition: i386-tdep.h:206
void gdbarch_register_osabi_sniffer(enum bfd_architecture arch, enum bfd_flavour flavour, enum gdb_osabi(*sniffer_fn)(bfd *))
Definition: osabi.c:225
CORE_ADDR(* sigcontext_addr)(struct frame_info *)
Definition: alpha-tdep.h:82
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1402
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1420
void _initialize_i386bsd_tdep(void)
Definition: i386bsd-tdep.c:115
int i386bsd_sc_reg_offset[]
Definition: i386bsd-tdep.c:54
static enum gdb_osabi i386bsd_aout_osabi_sniffer(bfd *abfd)
Definition: i386bsd-tdep.c:90
bfd_byte gdb_byte
Definition: common-types.h:38
static enum gdb_osabi i386bsd_core_osabi_sniffer(bfd *abfd)
Definition: i386bsd-tdep.c:102
void get_frame_register(struct frame_info *frame, int regnum, gdb_byte *buf)
Definition: frame.c:1085
int * sc_reg_offset
Definition: i386-tdep.h:215
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:321
enum bfd_endian byte_order
Definition: gdbarch.c:128
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2535
gdb_osabi
Definition: defs.h:540