]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/symm-nat.c
Change the stream argument to _filtered to GDB_FILE *.
[thirdparty/binutils-gdb.git] / gdb / symm-nat.c
CommitLineData
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
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, 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
41void
42store_inferior_registers(regno)
43int regno;
44{
45 struct pt_regset regs;
46 int reg_tmp, i;
47 extern char registers[];
48
49 regs.pr_eax = *(int *)&registers[REGISTER_BYTE(0)];
50 regs.pr_ebx = *(int *)&registers[REGISTER_BYTE(5)];
51 regs.pr_ecx = *(int *)&registers[REGISTER_BYTE(2)];
52 regs.pr_edx = *(int *)&registers[REGISTER_BYTE(1)];
53 regs.pr_esi = *(int *)&registers[REGISTER_BYTE(6)];
54 regs.pr_edi = *(int *)&registers[REGISTER_BYTE(7)];
55 regs.pr_esp = *(int *)&registers[REGISTER_BYTE(14)];
56 regs.pr_ebp = *(int *)&registers[REGISTER_BYTE(15)];
57 regs.pr_eip = *(int *)&registers[REGISTER_BYTE(16)];
58 regs.pr_flags = *(int *)&registers[REGISTER_BYTE(17)];
59 for (i = 0; i < 31; i++)
60 {
61 regs.pr_fpa.fpa_regs[i] =
62 *(int *)&registers[REGISTER_BYTE(FP1_REGNUM+i)];
63 }
64 PTRACE_WRITE_REGS (inferior_pid, (PTRACE_ARG3_TYPE) &regs);
65}
66
67void
68fetch_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) &regs);
78 *(int *)&registers[REGISTER_BYTE(EAX_REGNUM)] = regs.pr_eax;
79 *(int *)&registers[REGISTER_BYTE(EBX_REGNUM)] = regs.pr_ebx;
80 *(int *)&registers[REGISTER_BYTE(ECX_REGNUM)] = regs.pr_ecx;
81 *(int *)&registers[REGISTER_BYTE(EDX_REGNUM)] = regs.pr_edx;
82 *(int *)&registers[REGISTER_BYTE(ESI_REGNUM)] = regs.pr_esi;
83 *(int *)&registers[REGISTER_BYTE(EDI_REGNUM)] = regs.pr_edi;
84 *(int *)&registers[REGISTER_BYTE(EBP_REGNUM)] = regs.pr_ebp;
85 *(int *)&registers[REGISTER_BYTE(ESP_REGNUM)] = regs.pr_esp;
86 *(int *)&registers[REGISTER_BYTE(EIP_REGNUM)] = regs.pr_eip;
87 *(int *)&registers[REGISTER_BYTE(EFLAGS_REGNUM)] = regs.pr_flags;
88 for (i = 0; i < FPA_NREGS; i++)
89 {
90 *(int *)&registers[REGISTER_BYTE(FP1_REGNUM+i)] =
91 regs.pr_fpa.fpa_regs[i];
92 }
93 memcpy (&registers[REGISTER_BYTE(ST0_REGNUM)], regs.pr_fpu.fpu_stack[0], 10);
94 memcpy (&registers[REGISTER_BYTE(ST1_REGNUM)], regs.pr_fpu.fpu_stack[1], 10);
95 memcpy (&registers[REGISTER_BYTE(ST2_REGNUM)], regs.pr_fpu.fpu_stack[2], 10);
96 memcpy (&registers[REGISTER_BYTE(ST3_REGNUM)], regs.pr_fpu.fpu_stack[3], 10);
97 memcpy (&registers[REGISTER_BYTE(ST4_REGNUM)], regs.pr_fpu.fpu_stack[4], 10);
98 memcpy (&registers[REGISTER_BYTE(ST5_REGNUM)], regs.pr_fpu.fpu_stack[5], 10);
99 memcpy (&registers[REGISTER_BYTE(ST6_REGNUM)], regs.pr_fpu.fpu_stack[6], 10);
100 memcpy (&registers[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. */
104static
105print_fpu_status(ep)
106struct pt_regset ep;
107{
108 int i;
109 int bothstatus;
110 int top;
111 int fpreg;
112 unsigned char *p;
113
199b2450 114 printf_unfiltered("80387:");
56eec3c7 115 if (ep.pr_fpu.fpu_ip == 0) {
199b2450 116 printf_unfiltered(" not in use.\n");
56eec3c7
JK
117 return;
118 } else {
199b2450 119 printf_unfiltered("\n");
56eec3c7
JK
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);
199b2450
TL
125 printf_unfiltered ("last exception: ");
126 printf_unfiltered ("opcode 0x%x; ", ep.pr_fpu.fpu_rsvd4);
127 printf_unfiltered ("pc 0x%x:0x%x; ", ep.pr_fpu.fpu_cs, ep.pr_fpu.fpu_ip);
128 printf_unfiltered ("operand 0x%x:0x%x\n", ep.pr_fpu.fpu_data_offset, ep.pr_fpu.fpu_op_sel);
56eec3c7
JK
129
130 top = (ep.pr_fpu.fpu_status >> 11) & 7;
131
199b2450 132 printf_unfiltered ("regno tag msb lsb value\n");
56eec3c7
JK
133 for (fpreg = 7; fpreg >= 0; fpreg--)
134 {
135 double val;
136
199b2450 137 printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
56eec3c7
JK
138
139 switch ((ep.pr_fpu.fpu_tag >> (fpreg * 2)) & 3)
140 {
199b2450
TL
141 case 0: printf_unfiltered ("valid "); break;
142 case 1: printf_unfiltered ("zero "); break;
143 case 2: printf_unfiltered ("trap "); break;
144 case 3: printf_unfiltered ("empty "); break;
56eec3c7
JK
145 }
146 for (i = 9; i >= 0; i--)
199b2450 147 printf_unfiltered ("%02x", ep.pr_fpu.fpu_stack[fpreg][i]);
56eec3c7
JK
148
149 i387_to_double (ep.pr_fpu.fpu_stack[fpreg], (char *)&val);
199b2450 150 printf_unfiltered (" %g\n", val);
56eec3c7
JK
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
163print_1167_control_word(pcr)
164unsigned int pcr;
165
166{
167 int pcr_tmp;
168
169 pcr_tmp = pcr & FPA_PCR_MODE;
199b2450 170 printf_unfiltered("\tMODE= %#x; RND= %#x ", pcr_tmp, pcr_tmp & 12);
56eec3c7
JK
171 switch (pcr_tmp & 12) {
172 case 0:
199b2450 173 printf_unfiltered("RN (Nearest Value)");
56eec3c7
JK
174 break;
175 case 1:
199b2450 176 printf_unfiltered("RZ (Zero)");
56eec3c7
JK
177 break;
178 case 2:
199b2450 179 printf_unfiltered("RP (Positive Infinity)");
56eec3c7
JK
180 break;
181 case 3:
199b2450 182 printf_unfiltered("RM (Negative Infinity)");
56eec3c7
JK
183 break;
184 }
199b2450 185 printf_unfiltered("; IRND= %d ", pcr_tmp & 2);
56eec3c7 186 if (0 == pcr_tmp & 2) {
199b2450 187 printf_unfiltered("(same as RND)\n");
56eec3c7 188 } else {
199b2450 189 printf_unfiltered("(toward zero)\n");
56eec3c7
JK
190 }
191 pcr_tmp = pcr & FPA_PCR_EM;
199b2450
TL
192 printf_unfiltered("\tEM= %#x", pcr_tmp);
193 if (pcr_tmp & FPA_PCR_EM_DM) printf_unfiltered(" DM");
194 if (pcr_tmp & FPA_PCR_EM_UOM) printf_unfiltered(" UOM");
195 if (pcr_tmp & FPA_PCR_EM_PM) printf_unfiltered(" PM");
196 if (pcr_tmp & FPA_PCR_EM_UM) printf_unfiltered(" UM");
197 if (pcr_tmp & FPA_PCR_EM_OM) printf_unfiltered(" OM");
198 if (pcr_tmp & FPA_PCR_EM_ZM) printf_unfiltered(" ZM");
199 if (pcr_tmp & FPA_PCR_EM_IM) printf_unfiltered(" IM");
200 printf_unfiltered("\n");
56eec3c7 201 pcr_tmp = FPA_PCR_CC;
199b2450
TL
202 printf_unfiltered("\tCC= %#x", pcr_tmp);
203 if (pcr_tmp & FPA_PCR_20MHZ) printf_unfiltered(" 20MHZ");
204 if (pcr_tmp & FPA_PCR_CC_Z) printf_unfiltered(" Z");
205 if (pcr_tmp & FPA_PCR_CC_C2) printf_unfiltered(" C2");
206 if (pcr_tmp & FPA_PCR_CC_C1) printf_unfiltered(" C1");
56eec3c7
JK
207 switch (pcr_tmp) {
208 case FPA_PCR_CC_Z:
199b2450 209 printf_unfiltered(" (Equal)");
56eec3c7
JK
210 break;
211 case FPA_PCR_CC_C1:
199b2450 212 printf_unfiltered(" (Less than)");
56eec3c7
JK
213 break;
214 case 0:
199b2450 215 printf_unfiltered(" (Greater than)");
56eec3c7
JK
216 break;
217 case FPA_PCR_CC_Z | FPA_PCR_CC_C1 | FPA_PCR_CC_C2:
199b2450 218 printf_unfiltered(" (Unordered)");
56eec3c7
JK
219 break;
220 default:
199b2450 221 printf_unfiltered(" (Undefined)");
56eec3c7
JK
222 break;
223 }
199b2450 224 printf_unfiltered("\n");
56eec3c7 225 pcr_tmp = pcr & FPA_PCR_AE;
199b2450
TL
226 printf_unfiltered("\tAE= %#x", pcr_tmp);
227 if (pcr_tmp & FPA_PCR_AE_DE) printf_unfiltered(" DE");
228 if (pcr_tmp & FPA_PCR_AE_UOE) printf_unfiltered(" UOE");
229 if (pcr_tmp & FPA_PCR_AE_PE) printf_unfiltered(" PE");
230 if (pcr_tmp & FPA_PCR_AE_UE) printf_unfiltered(" UE");
231 if (pcr_tmp & FPA_PCR_AE_OE) printf_unfiltered(" OE");
232 if (pcr_tmp & FPA_PCR_AE_ZE) printf_unfiltered(" ZE");
233 if (pcr_tmp & FPA_PCR_AE_EE) printf_unfiltered(" EE");
234 if (pcr_tmp & FPA_PCR_AE_IE) printf_unfiltered(" IE");
235 printf_unfiltered("\n");
56eec3c7
JK
236}
237
238print_1167_regs(regs)
239long 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];
199b2450 256 printf_unfiltered("%%fp%d: raw= %#x, single= %f", i+1, regs[i], xf.f);
56eec3c7 257 if (!(i & 1)) {
199b2450 258 printf_unfiltered("\n");
56eec3c7
JK
259 } else {
260 xd.l[1] = regs[i];
261 xd.l[0] = regs[i+1];
199b2450 262 printf_unfiltered(", double= %f\n", xd.d);
56eec3c7
JK
263 }
264 }
265}
266
267print_fpa_status(ep)
268struct pt_regset ep;
269
270{
271
199b2450 272 printf_unfiltered("WTL 1167:");
56eec3c7 273 if (ep.pr_fpa.fpa_pcr !=0) {
199b2450 274 printf_unfiltered("\n");
56eec3c7
JK
275 print_1167_control_word(ep.pr_fpa.fpa_pcr);
276 print_1167_regs(ep.pr_fpa.fpa_regs);
277 } else {
199b2450 278 printf_unfiltered(" not in use.\n");
56eec3c7
JK
279 }
280}
281
282i386_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) &regset);
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}