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.
5 This file is part of GDB.
7 GDB is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 1, or (at your option)
12 GDB is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GDB; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include <sys/ptrace.h>
27 #define KERNEL /* To get floating point reg definitions */
28 #include <machine/reg.h>
34 #if defined (TARGET_SUN3)
35 /* All of this stuff is only relevant if both host and target are sun3. */
37 fetch_inferior_registers ()
39 struct regs inferior_registers
;
41 struct fp_status inferior_fp_registers
;
43 extern char registers
[];
47 ptrace (PTRACE_GETREGS
, inferior_pid
, &inferior_registers
);
49 ptrace (PTRACE_GETFPREGS
, inferior_pid
, &inferior_fp_registers
);
52 bcopy (&inferior_registers
, registers
, 16 * 4);
54 bcopy (&inferior_fp_registers
, ®isters
[REGISTER_BYTE (FP0_REGNUM
)],
55 sizeof inferior_fp_registers
.fps_regs
);
57 *(int *)®isters
[REGISTER_BYTE (PS_REGNUM
)] = inferior_registers
.r_ps
;
58 *(int *)®isters
[REGISTER_BYTE (PC_REGNUM
)] = inferior_registers
.r_pc
;
60 bcopy (&inferior_fp_registers
.fps_control
,
61 ®isters
[REGISTER_BYTE (FPC_REGNUM
)],
62 sizeof inferior_fp_registers
- sizeof inferior_fp_registers
.fps_regs
);
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). */
70 store_inferior_registers (regno
)
73 struct regs inferior_registers
;
75 struct fp_status inferior_fp_registers
;
77 extern char registers
[];
79 bcopy (registers
, &inferior_registers
, 16 * 4);
81 bcopy (®isters
[REGISTER_BYTE (FP0_REGNUM
)], &inferior_fp_registers
,
82 sizeof inferior_fp_registers
.fps_regs
);
84 inferior_registers
.r_ps
= *(int *)®isters
[REGISTER_BYTE (PS_REGNUM
)];
85 inferior_registers
.r_pc
= *(int *)®isters
[REGISTER_BYTE (PC_REGNUM
)];
88 bcopy (®isters
[REGISTER_BYTE (FPC_REGNUM
)],
89 &inferior_fp_registers
.fps_control
,
90 sizeof inferior_fp_registers
- sizeof inferior_fp_registers
.fps_regs
);
93 ptrace (PTRACE_SETREGS
, inferior_pid
, &inferior_registers
);
95 ptrace (PTRACE_SETFPREGS
, inferior_pid
, &inferior_fp_registers
);
99 /* Machine-dependent code for pulling registers out of a Sun-3 core file. */
102 fetch_core_registers (core_reg_sect
, core_reg_size
, which
)
104 unsigned core_reg_size
;
107 extern char registers
[];
108 struct regs
*regs
= (struct regs
*) core_reg_sect
;
111 if (core_reg_size
< sizeof (struct regs
))
112 error ("Can't find registers in core file");
114 bcopy ((char *)regs
, registers
, 16 * 4);
115 supply_register (PS_REGNUM
, ®s
->r_ps
);
116 supply_register (PC_REGNUM
, ®s
->r_pc
);
118 } else if (which
== 2) {
120 #define fpustruct ((struct fpu *) core_reg_sect)
122 if (core_reg_size
>= sizeof (struct fpu
))
125 bcopy (fpustruct
->f_fpstatus
.fps_regs
,
126 ®isters
[REGISTER_BYTE (FP0_REGNUM
)],
127 sizeof fpustruct
->f_fpstatus
.fps_regs
);
128 bcopy (&fpustruct
->f_fpstatus
.fps_control
,
129 ®isters
[REGISTER_BYTE (FPC_REGNUM
)],
130 sizeof fpustruct
->f_fpstatus
-
131 sizeof fpustruct
->f_fpstatus
.fps_regs
);
135 fprintf (stderr
, "Couldn't read float regs from core file\n");
138 #else /* Not sun3 target. */
139 /* These functions shouldn't be called when we're cross-debugging. */
142 fetch_inferior_registers ()
147 store_inferior_registers (regno
)
154 fetch_core_registers (core_reg_sect
, core_reg_size
, which
)
156 unsigned core_reg_size
;
160 #endif /* Not sun3 target. */