Skip to content

Commit 1b0b07b

Browse files
zapb-0borneoa
authored andcommitted
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 <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/8006 Tested-by: jenkins Reviewed-by: Antonio Borneo <[email protected]>
1 parent be5cfdc commit 1b0b07b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/target/target.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5845,7 +5845,17 @@ COMMAND_HANDLER(handle_target_debug_reason)
58455845

58465846
struct target *target = get_current_target(CMD_CTX);
58475847

5848-
command_print(CMD, "%s", debug_reason_name(target));
5848+
5849+
const char *debug_reason = nvp_value2name(nvp_target_debug_reason,
5850+
target->debug_reason)->name;
5851+
5852+
if (!debug_reason) {
5853+
command_print(CMD, "bug: invalid debug reason (%d)",
5854+
target->debug_reason);
5855+
return ERROR_FAIL;
5856+
}
5857+
5858+
command_print(CMD, "%s", debug_reason);
58495859

58505860
return ERROR_OK;
58515861
}

0 commit comments

Comments
 (0)