Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / alphabsd-nat.c
blob2da0b92c1a00e37025ec52579ca7101fba101cd8
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. */
22 #include "defs.h"
23 #include "inferior.h"
24 #include "regcache.h"
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>
36 #endif
38 #ifndef HAVE_GREGSET_T
39 typedef struct reg gregset_t;
40 #endif
42 #ifndef HAVE_FPREGSET_T
43 typedef struct fpreg fpregset_t;
44 #endif
46 #include "gregset.h"
48 /* Provide *regset() wrappers around the generic Alpha BSD register
49 supply/fill routines. */
51 void
52 supply_gregset (gregset_t *gregsetp)
54 alphabsd_supply_reg (current_regcache, (char *) gregsetp, -1);
57 void
58 fill_gregset (gregset_t *gregsetp, int regno)
60 alphabsd_fill_reg (current_regcache, (char *) gregsetp, regno);
63 void
64 supply_fpregset (fpregset_t *fpregsetp)
66 alphabsd_supply_fpreg (current_regcache, (char *) fpregsetp, -1);
69 void
70 fill_fpregset (fpregset_t *fpregsetp, int regno)
72 alphabsd_fill_fpreg (current_regcache, (char *) fpregsetp, regno);
75 /* Determine if PT_GETREGS fetches this register. */
77 static int
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). */
87 static void
88 alphabsd_fetch_inferior_registers (int regno)
90 if (regno == -1 || getregs_supplies (regno))
92 struct reg gregs;
94 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
95 (PTRACE_TYPE_ARG3) &gregs, TIDGET (inferior_ptid)) == -1)
96 perror_with_name (_("Couldn't get registers"));
98 alphabsd_supply_reg (current_regcache, (char *) &gregs, regno);
99 if (regno != -1)
100 return;
103 if (regno == -1 || regno >= FP0_REGNUM)
105 struct fpreg fpregs;
107 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
108 (PTRACE_TYPE_ARG3) &fpregs, TIDGET (inferior_ptid)) == -1)
109 perror_with_name (_("Couldn't get floating point status"));
111 alphabsd_supply_fpreg (current_regcache, (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). */
118 static void
119 alphabsd_store_inferior_registers (int regno)
121 if (regno == -1 || getregs_supplies (regno))
123 struct reg gregs;
124 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
125 (PTRACE_TYPE_ARG3) &gregs, TIDGET (inferior_ptid)) == -1)
126 perror_with_name (_("Couldn't get registers"));
128 alphabsd_fill_reg (current_regcache, (char *) &gregs, regno);
130 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
131 (PTRACE_TYPE_ARG3) &gregs, TIDGET (inferior_ptid)) == -1)
132 perror_with_name (_("Couldn't write registers"));
134 if (regno != -1)
135 return;
138 if (regno == -1 || regno >= FP0_REGNUM)
140 struct fpreg fpregs;
142 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
143 (PTRACE_TYPE_ARG3) &fpregs, TIDGET (inferior_ptid)) == -1)
144 perror_with_name (_("Couldn't get floating point status"));
146 alphabsd_fill_fpreg (current_regcache, (char *) &fpregs, regno);
148 if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
149 (PTRACE_TYPE_ARG3) &fpregs, TIDGET (inferior_ptid)) == -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);
157 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;
165 add_target (t);