| 1 | /* Native-dependent code for Motorola m68k's running NetBSD, for GDB. |
| 2 | Copyright 1988, 1989, 1991, 1992, 1994, 1996 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., 59 Temple Place - Suite 330, |
| 19 | Boston, MA 02111-1307, USA. */ |
| 20 | |
| 21 | #include <sys/types.h> |
| 22 | #include <sys/ptrace.h> |
| 23 | #include <machine/reg.h> |
| 24 | #include <machine/frame.h> |
| 25 | |
| 26 | #include "defs.h" |
| 27 | #include "inferior.h" |
| 28 | |
| 29 | void |
| 30 | fetch_inferior_registers (int regno) |
| 31 | { |
| 32 | struct reg inferior_registers; |
| 33 | struct fpreg inferior_fp_registers; |
| 34 | |
| 35 | ptrace (PT_GETREGS, inferior_pid, |
| 36 | (PTRACE_ARG3_TYPE) & inferior_registers, 0); |
| 37 | memcpy (®isters[REGISTER_BYTE (0)], &inferior_registers, |
| 38 | sizeof (inferior_registers)); |
| 39 | |
| 40 | ptrace (PT_GETFPREGS, inferior_pid, |
| 41 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0); |
| 42 | memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, |
| 43 | sizeof (inferior_fp_registers)); |
| 44 | |
| 45 | registers_fetched (); |
| 46 | } |
| 47 | |
| 48 | void |
| 49 | store_inferior_registers (int regno) |
| 50 | { |
| 51 | struct reg inferior_registers; |
| 52 | struct fpreg inferior_fp_registers; |
| 53 | |
| 54 | memcpy (&inferior_registers, ®isters[REGISTER_BYTE (0)], |
| 55 | sizeof (inferior_registers)); |
| 56 | ptrace (PT_SETREGS, inferior_pid, |
| 57 | (PTRACE_ARG3_TYPE) & inferior_registers, 0); |
| 58 | |
| 59 | memcpy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], |
| 60 | sizeof (inferior_fp_registers)); |
| 61 | ptrace (PT_SETFPREGS, inferior_pid, |
| 62 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0); |
| 63 | } |
| 64 | |
| 65 | struct md_core |
| 66 | { |
| 67 | struct reg intreg; |
| 68 | struct fpreg freg; |
| 69 | }; |
| 70 | |
| 71 | static void |
| 72 | fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, |
| 73 | CORE_ADDR ignore) |
| 74 | { |
| 75 | struct md_core *core_reg = (struct md_core *) core_reg_sect; |
| 76 | |
| 77 | /* Integer registers */ |
| 78 | memcpy (®isters[REGISTER_BYTE (0)], |
| 79 | &core_reg->intreg, sizeof (struct reg)); |
| 80 | /* Floating point registers */ |
| 81 | memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)], |
| 82 | &core_reg->freg, sizeof (struct fpreg)); |
| 83 | } |
| 84 | |
| 85 | /* Register that we are able to handle m68knbsd core file formats. |
| 86 | FIXME: is this really bfd_target_unknown_flavour? */ |
| 87 | |
| 88 | static struct core_fns m68knbsd_core_fns = |
| 89 | { |
| 90 | bfd_target_unknown_flavour, /* core_flavour */ |
| 91 | default_check_format, /* check_format */ |
| 92 | default_core_sniffer, /* core_sniffer */ |
| 93 | fetch_core_registers, /* core_read_registers */ |
| 94 | NULL /* next */ |
| 95 | }; |
| 96 | |
| 97 | void |
| 98 | _initialize_m68knbsd_nat (void) |
| 99 | { |
| 100 | add_core_fns (&m68knbsd_core_fns); |
| 101 | } |