Module Name: src
Committed By: thorpej
Date: Tue Nov 21 21:23:56 UTC 2023
Modified Files:
src/sys/arch/alpha/alpha: db_interface.c db_trace.c
src/sys/arch/alpha/include: db_machdep.h
Log Message:
Adjust proc/lwp access for user-space (crash(8)).
To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/alpha/alpha/db_interface.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/alpha/alpha/db_trace.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/include/db_machdep.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/alpha/alpha/db_interface.c
diff -u src/sys/arch/alpha/alpha/db_interface.c:1.38 src/sys/arch/alpha/alpha/db_interface.c:1.39
--- src/sys/arch/alpha/alpha/db_interface.c:1.38 Tue Nov 21 19:59:07 2023
+++ src/sys/arch/alpha/alpha/db_interface.c Tue Nov 21 21:23:56 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.38 2023/11/21 19:59:07 thorpej Exp $ */
+/* $NetBSD: db_interface.c,v 1.39 2023/11/21 21:23:56 thorpej Exp $ */
/*
* Mach Operating System
@@ -54,7 +54,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.38 2023/11/21 19:59:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.39 2023/11/21 21:23:56 thorpej Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -569,6 +569,21 @@ db_branch_taken(int ins, db_addr_t pc, d
return (newpc);
}
+unsigned long
+db_alpha_read_saved_reg(unsigned long *regp)
+{
+ unsigned long reg;
+
+ db_read_bytes((db_addr_t)regp, sizeof(reg), (char *)®);
+ return reg;
+}
+
+unsigned long
+db_alpha_tf_reg(struct trapframe *tf, unsigned int regno)
+{
+ return db_alpha_read_saved_reg(&tf->tf_regs[regno]);
+}
+
/*
* Alpha special symbol handling.
*/
Index: src/sys/arch/alpha/alpha/db_trace.c
diff -u src/sys/arch/alpha/alpha/db_trace.c:1.37 src/sys/arch/alpha/alpha/db_trace.c:1.38
--- src/sys/arch/alpha/alpha/db_trace.c:1.37 Tue Nov 21 20:40:24 2023
+++ src/sys/arch/alpha/alpha/db_trace.c Tue Nov 21 21:23:56 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: db_trace.c,v 1.37 2023/11/21 20:40:24 thorpej Exp $ */
+/* $NetBSD: db_trace.c,v 1.38 2023/11/21 21:23:56 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.37 2023/11/21 20:40:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.38 2023/11/21 21:23:56 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -138,16 +138,6 @@ decode_syscall(int number, void (*pr)(co
(*pr)(" (%d)", number);
}
-static unsigned long
-db_alpha_tf_reg(struct trapframe *tf, unsigned int regno)
-{
- unsigned long reg;
-
- db_read_bytes((db_addr_t)&tf->tf_regs[regno], sizeof(reg),
- (char *)®);
- return reg;
-}
-
void
db_stack_trace_print(db_expr_t addr, bool have_addr, db_expr_t count,
const char *modif, void (*pr)(const char *, ...))
@@ -191,15 +181,27 @@ db_stack_trace_print_ra(db_expr_t ra, bo
frame = (db_addr_t)tf + FRAME_SIZE * 8;
ra_from_tf = true;
} else {
+#ifdef _KERNEL
struct proc *p = NULL;
struct lwp *l = NULL;
+#else
+ struct proc pstore, *p = &pstore;
+ struct lwp lstore, *l = &lstore;
+#endif /* _KERNEL */
if (trace_thread) {
if (lwpaddr) {
+#ifdef _KERNEL
l = (struct lwp *)addr;
p = l->l_proc;
+#else
+ db_read_bytes(addr, sizeof(*l), (char *)l);
+ db_read_bytes((db_addr_t)l->l_proc,
+ sizeof(*p), (char *)p);
+#endif /* _KERNEL */
(*pr)("trace: pid %d ", p->p_pid);
} else {
+#ifdef _KERNEL
(*pr)("trace: pid %d ", (int)addr);
p = proc_find_raw(addr);
if (p == NULL) {
@@ -208,11 +210,15 @@ db_stack_trace_print_ra(db_expr_t ra, bo
}
l = LIST_FIRST(&p->p_lwps);
KASSERT(l != NULL);
+#else
+ (*pr)("no proc_find_raw() in crash\n");
+ return;
+#endif /* _KERNEL */
}
(*pr)("lid %d ", l->l_lid);
pcbp = lwp_getpcb(l);
- addr = (db_expr_t)pcbp->pcb_hw.apcb_ksp;
- callpc = pcbp->pcb_context[7];
+ addr = db_alpha_read_saved_reg(&pcbp->pcb_hw.apcb_ksp);
+ callpc = db_alpha_read_saved_reg(&pcbp->pcb_context[7]);
(*pr)("at 0x%lx\n", addr);
} else if (have_ra) {
callpc = ra;
Index: src/sys/arch/alpha/include/db_machdep.h
diff -u src/sys/arch/alpha/include/db_machdep.h:1.21 src/sys/arch/alpha/include/db_machdep.h:1.22
--- src/sys/arch/alpha/include/db_machdep.h:1.21 Tue Nov 21 19:59:07 2023
+++ src/sys/arch/alpha/include/db_machdep.h Tue Nov 21 21:23:56 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.21 2023/11/21 19:59:07 thorpej Exp $ */
+/* $NetBSD: db_machdep.h,v 1.22 2023/11/21 21:23:56 thorpej Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
@@ -211,6 +211,9 @@ bool db_alpha_sym_is_backstop(db_addr_t
bool db_alpha_sym_is_syscall(db_addr_t);
const char * db_alpha_trapsym_description(db_addr_t);
+unsigned long db_alpha_read_saved_reg(unsigned long *);
+unsigned long db_alpha_tf_reg(struct trapframe *, unsigned int);
+
/*
* Extra ddb options.
*/