Commit | Line | Data |
---|---|---|
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" | |
29 | ||
30 | #define RF(dst, src) \ | |
31 | memcpy(®isters[REGISTER_BYTE(dst)], &src, sizeof(src)) | |
32 | ||
33 | #define RS(src, dst) \ | |
34 | memcpy(&dst, ®isters[REGISTER_BYTE(src)], sizeof(dst)) | |
35 | ||
36 | void | |
37 | fetch_inferior_registers (regno) | |
38 | int regno; | |
39 | { | |
40 | struct reg inferior_registers; | |
41 | struct fpreg inferior_fp_registers; | |
42 | int i; | |
43 | ||
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); | |
53 | ||
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]); | |
58 | ||
59 | registers_fetched (); | |
60 | } | |
61 | ||
62 | void | |
63 | store_inferior_registers (regno) | |
64 | int regno; | |
65 | { | |
66 | struct reg inferior_registers; | |
67 | struct fpreg inferior_fp_registers; | |
68 | int i; | |
69 | ||
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); | |
77 | ||
78 | ptrace (PT_SETREGS, inferior_pid, | |
79 | (PTRACE_ARG3_TYPE) & inferior_registers, 0); | |
80 | ||
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); | |
85 | } | |
86 | ||
87 | struct md_core | |
88 | { | |
89 | struct reg intreg; | |
90 | struct fpreg freg; | |
91 | }; | |
92 | ||
93 | void | |
94 | fetch_core_registers (core_reg_sect, core_reg_size, which, ignore) | |
95 | char *core_reg_sect; | |
96 | unsigned core_reg_size; | |
97 | int which; | |
98 | CORE_ADDR ignore; | |
99 | { | |
100 | struct md_core *core_reg = (struct md_core *) core_reg_sect; | |
101 | int i; | |
102 | ||
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); | |
111 | ||
112 | /* Floating point registers */ | |
113 | for (i = 0; i < 32; i++) | |
114 | RF (FP0_REGNUM + i, core_reg->freg.r_regs[i]); | |
115 | ||
116 | registers_fetched (); | |
117 | } | |
118 | ||
119 | /* Register that we are able to handle ppcnbsd core file formats. | |
120 | FIXME: is this really bfd_target_unknown_flavour? */ | |
121 | ||
122 | static struct core_fns ppcnbsd_core_fns = | |
123 | { | |
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 */ | |
128 | NULL /* next */ | |
129 | }; | |
130 | ||
131 | void | |
132 | _initialize_ppcnbsd_nat () | |
133 | { | |
134 | add_core_fns (&ppcnbsd_core_fns); | |
135 | } |