This is an automated email from Gerrit.

"zapb <d...@zapb.de>" just uploaded a new patch set to Gerrit, which you can 
find at https://review.openocd.org/c/openocd/+/8006

-- gerrit

commit 7b0dc93dad3cdeda8d3d37359343268af78255db
Author: Marc Schink <d...@zapb.de>
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 <d...@zapb.de>

diff --git a/src/target/target.c b/src/target/target.c
index d368cb5156..1e532d93f8 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -5881,7 +5881,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;
 }

-- 

Reply via email to