1 /* Low level Alpha GNU/Linux interface, for GDB when running native.
2 Copyright (C) 2005-2018 Free Software Foundation, Inc.
4 This file is part of GDB.
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 3 of the License, or
9 (at your option) any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "linux-nat-trad.h"
24 #include "alpha-tdep.h"
26 #include "nat/gdb_ptrace.h"
27 #include <alpha/ptrace.h>
29 #include <sys/procfs.h>
32 /* The address of UNIQUE for ptrace. */
33 #define ALPHA_UNIQUE_PTRACE_ADDR 65
36 /* See the comment in m68k-tdep.c regarding the utility of these
40 supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
42 const long *regp = (const long *)gregsetp;
44 /* PC is in slot 32, UNIQUE is in slot 33. */
45 alpha_supply_int_regs (regcache, -1, regp, regp + 31, regp + 32);
49 fill_gregset (const struct regcache *regcache,
50 gdb_gregset_t *gregsetp, int regno)
52 long *regp = (long *)gregsetp;
54 /* PC is in slot 32, UNIQUE is in slot 33. */
55 alpha_fill_int_regs (regcache, regno, regp, regp + 31, regp + 32);
58 /* Now we do the same thing for floating-point registers.
59 Again, see the comments in m68k-tdep.c. */
62 supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
64 const long *regp = (const long *)fpregsetp;
66 /* FPCR is in slot 32. */
67 alpha_supply_fp_regs (regcache, -1, regp, regp + 31);
71 fill_fpregset (const struct regcache *regcache,
72 gdb_fpregset_t *fpregsetp, int regno)
74 long *regp = (long *)fpregsetp;
76 /* FPCR is in slot 32. */
77 alpha_fill_fp_regs (regcache, regno, regp, regp + 31);
82 alpha_linux_register_u_offset (struct gdbarch *gdbarch, int regno, int store_p)
84 if (regno == gdbarch_pc_regnum (gdbarch))
86 if (regno == ALPHA_UNIQUE_REGNUM)
87 return ALPHA_UNIQUE_PTRACE_ADDR;
88 if (regno < gdbarch_fp0_regnum (gdbarch))
89 return GPR_BASE + regno;
91 return FPR_BASE + regno - gdbarch_fp0_regnum (gdbarch);
95 _initialize_alpha_linux_nat (void)
97 linux_nat_add_target (linux_trad_target (alpha_linux_register_u_offset));