gdb/gdbserver/
[deliverable/binutils-gdb.git] / gdb / hppaobsd-tdep.c
CommitLineData
af5ca30d
NH
1/* Target-dependent code for OpenBSD/hppa
2
4c38e0a4
JB
3 Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010
4 Free Software Foundation, Inc.
af5ca30d
NH
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
5b1ba0e5 10 the Free Software Foundation; either version 3 of the License, or
af5ca30d
NH
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
5b1ba0e5 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
af5ca30d
NH
20
21#include "defs.h"
22#include "osabi.h"
23#include "regcache.h"
24#include "regset.h"
25
26#include "gdb_assert.h"
27#include "gdb_string.h"
28
29#include "hppa-tdep.h"
63807e1d 30#include "hppabsd-tdep.h"
af5ca30d
NH
31
32/* Core file support. */
33
34/* Sizeof `struct reg' in <machine/reg.h>. */
35#define HPPABSD_SIZEOF_GREGS (34 * 4)
36
37/* Supply register REGNUM from the buffer specified by GREGS and LEN
38 in the general-purpose register set REGSET to register cache
39 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
40
41static void
42hppabsd_supply_gregset (const struct regset *regset, struct regcache *regcache,
43 int regnum, const void *gregs, size_t len)
44{
45 const gdb_byte *regs = gregs;
46 size_t offset;
47 int i;
48
49 gdb_assert (len >= HPPABSD_SIZEOF_GREGS);
50
51 for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4)
52 {
53 if (regnum == -1 || regnum == i)
54 regcache_raw_supply (regcache, i, regs + offset);
55 }
56
57 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
58 regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs);
59 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
60 regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4);
61 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
62 regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4);
63}
64
65/* OpenBSD/hppa register set. */
66
67static struct regset hppabsd_gregset =
68{
69 NULL,
70 hppabsd_supply_gregset
71};
72
73/* Return the appropriate register set for the core section identified
74 by SECT_NAME and SECT_SIZE. */
75
76static const struct regset *
77hppaobsd_regset_from_core_section (struct gdbarch *gdbarch,
78 const char *sect_name, size_t sect_size)
79{
80 if (strcmp (sect_name, ".reg") == 0 && sect_size >= HPPABSD_SIZEOF_GREGS)
81 return &hppabsd_gregset;
82
83 return NULL;
84}
85\f
86
63807e1d 87static void
af5ca30d
NH
88hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
89{
90 /* Obviously OpenBSD is BSD-based. */
91 hppabsd_init_abi (info, gdbarch);
92
93 /* Core file support. */
94 set_gdbarch_regset_from_core_section
95 (gdbarch, hppaobsd_regset_from_core_section);
96
97}
98\f
99
100/* OpenBSD uses uses the traditional NetBSD core file format, even for
101 ports that use ELF. */
102#define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF
103
104static enum gdb_osabi
105hppaobsd_core_osabi_sniffer (bfd *abfd)
106{
107 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
108 return GDB_OSABI_NETBSD_CORE;
109
110 return GDB_OSABI_UNKNOWN;
111}
112\f
113
114/* Provide a prototype to silence -Wmissing-prototypes. */
115void _initialize_hppabsd_tdep (void);
116
117void
118_initialize_hppabsd_tdep (void)
119{
120 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
121 gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour,
122 hppaobsd_core_osabi_sniffer);
123
124 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF,
125 hppaobsd_init_abi);
126}
This page took 0.276875 seconds and 4 git commands to generate.