[bsp/qemu-vexpress-a9] support function names in backtraces

Pass -mpoke-function-name to the compiler and assembler when
RT_BACKTRACE_FUNCTION_NAME is enabled for the Cortex-A9 QEMU BSP.
Keep the BSP configuration opt-in so users can enable symbolized
backtraces through menuconfig without changing the default build.

The flag is appended through CCFLAGS and ASPPCOM after the build
environment is created instead of concatenating it into
CFLAGS/CXXFLAGS/ASFLAGS: when the toolchain is selected with
--exec-path, PrepareBuilding() reloads rtconfig and
_apply_exec_path_override() overwrites those variables, which would
silently drop the option. The build still succeeds but function names
are missing from the text section, leaving backtraces without usable
frames.

Example backtrace in QEMU (vexpress-a9, RT_BACKTRACE_FUNCTION_NAME=y,
fault triggered from msh through cmd_fault -> fault_level1 ->
fault_level2 -> fault_level3):

    backtrace:
    0x600475a8 @ fault_level3
    0x600475dc @ fault_level2
    0x60047608 @ fault_level1
    0x60047630 @ cmd_fault
    0x6006ca80 @ _msh_exec_cmd
    0x6006cb3c @ msh_exec
    0x600717b4 @ finsh_thread_entry

Signed-off-by: Hui Su <3164683437@qq.com>
This commit is contained in:
Hui Su authored and Rbb666 committed 2026-08-28 11:29:05 +08:00
1 parent 5abbbec420
commit 0ae80cc79c
1 file changed
+15
+15
View File
@@ -2,6 +2,16 @@ import os
import sys
import rtconfig
TRACE_CONFIG = ''
try:
with open('rtconfig.h') as f:
for line in f:
if line.strip() == '#define RT_BACKTRACE_FUNCTION_NAME':
TRACE_CONFIG = '-mpoke-function-name'
break
except OSError:
pass
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
@@ -20,6 +30,11 @@ env = Environment(tools = ['mingw'],
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
if TRACE_CONFIG:
env.AppendUnique(CCFLAGS=[TRACE_CONFIG])
env['ASPPCOM'] += ' ' + TRACE_CONFIG
env['ASCOM'] = env['ASPPCOM']
Export('RTT_ROOT')