From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83C66EB64D9 for ; Thu, 15 Jun 2023 19:02:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A0B08607F; Thu, 15 Jun 2023 21:02:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="siCxhHhh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F06BB86140; Thu, 15 Jun 2023 21:01:58 +0200 (CEST) Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2461F86065 for ; Thu, 15 Jun 2023 21:01:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ganboing@gmail.com Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6664a9f0b10so39197b3a.0 for ; Thu, 15 Jun 2023 12:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686855714; x=1689447714; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject:from:to:cc :subject:date:message-id:reply-to; bh=zXQeytn3KEoel7WAd5uc+IBtVE7rkxPSk+i+b2L80Lc=; b=siCxhHhhpkffEufmxFGWQZIFYtkk2NAl6yH3PU+1QGvcZQrMgu2qKH2aJcGqnHjCNg j4KiyTZIZmWUSio+kYTKNv3EAiI4Yc0vC7VrQmHE16UBAr8AzY7MoFgMdFKJEIkQedi9 4sFQG/0mQuWQdpQQrG31B2ljMUWuiR/pJli/CP2wA5bFoz4m0JNKswk14SMTYoeURY8O gAaElBbFpD3G+v91qmv+CZwSpG+gFHdQspGIFRPjN0ymD+IAc401F9sZCjoh5qj6Z4P7 qi7BW1xFeIWiwO2dWdbOF8rZG8icyVpfvb5+a9HarSW22cv3My8Yd/qqoz+t5HvsMDqO Beyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686855714; x=1689447714; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zXQeytn3KEoel7WAd5uc+IBtVE7rkxPSk+i+b2L80Lc=; b=ef28cu1Kj9B4Kzq47W4NBiRAssPxc1hjueyMAAqhL4UR8GCIUFhUywHJLVypgKC+/t z2s6ZC7WL5tMRcTDHYYxmXcEozO9ojY1jXMg7fqWm4YKRfdf+L/j4p7Rv3e6cwlgiFmJ z67Cs/sxX6xHuwczwqePsUBtr9ruHUaqcLHZhps2joRZfqRHnA+6BJMgBK7y9gHinQ6c qL4nI1uXjKTTk0CQnp724JNZ8L6psCOnwxiYT4FSYOa3BVsEguDhosymZNMyJlXTf5C+ QJqQ55D4MivupIKvjBRSrh2jIOMiYeXeIOtfmAp3c/KXVd5053xrDeASeCNE0WBl30EH Z1WQ== X-Gm-Message-State: AC+VfDxMG4sVPMbdhYBrjswqQC+knhFRaEEKgKgUWwAQOdhJhW/7/AZ7 sX8BhTa/M8Sw+cF3XJsD79I= X-Google-Smtp-Source: ACHHUZ41wkrpjdS9Qpeqto8qYLtrlwX8tnfzbwzpdPKvvyxH503rCExWU64mJD5y8NAivx1O3YnIWQ== X-Received: by 2002:a05:6a21:99a9:b0:10e:e1f9:d197 with SMTP id ve41-20020a056a2199a900b0010ee1f9d197mr271412pzb.38.1686855714247; Thu, 15 Jun 2023 12:01:54 -0700 (PDT) Received: from [192.168.0.13] ([172.92.174.136]) by smtp.gmail.com with ESMTPSA id r23-20020a170902be1700b001a183ade911sm14319337pls.56.2023.06.15.12.01.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 12:01:53 -0700 (PDT) Subject: Re: [PATCH] riscv: add backtrace support To: Ben Dooks , Ben Dooks , u-boot@lists.denx.de Cc: rick@andestech.com References: <20230515130322.516871-1-ben.dooks@sifive.com> <32369479-7490-f437-4c12-3250476d1862@codethink.co.uk> From: Bo Gan Message-ID: Date: Thu, 15 Jun 2023 12:01:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 6/14/23 10:15 AM, Ben Dooks wrote: > On 14/06/2023 07:25, Bo Gan wrote: >> On 5/25/23 4:05 AM, Ben Dooks wrote: >>> On 15/05/2023 14:03, Ben Dooks wrote: >>>> When debugging, it is useful to have a backtrace to find >>>> out what is in the call stack as the previous function (RA) >>>> may not have been the culprit. >>>> >>>> Since this adds size to the build, do not add it by default >>>> and avoid putting it in the SPL build if not needed. >>> >>> Hi, has anyone had time to review this? >>> >> >> Hi Ben, this looks really useful. I'd like to use it in SPL, >> but I'm unable to enable CONFIG_SPL_FRAMEPOINTER=y. It's likely >> that you need to add a SPL_FRAMEPOINTER entry to Kconfig as well. > > I will have a look at this, but testing may not be easy as the > setup we're using has limited SPL space. > I did a hack (duplicate `config FRAMEPOINTER` to `config SPL_FRAMEPOINTER`) --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -63,6 +63,24 @@ config SPL_SYS_DCACHE_OFF +config SPL_FRAMEPOINTER + bool "Build with frame pointer for stack unwinding" + depends on SPL + help + Choose this option to use the frame pointer so the stack can be + unwound if needed. This is useful for tracing where faults came + from as the source may be several functions back + + If you say Y here, then the code size will be increased due to + having to store the fp. + This is sufficient for enabling CONFIG_SPL_FRAMEPOINTER=y. With this, I tested SPL on JH7110 (VisionFive 2), and observed your patch's working: Unhandled exception: Load access fault EPC: 000000000800335e RA: 00000000080033e8 TVAL: 0000000000000040 SP: 00000000080ff5b0 GP: 00000000080dbda0 TP: 0000000000000000 T0: 00000000080ffb20 T1: 0000000000000020 T2: 0000000000000000 S0: 00000000080ffb20 S1: 00000000080ff6d0 A0: 0000000000000000 A1: 00000000080ff6d0 A2: 0000000008020d83 A3: 00000000080ffb20 A4: 0000000000000025 A5: 0000000008040218 A6: 0000000000000020 A7: 0000000008000000 S2: 0000000000000013 S3: 0000000000000001 S4: 0000000040000000 S5: 0000000000000001 S6: 000000000000000a S7: 00000000080ffb88 S8: 0000000002000000 S9: 000000000801bc60 S10: 00000000080fff38 S11: 0000000000000000 T3: 0000000000000023 T4: 0000000000000006 T5: 000000000001869f T6: 00000000080dd138 backtrace: backtrace 0: FP: 00000000080ffb20 RA: 0000000008005888 backtrace 1: FP: 00000000080ffb80 RA: 0000000008007046 backtrace 2: FP: 00000000080ffc50 RA: 00000000080024ec backtrace 3: FP: 00000000080ffd00 RA: 00000000080028e0 backtrace 4: FP: 00000000080ffe00 RA: 0000000008002cf6 backtrace 5: FP: 00000000080fff30 RA: 0000000008002144 backtrace 6: FP: 0000000008100000 RA: 0000000008000178 Code: 6797 0002 b783 1ba7 050e 953e 6108 6422 (613c) Looks like you just need a `config SPL_FRAMEPOINTER` entry in Kconfig.