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