summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2020-01-20 15:58:24 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2020-01-20 15:58:24 +0000
commit8dedb348f34b6ea68a8e7b1e905784762677b359 (patch)
treebe188db04b4562a8245c9d11553406df9fced9f5 /sys/arch
parent562bc692fe4670bfd2a4b5ec728fb5f5f41bbc00 (diff)
Separate the stack trace saving interface from ddb. The saving does not
require the debugger on most architectures, and the separation makes the code easier to use from other subsystems. The function definitions are still conditional to DDB. However, that should not matter for now. OK deraadt@, mpi@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/db_trace.c7
-rw-r--r--sys/arch/arm64/arm64/db_trace.c7
-rw-r--r--sys/arch/hppa/hppa/db_interface.c7
-rw-r--r--sys/arch/i386/i386/db_trace.c7
-rw-r--r--sys/arch/mips64/mips64/trap.c7
-rw-r--r--sys/arch/sparc64/sparc64/db_trace.c7
6 files changed, 24 insertions, 18 deletions
diff --git a/sys/arch/amd64/amd64/db_trace.c b/sys/arch/amd64/amd64/db_trace.c
index e5195c9e3a7..c4169b44374 100644
--- a/sys/arch/amd64/amd64/db_trace.c
+++ b/sys/arch/amd64/amd64/db_trace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_trace.c,v 1.48 2020/01/09 15:18:58 bluhm Exp $ */
+/* $OpenBSD: db_trace.c,v 1.49 2020/01/20 15:58:23 visa Exp $ */
/* $NetBSD: db_trace.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */
/*
@@ -30,6 +30,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
+#include <sys/stacktrace.h>
#include <sys/user.h>
#include <machine/db_machdep.h>
@@ -255,13 +256,13 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
}
void
-db_save_stack_trace(struct db_stack_trace *st)
+stacktrace_save(struct stacktrace *st)
{
struct callframe *frame, *lastframe;
frame = __builtin_frame_address(0);
st->st_count = 0;
- while (st->st_count < DB_STACK_TRACE_MAX) {
+ while (st->st_count < STACKTRACE_MAX) {
st->st_pc[st->st_count++] = frame->f_retaddr;
lastframe = frame;
diff --git a/sys/arch/arm64/arm64/db_trace.c b/sys/arch/arm64/arm64/db_trace.c
index 113f79e3217..46c49fcfa52 100644
--- a/sys/arch/arm64/arm64/db_trace.c
+++ b/sys/arch/arm64/arm64/db_trace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_trace.c,v 1.8 2019/11/07 14:44:52 mpi Exp $ */
+/* $OpenBSD: db_trace.c,v 1.9 2020/01/20 15:58:23 visa Exp $ */
/* $NetBSD: db_trace.c,v 1.8 2003/01/17 22:28:48 thorpej Exp $ */
/*
@@ -33,6 +33,7 @@
#include <sys/param.h>
#include <sys/proc.h>
+#include <sys/stacktrace.h>
#include <sys/user.h>
#include <arm64/armreg.h>
#include <machine/db_machdep.h>
@@ -149,13 +150,13 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
}
void
-db_save_stack_trace(struct db_stack_trace *st)
+stacktrace_save(struct stacktrace *st)
{
struct callframe *frame;
frame = __builtin_frame_address(0);
st->st_count = 0;
- while (st->st_count < DB_STACK_TRACE_MAX) {
+ while (st->st_count < STACKTRACE_MAX) {
st->st_pc[st->st_count++] = frame->f_lr;
if (!INKERNEL(frame->f_frame) || frame->f_frame <= frame)
diff --git a/sys/arch/hppa/hppa/db_interface.c b/sys/arch/hppa/hppa/db_interface.c
index 7afa81ed858..53449e93713 100644
--- a/sys/arch/hppa/hppa/db_interface.c
+++ b/sys/arch/hppa/hppa/db_interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_interface.c,v 1.46 2019/11/10 10:03:33 mpi Exp $ */
+/* $OpenBSD: db_interface.c,v 1.47 2020/01/20 15:58:23 visa Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -30,6 +30,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/stacktrace.h>
#include <machine/db_machdep.h>
#include <machine/frame.h>
@@ -315,7 +316,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
}
void
-db_save_stack_trace(struct db_stack_trace *st)
+stacktrace_save(struct stacktrace *st)
{
register_t *fp, pc, rp;
int i;
@@ -325,7 +326,7 @@ db_save_stack_trace(struct db_stack_trace *st)
rp = fp[-5];
st->st_count = 0;
- for (i = 0; i < DB_STACK_TRACE_MAX; i++) {
+ for (i = 0; i < STACKTRACE_MAX; i++) {
st->st_pc[st->st_count++] = rp;
/* next frame */
diff --git a/sys/arch/i386/i386/db_trace.c b/sys/arch/i386/i386/db_trace.c
index 603a3071462..5078722d255 100644
--- a/sys/arch/i386/i386/db_trace.c
+++ b/sys/arch/i386/i386/db_trace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_trace.c,v 1.37 2019/11/07 14:44:53 mpi Exp $ */
+/* $OpenBSD: db_trace.c,v 1.38 2020/01/20 15:58:23 visa Exp $ */
/* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */
/*
@@ -30,6 +30,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
+#include <sys/stacktrace.h>
#include <sys/user.h>
#include <machine/db_machdep.h>
@@ -260,13 +261,13 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
}
void
-db_save_stack_trace(struct db_stack_trace *st)
+stacktrace_save(struct stacktrace *st)
{
struct callframe *frame, *lastframe;
frame = __builtin_frame_address(0);
st->st_count = 0;
- while (st->st_count < DB_STACK_TRACE_MAX) {
+ while (st->st_count < STACKTRACE_MAX) {
st->st_pc[st->st_count++] = frame->f_retaddr;
lastframe = frame;
diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c
index e2d59a34c4f..371fba749d4 100644
--- a/sys/arch/mips64/mips64/trap.c
+++ b/sys/arch/mips64/mips64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.142 2019/09/06 16:22:40 visa Exp $ */
+/* $OpenBSD: trap.c,v 1.143 2020/01/20 15:58:23 visa Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -50,6 +50,7 @@
#include <sys/kernel.h>
#include <sys/signalvar.h>
#include <sys/user.h>
+#include <sys/stacktrace.h>
#include <sys/syscall.h>
#include <sys/syscall_mi.h>
#include <sys/buf.h>
@@ -1476,7 +1477,7 @@ end:
#ifdef DDB
void
-db_save_stack_trace(struct db_stack_trace *st)
+stacktrace_save(struct stacktrace *st)
{
extern char k_general[];
extern char u_general[];
@@ -1498,7 +1499,7 @@ db_save_stack_trace(struct db_stack_trace *st)
sp = (vaddr_t)__builtin_frame_address(0);
st->st_count = 0;
- while (st->st_count < DB_STACK_TRACE_MAX && pc != 0) {
+ while (st->st_count < STACKTRACE_MAX && pc != 0) {
if (!VALID_ADDRESS(pc) || !VALID_ADDRESS(sp))
break;
diff --git a/sys/arch/sparc64/sparc64/db_trace.c b/sys/arch/sparc64/sparc64/db_trace.c
index 1181c7bb2bf..376b9392c2e 100644
--- a/sys/arch/sparc64/sparc64/db_trace.c
+++ b/sys/arch/sparc64/sparc64/db_trace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_trace.c,v 1.19 2019/11/07 14:44:53 mpi Exp $ */
+/* $OpenBSD: db_trace.c,v 1.20 2020/01/20 15:58:23 visa Exp $ */
/* $NetBSD: db_trace.c,v 1.23 2001/07/10 06:06:16 eeh Exp $ */
/*
@@ -30,6 +30,7 @@
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/systm.h>
+#include <sys/stacktrace.h>
#include <sys/user.h>
#include <machine/db_machdep.h>
#include <machine/ctlreg.h>
@@ -154,7 +155,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
}
void
-db_save_stack_trace(struct db_stack_trace *st)
+stacktrace_save(struct stacktrace *st)
{
struct frame64 *f64;
vaddr_t pc;
@@ -167,7 +168,7 @@ db_save_stack_trace(struct db_stack_trace *st)
return;
st->st_count = 0;
- while (st->st_count < DB_STACK_TRACE_MAX) {
+ while (st->st_count < STACKTRACE_MAX) {
f64 = (struct frame64 *)(frame + BIAS);
pc = (vaddr_t)KLOAD(f64->fr_pc);