Commit | Line | Data |
---|---|---|
5f04ac3d C |
1 | /* Native-dependent code for NetBSD/i386, for GDB. |
2 | Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000 | |
3 | Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
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 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include <sys/types.h> | |
24 | #include <sys/ptrace.h> | |
25 | #include <machine/reg.h> | |
26 | #include <machine/frame.h> | |
27 | #include "inferior.h" | |
28 | #include "gdbcore.h" /* for registers_fetched() */ | |
29 | ||
30 | #define RF(dst, src) \ | |
31 | memcpy(®isters[REGISTER_BYTE(dst)], &src, sizeof(src)) | |
32 | ||
33 | #define RS(src, dst) \ | |
34 | memcpy(&dst, ®isters[REGISTER_BYTE(src)], sizeof(dst)) | |
35 | ||
36 | struct env387 | |
37 | { | |
38 | unsigned short control; | |
39 | unsigned short r0; | |
40 | unsigned short status; | |
41 | unsigned short r1; | |
42 | unsigned short tag; | |
43 | unsigned short r2; | |
44 | unsigned long eip; | |
45 | unsigned short code_seg; | |
46 | unsigned short opcode; | |
47 | unsigned long operand; | |
48 | unsigned short operand_seg; | |
49 | unsigned short r3; | |
50 | unsigned char regs[8][10]; | |
51 | }; | |
52 | ||
53 | void | |
54 | fetch_inferior_registers (regno) | |
55 | int regno; | |
56 | { | |
57 | struct reg inferior_registers; | |
58 | struct env387 inferior_fpregisters; | |
59 | ||
60 | ptrace (PT_GETREGS, inferior_pid, | |
61 | (PTRACE_ARG3_TYPE) &inferior_registers, 0); | |
62 | ptrace (PT_GETFPREGS, inferior_pid, | |
63 | (PTRACE_ARG3_TYPE) &inferior_fpregisters, 0); | |
64 | ||
65 | RF ( 0, inferior_registers.r_eax); | |
66 | RF ( 1, inferior_registers.r_ecx); | |
67 | RF ( 2, inferior_registers.r_edx); | |
68 | RF ( 3, inferior_registers.r_ebx); | |
69 | RF ( 4, inferior_registers.r_esp); | |
70 | RF ( 5, inferior_registers.r_ebp); | |
71 | RF ( 6, inferior_registers.r_esi); | |
72 | RF ( 7, inferior_registers.r_edi); | |
73 | RF ( 8, inferior_registers.r_eip); | |
74 | RF ( 9, inferior_registers.r_eflags); | |
75 | RF (10, inferior_registers.r_cs); | |
76 | RF (11, inferior_registers.r_ss); | |
77 | RF (12, inferior_registers.r_ds); | |
78 | RF (13, inferior_registers.r_es); | |
79 | RF (14, inferior_registers.r_fs); | |
80 | RF (15, inferior_registers.r_gs); | |
81 | ||
82 | RF (FP0_REGNUM, inferior_fpregisters.regs[0]); | |
83 | RF (FP0_REGNUM + 1, inferior_fpregisters.regs[1]); | |
84 | RF (FP0_REGNUM + 2, inferior_fpregisters.regs[2]); | |
85 | RF (FP0_REGNUM + 3, inferior_fpregisters.regs[3]); | |
86 | RF (FP0_REGNUM + 4, inferior_fpregisters.regs[4]); | |
87 | RF (FP0_REGNUM + 5, inferior_fpregisters.regs[5]); | |
88 | RF (FP0_REGNUM + 6, inferior_fpregisters.regs[6]); | |
89 | RF (FP0_REGNUM + 7, inferior_fpregisters.regs[7]); | |
90 | ||
91 | RF (FCTRL_REGNUM, inferior_fpregisters.control); | |
92 | RF (FSTAT_REGNUM, inferior_fpregisters.status); | |
93 | RF (FTAG_REGNUM, inferior_fpregisters.tag); | |
94 | RF (FCS_REGNUM, inferior_fpregisters.code_seg); | |
95 | RF (FCOFF_REGNUM, inferior_fpregisters.eip); | |
96 | RF (FDS_REGNUM, inferior_fpregisters.operand_seg); | |
97 | RF (FDOFF_REGNUM, inferior_fpregisters.operand); | |
98 | RF (FOP_REGNUM, inferior_fpregisters.opcode); | |
99 | ||
100 | registers_fetched (); | |
101 | } | |
102 | ||
103 | void | |
104 | store_inferior_registers (regno) | |
105 | int regno; | |
106 | { | |
107 | struct reg inferior_registers; | |
108 | struct env387 inferior_fpregisters; | |
109 | ||
110 | RS ( 0, inferior_registers.r_eax); | |
111 | RS ( 1, inferior_registers.r_ecx); | |
112 | RS ( 2, inferior_registers.r_edx); | |
113 | RS ( 3, inferior_registers.r_ebx); | |
114 | RS ( 4, inferior_registers.r_esp); | |
115 | RS ( 5, inferior_registers.r_ebp); | |
116 | RS ( 6, inferior_registers.r_esi); | |
117 | RS ( 7, inferior_registers.r_edi); | |
118 | RS ( 8, inferior_registers.r_eip); | |
119 | RS ( 9, inferior_registers.r_eflags); | |
120 | RS (10, inferior_registers.r_cs); | |
121 | RS (11, inferior_registers.r_ss); | |
122 | RS (12, inferior_registers.r_ds); | |
123 | RS (13, inferior_registers.r_es); | |
124 | RS (14, inferior_registers.r_fs); | |
125 | RS (15, inferior_registers.r_gs); | |
126 | ||
127 | ||
128 | RS (FP0_REGNUM, inferior_fpregisters.regs[0]); | |
129 | RS (FP0_REGNUM + 1, inferior_fpregisters.regs[1]); | |
130 | RS (FP0_REGNUM + 2, inferior_fpregisters.regs[2]); | |
131 | RS (FP0_REGNUM + 3, inferior_fpregisters.regs[3]); | |
132 | RS (FP0_REGNUM + 4, inferior_fpregisters.regs[4]); | |
133 | RS (FP0_REGNUM + 5, inferior_fpregisters.regs[5]); | |
134 | RS (FP0_REGNUM + 6, inferior_fpregisters.regs[6]); | |
135 | RS (FP0_REGNUM + 7, inferior_fpregisters.regs[7]); | |
136 | ||
137 | RS (FCTRL_REGNUM, inferior_fpregisters.control); | |
138 | RS (FSTAT_REGNUM, inferior_fpregisters.status); | |
139 | RS (FTAG_REGNUM, inferior_fpregisters.tag); | |
140 | RS (FCS_REGNUM, inferior_fpregisters.code_seg); | |
141 | RS (FCOFF_REGNUM, inferior_fpregisters.eip); | |
142 | RS (FDS_REGNUM, inferior_fpregisters.operand_seg); | |
143 | RS (FDOFF_REGNUM, inferior_fpregisters.operand); | |
144 | RS (FOP_REGNUM, inferior_fpregisters.opcode); | |
145 | ||
146 | ptrace (PT_SETREGS, inferior_pid, | |
147 | (PTRACE_ARG3_TYPE) &inferior_registers, 0); | |
148 | ptrace (PT_SETFPREGS, inferior_pid, | |
149 | (PTRACE_ARG3_TYPE) &inferior_fpregisters, 0); | |
150 | } | |
151 | ||
152 | struct md_core | |
153 | { | |
154 | struct reg intreg; | |
155 | struct fpreg freg; | |
156 | }; | |
157 | ||
158 | void | |
159 | fetch_core_registers (core_reg_sect, core_reg_size, which, ignore) | |
160 | char *core_reg_sect; | |
161 | unsigned core_reg_size; | |
162 | int which; | |
163 | CORE_ADDR ignore; | |
164 | { | |
165 | struct md_core *core_reg = (struct md_core *) core_reg_sect; | |
166 | ||
167 | /* integer registers */ | |
168 | memcpy (®isters[REGISTER_BYTE (0)], &core_reg->intreg, | |
169 | sizeof (struct reg)); | |
170 | /* floating point registers */ | |
171 | /* XXX */ | |
172 | } |