backtrace: Strip the source tree prefix from filenames

Display relative paths instead of absolute paths in backtrace output,
making the output cleaner and more portable across different build
environments.

This works by adding a SRCTREE define to lib/backtrace.c and stripping
it from filenames when printing.

Series-to: concept
Series-cc: heinrich
Cover-letter:
backtrace: Add runtime support for looking at the backtrace
In some cases the backtrace contains useful information, such as whether
a particular function was called earlier in the stack.

This series provides a very simple backtrace library, along with some
sandbox-specific functions to allow it to work. It is designed such that
another arch could implement it.

A new 'backtrace' command provides access to the backtrace.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2025-11-28 06:51:08 -07:00
committed by Simon Glass
parent eb711c45ce
commit cee822e941
4 changed files with 32 additions and 11 deletions

View File

@@ -14,9 +14,14 @@
/* Test 'backtrace' command */
static int cmd_test_backtrace(struct unit_test_state *uts)
{
/* for now, just run the command */
ut_assertok(run_command("backtrace", 0));
ut_assert_nextlinen("backtrace:");
ut_assert_nextlinen(" backtrace_show() at lib/backtrace.c:");
ut_assert_nextlinen(" do_backtrace() at cmd/backtrace.c:");
ut_assert_nextlinen(" cmd_process() at common/command.c:");
ut_assert_skip_to_linen(" cmd_test_backtrace() at test/cmd/backtrace.c:");
return 0;
}
DM_TEST(cmd_test_backtrace, UTF_SCAN_FDT);