1 /* Target-dependent code for Solaris UltraSPARC.
3 Copyright (C) 2003-2017 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
22 #include "frame-unwind.h"
27 #include "trad-frame.h"
30 #include "sol2-tdep.h"
31 #include "sparc64-tdep.h"
32 #include "solib-svr4.h"
34 /* From <sys/regset.h>. */
35 const struct sparc_gregmap sparc64_sol2_gregmap
=
37 32 * 8, /* "tstate" */
48 const struct sparc_fpregmap sparc64_sol2_fpregmap
=
55 sparc64_sol2_supply_core_gregset (const struct regset
*regset
,
56 struct regcache
*regcache
,
57 int regnum
, const void *gregs
, size_t len
)
59 sparc64_supply_gregset (&sparc64_sol2_gregmap
, regcache
, regnum
, gregs
);
63 sparc64_sol2_collect_core_gregset (const struct regset
*regset
,
64 const struct regcache
*regcache
,
65 int regnum
, void *gregs
, size_t len
)
67 sparc64_collect_gregset (&sparc64_sol2_gregmap
, regcache
, regnum
, gregs
);
71 sparc64_sol2_supply_core_fpregset (const struct regset
*regset
,
72 struct regcache
*regcache
,
73 int regnum
, const void *fpregs
, size_t len
)
75 sparc64_supply_fpregset (&sparc64_sol2_fpregmap
, regcache
, regnum
, fpregs
);
79 sparc64_sol2_collect_core_fpregset (const struct regset
*regset
,
80 const struct regcache
*regcache
,
81 int regnum
, void *fpregs
, size_t len
)
83 sparc64_collect_fpregset (&sparc64_sol2_fpregmap
, regcache
, regnum
, fpregs
);
86 static const struct regset sparc64_sol2_gregset
=
89 sparc64_sol2_supply_core_gregset
,
90 sparc64_sol2_collect_core_gregset
93 static const struct regset sparc64_sol2_fpregset
=
96 sparc64_sol2_supply_core_fpregset
,
97 sparc64_sol2_collect_core_fpregset
101 static struct sparc_frame_cache
*
102 sparc64_sol2_sigtramp_frame_cache (struct frame_info
*this_frame
,
105 struct sparc_frame_cache
*cache
;
106 CORE_ADDR mcontext_addr
, addr
;
110 return (struct sparc_frame_cache
*) *this_cache
;
112 cache
= sparc_frame_cache (this_frame
, this_cache
);
113 gdb_assert (cache
== *this_cache
);
115 cache
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
117 /* The third argument is a pointer to an instance of `ucontext_t',
118 which has a member `uc_mcontext' that contains the saved
121 (cache
->copied_regs_mask
& 0x04) ? SPARC_I2_REGNUM
: SPARC_O2_REGNUM
;
122 mcontext_addr
= get_frame_register_unsigned (this_frame
, regnum
) + 64;
124 cache
->saved_regs
[SPARC64_CCR_REGNUM
].addr
= mcontext_addr
+ 0 * 8;
125 cache
->saved_regs
[SPARC64_PC_REGNUM
].addr
= mcontext_addr
+ 1 * 8;
126 cache
->saved_regs
[SPARC64_NPC_REGNUM
].addr
= mcontext_addr
+ 2 * 8;
127 cache
->saved_regs
[SPARC64_Y_REGNUM
].addr
= mcontext_addr
+ 3 * 8;
128 cache
->saved_regs
[SPARC64_ASI_REGNUM
].addr
= mcontext_addr
+ 19 * 8;
129 cache
->saved_regs
[SPARC64_FPRS_REGNUM
].addr
= mcontext_addr
+ 20 * 8;
131 /* Since %g0 is always zero, keep the identity encoding. */
132 for (regnum
= SPARC_G1_REGNUM
, addr
= mcontext_addr
+ 4 * 8;
133 regnum
<= SPARC_O7_REGNUM
; regnum
++, addr
+= 8)
134 cache
->saved_regs
[regnum
].addr
= addr
;
136 if (get_frame_memory_unsigned (this_frame
, mcontext_addr
+ 21 * 8, 8))
138 /* The register windows haven't been flushed. */
139 for (regnum
= SPARC_L0_REGNUM
; regnum
<= SPARC_I7_REGNUM
; regnum
++)
140 trad_frame_set_unknown (cache
->saved_regs
, regnum
);
146 addr
= cache
->saved_regs
[SPARC_SP_REGNUM
].addr
;
147 sp
= get_frame_memory_unsigned (this_frame
, addr
, 8);
148 for (regnum
= SPARC_L0_REGNUM
, addr
= sp
+ BIAS
;
149 regnum
<= SPARC_I7_REGNUM
; regnum
++, addr
+= 8)
150 cache
->saved_regs
[regnum
].addr
= addr
;
157 sparc64_sol2_sigtramp_frame_this_id (struct frame_info
*this_frame
,
159 struct frame_id
*this_id
)
161 struct sparc_frame_cache
*cache
=
162 sparc64_sol2_sigtramp_frame_cache (this_frame
, this_cache
);
164 (*this_id
) = frame_id_build (cache
->base
, cache
->pc
);
167 static struct value
*
168 sparc64_sol2_sigtramp_frame_prev_register (struct frame_info
*this_frame
,
172 struct sparc_frame_cache
*cache
=
173 sparc64_sol2_sigtramp_frame_cache (this_frame
, this_cache
);
175 return trad_frame_get_prev_register (this_frame
, cache
->saved_regs
, regnum
);
179 sparc64_sol2_sigtramp_frame_sniffer (const struct frame_unwind
*self
,
180 struct frame_info
*this_frame
,
183 CORE_ADDR pc
= get_frame_pc (this_frame
);
186 find_pc_partial_function (pc
, &name
, NULL
, NULL
);
187 if (sparc_sol2_pc_in_sigtramp (pc
, name
))
192 static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind
=
195 default_frame_unwind_stop_reason
,
196 sparc64_sol2_sigtramp_frame_this_id
,
197 sparc64_sol2_sigtramp_frame_prev_register
,
199 sparc64_sol2_sigtramp_frame_sniffer
205 sparc64_sol2_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
207 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
209 tdep
->gregset
= &sparc64_sol2_gregset
;
210 tdep
->sizeof_gregset
= 304;
212 tdep
->fpregset
= &sparc64_sol2_fpregset
;
213 tdep
->sizeof_fpregset
= 544;
215 frame_unwind_append_unwinder (gdbarch
, &sparc64_sol2_sigtramp_frame_unwind
);
217 sparc64_init_abi (info
, gdbarch
);
219 /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop, SunPRO)
220 compiler puts out 0 instead of the address in N_SO stabs. Starting with
221 SunPRO 3.0, the compiler does this for N_FUN stabs too. */
222 set_gdbarch_sofun_address_maybe_missing (gdbarch
, 1);
224 /* The Sun compilers also do "globalization"; see the comment in
225 sparc_sol2_static_transform_name for more information. */
226 set_gdbarch_static_transform_name
227 (gdbarch
, sparc_sol2_static_transform_name
);
229 /* Solaris has SVR4-style shared libraries... */
230 set_gdbarch_skip_trampoline_code (gdbarch
, find_solib_trampoline_target
);
231 set_gdbarch_skip_solib_resolver (gdbarch
, sol2_skip_solib_resolver
);
232 set_solib_svr4_fetch_link_map_offsets
233 (gdbarch
, svr4_lp64_fetch_link_map_offsets
);
235 /* ...which means that we need some special handling when doing
236 prologue analysis. */
237 tdep
->plt_entry_size
= 16;
239 /* Solaris has kernel-assisted single-stepping support. */
240 set_gdbarch_software_single_step (gdbarch
, NULL
);
242 /* How to print LWP PTIDs from core files. */
243 set_gdbarch_core_pid_to_str (gdbarch
, sol2_core_pid_to_str
);
247 _initialize_sparc64_sol2_tdep (void)
249 gdbarch_register_osabi (bfd_arch_sparc
, bfd_mach_sparc_v9
,
250 GDB_OSABI_SOLARIS
, sparc64_sol2_init_abi
);