Commit | Line | Data |
---|---|---|
10d6c8cd | 1 | /* Low level Alpha GNU/Linux interface, for GDB when running native. |
e2882c85 | 2 | Copyright (C) 2005-2018 Free Software Foundation, Inc. |
10d6c8cd DJ |
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 | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
10d6c8cd DJ |
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 | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
10d6c8cd DJ |
18 | |
19 | #include "defs.h" | |
20 | #include "target.h" | |
390c1522 | 21 | #include "regcache.h" |
6798487f | 22 | #include "linux-nat-trad.h" |
b02f9d57 UW |
23 | |
24 | #include "alpha-tdep.h" | |
25 | ||
5826e159 | 26 | #include "nat/gdb_ptrace.h" |
b02f9d57 UW |
27 | #include <alpha/ptrace.h> |
28 | ||
29 | #include <sys/procfs.h> | |
30 | #include "gregset.h" | |
31 | ||
b02f9d57 UW |
32 | /* The address of UNIQUE for ptrace. */ |
33 | #define ALPHA_UNIQUE_PTRACE_ADDR 65 | |
34 | ||
f6ac5f3d PA |
35 | class alpha_linux_nat_target final : public linux_nat_trad_target |
36 | { | |
37 | protected: | |
38 | /* Override linux_nat_trad_target methods. */ | |
39 | CORE_ADDR register_u_offset (struct gdbarch *gdbarch, | |
40 | int regno, int store_p) override; | |
41 | }; | |
42 | ||
43 | static alpha_linux_nat_target the_alpha_linux_nat_target; | |
b02f9d57 | 44 | |
0963b4bd MS |
45 | /* See the comment in m68k-tdep.c regarding the utility of these |
46 | functions. */ | |
b02f9d57 UW |
47 | |
48 | void | |
7f7fe91e | 49 | supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp) |
b02f9d57 | 50 | { |
7f7fe91e | 51 | const long *regp = (const long *)gregsetp; |
b02f9d57 | 52 | |
efc72ef5 | 53 | /* PC is in slot 32, UNIQUE is in slot 33. */ |
7f7fe91e | 54 | alpha_supply_int_regs (regcache, -1, regp, regp + 31, regp + 32); |
b02f9d57 UW |
55 | } |
56 | ||
57 | void | |
7f7fe91e UW |
58 | fill_gregset (const struct regcache *regcache, |
59 | gdb_gregset_t *gregsetp, int regno) | |
b02f9d57 | 60 | { |
efc72ef5 | 61 | long *regp = (long *)gregsetp; |
b02f9d57 | 62 | |
efc72ef5 | 63 | /* PC is in slot 32, UNIQUE is in slot 33. */ |
7f7fe91e | 64 | alpha_fill_int_regs (regcache, regno, regp, regp + 31, regp + 32); |
b02f9d57 UW |
65 | } |
66 | ||
0963b4bd MS |
67 | /* Now we do the same thing for floating-point registers. |
68 | Again, see the comments in m68k-tdep.c. */ | |
b02f9d57 UW |
69 | |
70 | void | |
7f7fe91e | 71 | supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp) |
b02f9d57 | 72 | { |
7f7fe91e | 73 | const long *regp = (const long *)fpregsetp; |
b02f9d57 UW |
74 | |
75 | /* FPCR is in slot 32. */ | |
7f7fe91e | 76 | alpha_supply_fp_regs (regcache, -1, regp, regp + 31); |
b02f9d57 UW |
77 | } |
78 | ||
79 | void | |
7f7fe91e UW |
80 | fill_fpregset (const struct regcache *regcache, |
81 | gdb_fpregset_t *fpregsetp, int regno) | |
b02f9d57 | 82 | { |
efc72ef5 | 83 | long *regp = (long *)fpregsetp; |
b02f9d57 UW |
84 | |
85 | /* FPCR is in slot 32. */ | |
7f7fe91e | 86 | alpha_fill_fp_regs (regcache, regno, regp, regp + 31); |
b02f9d57 UW |
87 | } |
88 | ||
f6ac5f3d PA |
89 | CORE_ADDR |
90 | alpha_linux_nat_target::register_u_offset (struct gdbarch *gdbarch, | |
91 | int regno, int store_p) | |
910122bf | 92 | { |
ec7cc0e8 | 93 | if (regno == gdbarch_pc_regnum (gdbarch)) |
b02f9d57 UW |
94 | return PC; |
95 | if (regno == ALPHA_UNIQUE_REGNUM) | |
96 | return ALPHA_UNIQUE_PTRACE_ADDR; | |
ec7cc0e8 | 97 | if (regno < gdbarch_fp0_regnum (gdbarch)) |
b02f9d57 UW |
98 | return GPR_BASE + regno; |
99 | else | |
ec7cc0e8 | 100 | return FPR_BASE + regno - gdbarch_fp0_regnum (gdbarch); |
910122bf | 101 | } |
10d6c8cd | 102 | |
10d6c8cd DJ |
103 | void |
104 | _initialize_alpha_linux_nat (void) | |
105 | { | |
f6ac5f3d | 106 | linux_target = &the_alpha_linux_nat_target; |
d9f719f1 | 107 | add_inf_child_target (&the_alpha_linux_nat_target); |
10d6c8cd | 108 | } |