This is an automated email from Gerrit. Tomas Vanek (van...@fbl.cz) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4293
-- gerrit commit 46a9cd54db8df3a66334bf9b6d6d958c825e4d49 Author: Tomas Vanek <van...@fbl.cz> Date: Fri Nov 17 10:18:33 2017 +0100 target: set current target for event handler Many Tcl event handlers work with the current target. This become a problem in multi-target config, as the current target is the very one selected by the last 'targets' command and it may differ from the target issuing the event. To solve it, we either should 1) rewrite all relevant config scripts or 2) set the current target temporarily to the event issuing target for handler processing. This hack implements the case (2) Change-Id: I98d6943371b66652635efce0a86ac0eb891057a5 Signed-off-by: Tomas Vanek <van...@fbl.cz> diff --git a/src/target/target.c b/src/target/target.c index 36318d8..331be93 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4427,10 +4427,21 @@ void target_handle_event(struct target *target, enum target_event e) e, Jim_Nvp_value2name_simple(nvp_target_event, e)->name, Jim_GetString(teap->body, NULL)); + + /* HACK: Switch current target to the target + * an event is issued from (lot of scripts need it). + * Return back to previously current target + * as soon as event handler is done. */ + struct command_context *cmd_ctx = current_command_context(teap->interp); + int saved_curent_target = cmd_ctx->current_target; + cmd_ctx->current_target = target->target_number; + if (Jim_EvalObj(teap->interp, teap->body) != JIM_OK) { Jim_MakeErrorMessage(teap->interp); command_print(NULL, "%s\n", Jim_GetString(Jim_GetResult(teap->interp), NULL)); } + + cmd_ctx->current_target = saved_curent_target; } } } -- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel