helper: fix flaky capture command
authorØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 20 Sep 2010 09:50:32 +0000 (11:50 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 20 Sep 2010 18:45:48 +0000 (20:45 +0200)
capture of progress output would get polling
results. This will break in the example below
where polling output would override the tcl
return value.

capture {sleep 10000; set abc def}

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/helper/command.c

index 086b03d3e0b068ade1175f1e2346b700da88ec23..1bd8c42912656e263a792817fc8b5752db00b62e 100644 (file)
@@ -36,6 +36,7 @@
 #endif
 
 // @todo the inclusion of target.h here is a layering violation
+#include <jtag/jtag.h>
 #include <target/target.h>
 #include "command.h"
 #include "configuration.h"
@@ -867,6 +868,9 @@ static char* openocd_jim_fgets(char *s, int size, void *cookie)
        return NULL;
 }
 
+/* Capture progress output and return as tcl return value. If the
+ * progress output was empty, return tcl return value.
+ */
 static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 {
        if (argc != 2)
@@ -874,9 +878,21 @@ static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
        struct log_capture_state *state = command_log_capture_start(interp);
 
+       /* disable polling during capture. This avoids capturing output
+        * from polling.
+        *
+        * This is necessary in order to avoid accidentially getting a non-empty
+        * string for tcl fn's.
+        */
+       bool save_poll = jtag_poll_get_enabled();
+
+       jtag_poll_set_enabled(false);
+
        const char *str = Jim_GetString(argv[1], NULL);
        int retcode = Jim_Eval_Named(interp, str, __THIS__FILE__, __LINE__);
 
+       jtag_poll_set_enabled(save_poll);
+
        command_log_capture_finish(state);
 
        return retcode;

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)