From 40bfbfe4a56c2bc88af796f98f288be76ff14e7f Mon Sep 17 00:00:00 2001 From: kettenis Date: Sat, 17 Jun 2023 08:13:56 +0000 Subject: [PATCH] On arm64, the frame pointer points at the stack address where the frame pointer of the previous frame has been stored. The code in db_stack_trace_print() got that wrong for the initial frame. While there, remove a bogus comment and some unused #defines about the layout of stack frames. ok patrick@ --- sys/arch/arm64/arm64/db_trace.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/sys/arch/arm64/arm64/db_trace.c b/sys/arch/arm64/arm64/db_trace.c index f0c0bd5b0a0..0fcfa138f3e 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.14 2023/04/26 16:53:58 claudio Exp $ */ +/* $OpenBSD: db_trace.c,v 1.15 2023/06/17 08:13:56 kettenis Exp $ */ /* $NetBSD: db_trace.c,v 1.8 2003/01/17 22:28:48 thorpej Exp $ */ /* @@ -49,18 +49,6 @@ db_regs_t ddb_regs; #define INKERNEL(va) (((vaddr_t)(va)) & (1ULL << 63)) -#ifndef __clang__ -/* - * Clang uses a different stack frame, which looks like the following. - * - * return link value [fp, #+4] - * return fp value [fp] <- fp points to here - * - */ -#define FR_RFP (0x0) -#define FR_RLV (0x4) -#endif /* !__clang__ */ - void db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, char *modif, int (*pr)(const char *, ...)) @@ -98,7 +86,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, lastlr = p->p_addr->u_pcb.pcb_tf->tf_elr; } else { sp = addr; - db_read_bytes(sp+16, sizeof(vaddr_t), + db_read_bytes(sp, sizeof(vaddr_t), (char *)&frame); db_read_bytes(sp + 8, sizeof(vaddr_t), (char *)&lr); -- 2.20.1