Commit | Line | Data |
---|---|---|
69517000 AC |
1 | /* Low level interface to IA-64 running AIX for GDB, the GNU debugger. |
2 | ||
3 | Copyright 2000, 2001, 2003 Free Software Foundation, Inc. | |
d7fa2ae2 KB |
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 "inferior.h" | |
24 | #include "target.h" | |
25 | #include "gdbcore.h" | |
4e052eda | 26 | #include "regcache.h" |
d7fa2ae2 KB |
27 | #include <sys/procfs.h> |
28 | ||
29 | #include "symtab.h" | |
30 | #include "bfd.h" | |
31 | #include "symfile.h" | |
32 | #include "objfiles.h" | |
33 | ||
34 | #include <sys/types.h> | |
35 | #include <fcntl.h> | |
36 | #include "gdb_stat.h" | |
37 | ||
38 | void | |
39 | supply_gregset (prgregset_t *gregsetp) | |
40 | { | |
41 | int regi; | |
42 | ||
43 | for (regi = IA64_GR0_REGNUM; regi <= IA64_GR31_REGNUM; regi++) | |
44 | { | |
23a6d369 AC |
45 | regcache_raw_supply (current_regcache, regi, |
46 | (char *) &(gregsetp->__gpr[regi - IA64_GR0_REGNUM])); | |
d7fa2ae2 KB |
47 | } |
48 | ||
49 | for (regi = IA64_BR0_REGNUM; regi <= IA64_BR7_REGNUM; regi++) | |
50 | { | |
23a6d369 AC |
51 | regcache_raw_supply (current_regcache, regi, |
52 | (char *) &(gregsetp->__br[regi - IA64_BR0_REGNUM])); | |
d7fa2ae2 KB |
53 | } |
54 | ||
23a6d369 AC |
55 | regcache_raw_supply (current_regcache, IA64_PSR_REGNUM, |
56 | (char *) &(gregsetp->__psr)); | |
57 | regcache_raw_supply (current_regcache, IA64_IP_REGNUM, | |
58 | (char *) &(gregsetp->__ip)); | |
59 | regcache_raw_supply (current_regcache, IA64_CFM_REGNUM, | |
60 | (char *) &(gregsetp->__ifs)); | |
61 | regcache_raw_supply (current_regcache, IA64_RSC_REGNUM, | |
62 | (char *) &(gregsetp->__rsc)); | |
63 | regcache_raw_supply (current_regcache, IA64_BSP_REGNUM, | |
64 | (char *) &(gregsetp->__bsp)); | |
65 | regcache_raw_supply (current_regcache, IA64_BSPSTORE_REGNUM, | |
66 | (char *) &(gregsetp->__bspstore)); | |
67 | regcache_raw_supply (current_regcache, IA64_RNAT_REGNUM, | |
68 | (char *) &(gregsetp->__rnat)); | |
69 | regcache_raw_supply (current_regcache, IA64_PFS_REGNUM, | |
70 | (char *) &(gregsetp->__pfs)); | |
71 | regcache_raw_supply (current_regcache, IA64_UNAT_REGNUM, | |
72 | (char *) &(gregsetp->__unat)); | |
73 | regcache_raw_supply (current_regcache, IA64_PR_REGNUM, | |
74 | (char *) &(gregsetp->__preds)); | |
75 | regcache_raw_supply (current_regcache, IA64_CCV_REGNUM, | |
76 | (char *) &(gregsetp->__ccv)); | |
77 | regcache_raw_supply (current_regcache, IA64_LC_REGNUM, | |
78 | (char *) &(gregsetp->__lc)); | |
79 | regcache_raw_supply (current_regcache, IA64_EC_REGNUM, | |
80 | (char *) &(gregsetp->__ec)); | |
d7fa2ae2 | 81 | /* FIXME: __nats */ |
23a6d369 AC |
82 | regcache_raw_supply (current_regcache, IA64_FPSR_REGNUM, |
83 | (char *) &(gregsetp->__fpsr)); | |
d7fa2ae2 KB |
84 | |
85 | /* These (for the most part) are pseudo registers and are obtained | |
86 | by other means. Those that aren't are already handled by the | |
87 | code above. */ | |
88 | for (regi = IA64_GR32_REGNUM; regi <= IA64_GR127_REGNUM; regi++) | |
8262ee23 | 89 | deprecated_register_valid[regi] = 1; |
d7fa2ae2 | 90 | for (regi = IA64_PR0_REGNUM; regi <= IA64_PR63_REGNUM; regi++) |
8262ee23 | 91 | deprecated_register_valid[regi] = 1; |
d7fa2ae2 | 92 | for (regi = IA64_VFP_REGNUM; regi <= NUM_REGS; regi++) |
8262ee23 | 93 | deprecated_register_valid[regi] = 1; |
d7fa2ae2 KB |
94 | } |
95 | ||
96 | void | |
97 | fill_gregset (prgregset_t *gregsetp, int regno) | |
98 | { | |
99 | int regi; | |
100 | ||
101 | #define COPY_REG(_fld_,_regi_) \ | |
102 | if ((regno == -1) || regno == _regi_) \ | |
62700349 | 103 | memcpy (&(gregsetp->_fld_), &deprecated_registers[DEPRECATED_REGISTER_BYTE (_regi_)], \ |
3acba339 | 104 | register_size (current_gdbarch, _regi_)) |
d7fa2ae2 KB |
105 | |
106 | for (regi = IA64_GR0_REGNUM; regi <= IA64_GR31_REGNUM; regi++) | |
107 | { | |
108 | COPY_REG (__gpr[regi - IA64_GR0_REGNUM], regi); | |
109 | } | |
110 | ||
111 | for (regi = IA64_BR0_REGNUM; regi <= IA64_BR7_REGNUM; regi++) | |
112 | { | |
113 | COPY_REG (__br[regi - IA64_BR0_REGNUM], regi); | |
114 | } | |
115 | COPY_REG (__psr, IA64_PSR_REGNUM); | |
116 | COPY_REG (__ip, IA64_IP_REGNUM); | |
117 | COPY_REG (__ifs, IA64_CFM_REGNUM); | |
118 | COPY_REG (__rsc, IA64_RSC_REGNUM); | |
119 | COPY_REG (__bsp, IA64_BSP_REGNUM); | |
120 | ||
121 | /* Bad things happen if we don't update both bsp and bspstore at the | |
122 | same time. */ | |
123 | if (regno == IA64_BSP_REGNUM || regno == -1) | |
124 | { | |
125 | memcpy (&(gregsetp->__bspstore), | |
62700349 | 126 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (IA64_BSP_REGNUM)], |
3acba339 | 127 | register_size (current_gdbarch, IA64_BSP_REGNUM)); |
62700349 AC |
128 | memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (IA64_BSPSTORE_REGNUM)], |
129 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (IA64_BSP_REGNUM)], | |
3acba339 | 130 | register_size (current_gdbarch, IA64_BSP_REGNUM)); |
d7fa2ae2 KB |
131 | } |
132 | ||
133 | #if 0 | |
134 | /* We never actually write to bspstore, or we'd have to do the same thing | |
135 | here too. */ | |
136 | COPY_REG (__bspstore, IA64_BSPSTORE_REGNUM); | |
137 | #endif | |
138 | COPY_REG (__rnat, IA64_RNAT_REGNUM); | |
139 | COPY_REG (__pfs, IA64_PFS_REGNUM); | |
140 | COPY_REG (__unat, IA64_UNAT_REGNUM); | |
141 | COPY_REG (__preds, IA64_PR_REGNUM); | |
142 | COPY_REG (__ccv, IA64_CCV_REGNUM); | |
143 | COPY_REG (__lc, IA64_LC_REGNUM); | |
144 | COPY_REG (__ec, IA64_EC_REGNUM); | |
145 | /* FIXME: __nats */ | |
146 | COPY_REG (__fpsr, IA64_FPSR_REGNUM); | |
147 | #undef COPY_REG | |
148 | } | |
149 | ||
150 | void | |
151 | supply_fpregset (prfpregset_t *fpregsetp) | |
152 | { | |
52f0bd74 | 153 | int regi; |
d7fa2ae2 KB |
154 | |
155 | for (regi = IA64_FR0_REGNUM; regi <= IA64_FR127_REGNUM; regi++) | |
23a6d369 | 156 | regcache_raw_supply (current_regcache, regi, |
d7fa2ae2 KB |
157 | (char *) &(fpregsetp->__fpr[regi - IA64_FR0_REGNUM])); |
158 | } | |
159 | ||
160 | void | |
161 | fill_fpregset (prfpregset_t *fpregsetp, int regno) | |
162 | { | |
163 | int regi; | |
164 | char *to; | |
165 | char *from; | |
166 | ||
167 | for (regi = IA64_FR0_REGNUM; regi <= IA64_FR127_REGNUM; regi++) | |
168 | { | |
169 | if ((regno == -1) || (regno == regi)) | |
170 | { | |
62700349 | 171 | from = (char *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (regi)]; |
d7fa2ae2 | 172 | to = (char *) &(fpregsetp->__fpr[regi - IA64_FR0_REGNUM]); |
3acba339 | 173 | memcpy (to, from, register_size (current_gdbarch, regi)); |
d7fa2ae2 KB |
174 | } |
175 | } | |
176 | } |