Files
u-boot/test/cmd/backtrace.c
Simon Glass cee822e941 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>
2025-12-01 15:42:04 +00:00

28 lines
740 B
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Test for backtrace command
*
* Copyright 2025 Canonical Ltd
* Written by Simon Glass <simon.glass@canonical.com>
*/
#include <dm.h>
#include <dm/test.h>
#include <test/test.h>
#include <test/ut.h>
/* Test 'backtrace' command */
static int cmd_test_backtrace(struct unit_test_state *uts)
{
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);