From: openocd-gerrit <ope...@us...> - 2023-10-14 12:01:15
|
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 2c8c2cb6b1426afc73519a7445a71a0aed36cf0f (commit) via bcaac692d0fce45189279a4c80cbd6852e4bbf4e (commit) from d27a3a00b8582cf2750cbc86c6194f5796ccca06 (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 2c8c2cb6b1426afc73519a7445a71a0aed36cf0f Author: Marek Vrbka <mar...@co...> Date: Mon Sep 18 14:32:44 2023 +0200 command: Prepend logs during command capture Previously, if you ran a tcl command in capture like so: "capture { reg 0x1000 hw }" Such command did overwrite the tcl result if LOG_LVL_INFO or lower was logged during it. This patch changes it by prepending the log to the tcl result instead. As the tcl results should not be lost during capture. Change-Id: I37381b45e15c931ba2844d65c9d38f6ed2f6e4fd Signed-off-by: Marek Vrbka <mar...@co...> Reviewed-on: https://review.openocd.org/c/openocd/+/7902 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins Reviewed-by: Jan Matyas <jan...@co...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 2d59238b8..6ec280ad2 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -12475,7 +12475,7 @@ Return information about the flash banks @item @b{capture} <@var{command}> Run <@var{command}> and return full log output that was produced during -its execution. Example: +its execution together with the command output. Example: @example > capture "reset init" diff --git a/src/helper/command.c b/src/helper/command.c index 945b890b3..ef50ab5bd 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -99,8 +99,7 @@ static struct log_capture_state *command_log_capture_start(Jim_Interp *interp) * The tcl return value is empty for openocd commands that provide * progress output. * - * Therefore we set the tcl return value only if we actually - * captured output. + * For other commands, we prepend the logs to the tcl return value. */ static void command_log_capture_finish(struct log_capture_state *state) { @@ -109,15 +108,18 @@ static void command_log_capture_finish(struct log_capture_state *state) log_remove_callback(tcl_output, state); - int length; - Jim_GetString(state->output, &length); + int loglen; + const char *log_result = Jim_GetString(state->output, &loglen); + int reslen; + const char *cmd_result = Jim_GetString(Jim_GetResult(state->interp), &reslen); - if (length > 0) - Jim_SetResult(state->interp, state->output); - else { - /* No output captured, use tcl return value (which could - * be empty too). */ - } + // Just in case the log doesn't end with a newline, we add it + if (loglen != 0 && reslen != 0 && log_result[loglen - 1] != '\n') + Jim_AppendString(state->interp, state->output, "\n", 1); + + Jim_AppendString(state->interp, state->output, cmd_result, reslen); + + Jim_SetResult(state->interp, state->output); Jim_DecrRefCount(state->interp, state->output); free(state); @@ -691,8 +693,8 @@ COMMAND_HANDLER(handle_echo) return ERROR_OK; } -/* Capture progress output and return as tcl return value. If the - * progress output was empty, return tcl return value. +/* Return both the progress output (LOG_INFO and higher) + * and the tcl return value of a command. */ static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { commit bcaac692d0fce45189279a4c80cbd6852e4bbf4e Author: Kirill Radkin <kir...@sy...> Date: Tue Sep 26 16:49:09 2023 +0300 target: Fix an issue with rwp/rbp command in smp targets If wp/bp is missing at address rwp/rbp won't return zero code (on smp). Now it fixed. Fixes: 022e438292de ("target: Change policy of removing watchpoints/breakpoints.") Change-Id: I3a3c245f7088fc23227b286d2191fc7f3edba702 Signed-off-by: Kirill Radkin <kir...@sy...> Reviewed-on: https://review.openocd.org/c/openocd/+/7910 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index 5ce0346bb..4a613cc28 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -367,8 +367,10 @@ int breakpoint_remove(struct target *target, target_addr_t address) } } - if (num_found_breakpoints == 0) + if (num_found_breakpoints == 0) { LOG_TARGET_ERROR(target, "no breakpoint at address " TARGET_ADDR_FMT " found", address); + return ERROR_BREAKPOINT_NOT_FOUND; + } return retval; } @@ -591,7 +593,7 @@ int watchpoint_remove(struct target *target, target_addr_t address) num_found_watchpoints++; if (status != ERROR_OK) { - LOG_TARGET_ERROR(curr, "failed to remove watchpoint at address" TARGET_ADDR_FMT, address); + LOG_TARGET_ERROR(curr, "failed to remove watchpoint at address " TARGET_ADDR_FMT, address); retval = status; } } @@ -603,12 +605,14 @@ int watchpoint_remove(struct target *target, target_addr_t address) num_found_watchpoints++; if (retval != ERROR_OK) - LOG_TARGET_ERROR(target, "failed to remove watchpoint at address" TARGET_ADDR_FMT, address); + LOG_TARGET_ERROR(target, "failed to remove watchpoint at address " TARGET_ADDR_FMT, address); } } - if (num_found_watchpoints == 0) + if (num_found_watchpoints == 0) { LOG_TARGET_ERROR(target, "no watchpoint at address " TARGET_ADDR_FMT " found", address); + return ERROR_WATCHPOINT_NOT_FOUND; + } return retval; } ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 2 +- src/helper/command.c | 26 ++++++++++++++------------ src/target/breakpoints.c | 12 ++++++++---- 3 files changed, 23 insertions(+), 17 deletions(-) hooks/post-receive -- Main OpenOCD repository |