Fix the year on the following lines:
[deliverable/binutils-gdb.git] / gdb / ppcnbsd-nat.c
... / ...
CommitLineData
1/* Native-dependent code for PowerPC's running NetBSD, for GDB.
2 Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include <sys/types.h>
22#include <sys/ptrace.h>
23#include <machine/reg.h>
24#include <machine/frame.h>
25
26#include "defs.h"
27#include "inferior.h"
28#include "gdbcore.h"
29#include "ppc-tdep.h"
30
31#define RF(dst, src) \
32 memcpy(&registers[REGISTER_BYTE(dst)], &src, sizeof(src))
33
34#define RS(src, dst) \
35 memcpy(&dst, &registers[REGISTER_BYTE(src)], sizeof(dst))
36
37void
38fetch_inferior_registers (int regno)
39{
40 struct reg inferior_registers;
41#ifdef PT_GETFPREGS
42 struct fpreg inferior_fp_registers;
43#endif
44 int i;
45
46 ptrace (PT_GETREGS, inferior_pid,
47 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
48 for (i = 0; i < 32; i++)
49 RF (i, inferior_registers.fixreg[i]);
50 RF (PPC_LR_REGNUM, inferior_registers.lr);
51 RF (PPC_CR_REGNUM, inferior_registers.cr);
52 RF (PPC_XER_REGNUM, inferior_registers.xer);
53 RF (PPC_CTR_REGNUM, inferior_registers.ctr);
54 RF (PC_REGNUM, inferior_registers.pc);
55
56#ifdef PT_GETFPREGS
57 ptrace (PT_GETFPREGS, inferior_pid,
58 (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
59 for (i = 0; i < 32; i++)
60 RF (FP0_REGNUM + i, inferior_fp_registers.r_regs[i]);
61#endif
62
63 registers_fetched ();
64}
65
66void
67store_inferior_registers (int regno)
68{
69 struct reg inferior_registers;
70#ifdef PT_SETFPREGS
71 struct fpreg inferior_fp_registers;
72#endif
73 int i;
74
75 for (i = 0; i < 32; i++)
76 RS (i, inferior_registers.fixreg[i]);
77 RS (PPC_LR_REGNUM, inferior_registers.lr);
78 RS (PPC_CR_REGNUM, inferior_registers.cr);
79 RS (PPC_XER_REGNUM, inferior_registers.xer);
80 RS (PPC_CTR_REGNUM, inferior_registers.ctr);
81 RS (PC_REGNUM, inferior_registers.pc);
82
83 ptrace (PT_SETREGS, inferior_pid,
84 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
85
86#ifdef PT_SETFPREGS
87 for (i = 0; i < 32; i++)
88 RS (FP0_REGNUM + i, inferior_fp_registers.r_regs[i]);
89 ptrace (PT_SETFPREGS, inferior_pid,
90 (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
91#endif
92}
93
94struct md_core
95{
96 struct reg intreg;
97#ifdef PT_GETFPREGS
98 struct fpreg freg;
99#endif
100};
101
102void
103fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
104 CORE_ADDR ignore)
105{
106 struct md_core *core_reg = (struct md_core *) core_reg_sect;
107 int i;
108
109 /* Integer registers */
110 for (i = 0; i < 32; i++)
111 RF (i, core_reg->intreg.fixreg[i]);
112 RF (PPC_LR_REGNUM, core_reg->intreg.lr);
113 RF (PPC_CR_REGNUM, core_reg->intreg.cr);
114 RF (PPC_XER_REGNUM, core_reg->intreg.xer);
115 RF (PPC_CTR_REGNUM, core_reg->intreg.ctr);
116 RF (PC_REGNUM, core_reg->intreg.pc);
117
118#ifdef PT_FPGETREGS
119 /* Floating point registers */
120 for (i = 0; i < 32; i++)
121 RF (FP0_REGNUM + i, core_reg->freg.r_regs[i]);
122#endif
123
124 registers_fetched ();
125}
126
127/* Register that we are able to handle ppcnbsd core file formats.
128 FIXME: is this really bfd_target_unknown_flavour? */
129
130static struct core_fns ppcnbsd_core_fns =
131{
132 bfd_target_unknown_flavour, /* core_flavour */
133 default_check_format, /* check_format */
134 default_core_sniffer, /* core_sniffer */
135 fetch_core_registers, /* core_read_registers */
136 NULL /* next */
137};
138
139void
140_initialize_ppcnbsd_nat (void)
141{
142 add_core_fns (&ppcnbsd_core_fns);
143}
This page took 0.023067 seconds and 4 git commands to generate.