* config/tc-xtensa.c (xtensa_move_labels): Remove loops_ok argument.
[deliverable/binutils-gdb.git] / gdb / ppcnbsd-tdep.c
CommitLineData
def18405 1/* Target-dependent code for NetBSD/powerpc.
476be15e 2
6aba47ca
DJ
3 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
4 Free Software Foundation, Inc.
476be15e 5
485721b1
JT
6 Contributed by Wasabi Systems, Inc.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
197e01b6
EZ
22 Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. */
485721b1
JT
24
25#include "defs.h"
def18405 26#include "gdbtypes.h"
4be87837 27#include "osabi.h"
def18405
MK
28#include "regcache.h"
29#include "regset.h"
30#include "trad-frame.h"
31#include "tramp-frame.h"
32
33#include "gdb_assert.h"
34#include "gdb_string.h"
485721b1
JT
35
36#include "ppc-tdep.h"
37#include "ppcnbsd-tdep.h"
485721b1
JT
38#include "solib-svr4.h"
39
def18405
MK
40/* Register offsets from <machine/reg.h>. */
41struct ppc_reg_offsets ppcnbsd_reg_offsets;
42\f
485721b1 43
def18405 44/* Core file support. */
485721b1 45
1e17aef8 46/* NetBSD/powerpc register sets. */
485721b1 47
def18405 48struct regset ppcnbsd_gregset =
485721b1 49{
def18405
MK
50 &ppcnbsd_reg_offsets,
51 ppc_supply_gregset
52};
485721b1 53
def18405 54struct regset ppcnbsd_fpregset =
485721b1 55{
def18405
MK
56 &ppcnbsd_reg_offsets,
57 ppc_supply_fpregset
58};
485721b1 59
def18405
MK
60/* Return the appropriate register set for the core section identified
61 by SECT_NAME and SECT_SIZE. */
485721b1 62
def18405
MK
63static const struct regset *
64ppcnbsd_regset_from_core_section (struct gdbarch *gdbarch,
65 const char *sect_name, size_t sect_size)
485721b1 66{
def18405
MK
67 if (strcmp (sect_name, ".reg") == 0 && sect_size >= 148)
68 return &ppcnbsd_gregset;
485721b1 69
def18405
MK
70 if (strcmp (sect_name, ".reg2") == 0 && sect_size >= 264)
71 return &ppcnbsd_fpregset;
485721b1 72
def18405 73 return NULL;
485721b1 74}
def18405 75\f
485721b1 76
def18405 77/* NetBSD is confused. It appears that 1.5 was using the correct SVR4
957e27ac
AC
78 convention but, 1.6 switched to the below broken convention. For
79 the moment use the broken convention. Ulgh!. */
80
05580c65
AC
81static enum return_value_convention
82ppcnbsd_return_value (struct gdbarch *gdbarch, struct type *valtype,
21f79b33
NW
83 struct regcache *regcache, gdb_byte *readbuf,
84 const gdb_byte *writebuf)
05580c65 85{
def18405 86#if 0
05580c65
AC
87 if ((TYPE_CODE (valtype) == TYPE_CODE_STRUCT
88 || TYPE_CODE (valtype) == TYPE_CODE_UNION)
89 && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8)
90 && TYPE_VECTOR (valtype))
91 && !(TYPE_LENGTH (valtype) == 1
92 || TYPE_LENGTH (valtype) == 2
93 || TYPE_LENGTH (valtype) == 4
94 || TYPE_LENGTH (valtype) == 8))
95 return RETURN_VALUE_STRUCT_CONVENTION;
96 else
def18405 97#endif
05580c65 98 return ppc_sysv_abi_broken_return_value (gdbarch, valtype, regcache,
963e2bb7 99 readbuf, writebuf);
957e27ac 100}
def18405
MK
101\f
102
103/* Signal trampolines. */
104
105static const struct tramp_frame ppcnbsd2_sigtramp;
957e27ac 106
476be15e
AC
107static void
108ppcnbsd_sigtramp_cache_init (const struct tramp_frame *self,
109 struct frame_info *next_frame,
110 struct trad_frame_cache *this_cache,
111 CORE_ADDR func)
112{
476be15e
AC
113 struct gdbarch *gdbarch = get_frame_arch (next_frame);
114 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
def18405
MK
115 CORE_ADDR addr, base;
116 int i;
476be15e
AC
117
118 base = frame_unwind_register_unsigned (next_frame, SP_REGNUM);
def18405
MK
119 if (self == &ppcnbsd2_sigtramp)
120 addr = base + 0x10 + 2 * tdep->wordsize;
121 else
122 addr = base + 0x18 + 2 * tdep->wordsize;
123 for (i = 0; i < ppc_num_gprs; i++, addr += tdep->wordsize)
476be15e
AC
124 {
125 int regnum = i + tdep->ppc_gp0_regnum;
def18405 126 trad_frame_set_reg_addr (this_cache, regnum, addr);
476be15e 127 }
def18405
MK
128 trad_frame_set_reg_addr (this_cache, tdep->ppc_lr_regnum, addr);
129 addr += tdep->wordsize;
130 trad_frame_set_reg_addr (this_cache, tdep->ppc_cr_regnum, addr);
131 addr += tdep->wordsize;
132 trad_frame_set_reg_addr (this_cache, tdep->ppc_xer_regnum, addr);
133 addr += tdep->wordsize;
134 trad_frame_set_reg_addr (this_cache, tdep->ppc_ctr_regnum, addr);
135 addr += tdep->wordsize;
136 trad_frame_set_reg_addr (this_cache, PC_REGNUM, addr); /* SRR0? */
137 addr += tdep->wordsize;
476be15e
AC
138
139 /* Construct the frame ID using the function start. */
140 trad_frame_set_id (this_cache, frame_id_build (base, func));
141}
142
def18405
MK
143static const struct tramp_frame ppcnbsd_sigtramp =
144{
145 SIGTRAMP_FRAME,
146 4,
147 {
148 { 0x3821fff0, -1 }, /* add r1,r1,-16 */
149 { 0x4e800021, -1 }, /* blrl */
150 { 0x38610018, -1 }, /* addi r3,r1,24 */
151 { 0x38000127, -1 }, /* li r0,295 */
152 { 0x44000002, -1 }, /* sc */
153 { 0x38000001, -1 }, /* li r0,1 */
154 { 0x44000002, -1 }, /* sc */
155 { TRAMP_SENTINEL_INSN, -1 }
156 },
157 ppcnbsd_sigtramp_cache_init
158};
159
160/* NetBSD 2.0 introduced a slightly different signal trampoline. */
476be15e 161
def18405
MK
162static const struct tramp_frame ppcnbsd2_sigtramp =
163{
2cd8546d 164 SIGTRAMP_FRAME,
def18405
MK
165 4,
166 {
167 { 0x3821fff0, -1 }, /* add r1,r1,-16 */
168 { 0x4e800021, -1 }, /* blrl */
169 { 0x38610010, -1 }, /* addi r3,r1,16 */
170 { 0x38000127, -1 }, /* li r0,295 */
171 { 0x44000002, -1 }, /* sc */
172 { 0x38000001, -1 }, /* li r0,1 */
173 { 0x44000002, -1 }, /* sc */
2cd8546d 174 { TRAMP_SENTINEL_INSN, -1 }
476be15e
AC
175 },
176 ppcnbsd_sigtramp_cache_init
177};
def18405 178\f
476be15e 179
485721b1
JT
180static void
181ppcnbsd_init_abi (struct gdbarch_info info,
182 struct gdbarch *gdbarch)
183{
e754ae69
AC
184 /* For NetBSD, this is an on again, off again thing. Some systems
185 do use the broken struct convention, and some don't. */
05580c65 186 set_gdbarch_return_value (gdbarch, ppcnbsd_return_value);
def18405
MK
187
188 /* NetBSD uses SVR4-style shared libraries. */
189 set_solib_svr4_fetch_link_map_offsets
190 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
191
192 set_gdbarch_regset_from_core_section
193 (gdbarch, ppcnbsd_regset_from_core_section);
194
476be15e 195 tramp_frame_prepend_unwinder (gdbarch, &ppcnbsd_sigtramp);
def18405 196 tramp_frame_prepend_unwinder (gdbarch, &ppcnbsd2_sigtramp);
485721b1 197}
def18405
MK
198\f
199
200/* Provide a prototype to silence -Wmissing-prototypes. */
201void _initialize_ppcnbsd_tdep (void);
485721b1
JT
202
203void
204_initialize_ppcnbsd_tdep (void)
205{
05816f70 206 gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_NETBSD_ELF,
485721b1
JT
207 ppcnbsd_init_abi);
208
def18405
MK
209 /* Avoid initializing the register offsets again if they were
210 already initailized by ppcnbsd-nat.c. */
211 if (ppcnbsd_reg_offsets.pc_offset == 0)
212 {
213 /* General-purpose registers. */
214 ppcnbsd_reg_offsets.r0_offset = 0;
215 ppcnbsd_reg_offsets.lr_offset = 128;
216 ppcnbsd_reg_offsets.cr_offset = 132;
217 ppcnbsd_reg_offsets.xer_offset = 136;
218 ppcnbsd_reg_offsets.ctr_offset = 140;
219 ppcnbsd_reg_offsets.pc_offset = 144;
220 ppcnbsd_reg_offsets.ps_offset = -1;
221 ppcnbsd_reg_offsets.mq_offset = -1;
222
223 /* Floating-point registers. */
224 ppcnbsd_reg_offsets.f0_offset = 0;
225 ppcnbsd_reg_offsets.fpscr_offset = 256;
226
227 /* AltiVec registers. */
228 ppcnbsd_reg_offsets.vr0_offset = 0;
229 ppcnbsd_reg_offsets.vrsave_offset = 512;
230 ppcnbsd_reg_offsets.vscr_offset = 524;
231 }
485721b1 232}
This page took 0.432957 seconds and 4 git commands to generate.