GDB (xrefs)

/tmp/gdb-8.1/gdb/i386-sol2-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for Solaris x86.
2
3 Copyright (C) 2002-2018 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 "value.h"
22 #include "osabi.h"
23
24 #include "sol2-tdep.h"
25 #include "i386-tdep.h"
26 #include "solib-svr4.h"
27
28 /* From <ia32/sys/reg.h>. */
29 static 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
49 /* Return whether THIS_FRAME corresponds to a Solaris sigtramp
50 routine. */
51
52 static int
53 i386_sol2_sigtramp_p (struct frame_info *this_frame)
54 {
55 CORE_ADDR pc = get_frame_pc (this_frame);
56 const char *name;
57
58 find_pc_partial_function (pc, &name, NULL, NULL);
59 return (name && (strcmp ("sigacthandler", name) == 0
60 || strcmp (name, "ucbsigvechandler") == 0));
61 }
62
63 /* Solaris doesn't have a `struct sigcontext', but it does have a
64 `mcontext_t' that contains the saved set of machine registers. */
65
66 static CORE_ADDR
67 i386_sol2_mcontext_addr (struct frame_info *this_frame)
68 {
69 CORE_ADDR sp, ucontext_addr;
70
71 sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);
72 ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 4);
73
74 return ucontext_addr + 36;
75 }
76
77 /* SunPRO encodes the static variables. This is not related to C++
78 mangling, it is done for C too. */
79
80 static const char *
81 i386_sol2_static_transform_name (const char *name)
82 {
83 if (name[0] == '.')
84 {
85 const char *p;
86
87 /* For file-local statics there will be a period, a bunch of
88 junk (the contents of which match a string given in the
89 N_OPT), a period and the name. For function-local statics
90 there will be a bunch of junk (which seems to change the
91 second character from 'A' to 'B'), a period, the name of the
92 function, and the name. So just skip everything before the
93 last period. */
94 p = strrchr (name, '.');
95 if (p != NULL)
96 name = p + 1;
97 }
98 return name;
99 }
100
101 /* Solaris 2. */
102
103 static void
104 i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
105 {
106 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
107
108 /* Solaris is SVR4-based. */
109 i386_svr4_init_abi (info, gdbarch);
110
111 /* The SunPRO compiler puts out 0 instead of the address in N_SO symbols,
112 and for SunPRO 3.0, N_FUN symbols too. */
113 set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
114
115 /* Handle SunPRO encoding of static symbols. */
116 set_gdbarch_static_transform_name (gdbarch, i386_sol2_static_transform_name);
117
118 /* Solaris reserves space for its FPU emulator in `fpregset_t'.
119 There is also some space reserved for the registers of a Weitek
120 math coprocessor. */
121 tdep->gregset_reg_offset = i386_sol2_gregset_reg_offset;
122 tdep->gregset_num_regs = ARRAY_SIZE (i386_sol2_gregset_reg_offset);
123 tdep->sizeof_gregset = 19 * 4;
124 tdep->sizeof_fpregset = 380;
125
126 /* Signal trampolines are slightly different from SVR4. */
127 tdep->sigtramp_p = i386_sol2_sigtramp_p;
128 tdep->sigcontext_addr = i386_sol2_mcontext_addr;
129 tdep->sc_reg_offset = tdep->gregset_reg_offset;
130 tdep->sc_num_regs = tdep->gregset_num_regs;
131
132 /* Solaris has SVR4-style shared libraries. */
133 set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
134 set_solib_svr4_fetch_link_map_offsets
135 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
136
137 /* How to print LWP PTIDs from core files. */
138 set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
139 }
140
141
142 static enum gdb_osabi
143 i386_sol2_osabi_sniffer (bfd *abfd)
144 {
145 /* If we have a section named .SUNW_version, then it is almost
146 certainly Solaris 2. */
147 if (bfd_get_section_by_name (abfd, ".SUNW_version"))
148 return GDB_OSABI_SOLARIS;
149
150 return GDB_OSABI_UNKNOWN;
151 }
152
153 void
154 _initialize_i386_sol2_tdep (void)
155 {
156 /* Register an ELF OS ABI sniffer for Solaris 2 binaries. */
157 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
158 i386_sol2_osabi_sniffer);
159
160 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS,
161 i386_sol2_init_abi);
162 }
gdbarch
Definition: gdbarch.c:127
sol2_skip_solib_resolver
CORE_ADDR sol2_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: sol2-tdep.c:29
set_gdbarch_core_pid_to_str
void set_gdbarch_core_pid_to_str(struct gdbarch *gdbarch, gdbarch_core_pid_to_str_ftype core_pid_to_str)
Definition: gdbarch.c:3767
get_frame_pc
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2376
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
gdbarch_tdep::sc_num_regs
int sc_num_regs
Definition: i386-tdep.h:227
_initialize_i386_sol2_tdep
void _initialize_i386_sol2_tdep(void)
Definition: i386-sol2-tdep.c:154
gdbarch_tdep::pc
struct m32c_reg * pc
Definition: m32c-tdep.c:116
gdbarch_tdep
Definition: aarch64-tdep.h:55
sol2_core_pid_to_str
const char * sol2_core_pid_to_str(struct gdbarch *gdbarch, ptid_t ptid)
Definition: sol2-tdep.c:44
gdbarch_register_osabi_sniffer
void gdbarch_register_osabi_sniffer(enum bfd_architecture arch, enum bfd_flavour flavour, enum gdb_osabi(*sniffer_fn)(bfd *))
Definition: osabi.c:219
gdbarch_tdep::sigcontext_addr
CORE_ADDR(* sigcontext_addr)(struct frame_info *)
Definition: alpha-tdep.h:82
frame_info
Definition: frame.c:85
svr4_ilp32_fetch_link_map_offsets
struct link_map_offsets * svr4_ilp32_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3183
gdbarch_tdep::sizeof_fpregset
size_t sizeof_fpregset
Definition: i386-tdep.h:66
get_frame_memory_unsigned
ULONGEST get_frame_memory_unsigned(struct frame_info *this_frame, CORE_ADDR addr, int len)
Definition: frame.c:2671
defs.h
gdbarch_tdep
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1491
GDB_OSABI_UNKNOWN
Definition: defs.h:512
name
const char *const name
Definition: aarch64-tdep.c:76
i386_sol2_osabi_sniffer
static enum gdb_osabi i386_sol2_osabi_sniffer(bfd *abfd)
Definition: i386-sol2-tdep.c:143
i386_svr4_init_abi
void i386_svr4_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: i386-tdep.c:4467
solib-svr4.h
osabi.h
set_solib_svr4_fetch_link_map_offsets
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
Definition: solib-svr4.c:3137
i386_sol2_gregset_reg_offset
static int i386_sol2_gregset_reg_offset[]
Definition: i386-sol2-tdep.c:29
find_pc_partial_function
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
Definition: blockframe.c:320
I386_ESP_REGNUM
Definition: i386-tdep.h:275
sol2-tdep.h
i386_sol2_mcontext_addr
static CORE_ADDR i386_sol2_mcontext_addr(struct frame_info *this_frame)
Definition: i386-sol2-tdep.c:67
i386_sol2_init_abi
static void i386_sol2_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: i386-sol2-tdep.c:104
get_frame_register_unsigned
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1308
gdbarch_register_osabi
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition: osabi.c:143
set_gdbarch_sofun_address_maybe_missing
void set_gdbarch_sofun_address_maybe_missing(struct gdbarch *gdbarch, int sofun_address_maybe_missing)
Definition: gdbarch.c:4113
GDB_OSABI_SOLARIS
Definition: defs.h:516
gdbarch_tdep::gregset_reg_offset
int * gregset_reg_offset
Definition: i386-tdep.h:61
gdbarch_tdep::sigtramp_p
int(* sigtramp_p)(struct frame_info *)
Definition: i386-tdep.h:220
i386_sol2_sigtramp_p
static int i386_sol2_sigtramp_p(struct frame_info *this_frame)
Definition: i386-sol2-tdep.c:53
gdbarch_tdep::sizeof_gregset
size_t sizeof_gregset
Definition: i386-tdep.h:63
set_gdbarch_static_transform_name
void set_gdbarch_static_transform_name(struct gdbarch *gdbarch, gdbarch_static_transform_name_ftype static_transform_name)
Definition: gdbarch.c:4096
value.h
gdbarch_tdep::sp
struct m32c_reg * sp
Definition: m32c-tdep.c:119
i386_sol2_static_transform_name
static const char * i386_sol2_static_transform_name(const char *name)
Definition: i386-sol2-tdep.c:81
gdbarch_tdep::sc_reg_offset
int * sc_reg_offset
Definition: i386-tdep.h:226
gdbarch_info
Definition: gdbarch.h:1626
i386-tdep.h
set_gdbarch_skip_solib_resolver
void set_gdbarch_skip_solib_resolver(struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype skip_solib_resolver)
Definition: gdbarch.c:3333
gdbarch_tdep::gregset_num_regs
int gregset_num_regs
Definition: i386-tdep.h:62
gdb_osabi
gdb_osabi
Definition: defs.h:508