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