Remove duplicate comment
[deliverable/binutils-gdb.git] / gdb / sparc64-sol2-tdep.c
1 /* Target-dependent code for Solaris UltraSPARC.
2
3 Copyright (C) 2003-2014 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 "frame.h"
22 #include "frame-unwind.h"
23 #include "gdbarch.h"
24 #include "symtab.h"
25 #include "objfiles.h"
26 #include "osabi.h"
27 #include "trad-frame.h"
28
29 #include "sol2-tdep.h"
30 #include "sparc64-tdep.h"
31 #include "solib-svr4.h"
32
33 /* From <sys/regset.h>. */
34 const struct sparc_gregmap sparc64_sol2_gregmap =
35 {
36 32 * 8, /* "tstate" */
37 33 * 8, /* %pc */
38 34 * 8, /* %npc */
39 35 * 8, /* %y */
40 -1, /* %wim */
41 -1, /* %tbr */
42 1 * 8, /* %g1 */
43 16 * 8, /* %l0 */
44 8 /* sizeof (%y) */
45 };
46
47 const struct sparc_fpregmap sparc64_sol2_fpregmap =
48 {
49 0 * 8, /* %f0 */
50 33 * 8, /* %fsr */
51 };
52 \f
53
54 static struct sparc_frame_cache *
55 sparc64_sol2_sigtramp_frame_cache (struct frame_info *this_frame,
56 void **this_cache)
57 {
58 struct sparc_frame_cache *cache;
59 CORE_ADDR mcontext_addr, addr;
60 int regnum;
61
62 if (*this_cache)
63 return *this_cache;
64
65 cache = sparc_frame_cache (this_frame, this_cache);
66 gdb_assert (cache == *this_cache);
67
68 cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
69
70 /* The third argument is a pointer to an instance of `ucontext_t',
71 which has a member `uc_mcontext' that contains the saved
72 registers. */
73 regnum =
74 (cache->copied_regs_mask & 0x04) ? SPARC_I2_REGNUM : SPARC_O2_REGNUM;
75 mcontext_addr = get_frame_register_unsigned (this_frame, regnum) + 64;
76
77 cache->saved_regs[SPARC64_CCR_REGNUM].addr = mcontext_addr + 0 * 8;
78 cache->saved_regs[SPARC64_PC_REGNUM].addr = mcontext_addr + 1 * 8;
79 cache->saved_regs[SPARC64_NPC_REGNUM].addr = mcontext_addr + 2 * 8;
80 cache->saved_regs[SPARC64_Y_REGNUM].addr = mcontext_addr + 3 * 8;
81 cache->saved_regs[SPARC64_ASI_REGNUM].addr = mcontext_addr + 19 * 8;
82 cache->saved_regs[SPARC64_FPRS_REGNUM].addr = mcontext_addr + 20 * 8;
83
84 /* Since %g0 is always zero, keep the identity encoding. */
85 for (regnum = SPARC_G1_REGNUM, addr = mcontext_addr + 4 * 8;
86 regnum <= SPARC_O7_REGNUM; regnum++, addr += 8)
87 cache->saved_regs[regnum].addr = addr;
88
89 if (get_frame_memory_unsigned (this_frame, mcontext_addr + 21 * 8, 8))
90 {
91 /* The register windows haven't been flushed. */
92 for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++)
93 trad_frame_set_unknown (cache->saved_regs, regnum);
94 }
95 else
96 {
97 CORE_ADDR sp;
98
99 addr = cache->saved_regs[SPARC_SP_REGNUM].addr;
100 sp = get_frame_memory_unsigned (this_frame, addr, 8);
101 for (regnum = SPARC_L0_REGNUM, addr = sp + BIAS;
102 regnum <= SPARC_I7_REGNUM; regnum++, addr += 8)
103 cache->saved_regs[regnum].addr = addr;
104 }
105
106 return cache;
107 }
108
109 static void
110 sparc64_sol2_sigtramp_frame_this_id (struct frame_info *this_frame,
111 void **this_cache,
112 struct frame_id *this_id)
113 {
114 struct sparc_frame_cache *cache =
115 sparc64_sol2_sigtramp_frame_cache (this_frame, this_cache);
116
117 (*this_id) = frame_id_build (cache->base, cache->pc);
118 }
119
120 static struct value *
121 sparc64_sol2_sigtramp_frame_prev_register (struct frame_info *this_frame,
122 void **this_cache,
123 int regnum)
124 {
125 struct sparc_frame_cache *cache =
126 sparc64_sol2_sigtramp_frame_cache (this_frame, this_cache);
127
128 return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum);
129 }
130
131 static int
132 sparc64_sol2_sigtramp_frame_sniffer (const struct frame_unwind *self,
133 struct frame_info *this_frame,
134 void **this_cache)
135 {
136 CORE_ADDR pc = get_frame_pc (this_frame);
137 const char *name;
138
139 find_pc_partial_function (pc, &name, NULL, NULL);
140 if (sparc_sol2_pc_in_sigtramp (pc, name))
141 return 1;
142
143 return 0;
144 }
145 static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind =
146 {
147 SIGTRAMP_FRAME,
148 default_frame_unwind_stop_reason,
149 sparc64_sol2_sigtramp_frame_this_id,
150 sparc64_sol2_sigtramp_frame_prev_register,
151 NULL,
152 sparc64_sol2_sigtramp_frame_sniffer
153 };
154
155 \f
156
157 void
158 sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
159 {
160 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
161
162 frame_unwind_append_unwinder (gdbarch, &sparc64_sol2_sigtramp_frame_unwind);
163
164 sparc64_init_abi (info, gdbarch);
165
166 /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop, SunPRO)
167 compiler puts out 0 instead of the address in N_SO stabs. Starting with
168 SunPRO 3.0, the compiler does this for N_FUN stabs too. */
169 set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
170
171 /* The Sun compilers also do "globalization"; see the comment in
172 sparc_sol2_static_transform_name for more information. */
173 set_gdbarch_static_transform_name
174 (gdbarch, sparc_sol2_static_transform_name);
175
176 /* Solaris has SVR4-style shared libraries... */
177 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
178 set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
179 set_solib_svr4_fetch_link_map_offsets
180 (gdbarch, svr4_lp64_fetch_link_map_offsets);
181
182 /* ...which means that we need some special handling when doing
183 prologue analysis. */
184 tdep->plt_entry_size = 16;
185
186 /* Solaris has kernel-assisted single-stepping support. */
187 set_gdbarch_software_single_step (gdbarch, NULL);
188
189 /* How to print LWP PTIDs from core files. */
190 set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
191 }
192 \f
193
194 /* Provide a prototype to silence -Wmissing-prototypes. */
195 void _initialize_sparc64_sol2_tdep (void);
196
197 void
198 _initialize_sparc64_sol2_tdep (void)
199 {
200 gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9,
201 GDB_OSABI_SOLARIS, sparc64_sol2_init_abi);
202 }
This page took 0.032776 seconds and 4 git commands to generate.