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