summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2018-05-04 15:43:35 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2018-05-04 15:43:35 +0000
commit32d2c95f3d923fab0cb0835981507e8b32f35674 (patch)
treed4cee838f7c4c1f2f53d34bd11f9de4af85c56d8 /sys/arch
parente52902e4aa718e14d540a7cf10b1ac6e9a105e1b (diff)
Add stack trace saving for arm64.
OK guenther@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/arm64/db_trace.c20
-rw-r--r--sys/arch/arm64/include/frame.h7
2 files changed, 25 insertions, 2 deletions
diff --git a/sys/arch/arm64/arm64/db_trace.c b/sys/arch/arm64/arm64/db_trace.c
index f7892e1e96b..f9af3f981de 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.5 2017/05/30 15:39:04 mpi Exp $ */
+/* $OpenBSD: db_trace.c,v 1.6 2018/05/04 15:43:34 visa Exp $ */
/* $NetBSD: db_trace.c,v 1.8 2003/01/17 22:28:48 thorpej Exp $ */
/*
@@ -148,3 +148,21 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
--count;
}
}
+
+void
+db_save_stack_trace(struct db_stack_trace *st)
+{
+ struct callframe *frame;
+
+ frame = __builtin_frame_address(0);
+ st->st_count = 0;
+ while (st->st_count < DB_STACK_TRACE_MAX) {
+ st->st_pc[st->st_count++] = frame->f_lr;
+
+ if (!INKERNEL(frame->f_frame) || frame->f_frame <= frame)
+ break;
+ frame = frame->f_frame;
+ if (!INKERNEL(frame->f_lr))
+ break;
+ }
+}
diff --git a/sys/arch/arm64/include/frame.h b/sys/arch/arm64/include/frame.h
index 4ae1c4f7ec9..72fe913b1d3 100644
--- a/sys/arch/arm64/include/frame.h
+++ b/sys/arch/arm64/include/frame.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: frame.h,v 1.1 2016/12/17 23:38:33 patrick Exp $ */
+/* $OpenBSD: frame.h,v 1.2 2018/05/04 15:43:34 visa Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
*
@@ -67,6 +67,11 @@ struct switchframe {
register_t sf_lr;
};
+struct callframe {
+ struct callframe *f_frame;
+ register_t f_lr;
+};
+
#endif /* !_LOCORE */
#endif /* _MACHINE_FRAME_H_ */