From: openocd-gerrit <ope...@us...> - 2024-03-16 14:37:24
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via b63e065f23807cdf6da44d03def4c416686695f5 (commit) from 263dbc1472efa5f24e636e95f8c71a6f83b4097a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b63e065f23807cdf6da44d03def4c416686695f5 Author: Tomas Vanek <va...@fb...> Date: Fri Feb 16 17:40:22 2024 +0100 helper/log: add LOG_CUSTOM_LEVEL() macro Allow logging at a changeable level. Add an example of usage in ftdi driver. Log SWD commands with not OK response at debug level (3). For commands which responded OK use debug io level (4) not to flood the log. Signed-off-by: Tomas Vanek <va...@fb...> Change-Id: I67a472b293f7ed9ee84cadb7c081803e9eeb1ad0 Reviewed-on: https://review.openocd.org/c/openocd/+/8151 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/helper/log.h b/src/helper/log.h index ee71bf03f..818716a9d 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -114,6 +114,15 @@ extern int debug_level; expr); \ } while (0) +#define LOG_CUSTOM_LEVEL(level, expr ...) \ + do { \ + enum log_levels _level = level; \ + if (debug_level >= _level) \ + log_printf_lf(_level, \ + __FILE__, __LINE__, __func__, \ + expr); \ + } while (0) + #define LOG_INFO(expr ...) \ log_printf_lf(LOG_LVL_INFO, __FILE__, __LINE__, __func__, expr) diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c index 2bde93169..58f83af59 100644 --- a/src/jtag/drivers/ftdi.c +++ b/src/jtag/drivers/ftdi.c @@ -1088,7 +1088,8 @@ static int ftdi_swd_run_queue(void) /* Devices do not reply to DP_TARGETSEL write cmd, ignore received ack */ bool check_ack = swd_cmd_returns_ack(swd_cmd_queue[i].cmd); - LOG_DEBUG_IO("%s%s %s %s reg %X = %08"PRIx32, + LOG_CUSTOM_LEVEL((check_ack && ack != SWD_ACK_OK) ? LOG_LVL_DEBUG : LOG_LVL_DEBUG_IO, + "%s%s %s %s reg %X = %08" PRIx32, check_ack ? "" : "ack ignored ", ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ? "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK", swd_cmd_queue[i].cmd & SWD_CMD_APNDP ? "AP" : "DP", ----------------------------------------------------------------------- Summary of changes: src/helper/log.h | 9 +++++++++ src/jtag/drivers/ftdi.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |