]>
Commit | Line | Data |
---|---|---|
7d9884b9 JG |
1 | /* Host-dependent code for Sun-3 for GDB, the GNU debugger. |
2 | Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc. | |
dd3b648e RP |
3 | |
4 | This file is part of GDB. | |
5 | ||
99a7de40 | 6 | This program is free software; you can redistribute it and/or modify |
dd3b648e | 7 | it under the terms of the GNU General Public License as published by |
99a7de40 JG |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
dd3b648e | 10 | |
99a7de40 | 11 | This program is distributed in the hope that it will be useful, |
dd3b648e RP |
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 | |
99a7de40 JG |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
dd3b648e | 19 | |
dd3b648e | 20 | #include "defs.h" |
dd3b648e | 21 | #include "inferior.h" |
7d9884b9 | 22 | #include "gdbcore.h" |
dd3b648e RP |
23 | |
24 | #include <sys/ptrace.h> | |
25 | #define KERNEL /* To get floating point reg definitions */ | |
26 | #include <machine/reg.h> | |
27 | ||
dd3b648e RP |
28 | extern int errno; |
29 | ||
39d2bcca | 30 | #if defined (GDB_TARGET_IS_SUN3) |
9a822037 | 31 | /* All of this stuff is only relevant if both host and target are sun3. */ |
dd3b648e | 32 | void |
7919c3ed JG |
33 | fetch_inferior_registers (regno) |
34 | int regno; | |
dd3b648e RP |
35 | { |
36 | struct regs inferior_registers; | |
37 | #ifdef FP0_REGNUM | |
38 | struct fp_status inferior_fp_registers; | |
39 | #endif | |
40 | extern char registers[]; | |
41 | ||
42 | registers_fetched (); | |
43 | ||
e676a15f FF |
44 | ptrace (PTRACE_GETREGS, inferior_pid, |
45 | (PTRACE_ARG3_TYPE) &inferior_registers); | |
dd3b648e | 46 | #ifdef FP0_REGNUM |
e676a15f FF |
47 | ptrace (PTRACE_GETFPREGS, inferior_pid, |
48 | (PTRACE_ARG3_TYPE) &inferior_fp_registers); | |
dd3b648e RP |
49 | #endif |
50 | ||
51 | bcopy (&inferior_registers, registers, 16 * 4); | |
52 | #ifdef FP0_REGNUM | |
53 | bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], | |
54 | sizeof inferior_fp_registers.fps_regs); | |
55 | #endif | |
56 | *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; | |
57 | *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; | |
58 | #ifdef FP0_REGNUM | |
59 | bcopy (&inferior_fp_registers.fps_control, | |
60 | ®isters[REGISTER_BYTE (FPC_REGNUM)], | |
61 | sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); | |
62 | #endif | |
63 | } | |
64 | ||
65 | /* Store our register values back into the inferior. | |
66 | If REGNO is -1, do this for all registers. | |
67 | Otherwise, REGNO specifies which register (so we can save time). */ | |
68 | ||
7919c3ed | 69 | void |
dd3b648e RP |
70 | store_inferior_registers (regno) |
71 | int regno; | |
72 | { | |
73 | struct regs inferior_registers; | |
74 | #ifdef FP0_REGNUM | |
75 | struct fp_status inferior_fp_registers; | |
76 | #endif | |
77 | extern char registers[]; | |
78 | ||
79 | bcopy (registers, &inferior_registers, 16 * 4); | |
80 | #ifdef FP0_REGNUM | |
81 | bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, | |
82 | sizeof inferior_fp_registers.fps_regs); | |
83 | #endif | |
84 | inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; | |
85 | inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; | |
86 | ||
87 | #ifdef FP0_REGNUM | |
88 | bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], | |
89 | &inferior_fp_registers.fps_control, | |
90 | sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); | |
91 | #endif | |
92 | ||
e676a15f FF |
93 | ptrace (PTRACE_SETREGS, inferior_pid, |
94 | (PTRACE_ARG3_TYPE) &inferior_registers); | |
dd3b648e | 95 | #if FP0_REGNUM |
e676a15f FF |
96 | ptrace (PTRACE_SETFPREGS, inferior_pid, |
97 | (PTRACE_ARG3_TYPE) &inferior_fp_registers); | |
dd3b648e RP |
98 | #endif |
99 | } | |
100 | ||
101 | /* Machine-dependent code for pulling registers out of a Sun-3 core file. */ | |
102 | ||
103 | void | |
7919c3ed | 104 | fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr) |
dd3b648e RP |
105 | char *core_reg_sect; |
106 | unsigned core_reg_size; | |
107 | int which; | |
7919c3ed | 108 | unsigned int reg_addr; /* Unused in this version */ |
dd3b648e RP |
109 | { |
110 | extern char registers[]; | |
111 | struct regs *regs = (struct regs *) core_reg_sect; | |
112 | ||
113 | if (which == 0) { | |
114 | if (core_reg_size < sizeof (struct regs)) | |
115 | error ("Can't find registers in core file"); | |
116 | ||
117 | bcopy ((char *)regs, registers, 16 * 4); | |
b0c8c726 JG |
118 | supply_register (PS_REGNUM, (char *)®s->r_ps); |
119 | supply_register (PC_REGNUM, (char *)®s->r_pc); | |
dd3b648e RP |
120 | |
121 | } else if (which == 2) { | |
122 | ||
123 | #define fpustruct ((struct fpu *) core_reg_sect) | |
124 | ||
125 | if (core_reg_size >= sizeof (struct fpu)) | |
126 | { | |
f2ebc25f | 127 | #ifdef FP0_REGNUM |
dd3b648e RP |
128 | bcopy (fpustruct->f_fpstatus.fps_regs, |
129 | ®isters[REGISTER_BYTE (FP0_REGNUM)], | |
130 | sizeof fpustruct->f_fpstatus.fps_regs); | |
131 | bcopy (&fpustruct->f_fpstatus.fps_control, | |
132 | ®isters[REGISTER_BYTE (FPC_REGNUM)], | |
133 | sizeof fpustruct->f_fpstatus - | |
134 | sizeof fpustruct->f_fpstatus.fps_regs); | |
f2ebc25f | 135 | #endif |
dd3b648e RP |
136 | } |
137 | else | |
138 | fprintf (stderr, "Couldn't read float regs from core file\n"); | |
139 | } | |
140 | } | |
9a822037 JK |
141 | #else /* Not sun3 target. */ |
142 | /* These functions shouldn't be called when we're cross-debugging. */ | |
143 | ||
7919c3ed | 144 | /* ARGSUSED */ |
9a822037 | 145 | void |
7919c3ed JG |
146 | fetch_inferior_registers (regno) |
147 | int regno; | |
9a822037 JK |
148 | { |
149 | } | |
150 | ||
151 | /* ARGSUSED */ | |
7919c3ed | 152 | void |
9a822037 JK |
153 | store_inferior_registers (regno) |
154 | int regno; | |
155 | { | |
156 | } | |
157 | ||
158 | /* ARGSUSED */ | |
159 | void | |
7919c3ed | 160 | fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr) |
9a822037 JK |
161 | char *core_reg_sect; |
162 | unsigned core_reg_size; | |
163 | int which; | |
7919c3ed | 164 | unsigned int reg_addr; /* Unused in this version */ |
9a822037 JK |
165 | { |
166 | } | |
167 | #endif /* Not sun3 target. */ |