]>
Commit | Line | Data |
---|---|---|
4d0eabff | 1 | /* Native-dependent code for SVR4 Unix running on i386's, for GDB. |
e33aefba | 2 | Copyright 1988, 1989, 1991, 1992, 1996 Free Software Foundation, Inc. |
4d0eabff FF |
3 | |
4 | This file is part of GDB. | |
5 | ||
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. | |
10 | ||
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. | |
15 | ||
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 | |
6c9638b4 | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
4d0eabff | 19 | |
4708ac65 FF |
20 | #ifdef HAVE_SYS_PROCFS_H |
21 | ||
4d0eabff FF |
22 | #include "defs.h" |
23 | #include <sys/procfs.h> | |
24 | ||
25 | /* The /proc interface divides the target machine's register set up into | |
26 | two different sets, the general register set (gregset) and the floating | |
27 | point register set (fpregset). For each set, there is an ioctl to get | |
28 | the current register set and another ioctl to set the current values. | |
29 | ||
30 | The actual structure passed through the ioctl interface is, of course, | |
31 | naturally machine dependent, and is different for each set of registers. | |
32 | For the i386 for example, the general register set is typically defined | |
33 | by: | |
34 | ||
35 | typedef int gregset_t[19]; (in <sys/regset.h>) | |
36 | ||
37 | #define GS 0 (in <sys/reg.h>) | |
38 | #define FS 1 | |
39 | ... | |
40 | #define UESP 17 | |
41 | #define SS 18 | |
42 | ||
43 | and the floating point set by: | |
44 | ||
45 | typedef struct fpregset | |
46 | { | |
47 | union | |
48 | { | |
49 | struct fpchip_state // fp extension state // | |
50 | { | |
51 | int state[27]; // 287/387 saved state // | |
52 | int status; // status word saved at exception // | |
53 | } fpchip_state; | |
54 | struct fp_emul_space // for emulators // | |
55 | { | |
56 | char fp_emul[246]; | |
57 | char fp_epad[2]; | |
58 | } fp_emul_space; | |
59 | int f_fpregs[62]; // union of the above // | |
60 | } fp_reg_set; | |
61 | long f_wregs[33]; // saved weitek state // | |
62 | } fpregset_t; | |
63 | ||
64 | These routines provide the packing and unpacking of gregset_t and | |
65 | fpregset_t formatted data. | |
66 | ||
67 | */ | |
68 | ||
4708ac65 FF |
69 | #ifdef HAVE_GREGSET_T |
70 | ||
4d0eabff FF |
71 | /* This is a duplicate of the table in i386-xdep.c. */ |
72 | ||
73 | static int regmap[] = | |
74 | { | |
75 | EAX, ECX, EDX, EBX, | |
76 | UESP, EBP, ESI, EDI, | |
77 | EIP, EFL, CS, SS, | |
78 | DS, ES, FS, GS, | |
79 | }; | |
80 | ||
81 | ||
e33aefba FF |
82 | /* FIXME: These routine absolutely depends upon (NUM_REGS - NUM_FREGS) |
83 | being less than or equal to the number of registers that can be stored | |
84 | in a gregset_t. Note that with the current scheme there will typically | |
85 | be more registers actually stored in a gregset_t that what we know | |
86 | about. This is bogus and should be fixed. */ | |
87 | ||
4d0eabff FF |
88 | /* Given a pointer to a general register set in /proc format (gregset_t *), |
89 | unpack the register contents and supply them as gdb's idea of the current | |
90 | register values. */ | |
91 | ||
92 | void | |
93 | supply_gregset (gregsetp) | |
94 | gregset_t *gregsetp; | |
95 | { | |
96 | register int regi; | |
97 | register greg_t *regp = (greg_t *) gregsetp; | |
98 | extern int regmap[]; | |
99 | ||
e33aefba | 100 | for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++) |
4d0eabff FF |
101 | { |
102 | supply_register (regi, (char *) (regp + regmap[regi])); | |
103 | } | |
104 | } | |
105 | ||
106 | void | |
107 | fill_gregset (gregsetp, regno) | |
108 | gregset_t *gregsetp; | |
109 | int regno; | |
110 | { | |
111 | int regi; | |
112 | register greg_t *regp = (greg_t *) gregsetp; | |
113 | extern char registers[]; | |
114 | extern int regmap[]; | |
115 | ||
e33aefba | 116 | for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++) |
4d0eabff FF |
117 | { |
118 | if ((regno == -1) || (regno == regi)) | |
119 | { | |
120 | *(regp + regmap[regi]) = *(int *) ®isters[REGISTER_BYTE (regi)]; | |
121 | } | |
122 | } | |
123 | } | |
124 | ||
4708ac65 FF |
125 | #endif /* HAVE_GREGSET_T */ |
126 | ||
127 | #if defined (FP0_REGNUM) && defined (HAVE_FPREGSET_T) | |
4d0eabff FF |
128 | |
129 | /* Given a pointer to a floating point register set in /proc format | |
130 | (fpregset_t *), unpack the register contents and supply them as gdb's | |
131 | idea of the current floating point register values. */ | |
132 | ||
133 | void | |
134 | supply_fpregset (fpregsetp) | |
135 | fpregset_t *fpregsetp; | |
136 | { | |
137 | register int regi; | |
138 | ||
139 | /* FIXME: see m68k-tdep.c for an example, for the m68k. */ | |
140 | } | |
141 | ||
142 | /* Given a pointer to a floating point register set in /proc format | |
143 | (fpregset_t *), update the register specified by REGNO from gdb's idea | |
144 | of the current floating point register set. If REGNO is -1, update | |
145 | them all. */ | |
146 | ||
147 | void | |
148 | fill_fpregset (fpregsetp, regno) | |
149 | fpregset_t *fpregsetp; | |
150 | int regno; | |
151 | { | |
152 | int regi; | |
153 | char *to; | |
154 | char *from; | |
155 | extern char registers[]; | |
156 | ||
157 | /* FIXME: see m68k-tdep.c for an example, for the m68k. */ | |
158 | } | |
159 | ||
4708ac65 FF |
160 | #endif /* defined (FP0_REGNUM) && defined (HAVE_FPREGSET_T) */ |
161 | ||
162 | #endif /* HAVE_SYS_PROCFS_H */ |