GDB (API)
|
00001 /* Native-dependent code for Motorola 88000 BSD's. 00002 00003 Copyright (C) 2004-2013 Free Software Foundation, Inc. 00004 00005 This file is part of GDB. 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 #include "defs.h" 00021 #include "inferior.h" 00022 #include "regcache.h" 00023 #include "target.h" 00024 00025 #include <sys/types.h> 00026 #include <sys/ptrace.h> 00027 #include <machine/reg.h> 00028 00029 #include "m88k-tdep.h" 00030 #include "inf-ptrace.h" 00031 00032 /* Supply the general-purpose registers stored in GREGS to REGCACHE. */ 00033 00034 static void 00035 m88kbsd_supply_gregset (struct regcache *regcache, const void *gregs) 00036 { 00037 const char *regs = gregs; 00038 int regnum; 00039 00040 for (regnum = 0; regnum < M88K_NUM_REGS; regnum++) 00041 regcache_raw_supply (regcache, regnum, regs + regnum * 4); 00042 } 00043 00044 /* Collect the general-purpose registers from REGCACHE and store them 00045 in GREGS. */ 00046 00047 static void 00048 m88kbsd_collect_gregset (const struct regcache *regcache, 00049 void *gregs, int regnum) 00050 { 00051 char *regs = gregs; 00052 int i; 00053 00054 for (i = 0; i < M88K_NUM_REGS; i++) 00055 { 00056 if (regnum == -1 || regnum == i) 00057 regcache_raw_collect (regcache, i, regs + i * 4); 00058 } 00059 } 00060 00061 00062 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this 00063 for all registers. */ 00064 00065 static void 00066 m88kbsd_fetch_inferior_registers (struct target_ops *ops, 00067 struct regcache *regcache, int regnum) 00068 { 00069 struct reg regs; 00070 00071 if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), 00072 (PTRACE_TYPE_ARG3) ®s, 0) == -1) 00073 perror_with_name (_("Couldn't get registers")); 00074 00075 m88kbsd_supply_gregset (regcache, ®s); 00076 } 00077 00078 /* Store register REGNUM back into the inferior. If REGNUM is -1, do 00079 this for all registers. */ 00080 00081 static void 00082 m88kbsd_store_inferior_registers (struct target_ops *ops, 00083 struct regcache *regcache, int regnum) 00084 { 00085 struct reg regs; 00086 00087 if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), 00088 (PTRACE_TYPE_ARG3) ®s, 0) == -1) 00089 perror_with_name (_("Couldn't get registers")); 00090 00091 m88kbsd_collect_gregset (regcache, ®s, regnum); 00092 00093 if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid), 00094 (PTRACE_TYPE_ARG3) ®s, 0) == -1) 00095 perror_with_name (_("Couldn't write registers")); 00096 } 00097 00098 00099 /* Provide a prototype to silence -Wmissing-prototypes. */ 00100 void _initialize_m88kbsd_nat (void); 00101 00102 void 00103 _initialize_m88kbsd_nat (void) 00104 { 00105 struct target_ops *t; 00106 00107 t = inf_ptrace_target (); 00108 t->to_fetch_registers = m88kbsd_fetch_inferior_registers; 00109 t->to_store_registers = m88kbsd_store_inferior_registers; 00110 add_target (t); 00111 }