Add ravenscar-thread support for powerpc.
[deliverable/binutils-gdb.git] / gdb / hppaobsd-tdep.c
CommitLineData
af5ca30d
NH
1/* Target-dependent code for OpenBSD/hppa
2
0b302171 3 Copyright (C) 2004-2006, 2008-2012 Free Software Foundation, Inc.
af5ca30d
NH
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
5b1ba0e5 9 the Free Software Foundation; either version 3 of the License, or
af5ca30d
NH
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
5b1ba0e5 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
af5ca30d
NH
19
20#include "defs.h"
21#include "osabi.h"
22#include "regcache.h"
23#include "regset.h"
24
25#include "gdb_assert.h"
26#include "gdb_string.h"
27
28#include "hppa-tdep.h"
63807e1d 29#include "hppabsd-tdep.h"
af5ca30d
NH
30
31/* Core file support. */
32
33/* Sizeof `struct reg' in <machine/reg.h>. */
7c54a108
MK
34#define HPPAOBSD_SIZEOF_GREGS (34 * 4)
35
36/* Sizeof `struct fpreg' in <machine/reg.h>. */
37#define HPPAOBSD_SIZEOF_FPREGS (32 * 8)
af5ca30d
NH
38
39/* Supply register REGNUM from the buffer specified by GREGS and LEN
40 in the general-purpose register set REGSET to register cache
41 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
42
43static void
7c54a108
MK
44hppaobsd_supply_gregset (const struct regset *regset,
45 struct regcache *regcache,
46 int regnum, const void *gregs, size_t len)
af5ca30d
NH
47{
48 const gdb_byte *regs = gregs;
49 size_t offset;
50 int i;
51
7c54a108 52 gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS);
af5ca30d
NH
53
54 for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4)
55 {
56 if (regnum == -1 || regnum == i)
57 regcache_raw_supply (regcache, i, regs + offset);
58 }
59
60 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
61 regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs);
62 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
63 regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4);
64 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
65 regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4);
66}
67
7c54a108
MK
68/* Supply register REGNUM from the buffer specified by FPREGS and LEN
69 in the floating-point register set REGSET to register cache
70 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
71
72static void
73hppaobsd_supply_fpregset (const struct regset *regset,
74 struct regcache *regcache,
75 int regnum, const void *fpregs, size_t len)
76{
77 struct gdbarch *gdbarch = get_regcache_arch (regcache);
78 const gdb_byte *regs = fpregs;
79 int i;
80
81 gdb_assert (len >= HPPAOBSD_SIZEOF_FPREGS);
82
83 for (i = HPPA_FP0_REGNUM; i <= HPPA_FP31R_REGNUM; i++)
84 {
85 if (regnum == i || regnum == -1)
86 regcache_raw_supply (regcache, i, regs + (i - HPPA_FP0_REGNUM) * 4);
87 }
88}
89
90/* OpenBSD/hppa register sets. */
af5ca30d 91
7c54a108 92static struct regset hppaobsd_gregset =
af5ca30d
NH
93{
94 NULL,
7c54a108
MK
95 hppaobsd_supply_gregset
96};
97
98static struct regset hppaobsd_fpregset =
99{
100 NULL,
101 hppaobsd_supply_fpregset
af5ca30d
NH
102};
103
104/* Return the appropriate register set for the core section identified
105 by SECT_NAME and SECT_SIZE. */
106
107static const struct regset *
108hppaobsd_regset_from_core_section (struct gdbarch *gdbarch,
109 const char *sect_name, size_t sect_size)
110{
7c54a108
MK
111 if (strcmp (sect_name, ".reg") == 0 && sect_size >= HPPAOBSD_SIZEOF_GREGS)
112 return &hppaobsd_gregset;
113
114 if (strcmp (sect_name, ".reg2") == 0 && sect_size >= HPPAOBSD_SIZEOF_FPREGS)
115 return &hppaobsd_fpregset;
af5ca30d
NH
116
117 return NULL;
118}
119\f
120
63807e1d 121static void
af5ca30d
NH
122hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
123{
124 /* Obviously OpenBSD is BSD-based. */
125 hppabsd_init_abi (info, gdbarch);
126
127 /* Core file support. */
128 set_gdbarch_regset_from_core_section
129 (gdbarch, hppaobsd_regset_from_core_section);
af5ca30d
NH
130}
131\f
132
133/* OpenBSD uses uses the traditional NetBSD core file format, even for
134 ports that use ELF. */
135#define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF
136
137static enum gdb_osabi
138hppaobsd_core_osabi_sniffer (bfd *abfd)
139{
140 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
141 return GDB_OSABI_NETBSD_CORE;
142
143 return GDB_OSABI_UNKNOWN;
144}
145\f
146
147/* Provide a prototype to silence -Wmissing-prototypes. */
148void _initialize_hppabsd_tdep (void);
149
150void
151_initialize_hppabsd_tdep (void)
152{
153 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
154 gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour,
155 hppaobsd_core_osabi_sniffer);
156
157 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF,
158 hppaobsd_init_abi);
159}
This page took 0.421842 seconds and 4 git commands to generate.