* configure.ac: Check for the GNU/Linux ptrace signature.
[deliverable/binutils-gdb.git] / gdb / i386v4-nat.c
CommitLineData
40e20472
MK
1/* Native-dependent code for Unix SVR4 running on i386's.
2
6aba47ca 3 Copyright (C) 1988, 1989, 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2001,
9b254dd1 4 2002, 2004, 2007, 2008 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
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
c5aa993b 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 18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
20
21#include "defs.h"
22#include "value.h"
7a292a7a 23#include "inferior.h"
4e052eda 24#include "regcache.h"
c906108c
SS
25
26#ifdef HAVE_SYS_REG_H
27#include <sys/reg.h>
28#endif
29
fcc9bf01
MK
30#include "i386-tdep.h"
31#include "i387-tdep.h"
c906108c
SS
32
33#ifdef HAVE_SYS_PROCFS_H
34
35#include <sys/procfs.h>
36
f69c55b2
MK
37/* We must not compile this code for 64-bit Solaris x86. */
38#if !defined (PR_MODEL_NATIVE) || (PR_MODEL_NATIVE == PR_MODEL_ILP32)
39
c60c0f5f
MS
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,
40e20472 98 DS, ES, FS, GS
c906108c
SS
99};
100
fcc9bf01
MK
101/* Fill GDB's register array with the general-purpose register values
102 in *GREGSETP. */
c906108c
SS
103
104void
7f7fe91e 105supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
c906108c 106{
7f7fe91e 107 const greg_t *regp = (const greg_t *) gregsetp;
40e20472 108 int regnum;
fcc9bf01 109
40e20472 110 for (regnum = 0; regnum < I386_NUM_GREGS; regnum++)
7f7fe91e 111 regcache_raw_supply (regcache, regnum, regp + regmap[regnum]);
c906108c
SS
112}
113
40e20472
MK
114/* Fill register REGNUM (if it is a general-purpose register) in
115 *GREGSETPS with the value in GDB's register array. If REGNUM is -1,
fcc9bf01
MK
116 do this for all registers. */
117
c906108c 118void
7f7fe91e
UW
119fill_gregset (const struct regcache *regcache,
120 gregset_t *gregsetp, int regnum)
c906108c 121{
fcc9bf01
MK
122 greg_t *regp = (greg_t *) gregsetp;
123 int i;
124
125 for (i = 0; i < I386_NUM_GREGS; i++)
40e20472 126 if (regnum == -1 || regnum == i)
7f7fe91e 127 regcache_raw_collect (regcache, i, regp + regmap[i]);
c906108c
SS
128}
129
c5aa993b 130#endif /* HAVE_GREGSET_T */
c906108c 131
fcc9bf01 132#ifdef HAVE_FPREGSET_T
c906108c 133
fcc9bf01
MK
134/* Fill GDB's register array with the floating-point register values in
135 *FPREGSETP. */
14164c30 136
c5aa993b 137void
7f7fe91e 138supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
c906108c 139{
875f8d0e 140 if (gdbarch_fp0_regnum (get_regcache_arch (regcache)) == 0)
14164c30 141 return;
14164c30 142
7f7fe91e 143 i387_supply_fsave (regcache, -1, fpregsetp);
c906108c
SS
144}
145
fcc9bf01
MK
146/* Fill register REGNO (if it is a floating-point register) in
147 *FPREGSETP with the value in GDB's register array. If REGNO is -1,
148 do this for all registers. */
c906108c
SS
149
150void
7f7fe91e
UW
151fill_fpregset (const struct regcache *regcache,
152 fpregset_t *fpregsetp, int regno)
c906108c 153{
875f8d0e 154 if (gdbarch_fp0_regnum (get_regcache_arch (regcache)) == 0)
14164c30 155 return;
34588f23 156
7f7fe91e 157 i387_collect_fsave (regcache, regno, fpregsetp);
c906108c
SS
158}
159
fcc9bf01 160#endif /* HAVE_FPREGSET_T */
c906108c 161
f69c55b2
MK
162#endif /* not 64-bit. */
163
c5aa993b 164#endif /* HAVE_SYS_PROCFS_H */
This page took 0.669985 seconds and 4 git commands to generate.