1 /* Target-dependent code for Solaris SPARC.
3 Copyright (C) 2003-2020 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"
30 #include "trad-frame.h"
32 #include "sol2-tdep.h"
33 #include "sparc-tdep.h"
34 #include "solib-svr4.h"
36 /* From <sys/regset.h>. */
37 const struct sparc_gregmap sparc32_sol2_gregmap
=
49 const struct sparc_fpregmap sparc32_sol2_fpregmap
=
56 sparc32_sol2_supply_core_gregset (const struct regset
*regset
,
57 struct regcache
*regcache
,
58 int regnum
, const void *gregs
, size_t len
)
60 sparc32_supply_gregset (&sparc32_sol2_gregmap
, regcache
, regnum
, gregs
);
64 sparc32_sol2_collect_core_gregset (const struct regset
*regset
,
65 const struct regcache
*regcache
,
66 int regnum
, void *gregs
, size_t len
)
68 sparc32_collect_gregset (&sparc32_sol2_gregmap
, regcache
, regnum
, gregs
);
72 sparc32_sol2_supply_core_fpregset (const struct regset
*regset
,
73 struct regcache
*regcache
,
74 int regnum
, const void *fpregs
, size_t len
)
76 sparc32_supply_fpregset (&sparc32_sol2_fpregmap
, regcache
, regnum
, fpregs
);
80 sparc32_sol2_collect_core_fpregset (const struct regset
*regset
,
81 const struct regcache
*regcache
,
82 int regnum
, void *fpregs
, size_t len
)
84 sparc32_collect_fpregset (&sparc32_sol2_fpregmap
, regcache
, regnum
, fpregs
);
87 static const struct regset sparc32_sol2_gregset
=
90 sparc32_sol2_supply_core_gregset
,
91 sparc32_sol2_collect_core_gregset
94 static const struct regset sparc32_sol2_fpregset
=
97 sparc32_sol2_supply_core_fpregset
,
98 sparc32_sol2_collect_core_fpregset
102 static struct sparc_frame_cache
*
103 sparc32_sol2_sigtramp_frame_cache (struct frame_info
*this_frame
,
106 struct sparc_frame_cache
*cache
;
107 CORE_ADDR mcontext_addr
, addr
;
111 return (struct sparc_frame_cache
*) *this_cache
;
113 cache
= sparc_frame_cache (this_frame
, this_cache
);
114 gdb_assert (cache
== *this_cache
);
116 cache
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
118 /* The third argument is a pointer to an instance of `ucontext_t',
119 which has a member `uc_mcontext' that contains the saved
122 (cache
->copied_regs_mask
& 0x04) ? SPARC_I2_REGNUM
: SPARC_O2_REGNUM
;
123 mcontext_addr
= get_frame_register_unsigned (this_frame
, regnum
) + 40;
125 cache
->saved_regs
[SPARC32_PSR_REGNUM
].addr
= mcontext_addr
+ 0 * 4;
126 cache
->saved_regs
[SPARC32_PC_REGNUM
].addr
= mcontext_addr
+ 1 * 4;
127 cache
->saved_regs
[SPARC32_NPC_REGNUM
].addr
= mcontext_addr
+ 2 * 4;
128 cache
->saved_regs
[SPARC32_Y_REGNUM
].addr
= mcontext_addr
+ 3 * 4;
130 /* Since %g0 is always zero, keep the identity encoding. */
131 for (regnum
= SPARC_G1_REGNUM
, addr
= mcontext_addr
+ 4 * 4;
132 regnum
<= SPARC_O7_REGNUM
; regnum
++, addr
+= 4)
133 cache
->saved_regs
[regnum
].addr
= addr
;
135 if (get_frame_memory_unsigned (this_frame
, mcontext_addr
+ 19 * 4, 4))
137 /* The register windows haven't been flushed. */
138 for (regnum
= SPARC_L0_REGNUM
; regnum
<= SPARC_I7_REGNUM
; regnum
++)
139 trad_frame_set_unknown (cache
->saved_regs
, regnum
);
143 addr
= cache
->saved_regs
[SPARC_SP_REGNUM
].addr
;
144 addr
= get_frame_memory_unsigned (this_frame
, addr
, 4);
145 for (regnum
= SPARC_L0_REGNUM
;
146 regnum
<= SPARC_I7_REGNUM
; regnum
++, addr
+= 4)
147 cache
->saved_regs
[regnum
].addr
= addr
;
154 sparc32_sol2_sigtramp_frame_this_id (struct frame_info
*this_frame
,
156 struct frame_id
*this_id
)
158 struct sparc_frame_cache
*cache
=
159 sparc32_sol2_sigtramp_frame_cache (this_frame
, this_cache
);
161 (*this_id
) = frame_id_build (cache
->base
, cache
->pc
);
164 static struct value
*
165 sparc32_sol2_sigtramp_frame_prev_register (struct frame_info
*this_frame
,
169 struct sparc_frame_cache
*cache
=
170 sparc32_sol2_sigtramp_frame_cache (this_frame
, this_cache
);
172 return trad_frame_get_prev_register (this_frame
, cache
->saved_regs
, regnum
);
176 sparc32_sol2_sigtramp_frame_sniffer (const struct frame_unwind
*self
,
177 struct frame_info
*this_frame
,
180 return sol2_sigtramp_p (this_frame
);
183 static const struct frame_unwind sparc32_sol2_sigtramp_frame_unwind
=
186 default_frame_unwind_stop_reason
,
187 sparc32_sol2_sigtramp_frame_this_id
,
188 sparc32_sol2_sigtramp_frame_prev_register
,
190 sparc32_sol2_sigtramp_frame_sniffer
196 sparc32_sol2_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
198 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
200 tdep
->gregset
= &sparc32_sol2_gregset
;
201 tdep
->sizeof_gregset
= 152;
203 tdep
->fpregset
= &sparc32_sol2_fpregset
;
204 tdep
->sizeof_fpregset
= 400;
206 sol2_init_abi (info
, gdbarch
);
208 /* Solaris has SVR4-style shared libraries... */
209 set_gdbarch_skip_trampoline_code (gdbarch
, find_solib_trampoline_target
);
210 set_solib_svr4_fetch_link_map_offsets
211 (gdbarch
, svr4_ilp32_fetch_link_map_offsets
);
213 /* ...which means that we need some special handling when doing
214 prologue analysis. */
215 tdep
->plt_entry_size
= 12;
217 /* Solaris has kernel-assisted single-stepping support. */
218 set_gdbarch_software_single_step (gdbarch
, NULL
);
220 frame_unwind_append_unwinder (gdbarch
, &sparc32_sol2_sigtramp_frame_unwind
);
223 void _initialize_sparc_sol2_tdep ();
225 _initialize_sparc_sol2_tdep ()
227 gdbarch_register_osabi (bfd_arch_sparc
, 0,
228 GDB_OSABI_SOLARIS
, sparc32_sol2_init_abi
);