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