1 /* Native-dependent code for PowerPC's running NetBSD, for GDB.
2 Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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. */
22 #include <sys/types.h>
23 #include <sys/ptrace.h>
24 #include <machine/reg.h>
25 #include <machine/frame.h>
33 #define RF(dst, src) \
34 memcpy(®isters[REGISTER_BYTE(dst)], &src, sizeof(src))
36 #define RS(src, dst) \
37 memcpy(&dst, ®isters[REGISTER_BYTE(src)], sizeof(dst))
40 fetch_inferior_registers (int regno
)
42 struct reg inferior_registers
;
44 struct fpreg inferior_fp_registers
;
48 ptrace (PT_GETREGS
, inferior_pid
,
49 (PTRACE_ARG3_TYPE
) & inferior_registers
, 0);
50 for (i
= 0; i
< 32; i
++)
51 RF (i
, inferior_registers
.fixreg
[i
]);
52 RF (PPC_LR_REGNUM
, inferior_registers
.lr
);
53 RF (PPC_CR_REGNUM
, inferior_registers
.cr
);
54 RF (PPC_XER_REGNUM
, inferior_registers
.xer
);
55 RF (PPC_CTR_REGNUM
, inferior_registers
.ctr
);
56 RF (PC_REGNUM
, inferior_registers
.pc
);
59 ptrace (PT_GETFPREGS
, inferior_pid
,
60 (PTRACE_ARG3_TYPE
) &inferior_fp_registers
, 0);
61 for (i
= 0; i
< 32; i
++)
62 RF (FP0_REGNUM
+ i
, inferior_fp_registers
.r_regs
[i
]);
69 store_inferior_registers (int regno
)
71 struct reg inferior_registers
;
73 struct fpreg inferior_fp_registers
;
77 for (i
= 0; i
< 32; i
++)
78 RS (i
, inferior_registers
.fixreg
[i
]);
79 RS (PPC_LR_REGNUM
, inferior_registers
.lr
);
80 RS (PPC_CR_REGNUM
, inferior_registers
.cr
);
81 RS (PPC_XER_REGNUM
, inferior_registers
.xer
);
82 RS (PPC_CTR_REGNUM
, inferior_registers
.ctr
);
83 RS (PC_REGNUM
, inferior_registers
.pc
);
85 ptrace (PT_SETREGS
, inferior_pid
,
86 (PTRACE_ARG3_TYPE
) & inferior_registers
, 0);
89 for (i
= 0; i
< 32; i
++)
90 RS (FP0_REGNUM
+ i
, inferior_fp_registers
.r_regs
[i
]);
91 ptrace (PT_SETFPREGS
, inferior_pid
,
92 (PTRACE_ARG3_TYPE
) & inferior_fp_registers
, 0);
105 fetch_core_registers (char *core_reg_sect
, unsigned core_reg_size
, int which
,
108 struct md_core
*core_reg
= (struct md_core
*) core_reg_sect
;
111 /* Integer registers */
112 for (i
= 0; i
< 32; i
++)
113 RF (i
, core_reg
->intreg
.fixreg
[i
]);
114 RF (PPC_LR_REGNUM
, core_reg
->intreg
.lr
);
115 RF (PPC_CR_REGNUM
, core_reg
->intreg
.cr
);
116 RF (PPC_XER_REGNUM
, core_reg
->intreg
.xer
);
117 RF (PPC_CTR_REGNUM
, core_reg
->intreg
.ctr
);
118 RF (PC_REGNUM
, core_reg
->intreg
.pc
);
121 /* Floating point registers */
122 for (i
= 0; i
< 32; i
++)
123 RF (FP0_REGNUM
+ i
, core_reg
->freg
.r_regs
[i
]);
126 registers_fetched ();
129 /* Register that we are able to handle ppcnbsd core file formats.
130 FIXME: is this really bfd_target_unknown_flavour? */
132 static struct core_fns ppcnbsd_core_fns
=
134 bfd_target_unknown_flavour
, /* core_flavour */
135 default_check_format
, /* check_format */
136 default_core_sniffer
, /* core_sniffer */
137 fetch_core_registers
, /* core_read_registers */
142 _initialize_ppcnbsd_nat (void)
144 add_core_fns (&ppcnbsd_core_fns
);