GDB (API)
|
00001 /* Native-dependent code for VAX UNIXen (including older 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 00023 #include "gdb_assert.h" 00024 #include <sys/types.h> 00025 #include <sys/dir.h> 00026 #include <sys/user.h> 00027 00028 #ifdef HAVE_SYS_PTRACE_H 00029 #include <sys/ptrace.h> 00030 #endif 00031 00032 #ifndef PT_READ_U 00033 #define PT_READ_U 3 00034 #endif 00035 00036 #ifdef SYS_REG_H 00037 /* UNIX 32V and derivatives (including 3BSD). */ 00038 #include <sys/reg.h> 00039 #else 00040 /* 4.2BSD and derivatives. */ 00041 #include <machine/reg.h> 00042 #endif 00043 00044 #include "vax-tdep.h" 00045 #include "inf-ptrace.h" 00046 00047 /* Address of the user structure. This is the value for 32V; 3BSD 00048 uses a different value, but hey, who's still using those systems? */ 00049 static CORE_ADDR vax_kernel_u_addr = 0x80020000; 00050 00051 /* Location of the user's stored registers; usage is `u.u_ar0[XX]'. 00052 For 4.2BSD and ULTRIX these are negative! See <machine/reg.h>. */ 00053 static int vax_register_index[] = 00054 { 00055 R0, R1, R2, R3, R4, R5, 00056 R6, R7, R8, R9, R10, R11, 00057 AP, FP, SP, PC, PS 00058 }; 00059 00060 static CORE_ADDR 00061 vax_register_u_addr (CORE_ADDR u_ar0, int regnum) 00062 { 00063 gdb_assert (regnum >= 0 && regnum < ARRAY_SIZE (vax_register_index)); 00064 00065 /* Type is `int *u_ar0'. See <sys/user.h>. */ 00066 return u_ar0 + vax_register_index[regnum - VAX_R0_REGNUM] * 4; 00067 } 00068 00069 static CORE_ADDR 00070 vax_register_u_offset (struct gdbarch *gdbarch, int regnum, int store_p) 00071 { 00072 size_t u_ar0_offset = offsetof (struct user, u_ar0); 00073 CORE_ADDR u_ar0; 00074 int pid; 00075 00076 errno = 0; 00077 pid = ptid_get_pid (inferior_ptid); 00078 u_ar0 = ptrace (PT_READ_U, pid, u_ar0_offset, 0); 00079 if (errno) 00080 perror_with_name (_("Unable to determine location of registers")); 00081 00082 return vax_register_u_addr (u_ar0, regnum) - vax_kernel_u_addr; 00083 } 00084 00085 00086 #include <nlist.h> 00087 00088 #ifndef _PATH_UNIX 00089 #define _PATH_UNIX "/vmunix" 00090 #endif 00091 00092 /* Provide a prototype to silence -Wmissing-prototypes. */ 00093 void _initialize_vax_nat (void); 00094 00095 void 00096 _initialize_vax_nat (void) 00097 { 00098 struct nlist names[2]; 00099 00100 names[0].n_name = "_u"; 00101 names[1].n_name = NULL; 00102 if (nlist (_PATH_UNIX, names) == 0) 00103 vax_kernel_u_addr = names[0].n_value; 00104 00105 add_target (inf_ptrace_trad_target (vax_register_u_offset)); 00106 }