* amd64-linux-nat.c (fetch_inferior_registers): Correctly check
[deliverable/binutils-gdb.git] / gdb / i386-sol2-tdep.c
CommitLineData
8201327c 1/* Target-dependent code for Solaris x86.
911bc6ee
MK
2
3 Copyright 2002, 2003, 2004 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
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#include "defs.h"
52e9098c 23#include "value.h"
4be87837 24#include "osabi.h"
8201327c
MK
25
26#include "i386-tdep.h"
27
6a9756ed
MK
28/* From <ia32/sys/reg.h>. */
29static int i386_sol2_gregset_reg_offset[] =
30{
31 11 * 4, /* %eax */
32 10 * 4, /* %ecx */
33 9 * 4, /* %edx */
34 8 * 4, /* %ebx */
35 17 * 4, /* %esp */
36 6 * 4, /* %ebp */
37 5 * 4, /* %esi */
38 4 * 4, /* %edi */
39 14 * 4, /* %eip */
40 16 * 4, /* %eflags */
41 15 * 4, /* %cs */
42 18 * 4, /* %ss */
43 3 * 4, /* %ds */
44 2 * 4, /* %es */
45 1 * 4, /* %fs */
46 0 * 4 /* %gs */
47};
48
8201327c 49static int
911bc6ee 50i386_sol2_sigtramp_p (struct frame_info *next_frame)
8201327c 51{
911bc6ee
MK
52 CORE_ADDR pc = frame_pc_unwind (next_frame);
53
8201327c
MK
54 /* Signal handler frames under Solaris 2 are recognized by a return
55 address of 0xffffffff. */
56 return (pc == 0xffffffff);
57}
58
8349554d
MK
59/* Solaris doesn't have a `struct sigcontext', but it does have a
60 `mcontext_t' that contains the saved set of machine registers. */
61
62static CORE_ADDR
63i386_sol2_mcontext_addr (struct frame_info *next_frame)
64{
65 CORE_ADDR sp, ucontext_addr;
66
67 sp = frame_unwind_register_unsigned (next_frame, I386_ESP_REGNUM);
68 ucontext_addr = get_frame_memory_unsigned (next_frame, sp + 8, 4);
69
70 return ucontext_addr + 36;
71}
72
8201327c
MK
73/* Solaris 2. */
74
75static void
76i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
77{
78 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
79
80 /* Solaris is SVR4-based. */
81 i386_svr4_init_abi (info, gdbarch);
82
6a9756ed
MK
83 /* Solaris reserves space for its FPU emulator in `fpregset_t'.
84 There is also some space reserved for the registers of a Weitek
85 math coprocessor. */
86 tdep->gregset_reg_offset = i386_sol2_gregset_reg_offset;
87 tdep->gregset_num_regs = ARRAY_SIZE (i386_sol2_gregset_reg_offset);
88 tdep->sizeof_gregset = 19 * 4;
89 tdep->sizeof_fpregset = 380;
90
911bc6ee
MK
91 /* Signal trampolines are slightly different from SVR4. */
92 tdep->sigtramp_p = i386_sol2_sigtramp_p;
8349554d
MK
93 tdep->sigcontext_addr = i386_sol2_mcontext_addr;
94 tdep->sc_reg_offset = tdep->gregset_reg_offset;
95 tdep->sc_num_regs = tdep->gregset_num_regs;
8201327c
MK
96}
97\f
98
6e157172
MK
99static enum gdb_osabi
100i386_sol2_osabi_sniffer (bfd *abfd)
101{
102 /* If we have a section named .SUNW_version, then it is almost
103 certainly Solaris 2. */
104 if (bfd_get_section_by_name (abfd, ".SUNW_version"))
105 return GDB_OSABI_SOLARIS;
106
107 return GDB_OSABI_UNKNOWN;
108}
109
8201327c
MK
110/* Provide a prototype to silence -Wmissing-prototypes. */
111void _initialize_i386_sol2_tdep (void);
112
113void
114_initialize_i386_sol2_tdep (void)
115{
0c52bd59 116 /* Register an ELF OS ABI sniffer for Solaris 2 binaries. */
6e157172
MK
117 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
118 i386_sol2_osabi_sniffer);
119
05816f70 120 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS,
8201327c
MK
121 i386_sol2_init_abi);
122}
This page took 0.228018 seconds and 4 git commands to generate.