From 048f9d77207345aedc4d7063d5f6dc563b4e4cb6 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Wed, 28 Aug 2024 16:39:44 +0800 Subject: [PATCH] system/system: add config SYSTEM_SYSTEM_DUMPINFO In some cases, applicationes use system() to excute the nsh command, but it's hard to find out who used the system function to execute the nsh command, so add this config to print the call backtrace and the command content. Signed-off-by: Bowen Wang --- system/system/Kconfig | 6 ++++++ system/system/system.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/system/system/Kconfig b/system/system/Kconfig index 60af65449..955a4c6ea 100644 --- a/system/system/Kconfig +++ b/system/system/Kconfig @@ -41,4 +41,10 @@ config SYSTEM_SYSTEM_PRIORITY ---help--- The priority of the shell. +config SYSTEM_SYSTEM_DUMPINFO + bool "dump the system information" + default n + ---help--- + Dump the system information when the system() command is executed. + endif diff --git a/system/system/system.c b/system/system/system.c index 5ecc3ae8b..096f99718 100644 --- a/system/system/system.c +++ b/system/system/system.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "nshlib/nshlib.h" @@ -68,6 +70,11 @@ int system(FAR const char *cmd) int rc; int ret; +#ifdef CONFIG_SYSTEM_SYSTEM_DUMPINFO + syslog(LOG_INFO, "SYSTEM cmd=%s\n", cmd); + dump_stack(); +#endif + /* REVISIT: If cmd is NULL, then system() should return a non-zero value to * indicate if the command processor is available or zero if it is not. */