From: Bo Gan <ganboing@gmail.com>
To: Ben Dooks <ben.dooks@codethink.co.uk>,
Ben Dooks <ben.dooks@sifive.com>,
u-boot@lists.denx.de
Cc: rick@andestech.com
Subject: Re: [PATCH] riscv: add backtrace support
Date: Thu, 15 Jun 2023 12:01:52 -0700 [thread overview]
Message-ID: <b131a48d-e726-390a-1aec-56cc425bac44@gmail.com> (raw)
In-Reply-To: <f81cda79-a760-2f1b-9353-f028ac40b467@codethink.co.uk>
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.
next prev parent reply other threads:[~2023-06-15 19:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 13:03 [PATCH] riscv: add backtrace support Ben Dooks
2023-05-25 11:05 ` Ben Dooks
2023-06-14 6:25 ` Bo Gan
2023-06-14 17:15 ` Ben Dooks
2023-06-15 19:01 ` Bo Gan [this message]
2023-06-16 8:55 ` Ben Dooks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b131a48d-e726-390a-1aec-56cc425bac44@gmail.com \
--to=ganboing@gmail.com \
--cc=ben.dooks@codethink.co.uk \
--cc=ben.dooks@sifive.com \
--cc=rick@andestech.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox