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