* config/tc-xtensa.c (xtensa_mark_literal_pool_location): Remove
[deliverable/binutils-gdb.git] / gdb / sparcbsd-nat.c
1 /* Native-dependent code for SPARC BSD's.
2
3 Copyright 2002, 2003 Free Software Foundation, Inc.
4 Based on code contributed by Wasabi Systems, Inc.
5
6 This file is part of GDB.
7
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.
12
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.
17
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. */
22
23 #include "defs.h"
24 #include "inferior.h"
25 #include "regcache.h"
26
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"
30
31 #include <sys/types.h>
32 #include <sys/ptrace.h>
33 #include <machine/reg.h>
34
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);
41
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);
46
47 void
48 fetch_inferior_registers (int regnum)
49 {
50 if (regnum == -1 || sparcbsd_reg_supplies_p (regnum))
51 {
52 struct reg regs;
53
54 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
55 (PTRACE_ARG3_TYPE) &regs, 0) == -1)
56 perror_with_name ("Couldn't get registers");
57
58 sparcbsd_supply_reg ((char *) &regs, regnum);
59 if (regnum != -1)
60 return;
61 }
62
63 if (regnum == -1 || sparcbsd_fpreg_supplies_p (regnum))
64 {
65 struct fpreg fpregs;
66
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");
70
71 sparcbsd_supply_fpreg ((char *) &fpregs, regnum);
72 if (regnum != -1)
73 return;
74 }
75 }
76
77 void
78 store_inferior_registers (int regnum)
79 {
80 if (regnum == -1 || sparcbsd_reg_supplies_p (regnum))
81 {
82 struct reg regs;
83
84 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
85 (PTRACE_ARG3_TYPE) &regs, 0) == -1)
86 perror_with_name ("Couldn't get registers");
87
88 sparcbsd_fill_reg ((char *) &regs, regnum);
89
90 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
91 (PTRACE_ARG3_TYPE) &regs, 0) == -1)
92 perror_with_name ("Couldn't write registers");
93
94 /* Deal with the stack regs. */
95 if (regnum == -1 || regnum == SPARC_SP_REGNUM
96 || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM))
97 {
98 ULONGEST sp;
99
100 regcache_cooked_read_unsigned (current_regcache,
101 SPARC_SP_REGNUM, &sp);
102 sparc_fill_rwindow (sp, regnum);
103 }
104
105 if (regnum != -1)
106 return;
107 }
108
109 if (regnum == -1 || sparcbsd_fpreg_supplies_p (regnum))
110 {
111 struct fpreg fpregs;
112
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");
116
117 sparcbsd_fill_fpreg ((char *) &fpregs, regnum);
118
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");
122
123 if (regnum != -1)
124 return;
125 }
126 }
This page took 0.031301 seconds and 4 git commands to generate.