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