* linux-low.c (linux_read_memory): Change return type to
[deliverable/binutils-gdb.git] / gdb / i386-sol2-tdep.c
CommitLineData
8201327c 1/* Target-dependent code for Solaris x86.
1e698235 2 Copyright 2002, 2003 Free Software Foundation, Inc.
8201327c
MK
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include "defs.h"
52e9098c 22#include "value.h"
4be87837 23#include "osabi.h"
8201327c
MK
24
25#include "i386-tdep.h"
26
6a9756ed
MK
27/* From <ia32/sys/reg.h>. */
28static int i386_sol2_gregset_reg_offset[] =
29{
30 11 * 4, /* %eax */
31 10 * 4, /* %ecx */
32 9 * 4, /* %edx */
33 8 * 4, /* %ebx */
34 17 * 4, /* %esp */
35 6 * 4, /* %ebp */
36 5 * 4, /* %esi */
37 4 * 4, /* %edi */
38 14 * 4, /* %eip */
39 16 * 4, /* %eflags */
40 15 * 4, /* %cs */
41 18 * 4, /* %ss */
42 3 * 4, /* %ds */
43 2 * 4, /* %es */
44 1 * 4, /* %fs */
45 0 * 4 /* %gs */
46};
47
8201327c
MK
48static int
49i386_sol2_pc_in_sigtramp (CORE_ADDR pc, char *name)
50{
51 /* Signal handler frames under Solaris 2 are recognized by a return
52 address of 0xffffffff. */
53 return (pc == 0xffffffff);
54}
55
8349554d
MK
56/* Solaris doesn't have a `struct sigcontext', but it does have a
57 `mcontext_t' that contains the saved set of machine registers. */
58
59static CORE_ADDR
60i386_sol2_mcontext_addr (struct frame_info *next_frame)
61{
62 CORE_ADDR sp, ucontext_addr;
63
64 sp = frame_unwind_register_unsigned (next_frame, I386_ESP_REGNUM);
65 ucontext_addr = get_frame_memory_unsigned (next_frame, sp + 8, 4);
66
67 return ucontext_addr + 36;
68}
69
8201327c
MK
70/* Solaris 2. */
71
72static void
73i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
74{
75 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
76
77 /* Solaris is SVR4-based. */
78 i386_svr4_init_abi (info, gdbarch);
79
6a9756ed
MK
80 /* Solaris reserves space for its FPU emulator in `fpregset_t'.
81 There is also some space reserved for the registers of a Weitek
82 math coprocessor. */
83 tdep->gregset_reg_offset = i386_sol2_gregset_reg_offset;
84 tdep->gregset_num_regs = ARRAY_SIZE (i386_sol2_gregset_reg_offset);
85 tdep->sizeof_gregset = 19 * 4;
86 tdep->sizeof_fpregset = 380;
87
8349554d
MK
88 tdep->sigcontext_addr = i386_sol2_mcontext_addr;
89 tdep->sc_reg_offset = tdep->gregset_reg_offset;
90 tdep->sc_num_regs = tdep->gregset_num_regs;
91
acd5c798 92 /* Signal trampolines are slightly different from SVR4. */
8201327c 93 set_gdbarch_pc_in_sigtramp (gdbarch, i386_sol2_pc_in_sigtramp);
8201327c
MK
94}
95\f
96
6e157172
MK
97static enum gdb_osabi
98i386_sol2_osabi_sniffer (bfd *abfd)
99{
100 /* If we have a section named .SUNW_version, then it is almost
101 certainly Solaris 2. */
102 if (bfd_get_section_by_name (abfd, ".SUNW_version"))
103 return GDB_OSABI_SOLARIS;
104
105 return GDB_OSABI_UNKNOWN;
106}
107
8201327c
MK
108/* Provide a prototype to silence -Wmissing-prototypes. */
109void _initialize_i386_sol2_tdep (void);
110
111void
112_initialize_i386_sol2_tdep (void)
113{
0c52bd59 114 /* Register an ELF OS ABI sniffer for Solaris 2 binaries. */
6e157172
MK
115 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
116 i386_sol2_osabi_sniffer);
117
05816f70 118 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS,
8201327c
MK
119 i386_sol2_init_abi);
120}
This page took 0.177749 seconds and 4 git commands to generate.