* mips64obsd-nat.c, mips64obsd-tdep.c: New files.
[external/binutils.git] / gdb / mips64obsd-tdep.c
1 /* Target-dependent code for OpenBSD/mips64.
2
3    Copyright 2004 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 2 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, write to the Free Software
19    Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.  */
21
22 #include "defs.h"
23 #include "osabi.h"
24 #include "regcache.h"
25 #include "regset.h"
26
27 #include "gdb_string.h"
28
29 #include "mips-tdep.h"
30 #include "solib-svr4.h"
31
32 #define MIPS64OBSD_NUM_REGS 73
33
34 /* Core file support.  */
35
36 /* Supply register REGNUM from the buffer specified by GREGS and LEN
37    in the general-purpose register set REGSET to register cache
38    REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
39
40 static void
41 mips64obsd_supply_gregset (const struct regset *regset,
42                            struct regcache *regcache, int regnum,
43                            const void *gregs, size_t len)
44 {
45   const char *regs = gregs;
46   int i;
47
48   for (i = 0; i < MIPS64OBSD_NUM_REGS; i++)
49     {
50       if (regnum == i || regnum == -1)
51         regcache_raw_supply (regcache, i, regs + i * 8);
52     }
53 }
54
55 /* OpenBSD/mips64 register set.  */
56
57 static struct regset mips64obsd_gregset =
58 {
59   NULL,
60   mips64obsd_supply_gregset
61 };
62
63 /* Return the appropriate register set for the core section identified
64    by SECT_NAME and SECT_SIZE.  */
65
66 static const struct regset *
67 mips64obsd_regset_from_core_section (struct gdbarch *gdbarch,
68                                      const char *sect_name, size_t sect_size)
69 {
70   if (strcmp (sect_name, ".reg") == 0 && sect_size >= MIPS64OBSD_NUM_REGS * 8)
71     return &mips64obsd_gregset;
72
73   return NULL;
74 }
75 \f
76
77 static void
78 mips64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
79 {
80   set_gdbarch_regset_from_core_section
81     (gdbarch, mips64obsd_regset_from_core_section);
82
83   set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
84
85   set_solib_svr4_fetch_link_map_offsets
86     (gdbarch, svr4_lp64_fetch_link_map_offsets);
87 }
88
89 \f
90 /* Provide a prototype to silence -Wmissing-prototypes.  */
91 void _initialize_mips64obsd_tdep (void);
92
93 void
94 _initialize_mips64obsd_tdep (void)
95 {
96   gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_OPENBSD_ELF,
97                           mips64obsd_init_abi);
98 }