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 <wangbowen6@xiaomi.com>
This commit is contained in:
Bowen Wang 2024-08-28 16:39:44 +08:00 committed by Xiang Xiao
parent 3fef38c96d
commit 048f9d7720
2 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -31,6 +31,8 @@
#include <assert.h>
#include <debug.h>
#include <errno.h>
#include <execinfo.h>
#include <syslog.h>
#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.
*/