GDB (API)
/home/stan/gdb/src/gdb/alpha-linux-nat.c
Go to the documentation of this file.
00001 /* Low level Alpha GNU/Linux interface, for GDB when running native.
00002    Copyright (C) 2005-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 #include "defs.h"
00020 #include "target.h"
00021 #include "regcache.h"
00022 #include "linux-nat.h"
00023 
00024 #include "alpha-tdep.h"
00025 
00026 #include <sys/ptrace.h>
00027 #include <alpha/ptrace.h>
00028 
00029 #include <sys/procfs.h>
00030 #include "gregset.h"
00031 
00032 /* The address of UNIQUE for ptrace.  */
00033 #define ALPHA_UNIQUE_PTRACE_ADDR 65
00034 
00035 
00036 /* See the comment in m68k-tdep.c regarding the utility of these
00037    functions.  */
00038 
00039 void
00040 supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
00041 {
00042   const long *regp = (const long *)gregsetp;
00043 
00044   /* PC is in slot 32, UNIQUE is in slot 33.  */
00045   alpha_supply_int_regs (regcache, -1, regp, regp + 31, regp + 32);
00046 }
00047 
00048 void
00049 fill_gregset (const struct regcache *regcache,
00050               gdb_gregset_t *gregsetp, int regno)
00051 {
00052   long *regp = (long *)gregsetp;
00053 
00054   /* PC is in slot 32, UNIQUE is in slot 33.  */
00055   alpha_fill_int_regs (regcache, regno, regp, regp + 31, regp + 32);
00056 }
00057 
00058 /* Now we do the same thing for floating-point registers.
00059    Again, see the comments in m68k-tdep.c.  */
00060 
00061 void
00062 supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
00063 {
00064   const long *regp = (const long *)fpregsetp;
00065 
00066   /* FPCR is in slot 32.  */
00067   alpha_supply_fp_regs (regcache, -1, regp, regp + 31);
00068 }
00069 
00070 void
00071 fill_fpregset (const struct regcache *regcache,
00072                gdb_fpregset_t *fpregsetp, int regno)
00073 {
00074   long *regp = (long *)fpregsetp;
00075 
00076   /* FPCR is in slot 32.  */
00077   alpha_fill_fp_regs (regcache, regno, regp, regp + 31);
00078 }
00079 
00080 
00081 static CORE_ADDR
00082 alpha_linux_register_u_offset (struct gdbarch *gdbarch, int regno, int store_p)
00083 {
00084   if (regno == gdbarch_pc_regnum (gdbarch))
00085     return PC;
00086   if (regno == ALPHA_UNIQUE_REGNUM)
00087     return ALPHA_UNIQUE_PTRACE_ADDR;
00088   if (regno < gdbarch_fp0_regnum (gdbarch))
00089     return GPR_BASE + regno;
00090   else
00091     return FPR_BASE + regno - gdbarch_fp0_regnum (gdbarch);
00092 }
00093 
00094 void _initialialize_alpha_linux_nat (void);
00095 
00096 void
00097 _initialize_alpha_linux_nat (void)
00098 {
00099   linux_nat_add_target (linux_trad_target (alpha_linux_register_u_offset));
00100 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines