1 /* Target-dependent code for Solaris UltraSPARC.
3 Copyright 2003, 2004 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 2 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, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "frame-unwind.h"
29 #include "trad-frame.h"
31 #include "gdb_assert.h"
33 #include "sparc64-tdep.h"
35 /* From <sys/regset.h>. */
36 const struct sparc_gregset sparc64_sol2_gregset =
38 32 * 8, /* "tstate" */
50 static struct sparc_frame_cache *
51 sparc64_sol2_sigtramp_frame_cache (struct frame_info *next_frame,
54 struct sparc_frame_cache *cache;
55 CORE_ADDR mcontext_addr, addr;
61 cache = sparc_frame_cache (next_frame, this_cache);
62 gdb_assert (cache == *this_cache);
64 cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
66 /* The third argument is a pointer to an instance of `ucontext_t',
67 which has a member `uc_mcontext' that contains the saved
69 regnum = (cache->frameless_p ? SPARC_O2_REGNUM : SPARC_I2_REGNUM);
70 mcontext_addr = frame_unwind_register_unsigned (next_frame, regnum) + 64;
72 cache->saved_regs[SPARC64_CCR_REGNUM].addr = mcontext_addr + 0 * 8;
73 cache->saved_regs[SPARC64_PC_REGNUM].addr = mcontext_addr + 1 * 8;
74 cache->saved_regs[SPARC64_NPC_REGNUM].addr = mcontext_addr + 2 * 8;
75 cache->saved_regs[SPARC64_Y_REGNUM].addr = mcontext_addr + 3 * 8;
76 cache->saved_regs[SPARC64_ASI_REGNUM].addr = mcontext_addr + 19 * 8;
77 cache->saved_regs[SPARC64_FPRS_REGNUM].addr = mcontext_addr + 20 * 8;
79 /* Since %g0 is always zero, keep the identity encoding. */
80 for (regnum = SPARC_G1_REGNUM, addr = mcontext_addr + 4 * 8;
81 regnum <= SPARC_O7_REGNUM; regnum++, addr += 8)
82 cache->saved_regs[regnum].addr = addr;
84 if (get_frame_memory_unsigned (next_frame, mcontext_addr + 21 * 8, 8))
86 /* The register windows haven't been flushed. */
87 for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++)
88 trad_frame_set_unknown (cache->saved_regs, regnum);
94 addr = cache->saved_regs[SPARC_SP_REGNUM].addr;
95 sp = get_frame_memory_unsigned (next_frame, addr, 8);
96 for (regnum = SPARC_L0_REGNUM, addr = sp + BIAS;
97 regnum <= SPARC_I7_REGNUM; regnum++, addr += 8)
98 cache->saved_regs[regnum].addr = addr;
105 sparc64_sol2_sigtramp_frame_this_id (struct frame_info *next_frame,
107 struct frame_id *this_id)
109 struct sparc_frame_cache *cache =
110 sparc64_sol2_sigtramp_frame_cache (next_frame, this_cache);
112 (*this_id) = frame_id_build (cache->base, cache->pc);
116 sparc64_sol2_sigtramp_frame_prev_register (struct frame_info *next_frame,
118 int regnum, int *optimizedp,
119 enum lval_type *lvalp,
121 int *realnump, void *valuep)
123 struct sparc_frame_cache *cache =
124 sparc64_sol2_sigtramp_frame_cache (next_frame, this_cache);
126 trad_frame_prev_register (next_frame, cache->saved_regs, regnum,
127 optimizedp, lvalp, addrp, realnump, valuep);
130 static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind =
133 sparc64_sol2_sigtramp_frame_this_id,
134 sparc64_sol2_sigtramp_frame_prev_register
137 static const struct frame_unwind *
138 sparc64_sol2_sigtramp_frame_sniffer (struct frame_info *next_frame)
140 CORE_ADDR pc = frame_pc_unwind (next_frame);
143 find_pc_partial_function (pc, &name, NULL, NULL);
144 if (sparc_sol2_pc_in_sigtramp (pc, name))
145 return &sparc64_sol2_sigtramp_frame_unwind;
152 sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
154 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
156 set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, sparc_sol2_pc_in_sigtramp);
157 frame_unwind_append_sniffer (gdbarch, sparc64_sol2_sigtramp_frame_sniffer);
159 sparc64_init_abi (info, gdbarch);
161 /* Solaris has SVR4-style shared libraries... */
162 set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
163 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
165 /* ...which means that we need some special handling when doing
166 prologue analysis. */
167 tdep->plt_entry_size = 16;
169 /* Solaris has kernel-assisted single-stepping support. */
170 set_gdbarch_software_single_step (gdbarch, NULL);
174 /* Provide a prototype to silence -Wmissing-prototypes. */
175 void _initialize_sparc64_sol2_tdep (void);
178 _initialize_sparc64_sol2_tdep (void)
180 gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9,
181 GDB_OSABI_SOLARIS, sparc64_sol2_init_abi);