]>
Commit | Line | Data |
---|---|---|
386c036b MK |
1 | /* Target-dependent code for Solaris UltraSPARC. |
2 | ||
081bf9da | 3 | Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. |
386c036b 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. */ | |
386c036b MK |
21 | |
22 | #include "defs.h" | |
23 | #include "frame.h" | |
24 | #include "frame-unwind.h" | |
25 | #include "gdbarch.h" | |
26 | #include "symtab.h" | |
27 | #include "objfiles.h" | |
28 | #include "osabi.h" | |
29 | #include "trad-frame.h" | |
30 | ||
31 | #include "gdb_assert.h" | |
32 | ||
081bf9da | 33 | #include "sol2-tdep.h" |
386c036b | 34 | #include "sparc64-tdep.h" |
70b216c8 | 35 | #include "solib-svr4.h" |
386c036b MK |
36 | |
37 | /* From <sys/regset.h>. */ | |
38 | const struct sparc_gregset sparc64_sol2_gregset = | |
39 | { | |
40 | 32 * 8, /* "tstate" */ | |
41 | 33 * 8, /* %pc */ | |
42 | 34 * 8, /* %npc */ | |
43 | 35 * 8, /* %y */ | |
44 | -1, /* %wim */ | |
45 | -1, /* %tbr */ | |
46 | 1 * 8, /* %g1 */ | |
47 | 16 * 8, /* %l0 */ | |
48 | 8 /* sizeof (%y) */ | |
49 | }; | |
50 | \f | |
51 | ||
52 | static struct sparc_frame_cache * | |
53 | sparc64_sol2_sigtramp_frame_cache (struct frame_info *next_frame, | |
54 | void **this_cache) | |
55 | { | |
56 | struct sparc_frame_cache *cache; | |
57 | CORE_ADDR mcontext_addr, addr; | |
58 | int regnum; | |
59 | ||
60 | if (*this_cache) | |
61 | return *this_cache; | |
62 | ||
63 | cache = sparc_frame_cache (next_frame, this_cache); | |
64 | gdb_assert (cache == *this_cache); | |
65 | ||
66 | cache->saved_regs = trad_frame_alloc_saved_regs (next_frame); | |
67 | ||
68 | /* The third argument is a pointer to an instance of `ucontext_t', | |
69 | which has a member `uc_mcontext' that contains the saved | |
70 | registers. */ | |
71 | regnum = (cache->frameless_p ? SPARC_O2_REGNUM : SPARC_I2_REGNUM); | |
72 | mcontext_addr = frame_unwind_register_unsigned (next_frame, regnum) + 64; | |
73 | ||
74 | cache->saved_regs[SPARC64_CCR_REGNUM].addr = mcontext_addr + 0 * 8; | |
75 | cache->saved_regs[SPARC64_PC_REGNUM].addr = mcontext_addr + 1 * 8; | |
76 | cache->saved_regs[SPARC64_NPC_REGNUM].addr = mcontext_addr + 2 * 8; | |
77 | cache->saved_regs[SPARC64_Y_REGNUM].addr = mcontext_addr + 3 * 8; | |
78 | cache->saved_regs[SPARC64_ASI_REGNUM].addr = mcontext_addr + 19 * 8; | |
79 | cache->saved_regs[SPARC64_FPRS_REGNUM].addr = mcontext_addr + 20 * 8; | |
80 | ||
81 | /* Since %g0 is always zero, keep the identity encoding. */ | |
82 | for (regnum = SPARC_G1_REGNUM, addr = mcontext_addr + 4 * 8; | |
83 | regnum <= SPARC_O7_REGNUM; regnum++, addr += 8) | |
84 | cache->saved_regs[regnum].addr = addr; | |
85 | ||
86 | if (get_frame_memory_unsigned (next_frame, mcontext_addr + 21 * 8, 8)) | |
87 | { | |
88 | /* The register windows haven't been flushed. */ | |
89 | for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++) | |
90 | trad_frame_set_unknown (cache->saved_regs, regnum); | |
91 | } | |
92 | else | |
93 | { | |
94 | CORE_ADDR sp; | |
95 | ||
96 | addr = cache->saved_regs[SPARC_SP_REGNUM].addr; | |
97 | sp = get_frame_memory_unsigned (next_frame, addr, 8); | |
98 | for (regnum = SPARC_L0_REGNUM, addr = sp + BIAS; | |
99 | regnum <= SPARC_I7_REGNUM; regnum++, addr += 8) | |
100 | cache->saved_regs[regnum].addr = addr; | |
101 | } | |
102 | ||
103 | return cache; | |
104 | } | |
105 | ||
106 | static void | |
107 | sparc64_sol2_sigtramp_frame_this_id (struct frame_info *next_frame, | |
108 | void **this_cache, | |
109 | struct frame_id *this_id) | |
110 | { | |
111 | struct sparc_frame_cache *cache = | |
112 | sparc64_sol2_sigtramp_frame_cache (next_frame, this_cache); | |
113 | ||
114 | (*this_id) = frame_id_build (cache->base, cache->pc); | |
115 | } | |
116 | ||
117 | static void | |
118 | sparc64_sol2_sigtramp_frame_prev_register (struct frame_info *next_frame, | |
119 | void **this_cache, | |
120 | int regnum, int *optimizedp, | |
121 | enum lval_type *lvalp, | |
122 | CORE_ADDR *addrp, | |
47ef841b | 123 | int *realnump, gdb_byte *valuep) |
386c036b MK |
124 | { |
125 | struct sparc_frame_cache *cache = | |
126 | sparc64_sol2_sigtramp_frame_cache (next_frame, this_cache); | |
127 | ||
1f67027d AC |
128 | trad_frame_get_prev_register (next_frame, cache->saved_regs, regnum, |
129 | optimizedp, lvalp, addrp, realnump, valuep); | |
386c036b MK |
130 | } |
131 | ||
132 | static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind = | |
133 | { | |
134 | SIGTRAMP_FRAME, | |
135 | sparc64_sol2_sigtramp_frame_this_id, | |
136 | sparc64_sol2_sigtramp_frame_prev_register | |
137 | }; | |
138 | ||
139 | static const struct frame_unwind * | |
140 | sparc64_sol2_sigtramp_frame_sniffer (struct frame_info *next_frame) | |
141 | { | |
142 | CORE_ADDR pc = frame_pc_unwind (next_frame); | |
143 | char *name; | |
144 | ||
145 | find_pc_partial_function (pc, &name, NULL, NULL); | |
146 | if (sparc_sol2_pc_in_sigtramp (pc, name)) | |
147 | return &sparc64_sol2_sigtramp_frame_unwind; | |
148 | ||
149 | return NULL; | |
150 | } | |
151 | \f | |
152 | ||
153 | void | |
154 | sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
155 | { | |
156 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
157 | ||
386c036b MK |
158 | frame_unwind_append_sniffer (gdbarch, sparc64_sol2_sigtramp_frame_sniffer); |
159 | ||
160 | sparc64_init_abi (info, gdbarch); | |
161 | ||
162 | /* Solaris has SVR4-style shared libraries... */ | |
386c036b | 163 | set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); |
081bf9da | 164 | set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver); |
70b216c8 MK |
165 | set_solib_svr4_fetch_link_map_offsets |
166 | (gdbarch, svr4_lp64_fetch_link_map_offsets); | |
386c036b MK |
167 | |
168 | /* ...which means that we need some special handling when doing | |
169 | prologue analysis. */ | |
170 | tdep->plt_entry_size = 16; | |
171 | ||
172 | /* Solaris has kernel-assisted single-stepping support. */ | |
173 | set_gdbarch_software_single_step (gdbarch, NULL); | |
174 | } | |
175 | \f | |
176 | ||
177 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
178 | void _initialize_sparc64_sol2_tdep (void); | |
179 | ||
180 | void | |
181 | _initialize_sparc64_sol2_tdep (void) | |
182 | { | |
183 | gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9, | |
184 | GDB_OSABI_SOLARIS, sparc64_sol2_init_abi); | |
185 | } |