]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Host-dependent code for Apollo-68ks for GDB, the GNU debugger. |
2 | Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc. | |
3 | ||
c5aa993b | 4 | This file is part of GDB. |
c906108c | 5 | |
c5aa993b JM |
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. | |
c906108c | 10 | |
c5aa993b JM |
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. | |
c906108c | 15 | |
c5aa993b JM |
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., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
20 | |
21 | #include "defs.h" | |
22 | #include "inferior.h" | |
23 | ||
24 | #ifndef _ISP__M68K | |
25 | #define _ISP__M68K 1 | |
26 | #endif | |
27 | ||
28 | #include <ptrace.h> | |
29 | ||
30 | extern int errno; | |
31 | ||
32 | void | |
33 | fetch_inferior_registers (ignored) | |
c5aa993b | 34 | int ignored; |
c906108c SS |
35 | { |
36 | struct ptrace_$data_regs_m68k inferior_registers; | |
37 | struct ptrace_$floating_regs_m68k inferior_fp_registers; | |
38 | struct ptrace_$control_regs_m68k inferior_control_registers; | |
c906108c | 39 | |
c5aa993b JM |
40 | ptrace_$init_control (&inferior_control_registers); |
41 | inferior_fp_registers.size = sizeof (inferior_fp_registers); | |
c906108c SS |
42 | |
43 | registers_fetched (); | |
c5aa993b | 44 | |
c906108c | 45 | ptrace (PTRACE_GETREGS, inferior_pid, |
c5aa993b | 46 | (PTRACE_ARG3_TYPE) & inferior_registers, |
c906108c | 47 | ptrace_$data_set, |
c5aa993b | 48 | (PTRACE_ARG3_TYPE) & inferior_registers, |
c906108c SS |
49 | ptrace_$data_set); |
50 | ||
51 | ptrace (PTRACE_GETREGS, inferior_pid, | |
c5aa993b JM |
52 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
53 | ptrace_$floating_set_m68k, | |
54 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, | |
55 | ptrace_$floating_set_m68k); | |
c906108c SS |
56 | |
57 | ptrace (PTRACE_GETREGS, inferior_pid, | |
c5aa993b JM |
58 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
59 | ptrace_$control_set_m68k, | |
60 | (PTRACE_ARG3_TYPE) & inferior_control_registers, | |
61 | ptrace_$control_set_m68k); | |
c906108c SS |
62 | |
63 | bcopy (&inferior_registers, registers, 16 * 4); | |
64 | bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], | |
65 | sizeof inferior_fp_registers.regs); | |
c5aa993b JM |
66 | *(int *) ®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_control_registers.sr; |
67 | *(int *) ®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_control_registers.pc; | |
c906108c SS |
68 | } |
69 | ||
70 | /* Store our register values back into the inferior. | |
71 | If REGNO is -1, do this for all registers. | |
72 | Otherwise, REGNO specifies which register (so we can save time). */ | |
73 | ||
74 | void | |
75 | store_inferior_registers (regno) | |
76 | int regno; | |
77 | { | |
78 | struct ptrace_$data_regs_m68k inferior_registers; | |
79 | struct ptrace_$floating_regs_m68k inferior_fp_registers; | |
80 | struct ptrace_$control_regs_m68k inferior_control_registers; | |
c906108c | 81 | |
c5aa993b JM |
82 | ptrace_$init_control (&inferior_control_registers); |
83 | inferior_fp_registers.size = sizeof (inferior_fp_registers); | |
c906108c SS |
84 | |
85 | ptrace (PTRACE_GETREGS, inferior_pid, | |
c5aa993b JM |
86 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
87 | ptrace_$floating_set_m68k, | |
88 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, | |
89 | ptrace_$floating_set_m68k); | |
c906108c SS |
90 | |
91 | ptrace (PTRACE_GETREGS, inferior_pid, | |
c5aa993b JM |
92 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
93 | ptrace_$control_set_m68k, | |
94 | (PTRACE_ARG3_TYPE) & inferior_control_registers, | |
95 | ptrace_$control_set_m68k); | |
c906108c | 96 | |
c5aa993b | 97 | bcopy (registers, &inferior_registers, sizeof (inferior_registers)); |
c906108c SS |
98 | |
99 | bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], inferior_fp_registers.regs, | |
100 | sizeof inferior_fp_registers.regs); | |
101 | ||
c5aa993b JM |
102 | inferior_control_registers.sr = *(int *) ®isters[REGISTER_BYTE (PS_REGNUM)]; |
103 | inferior_control_registers.pc = *(int *) ®isters[REGISTER_BYTE (PC_REGNUM)]; | |
c906108c SS |
104 | |
105 | ptrace (PTRACE_SETREGS, inferior_pid, | |
c5aa993b | 106 | (PTRACE_ARG3_TYPE) & inferior_registers, |
c906108c | 107 | ptrace_$data_set_m68k, |
c5aa993b | 108 | (PTRACE_ARG3_TYPE) & inferior_registers, |
c906108c SS |
109 | ptrace_$data_set_m68k); |
110 | ||
111 | ptrace (PTRACE_SETREGS, inferior_pid, | |
c5aa993b | 112 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
c906108c | 113 | ptrace_$floating_set_m68k, |
c5aa993b | 114 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
c906108c SS |
115 | ptrace_$floating_set_m68k); |
116 | ||
117 | ptrace (PTRACE_SETREGS, inferior_pid, | |
c5aa993b | 118 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
c906108c | 119 | ptrace_$control_set_m68k, |
c5aa993b | 120 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
c906108c SS |
121 | ptrace_$control_set_m68k); |
122 | } |