Added support for hosting on an Apollo Series 400 processor (under
[deliverable/binutils-gdb.git] / gdb / a68v-xdep.c
1 /* Host-dependent code for Apollo-68ksfor GDB, the GNU debugger.
2 Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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.
15
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include <stdio.h>
21 #include "defs.h"
22 #include "inferior.h"
23 #include "gdbcore.h"
24
25 extern int errno;
26
27 #if defined (GDB_TARGET_IS_SUN3)
28 /* All of this stuff is only relevant if both host and target are sun3. */
29 void
30 fetch_inferior_registers ()
31 {
32 struct regs inferior_registers;
33 #ifdef FP0_REGNUM
34 struct fp_status inferior_fp_registers;
35 #endif
36 extern char registers[];
37
38 registers_fetched ();
39
40 ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers);
41 #ifdef FP0_REGNUM
42 ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers);
43 #endif
44
45 bcopy (&inferior_registers, registers, 16 * 4);
46 #ifdef FP0_REGNUM
47 bcopy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
48 sizeof inferior_fp_registers.fps_regs);
49 #endif
50 *(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
51 *(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
52 #ifdef FP0_REGNUM
53 bcopy (&inferior_fp_registers.fps_control,
54 &registers[REGISTER_BYTE (FPC_REGNUM)],
55 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
56 #endif
57 }
58
59 /* Store our register values back into the inferior.
60 If REGNO is -1, do this for all registers.
61 Otherwise, REGNO specifies which register (so we can save time). */
62
63 store_inferior_registers (regno)
64 int regno;
65 {
66 struct regs inferior_registers;
67 #ifdef FP0_REGNUM
68 struct fp_status inferior_fp_registers;
69 #endif
70 extern char registers[];
71
72 bcopy (registers, &inferior_registers, 16 * 4);
73 #ifdef FP0_REGNUM
74 bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
75 sizeof inferior_fp_registers.fps_regs);
76 #endif
77 inferior_registers.r_ps = *(int *)&registers[REGISTER_BYTE (PS_REGNUM)];
78 inferior_registers.r_pc = *(int *)&registers[REGISTER_BYTE (PC_REGNUM)];
79
80 #ifdef FP0_REGNUM
81 bcopy (&registers[REGISTER_BYTE (FPC_REGNUM)],
82 &inferior_fp_registers.fps_control,
83 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
84 #endif
85
86 ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers);
87 #if FP0_REGNUM
88 ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers);
89 #endif
90 }
91
92 /* Machine-dependent code for pulling registers out of a Sun-3 core file. */
93
94 void
95 fetch_core_registers (core_reg_sect, core_reg_size, which)
96 char *core_reg_sect;
97 unsigned core_reg_size;
98 int which;
99 {
100 extern char registers[];
101 struct regs *regs = (struct regs *) core_reg_sect;
102
103 if (which == 0) {
104 if (core_reg_size < sizeof (struct regs))
105 error ("Can't find registers in core file");
106
107 bcopy ((char *)regs, registers, 16 * 4);
108 supply_register (PS_REGNUM, &regs->r_ps);
109 supply_register (PC_REGNUM, &regs->r_pc);
110
111 } else if (which == 2) {
112
113 #define fpustruct ((struct fpu *) core_reg_sect)
114
115 if (core_reg_size >= sizeof (struct fpu))
116 {
117 #ifdef FP0_REGNUM
118 bcopy (fpustruct->f_fpstatus.fps_regs,
119 &registers[REGISTER_BYTE (FP0_REGNUM)],
120 sizeof fpustruct->f_fpstatus.fps_regs);
121 bcopy (&fpustruct->f_fpstatus.fps_control,
122 &registers[REGISTER_BYTE (FPC_REGNUM)],
123 sizeof fpustruct->f_fpstatus -
124 sizeof fpustruct->f_fpstatus.fps_regs);
125 #endif
126 }
127 else
128 fprintf (stderr, "Couldn't read float regs from core file\n");
129 }
130 }
131 #else /* Not sun3 target. */
132 /* These functions shouldn't be called when we're cross-debugging. */
133
134 void
135 fetch_inferior_registers ()
136 {
137 }
138
139 /* ARGSUSED */
140 store_inferior_registers (regno)
141 int regno;
142 {
143 }
144
145 /* ARGSUSED */
146 void
147 fetch_core_registers (core_reg_sect, core_reg_size, which)
148 char *core_reg_sect;
149 unsigned core_reg_size;
150 int which;
151 {
152 }
153 #endif /* Not sun3 target. */
This page took 0.034846 seconds and 5 git commands to generate.