29k/UDI add stragglers.
[deliverable/binutils-gdb.git] / gdb / os68k-xdep.c
CommitLineData
36a2f895
SEF
1/* Host-dependent code for Sun-3 for GDB, the GNU debugger.
2 Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
36a2f895
SEF
20#include "defs.h"
21#include "inferior.h"
22#include "gdbcore.h"
23
24#include <sys/ptrace.h>
25#define KERNEL /* To get floating point reg definitions */
26#include <machine/reg.h>
27
28extern int errno;
29
30#if defined (GDB_TARGET_IS_SUN3)
31/* All of this stuff is only relevant if both host and target are sun3. */
32void
33fetch_inferior_registers ()
34{
35 struct regs inferior_registers;
36#ifdef FP0_REGNUM
37 struct fp_status inferior_fp_registers;
38#endif
39 extern char registers[];
40
41 registers_fetched ();
42
43 ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers);
44#ifdef FP0_REGNUM
45 ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers);
46#endif
47
48 bcopy (&inferior_registers, registers, 16 * 4);
49#ifdef FP0_REGNUM
50 bcopy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
51 sizeof inferior_fp_registers.fps_regs);
52#endif
53 *(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
54 *(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
55#ifdef FP0_REGNUM
56 bcopy (&inferior_fp_registers.fps_control,
57 &registers[REGISTER_BYTE (FPC_REGNUM)],
58 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
59#endif
60}
61
62/* Store our register values back into the inferior.
63 If REGNO is -1, do this for all registers.
64 Otherwise, REGNO specifies which register (so we can save time). */
65
66store_inferior_registers (regno)
67 int regno;
68{
69 struct regs inferior_registers;
70#ifdef FP0_REGNUM
71 struct fp_status inferior_fp_registers;
72#endif
73 extern char registers[];
74
75 bcopy (registers, &inferior_registers, 16 * 4);
76#ifdef FP0_REGNUM
77 bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
78 sizeof inferior_fp_registers.fps_regs);
79#endif
80 inferior_registers.r_ps = *(int *)&registers[REGISTER_BYTE (PS_REGNUM)];
81 inferior_registers.r_pc = *(int *)&registers[REGISTER_BYTE (PC_REGNUM)];
82
83#ifdef FP0_REGNUM
84 bcopy (&registers[REGISTER_BYTE (FPC_REGNUM)],
85 &inferior_fp_registers.fps_control,
86 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
87#endif
88
89 ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers);
90#if FP0_REGNUM
91 ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers);
92#endif
93}
94
95/* Machine-dependent code for pulling registers out of a Sun-3 core file. */
96
97void
98fetch_core_registers (core_reg_sect, core_reg_size, which)
99 char *core_reg_sect;
100 unsigned core_reg_size;
101 int which;
102{
103 extern char registers[];
104 struct regs *regs = (struct regs *) core_reg_sect;
105
106 if (which == 0) {
107 if (core_reg_size < sizeof (struct regs))
108 error ("Can't find registers in core file");
109
110 bcopy ((char *)regs, registers, 16 * 4);
111 supply_register (PS_REGNUM, &regs->r_ps);
112 supply_register (PC_REGNUM, &regs->r_pc);
113
114 } else if (which == 2) {
115
116#define fpustruct ((struct fpu *) core_reg_sect)
117
118 if (core_reg_size >= sizeof (struct fpu))
119 {
120#ifdef FP0_REGNUM
121 bcopy (fpustruct->f_fpstatus.fps_regs,
122 &registers[REGISTER_BYTE (FP0_REGNUM)],
123 sizeof fpustruct->f_fpstatus.fps_regs);
124 bcopy (&fpustruct->f_fpstatus.fps_control,
125 &registers[REGISTER_BYTE (FPC_REGNUM)],
126 sizeof fpustruct->f_fpstatus -
127 sizeof fpustruct->f_fpstatus.fps_regs);
128#endif
129 }
130 else
131 fprintf (stderr, "Couldn't read float regs from core file\n");
132 }
133}
134#else /* Not sun3 target. */
135/* These functions shouldn't be called when we're cross-debugging. */
136
137void
138fetch_inferior_registers ()
139{
140}
141
142/* ARGSUSED */
143store_inferior_registers (regno)
144 int regno;
145{
146}
147
148/* ARGSUSED */
149void
150fetch_core_registers (core_reg_sect, core_reg_size, which)
151 char *core_reg_sect;
152 unsigned core_reg_size;
153 int which;
154{
155}
156#endif /* Not sun3 target. */
This page took 0.033869 seconds and 4 git commands to generate.