1 /* Native-dependent code for BSD Unix running on i386's, for GDB.
2 Copyright 1988, 1989, 1991, 1992, 1994 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
21 #include <machine/reg.h>
23 /* this table must line up with REGISTER_NAMES in tm-i386.h */
24 /* symbols like 'tEAX' come from <machine/reg.h> */
25 static int tregmap
[] =
27 tEAX
, tECX
, tEDX
, tEBX
,
28 tESP
, tEBP
, tESI
, tEDI
,
29 tEIP
, tEFLAGS
, tCS
, tSS
33 static int sregmap
[] =
35 sEAX
, sECX
, sEDX
, sEBX
,
36 sESP
, sEBP
, sESI
, sEDI
,
37 sEIP
, sEFLAGS
, sCS
, sSS
41 /* NetBSD has decided to collapse the s* and t* symbols. So if the s*
42 ones aren't around, use the t* ones for sregmap too. */
44 static int sregmap
[] =
46 tEAX
, tECX
, tEDX
, tEBX
,
47 tESP
, tEBP
, tESI
, tEDI
,
48 tEIP
, tEFLAGS
, tCS
, tSS
52 /* blockend is the value of u.u_ar0, and points to the
53 place where ES is stored. */
56 i386_register_u_addr (blockend
, regnum
)
60 /* The following condition is a kludge to get at the proper register map
61 depending upon the state of pcb_flag.
62 The proper condition would be
63 if (u.u_pcb.pcb_flag & FM_TRAP)
64 but that would require a ptrace call here and wouldn't work
67 if (blockend
< 0x1fcc)
68 return (blockend
+ 4 * tregmap
[regnum
]);
70 return (blockend
+ 4 * sregmap
[regnum
]);
75 #include "floatformat.h"
77 #include <sys/param.h>
80 #include <sys/ioctl.h>
86 #include <sys/resource.h>
88 #define curpcb Xcurpcb /* XXX avoid leaking declaration from pcb.h */
93 #include <sys/ptrace.h>
95 extern void print_387_control_word (); /* i387-tdep.h */
96 extern void print_387_status_word ();
98 #define fpstate save87
99 #define U_FPSTATE(u) u.u_pcb.pcb_savefpu
103 unsigned short control
;
105 unsigned short status
;
110 unsigned short code_seg
;
111 unsigned short opcode
;
112 unsigned long operand
;
113 unsigned short operand_seg
;
115 unsigned char regs
[8][10];
119 print_387_status (status
, ep
)
120 unsigned short status
;
129 bothstatus
= ((status
!= 0) && (ep
->status
!= 0));
133 printf_unfiltered ("u: ");
134 print_387_status_word ((unsigned int)status
);
140 printf_unfiltered ("e: ");
141 print_387_status_word ((unsigned int)ep
->status
);
144 print_387_control_word ((unsigned int)ep
->control
);
145 printf_unfiltered ("last exception: ");
146 printf_unfiltered ("opcode %s; ", local_hex_string(ep
->opcode
));
147 printf_unfiltered ("pc %s:", local_hex_string(ep
->code_seg
));
148 printf_unfiltered ("%s; ", local_hex_string(ep
->eip
));
149 printf_unfiltered ("operand %s", local_hex_string(ep
->operand_seg
));
150 printf_unfiltered (":%s\n", local_hex_string(ep
->operand
));
152 top
= (ep
->status
>> 11) & 7;
154 printf_unfiltered ("regno tag msb lsb value\n");
155 for (fpreg
= 7; fpreg
>= 0; fpreg
--)
159 printf_unfiltered ("%s %d: ", fpreg
== top
? "=>" : " ", fpreg
);
161 switch ((ep
->tag
>> (fpreg
* 2)) & 3)
163 case 0: printf_unfiltered ("valid "); break;
164 case 1: printf_unfiltered ("zero "); break;
165 case 2: printf_unfiltered ("trap "); break;
166 case 3: printf_unfiltered ("empty "); break;
168 for (i
= 9; i
>= 0; i
--)
169 printf_unfiltered ("%02x", ep
->regs
[fpreg
][i
]);
171 floatformat_to_double(&floatformat_i387_ext
, (char *) ep
->regs
[fpreg
],
173 printf_unfiltered (" %g\n", val
);
179 struct user u
; /* just for address computations */
181 /* fpstate defined in <sys/user.h> */
182 struct fpstate
*fpstatep
;
183 char buf
[sizeof (struct fpstate
) + 2 * sizeof (int)];
186 unsigned int rounded_addr
;
187 unsigned int rounded_size
;
188 /*extern int corechan;*/
190 extern int inferior_pid
;
192 uaddr
= (char *)&U_FPSTATE(u
) - (char *)&u
;
197 rounded_addr
= uaddr
& -sizeof (int);
198 rounded_size
= (((uaddr
+ sizeof (struct fpstate
)) - uaddr
) +
199 sizeof (int) - 1) / sizeof (int);
200 skip
= uaddr
- rounded_addr
;
203 for (i
= 0; i
< rounded_size
; i
++)
205 *ip
++ = ptrace (PT_READ_U
, inferior_pid
, (caddr_t
)rounded_addr
, 0);
206 rounded_addr
+= sizeof (int);
211 printf("float info: can't do a core file (yet)\n");
214 if (lseek (corechan
, uaddr
, 0) < 0)
215 perror_with_name ("seek on core file");
216 if (myread (corechan
, buf
, sizeof (struct fpstate
)) < 0)
217 perror_with_name ("read from core file");
222 print_387_status (0, (struct env387
*)buf
);
This page took 0.033664 seconds and 4 git commands to generate.