target: add API to temporarily mask target polling

The same flag 'jtag_poll' is currently used as local data for the
command 'poll' and to temporarily mask the target polling.
This can cause unexpected behavior if the command 'poll' is
executed while polling is temporarily masked.

Add a new flag 'jtag_poll_en' to hold the temporarily mask
condition and keep 'jtag_poll' for the 'poll' command only.

While there, change the initial assignment of 'jtag_poll' using
the proper boolean value.

Change-Id: I18dcf7c65b07aefadf046caaa2fcd2d74fa6fbae
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7009
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
This commit is contained in:
Antonio Borneo
2022-05-30 22:49:12 +02:00
parent c3138e2d80
commit 0d56f379b5
5 changed files with 41 additions and 15 deletions

View File

@@ -702,14 +702,12 @@ static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
* This is necessary in order to avoid accidentally getting a non-empty
* string for tcl fn's.
*/
bool save_poll = jtag_poll_get_enabled();
jtag_poll_set_enabled(false);
bool save_poll_mask = jtag_poll_mask();
const char *str = Jim_GetString(argv[1], NULL);
int retcode = Jim_Eval_Named(interp, str, __THIS__FILE__, __LINE__);
jtag_poll_set_enabled(save_poll);
jtag_poll_unmask(save_poll_mask);
command_log_capture_finish(state);