]>
Commit | Line | Data |
---|---|---|
ebd99d54 | 1 | /* Intel 386 native support for SYSV systems (pre-SVR4). |
c7c94073 RP |
2 | Copyright (C) 1988, 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 | #include "defs.h" | |
21 | #include "frame.h" | |
22 | #include "inferior.h" | |
23 | #include "language.h" | |
24 | #include "gdbcore.h" | |
25 | ||
26 | #ifdef USG | |
27 | #include <sys/types.h> | |
28 | #endif | |
29 | ||
30 | #include <sys/param.h> | |
31 | #include <sys/dir.h> | |
32 | #include <signal.h> | |
33 | #include <sys/user.h> | |
34 | #include <sys/ioctl.h> | |
35 | #include <fcntl.h> | |
36 | ||
37 | #include <sys/file.h> | |
38 | #include <sys/stat.h> | |
39 | ||
ebd99d54 | 40 | #ifndef NO_SYS_REG_H |
c7c94073 | 41 | #include <sys/reg.h> |
ebd99d54 FF |
42 | #endif |
43 | ||
eae3f093 | 44 | #include "floatformat.h" |
c7c94073 RP |
45 | |
46 | #include "target.h" | |
47 | ||
c7c94073 RP |
48 | \f |
49 | /* this table must line up with REGISTER_NAMES in tm-i386v.h */ | |
50 | /* symbols like 'EAX' come from <sys/reg.h> */ | |
51 | static int regmap[] = | |
52 | { | |
53 | EAX, ECX, EDX, EBX, | |
54 | UESP, EBP, ESI, EDI, | |
55 | EIP, EFL, CS, SS, | |
56 | DS, ES, FS, GS, | |
57 | }; | |
58 | ||
59 | /* blockend is the value of u.u_ar0, and points to the | |
60 | * place where GS is stored | |
61 | */ | |
62 | ||
63 | int | |
64 | i386_register_u_addr (blockend, regnum) | |
65 | int blockend; | |
66 | int regnum; | |
67 | { | |
68 | #if 0 | |
69 | /* this will be needed if fp registers are reinstated */ | |
70 | /* for now, you can look at them with 'info float' | |
71 | * sys5 wont let you change them with ptrace anyway | |
72 | */ | |
73 | if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM) | |
74 | { | |
75 | int ubase, fpstate; | |
76 | struct user u; | |
77 | ubase = blockend + 4 * (SS + 1) - KSTKSZ; | |
78 | fpstate = ubase + ((char *)&u.u_fpstate - (char *)&u); | |
79 | return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM)); | |
80 | } | |
81 | else | |
82 | #endif | |
83 | return (blockend + 4 * regmap[regnum]); | |
84 | ||
85 | } | |
86 | ||
87 | #if 0 | |
88 | /* using FLOAT_INFO as is would be a problem. FLOAT_INFO is called | |
89 | via a command xxx and eventually calls ptrace without ever having | |
90 | traversed the target vector. This would be terribly impolite | |
91 | behaviour for a sun4 hosted remote gdb. | |
92 | ||
93 | A fix might be to move this code into the "info registers" command. | |
94 | [email protected] 15 Sept 92. */ | |
95 | i386_float_info () | |
96 | { | |
97 | struct user u; /* just for address computations */ | |
98 | int i; | |
99 | /* fpstate defined in <sys/user.h> */ | |
100 | struct fpstate *fpstatep; | |
101 | char buf[sizeof (struct fpstate) + 2 * sizeof (int)]; | |
102 | unsigned int uaddr; | |
103 | char fpvalid = 0; | |
104 | unsigned int rounded_addr; | |
105 | unsigned int rounded_size; | |
106 | extern int corechan; | |
107 | int skip; | |
108 | ||
109 | uaddr = (char *)&u.u_fpvalid - (char *)&u; | |
110 | if (target_has_execution) | |
111 | { | |
112 | unsigned int data; | |
113 | unsigned int mask; | |
114 | ||
115 | rounded_addr = uaddr & -sizeof (int); | |
116 | data = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) rounded_addr, 0); | |
117 | mask = 0xff << ((uaddr - rounded_addr) * 8); | |
118 | ||
119 | fpvalid = ((data & mask) != 0); | |
120 | } | |
121 | #if 0 | |
122 | else | |
123 | { | |
124 | if (lseek (corechan, uaddr, 0) < 0) | |
125 | perror ("seek on core file"); | |
126 | if (myread (corechan, &fpvalid, 1) < 0) | |
127 | perror ("read on core file"); | |
128 | ||
129 | } | |
130 | #endif /* no core support yet */ | |
131 | ||
132 | if (fpvalid == 0) | |
133 | { | |
199b2450 | 134 | printf_unfiltered ("no floating point status saved\n"); |
c7c94073 RP |
135 | return; |
136 | } | |
137 | ||
138 | uaddr = (char *)&U_FPSTATE(u) - (char *)&u; | |
139 | if (target_has_execution) | |
140 | { | |
141 | int *ip; | |
142 | ||
143 | rounded_addr = uaddr & -sizeof (int); | |
144 | rounded_size = (((uaddr + sizeof (struct fpstate)) - uaddr) + | |
145 | sizeof (int) - 1) / sizeof (int); | |
146 | skip = uaddr - rounded_addr; | |
147 | ||
148 | ip = (int *)buf; | |
149 | for (i = 0; i < rounded_size; i++) | |
150 | { | |
151 | *ip++ = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) rounded_addr, 0); | |
152 | rounded_addr += sizeof (int); | |
153 | } | |
154 | } | |
155 | #if 0 | |
156 | else | |
157 | { | |
158 | if (lseek (corechan, uaddr, 0) < 0) | |
159 | perror_with_name ("seek on core file"); | |
160 | if (myread (corechan, buf, sizeof (struct fpstate)) < 0) | |
161 | perror_with_name ("read from core file"); | |
162 | skip = 0; | |
163 | } | |
3496b745 | 164 | #endif /* 0 */ |
c7c94073 RP |
165 | |
166 | fpstatep = (struct fpstate *)(buf + skip); | |
167 | print_387_status (fpstatep->status, (struct env387 *)fpstatep->state); | |
168 | } | |
169 | ||
170 | #endif /* never */ |