Commit | Line | Data |
---|---|---|
d195bc9f MK |
1 | /* Native-dependent code for OpenBSD/powerpc. |
2 | ||
65d034bc | 3 | Copyright 2004, 2005 Free Software Foundation, Inc. |
d195bc9f 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 | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include "inferior.h" | |
24 | #include "regcache.h" | |
25 | ||
26 | #include <stddef.h> | |
27 | #include <sys/types.h> | |
28 | #include <sys/ptrace.h> | |
29 | #include <machine/reg.h> | |
30 | ||
c79ac407 | 31 | #include "ppc-tdep.h" |
d195bc9f | 32 | #include "ppcobsd-tdep.h" |
65d034bc | 33 | #include "inf-ptrace.h" |
d195bc9f MK |
34 | |
35 | /* OpenBSD/powerpc doesn't have PT_GETFPREGS/PT_SETFPREGS like | |
36 | NetBSD/powerpc and FreeBSD/powerpc. */ | |
37 | ||
38 | /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this | |
39 | for all registers. */ | |
40 | ||
65d034bc MK |
41 | static void |
42 | ppcobsd_fetch_registers (int regnum) | |
d195bc9f MK |
43 | { |
44 | struct reg regs; | |
45 | ||
46 | if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), | |
9f8e0089 | 47 | (PTRACE_TYPE_ARG3) ®s, 0) == -1) |
e2e0b3e5 | 48 | perror_with_name (_("Couldn't get registers")); |
d195bc9f MK |
49 | |
50 | ppcobsd_supply_gregset (&ppcobsd_gregset, current_regcache, -1, | |
51 | ®s, sizeof regs); | |
52 | } | |
53 | ||
54 | /* Store register REGNUM back into the inferior. If REGNUM is -1, do | |
55 | this for all registers. */ | |
56 | ||
65d034bc MK |
57 | static void |
58 | ppcobsd_store_registers (int regnum) | |
d195bc9f MK |
59 | { |
60 | struct reg regs; | |
61 | ||
62 | if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), | |
9f8e0089 | 63 | (PTRACE_TYPE_ARG3) ®s, 0) == -1) |
e2e0b3e5 | 64 | perror_with_name (_("Couldn't get registers")); |
d195bc9f MK |
65 | |
66 | ppcobsd_collect_gregset (&ppcobsd_gregset, current_regcache, | |
67 | regnum, ®s, sizeof regs); | |
68 | ||
69 | if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), | |
9f8e0089 | 70 | (PTRACE_TYPE_ARG3) ®s, 0) == -1) |
e2e0b3e5 | 71 | perror_with_name (_("Couldn't write registers")); |
d195bc9f MK |
72 | } |
73 | \f | |
74 | ||
75 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
76 | void _initialize_ppcobsd_nat (void); | |
77 | ||
78 | void | |
79 | _initialize_ppcobsd_nat (void) | |
80 | { | |
65d034bc MK |
81 | struct target_ops *t; |
82 | ||
83 | /* Add in local overrides. */ | |
84 | t = inf_ptrace_target (); | |
85 | t->to_fetch_registers = ppcobsd_fetch_registers; | |
86 | t->to_store_registers = ppcobsd_store_registers; | |
87 | add_target (t); | |
88 | ||
d195bc9f MK |
89 | /* General-purpose registers. */ |
90 | ppcobsd_reg_offsets.r0_offset = offsetof (struct reg, gpr); | |
91 | ppcobsd_reg_offsets.pc_offset = offsetof (struct reg, pc); | |
92 | ppcobsd_reg_offsets.ps_offset = offsetof (struct reg, ps); | |
93 | ppcobsd_reg_offsets.cr_offset = offsetof (struct reg, cnd); | |
94 | ppcobsd_reg_offsets.lr_offset = offsetof (struct reg, lr); | |
95 | ppcobsd_reg_offsets.ctr_offset = offsetof (struct reg, cnt); | |
96 | ppcobsd_reg_offsets.xer_offset = offsetof (struct reg, xer); | |
97 | ppcobsd_reg_offsets.mq_offset = offsetof (struct reg, mq); | |
98 | ||
99 | /* Floating-point registers. */ | |
100 | ppcobsd_reg_offsets.f0_offset = offsetof (struct reg, fpr); | |
101 | ppcobsd_reg_offsets.fpscr_offset = -1; | |
102 | ||
103 | /* AltiVec registers. */ | |
104 | ppcobsd_reg_offsets.vr0_offset = offsetof (struct vreg, vreg); | |
105 | ppcobsd_reg_offsets.vscr_offset = offsetof (struct vreg, vscr); | |
106 | ppcobsd_reg_offsets.vrsave_offset = offsetof (struct vreg, vrsave); | |
107 | } |