1 /* Native-dependent code for HP PA-RISC BSD's.
3 Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, 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 3 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, see <http://www.gnu.org/licenses/>. */
26 #include <sys/types.h>
27 #include <sys/ptrace.h>
28 #include <machine/reg.h>
30 #include "hppa-tdep.h"
31 #include "inf-ptrace.h"
34 hppabsd_gregset_supplies_p (int regnum
)
36 return (regnum
>= HPPA_R0_REGNUM
&& regnum
<= HPPA_PCOQ_TAIL_REGNUM
);
40 hppabsd_fpregset_supplies_p (int regnum
)
42 return (regnum
>= HPPA_FP0_REGNUM
&& regnum
<= HPPA_FP31R_REGNUM
);
45 /* Supply the general-purpose registers stored in GREGS to REGCACHE. */
48 hppabsd_supply_gregset (struct regcache
*regcache
, const void *gregs
)
50 const char *regs
= gregs
;
53 for (regnum
= HPPA_R1_REGNUM
; regnum
<= HPPA_R31_REGNUM
; regnum
++)
54 regcache_raw_supply (regcache
, regnum
, regs
+ regnum
* 4);
56 regcache_raw_supply (regcache
, HPPA_SAR_REGNUM
, regs
);
57 regcache_raw_supply (regcache
, HPPA_PCOQ_HEAD_REGNUM
, regs
+ 32 * 4);
58 regcache_raw_supply (regcache
, HPPA_PCOQ_TAIL_REGNUM
, regs
+ 33 * 4);
61 /* Supply the floating-point registers stored in FPREGS to REGCACHE. */
64 hppabsd_supply_fpregset (struct regcache
*regcache
, const void *fpregs
)
66 const char *regs
= fpregs
;
69 for (regnum
= HPPA_FP0_REGNUM
; regnum
<= HPPA_FP31R_REGNUM
;
70 regnum
+= 2, regs
+= 8)
72 regcache_raw_supply (regcache
, regnum
, regs
);
73 regcache_raw_supply (regcache
, regnum
+ 1, regs
+ 4);
77 /* Collect the general-purpose registers from REGCACHE and store them
81 hppabsd_collect_gregset (const struct regcache
*regcache
,
82 void *gregs
, int regnum
)
87 for (i
= HPPA_R1_REGNUM
; i
<= HPPA_R31_REGNUM
; i
++)
89 if (regnum
== -1 || regnum
== i
)
90 regcache_raw_collect (regcache
, i
, regs
+ i
* 4);
93 if (regnum
== -1 || regnum
== HPPA_SAR_REGNUM
)
94 regcache_raw_collect (regcache
, HPPA_SAR_REGNUM
, regs
);
95 if (regnum
== -1 || regnum
== HPPA_PCOQ_HEAD_REGNUM
)
96 regcache_raw_collect (regcache
, HPPA_PCOQ_HEAD_REGNUM
, regs
+ 32 * 4);
97 if (regnum
== -1 || regnum
== HPPA_PCOQ_TAIL_REGNUM
)
98 regcache_raw_collect (regcache
, HPPA_PCOQ_TAIL_REGNUM
, regs
+ 33 * 4);
101 /* Collect the floating-point registers from REGCACHE and store them
105 hppabsd_collect_fpregset (struct regcache
*regcache
,
106 void *fpregs
, int regnum
)
111 for (i
= HPPA_FP0_REGNUM
; i
<= HPPA_FP31R_REGNUM
; i
+= 2, regs
+= 8)
113 if (regnum
== -1 || regnum
== i
|| regnum
== i
+ 1)
115 regcache_raw_collect (regcache
, i
, regs
);
116 regcache_raw_collect (regcache
, i
+ 1, regs
+ 4);
122 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
123 for all registers (including the floating-point registers). */
126 hppabsd_fetch_registers (struct target_ops
*ops
,
127 struct regcache
*regcache
, int regnum
)
129 if (regnum
== -1 || hppabsd_gregset_supplies_p (regnum
))
133 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
134 (PTRACE_TYPE_ARG3
) ®s
, 0) == -1)
135 perror_with_name (_("Couldn't get registers"));
137 hppabsd_supply_gregset (regcache
, ®s
);
140 if (regnum
== -1 || hppabsd_fpregset_supplies_p (regnum
))
144 if (ptrace (PT_GETFPREGS
, PIDGET (inferior_ptid
),
145 (PTRACE_TYPE_ARG3
) &fpregs
, 0) == -1)
146 perror_with_name (_("Couldn't get floating point status"));
148 hppabsd_supply_fpregset (regcache
, &fpregs
);
152 /* Store register REGNUM back into the inferior. If REGNUM is -1, do
153 this for all registers (including the floating-point registers). */
156 hppabsd_store_registers (struct target_ops
*ops
,
157 struct regcache
*regcache
, int regnum
)
159 if (regnum
== -1 || hppabsd_gregset_supplies_p (regnum
))
163 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
164 (PTRACE_TYPE_ARG3
) ®s
, 0) == -1)
165 perror_with_name (_("Couldn't get registers"));
167 hppabsd_collect_gregset (regcache
, ®s
, regnum
);
169 if (ptrace (PT_SETREGS
, PIDGET (inferior_ptid
),
170 (PTRACE_TYPE_ARG3
) ®s
, 0) == -1)
171 perror_with_name (_("Couldn't write registers"));
174 if (regnum
== -1 || hppabsd_fpregset_supplies_p (regnum
))
178 if (ptrace (PT_GETFPREGS
, PIDGET (inferior_ptid
),
179 (PTRACE_TYPE_ARG3
) &fpregs
, 0) == -1)
180 perror_with_name (_("Couldn't get floating point status"));
182 hppabsd_collect_fpregset (regcache
, &fpregs
, regnum
);
184 if (ptrace (PT_SETFPREGS
, PIDGET (inferior_ptid
),
185 (PTRACE_TYPE_ARG3
) &fpregs
, 0) == -1)
186 perror_with_name (_("Couldn't write floating point status"));
190 /* Provide a prototype to silence -Wmissing-prototypes. */
191 void _initialize_hppabsd_nat (void);
194 _initialize_hppabsd_nat (void)
196 struct target_ops
*t
;
198 /* Add in local overrides. */
199 t
= inf_ptrace_target ();
200 t
->to_fetch_registers
= hppabsd_fetch_registers
;
201 t
->to_store_registers
= hppabsd_store_registers
;
This page took 0.0336 seconds and 4 git commands to generate.