This is an automated email from Gerrit.

Antonio Borneo ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/5199

-- gerrit

commit b5887edfe70f3e3ef995da40acf315a60da5fc76
Author: Antonio Borneo <[email protected]>
Date:   Mon Jun 3 15:30:41 2019 +0200

    jtag: fix error on TCL command "return" in jtag event handler
    
    The TCL command "return" always returns error code JIM_RETURN, to
    indicate that the effective error code and message are elsewhere.
    
    In the current implementation, the caller of jtag's event only
    checks for return code JIM_OK and considers any other value,
    including JIM_RETURN, as an error condition.
    
    It can be tested running openocd on a jtag target and adding a
    jtag event "setup" with a single line "return", e.g.
        openocd -f board/ti_cc3200_launchxl.cfg \
        -c 'jtag configure cc32xx.cpu -event setup return'
    to get the message:
        ../src/jtag/core.c:1599: Error:
        in procedure 'jtag_init' called at file "../src/jtag/core.c",
        line 1599
    
    Modify jtag_tap_handle_event() to detect the specific return value
    of the "return" command and to test the real error code that is,
    eventually, specified to the TCL "return" command.
    
    Change-Id: I6d6febc15ef169638afffbffc1810e0b84fcf5c8
    Reported-by: Tomas Vanek <[email protected]>
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c
index 0161b28..cbdf2ad 100644
--- a/src/jtag/tcl.c
+++ b/src/jtag/tcl.c
@@ -639,6 +639,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
 static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
 {
        struct jtag_tap_event_action *jteap;
+       int retval;
 
        for (jteap = tap->event_action; jteap != NULL; jteap = jteap->next) {
                if (jteap->event != e)
@@ -649,7 +650,11 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, 
enum jtag_event e)
                        tap->dotted_name, e, nvp->name,
                        Jim_GetString(jteap->body, NULL));
 
-               if (Jim_EvalObj(jteap->interp, jteap->body) != JIM_OK) {
+               retval = Jim_EvalObj(jteap->interp, jteap->body);
+               if (retval == JIM_RETURN)
+                       retval = jteap->interp->returnCode;
+
+               if (retval != JIM_OK) {
                        Jim_MakeErrorMessage(jteap->interp);
                        LOG_USER("%s", 
Jim_GetString(Jim_GetResult(jteap->interp), NULL));
                        continue;

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to