Mon Sep 19 17:24:23 2022 UTC ()
Fixed stack analyzing backtrace (bt/s) correctly for nested trapframes.


(ryo)
diff -r1.19 -r1.20 src/sys/arch/aarch64/aarch64/db_trace.c

cvs diff -r1.19 -r1.20 src/sys/arch/aarch64/aarch64/db_trace.c (expand / switch to unified diff)

--- src/sys/arch/aarch64/aarch64/db_trace.c 2022/06/07 23:55:25 1.19
+++ src/sys/arch/aarch64/aarch64/db_trace.c 2022/09/19 17:24:23 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db_trace.c,v 1.19 2022/06/07 23:55:25 ryo Exp $ */ 1/* $NetBSD: db_trace.c,v 1.20 2022/09/19 17:24:23 ryo Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org> 4 * Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30 30
31__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.19 2022/06/07 23:55:25 ryo Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.20 2022/09/19 17:24:23 ryo Exp $");
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/bitops.h> 34#include <sys/bitops.h>
35#include <sys/proc.h> 35#include <sys/proc.h>
36 36
37#include <aarch64/db_machdep.h> 37#include <aarch64/db_machdep.h>
38#include <aarch64/machdep.h> 38#include <aarch64/machdep.h>
39#include <aarch64/armreg.h> 39#include <aarch64/armreg.h>
40#include <aarch64/vmparam.h> 40#include <aarch64/vmparam.h>
41 41
42#include <arm/cpufunc.h> 42#include <arm/cpufunc.h>
43 43
44#include <uvm/uvm_extern.h> 44#include <uvm/uvm_extern.h>
@@ -534,28 +534,28 @@ db_sp_trace(struct trapframe *tf, db_add @@ -534,28 +534,28 @@ db_sp_trace(struct trapframe *tf, db_add
534 534
535 db_read_bytes((db_addr_t)sp, sizeof(tf_buf), 535 db_read_bytes((db_addr_t)sp, sizeof(tf_buf),
536 (char *)&tf_buf); 536 (char *)&tf_buf);
537 if (tf_buf.tf_lr == 0) 537 if (tf_buf.tf_lr == 0)
538 break; 538 break;
539 pr_frame((struct trapframe *)sp, pr); 539 pr_frame((struct trapframe *)sp, pr);
540 540
541 sp = tf_buf.tf_sp; 541 sp = tf_buf.tf_sp;
542 pc = tf_buf.tf_pc; 542 pc = tf_buf.tf_pc;
543 if (pc == 0) 543 if (pc == 0)
544 pc = aarch64_strip_pac(tf_buf.tf_lr); 544 pc = aarch64_strip_pac(tf_buf.tf_lr);
545 if (pc == 0) 545 if (pc == 0)
546 break; 546 break;
547 547 lr0 = aarch64_strip_pac(tf_buf.tf_lr);
548 pr_traceaddr("sp", sp, pc, flags, pr); 548 allow_leaf_function = true;
549 549
550 } else { 550 } else {
551 db_sym_t sym; 551 db_sym_t sym;
552 db_addr_t func_entry, lr; 552 db_addr_t func_entry, lr;
553 db_expr_t func_offset; 553 db_expr_t func_offset;
554 vsize_t stacksize; 554 vsize_t stacksize;
555 555
556 pr_traceaddr("sp", sp, pc, flags, pr); 556 pr_traceaddr("sp", sp, pc, flags, pr);
557 557
558 if ((flags & TRACEFLAG_USERSPACE) == 0 && 558 if ((flags & TRACEFLAG_USERSPACE) == 0 &&
559 !IN_KERNEL_VM_ADDRESS(pc)) 559 !IN_KERNEL_VM_ADDRESS(pc))
560 break; 560 break;
561 561