1 /* Target-dependent code for SuperH running NetBSD, for GDB.
2 Copyright 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Wasabi Systems, 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. */
28 #include "solib-svr4.h"
30 #include "nbsd-tdep.h"
32 #include "shnbsd-tdep.h"
34 /* Convert an r0-r15 register number into an offset into a ptrace
35 register structure. */
36 static const int regmap[] =
56 #define SIZEOF_STRUCT_REG (21 * 4)
59 shnbsd_supply_reg (char *regs, int regno)
63 if (regno == PC_REGNUM || regno == -1)
64 regcache_raw_supply (current_regcache, PC_REGNUM, regs + (0 * 4));
66 if (regno == SR_REGNUM || regno == -1)
67 regcache_raw_supply (current_regcache, SR_REGNUM, regs + (1 * 4));
69 if (regno == PR_REGNUM || regno == -1)
70 regcache_raw_supply (current_regcache, PR_REGNUM, regs + (2 * 4));
72 if (regno == MACH_REGNUM || regno == -1)
73 regcache_raw_supply (current_regcache, MACH_REGNUM, regs + (3 * 4));
75 if (regno == MACL_REGNUM || regno == -1)
76 regcache_raw_supply (current_regcache, MACL_REGNUM, regs + (4 * 4));
78 if ((regno >= R0_REGNUM && regno <= (R0_REGNUM + 15)) || regno == -1)
80 for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
81 if (regno == i || regno == -1)
82 regcache_raw_supply (current_regcache, i,
83 regs + regmap[i - R0_REGNUM]);
88 shnbsd_fill_reg (char *regs, int regno)
92 if (regno == PC_REGNUM || regno == -1)
93 regcache_raw_collect (current_regcache, PC_REGNUM, regs + (0 * 4));
95 if (regno == SR_REGNUM || regno == -1)
96 regcache_raw_collect (current_regcache, SR_REGNUM, regs + (1 * 4));
98 if (regno == PR_REGNUM || regno == -1)
99 regcache_raw_collect (current_regcache, PR_REGNUM, regs + (2 * 4));
101 if (regno == MACH_REGNUM || regno == -1)
102 regcache_raw_collect (current_regcache, MACH_REGNUM, regs + (3 * 4));
104 if (regno == MACL_REGNUM || regno == -1)
105 regcache_raw_collect (current_regcache, MACL_REGNUM, regs + (4 * 4));
107 if ((regno >= R0_REGNUM && regno <= (R0_REGNUM + 15)) || regno == -1)
109 for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
110 if (regno == i || regno == -1)
111 regcache_raw_collect (current_regcache, i,
112 regs + regmap[i - R0_REGNUM]);
117 fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
118 int which, CORE_ADDR ignore)
120 /* We get everything from the .reg section. */
124 if (core_reg_size < SIZEOF_STRUCT_REG)
126 warning ("Wrong size register set in core file.");
130 /* Integer registers. */
131 shnbsd_supply_reg (core_reg_sect, -1);
135 fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size,
136 int which, CORE_ADDR ignore)
140 case 0: /* Integer registers. */
141 if (core_reg_size != SIZEOF_STRUCT_REG)
142 warning ("Wrong size register set in core file.");
144 shnbsd_supply_reg (core_reg_sect, -1);
148 /* Don't know what kind of register request this is; just ignore it. */
153 static struct core_fns shnbsd_core_fns =
155 bfd_target_unknown_flavour, /* core_flavour */
156 default_check_format, /* check_format */
157 default_core_sniffer, /* core_sniffer */
158 fetch_core_registers, /* core_read_registers */
162 static struct core_fns shnbsd_elfcore_fns =
164 bfd_target_elf_flavour, /* core_flavour */
165 default_check_format, /* check_format */
166 default_core_sniffer, /* core_sniffer */
167 fetch_elfcore_registers, /* core_read_registers */
172 shnbsd_init_abi (struct gdbarch_info info,
173 struct gdbarch *gdbarch)
175 set_solib_svr4_fetch_link_map_offsets (gdbarch,
176 nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
180 _initialize_shnbsd_tdep (void)
182 deprecated_add_core_fns (&shnbsd_core_fns);
183 deprecated_add_core_fns (&shnbsd_elfcore_fns);
185 gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_NETBSD_ELF,