| 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, |
| 40 | (PTRACE_ARG3_TYPE) &inferior_registers, 0); |
| 41 | #ifdef FP0_REGNUM |
| 42 | ptrace (PTRACE_GETFPREGS, inferior_pid, |
| 43 | (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); |
| 44 | #endif |
| 45 | |
| 46 | bcopy (&inferior_registers, registers, 16 * 4); |
| 47 | #ifdef FP0_REGNUM |
| 48 | bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], |
| 49 | sizeof inferior_fp_registers.fps_regs); |
| 50 | #endif |
| 51 | *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; |
| 52 | *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; |
| 53 | #ifdef FP0_REGNUM |
| 54 | bcopy (&inferior_fp_registers.fps_control, |
| 55 | ®isters[REGISTER_BYTE (FPC_REGNUM)], |
| 56 | sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); |
| 57 | #endif |
| 58 | } |
| 59 | |
| 60 | /* Store our register values back into the inferior. |
| 61 | If REGNO is -1, do this for all registers. |
| 62 | Otherwise, REGNO specifies which register (so we can save time). */ |
| 63 | |
| 64 | void |
| 65 | store_inferior_registers (regno) |
| 66 | int regno; |
| 67 | { |
| 68 | struct regs inferior_registers; |
| 69 | #ifdef FP0_REGNUM |
| 70 | struct fp_status inferior_fp_registers; |
| 71 | #endif |
| 72 | extern char registers[]; |
| 73 | |
| 74 | bcopy (registers, &inferior_registers, 16 * 4); |
| 75 | #ifdef FP0_REGNUM |
| 76 | bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, |
| 77 | sizeof inferior_fp_registers.fps_regs); |
| 78 | #endif |
| 79 | inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; |
| 80 | inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; |
| 81 | |
| 82 | #ifdef FP0_REGNUM |
| 83 | bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], |
| 84 | &inferior_fp_registers.fps_control, |
| 85 | sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); |
| 86 | #endif |
| 87 | |
| 88 | ptrace (PTRACE_SETREGS, inferior_pid, |
| 89 | (PTRACE_ARG3_TYPE) &inferior_registers, 0); |
| 90 | #if FP0_REGNUM |
| 91 | ptrace (PTRACE_SETFPREGS, inferior_pid, |
| 92 | (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); |
| 93 | #endif |
| 94 | } |
| 95 | |
| 96 | /* Machine-dependent code for pulling registers out of a Sun-3 core file. */ |
| 97 | |
| 98 | void |
| 99 | fetch_core_registers (core_reg_sect, core_reg_size, which) |
| 100 | char *core_reg_sect; |
| 101 | unsigned core_reg_size; |
| 102 | int which; |
| 103 | { |
| 104 | extern char registers[]; |
| 105 | struct regs *regs = (struct regs *) core_reg_sect; |
| 106 | |
| 107 | if (which == 0) { |
| 108 | if (core_reg_size < sizeof (struct regs)) |
| 109 | error ("Can't find registers in core file"); |
| 110 | |
| 111 | bcopy ((char *)regs, registers, 16 * 4); |
| 112 | supply_register (PS_REGNUM, ®s->r_ps); |
| 113 | supply_register (PC_REGNUM, ®s->r_pc); |
| 114 | |
| 115 | } else if (which == 2) { |
| 116 | |
| 117 | #define fpustruct ((struct fpu *) core_reg_sect) |
| 118 | |
| 119 | if (core_reg_size >= sizeof (struct fpu)) |
| 120 | { |
| 121 | #ifdef FP0_REGNUM |
| 122 | bcopy (fpustruct->f_fpstatus.fps_regs, |
| 123 | ®isters[REGISTER_BYTE (FP0_REGNUM)], |
| 124 | sizeof fpustruct->f_fpstatus.fps_regs); |
| 125 | bcopy (&fpustruct->f_fpstatus.fps_control, |
| 126 | ®isters[REGISTER_BYTE (FPC_REGNUM)], |
| 127 | sizeof fpustruct->f_fpstatus - |
| 128 | sizeof fpustruct->f_fpstatus.fps_regs); |
| 129 | #endif |
| 130 | } |
| 131 | else |
| 132 | fprintf (stderr, "Couldn't read float regs from core file\n"); |
| 133 | } |
| 134 | } |
| 135 | #else /* Not sun3 target. */ |
| 136 | /* These functions shouldn't be called when we're cross-debugging. */ |
| 137 | |
| 138 | void |
| 139 | fetch_inferior_registers () |
| 140 | { |
| 141 | } |
| 142 | |
| 143 | /* ARGSUSED */ |
| 144 | void |
| 145 | store_inferior_registers (regno) |
| 146 | int regno; |
| 147 | { |
| 148 | } |
| 149 | |
| 150 | /* ARGSUSED */ |
| 151 | void |
| 152 | fetch_core_registers (core_reg_sect, core_reg_size, which) |
| 153 | char *core_reg_sect; |
| 154 | unsigned core_reg_size; |
| 155 | int which; |
| 156 | { |
| 157 | } |
| 158 | #endif /* Not sun3 target. */ |