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