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