target: do not print an error on shutdown in target events 10/5710/2
authorAntonio Borneo <borneo.antonio@gmail.com>
Tue, 2 Jun 2020 12:43:29 +0000 (14:43 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 27 Jun 2020 14:34:51 +0000 (15:34 +0100)
Before commit b3ce5a0ae545 ("target: use LOG_USER to print errors
in events") an error in an event handler was silently lost, while
now the associated message is printed out.

A "shutdown" command in a target event (e.g. in gdb-detach) causes
the event to end with error code ERROR_COMMAND_CLOSE_CONNECTION,
that triggers the error message:
shutdown command invoked
Error executing event <event-name> on target <target-name>:

The error code returned by the command "shutdown" is required to
stop the execution in a script/proc and avoid executing any
further command in the script/proc.
It is then normal to get an error code from the "shutdown" command
and it should not be printed out.

Intercept the return code of the event in case of "shutdown", then
skip scheduling other target events and return without printing
the incorrect error message.

Change-Id: Ia3085fb46beacb90a5e4bf0abf7c6e28bb9e6a9b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Laurent Lemele <laurent.lemele@st.com>
Reviewed-on: http://openocd.zylin.com/5710
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
src/target/target.c

index c0953a3f1ca666eebc4deec6bf75f6eb0308579a..2ea1e206c776ab5c993a085251a5be103d621743 100644 (file)
@@ -4582,8 +4582,14 @@ void target_handle_event(struct target *target, enum target_event e)
                        struct command_context *cmd_ctx = current_command_context(teap->interp);
                        struct target *saved_target_override = cmd_ctx->current_target_override;
                        cmd_ctx->current_target_override = target;
+
                        retval = Jim_EvalObj(teap->interp, teap->body);
 
+                       cmd_ctx->current_target_override = saved_target_override;
+
+                       if (retval == ERROR_COMMAND_CLOSE_CONNECTION)
+                               return;
+
                        if (retval == JIM_RETURN)
                                retval = teap->interp->returnCode;
 
@@ -4596,8 +4602,6 @@ void target_handle_event(struct target *target, enum target_event e)
                                /* clean both error code and stacktrace before return */
                                Jim_Eval(teap->interp, "error \"\" \"\"");
                        }
-
-                       cmd_ctx->current_target_override = saved_target_override;
                }
        }
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)