From 7fafb0add5d07540964cde734f41aff650eafefc Mon Sep 17 00:00:00 2001 From: Tomek CEDRO Date: Sun, 11 Sep 2011 00:56:26 +0000 Subject: transport/swd: Changes in logging mechanism: 1. LogLevel is inherited during transport initialization and only if context is created. 2. swd_log() use vprintf as using openocd logging mechanisms caused program crash by va recurrence. 3. Fixed tcl interface to use/update loglevel configuration parameter from swdctx stored within dap. --- src/transport/swd_tcl.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/transport/swd_tcl.c') diff --git a/src/transport/swd_tcl.c b/src/transport/swd_tcl.c index d75ad740..9389f66c 100644 --- a/src/transport/swd_tcl.c +++ b/src/transport/swd_tcl.c @@ -40,18 +40,16 @@ #include -//we need to use this until we get rid of global pointers -extern struct jtag_interface *jtag_interface; - - COMMAND_HANDLER(handle_swd_loglevel) { int loglevel; - swd_ctx_t *swdctx=(swd_ctx_t *)jtag_interface->transport->ctx; + struct target *target = get_current_target(CMD_CTX); + struct arm *arm = target_to_arm(target); + swd_ctx_t *swdctx = (swd_ctx_t *)arm->dap->ctx; switch (CMD_ARGC) { case 0: - LOG_INFO("Current SWD LogLevel[%d..%d] is: %d (%s)", SWD_LOGLEVEL_MIN, SWD_LOGLEVEL_MAX, swdctx->config.loglevel, swd_log_level_string(swdctx->config.loglevel)); + LOG_USER("Current SWD LogLevel[%d..%d] is: %d (%s)\n", SWD_LOGLEVEL_MIN, SWD_LOGLEVEL_MAX, swdctx->config.loglevel, swd_log_level_string(swdctx->config.loglevel)); break; case 1: // We want to allow inherit current OpenOCD's debuglevel. @@ -60,7 +58,7 @@ COMMAND_HANDLER(handle_swd_loglevel) LOG_ERROR("LogLevel inherit failed!"); return ERROR_FAIL; } else { - LOG_INFO("Using OpenOCD settings, SWD LogLevel[%d..%d] set to: %d (%s)", SWD_LOGLEVEL_MIN, SWD_LOGLEVEL_MAX, loglevel, swd_log_level_string(loglevel)); + LOG_USER("Using OpenOCD settings, SWD LogLevel[%d..%d] set to: %d (%s)\n", SWD_LOGLEVEL_MIN, SWD_LOGLEVEL_MAX, loglevel, swd_log_level_string(loglevel)); return ERROR_OK; } } @@ -69,7 +67,7 @@ COMMAND_HANDLER(handle_swd_loglevel) if (loglevelSWD_LOGLEVEL_MAX) { LOG_ERROR("Bad SWD LogLevel value!"); return ERROR_FAIL; - } else LOG_INFO("Setting SWD LogLevel[%d..%d] to: %d (%s)", SWD_LOGLEVEL_MIN, SWD_LOGLEVEL_MAX, loglevel, swd_log_level_string(loglevel)); + } else LOG_USER("Setting SWD LogLevel[%d..%d] to: %d (%s)\n", SWD_LOGLEVEL_MIN, SWD_LOGLEVEL_MAX, loglevel, swd_log_level_string(loglevel)); if(swd_log_level_set(swdctx, loglevel)<0){ return ERROR_FAIL; } else return ERROR_OK; -- cgit v1.2.3