[PATCH RFC 3/3] arm64: unwind stack on exception

Tom Rini trini at konsulko.com
Fri Jul 12 18:48:05 CEST 2024


On Wed, Jul 10, 2024 at 06:26:20PM +0200, Caleb Connolly wrote:

> We already build arm64 images with frame pointers. Let's finally make
> use of them in tandem with the new symbol lookup support by unwinding
> the stack when an exception occurs, producing a backtrace similar to
> those emitted by Linux.
> 
> In addition, introduce a dedicated unwind_stack() function which can be
> called from anywhere to print a backtrace.
> 
> Signed-off-by: Caleb Connolly <caleb.connolly at linaro.org>
> ---
>  arch/arm/include/asm/ptrace.h |  4 +++
>  arch/arm/lib/interrupts_64.c  | 76 +++++++++++++++++++++++++++++++++++++++++++
>  lib/Kconfig                   |  6 ++--
>  3 files changed, 84 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
> index a836f6cc60db..f42cfb33e918 100644
> --- a/arch/arm/include/asm/ptrace.h
> +++ b/arch/arm/include/asm/ptrace.h
> @@ -22,8 +22,12 @@
>  
>  #ifdef __KERNEL__
>  extern void show_regs(struct pt_regs *);
>  
> +#if CONFIG_IS_ENABLED(SYMBOL_LOOKUP)
> +void unwind_stack(void);
> +#endif

No guarding prototypes.

> diff --git a/lib/Kconfig b/lib/Kconfig
> index 06a78f83b7d6..092b780aeeb8 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -979,11 +979,13 @@ config VPL_OF_LIBFDT_ASSUME_MASK
>  	  unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
>  
>  config SYMBOL_LOOKUP
>  	bool "Enable symbol lookup"
> +	default n

This is already the default.

>  	help
> -	  This enables support for looking up symbol names from addresses. The
> -	  primary usecase for this is improved debugging support.
> +	  This enables support for looking up symbol names from addresses. When
> +	  enabled U-Boot will print stack traces with function names when an
> +	  exception occurs.

Please just word this as you want in the previous patch.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20240712/ed457a1b/attachment.sig>


More information about the U-Boot mailing list