1 /* Native-dependent code for HP PA-RISC BSD's.
3 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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. */
27 #include <sys/types.h>
28 #include <sys/ptrace.h>
29 #include <machine/reg.h>
31 #include "hppa-tdep.h"
32 #include "inf-ptrace.h"
35 hppabsd_gregset_supplies_p (int regnum
)
37 return (regnum
>= HPPA_R0_REGNUM
&& regnum
<= HPPA_PCOQ_TAIL_REGNUM
);
41 hppabsd_fpregset_supplies_p (int regnum
)
43 return (regnum
>= HPPA_FP0_REGNUM
&& regnum
<= HPPA_FP31R_REGNUM
);
46 /* Supply the general-purpose registers stored in GREGS to REGCACHE. */
49 hppabsd_supply_gregset (struct regcache
*regcache
, const void *gregs
)
51 const char *regs
= gregs
;
54 for (regnum
= HPPA_R1_REGNUM
; regnum
<= HPPA_R31_REGNUM
; regnum
++)
55 regcache_raw_supply (regcache
, regnum
, regs
+ regnum
* 4);
57 regcache_raw_supply (regcache
, HPPA_SAR_REGNUM
, regs
);
58 regcache_raw_supply (regcache
, HPPA_PCOQ_HEAD_REGNUM
, regs
+ 32 * 4);
59 regcache_raw_supply (regcache
, HPPA_PCOQ_TAIL_REGNUM
, regs
+ 33 * 4);
62 /* Supply the floating-point registers stored in FPREGS to REGCACHE. */
65 hppabsd_supply_fpregset (struct regcache
*regcache
, const void *fpregs
)
67 const char *regs
= fpregs
;
70 for (regnum
= HPPA_FP0_REGNUM
; regnum
<= HPPA_FP31R_REGNUM
;
71 regnum
+= 2, regs
+= 8)
73 regcache_raw_supply (regcache
, regnum
, regs
);
74 regcache_raw_supply (regcache
, regnum
+ 1, regs
+ 4);
78 /* Collect the general-purpose registers from REGCACHE and store them
82 hppabsd_collect_gregset (const struct regcache
*regcache
,
83 void *gregs
, int regnum
)
88 for (i
= HPPA_R1_REGNUM
; i
<= HPPA_R31_REGNUM
; i
++)
90 if (regnum
== -1 || regnum
== i
)
91 regcache_raw_collect (regcache
, i
, regs
+ i
* 4);
94 if (regnum
== -1 || regnum
== HPPA_SAR_REGNUM
)
95 regcache_raw_collect (regcache
, HPPA_SAR_REGNUM
, regs
);
96 if (regnum
== -1 || regnum
== HPPA_PCOQ_HEAD_REGNUM
)
97 regcache_raw_collect (regcache
, HPPA_PCOQ_HEAD_REGNUM
, regs
+ 32 * 4);
98 if (regnum
== -1 || regnum
== HPPA_PCOQ_TAIL_REGNUM
)
99 regcache_raw_collect (regcache
, HPPA_PCOQ_TAIL_REGNUM
, regs
+ 33 * 4);
102 /* Collect the floating-point registers from REGCACHE and store them
106 hppabsd_collect_fpregset (struct regcache
*regcache
,
107 void *fpregs
, int regnum
)
112 for (i
= HPPA_FP0_REGNUM
; i
<= HPPA_FP31R_REGNUM
; i
+= 2, regs
+= 8)
114 if (regnum
== -1 || regnum
== i
|| regnum
== i
+ 1)
116 regcache_raw_collect (regcache
, i
, regs
);
117 regcache_raw_collect (regcache
, i
+ 1, regs
+ 4);
123 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
124 for all registers (including the floating-point registers). */
127 hppabsd_fetch_registers (int regnum
)
129 struct regcache
*regcache
= current_regcache
;
131 if (regnum
== -1 || hppabsd_gregset_supplies_p (regnum
))
135 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
136 (PTRACE_TYPE_ARG3
) ®s
, 0) == -1)
137 perror_with_name (_("Couldn't get registers"));
139 hppabsd_supply_gregset (regcache
, ®s
);
142 if (regnum
== -1 || hppabsd_fpregset_supplies_p (regnum
))
146 if (ptrace (PT_GETFPREGS
, PIDGET (inferior_ptid
),
147 (PTRACE_TYPE_ARG3
) &fpregs
, 0) == -1)
148 perror_with_name (_("Couldn't get floating point status"));
150 hppabsd_supply_fpregset (current_regcache
, &fpregs
);
154 /* Store register REGNUM back into the inferior. If REGNUM is -1, do
155 this for all registers (including the floating-point registers). */
158 hppabsd_store_registers (int regnum
)
160 if (regnum
== -1 || hppabsd_gregset_supplies_p (regnum
))
164 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
165 (PTRACE_TYPE_ARG3
) ®s
, 0) == -1)
166 perror_with_name (_("Couldn't get registers"));
168 hppabsd_collect_gregset (current_regcache
, ®s
, regnum
);
170 if (ptrace (PT_SETREGS
, PIDGET (inferior_ptid
),
171 (PTRACE_TYPE_ARG3
) ®s
, 0) == -1)
172 perror_with_name (_("Couldn't write registers"));
175 if (regnum
== -1 || hppabsd_fpregset_supplies_p (regnum
))
179 if (ptrace (PT_GETFPREGS
, PIDGET (inferior_ptid
),
180 (PTRACE_TYPE_ARG3
) &fpregs
, 0) == -1)
181 perror_with_name (_("Couldn't get floating point status"));
183 hppabsd_collect_fpregset (current_regcache
, &fpregs
, regnum
);
185 if (ptrace (PT_SETFPREGS
, PIDGET (inferior_ptid
),
186 (PTRACE_TYPE_ARG3
) &fpregs
, 0) == -1)
187 perror_with_name (_("Couldn't write floating point status"));
191 /* Provide a prototype to silence -Wmissing-prototypes. */
192 void _initialize_hppabsd_nat (void);
195 _initialize_hppabsd_nat (void)
197 struct target_ops
*t
;
199 /* Add in local overrides. */
200 t
= inf_ptrace_target ();
201 t
->to_fetch_registers
= hppabsd_fetch_registers
;
202 t
->to_store_registers
= hppabsd_store_registers
;
This page took 0.032906 seconds and 4 git commands to generate.