]>
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 RP |
19 | |
20 | #include <stdio.h> | |
21 | #include "defs.h" | |
dd3b648e | 22 | #include "inferior.h" |
7d9884b9 | 23 | #include "gdbcore.h" |
dd3b648e RP |
24 | |
25 | #include <sys/ptrace.h> | |
26 | #define KERNEL /* To get floating point reg definitions */ | |
27 | #include <machine/reg.h> | |
28 | ||
dd3b648e RP |
29 | extern int errno; |
30 | ||
39d2bcca | 31 | #if defined (GDB_TARGET_IS_SUN3) |
9a822037 | 32 | /* All of this stuff is only relevant if both host and target are sun3. */ |
dd3b648e RP |
33 | void |
34 | fetch_inferior_registers () | |
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 | ||
44 | ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers); | |
45 | #ifdef FP0_REGNUM | |
46 | ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers); | |
47 | #endif | |
48 | ||
49 | bcopy (&inferior_registers, registers, 16 * 4); | |
50 | #ifdef FP0_REGNUM | |
51 | bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], | |
52 | sizeof inferior_fp_registers.fps_regs); | |
53 | #endif | |
54 | *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; | |
55 | *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; | |
56 | #ifdef FP0_REGNUM | |
57 | bcopy (&inferior_fp_registers.fps_control, | |
58 | ®isters[REGISTER_BYTE (FPC_REGNUM)], | |
59 | sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); | |
60 | #endif | |
61 | } | |
62 | ||
63 | /* Store our register values back into the inferior. | |
64 | If REGNO is -1, do this for all registers. | |
65 | Otherwise, REGNO specifies which register (so we can save time). */ | |
66 | ||
67 | store_inferior_registers (regno) | |
68 | int regno; | |
69 | { | |
70 | struct regs inferior_registers; | |
71 | #ifdef FP0_REGNUM | |
72 | struct fp_status inferior_fp_registers; | |
73 | #endif | |
74 | extern char registers[]; | |
75 | ||
76 | bcopy (registers, &inferior_registers, 16 * 4); | |
77 | #ifdef FP0_REGNUM | |
78 | bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, | |
79 | sizeof inferior_fp_registers.fps_regs); | |
80 | #endif | |
81 | inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; | |
82 | inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; | |
83 | ||
84 | #ifdef FP0_REGNUM | |
85 | bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], | |
86 | &inferior_fp_registers.fps_control, | |
87 | sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); | |
88 | #endif | |
89 | ||
90 | ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); | |
91 | #if FP0_REGNUM | |
92 | ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); | |
93 | #endif | |
94 | } | |
95 | ||
96 | /* Machine-dependent code for pulling registers out of a Sun-3 core file. */ | |
97 | ||
98 | void | |
99 | fetch_core_registers (core_reg_sect, core_reg_size, which) | |
100 | char *core_reg_sect; | |
101 | unsigned core_reg_size; | |
102 | int which; | |
103 | { | |
104 | extern char registers[]; | |
105 | struct regs *regs = (struct regs *) core_reg_sect; | |
106 | ||
107 | if (which == 0) { | |
108 | if (core_reg_size < sizeof (struct regs)) | |
109 | error ("Can't find registers in core file"); | |
110 | ||
111 | bcopy ((char *)regs, registers, 16 * 4); | |
112 | supply_register (PS_REGNUM, ®s->r_ps); | |
113 | supply_register (PC_REGNUM, ®s->r_pc); | |
114 | ||
115 | } else if (which == 2) { | |
116 | ||
117 | #define fpustruct ((struct fpu *) core_reg_sect) | |
118 | ||
119 | if (core_reg_size >= sizeof (struct fpu)) | |
120 | { | |
f2ebc25f | 121 | #ifdef FP0_REGNUM |
dd3b648e RP |
122 | bcopy (fpustruct->f_fpstatus.fps_regs, |
123 | ®isters[REGISTER_BYTE (FP0_REGNUM)], | |
124 | sizeof fpustruct->f_fpstatus.fps_regs); | |
125 | bcopy (&fpustruct->f_fpstatus.fps_control, | |
126 | ®isters[REGISTER_BYTE (FPC_REGNUM)], | |
127 | sizeof fpustruct->f_fpstatus - | |
128 | sizeof fpustruct->f_fpstatus.fps_regs); | |
f2ebc25f | 129 | #endif |
dd3b648e RP |
130 | } |
131 | else | |
132 | fprintf (stderr, "Couldn't read float regs from core file\n"); | |
133 | } | |
134 | } | |
9a822037 JK |
135 | #else /* Not sun3 target. */ |
136 | /* These functions shouldn't be called when we're cross-debugging. */ | |
137 | ||
138 | void | |
139 | fetch_inferior_registers () | |
140 | { | |
141 | } | |
142 | ||
143 | /* ARGSUSED */ | |
144 | store_inferior_registers (regno) | |
145 | int regno; | |
146 | { | |
147 | } | |
148 | ||
149 | /* ARGSUSED */ | |
150 | void | |
151 | fetch_core_registers (core_reg_sect, core_reg_size, which) | |
152 | char *core_reg_sect; | |
153 | unsigned core_reg_size; | |
154 | int which; | |
155 | { | |
156 | } | |
157 | #endif /* Not sun3 target. */ |