helper/command: strip replicated command name in log 60/5660/2
authorAntonio Borneo <borneo.antonio@gmail.com>
Sun, 20 Oct 2019 17:40:28 +0000 (19:40 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 24 May 2020 20:36:29 +0000 (21:36 +0100)
After commit 0840414f0e57 ("helper/command: do not replace new
commands with ocd_ prefix"), the command name is present in
argv[0], so there is no need to pass it directly. The current code
causes the command name to be logged twice, once explicitly and
then from the content of argv[0]:
openocd -c 'debug_level 3; echo hello; shutdown'
<snip>
Debug: 13 3 command.c:142 script_debug(): command - echo echo hello
<snip>
Debug: 16 4 command.c:142 script_debug(): command - shutdown shutdown

Remove the command name from the arguments of the function
script_debug().

Change-Id: I57860774f450ff717ee71ef9dc07590549a84319
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5660
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
src/helper/command.c
src/helper/command.h
src/jtag/tcl.c

index 4422b4abe9b21e029c6c193b724241289eefbf87..14746a0958c3d7fd4b8b78b964e9a014b3a2963c 100644 (file)
@@ -126,13 +126,12 @@ extern struct command_context *global_cmd_ctx;
 
 /* dump a single line to the log for the command.
  * Do nothing in case we are not at debug level 3 */
 
 /* dump a single line to the log for the command.
  * Do nothing in case we are not at debug level 3 */
-void script_debug(Jim_Interp *interp, const char *name,
-       unsigned argc, Jim_Obj * const *argv)
+void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv)
 {
        if (debug_level < LOG_LVL_DEBUG)
                return;
 
 {
        if (debug_level < LOG_LVL_DEBUG)
                return;
 
-       char *dbg = alloc_printf("command - %s", name);
+       char *dbg = alloc_printf("command -");
        for (unsigned i = 0; i < argc; i++) {
                int len;
                const char *w = Jim_GetString(argv[i], &len);
        for (unsigned i = 0; i < argc; i++) {
                int len;
                const char *w = Jim_GetString(argv[i], &len);
@@ -213,7 +212,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
        struct command *c = interp->cmdPrivData;
        assert(c);
 
        struct command *c = interp->cmdPrivData;
        assert(c);
-       script_debug(interp, c->name, argc, argv);
+       script_debug(interp, argc, argv);
        return script_command_run(interp, argc, argv, c);
 }
 
        return script_command_run(interp, argc, argv, c);
 }
 
@@ -1032,8 +1031,7 @@ static int run_usage(Jim_Interp *interp, int argc_valid, int argc, Jim_Obj * con
 
 static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 {
 
 static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 {
-       const char *cmd_name = Jim_GetString(argv[0], NULL);
-       script_debug(interp, cmd_name, argc, argv);
+       script_debug(interp, argc, argv);
 
        struct command_context *cmd_ctx = current_command_context(interp);
        struct command *c = cmd_ctx->commands;
 
        struct command_context *cmd_ctx = current_command_context(interp);
        struct command *c = cmd_ctx->commands;
index 672ccd02bf593a17b97f5c6870ba51134c94d8a8..a20c4620dda08ef0aa1675929b75e025df43dc9b 100644 (file)
@@ -448,7 +448,6 @@ COMMAND_HELPER(handle_command_parse_bool, bool *out, const char *label);
 #define COMMAND_PARSE_ENABLE(in, out) \
        COMMAND_PARSE_BOOL(in, out, "enable", "disable")
 
 #define COMMAND_PARSE_ENABLE(in, out) \
        COMMAND_PARSE_BOOL(in, out, "enable", "disable")
 
-void script_debug(Jim_Interp *interp, const char *cmd,
-                 unsigned argc, Jim_Obj * const *argv);
+void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv);
 
 #endif /* OPENOCD_HELPER_COMMAND_H */
 
 #endif /* OPENOCD_HELPER_COMMAND_H */
index f52cbd60623b46016904d7f6cf614ba254bd809a..01210bd69df16983ccdbd1a55b6bb43df6be19a3 100644 (file)
@@ -108,7 +108,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args
 
        endstate = TAP_IDLE;
 
 
        endstate = TAP_IDLE;
 
-       script_debug(interp, "drscan", argc, args);
+       script_debug(interp, argc, args);
 
        /* validate arguments as numbers */
        e = JIM_OK;
 
        /* validate arguments as numbers */
        e = JIM_OK;
@@ -229,7 +229,7 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar
                return JIM_ERR;
        }
 
                return JIM_ERR;
        }
 
-       script_debug(interp, "pathmove", argc, args);
+       script_debug(interp, argc, args);
 
        int i;
        for (i = 0; i < argc-1; i++) {
 
        int i;
        for (i = 0; i < argc-1; i++) {
@@ -261,7 +261,7 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar
 
 static int Jim_Command_flush_count(Jim_Interp *interp, int argc, Jim_Obj *const *args)
 {
 
 static int Jim_Command_flush_count(Jim_Interp *interp, int argc, Jim_Obj *const *args)
 {
-       script_debug(interp, "flush_count", argc, args);
+       script_debug(interp, argc, args);
 
        Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count()));
 
 
        Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count()));
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)