1 /* Native-dependent code for SVR4 Unix running on i386's, for GDB.
2 Copyright 1988, 1989, 1991, 1992, 1996 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 #ifdef HAVE_SYS_PROCFS_H
28 #include <sys/procfs.h>
30 /* The /proc interface divides the target machine's register set up into
31 two different sets, the general register set (gregset) and the floating
32 point register set (fpregset). For each set, there is an ioctl to get
33 the current register set and another ioctl to set the current values.
35 The actual structure passed through the ioctl interface is, of course,
36 naturally machine dependent, and is different for each set of registers.
37 For the i386 for example, the general register set is typically defined
40 typedef int gregset_t[19]; (in <sys/regset.h>)
42 #define GS 0 (in <sys/reg.h>)
48 and the floating point set by:
50 typedef struct fpregset
54 struct fpchip_state // fp extension state //
56 int state[27]; // 287/387 saved state //
57 int status; // status word saved at exception //
59 struct fp_emul_space // for emulators //
64 int f_fpregs[62]; // union of the above //
66 long f_wregs[33]; // saved weitek state //
69 These routines provide the packing and unpacking of gregset_t and
70 fpregset_t formatted data.
76 /* This is a duplicate of the table in i386-xdep.c. */
87 /* FIXME: These routine absolutely depends upon (NUM_REGS - NUM_FREGS)
88 being less than or equal to the number of registers that can be stored
89 in a gregset_t. Note that with the current scheme there will typically
90 be more registers actually stored in a gregset_t that what we know
91 about. This is bogus and should be fixed. */
93 /* Given a pointer to a general register set in /proc format (gregset_t *),
94 unpack the register contents and supply them as gdb's idea of the current
98 supply_gregset (gregsetp)
102 register greg_t *regp = (greg_t *) gregsetp;
105 for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++)
107 supply_register (regi, (char *) (regp + regmap[regi]));
112 fill_gregset (gregsetp, regno)
117 register greg_t *regp = (greg_t *) gregsetp;
118 extern char registers[];
121 for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++)
123 if ((regno == -1) || (regno == regi))
125 *(regp + regmap[regi]) = *(int *) ®isters[REGISTER_BYTE (regi)];
130 #endif /* HAVE_GREGSET_T */
132 #if defined (FP0_REGNUM) && defined (HAVE_FPREGSET_T)
134 /* Given a pointer to a floating point register set in /proc format
135 (fpregset_t *), unpack the register contents and supply them as gdb's
136 idea of the current floating point register values. */
139 supply_fpregset (fpregsetp)
140 fpregset_t *fpregsetp;
142 /* FIXME: see m68k-tdep.c for an example, for the m68k. */
145 /* Given a pointer to a floating point register set in /proc format
146 (fpregset_t *), update the register specified by REGNO from gdb's idea
147 of the current floating point register set. If REGNO is -1, update
151 fill_fpregset (fpregsetp, regno)
152 fpregset_t *fpregsetp;
155 /* FIXME: see m68k-tdep.c for an example, for the m68k. */
158 #endif /* defined (FP0_REGNUM) && defined (HAVE_FPREGSET_T) */
160 #endif /* HAVE_SYS_PROCFS_H */