Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / hppaobsd-tdep.c
blob8798f7e194de0d4359b493d4c5ee6dff97d83139
1 /* Target-dependent code for OpenBSD/hppa
3 Copyright (C) 2004, 2005, 2006 Free Software Foundation, 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., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 #include "defs.h"
23 #include "arch-utils.h"
24 #include "symtab.h"
25 #include "objfiles.h"
26 #include "osabi.h"
27 #include "regcache.h"
28 #include "regset.h"
29 #include "target.h"
30 #include "value.h"
32 #include "gdb_assert.h"
33 #include "gdb_string.h"
35 #include "elf/common.h"
37 #include "hppa-tdep.h"
38 #include "solib-svr4.h"
40 /* Core file support. */
42 /* Sizeof `struct reg' in <machine/reg.h>. */
43 #define HPPABSD_SIZEOF_GREGS (34 * 4)
45 /* Supply register REGNUM from the buffer specified by GREGS and LEN
46 in the general-purpose register set REGSET to register cache
47 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
49 static void
50 hppabsd_supply_gregset (const struct regset *regset, struct regcache *regcache,
51 int regnum, const void *gregs, size_t len)
53 const gdb_byte *regs = gregs;
54 size_t offset;
55 int i;
57 gdb_assert (len >= HPPABSD_SIZEOF_GREGS);
59 for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4)
61 if (regnum == -1 || regnum == i)
62 regcache_raw_supply (regcache, i, regs + offset);
65 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
66 regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs);
67 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
68 regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4);
69 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
70 regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4);
73 /* OpenBSD/hppa register set. */
75 static struct regset hppabsd_gregset =
77 NULL,
78 hppabsd_supply_gregset
81 /* Return the appropriate register set for the core section identified
82 by SECT_NAME and SECT_SIZE. */
84 static const struct regset *
85 hppabsd_regset_from_core_section (struct gdbarch *gdbarch,
86 const char *sect_name, size_t sect_size)
88 if (strcmp (sect_name, ".reg") == 0 && sect_size >= HPPABSD_SIZEOF_GREGS)
89 return &hppabsd_gregset;
91 return NULL;
95 void hppabsd_init_abi (struct gdbarch_info, struct gdbarch *);
97 void
98 hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
100 /* Obviously OpenBSD is BSD-based. */
101 hppabsd_init_abi (info, gdbarch);
103 /* Core file support. */
104 set_gdbarch_regset_from_core_section
105 (gdbarch, hppaobsd_regset_from_core_section);
110 /* OpenBSD uses uses the traditional NetBSD core file format, even for
111 ports that use ELF. */
112 #define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF
114 static enum gdb_osabi
115 hppaobsd_core_osabi_sniffer (bfd *abfd)
117 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
118 return GDB_OSABI_NETBSD_CORE;
120 return GDB_OSABI_UNKNOWN;
124 /* Provide a prototype to silence -Wmissing-prototypes. */
125 void _initialize_hppabsd_tdep (void);
127 void
128 _initialize_hppabsd_tdep (void)
130 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
131 gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour,
132 hppaobsd_core_osabi_sniffer);
134 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF,
135 hppaobsd_init_abi);