Tcl exception codes cleanup, shutdown command amendments
This patch might influence openocd Tcl commands behaviour in subtle ways, please give it a nice testing. The idea is that if an OpenOCD Tcl command returns an error, an exception is raised, and then the return code is propogated all the way up (or to the "catch" if present). This allows to detect "shutdown" which is not actually an error but has to raise an exception to stop execution of the commands that follow it in the script. openocd_thread special-cases shutdown because it should then terminate OpenOCD with a success error code, unless shutdown was called with an optional "error" argument which means terminate with a non-zero exit code. Change-Id: I7b6fa8a2e24c947dc45d8def0008b4b007c478b3 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2600 Tested-by: jenkins Reviewed-by: Juha Niskanen <juha.niskanen@haltian.com> Reviewed-by: Jens Bauer <jens@gpio.dk> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
This commit is contained in:
@@ -283,7 +283,9 @@ static int openocd_thread(int argc, char *argv[], struct command_context *cmd_ct
|
||||
return ERROR_FAIL;
|
||||
|
||||
ret = parse_config_file(cmd_ctx);
|
||||
if (ret != ERROR_OK)
|
||||
if (ret == ERROR_COMMAND_CLOSE_CONNECTION)
|
||||
return ERROR_OK;
|
||||
else if (ret != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
|
||||
ret = server_init(cmd_ctx);
|
||||
@@ -296,9 +298,15 @@ static int openocd_thread(int argc, char *argv[], struct command_context *cmd_ct
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
server_loop(cmd_ctx);
|
||||
ret = server_loop(cmd_ctx);
|
||||
|
||||
return server_quit();
|
||||
int last_signal = server_quit();
|
||||
if (last_signal != ERROR_OK)
|
||||
return last_signal;
|
||||
|
||||
if (ret != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/* normally this is the main() function entry, but if OpenOCD is linked
|
||||
|
||||
Reference in New Issue
Block a user