1 /* Native-dependent code for Alpha BSD's.
3 Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
26 #include "alpha-tdep.h"
27 #include "alphabsd-tdep.h"
28 #include "inf-ptrace.h"
30 #include <sys/types.h>
31 #include <sys/ptrace.h>
32 #include <machine/reg.h>
34 #ifdef HAVE_SYS_PROCFS_H
35 #include <sys/procfs.h>
38 #ifndef HAVE_GREGSET_T
39 typedef struct reg gregset_t;
42 #ifndef HAVE_FPREGSET_T
43 typedef struct fpreg fpregset_t;
48 /* Provide *regset() wrappers around the generic Alpha BSD register
49 supply/fill routines. */
52 supply_gregset (gregset_t *gregsetp)
54 alphabsd_supply_reg ((char *) gregsetp, -1);
58 fill_gregset (gregset_t *gregsetp, int regno)
60 alphabsd_fill_reg ((char *) gregsetp, regno);
64 supply_fpregset (fpregset_t *fpregsetp)
66 alphabsd_supply_fpreg ((char *) fpregsetp, -1);
70 fill_fpregset (fpregset_t *fpregsetp, int regno)
72 alphabsd_fill_fpreg ((char *) fpregsetp, regno);
75 /* Determine if PT_GETREGS fetches this register. */
78 getregs_supplies (int regno)
80 return ((regno >= ALPHA_V0_REGNUM && regno <= ALPHA_ZERO_REGNUM)
81 || regno >= ALPHA_PC_REGNUM);
84 /* Fetch register REGNO from the inferior. If REGNO is -1, do this
85 for all registers (including the floating point registers). */
88 alphabsd_fetch_inferior_registers (int regno)
90 if (regno == -1 || getregs_supplies (regno))
94 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
95 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
96 perror_with_name (_("Couldn't get registers"));
98 alphabsd_supply_reg ((char *) &gregs, regno);
103 if (regno == -1 || regno >= FP0_REGNUM)
107 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
108 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
109 perror_with_name (_("Couldn't get floating point status"));
111 alphabsd_supply_fpreg ((char *) &fpregs, regno);
115 /* Store register REGNO back into the inferior. If REGNO is -1, do
116 this for all registers (including the floating point registers). */
119 alphabsd_store_inferior_registers (int regno)
121 if (regno == -1 || getregs_supplies (regno))
124 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
125 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
126 perror_with_name (_("Couldn't get registers"));
128 alphabsd_fill_reg ((char *) &gregs, regno);
130 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
131 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
132 perror_with_name (_("Couldn't write registers"));
138 if (regno == -1 || regno >= FP0_REGNUM)
142 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
143 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
144 perror_with_name (_("Couldn't get floating point status"));
146 alphabsd_fill_fpreg ((char *) &fpregs, regno);
148 if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
149 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
150 perror_with_name (_("Couldn't write floating point status"));
154 /* Provide a prototype to silence -Wmissing-prototypes. */
155 void _initialize_alphabsd_nat (void);
158 _initialize_alphabsd_nat (void)
160 struct target_ops *t;
162 t = inf_ptrace_target ();
163 t->to_fetch_registers = alphabsd_fetch_inferior_registers;
164 t->to_store_registers = alphabsd_store_inferior_registers;