1 /* Native-dependent code for PowerPC's running NetBSD, for GDB.
2 Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
21 #include <sys/types.h>
22 #include <sys/ptrace.h>
23 #include <machine/reg.h>
24 #include <machine/frame.h>
31 #define RF(dst, src) \
32 memcpy(®isters[REGISTER_BYTE(dst)], &src, sizeof(src))
34 #define RS(src, dst) \
35 memcpy(&dst, ®isters[REGISTER_BYTE(src)], sizeof(dst))
38 fetch_inferior_registers (int regno
)
40 struct reg inferior_registers
;
42 struct fpreg inferior_fp_registers
;
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
);
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
]);
67 store_inferior_registers (int regno
)
69 struct reg inferior_registers
;
71 struct fpreg inferior_fp_registers
;
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
);
83 ptrace (PT_SETREGS
, inferior_pid
,
84 (PTRACE_ARG3_TYPE
) & inferior_registers
, 0);
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);
103 fetch_core_registers (char *core_reg_sect
, unsigned core_reg_size
, int which
,
106 struct md_core
*core_reg
= (struct md_core
*) core_reg_sect
;
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
);
119 /* Floating point registers */
120 for (i
= 0; i
< 32; i
++)
121 RF (FP0_REGNUM
+ i
, core_reg
->freg
.r_regs
[i
]);
124 registers_fetched ();
127 /* Register that we are able to handle ppcnbsd core file formats.
128 FIXME: is this really bfd_target_unknown_flavour? */
130 static struct core_fns ppcnbsd_core_fns
=
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 */
140 _initialize_ppcnbsd_nat (void)
142 add_core_fns (&ppcnbsd_core_fns
);