* remote-fileio.c (remote_fileio_return_success): Take a gdb_byte
[deliverable/binutils-gdb.git] / gdb / alphabsd-nat.c
CommitLineData
448628fe 1/* Native-dependent code for Alpha BSD's.
07681759 2
197e01b6 3 Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
448628fe
MK
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
197e01b6
EZ
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
448628fe
MK
21
22#include "defs.h"
23#include "inferior.h"
4e052eda 24#include "regcache.h"
448628fe 25
dc129d82 26#include "alpha-tdep.h"
12bcb0fe 27#include "alphabsd-tdep.h"
0d6e4ad7 28#include "inf-ptrace.h"
dc129d82 29
448628fe
MK
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
39typedef struct reg gregset_t;
40#endif
41
12bcb0fe
JT
42#ifndef HAVE_FPREGSET_T
43typedef struct fpreg fpregset_t;
44#endif
448628fe
MK
45
46#include "gregset.h"
47
12bcb0fe
JT
48/* Provide *regset() wrappers around the generic Alpha BSD register
49 supply/fill routines. */
448628fe
MK
50
51void
52supply_gregset (gregset_t *gregsetp)
53{
12bcb0fe 54 alphabsd_supply_reg ((char *) gregsetp, -1);
448628fe
MK
55}
56
448628fe
MK
57void
58fill_gregset (gregset_t *gregsetp, int regno)
59{
12bcb0fe 60 alphabsd_fill_reg ((char *) gregsetp, regno);
448628fe
MK
61}
62
448628fe
MK
63void
64supply_fpregset (fpregset_t *fpregsetp)
65{
12bcb0fe 66 alphabsd_supply_fpreg ((char *) fpregsetp, -1);
448628fe
MK
67}
68
448628fe
MK
69void
70fill_fpregset (fpregset_t *fpregsetp, int regno)
71{
12bcb0fe 72 alphabsd_fill_fpreg ((char *) fpregsetp, regno);
448628fe 73}
12bcb0fe 74\f
e771a871
JT
75/* Determine if PT_GETREGS fetches this register. */
76
77static int
78getregs_supplies (int regno)
79{
dc129d82 80 return ((regno >= ALPHA_V0_REGNUM && regno <= ALPHA_ZERO_REGNUM)
07681759 81 || regno >= ALPHA_PC_REGNUM);
e771a871
JT
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
0d6e4ad7
MK
87static void
88alphabsd_fetch_inferior_registers (int regno)
448628fe 89{
e771a871
JT
90 if (regno == -1 || getregs_supplies (regno))
91 {
12bcb0fe 92 struct reg gregs;
e771a871
JT
93
94 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
9f8e0089 95 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
edefbb7c 96 perror_with_name (_("Couldn't get registers"));
448628fe 97
12bcb0fe 98 alphabsd_supply_reg ((char *) &gregs, regno);
e771a871
JT
99 if (regno != -1)
100 return;
101 }
448628fe
MK
102
103 if (regno == -1 || regno >= FP0_REGNUM)
104 {
12bcb0fe 105 struct fpreg fpregs;
448628fe 106
39f77062 107 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
9f8e0089 108 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
edefbb7c 109 perror_with_name (_("Couldn't get floating point status"));
448628fe 110
12bcb0fe 111 alphabsd_supply_fpreg ((char *) &fpregs, regno);
448628fe 112 }
448628fe
MK
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
0d6e4ad7
MK
118static void
119alphabsd_store_inferior_registers (int regno)
448628fe 120{
e771a871
JT
121 if (regno == -1 || getregs_supplies (regno))
122 {
12bcb0fe 123 struct reg gregs;
e771a871 124 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
9f8e0089 125 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
edefbb7c 126 perror_with_name (_("Couldn't get registers"));
e771a871 127
12bcb0fe 128 alphabsd_fill_reg ((char *) &gregs, regno);
448628fe 129
e771a871 130 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
9f8e0089 131 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
edefbb7c 132 perror_with_name (_("Couldn't write registers"));
448628fe 133
e771a871
JT
134 if (regno != -1)
135 return;
136 }
448628fe
MK
137
138 if (regno == -1 || regno >= FP0_REGNUM)
139 {
12bcb0fe 140 struct fpreg fpregs;
448628fe 141
39f77062 142 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
9f8e0089 143 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
edefbb7c 144 perror_with_name (_("Couldn't get floating point status"));
448628fe 145
12bcb0fe 146 alphabsd_fill_fpreg ((char *) &fpregs, regno);
448628fe 147
39f77062 148 if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
9f8e0089 149 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
edefbb7c 150 perror_with_name (_("Couldn't write floating point status"));
448628fe
MK
151 }
152}
0d6e4ad7
MK
153
154/* Provide a prototype to silence -Wmissing-prototypes. */
155void _initialize_alphabsd_nat (void);
156
157void
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.365949 seconds and 4 git commands to generate.