This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 048f9d772 system/system: add config SYSTEM_SYSTEM_DUMPINFO
048f9d772 is described below
commit 048f9d77207345aedc4d7063d5f6dc563b4e4cb6
Author: Bowen Wang <[email protected]>
AuthorDate: Wed Aug 28 16:39:44 2024 +0800
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 <[email protected]>
---
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 <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.
*/