summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorChristoph Muellner <christoph.muellner@theobroma-systems.com>2019-04-05 13:03:46 +0200
committerSimon Glass <sjg@chromium.org>2019-04-23 20:26:43 -0600
commit7ae31fccec16d4885f1704b089eb018be836f619 (patch)
tree15f4fc440cdca7fd954ee2a5ecc226c82930aa7c /common
parent62392675cdea46ca38a4d2b9be2c82e29b3b6da3 (diff)
common: command: Add command execution tracer.
When using boot scripts it can become quite hard to understand which commands are actually executed during bootup (e.g. where is a kernel image loaded from or which DTB is in use). Shell scripts suffer from a similar problem and many shells address this problem with a command execution tracer (e.g. BASH has xtrace, which can be enabled by "set -x"). This patch introduces a command tracer for U-Boot, which prints every command with its arguments before it is executed. Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Diffstat (limited to 'common')
-rw-r--r--common/command.c14
1 files changed, 14 insertions, 0 deletions
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) {