]>
Commit | Line | Data |
---|---|---|
56eec3c7 JK |
1 | /* Sequent Symmetry host interface, for GDB when running under Unix. |
2 | Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | /* FIXME, some 387-specific items of use taken from i387-tdep.c -- ought to be | |
21 | merged back in. */ | |
22 | ||
23 | #include "defs.h" | |
24 | #include "frame.h" | |
25 | #include "inferior.h" | |
26 | #include "symtab.h" | |
27 | ||
28 | #include <signal.h> | |
29 | #include <sys/param.h> | |
30 | #include <sys/user.h> | |
31 | #include <sys/dir.h> | |
32 | #include <sys/ioctl.h> | |
33 | #include <sys/stat.h> | |
34 | #include "gdbcore.h" | |
35 | #include <fcntl.h> | |
36 | #include <sgtty.h> | |
37 | #define TERMINAL struct sgttyb | |
38 | ||
39 | #include "gdbcore.h" | |
40 | ||
41 | void | |
42 | store_inferior_registers(regno) | |
43 | int regno; | |
44 | { | |
45 | struct pt_regset regs; | |
46 | int reg_tmp, i; | |
47 | extern char registers[]; | |
48 | ||
49 | regs.pr_eax = *(int *)®isters[REGISTER_BYTE(0)]; | |
50 | regs.pr_ebx = *(int *)®isters[REGISTER_BYTE(5)]; | |
51 | regs.pr_ecx = *(int *)®isters[REGISTER_BYTE(2)]; | |
52 | regs.pr_edx = *(int *)®isters[REGISTER_BYTE(1)]; | |
53 | regs.pr_esi = *(int *)®isters[REGISTER_BYTE(6)]; | |
54 | regs.pr_edi = *(int *)®isters[REGISTER_BYTE(7)]; | |
55 | regs.pr_esp = *(int *)®isters[REGISTER_BYTE(14)]; | |
56 | regs.pr_ebp = *(int *)®isters[REGISTER_BYTE(15)]; | |
57 | regs.pr_eip = *(int *)®isters[REGISTER_BYTE(16)]; | |
58 | regs.pr_flags = *(int *)®isters[REGISTER_BYTE(17)]; | |
59 | for (i = 0; i < 31; i++) | |
60 | { | |
61 | regs.pr_fpa.fpa_regs[i] = | |
62 | *(int *)®isters[REGISTER_BYTE(FP1_REGNUM+i)]; | |
63 | } | |
64 | PTRACE_WRITE_REGS (inferior_pid, (PTRACE_ARG3_TYPE) ®s); | |
65 | } | |
66 | ||
67 | void | |
68 | fetch_inferior_registers (regno) | |
69 | int regno; | |
70 | { | |
71 | int i; | |
72 | struct pt_regset regs; | |
73 | extern char registers[]; | |
74 | ||
75 | registers_fetched (); | |
76 | ||
77 | PTRACE_READ_REGS (inferior_pid, (PTRACE_ARG3_TYPE) ®s); | |
78 | *(int *)®isters[REGISTER_BYTE(EAX_REGNUM)] = regs.pr_eax; | |
79 | *(int *)®isters[REGISTER_BYTE(EBX_REGNUM)] = regs.pr_ebx; | |
80 | *(int *)®isters[REGISTER_BYTE(ECX_REGNUM)] = regs.pr_ecx; | |
81 | *(int *)®isters[REGISTER_BYTE(EDX_REGNUM)] = regs.pr_edx; | |
82 | *(int *)®isters[REGISTER_BYTE(ESI_REGNUM)] = regs.pr_esi; | |
83 | *(int *)®isters[REGISTER_BYTE(EDI_REGNUM)] = regs.pr_edi; | |
84 | *(int *)®isters[REGISTER_BYTE(EBP_REGNUM)] = regs.pr_ebp; | |
85 | *(int *)®isters[REGISTER_BYTE(ESP_REGNUM)] = regs.pr_esp; | |
86 | *(int *)®isters[REGISTER_BYTE(EIP_REGNUM)] = regs.pr_eip; | |
87 | *(int *)®isters[REGISTER_BYTE(EFLAGS_REGNUM)] = regs.pr_flags; | |
88 | for (i = 0; i < FPA_NREGS; i++) | |
89 | { | |
90 | *(int *)®isters[REGISTER_BYTE(FP1_REGNUM+i)] = | |
91 | regs.pr_fpa.fpa_regs[i]; | |
92 | } | |
93 | memcpy (®isters[REGISTER_BYTE(ST0_REGNUM)], regs.pr_fpu.fpu_stack[0], 10); | |
94 | memcpy (®isters[REGISTER_BYTE(ST1_REGNUM)], regs.pr_fpu.fpu_stack[1], 10); | |
95 | memcpy (®isters[REGISTER_BYTE(ST2_REGNUM)], regs.pr_fpu.fpu_stack[2], 10); | |
96 | memcpy (®isters[REGISTER_BYTE(ST3_REGNUM)], regs.pr_fpu.fpu_stack[3], 10); | |
97 | memcpy (®isters[REGISTER_BYTE(ST4_REGNUM)], regs.pr_fpu.fpu_stack[4], 10); | |
98 | memcpy (®isters[REGISTER_BYTE(ST5_REGNUM)], regs.pr_fpu.fpu_stack[5], 10); | |
99 | memcpy (®isters[REGISTER_BYTE(ST6_REGNUM)], regs.pr_fpu.fpu_stack[6], 10); | |
100 | memcpy (®isters[REGISTER_BYTE(ST7_REGNUM)], regs.pr_fpu.fpu_stack[7], 10); | |
101 | } | |
102 | \f | |
103 | /* FIXME: This should be merged with i387-tdep.c as well. */ | |
104 | static | |
105 | print_fpu_status(ep) | |
106 | struct pt_regset ep; | |
107 | { | |
108 | int i; | |
109 | int bothstatus; | |
110 | int top; | |
111 | int fpreg; | |
112 | unsigned char *p; | |
113 | ||
114 | printf("80387:"); | |
115 | if (ep.pr_fpu.fpu_ip == 0) { | |
116 | printf(" not in use.\n"); | |
117 | return; | |
118 | } else { | |
119 | printf("\n"); | |
120 | } | |
121 | if (ep.pr_fpu.fpu_status != 0) { | |
122 | print_387_status_word (ep.pr_fpu.fpu_status); | |
123 | } | |
124 | print_387_control_word (ep.pr_fpu.fpu_control); | |
125 | printf ("last exception: "); | |
126 | printf ("opcode 0x%x; ", ep.pr_fpu.fpu_rsvd4); | |
127 | printf ("pc 0x%x:0x%x; ", ep.pr_fpu.fpu_cs, ep.pr_fpu.fpu_ip); | |
128 | printf ("operand 0x%x:0x%x\n", ep.pr_fpu.fpu_data_offset, ep.pr_fpu.fpu_op_sel); | |
129 | ||
130 | top = (ep.pr_fpu.fpu_status >> 11) & 7; | |
131 | ||
132 | printf ("regno tag msb lsb value\n"); | |
133 | for (fpreg = 7; fpreg >= 0; fpreg--) | |
134 | { | |
135 | double val; | |
136 | ||
137 | printf ("%s %d: ", fpreg == top ? "=>" : " ", fpreg); | |
138 | ||
139 | switch ((ep.pr_fpu.fpu_tag >> (fpreg * 2)) & 3) | |
140 | { | |
141 | case 0: printf ("valid "); break; | |
142 | case 1: printf ("zero "); break; | |
143 | case 2: printf ("trap "); break; | |
144 | case 3: printf ("empty "); break; | |
145 | } | |
146 | for (i = 9; i >= 0; i--) | |
147 | printf ("%02x", ep.pr_fpu.fpu_stack[fpreg][i]); | |
148 | ||
149 | i387_to_double (ep.pr_fpu.fpu_stack[fpreg], (char *)&val); | |
150 | printf (" %g\n", val); | |
151 | } | |
152 | if (ep.pr_fpu.fpu_rsvd1) | |
153 | warning ("rsvd1 is 0x%x\n", ep.pr_fpu.fpu_rsvd1); | |
154 | if (ep.pr_fpu.fpu_rsvd2) | |
155 | warning ("rsvd2 is 0x%x\n", ep.pr_fpu.fpu_rsvd2); | |
156 | if (ep.pr_fpu.fpu_rsvd3) | |
157 | warning ("rsvd3 is 0x%x\n", ep.pr_fpu.fpu_rsvd3); | |
158 | if (ep.pr_fpu.fpu_rsvd5) | |
159 | warning ("rsvd5 is 0x%x\n", ep.pr_fpu.fpu_rsvd5); | |
160 | } | |
161 | ||
162 | ||
163 | print_1167_control_word(pcr) | |
164 | unsigned int pcr; | |
165 | ||
166 | { | |
167 | int pcr_tmp; | |
168 | ||
169 | pcr_tmp = pcr & FPA_PCR_MODE; | |
170 | printf("\tMODE= %#x; RND= %#x ", pcr_tmp, pcr_tmp & 12); | |
171 | switch (pcr_tmp & 12) { | |
172 | case 0: | |
173 | printf("RN (Nearest Value)"); | |
174 | break; | |
175 | case 1: | |
176 | printf("RZ (Zero)"); | |
177 | break; | |
178 | case 2: | |
179 | printf("RP (Positive Infinity)"); | |
180 | break; | |
181 | case 3: | |
182 | printf("RM (Negative Infinity)"); | |
183 | break; | |
184 | } | |
185 | printf("; IRND= %d ", pcr_tmp & 2); | |
186 | if (0 == pcr_tmp & 2) { | |
187 | printf("(same as RND)\n"); | |
188 | } else { | |
189 | printf("(toward zero)\n"); | |
190 | } | |
191 | pcr_tmp = pcr & FPA_PCR_EM; | |
192 | printf("\tEM= %#x", pcr_tmp); | |
193 | if (pcr_tmp & FPA_PCR_EM_DM) printf(" DM"); | |
194 | if (pcr_tmp & FPA_PCR_EM_UOM) printf(" UOM"); | |
195 | if (pcr_tmp & FPA_PCR_EM_PM) printf(" PM"); | |
196 | if (pcr_tmp & FPA_PCR_EM_UM) printf(" UM"); | |
197 | if (pcr_tmp & FPA_PCR_EM_OM) printf(" OM"); | |
198 | if (pcr_tmp & FPA_PCR_EM_ZM) printf(" ZM"); | |
199 | if (pcr_tmp & FPA_PCR_EM_IM) printf(" IM"); | |
200 | printf("\n"); | |
201 | pcr_tmp = FPA_PCR_CC; | |
202 | printf("\tCC= %#x", pcr_tmp); | |
203 | if (pcr_tmp & FPA_PCR_20MHZ) printf(" 20MHZ"); | |
204 | if (pcr_tmp & FPA_PCR_CC_Z) printf(" Z"); | |
205 | if (pcr_tmp & FPA_PCR_CC_C2) printf(" C2"); | |
206 | if (pcr_tmp & FPA_PCR_CC_C1) printf(" C1"); | |
207 | switch (pcr_tmp) { | |
208 | case FPA_PCR_CC_Z: | |
209 | printf(" (Equal)"); | |
210 | break; | |
211 | case FPA_PCR_CC_C1: | |
212 | printf(" (Less than)"); | |
213 | break; | |
214 | case 0: | |
215 | printf(" (Greater than)"); | |
216 | break; | |
217 | case FPA_PCR_CC_Z | FPA_PCR_CC_C1 | FPA_PCR_CC_C2: | |
218 | printf(" (Unordered)"); | |
219 | break; | |
220 | default: | |
221 | printf(" (Undefined)"); | |
222 | break; | |
223 | } | |
224 | printf("\n"); | |
225 | pcr_tmp = pcr & FPA_PCR_AE; | |
226 | printf("\tAE= %#x", pcr_tmp); | |
227 | if (pcr_tmp & FPA_PCR_AE_DE) printf(" DE"); | |
228 | if (pcr_tmp & FPA_PCR_AE_UOE) printf(" UOE"); | |
229 | if (pcr_tmp & FPA_PCR_AE_PE) printf(" PE"); | |
230 | if (pcr_tmp & FPA_PCR_AE_UE) printf(" UE"); | |
231 | if (pcr_tmp & FPA_PCR_AE_OE) printf(" OE"); | |
232 | if (pcr_tmp & FPA_PCR_AE_ZE) printf(" ZE"); | |
233 | if (pcr_tmp & FPA_PCR_AE_EE) printf(" EE"); | |
234 | if (pcr_tmp & FPA_PCR_AE_IE) printf(" IE"); | |
235 | printf("\n"); | |
236 | } | |
237 | ||
238 | print_1167_regs(regs) | |
239 | long regs[FPA_NREGS]; | |
240 | ||
241 | { | |
242 | int i; | |
243 | ||
244 | union { | |
245 | double d; | |
246 | long l[2]; | |
247 | } xd; | |
248 | union { | |
249 | float f; | |
250 | long l; | |
251 | } xf; | |
252 | ||
253 | ||
254 | for (i = 0; i < FPA_NREGS; i++) { | |
255 | xf.l = regs[i]; | |
256 | printf("%%fp%d: raw= %#x, single= %f", i+1, regs[i], xf.f); | |
257 | if (!(i & 1)) { | |
258 | printf("\n"); | |
259 | } else { | |
260 | xd.l[1] = regs[i]; | |
261 | xd.l[0] = regs[i+1]; | |
262 | printf(", double= %f\n", xd.d); | |
263 | } | |
264 | } | |
265 | } | |
266 | ||
267 | print_fpa_status(ep) | |
268 | struct pt_regset ep; | |
269 | ||
270 | { | |
271 | ||
272 | printf("WTL 1167:"); | |
273 | if (ep.pr_fpa.fpa_pcr !=0) { | |
274 | printf("\n"); | |
275 | print_1167_control_word(ep.pr_fpa.fpa_pcr); | |
276 | print_1167_regs(ep.pr_fpa.fpa_regs); | |
277 | } else { | |
278 | printf(" not in use.\n"); | |
279 | } | |
280 | } | |
281 | ||
282 | i386_float_info () | |
283 | { | |
284 | char ubuf[UPAGES*NBPG]; | |
285 | struct pt_regset regset; | |
286 | ||
287 | if (have_inferior_p()) | |
288 | { | |
289 | PTRACE_READ_REGS (inferior_pid, (PTRACE_ARG3_TYPE) ®set); | |
290 | } | |
291 | else | |
292 | { | |
293 | int corechan = bfd_cache_lookup (core_bfd); | |
294 | if (lseek (corechan, 0, 0) < 0) | |
295 | { | |
296 | perror ("seek on core file"); | |
297 | } | |
298 | if (myread (corechan, ubuf, UPAGES*NBPG) < 0) | |
299 | { | |
300 | perror ("read on core file"); | |
301 | } | |
302 | /* only interested in the floating point registers */ | |
303 | regset.pr_fpu = ((struct user *) ubuf)->u_fpusave; | |
304 | regset.pr_fpa = ((struct user *) ubuf)->u_fpasave; | |
305 | } | |
306 | print_fpu_status(regset); | |
307 | print_fpa_status(regset); | |
308 | } |