target: avoid polling during 'resumed' event handler
[openocd.git] / src / target / target.c
index fa98c884b8b6730d84ceda843eb38e40c8dfeba0..cab84b06be9640eafec16a689038c678f96f89a7 100644 (file)
@@ -637,7 +637,18 @@ int target_resume(struct target *target, int current, target_addr_t address,
         * we poll. The CPU can even halt at the current PC as a result of
         * a software breakpoint being inserted by (a bug?) the application.
         */
+       /*
+        * resume() triggers the event 'resumed'. The execution of TCL commands
+        * in the event handler causes the polling of targets. If the target has
+        * already halted for a breakpoint, polling will run the 'halted' event
+        * handler before the pending 'resumed' handler.
+        * Disable polling during resume() to guarantee the execution of handlers
+        * in the correct order.
+        */
+       bool save_poll = jtag_poll_get_enabled();
+       jtag_poll_set_enabled(false);
        retval = target->type->resume(target, current, address, handle_breakpoints, debug_execution);
+       jtag_poll_set_enabled(save_poll);
        if (retval != ERROR_OK)
                return retval;
 
@@ -4056,7 +4067,7 @@ COMMAND_HANDLER(handle_wp_command)
        }
 
        enum watchpoint_rw type = WPT_ACCESS;
-       uint32_t addr = 0;
+       target_addr_t addr = 0;
        uint32_t length = 0;
        uint32_t data_value = 0x0;
        uint32_t data_mask = 0xffffffff;
@@ -4086,7 +4097,7 @@ COMMAND_HANDLER(handle_wp_command)
                /* fall through */
        case 2:
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], length);
-               COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr);
+               COMMAND_PARSE_ADDRESS(CMD_ARGV[0], addr);
                break;
 
        default:
@@ -4106,8 +4117,8 @@ COMMAND_HANDLER(handle_rwp_command)
        if (CMD_ARGC != 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       uint32_t addr;
-       COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr);
+       target_addr_t addr;
+       COMMAND_PARSE_ADDRESS(CMD_ARGV[0], addr);
 
        struct target *target = get_current_target(CMD_CTX);
        watchpoint_remove(target, addr);

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)