From owner-svn-src-head@freebsd.org Thu Feb 6 18:02:38 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3E4A232711; Thu, 6 Feb 2020 18:02:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48D5qy4K5Xz4MLp; Thu, 6 Feb 2020 18:02:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F7A61F9AF; Thu, 6 Feb 2020 18:02:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 016I2caY089439; Thu, 6 Feb 2020 18:02:38 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 016I2cVu089438; Thu, 6 Feb 2020 18:02:38 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202002061802.016I2cVu089438@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 6 Feb 2020 18:02:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357630 - head/sys/riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/riscv/riscv X-SVN-Commit-Revision: 357630 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Feb 2020 18:02:38 -0000 Author: jhb Date: Thu Feb 6 18:02:38 2020 New Revision: 357630 URL: https://svnweb.freebsd.org/changeset/base/357630 Log: Fix DDB to unwind across exception frames. While here, add an extra line of information for exceptions and interrupts and compress the per-frame line down to one line to match other architectures. Reviewed by: mhorne, br MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23508 Modified: head/sys/riscv/riscv/db_trace.c Modified: head/sys/riscv/riscv/db_trace.c ============================================================================== --- head/sys/riscv/riscv/db_trace.c Thu Feb 6 18:00:50 2020 (r357629) +++ head/sys/riscv/riscv/db_trace.c Thu Feb 6 18:02:38 2020 (r357630) @@ -2,6 +2,7 @@ * Copyright (c) 2015 The FreeBSD Foundation * Copyright (c) 2016 Ruslan Bukin * All rights reserved. + * Copyright (c) 2020 John Baldwin * * Portions of this software were developed by Semihalf under * the sponsorship of the FreeBSD Foundation. @@ -38,15 +39,18 @@ #include __FBSDID("$FreeBSD$"); + #include -#include #include -#include +#include + #include #include +#include #include #include +#include void db_md_list_watchpoints() @@ -80,9 +84,6 @@ db_stack_trace_cmd(struct unwind_state *frame) while (1) { pc = frame->pc; - if (unwind_frame(frame) < 0) - break; - sym = db_search_symbol(pc, DB_STGY_ANY, &offset); if (sym == C_DB_SYM_NULL) { value = 0; @@ -94,11 +95,32 @@ db_stack_trace_cmd(struct unwind_state *frame) db_printsym(frame->pc, DB_STGY_PROC); db_printf("\n"); - db_printf("\t pc = 0x%016lx ra = 0x%016lx\n", - pc, frame->pc); - db_printf("\t sp = 0x%016lx fp = 0x%016lx\n", - frame->sp, frame->fp); - db_printf("\n"); + if (strcmp(name, "cpu_exception_handler_supervisor") == 0 || + strcmp(name, "cpu_exception_handler_user") == 0) { + struct trapframe *tf; + + tf = (struct trapframe *)(uintptr_t)frame->sp; + + if (tf->tf_scause & EXCP_INTR) + db_printf("--- interrupt %ld\n", + tf->tf_scause & EXCP_MASK); + else + db_printf("--- exception %ld, tval = %#lx\n", + tf->tf_scause & EXCP_MASK, + tf->tf_stval); + frame->sp = (uint64_t)tf->tf_sp; + frame->fp = (uint64_t)tf->tf_s[0]; + frame->pc = (uint64_t)tf->tf_sepc; + if (!INKERNEL(frame->fp)) + break; + continue; + } + + if (strcmp(name, "fork_trampoline") == 0) + break; + + if (unwind_frame(frame) < 0) + break; } }