* NEWS (New native configurations): Mention NetBSD/vax.
[deliverable/binutils-gdb.git] / gdb / i386v4-nat.c
CommitLineData
fcc9bf01
MK
1/* Native-dependent code for SVR4 Unix running on i386's.
2 Copyright 1988, 1989, 1991, 1992, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002
b6ba6518 4 Free Software Foundation, Inc.
c906108c 5
c5aa993b 6 This file is part of GDB.
c906108c 7
c5aa993b
JM
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
c906108c 12
c5aa993b
JM
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
c906108c 17
c5aa993b
JM
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
c906108c
SS
22
23#include "defs.h"
24#include "value.h"
7a292a7a 25#include "inferior.h"
4e052eda 26#include "regcache.h"
c906108c
SS
27
28#ifdef HAVE_SYS_REG_H
29#include <sys/reg.h>
30#endif
31
fcc9bf01
MK
32#include "i386-tdep.h"
33#include "i387-tdep.h"
c906108c
SS
34
35#ifdef HAVE_SYS_PROCFS_H
36
37#include <sys/procfs.h>
38
c60c0f5f
MS
39/* Prototypes for supply_gregset etc. */
40#include "gregset.h"
41
fcc9bf01
MK
42/* The `/proc' interface divides the target machine's register set up
43 into two different sets, the general purpose register set (gregset)
44 and the floating-point register set (fpregset). For each set,
45 there is an ioctl to get the current register set and another ioctl
46 to set the current values.
c5aa993b 47
fcc9bf01
MK
48 The actual structure passed through the ioctl interface is, of
49 course, naturally machine dependent, and is different for each set
50 of registers. For the i386 for example, the general-purpose
51 register set is typically defined by:
c5aa993b
JM
52
53 typedef int gregset_t[19]; (in <sys/regset.h>)
54
55 #define GS 0 (in <sys/reg.h>)
56 #define FS 1
57 ...
58 #define UESP 17
59 #define SS 18
60
fcc9bf01
MK
61 and the floating-point set by:
62
63 typedef struct fpregset {
64 union {
65 struct fpchip_state // fp extension state //
66 {
67 int state[27]; // 287/387 saved state //
68 int status; // status word saved at //
69 // exception //
70 } fpchip_state;
71 struct fp_emul_space // for emulators //
72 {
73 char fp_emul[246];
74 char fp_epad[2];
75 } fp_emul_space;
76 int f_fpregs[62]; // union of the above //
77 } fp_reg_set;
78 long f_wregs[33]; // saved weitek state //
c5aa993b
JM
79 } fpregset_t;
80
fcc9bf01
MK
81 Incidentally fpchip_state contains the FPU state in the same format
82 as used by the "fsave" instruction, and that's the only thing we
83 support here. I don't know how the emulator stores it state. The
84 Weitek stuff definitely isn't supported.
c906108c 85
fcc9bf01
MK
86 The routines defined here, provide the packing and unpacking of
87 gregset_t and fpregset_t formatted data. */
c906108c
SS
88
89#ifdef HAVE_GREGSET_T
90
fcc9bf01
MK
91/* Mapping between the general-purpose registers in `/proc'
92 format and GDB's register array layout. */
c5aa993b 93static int regmap[] =
c906108c
SS
94{
95 EAX, ECX, EDX, EBX,
96 UESP, EBP, ESI, EDI,
97 EIP, EFL, CS, SS,
98 DS, ES, FS, GS,
99};
100
fcc9bf01
MK
101/* Fill GDB's register array with the general-purpose register values
102 in *GREGSETP. */
c906108c
SS
103
104void
fba45db2 105supply_gregset (gregset_t *gregsetp)
c906108c 106{
fcc9bf01
MK
107 greg_t *regp = (greg_t *) gregsetp;
108 int i;
109
110 for (i = 0; i < I386_NUM_GREGS; i++)
111 supply_register (i, (char *) (regp + regmap[i]));
c906108c
SS
112}
113
fcc9bf01
MK
114/* Fill register REGNO (if it is a general-purpose register) in
115 *GREGSETPS with the value in GDB's register array. If REGNO is -1,
116 do this for all registers. */
117
c906108c 118void
fba45db2 119fill_gregset (gregset_t *gregsetp, int regno)
c906108c 120{
fcc9bf01
MK
121 greg_t *regp = (greg_t *) gregsetp;
122 int i;
123
124 for (i = 0; i < I386_NUM_GREGS; i++)
125 if (regno == -1 || regno == i)
126 regcache_collect (i, regp + regmap[i]);
c906108c
SS
127}
128
c5aa993b 129#endif /* HAVE_GREGSET_T */
c906108c 130
fcc9bf01 131#ifdef HAVE_FPREGSET_T
c906108c 132
fcc9bf01
MK
133/* Fill GDB's register array with the floating-point register values in
134 *FPREGSETP. */
14164c30 135
c5aa993b 136void
fba45db2 137supply_fpregset (fpregset_t *fpregsetp)
c906108c 138{
fcc9bf01 139 if (FP0_REGNUM == 0)
14164c30 140 return;
14164c30 141
41d041d6 142 i387_supply_fsave (current_regcache, -1, fpregsetp);
c906108c
SS
143}
144
fcc9bf01
MK
145/* Fill register REGNO (if it is a floating-point register) in
146 *FPREGSETP with the value in GDB's register array. If REGNO is -1,
147 do this for all registers. */
c906108c
SS
148
149void
fba45db2 150fill_fpregset (fpregset_t *fpregsetp, int regno)
c906108c 151{
fcc9bf01 152 if (FP0_REGNUM == 0)
14164c30 153 return;
34588f23 154
fcc9bf01 155 i387_fill_fsave ((char *) fpregsetp, regno);
c906108c
SS
156}
157
fcc9bf01 158#endif /* HAVE_FPREGSET_T */
c906108c 159
c5aa993b 160#endif /* HAVE_SYS_PROCFS_H */
This page took 0.359537 seconds and 4 git commands to generate.