X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Fcommand.c;h=3625508f26b584afc09177dd19e391623ccdff34;hp=cf66f8a4c701a2c402a4133880e294ca76441f9d;hb=709f08f17ad5128b86966365510dbe8f67736304;hpb=6d8604de37855da6e9acf79adbb488788bdc9917 diff --git a/src/helper/command.c b/src/helper/command.c index cf66f8a4c7..3625508f26 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -108,10 +108,15 @@ static int command_retval_set(Jim_Interp *interp, int retval) 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 */ void script_debug(Jim_Interp *interp, const char *name, unsigned argc, Jim_Obj *const *argv) { - LOG_DEBUG("command - %s", name); + if (debug_level < LOG_LVL_DEBUG) + return; + + char * dbg = alloc_printf("command - %s", name); for (unsigned i = 0; i < argc; i++) { int len; @@ -121,8 +126,12 @@ void script_debug(Jim_Interp *interp, const char *name, if (*w == '#') break; - LOG_DEBUG("%s - argv[%d]=%s", name, i, w); + char * t = alloc_printf("%s %s", dbg, w); + free (dbg); + dbg = t; } + LOG_DEBUG("%s", dbg); + free(dbg); } static void script_command_args_free(const char **words, unsigned nwords) @@ -366,7 +375,10 @@ struct command* register_command(struct command_context *context, struct command *c = command_find(*head, name); if (NULL != c) { - LOG_ERROR("command '%s' is already registered in '%s' context", + /* TODO: originally we treated attempting to register a cmd twice as an error + * Sometimes we need this behaviour, such as with flash banks. + * http://www.mail-archive.com/openocd-development@lists.berlios.de/msg11152.html */ + LOG_DEBUG("command '%s' is already registered in '%s' context", name, parent ? parent->name : ""); return c; }