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>
30 #define RF(dst, src) \
31 memcpy(®isters[REGISTER_BYTE(dst)], &src, sizeof(src))
33 #define RS(src, dst) \
34 memcpy(&dst, ®isters[REGISTER_BYTE(src)], sizeof(dst))
37 fetch_inferior_registers (int regno
)
39 struct reg inferior_registers
;
40 struct fpreg inferior_fp_registers
;
43 ptrace (PT_GETREGS
, inferior_pid
,
44 (PTRACE_ARG3_TYPE
) & inferior_registers
, 0);
45 for (i
= 0; i
< 32; i
++)
46 RF (i
, inferior_registers
.fixreg
[i
]);
47 RF (LR_REGNUM
, inferior_registers
.lr
);
48 RF (CR_REGNUM
, inferior_registers
.cr
);
49 RF (XER_REGNUM
, inferior_registers
.xer
);
50 RF (CTR_REGNUM
, inferior_registers
.ctr
);
51 RF (PC_REGNUM
, inferior_registers
.pc
);
53 ptrace (PT_GETFPREGS
, inferior_pid
,
54 (PTRACE_ARG3_TYPE
) & inferior_fp_registers
, 0);
55 for (i
= 0; i
< 32; i
++)
56 RF (FP0_REGNUM
+ i
, inferior_fp_registers
.r_regs
[i
]);
62 store_inferior_registers (int regno
)
64 struct reg inferior_registers
;
65 struct fpreg inferior_fp_registers
;
68 for (i
= 0; i
< 32; i
++)
69 RS (i
, inferior_registers
.fixreg
[i
]);
70 RS (LR_REGNUM
, inferior_registers
.lr
);
71 RS (CR_REGNUM
, inferior_registers
.cr
);
72 RS (XER_REGNUM
, inferior_registers
.xer
);
73 RS (CTR_REGNUM
, inferior_registers
.ctr
);
74 RS (PC_REGNUM
, inferior_registers
.pc
);
76 ptrace (PT_SETREGS
, inferior_pid
,
77 (PTRACE_ARG3_TYPE
) & inferior_registers
, 0);
79 for (i
= 0; i
< 32; i
++)
80 RS (FP0_REGNUM
+ i
, inferior_fp_registers
.r_regs
[i
]);
81 ptrace (PT_SETFPREGS
, inferior_pid
,
82 (PTRACE_ARG3_TYPE
) & inferior_fp_registers
, 0);
92 fetch_core_registers (char *core_reg_sect
, unsigned core_reg_size
, int which
,
95 struct md_core
*core_reg
= (struct md_core
*) core_reg_sect
;
98 /* Integer registers */
99 for (i
= 0; i
< 32; i
++)
100 RF (i
, core_reg
->intreg
.fixreg
[i
]);
101 RF (LR_REGNUM
, core_reg
->intreg
.lr
);
102 RF (CR_REGNUM
, core_reg
->intreg
.cr
);
103 RF (XER_REGNUM
, core_reg
->intreg
.xer
);
104 RF (CTR_REGNUM
, core_reg
->intreg
.ctr
);
105 RF (PC_REGNUM
, core_reg
->intreg
.pc
);
107 /* Floating point registers */
108 for (i
= 0; i
< 32; i
++)
109 RF (FP0_REGNUM
+ i
, core_reg
->freg
.r_regs
[i
]);
111 registers_fetched ();
114 /* Register that we are able to handle ppcnbsd core file formats.
115 FIXME: is this really bfd_target_unknown_flavour? */
117 static struct core_fns ppcnbsd_core_fns
=
119 bfd_target_unknown_flavour
, /* core_flavour */
120 default_check_format
, /* check_format */
121 default_core_sniffer
, /* core_sniffer */
122 fetch_core_registers
, /* core_read_registers */
127 _initialize_ppcnbsd_nat (void)
129 add_core_fns (&ppcnbsd_core_fns
);