1 /* Native-dependent code for Unix SVR4 running on i386's.
3 Copyright (C) 1988-2013 Free Software Foundation, Inc.
5 This file is part of GDB.
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
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
29 #include "i386-tdep.h"
30 #include "i387-tdep.h"
32 #ifdef HAVE_SYS_PROCFS_H
34 #include <sys/procfs.h>
36 /* We must not compile this code for 64-bit Solaris x86. */
37 #if !defined (PR_MODEL_NATIVE) || (PR_MODEL_NATIVE == PR_MODEL_ILP32)
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.
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:
52 typedef int gregset_t[19]; (in <sys/regset.h>)
54 #define GS 0 (in <sys/reg.h>)
60 and the floating-point set by:
62 typedef struct fpregset {
64 struct fpchip_state // fp extension state //
66 int state[27]; // 287/387 saved state //
67 int status; // status word saved at //
70 struct fp_emul_space // for emulators //
75 int f_fpregs[62]; // union of the above //
77 long f_wregs[33]; // saved weitek state //
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.
85 The routines defined here, provide the packing and unpacking of
86 gregset_t and fpregset_t formatted data. */
90 /* Mapping between the general-purpose registers in `/proc'
91 format and GDB's register array layout. */
100 /* Fill GDB's register array with the general-purpose register values
104 supply_gregset (struct regcache
*regcache
, const gregset_t
*gregsetp
)
106 const greg_t
*regp
= (const greg_t
*) gregsetp
;
109 for (regnum
= 0; regnum
< I386_NUM_GREGS
; regnum
++)
110 regcache_raw_supply (regcache
, regnum
, regp
+ regmap
[regnum
]);
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,
115 do this for all registers. */
118 fill_gregset (const struct regcache
*regcache
,
119 gregset_t
*gregsetp
, int regnum
)
121 greg_t
*regp
= (greg_t
*) gregsetp
;
124 for (i
= 0; i
< I386_NUM_GREGS
; i
++)
125 if (regnum
== -1 || regnum
== i
)
126 regcache_raw_collect (regcache
, i
, regp
+ regmap
[i
]);
129 #endif /* HAVE_GREGSET_T */
131 #ifdef HAVE_FPREGSET_T
133 /* Fill GDB's register array with the floating-point register values in
137 supply_fpregset (struct regcache
*regcache
, const fpregset_t
*fpregsetp
)
139 if (gdbarch_fp0_regnum (get_regcache_arch (regcache
)) == 0)
142 i387_supply_fsave (regcache
, -1, fpregsetp
);
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. */
150 fill_fpregset (const struct regcache
*regcache
,
151 fpregset_t
*fpregsetp
, int regno
)
153 if (gdbarch_fp0_regnum (get_regcache_arch (regcache
)) == 0)
156 i387_collect_fsave (regcache
, regno
, fpregsetp
);
159 #endif /* HAVE_FPREGSET_T */
161 #endif /* not 64-bit. */
163 #endif /* HAVE_SYS_PROCFS_H */
This page took 0.042232 seconds and 4 git commands to generate.