Fri Jan 7 02:56:44 2011 UTC ()
Deal with the new trapframe


(matt)
diff -r1.2 -r1.2.28.1 src/gnu/dist/gdb6/gdb/ppcnbsd-nat.c

cvs diff -r1.2 -r1.2.28.1 src/gnu/dist/gdb6/gdb/Attic/ppcnbsd-nat.c (switch to unified diff)

--- src/gnu/dist/gdb6/gdb/Attic/ppcnbsd-nat.c 2006/12/06 18:25:29 1.2
+++ src/gnu/dist/gdb6/gdb/Attic/ppcnbsd-nat.c 2011/01/07 02:56:44 1.2.28.1
@@ -1,195 +1,195 @@ @@ -1,195 +1,195 @@
1/* Native-dependent code for NetBSD/powerpc. 1/* Native-dependent code for NetBSD/powerpc.
2 2
3 Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
4 4
5 Contributed by Wasabi Systems, Inc. 5 Contributed by Wasabi Systems, Inc.
6 6
7 This file is part of GDB. 7 This file is part of GDB.
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or 11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version. 12 (at your option) any later version.
13 13
14 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 17 GNU General Public License for more details.
18 18
19 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */ 22 Boston, MA 02110-1301, USA. */
23 23
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/ptrace.h> 25#include <sys/ptrace.h>
26#include <machine/reg.h> 26#include <machine/reg.h>
27#include <machine/frame.h> 27#include <machine/frame.h>
28#include <machine/pcb.h> 28#include <machine/pcb.h>
29 29
30#include "defs.h" 30#include "defs.h"
31#include "gdbcore.h" 31#include "gdbcore.h"
32#include "inferior.h" 32#include "inferior.h"
33#include "regcache.h" 33#include "regcache.h"
34 34
35#include "gdb_assert.h" 35#include "gdb_assert.h"
36 36
37#include "nbsd-nat.h" 37#include "nbsd-nat.h"
38#include "ppc-tdep.h" 38#include "ppc-tdep.h"
39#include "ppcnbsd-tdep.h" 39#include "ppcnbsd-tdep.h"
40#include "bsd-kvm.h" 40#include "bsd-kvm.h"
41#include "inf-ptrace.h" 41#include "inf-ptrace.h"
42 42
43/* Returns true if PT_GETREGS fetches this register. */ 43/* Returns true if PT_GETREGS fetches this register. */
44 44
45static int 45static int
46getregs_supplies (int regnum) 46getregs_supplies (int regnum)
47{ 47{
48 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 48 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
49 49
50 return ((regnum >= tdep->ppc_gp0_regnum 50 return ((regnum >= tdep->ppc_gp0_regnum
51 && regnum < tdep->ppc_gp0_regnum + ppc_num_gprs) 51 && regnum < tdep->ppc_gp0_regnum + ppc_num_gprs)
52 || regnum == tdep->ppc_lr_regnum 52 || regnum == tdep->ppc_lr_regnum
53 || regnum == tdep->ppc_cr_regnum 53 || regnum == tdep->ppc_cr_regnum
54 || regnum == tdep->ppc_xer_regnum 54 || regnum == tdep->ppc_xer_regnum
55 || regnum == tdep->ppc_ctr_regnum 55 || regnum == tdep->ppc_ctr_regnum
56 || regnum == PC_REGNUM); 56 || regnum == PC_REGNUM);
57} 57}
58 58
59/* Like above, but for PT_GETFPREGS. */ 59/* Like above, but for PT_GETFPREGS. */
60 60
61static int 61static int
62getfpregs_supplies (int regnum) 62getfpregs_supplies (int regnum)
63{ 63{
64 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 64 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
65 65
66 /* FIXME: jimb/2004-05-05: Some PPC variants don't have floating 66 /* FIXME: jimb/2004-05-05: Some PPC variants don't have floating
67 point registers. Traditionally, GDB's register set has still 67 point registers. Traditionally, GDB's register set has still
68 listed the floating point registers for such machines, so this 68 listed the floating point registers for such machines, so this
69 code is harmless. However, the new E500 port actually omits the 69 code is harmless. However, the new E500 port actually omits the
70 floating point registers entirely from the register set --- they 70 floating point registers entirely from the register set --- they
71 don't even have register numbers assigned to them. 71 don't even have register numbers assigned to them.
72 72
73 It's not clear to me how best to update this code, so this assert 73 It's not clear to me how best to update this code, so this assert
74 will alert the first person to encounter the NetBSD/E500 74 will alert the first person to encounter the NetBSD/E500
75 combination to the problem. */ 75 combination to the problem. */
76 gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); 76 gdb_assert (ppc_floating_point_unit_p (current_gdbarch));
77 77
78 return ((regnum >= tdep->ppc_fp0_regnum 78 return ((regnum >= tdep->ppc_fp0_regnum
79 && regnum < tdep->ppc_fp0_regnum + ppc_num_fprs) 79 && regnum < tdep->ppc_fp0_regnum + ppc_num_fprs)
80 || regnum == tdep->ppc_fpscr_regnum); 80 || regnum == tdep->ppc_fpscr_regnum);
81} 81}
82 82
83static void 83static void
84ppcnbsd_fetch_inferior_registers (int regnum) 84ppcnbsd_fetch_inferior_registers (int regnum)
85{ 85{
86 if (regnum == -1 || getregs_supplies (regnum)) 86 if (regnum == -1 || getregs_supplies (regnum))
87 { 87 {
88 struct reg regs; 88 struct reg regs;
89 89
90 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), 90 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
91 (PTRACE_TYPE_ARG3) &regs, 0) == -1) 91 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
92 perror_with_name (_("Couldn't get registers")); 92 perror_with_name (_("Couldn't get registers"));
93 93
94 ppc_supply_gregset (&ppcnbsd_gregset, current_regcache, 94 ppc_supply_gregset (&ppcnbsd_gregset, current_regcache,
95 regnum, &regs, sizeof regs); 95 regnum, &regs, sizeof regs);
96 } 96 }
97 97
98 if (regnum == -1 || getfpregs_supplies (regnum)) 98 if (regnum == -1 || getfpregs_supplies (regnum))
99 { 99 {
100 struct fpreg fpregs; 100 struct fpreg fpregs;
101 101
102 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), 102 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
103 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 103 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
104 perror_with_name (_("Couldn't get FP registers")); 104 perror_with_name (_("Couldn't get FP registers"));
105 105
106 ppc_supply_fpregset (&ppcnbsd_fpregset, current_regcache, 106 ppc_supply_fpregset (&ppcnbsd_fpregset, current_regcache,
107 regnum, &fpregs, sizeof fpregs); 107 regnum, &fpregs, sizeof fpregs);
108 } 108 }
109} 109}
110 110
111static void 111static void
112ppcnbsd_store_inferior_registers (int regnum) 112ppcnbsd_store_inferior_registers (int regnum)
113{ 113{
114 if (regnum == -1 || getregs_supplies (regnum)) 114 if (regnum == -1 || getregs_supplies (regnum))
115 { 115 {
116 struct reg regs; 116 struct reg regs;
117 117
118 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), 118 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
119 (PTRACE_TYPE_ARG3) &regs, 0) == -1) 119 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
120 perror_with_name (_("Couldn't get registers")); 120 perror_with_name (_("Couldn't get registers"));
121 121
122 ppc_collect_gregset (&ppcnbsd_gregset, current_regcache, 122 ppc_collect_gregset (&ppcnbsd_gregset, current_regcache,
123 regnum, &regs, sizeof regs); 123 regnum, &regs, sizeof regs);
124 124
125 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), 125 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
126 (PTRACE_TYPE_ARG3) &regs, 0) == -1) 126 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
127 perror_with_name (_("Couldn't write registers")); 127 perror_with_name (_("Couldn't write registers"));
128 } 128 }
129 129
130 if (regnum == -1 || getfpregs_supplies (regnum)) 130 if (regnum == -1 || getfpregs_supplies (regnum))
131 { 131 {
132 struct fpreg fpregs; 132 struct fpreg fpregs;
133 133
134 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), 134 if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
135 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 135 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
136 perror_with_name (_("Couldn't get FP registers")); 136 perror_with_name (_("Couldn't get FP registers"));
137 137
138 ppc_collect_fpregset (&ppcnbsd_fpregset, current_regcache, 138 ppc_collect_fpregset (&ppcnbsd_fpregset, current_regcache,
139 regnum, &fpregs, sizeof fpregs); 139 regnum, &fpregs, sizeof fpregs);
140 140
141 if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), 141 if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
142 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 142 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
143 perror_with_name (_("Couldn't set FP registers")); 143 perror_with_name (_("Couldn't set FP registers"));
144 } 144 }
145} 145}
146 146
147static int 147static int
148ppcnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) 148ppcnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
149{ 149{
150 struct switchframe sf; 150 struct switchframe sf;
151 struct callframe cf; 151 struct callframe cf;
152 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 152 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
153 int i; 153 int i;
154 154
155 /* The stack pointer shouldn't be zero. */ 155 /* The stack pointer shouldn't be zero. */
156 if (pcb->pcb_sp == 0) 156 if (pcb->pcb_sp == 0)
157 return 0; 157 return 0;
158 158
159 read_memory (pcb->pcb_sp, (gdb_byte *)&sf, sizeof sf); 159 read_memory (pcb->pcb_sp, (gdb_byte *)&sf, sizeof sf);
160 regcache_raw_supply (regcache, tdep->ppc_cr_regnum, &sf.cr); 160 regcache_raw_supply (regcache, tdep->ppc_cr_regnum, &sf.sf_cr);
161 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 2, &sf.fixreg2); 161 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 2, &sf.sf_fixreg2);
162 for (i = 0 ; i < 19 ; i++) 162 for (i = 0 ; i < 19 ; i++)
163 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 13 + i, 163 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 13 + i,
164 &sf.fixreg[i]); 164 &sf.sf_fixreg[i]);
165 165
166 read_memory(sf.sp, (gdb_byte *)&cf, sizeof(cf)); 166 read_memory(sf.sf_sp, (gdb_byte *)&cf, sizeof(cf));
167 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 30, &cf.r30); 167 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 30, &cf.cf_r30);
168 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 31, &cf.r31); 168 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 31, &cf.cf_r31);
169 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 1, &cf.sp); 169 regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 1, &cf.cf_sp);
170 170
171 read_memory(cf.sp, (gdb_byte *)&cf, sizeof(cf)); 171 read_memory(cf.cf_sp, (gdb_byte *)&cf, sizeof(cf));
172 regcache_raw_supply (regcache, tdep->ppc_lr_regnum, &cf.lr); 172 regcache_raw_supply (regcache, tdep->ppc_lr_regnum, &cf.cf_lr);
173 regcache_raw_supply (regcache, PC_REGNUM, &cf.lr); 173 regcache_raw_supply (regcache, PC_REGNUM, &cf.cf_lr);
174 174
175 return 1; 175 return 1;
176} 176}
177 177
178/* Provide a prototype to silence -Wmissing-prototypes. */ 178/* Provide a prototype to silence -Wmissing-prototypes. */
179void _initialize_ppcnbsd_nat (void); 179void _initialize_ppcnbsd_nat (void);
180 180
181void 181void
182_initialize_ppcnbsd_nat (void) 182_initialize_ppcnbsd_nat (void)
183{ 183{
184 struct target_ops *t; 184 struct target_ops *t;
185 185
186 /* Support debugging kernel virtual memory images. */ 186 /* Support debugging kernel virtual memory images. */
187 bsd_kvm_add_target (ppcnbsd_supply_pcb); 187 bsd_kvm_add_target (ppcnbsd_supply_pcb);
188 188
189 /* Add in local overrides. */ 189 /* Add in local overrides. */
190 t = inf_ptrace_target (); 190 t = inf_ptrace_target ();
191 t->to_fetch_registers = ppcnbsd_fetch_inferior_registers; 191 t->to_fetch_registers = ppcnbsd_fetch_inferior_registers;
192 t->to_store_registers = ppcnbsd_store_inferior_registers; 192 t->to_store_registers = ppcnbsd_store_inferior_registers;
193 t->to_pid_to_exec_file = nbsd_pid_to_exec_file; 193 t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
194 add_target (t); 194 add_target (t);
195} 195}