* dlltool.c (add_stdcall_underscore): New flag.
[deliverable/binutils-gdb.git] / gdb / alphabsd-nat.c
1 /* Native-dependent code for Alpha BSD's.
2
3 Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
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., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
21
22 #include "defs.h"
23 #include "inferior.h"
24 #include "regcache.h"
25
26 #include "alpha-tdep.h"
27 #include "alphabsd-tdep.h"
28 #include "inf-ptrace.h"
29
30 #include <sys/types.h>
31 #include <sys/ptrace.h>
32 #include <machine/reg.h>
33
34 #ifdef HAVE_SYS_PROCFS_H
35 #include <sys/procfs.h>
36 #endif
37
38 #ifndef HAVE_GREGSET_T
39 typedef struct reg gregset_t;
40 #endif
41
42 #ifndef HAVE_FPREGSET_T
43 typedef struct fpreg fpregset_t;
44 #endif
45
46 #include "gregset.h"
47
48 /* Provide *regset() wrappers around the generic Alpha BSD register
49 supply/fill routines. */
50
51 void
52 supply_gregset (gregset_t *gregsetp)
53 {
54 alphabsd_supply_reg ((char *) gregsetp, -1);
55 }
56
57 void
58 fill_gregset (gregset_t *gregsetp, int regno)
59 {
60 alphabsd_fill_reg ((char *) gregsetp, regno);
61 }
62
63 void
64 supply_fpregset (fpregset_t *fpregsetp)
65 {
66 alphabsd_supply_fpreg ((char *) fpregsetp, -1);
67 }
68
69 void
70 fill_fpregset (fpregset_t *fpregsetp, int regno)
71 {
72 alphabsd_fill_fpreg ((char *) fpregsetp, regno);
73 }
74 \f
75 /* Determine if PT_GETREGS fetches this register. */
76
77 static int
78 getregs_supplies (int regno)
79 {
80 return ((regno >= ALPHA_V0_REGNUM && regno <= ALPHA_ZERO_REGNUM)
81 || regno >= ALPHA_PC_REGNUM);
82 }
83
84 /* Fetch register REGNO from the inferior. If REGNO is -1, do this
85 for all registers (including the floating point registers). */
86
87 static void
88 alphabsd_fetch_inferior_registers (int regno)
89 {
90 if (regno == -1 || getregs_supplies (regno))
91 {
92 struct reg gregs;
93
94 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
95 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
96 perror_with_name (_("Couldn't get registers"));
97
98 alphabsd_supply_reg ((char *) &gregs, regno);
99 if (regno != -1)
100 return;
101 }
102
103 if (regno == -1 || regno >= FP0_REGNUM)
104 {
105 struct fpreg fpregs;
106
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"));
110
111 alphabsd_supply_fpreg ((char *) &fpregs, regno);
112 }
113 }
114
115 /* Store register REGNO back into the inferior. If REGNO is -1, do
116 this for all registers (including the floating point registers). */
117
118 static void
119 alphabsd_store_inferior_registers (int regno)
120 {
121 if (regno == -1 || getregs_supplies (regno))
122 {
123 struct reg gregs;
124 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
125 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
126 perror_with_name (_("Couldn't get registers"));
127
128 alphabsd_fill_reg ((char *) &gregs, regno);
129
130 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
131 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
132 perror_with_name (_("Couldn't write registers"));
133
134 if (regno != -1)
135 return;
136 }
137
138 if (regno == -1 || regno >= FP0_REGNUM)
139 {
140 struct fpreg fpregs;
141
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"));
145
146 alphabsd_fill_fpreg ((char *) &fpregs, regno);
147
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"));
151 }
152 }
153
154 /* Provide a prototype to silence -Wmissing-prototypes. */
155 void _initialize_alphabsd_nat (void);
156
157 void
158 _initialize_alphabsd_nat (void)
159 {
160 struct target_ops *t;
161
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);
166 }
This page took 0.12793 seconds and 4 git commands to generate.