* arch-utils.c (set_architecture, set_architecture_from_arch_mach,
[deliverable/binutils-gdb.git] / gdb / ppcnbsd-nat.c
CommitLineData
e42180d7
C
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"
ec3d358c 29#include "ppc-tdep.h"
e42180d7
C
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
fba45db2 38fetch_inferior_registers (int regno)
e42180d7
C
39{
40 struct reg inferior_registers;
ec3d358c 41#ifdef PT_GETFPREGS
e42180d7 42 struct fpreg inferior_fp_registers;
ec3d358c 43#endif
e42180d7
C
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]);
ec3d358c
C
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);
e42180d7
C
54 RF (PC_REGNUM, inferior_registers.pc);
55
ec3d358c 56#ifdef PT_GETFPREGS
e42180d7 57 ptrace (PT_GETFPREGS, inferior_pid,
ec3d358c 58 (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
e42180d7
C
59 for (i = 0; i < 32; i++)
60 RF (FP0_REGNUM + i, inferior_fp_registers.r_regs[i]);
ec3d358c 61#endif
e42180d7
C
62
63 registers_fetched ();
64}
65
66void
fba45db2 67store_inferior_registers (int regno)
e42180d7
C
68{
69 struct reg inferior_registers;
ec3d358c 70#ifdef PT_SETFPREGS
e42180d7 71 struct fpreg inferior_fp_registers;
ec3d358c 72#endif
e42180d7
C
73 int i;
74
75 for (i = 0; i < 32; i++)
76 RS (i, inferior_registers.fixreg[i]);
ec3d358c
C
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);
e42180d7
C
81 RS (PC_REGNUM, inferior_registers.pc);
82
83 ptrace (PT_SETREGS, inferior_pid,
84 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
85
ec3d358c 86#ifdef PT_SETFPREGS
e42180d7
C
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);
ec3d358c 91#endif
e42180d7
C
92}
93
94struct md_core
95{
96 struct reg intreg;
ec3d358c 97#ifdef PT_GETFPREGS
e42180d7 98 struct fpreg freg;
ec3d358c 99#endif
e42180d7
C
100};
101
102void
fba45db2
KB
103fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
104 CORE_ADDR ignore)
e42180d7
C
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]);
ec3d358c
C
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);
e42180d7
C
116 RF (PC_REGNUM, core_reg->intreg.pc);
117
ec3d358c 118#ifdef PT_FPGETREGS
e42180d7
C
119 /* Floating point registers */
120 for (i = 0; i < 32; i++)
121 RF (FP0_REGNUM + i, core_reg->freg.r_regs[i]);
ec3d358c 122#endif
e42180d7
C
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
fba45db2 140_initialize_ppcnbsd_nat (void)
e42180d7
C
141{
142 add_core_fns (&ppcnbsd_core_fns);
143}
This page took 0.048987 seconds and 4 git commands to generate.