From: OpenOCD-Gerrit <ope...@us...> - 2020-08-16 10:50:23
|
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 d88765a7e2997c987ea7e5391378b3ae8b4fb59b (commit) via 401086186f2560b7c45ea53c200a0558f84437be (commit) from 105f8386ad92d27f0171d748f9b2a804a5317fd9 (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 d88765a7e2997c987ea7e5391378b3ae8b4fb59b Author: Antonio Borneo <bor...@gm...> Date: Fri Apr 24 00:28:49 2020 +0200 log: handle LOG_*() before calling to log_init() There are cases where LOG_*() functions are called before the logs are initialized with log_init(). E.g. in transport_register() that is executed in gcc constructors, thus called even before main(). With debug_level set to LOG_LVL_USER=-1 all the LOG_ERROR() get dropped. Properly initializing debug_level cause segmentation fault due to log_output still not initialized. Initialize debug_level to LOG_LVL_INFO so errors get printed. Handle separately the case of log_output still NULL, meaning that log_init() is not called yet. Change-Id: I2ea32c87a4955fb44e79b38131c456e25dfbc327 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5602 Tested-by: jenkins diff --git a/src/helper/log.c b/src/helper/log.c index 31122554e..b05850df0 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -40,7 +40,7 @@ #endif #endif -int debug_level = -1; +int debug_level = LOG_LVL_INFO; static FILE *log_output; static struct log_callback *log_callbacks; @@ -91,6 +91,14 @@ static void log_puts(enum log_levels level, const char *string) { char *f; + + if (!log_output) { + /* log_init() not called yet; print on stderr */ + fputs(string, stderr); + fflush(stderr); + return; + } + if (level == LOG_LVL_OUTPUT) { /* do not prepend any headers, just print out what we were given and return */ fputs(string, log_output); @@ -277,9 +285,6 @@ void log_init(void) { /* set defaults for daemon configuration, * if not set by cmdline or cfgfile */ - if (debug_level == -1) - debug_level = LOG_LVL_INFO; - char *debug_env = getenv("OPENOCD_DEBUG_LEVEL"); if (NULL != debug_env) { int value; commit 401086186f2560b7c45ea53c200a0558f84437be Author: Christopher Head <ch...@za...> Date: Mon Aug 10 11:09:02 2020 -0700 server/gdb_server: fix incorrect condition check The warning message should be printed if the target is NOT halted, not if it IS halted. Change-Id: I0a38292a8a2e20e4a4a5ada92b475d551d4cbf38 Signed-off-by: Christopher Head <ch...@za...> Reviewed-on: http://openocd.zylin.com/5794 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 61d7686c4..f94b72817 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1025,7 +1025,7 @@ static int gdb_new_connection(struct connection *connection) return ERROR_TARGET_NOT_EXAMINED; } - if (target->state == TARGET_HALTED) + if (target->state != TARGET_HALTED) LOG_WARNING("GDB connection %d on target %s not halted", gdb_actual_connections, target_name(target)); ----------------------------------------------------------------------- Summary of changes: src/helper/log.c | 13 +++++++++---- src/server/gdb_server.c | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) hooks/post-receive -- Main OpenOCD repository |