On arm64, the frame pointer points at the stack address where the frame
authorkettenis <kettenis@openbsd.org>
Sat, 17 Jun 2023 08:13:56 +0000 (08:13 +0000)
committerkettenis <kettenis@openbsd.org>
Sat, 17 Jun 2023 08:13:56 +0000 (08:13 +0000)
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

index f0c0bd5..0fcfa13 100644 (file)
@@ -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);