While a call to dump_stack() is easily hacked into the code, it can be useful during development to just print the stacktrace from the shell, e.g. to verify that kallsyms sharing for EFI works as intended. Add an option to cpuinfo to provide this functionality. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- arch/arm/cpu/cpuinfo.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/arm/cpu/cpuinfo.c b/arch/arm/cpu/cpuinfo.c index aea50e80d194..2d3fe2ac8d0c 100644 --- a/arch/arm/cpu/cpuinfo.c +++ b/arch/arm/cpu/cpuinfo.c @@ -4,6 +4,7 @@ /* cpuinfo.c - Show information about cp15 registers */ #include <common.h> +#include <getopt.h> #include <command.h> #include <complete.h> #include <asm/system.h> @@ -49,9 +50,23 @@ static int do_cpuinfo(int argc, char *argv[]) { unsigned long mainid, cache, cr; char *architecture, *implementer; - int i; + int opt, i; int cpu_arch; + while ((opt = getopt(argc, argv, "s")) > 0) { + switch (opt) { + case 's': + if (!IS_ENABLED(CONFIG_ARCH_HAS_STACK_DUMP)) + return -ENOSYS; + + printf("SP: 0x%08lx\n", get_sp()); + dump_stack(); + return 0; + default: + return COMMAND_ERROR_USAGE; + } + } + #ifdef CONFIG_CPU_64v8 __asm__ __volatile__( "mrs %0, midr_el1\n" @@ -255,10 +270,16 @@ static int do_cpuinfo(int argc, char *argv[]) return 0; } +BAREBOX_CMD_HELP_START(cpuinfo) +BAREBOX_CMD_HELP_TEXT("Shows misc info about CPU") +BAREBOX_CMD_HELP_OPT ("-s", "print call stack info (if supported)") +BAREBOX_CMD_HELP_END + BAREBOX_CMD_START(cpuinfo) .cmd = do_cpuinfo, BAREBOX_CMD_DESC("show info about CPU") + BAREBOX_CMD_OPTS("[-s]") BAREBOX_CMD_GROUP(CMD_GRP_INFO) BAREBOX_CMD_COMPLETE(empty_complete) + BAREBOX_CMD_HELP(cmd_cpuinfo_help) BAREBOX_CMD_END - -- 2.39.2