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 (regno
)
40 struct reg inferior_registers
;
41 struct fpreg inferior_fp_registers
;
44 ptrace (PT_GETREGS
, inferior_pid
,
45 (PTRACE_ARG3_TYPE
) & inferior_registers
, 0);
46 for (i
= 0; i
< 32; i
++)
47 RF (i
, inferior_registers
.fixreg
[i
]);
48 RF (LR_REGNUM
, inferior_registers
.lr
);
49 RF (CR_REGNUM
, inferior_registers
.cr
);
50 RF (XER_REGNUM
, inferior_registers
.xer
);
51 RF (CTR_REGNUM
, inferior_registers
.ctr
);
52 RF (PC_REGNUM
, inferior_registers
.pc
);
54 ptrace (PT_GETFPREGS
, inferior_pid
,
55 (PTRACE_ARG3_TYPE
) & inferior_fp_registers
, 0);
56 for (i
= 0; i
< 32; i
++)
57 RF (FP0_REGNUM
+ i
, inferior_fp_registers
.r_regs
[i
]);
63 store_inferior_registers (regno
)
66 struct reg inferior_registers
;
67 struct fpreg inferior_fp_registers
;
70 for (i
= 0; i
< 32; i
++)
71 RS (i
, inferior_registers
.fixreg
[i
]);
72 RS (LR_REGNUM
, inferior_registers
.lr
);
73 RS (CR_REGNUM
, inferior_registers
.cr
);
74 RS (XER_REGNUM
, inferior_registers
.xer
);
75 RS (CTR_REGNUM
, inferior_registers
.ctr
);
76 RS (PC_REGNUM
, inferior_registers
.pc
);
78 ptrace (PT_SETREGS
, inferior_pid
,
79 (PTRACE_ARG3_TYPE
) & inferior_registers
, 0);
81 for (i
= 0; i
< 32; i
++)
82 RS (FP0_REGNUM
+ i
, inferior_fp_registers
.r_regs
[i
]);
83 ptrace (PT_SETFPREGS
, inferior_pid
,
84 (PTRACE_ARG3_TYPE
) & inferior_fp_registers
, 0);
94 fetch_core_registers (core_reg_sect
, core_reg_size
, which
, ignore
)
96 unsigned core_reg_size
;
100 struct md_core
*core_reg
= (struct md_core
*) core_reg_sect
;
103 /* Integer registers */
104 for (i
= 0; i
< 32; i
++)
105 RF (i
, core_reg
->intreg
.fixreg
[i
]);
106 RF (LR_REGNUM
, core_reg
->intreg
.lr
);
107 RF (CR_REGNUM
, core_reg
->intreg
.cr
);
108 RF (XER_REGNUM
, core_reg
->intreg
.xer
);
109 RF (CTR_REGNUM
, core_reg
->intreg
.ctr
);
110 RF (PC_REGNUM
, core_reg
->intreg
.pc
);
112 /* Floating point registers */
113 for (i
= 0; i
< 32; i
++)
114 RF (FP0_REGNUM
+ i
, core_reg
->freg
.r_regs
[i
]);
116 registers_fetched ();
119 /* Register that we are able to handle ppcnbsd core file formats.
120 FIXME: is this really bfd_target_unknown_flavour? */
122 static struct core_fns ppcnbsd_core_fns
=
124 bfd_target_unknown_flavour
, /* core_flavour */
125 default_check_format
, /* check_format */
126 default_core_sniffer
, /* core_sniffer */
127 fetch_core_registers
, /* core_read_registers */
132 _initialize_ppcnbsd_nat ()
134 add_core_fns (&ppcnbsd_core_fns
);