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 | ||
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 | ||
7919c3ed | 67 | void |
dd3b648e RP |
68 | store_inferior_registers (regno) |
69 | int regno; | |
70 | { | |
71 | struct regs inferior_registers; | |
72 | #ifdef FP0_REGNUM | |
73 | struct fp_status inferior_fp_registers; | |
74 | #endif | |
75 | extern char registers[]; | |
76 | ||
77 | bcopy (registers, &inferior_registers, 16 * 4); | |
78 | #ifdef FP0_REGNUM | |
79 | bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, | |
80 | sizeof inferior_fp_registers.fps_regs); | |
81 | #endif | |
82 | inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; | |
83 | inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; | |
84 | ||
85 | #ifdef FP0_REGNUM | |
86 | bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], | |
87 | &inferior_fp_registers.fps_control, | |
88 | sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); | |
89 | #endif | |
90 | ||
91 | ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); | |
92 | #if FP0_REGNUM | |
93 | ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); | |
94 | #endif | |
95 | } | |
96 | ||
97 | /* Machine-dependent code for pulling registers out of a Sun-3 core file. */ | |
98 | ||
99 | void | |
7919c3ed | 100 | fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr) |
dd3b648e RP |
101 | char *core_reg_sect; |
102 | unsigned core_reg_size; | |
103 | int which; | |
7919c3ed | 104 | unsigned int reg_addr; /* Unused in this version */ |
dd3b648e RP |
105 | { |
106 | extern char registers[]; | |
107 | struct regs *regs = (struct regs *) core_reg_sect; | |
108 | ||
109 | if (which == 0) { | |
110 | if (core_reg_size < sizeof (struct regs)) | |
111 | error ("Can't find registers in core file"); | |
112 | ||
113 | bcopy ((char *)regs, registers, 16 * 4); | |
114 | supply_register (PS_REGNUM, ®s->r_ps); | |
115 | supply_register (PC_REGNUM, ®s->r_pc); | |
116 | ||
117 | } else if (which == 2) { | |
118 | ||
119 | #define fpustruct ((struct fpu *) core_reg_sect) | |
120 | ||
121 | if (core_reg_size >= sizeof (struct fpu)) | |
122 | { | |
f2ebc25f | 123 | #ifdef FP0_REGNUM |
dd3b648e RP |
124 | bcopy (fpustruct->f_fpstatus.fps_regs, |
125 | ®isters[REGISTER_BYTE (FP0_REGNUM)], | |
126 | sizeof fpustruct->f_fpstatus.fps_regs); | |
127 | bcopy (&fpustruct->f_fpstatus.fps_control, | |
128 | ®isters[REGISTER_BYTE (FPC_REGNUM)], | |
129 | sizeof fpustruct->f_fpstatus - | |
130 | sizeof fpustruct->f_fpstatus.fps_regs); | |
f2ebc25f | 131 | #endif |
dd3b648e RP |
132 | } |
133 | else | |
134 | fprintf (stderr, "Couldn't read float regs from core file\n"); | |
135 | } | |
136 | } | |
9a822037 JK |
137 | #else /* Not sun3 target. */ |
138 | /* These functions shouldn't be called when we're cross-debugging. */ | |
139 | ||
7919c3ed | 140 | /* ARGSUSED */ |
9a822037 | 141 | void |
7919c3ed JG |
142 | fetch_inferior_registers (regno) |
143 | int regno; | |
9a822037 JK |
144 | { |
145 | } | |
146 | ||
147 | /* ARGSUSED */ | |
7919c3ed | 148 | void |
9a822037 JK |
149 | store_inferior_registers (regno) |
150 | int regno; | |
151 | { | |
152 | } | |
153 | ||
154 | /* ARGSUSED */ | |
155 | void | |
7919c3ed | 156 | fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr) |
9a822037 JK |
157 | char *core_reg_sect; |
158 | unsigned core_reg_size; | |
159 | int which; | |
7919c3ed | 160 | unsigned int reg_addr; /* Unused in this version */ |
9a822037 JK |
161 | { |
162 | } | |
163 | #endif /* Not sun3 target. */ |