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