Thu Apr 13 06:39:23 2023 UTC ()
powerpc/ddb: Fix one more load to use db_read_bytes.

Fix some typos in crash(8) comments too.

XXX pullup-8
XXX pullup-9
XXX pullup-10


(riastradh)
diff -r1.62 -r1.63 src/sys/arch/powerpc/powerpc/db_trace.c

cvs diff -r1.62 -r1.63 src/sys/arch/powerpc/powerpc/db_trace.c (expand / switch to unified diff)

--- src/sys/arch/powerpc/powerpc/db_trace.c 2023/04/12 19:47:41 1.62
+++ src/sys/arch/powerpc/powerpc/db_trace.c 2023/04/13 06:39:23 1.63
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db_trace.c,v 1.62 2023/04/12 19:47:41 riastradh Exp $ */ 1/* $NetBSD: db_trace.c,v 1.63 2023/04/13 06:39:23 riastradh Exp $ */
2/* $OpenBSD: db_trace.c,v 1.3 1997/03/21 02:10:48 niklas Exp $ */ 2/* $OpenBSD: db_trace.c,v 1.3 1997/03/21 02:10:48 niklas Exp $ */
3 3
4/* 4/*
5 * Mach Operating System 5 * Mach Operating System
6 * Copyright (c) 1992 Carnegie Mellon University 6 * Copyright (c) 1992 Carnegie Mellon University
7 * All Rights Reserved. 7 * All Rights Reserved.
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and its 9 * Permission to use, copy, modify and distribute this software and its
10 * documentation is hereby granted, provided that both the copyright 10 * documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * 18 *
19 * Carnegie Mellon requests users of this software to return to 19 * Carnegie Mellon requests users of this software to return to
20 * 20 *
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science 22 * School of Computer Science
23 * Carnegie Mellon University 23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890 24 * Pittsburgh PA 15213-3890
25 * 25 *
26 * any improvements or extensions that they make and grant Carnegie Mellon 26 * any improvements or extensions that they make and grant Carnegie Mellon
27 * the rights to redistribute these changes. 27 * the rights to redistribute these changes.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.62 2023/04/12 19:47:41 riastradh Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.63 2023/04/13 06:39:23 riastradh Exp $");
32 32
33#ifdef _KERNEL_OPT 33#ifdef _KERNEL_OPT
34#include "opt_ppcarch.h" 34#include "opt_ppcarch.h"
35#endif 35#endif
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/proc.h> 38#include <sys/proc.h>
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40 40
41#include <uvm/uvm_extern.h> 41#include <uvm/uvm_extern.h>
42 42
43#include <machine/db_machdep.h> 43#include <machine/db_machdep.h>
44#include <machine/pmap.h> 44#include <machine/pmap.h>
@@ -178,76 +178,76 @@ db_stack_trace_print(db_expr_t addr, boo @@ -178,76 +178,76 @@ db_stack_trace_print(db_expr_t addr, boo
178 (*pr)("trace: pid %d ", (int)addr); 178 (*pr)("trace: pid %d ", (int)addr);
179 p = db_proc_find((pid_t)addr); 179 p = db_proc_find((pid_t)addr);
180 if (p == NULL) { 180 if (p == NULL) {
181 (*pr)("not found\n"); 181 (*pr)("not found\n");
182 return; 182 return;
183 } 183 }
184 l = R(&LIST_FIRST(&p->p_lwps)); 184 l = R(&LIST_FIRST(&p->p_lwps));
185 if (l == NULL) { 185 if (l == NULL) {
186 (*pr)("trace: no LWP?\n"); 186 (*pr)("trace: no LWP?\n");
187 return; 187 return;
188 } 188 }
189 } 189 }
190 (*pr)("lid %d ", R(&l->l_lid)); 190 (*pr)("lid %d ", R(&l->l_lid));
191 pcb = lwp_getpcb(l); 191 pcb = R(&l->l_addr); /* lwp_getpcb */
192 frame = (db_addr_t)R(&pcb->pcb_sp); 192 frame = (db_addr_t)R(&pcb->pcb_sp);
193 (*pr)("at %p\n", frame); 193 (*pr)("at %p\n", frame);
194 } else 194 } else
195 frame = (db_addr_t)addr; 195 frame = (db_addr_t)addr;
196 } else { 196 } else {
197 frame = (db_addr_t)ddb_regs.r[1]; 197 frame = (db_addr_t)ddb_regs.r[1];
198 } 198 }
199 for (;;) { 199 for (;;) {
200 if (frame < PAGE_SIZE) 200 if (frame < PAGE_SIZE)
201 break; 201 break;
202 frame = R((db_addr_t *)frame); 202 frame = R((db_addr_t *)frame);
203 next_frame: 203 next_frame:
204 args = (db_addr_t *)(frame + 8); 204 args = (db_addr_t *)(frame + 8);
205 if (frame < PAGE_SIZE) 205 if (frame < PAGE_SIZE)
206 break; 206 break;
207 if (count-- == 0) 207 if (count-- == 0)
208 break; 208 break;
209 209
210 lr = R((db_addr_t *)(frame + 4)) - 4; 210 lr = R((db_addr_t *)(frame + 4)) - 4;
211 if ((lr & 3) || (lr < 0x100)) { 211 if ((lr & 3) || (lr < 0x100)) {
212 (*pr)("saved LR(0x%x) is invalid.", lr); 212 (*pr)("saved LR(0x%x) is invalid.", lr);
213 break; 213 break;
214 } 214 }
215 215
216 (*pr)("0x%08lx: ", frame); 216 (*pr)("0x%08lx: ", frame);
217 if (lr + 4 == (db_addr_t) trapexit || 217 if (lr + 4 == (db_addr_t) trapexit ||
218#if !defined(_KERNEL) || defined(PPC_BOOKE) /* XXX crash(*) */ 218#if !defined(_KERNEL) || defined(PPC_BOOKE) /* XXX crash(8) */
219 lr + 4 == (db_addr_t) intrcall || 219 lr + 4 == (db_addr_t) intrcall ||
220#endif 220#endif
221 lr + 4 == (db_addr_t) sctrapexit) { 221 lr + 4 == (db_addr_t) sctrapexit) {
222 const char *trapstr; 222 const char *trapstr;
223 struct trapframe *tf = 223 struct trapframe *tf =
224 &((struct ktrapframe *)frame)->ktf_tf; 224 &((struct ktrapframe *)frame)->ktf_tf;
225 (*pr)("%s ", 225 (*pr)("%s ",
226 R(&tf->tf_srr1) & PSL_PR ? "user" : "kernel"); 226 R(&tf->tf_srr1) & PSL_PR ? "user" : "kernel");
227 if (lr + 4 == (db_addr_t) sctrapexit) { 227 if (lr + 4 == (db_addr_t) sctrapexit) {
228 (*pr)("SC trap #%d by ", R(&tf->tf_fixreg[0])); 228 (*pr)("SC trap #%d by ", R(&tf->tf_fixreg[0]));
229 goto print_trap; 229 goto print_trap;
230 } 230 }
231 switch (R(&tf->tf_exc)) { 231 switch (R(&tf->tf_exc)) {
232 case EXC_DSI: 232 case EXC_DSI:
233#ifdef PPC_OEA /* XXX crash(*) */ 233#ifdef PPC_OEA /* XXX crash(8) */
234 (*pr)("DSI %s trap @ %#x by ", 234 (*pr)("DSI %s trap @ %#x by ",
235 (R(&tf->tf_dsisr) & DSISR_STORE 235 (R(&tf->tf_dsisr) & DSISR_STORE
236 ? "write" 236 ? "write"
237 : "read"), 237 : "read"),
238 R(&tf->tf_dar)); 238 R(&tf->tf_dar));
239#endif 239#endif
240#ifdef PPC_IBM4XX /* XXX crash(*) */ 240#ifdef PPC_IBM4XX /* XXX crash(8) */
241 trapstr = "DSI"; 241 trapstr = "DSI";
242dsi: 242dsi:
243 (*pr)("%s %s trap @ %#x by ", trapstr, 243 (*pr)("%s %s trap @ %#x by ", trapstr,
244 (R(&tf->tf_esr) & ESR_DST 244 (R(&tf->tf_esr) & ESR_DST
245 ? "write" 245 ? "write"
246 : "read"), 246 : "read"),
247 R(&tf->tf_dear)); 247 R(&tf->tf_dear));
248#endif 248#endif
249 goto print_trap; 249 goto print_trap;
250 case EXC_ALI: 250 case EXC_ALI:
251#ifdef PPC_OEA /* XXX crash(8) */ 251#ifdef PPC_OEA /* XXX crash(8) */
252 (*pr)("ALI trap @ %#x (DSISR %#x) ", 252 (*pr)("ALI trap @ %#x (DSISR %#x) ",
253 R(&tf->tf_dar), R(&tf->tf_dsisr)); 253 R(&tf->tf_dar), R(&tf->tf_dsisr));