summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/Kconfig11
-rw-r--r--common/command.c14
2 files changed, 25 insertions, 0 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 2bdbfcb3d0..f6e7cd4303 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -53,6 +53,17 @@ config SYS_PROMPT
This string is displayed in the command line to the left of the
cursor.
+config SYS_XTRACE
+ string "Command execution tracer"
+ depends on CMDLINE
+ default y if CMDLINE
+ help
+ This option enables the possiblity to print all commands before
+ executing them and after all variables are evaluated (similar
+ to Bash's xtrace/'set -x' feature).
+ To enable the tracer a variable "xtrace" needs to be defined in
+ the environment.
+
menu "Autoboot options"
config AUTOBOOT
diff --git a/common/command.c b/common/command.c
index e14d1fa1d6..e192bb2a61 100644
--- a/common/command.c
+++ b/common/command.c
@@ -574,6 +574,20 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[],
enum command_ret_t rc = CMD_RET_SUCCESS;
cmd_tbl_t *cmdtp;
+#if defined(CONFIG_SYS_XTRACE)
+ char *xtrace;
+
+ xtrace = env_get("xtrace");
+ if (xtrace) {
+ puts("+");
+ for (int i = 0; i < argc; i++) {
+ puts(" ");
+ puts(argv[i]);
+ }
+ puts("\n");
+ }
+#endif
+
/* Look up command in command table */
cmdtp = find_cmd(argv[0]);
if (cmdtp == NULL) {