]>
Commit | Line | Data |
---|---|---|
448628fe | 1 | /* Native-dependent code for Alpha BSD's. |
07681759 MK |
2 | |
3 | Copyright 2000, 2001, 2002, 2004 Free Software Foundation, Inc. | |
448628fe MK |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include "inferior.h" | |
4e052eda | 24 | #include "regcache.h" |
448628fe | 25 | |
dc129d82 | 26 | #include "alpha-tdep.h" |
12bcb0fe | 27 | #include "alphabsd-tdep.h" |
dc129d82 | 28 | |
448628fe MK |
29 | #include <sys/types.h> |
30 | #include <sys/ptrace.h> | |
31 | #include <machine/reg.h> | |
32 | ||
33 | #ifdef HAVE_SYS_PROCFS_H | |
34 | #include <sys/procfs.h> | |
35 | #endif | |
36 | ||
37 | #ifndef HAVE_GREGSET_T | |
38 | typedef struct reg gregset_t; | |
39 | #endif | |
40 | ||
12bcb0fe JT |
41 | #ifndef HAVE_FPREGSET_T |
42 | typedef struct fpreg fpregset_t; | |
43 | #endif | |
448628fe MK |
44 | |
45 | #include "gregset.h" | |
46 | ||
12bcb0fe JT |
47 | /* Provide *regset() wrappers around the generic Alpha BSD register |
48 | supply/fill routines. */ | |
448628fe MK |
49 | |
50 | void | |
51 | supply_gregset (gregset_t *gregsetp) | |
52 | { | |
12bcb0fe | 53 | alphabsd_supply_reg ((char *) gregsetp, -1); |
448628fe MK |
54 | } |
55 | ||
448628fe MK |
56 | void |
57 | fill_gregset (gregset_t *gregsetp, int regno) | |
58 | { | |
12bcb0fe | 59 | alphabsd_fill_reg ((char *) gregsetp, regno); |
448628fe MK |
60 | } |
61 | ||
448628fe MK |
62 | void |
63 | supply_fpregset (fpregset_t *fpregsetp) | |
64 | { | |
12bcb0fe | 65 | alphabsd_supply_fpreg ((char *) fpregsetp, -1); |
448628fe MK |
66 | } |
67 | ||
448628fe MK |
68 | void |
69 | fill_fpregset (fpregset_t *fpregsetp, int regno) | |
70 | { | |
12bcb0fe | 71 | alphabsd_fill_fpreg ((char *) fpregsetp, regno); |
448628fe | 72 | } |
12bcb0fe | 73 | \f |
e771a871 JT |
74 | /* Determine if PT_GETREGS fetches this register. */ |
75 | ||
76 | static int | |
77 | getregs_supplies (int regno) | |
78 | { | |
dc129d82 | 79 | return ((regno >= ALPHA_V0_REGNUM && regno <= ALPHA_ZERO_REGNUM) |
07681759 | 80 | || regno >= ALPHA_PC_REGNUM); |
e771a871 JT |
81 | } |
82 | ||
448628fe MK |
83 | /* Fetch register REGNO from the inferior. If REGNO is -1, do this |
84 | for all registers (including the floating point registers). */ | |
85 | ||
86 | void | |
87 | fetch_inferior_registers (int regno) | |
88 | { | |
e771a871 JT |
89 | if (regno == -1 || getregs_supplies (regno)) |
90 | { | |
12bcb0fe | 91 | struct reg gregs; |
e771a871 JT |
92 | |
93 | if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), | |
9f8e0089 | 94 | (PTRACE_TYPE_ARG3) &gregs, 0) == -1) |
e771a871 | 95 | perror_with_name ("Couldn't get registers"); |
448628fe | 96 | |
12bcb0fe | 97 | alphabsd_supply_reg ((char *) &gregs, regno); |
e771a871 JT |
98 | if (regno != -1) |
99 | return; | |
100 | } | |
448628fe MK |
101 | |
102 | if (regno == -1 || regno >= FP0_REGNUM) | |
103 | { | |
12bcb0fe | 104 | struct fpreg fpregs; |
448628fe | 105 | |
39f77062 | 106 | if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), |
9f8e0089 | 107 | (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
448628fe MK |
108 | perror_with_name ("Couldn't get floating point status"); |
109 | ||
12bcb0fe | 110 | alphabsd_supply_fpreg ((char *) &fpregs, regno); |
448628fe | 111 | } |
448628fe MK |
112 | } |
113 | ||
114 | /* Store register REGNO back into the inferior. If REGNO is -1, do | |
115 | this for all registers (including the floating point registers). */ | |
116 | ||
117 | void | |
118 | store_inferior_registers (int regno) | |
119 | { | |
e771a871 JT |
120 | if (regno == -1 || getregs_supplies (regno)) |
121 | { | |
12bcb0fe | 122 | struct reg gregs; |
e771a871 | 123 | if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), |
9f8e0089 | 124 | (PTRACE_TYPE_ARG3) &gregs, 0) == -1) |
e771a871 JT |
125 | perror_with_name ("Couldn't get registers"); |
126 | ||
12bcb0fe | 127 | alphabsd_fill_reg ((char *) &gregs, regno); |
448628fe | 128 | |
e771a871 | 129 | if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), |
9f8e0089 | 130 | (PTRACE_TYPE_ARG3) &gregs, 0) == -1) |
e771a871 | 131 | perror_with_name ("Couldn't write registers"); |
448628fe | 132 | |
e771a871 JT |
133 | if (regno != -1) |
134 | return; | |
135 | } | |
448628fe MK |
136 | |
137 | if (regno == -1 || regno >= FP0_REGNUM) | |
138 | { | |
12bcb0fe | 139 | struct fpreg fpregs; |
448628fe | 140 | |
39f77062 | 141 | if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), |
9f8e0089 | 142 | (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
448628fe MK |
143 | perror_with_name ("Couldn't get floating point status"); |
144 | ||
12bcb0fe | 145 | alphabsd_fill_fpreg ((char *) &fpregs, regno); |
448628fe | 146 | |
39f77062 | 147 | if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), |
9f8e0089 | 148 | (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
448628fe MK |
149 | perror_with_name ("Couldn't write floating point status"); |
150 | } | |
151 | } |