]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/i386-sol2-tdep.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / i386-sol2-tdep.c
CommitLineData
8201327c 1/* Target-dependent code for Solaris x86.
911bc6ee 2
6aba47ca 3 Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
8201327c
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
197e01b6
EZ
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
8201327c
MK
21
22#include "defs.h"
52e9098c 23#include "value.h"
4be87837 24#include "osabi.h"
8201327c 25
d9f8c85b
MK
26#include "gdb_string.h"
27
081bf9da 28#include "sol2-tdep.h"
8201327c 29#include "i386-tdep.h"
75f501b5 30#include "solib-svr4.h"
8201327c 31
6a9756ed
MK
32/* From <ia32/sys/reg.h>. */
33static int i386_sol2_gregset_reg_offset[] =
34{
35 11 * 4, /* %eax */
36 10 * 4, /* %ecx */
37 9 * 4, /* %edx */
38 8 * 4, /* %ebx */
39 17 * 4, /* %esp */
40 6 * 4, /* %ebp */
41 5 * 4, /* %esi */
42 4 * 4, /* %edi */
43 14 * 4, /* %eip */
44 16 * 4, /* %eflags */
45 15 * 4, /* %cs */
46 18 * 4, /* %ss */
47 3 * 4, /* %ds */
48 2 * 4, /* %es */
49 1 * 4, /* %fs */
50 0 * 4 /* %gs */
51};
52
d9f8c85b
MK
53/* Return whether the frame preceding NEXT_FRAME corresponds to a
54 Solaris sigtramp routine. */
55
8201327c 56static int
911bc6ee 57i386_sol2_sigtramp_p (struct frame_info *next_frame)
8201327c 58{
911bc6ee 59 CORE_ADDR pc = frame_pc_unwind (next_frame);
d9f8c85b 60 char *name;
911bc6ee 61
d9f8c85b
MK
62 find_pc_partial_function (pc, &name, NULL, NULL);
63 return (name && (strcmp ("sigacthandler", name) == 0
64 || strcmp (name, "ucbsigvechandler") == 0));
8201327c
MK
65}
66
8349554d
MK
67/* Solaris doesn't have a `struct sigcontext', but it does have a
68 `mcontext_t' that contains the saved set of machine registers. */
69
70static CORE_ADDR
71i386_sol2_mcontext_addr (struct frame_info *next_frame)
72{
73 CORE_ADDR sp, ucontext_addr;
74
75 sp = frame_unwind_register_unsigned (next_frame, I386_ESP_REGNUM);
76 ucontext_addr = get_frame_memory_unsigned (next_frame, sp + 8, 4);
77
78 return ucontext_addr + 36;
79}
80
8201327c
MK
81/* Solaris 2. */
82
83static void
84i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
85{
86 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
87
88 /* Solaris is SVR4-based. */
89 i386_svr4_init_abi (info, gdbarch);
90
6a9756ed
MK
91 /* Solaris reserves space for its FPU emulator in `fpregset_t'.
92 There is also some space reserved for the registers of a Weitek
93 math coprocessor. */
94 tdep->gregset_reg_offset = i386_sol2_gregset_reg_offset;
95 tdep->gregset_num_regs = ARRAY_SIZE (i386_sol2_gregset_reg_offset);
96 tdep->sizeof_gregset = 19 * 4;
97 tdep->sizeof_fpregset = 380;
98
911bc6ee
MK
99 /* Signal trampolines are slightly different from SVR4. */
100 tdep->sigtramp_p = i386_sol2_sigtramp_p;
8349554d
MK
101 tdep->sigcontext_addr = i386_sol2_mcontext_addr;
102 tdep->sc_reg_offset = tdep->gregset_reg_offset;
103 tdep->sc_num_regs = tdep->gregset_num_regs;
75f501b5 104
081bf9da
MK
105 /* Solaris has SVR4-style shared libraries. */
106 set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
75f501b5
MK
107 set_solib_svr4_fetch_link_map_offsets
108 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
8201327c
MK
109}
110\f
111
6e157172
MK
112static enum gdb_osabi
113i386_sol2_osabi_sniffer (bfd *abfd)
114{
115 /* If we have a section named .SUNW_version, then it is almost
116 certainly Solaris 2. */
117 if (bfd_get_section_by_name (abfd, ".SUNW_version"))
118 return GDB_OSABI_SOLARIS;
119
120 return GDB_OSABI_UNKNOWN;
121}
122
8201327c
MK
123/* Provide a prototype to silence -Wmissing-prototypes. */
124void _initialize_i386_sol2_tdep (void);
125
126void
127_initialize_i386_sol2_tdep (void)
128{
0c52bd59 129 /* Register an ELF OS ABI sniffer for Solaris 2 binaries. */
6e157172
MK
130 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
131 i386_sol2_osabi_sniffer);
132
05816f70 133 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS,
8201327c
MK
134 i386_sol2_init_abi);
135}