From: openocd-gerrit <ope...@us...> - 2023-11-24 21:41:18
|
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 1b0b07baab2b23318ddc484a58d66214f0c2a0d2 (commit) from be5cfdc86bce09e688aad16134cb36561c85d5eb (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 1b0b07baab2b23318ddc484a58d66214f0c2a0d2 Author: Marc Schink <de...@za...> Date: Sun Nov 12 11:43:48 2023 +0100 target: Throw error in 'debug_reason' command Instead of returning an 'error string', throw an error. This makes it much easier to handle errors in Tcl scripts or in tools that use Tcl RPC. Change-Id: I75c48750cfad7430fa5e6bc88fe04ebd59d34cea Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/8006 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/target.c b/src/target/target.c index d8e65863c..4a4c62613 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5845,7 +5845,17 @@ COMMAND_HANDLER(handle_target_debug_reason) struct target *target = get_current_target(CMD_CTX); - command_print(CMD, "%s", debug_reason_name(target)); + + const char *debug_reason = nvp_value2name(nvp_target_debug_reason, + target->debug_reason)->name; + + if (!debug_reason) { + command_print(CMD, "bug: invalid debug reason (%d)", + target->debug_reason); + return ERROR_FAIL; + } + + command_print(CMD, "%s", debug_reason); return ERROR_OK; } ----------------------------------------------------------------------- Summary of changes: src/target/target.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |