diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2020-04-18 04:45:21 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2020-04-18 04:45:21 +0000 |
commit | 5a605a79f4c28e5941a2d7ddae133f41be01943b (patch) | |
tree | 29dae8806a28879901fbcd50c1f3535ed6a8f24d /sys/arch | |
parent | 65e97594bd9ffe2fd77966373c16eb0015a4f2ae (diff) |
Sync existing stacktrace_save() implementations
Upgrade stacktrace_save() to stacktrace_save_at() on architectures where
the latter is missing. Define stacktrace_save() as an inline function
in header <sys/stacktrace.h> to reduce duplication of code.
OK mpi@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/db_trace.c | 8 | ||||
-rw-r--r-- | sys/arch/arm64/arm64/db_trace.c | 9 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/db_interface.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/i386/db_trace.c | 8 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/trap.c | 12 | ||||
-rw-r--r-- | sys/arch/powerpc/ddb/db_trace.c | 8 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/db_trace.c | 8 |
7 files changed, 24 insertions, 38 deletions
diff --git a/sys/arch/amd64/amd64/db_trace.c b/sys/arch/amd64/amd64/db_trace.c index c26c386cb4b..34000b9fd3a 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.51 2020/03/29 15:14:28 visa Exp $ */ +/* $OpenBSD: db_trace.c,v 1.52 2020/04/18 04:45:20 visa Exp $ */ /* $NetBSD: db_trace.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */ /* @@ -288,12 +288,6 @@ stacktrace_save_at(struct stacktrace *st, unsigned int skip) } } -void -stacktrace_save(struct stacktrace *st) -{ - return stacktrace_save_at(st, 0); -} - vaddr_t db_get_pc(struct trapframe *tf) { diff --git a/sys/arch/arm64/arm64/db_trace.c b/sys/arch/arm64/arm64/db_trace.c index 8ea1b463e56..a23e4f11d9b 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.10 2020/03/29 15:14:28 visa Exp $ */ +/* $OpenBSD: db_trace.c,v 1.11 2020/04/18 04:45:20 visa Exp $ */ /* $NetBSD: db_trace.c,v 1.8 2003/01/17 22:28:48 thorpej Exp $ */ /* @@ -150,7 +150,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, } void -stacktrace_save(struct stacktrace *st) +stacktrace_save_at(struct stacktrace *st, unsigned int skip) { struct callframe *frame, *lastframe, *limit; struct proc *p = curproc; @@ -166,7 +166,10 @@ stacktrace_save(struct stacktrace *st) sizeof(struct trapframe) - 0x10); while (st->st_count < STACKTRACE_MAX) { - st->st_pc[st->st_count++] = frame->f_lr; + if (skip == 0) + st->st_pc[st->st_count++] = frame->f_lr; + else + skip--; lastframe = frame; frame = frame->f_frame; diff --git a/sys/arch/hppa/hppa/db_interface.c b/sys/arch/hppa/hppa/db_interface.c index 53449e93713..4fdc05da415 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.47 2020/01/20 15:58:23 visa Exp $ */ +/* $OpenBSD: db_interface.c,v 1.48 2020/04/18 04:45:20 visa Exp $ */ /* * Copyright (c) 1999-2003 Michael Shalayeff @@ -316,7 +316,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, } void -stacktrace_save(struct stacktrace *st) +stacktrace_save_at(struct stacktrace *st, unsigned int skip) { register_t *fp, pc, rp; int i; @@ -327,7 +327,10 @@ stacktrace_save(struct stacktrace *st) st->st_count = 0; for (i = 0; i < STACKTRACE_MAX; i++) { - st->st_pc[st->st_count++] = rp; + if (skip == 0) + st->st_pc[st->st_count++] = rp; + else + skip--; /* next frame */ pc = rp; diff --git a/sys/arch/i386/i386/db_trace.c b/sys/arch/i386/i386/db_trace.c index 60787cf2395..09c630d0a81 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.40 2020/03/29 15:14:28 visa Exp $ */ +/* $OpenBSD: db_trace.c,v 1.41 2020/04/18 04:45:20 visa Exp $ */ /* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */ /* @@ -293,12 +293,6 @@ stacktrace_save_at(struct stacktrace *st, unsigned int skip) } } -void -stacktrace_save(struct stacktrace *st) -{ - return stacktrace_save_at(st, 0); -} - vaddr_t db_get_pc(struct trapframe *tf) { diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index 371fba749d4..2945e37312b 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.143 2020/01/20 15:58:23 visa Exp $ */ +/* $OpenBSD: trap.c,v 1.144 2020/04/18 04:45:20 visa Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -1477,7 +1477,7 @@ end: #ifdef DDB void -stacktrace_save(struct stacktrace *st) +stacktrace_save_at(struct stacktrace *st, unsigned int skip) { extern char k_general[]; extern char u_general[]; @@ -1503,8 +1503,12 @@ stacktrace_save(struct stacktrace *st) if (!VALID_ADDRESS(pc) || !VALID_ADDRESS(sp)) break; - if (!first) - st->st_pc[st->st_count++] = pc; + if (!first) { + if (skip == 0) + st->st_pc[st->st_count++] = pc; + else + skip--; + } first = 0; /* Determine the start address of the current subroutine. */ diff --git a/sys/arch/powerpc/ddb/db_trace.c b/sys/arch/powerpc/ddb/db_trace.c index 92c1e09f2d3..248d62be9d6 100644 --- a/sys/arch/powerpc/ddb/db_trace.c +++ b/sys/arch/powerpc/ddb/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.15 2020/04/10 07:23:21 mpi Exp $ */ +/* $OpenBSD: db_trace.c,v 1.16 2020/04/18 04:45:20 visa Exp $ */ /* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */ /* @@ -253,9 +253,3 @@ stacktrace_save_at(struct stacktrace *st, unsigned int skip) break; } } - -void -stacktrace_save(struct stacktrace *st) -{ - return stacktrace_save_at(st, 0); -} diff --git a/sys/arch/sparc64/sparc64/db_trace.c b/sys/arch/sparc64/sparc64/db_trace.c index ac224f718c7..6a6bccd2512 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.21 2020/03/25 14:59:23 mpi Exp $ */ +/* $OpenBSD: db_trace.c,v 1.22 2020/04/18 04:45:20 visa Exp $ */ /* $NetBSD: db_trace.c,v 1.23 2001/07/10 06:06:16 eeh Exp $ */ /* @@ -189,12 +189,6 @@ stacktrace_save_at(struct stacktrace *st, unsigned int skip) } void -stacktrace_save(struct stacktrace *st) -{ - return stacktrace_save_at(st, 0); -} - -void db_dump_window(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { int i; |