1 /* Native-dependent code for SPARC BSD's.
3 Copyright 2002, 2003 Free Software Foundation, Inc.
4 Based on code contributed by Wasabi Systems, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
27 /* FIXME: Should be changed to sparc-tdep.h when the old code is gone. */
28 #include "sparc64-tdep.h"
29 #include "sparcbsd-nat.h"
31 #include <sys/types.h>
32 #include <sys/ptrace.h>
33 #include <machine/reg.h>
35 /* Functions translating between `struct reg' and `struct fpreg' and
36 GDB's register cache. */
37 void (*sparcbsd_supply_reg
)(const char *, int);
38 void (*sparcbsd_fill_reg
)(char *, int);
39 void (*sparcbsd_supply_fpreg
)(const char *, int);
40 void (*sparcbsd_fill_fpreg
)(char *, int);
42 /* Functions indication whether `struct reg' or `struct fpreg' provides
43 a certain register. */
44 int (*sparcbsd_reg_supplies_p
)(int);
45 int (*sparcbsd_fpreg_supplies_p
)(int);
48 fetch_inferior_registers (int regnum
)
50 if (regnum
== -1 || sparcbsd_reg_supplies_p (regnum
))
54 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
55 (PTRACE_ARG3_TYPE
) ®s
, 0) == -1)
56 perror_with_name ("Couldn't get registers");
58 sparcbsd_supply_reg ((char *) ®s
, regnum
);
63 if (regnum
== -1 || sparcbsd_fpreg_supplies_p (regnum
))
67 if (ptrace (PT_GETFPREGS
, PIDGET (inferior_ptid
),
68 (PTRACE_ARG3_TYPE
) &fpregs
, 0) == -1)
69 perror_with_name ("Couldn't get floating-point registers");
71 sparcbsd_supply_fpreg ((char *) &fpregs
, regnum
);
78 store_inferior_registers (int regnum
)
80 if (regnum
== -1 || sparcbsd_reg_supplies_p (regnum
))
84 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
85 (PTRACE_ARG3_TYPE
) ®s
, 0) == -1)
86 perror_with_name ("Couldn't get registers");
88 sparcbsd_fill_reg ((char *) ®s
, regnum
);
90 if (ptrace (PT_SETREGS
, PIDGET (inferior_ptid
),
91 (PTRACE_ARG3_TYPE
) ®s
, 0) == -1)
92 perror_with_name ("Couldn't write registers");
94 /* Deal with the stack regs. */
95 if (regnum
== -1 || regnum
== SPARC_SP_REGNUM
96 || (regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
))
100 regcache_cooked_read_unsigned (current_regcache
,
101 SPARC_SP_REGNUM
, &sp
);
102 sparc_fill_rwindow (sp
, regnum
);
109 if (regnum
== -1 || sparcbsd_fpreg_supplies_p (regnum
))
113 if (ptrace (PT_GETFPREGS
, PIDGET (inferior_ptid
),
114 (PTRACE_ARG3_TYPE
) &fpregs
, 0) == -1)
115 perror_with_name ("Couldn't get floating-point registers");
117 sparcbsd_fill_fpreg ((char *) &fpregs
, regnum
);
119 if (ptrace (PT_SETFPREGS
, PIDGET (inferior_ptid
),
120 (PTRACE_ARG3_TYPE
) &fpregs
, 0) == -1)
121 perror_with_name ("Couldn't write floating-point registers");