1 /* Native-dependent code for Alpha BSD's.
2 Copyright 2000, 2001, 2002 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 2 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, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
25 #include "alpha-tdep.h"
27 #include <sys/types.h>
28 #include <sys/ptrace.h>
29 #include <machine/reg.h>
31 #ifdef HAVE_SYS_PROCFS_H
32 #include <sys/procfs.h>
35 #ifndef HAVE_GREGSET_T
36 typedef struct reg gregset_t
;
39 #ifndef HAVE_FPREGSET_T
40 typedef struct fpreg fpregset_t
;
45 /* Number of general-purpose registers. */
48 /* Number of floating point registers. */
52 /* Transfering the registers between GDB, inferiors and core files. */
54 /* Fill GDB's register array with the general-purpose register values
58 supply_gregset (gregset_t
*gregsetp
)
62 for (i
= 0; i
< NUM_GREGS
; i
++)
64 if (CANNOT_FETCH_REGISTER (i
))
65 supply_register (i
, NULL
);
67 supply_register (i
, (char *) &gregsetp
->r_regs
[i
]);
70 /* The PC travels in the R_ZERO slot. */
71 supply_register (PC_REGNUM
, (char *) &gregsetp
->r_regs
[R_ZERO
]);
74 /* Fill register REGNO (if it is a general-purpose register) in
75 *GREGSETPS with the value in GDB's register array. If REGNO is -1,
76 do this for all registers. */
79 fill_gregset (gregset_t
*gregsetp
, int regno
)
83 for (i
= 0; i
< NUM_GREGS
; i
++)
84 if ((regno
== -1 || regno
== i
) && ! CANNOT_STORE_REGISTER (i
))
85 regcache_collect (i
, (char *) &gregsetp
->r_regs
[i
]);
87 /* The PC travels in the R_ZERO slot. */
88 if (regno
== -1 || regno
== PC_REGNUM
)
89 regcache_collect (PC_REGNUM
, (char *) &gregsetp
->r_regs
[R_ZERO
]);
92 /* Fill GDB's register array with the floating-point register values
96 supply_fpregset (fpregset_t
*fpregsetp
)
100 for (i
= FP0_REGNUM
; i
< FP0_REGNUM
+ NUM_FPREGS
; i
++)
102 if (CANNOT_FETCH_REGISTER (i
))
103 supply_register (i
, NULL
);
105 supply_register (i
, (char *) &fpregsetp
->fpr_regs
[i
- FP0_REGNUM
]);
108 supply_register (ALPHA_FPCR_REGNUM
, (char *) &fpregsetp
->fpr_cr
);
111 /* Fill register REGNO (if it is a floating-point register) in
112 *FPREGSETP with the value in GDB's register array. If REGNO is -1,
113 do this for all registers. */
116 fill_fpregset (fpregset_t
*fpregsetp
, int regno
)
120 for (i
= FP0_REGNUM
; i
< FP0_REGNUM
+ NUM_FPREGS
; i
++)
121 if ((regno
== -1 || regno
== i
) && ! CANNOT_STORE_REGISTER (i
))
122 regcache_collect (i
, (char *) &fpregsetp
->fpr_regs
[i
- FP0_REGNUM
]);
124 if (regno
== -1 || regno
== ALPHA_FPCR_REGNUM
)
125 regcache_collect (ALPHA_FPCR_REGNUM
, (char *) &fpregsetp
->fpr_cr
);
129 /* Determine if PT_GETREGS fetches this register. */
132 getregs_supplies (int regno
)
135 return ((regno
>= ALPHA_V0_REGNUM
&& regno
<= ALPHA_ZERO_REGNUM
)
136 || regno
>= PC_REGNUM
);
140 /* Fetch register REGNO from the inferior. If REGNO is -1, do this
141 for all registers (including the floating point registers). */
144 fetch_inferior_registers (int regno
)
147 if (regno
== -1 || getregs_supplies (regno
))
151 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
152 (PTRACE_ARG3_TYPE
) &gregs
, 0) == -1)
153 perror_with_name ("Couldn't get registers");
155 supply_gregset (&gregs
);
160 if (regno
== -1 || regno
>= FP0_REGNUM
)
164 if (ptrace (PT_GETFPREGS
, PIDGET (inferior_ptid
),
165 (PTRACE_ARG3_TYPE
) &fpregs
, 0) == -1)
166 perror_with_name ("Couldn't get floating point status");
168 supply_fpregset (&fpregs
);
171 /* Reset virtual frame pointer. */
172 supply_register (FP_REGNUM
, NULL
);
175 /* Store register REGNO back into the inferior. If REGNO is -1, do
176 this for all registers (including the floating point registers). */
179 store_inferior_registers (int regno
)
182 if (regno
== -1 || getregs_supplies (regno
))
185 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
186 (PTRACE_ARG3_TYPE
) &gregs
, 0) == -1)
187 perror_with_name ("Couldn't get registers");
189 fill_gregset (&gregs
, regno
);
191 if (ptrace (PT_SETREGS
, PIDGET (inferior_ptid
),
192 (PTRACE_ARG3_TYPE
) &gregs
, 0) == -1)
193 perror_with_name ("Couldn't write registers");
199 if (regno
== -1 || regno
>= FP0_REGNUM
)
203 if (ptrace (PT_GETFPREGS
, PIDGET (inferior_ptid
),
204 (PTRACE_ARG3_TYPE
) &fpregs
, 0) == -1)
205 perror_with_name ("Couldn't get floating point status");
207 fill_fpregset (&fpregs
, regno
);
209 if (ptrace (PT_SETFPREGS
, PIDGET (inferior_ptid
),
210 (PTRACE_ARG3_TYPE
) &fpregs
, 0) == -1)
211 perror_with_name ("Couldn't write floating point status");
This page took 0.034255 seconds and 4 git commands to generate.