* alpha-nat.c (ALPHA_REGSET_BASE, ALPHA_REGSET_UNIQUE): Do not define,
[binutils-gdb.git] / gdb / alpha-linux-nat.c
1 /* Low level Alpha GNU/Linux interface, for GDB when running native.
2 Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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 2 of the License, or
9 (at your option) any later version.
10
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.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21 #include "defs.h"
22 #include "target.h"
23 #include "linux-nat.h"
24
25 #include "alpha-tdep.h"
26
27 #include <sys/ptrace.h>
28 #include <alpha/ptrace.h>
29
30 #include <sys/procfs.h>
31 #include "gregset.h"
32
33 /* The address of UNIQUE for ptrace. */
34 #define ALPHA_UNIQUE_PTRACE_ADDR 65
35
36
37 /*
38 * See the comment in m68k-tdep.c regarding the utility of these functions.
39 */
40
41 void
42 supply_gregset (gdb_gregset_t *gregsetp)
43 {
44 long *regp = (long *)gregsetp;
45
46 /* PC is in slot 32, UNIQUE is in slot 33. */
47 alpha_supply_int_regs (-1, regp, regp + 31, regp + 32);
48 }
49
50 void
51 fill_gregset (gdb_gregset_t *gregsetp, int regno)
52 {
53 long *regp = (long *)gregsetp;
54
55 /* PC is in slot 32, UNIQUE is in slot 33. */
56 alpha_fill_int_regs (regno, regp, regp + 31, regp + 32);
57 }
58
59 /*
60 * Now we do the same thing for floating-point registers.
61 * Again, see the comments in m68k-tdep.c.
62 */
63
64 void
65 supply_fpregset (gdb_fpregset_t *fpregsetp)
66 {
67 long *regp = (long *)fpregsetp;
68
69 /* FPCR is in slot 32. */
70 alpha_supply_fp_regs (-1, regp, regp + 31);
71 }
72
73 void
74 fill_fpregset (gdb_fpregset_t *fpregsetp, int regno)
75 {
76 long *regp = (long *)fpregsetp;
77
78 /* FPCR is in slot 32. */
79 alpha_fill_fp_regs (regno, regp, regp + 31);
80 }
81
82
83 static CORE_ADDR
84 alpha_linux_register_u_offset (int regno)
85 {
86 if (regno == PC_REGNUM)
87 return PC;
88 if (regno == ALPHA_UNIQUE_REGNUM)
89 return ALPHA_UNIQUE_PTRACE_ADDR;
90 if (regno < FP0_REGNUM)
91 return GPR_BASE + regno;
92 else
93 return FPR_BASE + regno - FP0_REGNUM;
94 }
95
96 void _initialialize_alpha_linux_nat (void);
97
98 void
99 _initialize_alpha_linux_nat (void)
100 {
101 linux_nat_add_target (linux_trad_target (alpha_linux_register_u_offset));
102 }