]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/sparc64-sol2-tdep.c
* win32-low.c (win32_add_one_solib): If the dll name is
[thirdparty/binutils-gdb.git] / gdb / sparc64-sol2-tdep.c
CommitLineData
386c036b
MK
1/* Target-dependent code for Solaris UltraSPARC.
2
0fb0cc75
JB
3 Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009
4 Free Software Foundation, Inc.
386c036b
MK
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
386c036b
MK
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
386c036b
MK
20
21#include "defs.h"
22#include "frame.h"
23#include "frame-unwind.h"
24#include "gdbarch.h"
25#include "symtab.h"
26#include "objfiles.h"
27#include "osabi.h"
28#include "trad-frame.h"
29
30#include "gdb_assert.h"
31
081bf9da 32#include "sol2-tdep.h"
386c036b 33#include "sparc64-tdep.h"
70b216c8 34#include "solib-svr4.h"
386c036b
MK
35
36/* From <sys/regset.h>. */
37const struct sparc_gregset sparc64_sol2_gregset =
38{
39 32 * 8, /* "tstate" */
40 33 * 8, /* %pc */
41 34 * 8, /* %npc */
42 35 * 8, /* %y */
43 -1, /* %wim */
44 -1, /* %tbr */
45 1 * 8, /* %g1 */
46 16 * 8, /* %l0 */
47 8 /* sizeof (%y) */
48};
49\f
50
51static struct sparc_frame_cache *
236369e7 52sparc64_sol2_sigtramp_frame_cache (struct frame_info *this_frame,
386c036b
MK
53 void **this_cache)
54{
55 struct sparc_frame_cache *cache;
56 CORE_ADDR mcontext_addr, addr;
57 int regnum;
58
59 if (*this_cache)
60 return *this_cache;
61
236369e7 62 cache = sparc_frame_cache (this_frame, this_cache);
386c036b
MK
63 gdb_assert (cache == *this_cache);
64
236369e7 65 cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
386c036b
MK
66
67 /* The third argument is a pointer to an instance of `ucontext_t',
68 which has a member `uc_mcontext' that contains the saved
69 registers. */
70 regnum = (cache->frameless_p ? SPARC_O2_REGNUM : SPARC_I2_REGNUM);
236369e7 71 mcontext_addr = get_frame_register_unsigned (this_frame, regnum) + 64;
386c036b
MK
72
73 cache->saved_regs[SPARC64_CCR_REGNUM].addr = mcontext_addr + 0 * 8;
74 cache->saved_regs[SPARC64_PC_REGNUM].addr = mcontext_addr + 1 * 8;
75 cache->saved_regs[SPARC64_NPC_REGNUM].addr = mcontext_addr + 2 * 8;
76 cache->saved_regs[SPARC64_Y_REGNUM].addr = mcontext_addr + 3 * 8;
77 cache->saved_regs[SPARC64_ASI_REGNUM].addr = mcontext_addr + 19 * 8;
78 cache->saved_regs[SPARC64_FPRS_REGNUM].addr = mcontext_addr + 20 * 8;
79
80 /* Since %g0 is always zero, keep the identity encoding. */
81 for (regnum = SPARC_G1_REGNUM, addr = mcontext_addr + 4 * 8;
82 regnum <= SPARC_O7_REGNUM; regnum++, addr += 8)
83 cache->saved_regs[regnum].addr = addr;
84
236369e7 85 if (get_frame_memory_unsigned (this_frame, mcontext_addr + 21 * 8, 8))
386c036b
MK
86 {
87 /* The register windows haven't been flushed. */
88 for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++)
89 trad_frame_set_unknown (cache->saved_regs, regnum);
90 }
91 else
92 {
93 CORE_ADDR sp;
94
95 addr = cache->saved_regs[SPARC_SP_REGNUM].addr;
236369e7 96 sp = get_frame_memory_unsigned (this_frame, addr, 8);
386c036b
MK
97 for (regnum = SPARC_L0_REGNUM, addr = sp + BIAS;
98 regnum <= SPARC_I7_REGNUM; regnum++, addr += 8)
99 cache->saved_regs[regnum].addr = addr;
100 }
101
102 return cache;
103}
104
105static void
236369e7 106sparc64_sol2_sigtramp_frame_this_id (struct frame_info *this_frame,
386c036b
MK
107 void **this_cache,
108 struct frame_id *this_id)
109{
110 struct sparc_frame_cache *cache =
236369e7 111 sparc64_sol2_sigtramp_frame_cache (this_frame, this_cache);
386c036b
MK
112
113 (*this_id) = frame_id_build (cache->base, cache->pc);
114}
115
236369e7
JB
116static struct value *
117sparc64_sol2_sigtramp_frame_prev_register (struct frame_info *this_frame,
386c036b 118 void **this_cache,
236369e7 119 int regnum)
386c036b
MK
120{
121 struct sparc_frame_cache *cache =
236369e7 122 sparc64_sol2_sigtramp_frame_cache (this_frame, this_cache);
386c036b 123
236369e7 124 return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum);
386c036b
MK
125}
126
236369e7
JB
127static int
128sparc64_sol2_sigtramp_frame_sniffer (const struct frame_unwind *self,
129 struct frame_info *this_frame,
130 void **this_cache)
386c036b 131{
236369e7 132 CORE_ADDR pc = get_frame_pc (this_frame);
386c036b
MK
133 char *name;
134
135 find_pc_partial_function (pc, &name, NULL, NULL);
136 if (sparc_sol2_pc_in_sigtramp (pc, name))
236369e7 137 return 1;
386c036b 138
236369e7 139 return 0;
386c036b 140}
236369e7
JB
141static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind =
142{
143 SIGTRAMP_FRAME,
144 sparc64_sol2_sigtramp_frame_this_id,
145 sparc64_sol2_sigtramp_frame_prev_register,
146 NULL,
147 sparc64_sol2_sigtramp_frame_sniffer
148};
149
386c036b
MK
150\f
151
152void
153sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
154{
155 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
156
236369e7 157 frame_unwind_append_unwinder (gdbarch, &sparc64_sol2_sigtramp_frame_unwind);
386c036b
MK
158
159 sparc64_init_abi (info, gdbarch);
160
203c3895
UW
161 /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop, SunPRO)
162 compiler puts out 0 instead of the address in N_SO stabs. Starting with
163 SunPRO 3.0, the compiler does this for N_FUN stabs too. */
164 set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
165
149ad273
UW
166 /* The Sun compilers also do "globalization"; see the comment in
167 sparc_sol2_static_transform_name for more information. */
168 set_gdbarch_static_transform_name
169 (gdbarch, sparc_sol2_static_transform_name);
170
386c036b 171 /* Solaris has SVR4-style shared libraries... */
386c036b 172 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
081bf9da 173 set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
70b216c8
MK
174 set_solib_svr4_fetch_link_map_offsets
175 (gdbarch, svr4_lp64_fetch_link_map_offsets);
386c036b
MK
176
177 /* ...which means that we need some special handling when doing
178 prologue analysis. */
179 tdep->plt_entry_size = 16;
180
181 /* Solaris has kernel-assisted single-stepping support. */
182 set_gdbarch_software_single_step (gdbarch, NULL);
959b8724
PA
183
184 /* Solaris encodes the pid of the inferior in regset section
185 names. */
186 set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
28439f5e
PA
187
188 /* How to print LWP PTIDs from core files. */
189 set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
386c036b
MK
190}
191\f
192
193/* Provide a prototype to silence -Wmissing-prototypes. */
194void _initialize_sparc64_sol2_tdep (void);
195
196void
197_initialize_sparc64_sol2_tdep (void)
198{
199 gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9,
200 GDB_OSABI_SOLARIS, sparc64_sol2_init_abi);
201}