* [PATCH 1/1] riscv: simplify backtrace report
@ 2024-05-14 5:51 Heinrich Schuchardt
2024-05-14 9:54 ` Leo Liang
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2024-05-14 5:51 UTC (permalink / raw)
To: Rick Chen, Leo; +Cc: Ben Dooks, u-boot, Heinrich Schuchardt
* We already have a header 'backtrace', there is no need to repeat the
word backtrace on every line.
* Add a blank line before the backtrace section of the crash report for
improved readability.
* If U-Boot is compiled without backtrace, there is no need to write a
message at all.
* Avoid #ifdef. We prefer functions to always be compiled and let
the linker remove them if not needed.
* Foresee 3 digits for the backtrace index.
For testing the 'exception' command can be used.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
arch/riscv/lib/interrupts.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/arch/riscv/lib/interrupts.c b/arch/riscv/lib/interrupts.c
index 7350e2ced85..f9a1428a486 100644
--- a/arch/riscv/lib/interrupts.c
+++ b/arch/riscv/lib/interrupts.c
@@ -60,21 +60,20 @@ static void show_regs(struct pt_regs *regs)
#endif
}
-#if defined(CONFIG_FRAMEPOINTER) || defined(CONFIG_SPL_FRAMEPOINTER)
-static void show_backtrace(struct pt_regs *regs)
+static void __maybe_unused show_backtrace(struct pt_regs *regs)
{
uintptr_t *fp = (uintptr_t *)regs->s0;
unsigned count = 0;
ulong ra;
- printf("backtrace:\n");
+ printf("\nbacktrace:\n");
/* there are a few entry points where the s0 register is
* set to gd, so to avoid changing those, just abort if
* the value is the same */
while (fp != NULL && fp != (uintptr_t *)gd) {
ra = fp[-1];
- printf("backtrace %2d: FP: " REG_FMT " RA: " REG_FMT,
+ printf("%3d: FP: " REG_FMT " RA: " REG_FMT,
count, (ulong)fp, ra);
if (gd && gd->flags & GD_FLG_RELOC)
@@ -87,12 +86,6 @@ static void show_backtrace(struct pt_regs *regs)
count++;
}
}
-#else
-static void show_backtrace(struct pt_regs *regs)
-{
- printf("No backtrace support enabled\n");
-}
-#endif
/**
* instr_len() - get instruction length
@@ -165,7 +158,8 @@ static void _exit_trap(ulong code, ulong epc, ulong tval, struct pt_regs *regs)
epc - gd->reloc_off, regs->ra - gd->reloc_off);
show_regs(regs);
- show_backtrace(regs);
+ if (CONFIG_IS_ENABLED(FRAMEPOINTER))
+ show_backtrace(regs);
show_code(epc);
show_efi_loaded_images(epc);
panic("\n");
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] riscv: simplify backtrace report
2024-05-14 5:51 [PATCH 1/1] riscv: simplify backtrace report Heinrich Schuchardt
@ 2024-05-14 9:54 ` Leo Liang
0 siblings, 0 replies; 2+ messages in thread
From: Leo Liang @ 2024-05-14 9:54 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: Rick Chen, Ben Dooks, u-boot
On Tue, May 14, 2024 at 07:51:42AM +0200, Heinrich Schuchardt wrote:
> * We already have a header 'backtrace', there is no need to repeat the
> word backtrace on every line.
> * Add a blank line before the backtrace section of the crash report for
> improved readability.
> * If U-Boot is compiled without backtrace, there is no need to write a
> message at all.
> * Avoid #ifdef. We prefer functions to always be compiled and let
> the linker remove them if not needed.
> * Foresee 3 digits for the backtrace index.
>
> For testing the 'exception' command can be used.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> arch/riscv/lib/interrupts.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-14 9:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-14 5:51 [PATCH 1/1] riscv: simplify backtrace report Heinrich Schuchardt
2024-05-14 9:54 ` Leo Liang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox