]>
Commit | Line | Data |
---|---|---|
e42180d7 | 1 | /* Native-dependent code for PowerPC's running NetBSD, for GDB. |
b6ba6518 KB |
2 | Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001 |
3 | Free Software Foundation, Inc. | |
e42180d7 C |
4 | |
5 | This file is part of GDB. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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. */ | |
21 | ||
22 | #include <sys/types.h> | |
23 | #include <sys/ptrace.h> | |
24 | #include <machine/reg.h> | |
25 | #include <machine/frame.h> | |
26 | ||
27 | #include "defs.h" | |
28 | #include "inferior.h" | |
29 | #include "gdbcore.h" | |
ec3d358c | 30 | #include "ppc-tdep.h" |
4e052eda | 31 | #include "regcache.h" |
e42180d7 C |
32 | |
33 | #define RF(dst, src) \ | |
34 | memcpy(®isters[REGISTER_BYTE(dst)], &src, sizeof(src)) | |
35 | ||
36 | #define RS(src, dst) \ | |
37 | memcpy(&dst, ®isters[REGISTER_BYTE(src)], sizeof(dst)) | |
38 | ||
39 | void | |
fba45db2 | 40 | fetch_inferior_registers (int regno) |
e42180d7 C |
41 | { |
42 | struct reg inferior_registers; | |
ec3d358c | 43 | #ifdef PT_GETFPREGS |
e42180d7 | 44 | struct fpreg inferior_fp_registers; |
ec3d358c | 45 | #endif |
e42180d7 C |
46 | int i; |
47 | ||
39f77062 | 48 | ptrace (PT_GETREGS, PIDGET (inferior_ptid), |
e42180d7 C |
49 | (PTRACE_ARG3_TYPE) & inferior_registers, 0); |
50 | for (i = 0; i < 32; i++) | |
51 | RF (i, inferior_registers.fixreg[i]); | |
2188cbdd EZ |
52 | RF (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum, inferior_registers.lr); |
53 | RF (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum, inferior_registers.cr); | |
54 | RF (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum, inferior_registers.xer); | |
55 | RF (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum, inferior_registers.ctr); | |
e42180d7 C |
56 | RF (PC_REGNUM, inferior_registers.pc); |
57 | ||
ec3d358c | 58 | #ifdef PT_GETFPREGS |
39f77062 | 59 | ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), |
ec3d358c | 60 | (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); |
e42180d7 | 61 | for (i = 0; i < 32; i++) |
6d799331 | 62 | RF (FP0_REGNUM + i, inferior_fp_registers.fpreg[i]); |
ec3d358c | 63 | #endif |
e42180d7 C |
64 | |
65 | registers_fetched (); | |
66 | } | |
67 | ||
68 | void | |
fba45db2 | 69 | store_inferior_registers (int regno) |
e42180d7 C |
70 | { |
71 | struct reg inferior_registers; | |
ec3d358c | 72 | #ifdef PT_SETFPREGS |
e42180d7 | 73 | struct fpreg inferior_fp_registers; |
ec3d358c | 74 | #endif |
e42180d7 C |
75 | int i; |
76 | ||
77 | for (i = 0; i < 32; i++) | |
78 | RS (i, inferior_registers.fixreg[i]); | |
2188cbdd EZ |
79 | RS (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum, inferior_registers.lr); |
80 | RS (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum, inferior_registers.cr); | |
81 | RS (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum, inferior_registers.xer); | |
82 | RS (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum, inferior_registers.ctr); | |
e42180d7 C |
83 | RS (PC_REGNUM, inferior_registers.pc); |
84 | ||
39f77062 | 85 | ptrace (PT_SETREGS, PIDGET (inferior_ptid), |
e42180d7 C |
86 | (PTRACE_ARG3_TYPE) & inferior_registers, 0); |
87 | ||
ec3d358c | 88 | #ifdef PT_SETFPREGS |
e42180d7 | 89 | for (i = 0; i < 32; i++) |
6d799331 | 90 | RS (FP0_REGNUM + i, inferior_fp_registers.fpreg[i]); |
39f77062 | 91 | ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), |
e42180d7 | 92 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0); |
ec3d358c | 93 | #endif |
e42180d7 C |
94 | } |
95 | ||
96 | struct md_core | |
97 | { | |
98 | struct reg intreg; | |
ec3d358c | 99 | #ifdef PT_GETFPREGS |
e42180d7 | 100 | struct fpreg freg; |
ec3d358c | 101 | #endif |
e42180d7 C |
102 | }; |
103 | ||
104 | void | |
fba45db2 KB |
105 | fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, |
106 | CORE_ADDR ignore) | |
e42180d7 C |
107 | { |
108 | struct md_core *core_reg = (struct md_core *) core_reg_sect; | |
109 | int i; | |
110 | ||
111 | /* Integer registers */ | |
112 | for (i = 0; i < 32; i++) | |
113 | RF (i, core_reg->intreg.fixreg[i]); | |
2188cbdd EZ |
114 | RF (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum, core_reg->intreg.lr); |
115 | RF (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum, core_reg->intreg.cr); | |
116 | RF (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum, core_reg->intreg.xer); | |
117 | RF (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum, core_reg->intreg.ctr); | |
e42180d7 C |
118 | RF (PC_REGNUM, core_reg->intreg.pc); |
119 | ||
ec3d358c | 120 | #ifdef PT_FPGETREGS |
e42180d7 C |
121 | /* Floating point registers */ |
122 | for (i = 0; i < 32; i++) | |
6d799331 | 123 | RF (FP0_REGNUM + i, core_reg->freg.fpreg[i]); |
ec3d358c | 124 | #endif |
e42180d7 C |
125 | |
126 | registers_fetched (); | |
127 | } | |
128 | ||
129 | /* Register that we are able to handle ppcnbsd core file formats. | |
130 | FIXME: is this really bfd_target_unknown_flavour? */ | |
131 | ||
132 | static struct core_fns ppcnbsd_core_fns = | |
133 | { | |
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 */ | |
138 | NULL /* next */ | |
139 | }; | |
140 | ||
141 | void | |
fba45db2 | 142 | _initialize_ppcnbsd_nat (void) |
e42180d7 C |
143 | { |
144 | add_core_fns (&ppcnbsd_core_fns); | |
145 | } |