OLD | NEW |
1 /* Target-dependent code for OpenBSD/hppa | 1 /* Target-dependent code for OpenBSD/hppa |
2 | 2 |
3 Copyright (C) 2004-2006, 2008-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2004-2013 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GDB. | 5 This file is part of GDB. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 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 | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
11 | 11 |
12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
19 | 19 |
20 #include "defs.h" | 20 #include "defs.h" |
21 #include "osabi.h" | 21 #include "osabi.h" |
22 #include "regcache.h" | 22 #include "regcache.h" |
23 #include "regset.h" | 23 #include "regset.h" |
24 | 24 |
25 #include "gdb_assert.h" | 25 #include "gdb_assert.h" |
26 #include "gdb_string.h" | 26 #include <string.h> |
27 | 27 |
28 #include "hppa-tdep.h" | 28 #include "hppa-tdep.h" |
29 #include "hppabsd-tdep.h" | 29 #include "hppabsd-tdep.h" |
30 | 30 |
31 /* Core file support. */ | 31 /* Core file support. */ |
32 | 32 |
33 /* Sizeof `struct reg' in <machine/reg.h>. */ | 33 /* Sizeof `struct reg' in <machine/reg.h>. */ |
34 #define HPPAOBSD_SIZEOF_GREGS» (34 * 4) | 34 #define HPPAOBSD_SIZEOF_GREGS» (34 * 4) /* OpenBSD 5.1 and earlier. */ |
| 35 #define HPPANBSD_SIZEOF_GREGS» (46 * 4) /* NetBSD and OpenBSD 5.2 and later. *
/ |
35 | 36 |
36 /* Sizeof `struct fpreg' in <machine/reg.h>. */ | 37 /* Sizeof `struct fpreg' in <machine/reg.h>. */ |
37 #define HPPAOBSD_SIZEOF_FPREGS (32 * 8) | 38 #define HPPAOBSD_SIZEOF_FPREGS (32 * 8) |
38 | 39 |
39 /* Supply register REGNUM from the buffer specified by GREGS and LEN | 40 /* Supply register REGNUM from the buffer specified by GREGS and LEN |
40 in the general-purpose register set REGSET to register cache | 41 in the general-purpose register set REGSET to register cache |
41 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ | 42 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ |
42 | 43 |
43 static void | 44 static void |
44 hppaobsd_supply_gregset (const struct regset *regset, | 45 hppaobsd_supply_gregset (const struct regset *regset, |
45 struct regcache *regcache, | 46 struct regcache *regcache, |
46 int regnum, const void *gregs, size_t len) | 47 int regnum, const void *gregs, size_t len) |
47 { | 48 { |
| 49 gdb_byte zero[4] = { 0 }; |
48 const gdb_byte *regs = gregs; | 50 const gdb_byte *regs = gregs; |
49 size_t offset; | 51 size_t offset; |
50 int i; | 52 int i; |
51 | 53 |
52 gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS); | 54 gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS); |
53 | 55 |
| 56 if (regnum == -1 || regnum == HPPA_R0_REGNUM) |
| 57 regcache_raw_supply (regcache, HPPA_R0_REGNUM, &zero); |
54 for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4) | 58 for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4) |
55 { | 59 { |
56 if (regnum == -1 || regnum == i) | 60 if (regnum == -1 || regnum == i) |
57 regcache_raw_supply (regcache, i, regs + offset); | 61 regcache_raw_supply (regcache, i, regs + offset); |
58 } | 62 } |
59 | 63 |
60 if (regnum == -1 || regnum == HPPA_SAR_REGNUM) | 64 if (len >= HPPANBSD_SIZEOF_GREGS) |
61 regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs); | 65 { |
62 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM) | 66 if (regnum == -1 || regnum == HPPA_IPSW_REGNUM) |
63 regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4); | 67 » regcache_raw_supply (regcache, HPPA_IPSW_REGNUM, regs); |
64 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM) | 68 if (regnum == -1 || regnum == HPPA_SAR_REGNUM) |
65 regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4); | 69 » regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs + 32 * 4); |
| 70 if (regnum == -1 || regnum == HPPA_PCSQ_HEAD_REGNUM) |
| 71 » regcache_raw_supply (regcache, HPPA_PCSQ_HEAD_REGNUM, regs + 33 * 4); |
| 72 if (regnum == -1 || regnum == HPPA_PCSQ_TAIL_REGNUM) |
| 73 » regcache_raw_supply (regcache, HPPA_PCSQ_TAIL_REGNUM, regs + 34 * 4); |
| 74 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM) |
| 75 » regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 35 * 4); |
| 76 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM) |
| 77 » regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 36 * 4); |
| 78 if (regnum == -1 || regnum == HPPA_SR0_REGNUM) |
| 79 » regcache_raw_supply (regcache, HPPA_SR0_REGNUM, regs + 37 * 4); |
| 80 if (regnum == -1 || regnum == HPPA_SR1_REGNUM) |
| 81 » regcache_raw_supply (regcache, HPPA_SR1_REGNUM, regs + 38 * 4); |
| 82 if (regnum == -1 || regnum == HPPA_SR2_REGNUM) |
| 83 » regcache_raw_supply (regcache, HPPA_SR2_REGNUM, regs + 39 * 4); |
| 84 if (regnum == -1 || regnum == HPPA_SR3_REGNUM) |
| 85 » regcache_raw_supply (regcache, HPPA_SR3_REGNUM, regs + 40 * 4); |
| 86 if (regnum == -1 || regnum == HPPA_SR4_REGNUM) |
| 87 » regcache_raw_supply (regcache, HPPA_SR4_REGNUM, regs + 41 * 4); |
| 88 if (regnum == -1 || regnum == HPPA_SR5_REGNUM) |
| 89 » regcache_raw_supply (regcache, HPPA_SR5_REGNUM, regs + 42 * 4); |
| 90 if (regnum == -1 || regnum == HPPA_SR6_REGNUM) |
| 91 » regcache_raw_supply (regcache, HPPA_SR6_REGNUM, regs + 43 * 4); |
| 92 if (regnum == -1 || regnum == HPPA_SR7_REGNUM) |
| 93 » regcache_raw_supply (regcache, HPPA_SR7_REGNUM, regs + 44 * 4); |
| 94 if (regnum == -1 || regnum == HPPA_CR26_REGNUM) |
| 95 » regcache_raw_supply (regcache, HPPA_CR26_REGNUM, regs + 45 * 4); |
| 96 if (regnum == -1 || regnum == HPPA_CR27_REGNUM) |
| 97 » regcache_raw_supply (regcache, HPPA_CR27_REGNUM, regs + 46 * 4); |
| 98 } |
| 99 else |
| 100 { |
| 101 if (regnum == -1 || regnum == HPPA_SAR_REGNUM) |
| 102 » regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs); |
| 103 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM) |
| 104 » regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4); |
| 105 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM) |
| 106 » regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4); |
| 107 } |
66 } | 108 } |
67 | 109 |
68 /* Supply register REGNUM from the buffer specified by FPREGS and LEN | 110 /* Supply register REGNUM from the buffer specified by FPREGS and LEN |
69 in the floating-point register set REGSET to register cache | 111 in the floating-point register set REGSET to register cache |
70 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ | 112 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ |
71 | 113 |
72 static void | 114 static void |
73 hppaobsd_supply_fpregset (const struct regset *regset, | 115 hppaobsd_supply_fpregset (const struct regset *regset, |
74 struct regcache *regcache, | 116 struct regcache *regcache, |
75 int regnum, const void *fpregs, size_t len) | 117 int regnum, const void *fpregs, size_t len) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 void | 195 void |
154 _initialize_hppabsd_tdep (void) | 196 _initialize_hppabsd_tdep (void) |
155 { | 197 { |
156 /* BFD doesn't set a flavour for NetBSD style a.out core files. */ | 198 /* BFD doesn't set a flavour for NetBSD style a.out core files. */ |
157 gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour, | 199 gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour, |
158 hppaobsd_core_osabi_sniffer); | 200 hppaobsd_core_osabi_sniffer); |
159 | 201 |
160 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF, | 202 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF, |
161 hppaobsd_init_abi); | 203 hppaobsd_init_abi); |
162 } | 204 } |
OLD | NEW |