Commit | Line | Data |
---|---|---|
448628fe | 1 | /* Native-dependent code for Alpha BSD's. |
e771a871 | 2 | Copyright 2000, 2001, 2002 Free Software Foundation, Inc. |
448628fe MK |
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., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #include "defs.h" | |
22 | #include "inferior.h" | |
4e052eda | 23 | #include "regcache.h" |
448628fe | 24 | |
dc129d82 | 25 | #include "alpha-tdep.h" |
12bcb0fe | 26 | #include "alphabsd-tdep.h" |
dc129d82 | 27 | |
448628fe MK |
28 | #include <sys/types.h> |
29 | #include <sys/ptrace.h> | |
30 | #include <machine/reg.h> | |
31 | ||
32 | #ifdef HAVE_SYS_PROCFS_H | |
33 | #include <sys/procfs.h> | |
34 | #endif | |
35 | ||
36 | #ifndef HAVE_GREGSET_T | |
37 | typedef struct reg gregset_t; | |
38 | #endif | |
39 | ||
12bcb0fe JT |
40 | #ifndef HAVE_FPREGSET_T |
41 | typedef struct fpreg fpregset_t; | |
42 | #endif | |
448628fe MK |
43 | |
44 | #include "gregset.h" | |
45 | ||
12bcb0fe JT |
46 | /* Provide *regset() wrappers around the generic Alpha BSD register |
47 | supply/fill routines. */ | |
448628fe MK |
48 | |
49 | void | |
50 | supply_gregset (gregset_t *gregsetp) | |
51 | { | |
12bcb0fe | 52 | alphabsd_supply_reg ((char *) gregsetp, -1); |
448628fe MK |
53 | } |
54 | ||
448628fe MK |
55 | void |
56 | fill_gregset (gregset_t *gregsetp, int regno) | |
57 | { | |
12bcb0fe | 58 | alphabsd_fill_reg ((char *) gregsetp, regno); |
448628fe MK |
59 | } |
60 | ||
448628fe MK |
61 | void |
62 | supply_fpregset (fpregset_t *fpregsetp) | |
63 | { | |
12bcb0fe | 64 | alphabsd_supply_fpreg ((char *) fpregsetp, -1); |
448628fe MK |
65 | } |
66 | ||
448628fe MK |
67 | void |
68 | fill_fpregset (fpregset_t *fpregsetp, int regno) | |
69 | { | |
12bcb0fe | 70 | alphabsd_fill_fpreg ((char *) fpregsetp, regno); |
448628fe | 71 | } |
12bcb0fe | 72 | \f |
e771a871 JT |
73 | /* Determine if PT_GETREGS fetches this register. */ |
74 | ||
75 | static int | |
76 | getregs_supplies (int regno) | |
77 | { | |
78 | ||
dc129d82 | 79 | return ((regno >= ALPHA_V0_REGNUM && regno <= ALPHA_ZERO_REGNUM) |
e771a871 JT |
80 | || regno >= PC_REGNUM); |
81 | } | |
82 | ||
83 | ||
448628fe MK |
84 | /* Fetch register REGNO from the inferior. If REGNO is -1, do this |
85 | for all registers (including the floating point registers). */ | |
86 | ||
87 | void | |
88 | fetch_inferior_registers (int regno) | |
89 | { | |
448628fe | 90 | |
e771a871 JT |
91 | if (regno == -1 || getregs_supplies (regno)) |
92 | { | |
12bcb0fe | 93 | struct reg gregs; |
e771a871 JT |
94 | |
95 | if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), | |
96 | (PTRACE_ARG3_TYPE) &gregs, 0) == -1) | |
97 | perror_with_name ("Couldn't get registers"); | |
448628fe | 98 | |
12bcb0fe | 99 | alphabsd_supply_reg ((char *) &gregs, regno); |
e771a871 JT |
100 | if (regno != -1) |
101 | return; | |
102 | } | |
448628fe MK |
103 | |
104 | if (regno == -1 || regno >= FP0_REGNUM) | |
105 | { | |
12bcb0fe | 106 | struct fpreg fpregs; |
448628fe | 107 | |
39f77062 | 108 | if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), |
448628fe MK |
109 | (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) |
110 | perror_with_name ("Couldn't get floating point status"); | |
111 | ||
12bcb0fe | 112 | alphabsd_supply_fpreg ((char *) &fpregs, regno); |
448628fe MK |
113 | } |
114 | ||
115 | /* Reset virtual frame pointer. */ | |
116 | supply_register (FP_REGNUM, NULL); | |
117 | } | |
118 | ||
119 | /* Store register REGNO back into the inferior. If REGNO is -1, do | |
120 | this for all registers (including the floating point registers). */ | |
121 | ||
122 | void | |
123 | store_inferior_registers (int regno) | |
124 | { | |
448628fe | 125 | |
e771a871 JT |
126 | if (regno == -1 || getregs_supplies (regno)) |
127 | { | |
12bcb0fe | 128 | struct reg gregs; |
e771a871 JT |
129 | if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), |
130 | (PTRACE_ARG3_TYPE) &gregs, 0) == -1) | |
131 | perror_with_name ("Couldn't get registers"); | |
132 | ||
12bcb0fe | 133 | alphabsd_fill_reg ((char *) &gregs, regno); |
448628fe | 134 | |
e771a871 JT |
135 | if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), |
136 | (PTRACE_ARG3_TYPE) &gregs, 0) == -1) | |
137 | perror_with_name ("Couldn't write registers"); | |
448628fe | 138 | |
e771a871 JT |
139 | if (regno != -1) |
140 | return; | |
141 | } | |
448628fe MK |
142 | |
143 | if (regno == -1 || regno >= FP0_REGNUM) | |
144 | { | |
12bcb0fe | 145 | struct fpreg fpregs; |
448628fe | 146 | |
39f77062 | 147 | if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), |
448628fe MK |
148 | (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) |
149 | perror_with_name ("Couldn't get floating point status"); | |
150 | ||
12bcb0fe | 151 | alphabsd_fill_fpreg ((char *) &fpregs, regno); |
448628fe | 152 | |
39f77062 | 153 | if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), |
448628fe MK |
154 | (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) |
155 | perror_with_name ("Couldn't write floating point status"); | |
156 | } | |
157 | } |