GDB (API)
|
00001 /* Native-dependent code for MIPS systems running NetBSD. 00002 00003 Copyright (C) 2000-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 "mips-tdep.h" 00030 #include "mipsnbsd-tdep.h" 00031 #include "inf-ptrace.h" 00032 00033 /* Determine if PT_GETREGS fetches this register. */ 00034 static int 00035 getregs_supplies (struct gdbarch *gdbarch, int regno) 00036 { 00037 return ((regno) >= MIPS_ZERO_REGNUM 00038 && (regno) <= gdbarch_pc_regnum (gdbarch)); 00039 } 00040 00041 static void 00042 mipsnbsd_fetch_inferior_registers (struct target_ops *ops, 00043 struct regcache *regcache, int regno) 00044 { 00045 struct gdbarch *gdbarch = get_regcache_arch (regcache); 00046 if (regno == -1 || getregs_supplies (gdbarch, regno)) 00047 { 00048 struct reg regs; 00049 00050 if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), 00051 (PTRACE_TYPE_ARG3) ®s, 0) == -1) 00052 perror_with_name (_("Couldn't get registers")); 00053 00054 mipsnbsd_supply_reg (regcache, (char *) ®s, regno); 00055 if (regno != -1) 00056 return; 00057 } 00058 00059 if (regno == -1 00060 || regno >= gdbarch_fp0_regnum (get_regcache_arch (regcache))) 00061 { 00062 struct fpreg fpregs; 00063 00064 if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), 00065 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 00066 perror_with_name (_("Couldn't get floating point status")); 00067 00068 mipsnbsd_supply_fpreg (regcache, (char *) &fpregs, regno); 00069 } 00070 } 00071 00072 static void 00073 mipsnbsd_store_inferior_registers (struct target_ops *ops, 00074 struct regcache *regcache, int regno) 00075 { 00076 struct gdbarch *gdbarch = get_regcache_arch (regcache); 00077 if (regno == -1 || getregs_supplies (gdbarch, regno)) 00078 { 00079 struct reg regs; 00080 00081 if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), 00082 (PTRACE_TYPE_ARG3) ®s, 0) == -1) 00083 perror_with_name (_("Couldn't get registers")); 00084 00085 mipsnbsd_fill_reg (regcache, (char *) ®s, regno); 00086 00087 if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid), 00088 (PTRACE_TYPE_ARG3) ®s, 0) == -1) 00089 perror_with_name (_("Couldn't write registers")); 00090 00091 if (regno != -1) 00092 return; 00093 } 00094 00095 if (regno == -1 00096 || regno >= gdbarch_fp0_regnum (get_regcache_arch (regcache))) 00097 { 00098 struct fpreg fpregs; 00099 00100 if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), 00101 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 00102 perror_with_name (_("Couldn't get floating point status")); 00103 00104 mipsnbsd_fill_fpreg (regcache, (char *) &fpregs, regno); 00105 00106 if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid), 00107 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 00108 perror_with_name (_("Couldn't write floating point status")); 00109 } 00110 } 00111 00112 00113 /* Provide a prototype to silence -Wmissing-prototypes. */ 00114 void _initialize_mipsnbsd_nat (void); 00115 00116 void 00117 _initialize_mipsnbsd_nat (void) 00118 { 00119 struct target_ops *t; 00120 00121 t = inf_ptrace_target (); 00122 t->to_fetch_registers = mipsnbsd_fetch_inferior_registers; 00123 t->to_store_registers = mipsnbsd_store_inferior_registers; 00124 add_target (t); 00125 }