This commit was generated by cvs2svn to track changes on a CVS vendor
[binutils-gdb.git] / gdb / i386v4-nat.c
1 /* Native-dependent code for SVR4 Unix running on i386's, for GDB.
2 Copyright 1988, 1989, 1991, 1992, 1996, 1998 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20 #include "defs.h"
21 #include "value.h"
22 #include "inferior.h"
23
24 #ifdef HAVE_SYS_REG_H
25 #include <sys/reg.h>
26 #endif
27
28
29 #ifdef HAVE_SYS_PROCFS_H
30
31 #include <sys/procfs.h>
32
33 /* The /proc interface divides the target machine's register set up into
34 two different sets, the general register set (gregset) and the floating
35 point register set (fpregset). For each set, there is an ioctl to get
36 the current register set and another ioctl to set the current values.
37
38 The actual structure passed through the ioctl interface is, of course,
39 naturally machine dependent, and is different for each set of registers.
40 For the i386 for example, the general register set is typically defined
41 by:
42
43 typedef int gregset_t[19]; (in <sys/regset.h>)
44
45 #define GS 0 (in <sys/reg.h>)
46 #define FS 1
47 ...
48 #define UESP 17
49 #define SS 18
50
51 and the floating point set by:
52
53 typedef struct fpregset
54 {
55 union
56 {
57 struct fpchip_state // fp extension state //
58 {
59 int state[27]; // 287/387 saved state //
60 int status; // status word saved at exception //
61 } fpchip_state;
62 struct fp_emul_space // for emulators //
63 {
64 char fp_emul[246];
65 char fp_epad[2];
66 } fp_emul_space;
67 int f_fpregs[62]; // union of the above //
68 } fp_reg_set;
69 long f_wregs[33]; // saved weitek state //
70 } fpregset_t;
71
72 These routines provide the packing and unpacking of gregset_t and
73 fpregset_t formatted data.
74
75 */
76
77 #ifdef HAVE_GREGSET_T
78
79 /* This is a duplicate of the table in i386-xdep.c. */
80
81 static int regmap[] =
82 {
83 EAX, ECX, EDX, EBX,
84 UESP, EBP, ESI, EDI,
85 EIP, EFL, CS, SS,
86 DS, ES, FS, GS,
87 };
88
89 /* Prototypes for local functions */
90
91 void fill_gregset PARAMS ((gregset_t *, int));
92
93 void supply_gregset PARAMS ((gregset_t *));
94
95 void supply_fpregset PARAMS ((fpregset_t *));
96
97 void fill_fpregset PARAMS ((fpregset_t *, int));
98
99
100 /* FIXME: These routine absolutely depends upon (NUM_REGS - NUM_FREGS)
101 being less than or equal to the number of registers that can be stored
102 in a gregset_t. Note that with the current scheme there will typically
103 be more registers actually stored in a gregset_t that what we know
104 about. This is bogus and should be fixed. */
105
106 /* Given a pointer to a general register set in /proc format (gregset_t *),
107 unpack the register contents and supply them as gdb's idea of the current
108 register values. */
109
110 void
111 supply_gregset (gregsetp)
112 gregset_t *gregsetp;
113 {
114 register int regi;
115 register greg_t *regp = (greg_t *) gregsetp;
116 extern int regmap[];
117
118 for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++)
119 {
120 supply_register (regi, (char *) (regp + regmap[regi]));
121 }
122 }
123
124 void
125 fill_gregset (gregsetp, regno)
126 gregset_t *gregsetp;
127 int regno;
128 {
129 int regi;
130 register greg_t *regp = (greg_t *) gregsetp;
131 extern int regmap[];
132
133 for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++)
134 {
135 if ((regno == -1) || (regno == regi))
136 {
137 *(regp + regmap[regi]) = *(int *) &registers[REGISTER_BYTE (regi)];
138 }
139 }
140 }
141
142 #endif /* HAVE_GREGSET_T */
143
144 #if defined (FP0_REGNUM) && defined (HAVE_FPREGSET_T)
145
146 /* Given a pointer to a floating point register set in /proc format
147 (fpregset_t *), unpack the register contents and supply them as gdb's
148 idea of the current floating point register values. */
149
150 void
151 supply_fpregset (fpregsetp)
152 fpregset_t *fpregsetp;
153 {
154 /* FIXME: see m68k-tdep.c for an example, for the m68k. */
155 }
156
157 /* Given a pointer to a floating point register set in /proc format
158 (fpregset_t *), update the register specified by REGNO from gdb's idea
159 of the current floating point register set. If REGNO is -1, update
160 them all. */
161
162 void
163 fill_fpregset (fpregsetp, regno)
164 fpregset_t *fpregsetp;
165 int regno;
166 {
167 /* FIXME: see m68k-tdep.c for an example, for the m68k. */
168 }
169
170 #endif /* defined (FP0_REGNUM) && defined (HAVE_FPREGSET_T) */
171
172 #endif /* HAVE_SYS_PROCFS_H */