GDB (xrefs)

/tmp/gdb-8.1/gdb/sparc64-sol2-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for Solaris UltraSPARC.
2
3 Copyright (C) 2003-2018 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 #include "regset.h"
29
30 #include "sol2-tdep.h"
31 #include "sparc64-tdep.h"
32 #include "solib-svr4.h"
33
34 /* From <sys/regset.h>. */
35 const struct sparc_gregmap sparc64_sol2_gregmap =
36 {
37 32 * 8, /* "tstate" */
38 33 * 8, /* %pc */
39 34 * 8, /* %npc */
40 35 * 8, /* %y */
41 -1, /* %wim */
42 -1, /* %tbr */
43 1 * 8, /* %g1 */
44 16 * 8, /* %l0 */
45 8 /* sizeof (%y) */
46 };
47
48 const struct sparc_fpregmap sparc64_sol2_fpregmap =
49 {
50 0 * 8, /* %f0 */
51 33 * 8, /* %fsr */
52 };
53
54 static void
55 sparc64_sol2_supply_core_gregset (const struct regset *regset,
56 struct regcache *regcache,
57 int regnum, const void *gregs, size_t len)
58 {
59 sparc64_supply_gregset (&sparc64_sol2_gregmap, regcache, regnum, gregs);
60 }
61
62 static void
63 sparc64_sol2_collect_core_gregset (const struct regset *regset,
64 const struct regcache *regcache,
65 int regnum, void *gregs, size_t len)
66 {
67 sparc64_collect_gregset (&sparc64_sol2_gregmap, regcache, regnum, gregs);
68 }
69
70 static void
71 sparc64_sol2_supply_core_fpregset (const struct regset *regset,
72 struct regcache *regcache,
73 int regnum, const void *fpregs, size_t len)
74 {
75 sparc64_supply_fpregset (&sparc64_sol2_fpregmap, regcache, regnum, fpregs);
76 }
77
78 static void
79 sparc64_sol2_collect_core_fpregset (const struct regset *regset,
80 const struct regcache *regcache,
81 int regnum, void *fpregs, size_t len)
82 {
83 sparc64_collect_fpregset (&sparc64_sol2_fpregmap, regcache, regnum, fpregs);
84 }
85
86 static const struct regset sparc64_sol2_gregset =
87 {
88 NULL,
89 sparc64_sol2_supply_core_gregset,
90 sparc64_sol2_collect_core_gregset
91 };
92
93 static const struct regset sparc64_sol2_fpregset =
94 {
95 NULL,
96 sparc64_sol2_supply_core_fpregset,
97 sparc64_sol2_collect_core_fpregset
98 };
99
100
101 static struct sparc_frame_cache *
102 sparc64_sol2_sigtramp_frame_cache (struct frame_info *this_frame,
103 void **this_cache)
104 {
105 struct sparc_frame_cache *cache;
106 CORE_ADDR mcontext_addr, addr;
107 int regnum;
108
109 if (*this_cache)
110 return (struct sparc_frame_cache *) *this_cache;
111
112 cache = sparc_frame_cache (this_frame, this_cache);
113 gdb_assert (cache == *this_cache);
114
115 cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
116
117 /* The third argument is a pointer to an instance of `ucontext_t',
118 which has a member `uc_mcontext' that contains the saved
119 registers. */
120 regnum =
121 (cache->copied_regs_mask & 0x04) ? SPARC_I2_REGNUM : SPARC_O2_REGNUM;
122 mcontext_addr = get_frame_register_unsigned (this_frame, regnum) + 64;
123
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;
130
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;
135
136 if (get_frame_memory_unsigned (this_frame, mcontext_addr + 21 * 8, 8))
137 {
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);
141 }
142 else
143 {
144 CORE_ADDR sp;
145
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;
151 }
152
153 return cache;
154 }
155
156 static void
157 sparc64_sol2_sigtramp_frame_this_id (struct frame_info *this_frame,
158 void **this_cache,
159 struct frame_id *this_id)
160 {
161 struct sparc_frame_cache *cache =
162 sparc64_sol2_sigtramp_frame_cache (this_frame, this_cache);
163
164 (*this_id) = frame_id_build (cache->base, cache->pc);
165 }
166
167 static struct value *
168 sparc64_sol2_sigtramp_frame_prev_register (struct frame_info *this_frame,
169 void **this_cache,
170 int regnum)
171 {
172 struct sparc_frame_cache *cache =
173 sparc64_sol2_sigtramp_frame_cache (this_frame, this_cache);
174
175 return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum);
176 }
177
178 static int
179 sparc64_sol2_sigtramp_frame_sniffer (const struct frame_unwind *self,
180 struct frame_info *this_frame,
181 void **this_cache)
182 {
183 CORE_ADDR pc = get_frame_pc (this_frame);
184 const char *name;
185
186 find_pc_partial_function (pc, &name, NULL, NULL);
187 if (sparc_sol2_pc_in_sigtramp (pc, name))
188 return 1;
189
190 return 0;
191 }
192 static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind =
193 {
194 SIGTRAMP_FRAME,
195 default_frame_unwind_stop_reason,
196 sparc64_sol2_sigtramp_frame_this_id,
197 sparc64_sol2_sigtramp_frame_prev_register,
198 NULL,
199 sparc64_sol2_sigtramp_frame_sniffer
200 };
201
202
203
204 void
205 sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
206 {
207 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
208
209 tdep->gregset = &sparc64_sol2_gregset;
210 tdep->sizeof_gregset = 304;
211
212 tdep->fpregset = &sparc64_sol2_fpregset;
213 tdep->sizeof_fpregset = 544;
214
215 frame_unwind_append_unwinder (gdbarch, &sparc64_sol2_sigtramp_frame_unwind);
216
217 sparc64_init_abi (info, gdbarch);
218
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);
223
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);
228
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);
234
235 /* ...which means that we need some special handling when doing
236 prologue analysis. */
237 tdep->plt_entry_size = 16;
238
239 /* Solaris has kernel-assisted single-stepping support. */
240 set_gdbarch_software_single_step (gdbarch, NULL);
241
242 /* How to print LWP PTIDs from core files. */
243 set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
244 }
245
246 void
247 _initialize_sparc64_sol2_tdep (void)
248 {
249 gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9,
250 GDB_OSABI_SOLARIS, sparc64_sol2_init_abi);
251 }
gdbarch
Definition: gdbarch.c:127
sparc64_collect_fpregset
void sparc64_collect_fpregset(const struct sparc_fpregmap *fpregmap, const struct regcache *regcache, int regnum, void *fpregs)
Definition: sparc64-tdep.c:2143
sparc64_init_abi
void sparc64_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: sparc64-tdep.c:1804
sparc64_sol2_fpregset
static const struct regset sparc64_sol2_fpregset
Definition: sparc64-sol2-tdep.c:93
sol2_skip_solib_resolver
CORE_ADDR sol2_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: sol2-tdep.c:29
frame_id_build
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition: frame.c:624
set_gdbarch_core_pid_to_str
void set_gdbarch_core_pid_to_str(struct gdbarch *gdbarch, gdbarch_core_pid_to_str_ftype core_pid_to_str)
Definition: gdbarch.c:3767
get_frame_pc
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2376
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
svr4_lp64_fetch_link_map_offsets
struct link_map_offsets * svr4_lp64_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3214
trad_frame_get_prev_register
struct value * trad_frame_get_prev_register(struct frame_info *this_frame, struct trad_frame_saved_reg this_saved_regs[], int regnum)
Definition: trad-frame.c:142
sparc_frame_cache::pc
CORE_ADDR pc
Definition: sparc-tdep.h:171
sparc_sol2_static_transform_name
const char * sparc_sol2_static_transform_name(const char *name)
Definition: sparc-sol2-tdep.c:227
if
if(!(yy_init))
Definition: ada-lex.c:1075
set_gdbarch_skip_trampoline_code
void set_gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype skip_trampoline_code)
Definition: gdbarch.c:3316
gdbarch_tdep::gregset
const struct regset * gregset
Definition: sparc-tdep.h:73
sparc_frame_cache
struct sparc_frame_cache * sparc_frame_cache(struct frame_info *this_frame, void **this_cache)
Definition: sparc-tdep.c:1174
BIAS
#define BIAS
Definition: sparc-tdep.c:72
gdbarch_tdep
Definition: aarch64-tdep.h:55
sol2_core_pid_to_str
const char * sol2_core_pid_to_str(struct gdbarch *gdbarch, ptid_t ptid)
Definition: sol2-tdep.c:44
SPARC_O7_REGNUM
Definition: sparc-tdep.h:116
sparc64_sol2_sigtramp_frame_this_id
static void sparc64_sol2_sigtramp_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
Definition: sparc64-sol2-tdep.c:157
sparc64-tdep.h
SIGTRAMP_FRAME
Definition: frame.h:255
frame_info
Definition: frame.c:85
sparc64_sol2_sigtramp_frame_unwind
static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind
Definition: sparc64-sol2-tdep.c:192
sparc_gregmap
Definition: sparc-tdep.h:37
_initialize_sparc64_sol2_tdep
void _initialize_sparc64_sol2_tdep(void)
Definition: sparc64-sol2-tdep.c:247
sparc64_sol2_gregset
static const struct regset sparc64_sol2_gregset
Definition: sparc64-sol2-tdep.c:86
gdbarch_tdep::sizeof_fpregset
size_t sizeof_fpregset
Definition: i386-tdep.h:66
get_frame_memory_unsigned
ULONGEST get_frame_memory_unsigned(struct frame_info *this_frame, CORE_ADDR addr, int len)
Definition: frame.c:2671
defs.h
sparc64_collect_gregset
void sparc64_collect_gregset(const struct sparc_gregmap *gregmap, const struct regcache *regcache, int regnum, void *gregs)
Definition: sparc64-tdep.c:1995
sparc64_supply_gregset
void sparc64_supply_gregset(const struct sparc_gregmap *gregmap, struct regcache *regcache, int regnum, const void *gregs)
Definition: sparc64-tdep.c:1878
gdbarch_tdep
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1491
SPARC_O2_REGNUM
Definition: sparc-tdep.h:111
frame_unwind_append_unwinder
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
Definition: frame-unwind.c:79
sparc_frame_cache::saved_regs
struct trad_frame_saved_reg * saved_regs
Definition: sparc-tdep.h:189
objfiles.h
SPARC_SP_REGNUM
Definition: sparc-tdep.h:115
regset
Definition: regset.h:34
SPARC_I7_REGNUM
Definition: sparc-tdep.h:132
symtab.h
name
const char *const name
Definition: aarch64-tdep.c:76
SPARC64_PC_REGNUM
Definition: sparc64-tdep.h:53
sparc64_sol2_supply_core_gregset
static void sparc64_sol2_supply_core_gregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
Definition: sparc64-sol2-tdep.c:55
SPARC_L0_REGNUM
Definition: sparc-tdep.h:117
trad-frame.h
sparc64_sol2_gregmap
const struct sparc_gregmap sparc64_sol2_gregmap
Definition: sparc64-sol2-tdep.c:35
find_solib_trampoline_target
CORE_ADDR find_solib_trampoline_target(struct frame_info *frame, CORE_ADDR pc)
Definition: minsyms.c:1492
solib-svr4.h
osabi.h
sparc_frame_cache::base
CORE_ADDR base
Definition: sparc-tdep.h:170
SPARC64_NPC_REGNUM
Definition: sparc64-tdep.h:54
sparc64_supply_fpregset
void sparc64_supply_fpregset(const struct sparc_fpregmap *fpregmap, struct regcache *regcache, int regnum, const void *fpregs)
Definition: sparc64-tdep.c:2105
gdbarch.h
frame.h
sparc64_sol2_collect_core_fpregset
static void sparc64_sol2_collect_core_fpregset(const struct regset *regset, const struct regcache *regcache, int regnum, void *fpregs, size_t len)
Definition: sparc64-sol2-tdep.c:79
set_solib_svr4_fetch_link_map_offsets
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
Definition: solib-svr4.c:3137
sparc_fpregmap
Definition: sparc-tdep.h:50
find_pc_partial_function
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
Definition: blockframe.c:320
frame-unwind.h
SPARC_I2_REGNUM
Definition: sparc-tdep.h:127
sol2-tdep.h
SPARC_G1_REGNUM
Definition: sparc-tdep.h:102
SPARC64_ASI_REGNUM
Definition: sparc64-tdep.h:66
regnum
int regnum
Definition: aarch64-tdep.c:77
sparc64_sol2_sigtramp_frame_prev_register
static struct value * sparc64_sol2_sigtramp_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
Definition: sparc64-sol2-tdep.c:168
get_frame_register_unsigned
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1308
gdbarch_register_osabi
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition: osabi.c:143
set_gdbarch_sofun_address_maybe_missing
void set_gdbarch_sofun_address_maybe_missing(struct gdbarch *gdbarch, int sofun_address_maybe_missing)
Definition: gdbarch.c:4113
trad_frame_alloc_saved_regs
struct trad_frame_saved_reg * trad_frame_alloc_saved_regs(struct gdbarch *gdbarch)
Definition: trad-frame.c:47
GDB_OSABI_SOLARIS
Definition: defs.h:516
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
value
Definition: value.c:169
set_gdbarch_software_single_step
void set_gdbarch_software_single_step(struct gdbarch *gdbarch, gdbarch_software_single_step_ftype software_single_step)
Definition: gdbarch.c:3258
trad_frame_saved_reg::addr
LONGEST addr
Definition: trad-frame.h:83
sparc_frame_cache::copied_regs_mask
unsigned char copied_regs_mask
Definition: sparc-tdep.h:183
SPARC64_Y_REGNUM
Definition: sparc64-tdep.h:58
gdbarch_tdep::sizeof_gregset
size_t sizeof_gregset
Definition: i386-tdep.h:63
set_gdbarch_static_transform_name
void set_gdbarch_static_transform_name(struct gdbarch *gdbarch, gdbarch_static_transform_name_ftype static_transform_name)
Definition: gdbarch.c:4096
frame_unwind
Definition: frame-unwind.h:144
gdbarch_tdep::fpregset
const struct regset * fpregset
Definition: i386-tdep.h:253
sparc64_sol2_supply_core_fpregset
static void sparc64_sol2_supply_core_fpregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len)
Definition: sparc64-sol2-tdep.c:71
default_frame_unwind_stop_reason
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
Definition: frame-unwind.c:184
sparc_sol2_pc_in_sigtramp
int sparc_sol2_pc_in_sigtramp(CORE_ADDR pc, const char *name)
Definition: sparc-sol2-tdep.c:119
trad_frame_set_unknown
void trad_frame_set_unknown(struct trad_frame_saved_reg this_saved_regs[], int regnum)
Definition: trad-frame.c:133
regcache
Definition: regcache.h:232
gdbarch_info
Definition: gdbarch.h:1626
sparc64_sol2_collect_core_gregset
static void sparc64_sol2_collect_core_gregset(const struct regset *regset, const struct regcache *regcache, int regnum, void *gregs, size_t len)
Definition: sparc64-sol2-tdep.c:63
SPARC64_FPRS_REGNUM
Definition: sparc64-tdep.h:57
sparc64_sol2_fpregmap
const struct sparc_fpregmap sparc64_sol2_fpregmap
Definition: sparc64-sol2-tdep.c:48
regset.h
sparc64_sol2_init_abi
void sparc64_sol2_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: sparc64-sol2-tdep.c:205
gdbarch_tdep::plt_entry_size
size_t plt_entry_size
Definition: sparc-tdep.h:83
set_gdbarch_skip_solib_resolver
void set_gdbarch_skip_solib_resolver(struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype skip_solib_resolver)
Definition: gdbarch.c:3333
sparc_frame_cache
Definition: sparc-tdep.h:167
frame_id
Definition: frame.h:111
sparc64_sol2_sigtramp_frame_cache
static struct sparc_frame_cache * sparc64_sol2_sigtramp_frame_cache(struct frame_info *this_frame, void **this_cache)
Definition: sparc64-sol2-tdep.c:102
sparc64_sol2_sigtramp_frame_sniffer
static int sparc64_sol2_sigtramp_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_cache)
Definition: sparc64-sol2-tdep.c:179
SPARC64_CCR_REGNUM
Definition: sparc64-tdep.h:67