2005-02-11 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / ppcobsd-nat.c
1 /* Native-dependent code for OpenBSD/powerpc.
2
3 Copyright 2004 Free Software Foundation, Inc.
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
31 #include "ppc-tdep.h"
32 #include "ppcobsd-tdep.h"
33
34 /* OpenBSD/powerpc doesn't have PT_GETFPREGS/PT_SETFPREGS like
35 NetBSD/powerpc and FreeBSD/powerpc. */
36
37 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
38 for all registers. */
39
40 void
41 fetch_inferior_registers (int regnum)
42 {
43 struct reg regs;
44
45 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
46 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
47 perror_with_name (_("Couldn't get registers"));
48
49 ppcobsd_supply_gregset (&ppcobsd_gregset, current_regcache, -1,
50 &regs, sizeof regs);
51 }
52
53 /* Store register REGNUM back into the inferior. If REGNUM is -1, do
54 this for all registers. */
55
56 void
57 store_inferior_registers (int regnum)
58 {
59 struct reg regs;
60
61 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
62 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
63 perror_with_name (_("Couldn't get registers"));
64
65 ppcobsd_collect_gregset (&ppcobsd_gregset, current_regcache,
66 regnum, &regs, sizeof regs);
67
68 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
69 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
70 perror_with_name (_("Couldn't write registers"));
71 }
72 \f
73
74 /* Provide a prototype to silence -Wmissing-prototypes. */
75 void _initialize_ppcobsd_nat (void);
76
77 void
78 _initialize_ppcobsd_nat (void)
79 {
80 /* General-purpose registers. */
81 ppcobsd_reg_offsets.r0_offset = offsetof (struct reg, gpr);
82 ppcobsd_reg_offsets.pc_offset = offsetof (struct reg, pc);
83 ppcobsd_reg_offsets.ps_offset = offsetof (struct reg, ps);
84 ppcobsd_reg_offsets.cr_offset = offsetof (struct reg, cnd);
85 ppcobsd_reg_offsets.lr_offset = offsetof (struct reg, lr);
86 ppcobsd_reg_offsets.ctr_offset = offsetof (struct reg, cnt);
87 ppcobsd_reg_offsets.xer_offset = offsetof (struct reg, xer);
88 ppcobsd_reg_offsets.mq_offset = offsetof (struct reg, mq);
89
90 /* Floating-point registers. */
91 ppcobsd_reg_offsets.f0_offset = offsetof (struct reg, fpr);
92 ppcobsd_reg_offsets.fpscr_offset = -1;
93
94 /* AltiVec registers. */
95 ppcobsd_reg_offsets.vr0_offset = offsetof (struct vreg, vreg);
96 ppcobsd_reg_offsets.vscr_offset = offsetof (struct vreg, vscr);
97 ppcobsd_reg_offsets.vrsave_offset = offsetof (struct vreg, vrsave);
98 }
This page took 0.049348 seconds and 4 git commands to generate.