From 2a3d9d0d9078136912ffeef4a9f125a8206ab6f9 Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Sat, 18 May 2024 17:36:43 +0800 Subject: [PATCH] arch: arm64: use symtab to print function name in stack trace Selecting `CONFIG_SYMTAB` will enable the symtab generation which will be used in the stack trace to print the function name of the return address. Added `arm64` to the `arch.common.stack_unwind.symtab` test. Signed-off-by: Yong Cong Sin --- arch/arm64/core/fatal.c | 9 +++++++++ doc/releases/release-notes-3.7.rst | 4 ++++ tests/arch/common/stack_unwind/testcase.yaml | 2 ++ 3 files changed, 15 insertions(+) diff --git a/arch/arm64/core/fatal.c b/arch/arm64/core/fatal.c index 84ff767508e..92ef0d8a3da 100644 --- a/arch/arm64/core/fatal.c +++ b/arch/arm64/core/fatal.c @@ -13,6 +13,7 @@ * exceptions */ +#include #include #include #include @@ -224,8 +225,16 @@ static void esf_unwind(const z_arch_esf_t *esf) LOG_ERR(""); while (fp != NULL) { lr = fp[1]; +#ifdef CONFIG_SYMTAB + uint32_t offset = 0; + const char *name = symtab_find_symbol_name(lr, &offset); + + LOG_ERR("backtrace %2d: fp: 0x%016llx lr: 0x%016llx [%s+0x%x]", + count++, (uint64_t) fp, lr, name, offset); +#else LOG_ERR("backtrace %2d: fp: 0x%016llx lr: 0x%016llx", count++, (uint64_t) fp, lr); +#endif fp = (uint64_t *) fp[0]; } LOG_ERR(""); diff --git a/doc/releases/release-notes-3.7.rst b/doc/releases/release-notes-3.7.rst index d30186c7c73..334d12ed053 100644 --- a/doc/releases/release-notes-3.7.rst +++ b/doc/releases/release-notes-3.7.rst @@ -71,6 +71,10 @@ Architectures * ARM +* ARM64 + + * Implemented symbol names in the backtraces, enable by selecting :kconfig:option:`CONFIG_SYMTAB` + * RISC-V * The fatal error message triggered from a fault now contains the callee-saved-registers states. diff --git a/tests/arch/common/stack_unwind/testcase.yaml b/tests/arch/common/stack_unwind/testcase.yaml index 84e00ecbf59..f57e8b41048 100644 --- a/tests/arch/common/stack_unwind/testcase.yaml +++ b/tests/arch/common/stack_unwind/testcase.yaml @@ -53,9 +53,11 @@ tests: arch.common.stack_unwind.symtab: arch_allow: - riscv + - arm64 integration_platforms: - qemu_riscv32 - qemu_riscv64 + - qemu_cortex_a53 extra_args: OVERLAY_CONFIG="enable_fp.conf" harness_config: type: multi_line