summaryrefslogtreecommitdiff
path: root/src/helper/log.c
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-07-18 10:20:10 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-07-18 10:20:10 +0000
commit94e75e0c06c4d683b33a03aee17b80c8a59bbd47 (patch)
tree0119048c905e9fa2d382ac62f69223b2de376092 /src/helper/log.c
parent7648d6b28793e8eb436a56682915185cb819ff5e (diff)
downloadopenocd_libswd-94e75e0c06c4d683b33a03aee17b80c8a59bbd47.tar.gz
openocd_libswd-94e75e0c06c4d683b33a03aee17b80c8a59bbd47.tar.bz2
openocd_libswd-94e75e0c06c4d683b33a03aee17b80c8a59bbd47.tar.xz
openocd_libswd-94e75e0c06c4d683b33a03aee17b80c8a59bbd47.zip
1. GDB will print cryptic error messages if it is not fed keep-alive packets
within the last 2000ms. To fix this, add keep_alive() if you are spending >1000ms in an algorithm thus holding up the server loop. target_call_timer_callbacks() invokes keep_alive(). 2. post_reset script is now executed at normal JTAG speed and not reset speed. 3. Resume is now synchronous again. Hopefully it will work this time. git-svn-id: svn://svn.berlios.de/openocd/trunk@826 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper/log.c')
-rw-r--r--src/helper/log.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/helper/log.c b/src/helper/log.c
index e9c1fa20..0a416244 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -40,6 +40,9 @@ int debug_level = -1;
static FILE* log_output;
static log_callback_t *log_callbacks = NULL;
+static long long last_time;
+static long long current_time;
+
static long long start;
static char *log_strings[5] =
@@ -229,6 +232,8 @@ int log_init(struct command_context_s *cmd_ctx)
log_output = stderr;
}
+ start=last_time=timeval_ms();
+
return ERROR_OK;
}
@@ -327,3 +332,43 @@ char *alloc_printf(const char *format, ...)
va_end(ap);
return string;
}
+
+/* Code must return to the server loop before 1000ms has returned or invoke
+ * this function.
+ *
+ * The GDB connection will time out if it spends >2000ms and you'll get nasty
+ * error messages from GDB:
+ *
+ * Ignoring packet error, continuing...
+ * Reply contains invalid hex digit 116
+ *
+ * While it is possible use "set remotetimeout" to more than the default 2000ms
+ * in GDB, OpenOCD guarantees that it sends keep-alive packages on the
+ * GDB protocol and it is a bug in OpenOCD not to either return to the server
+ * loop or invoke keep_alive() every 1000ms.
+ *
+ * This function will send a keep alive packet if >500ms has passed since last time
+ * it was invoked.
+ *
+ */
+void keep_alive()
+{
+ current_time=timeval_ms();
+ if (current_time-last_time>1000)
+ {
+ LOG_WARNING("keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (%d)", current_time-last_time);
+ last_time=current_time;
+ } else if (current_time-last_time>500)
+ {
+ /* this will keep the GDB connection alive */
+ LOG_USER_N("%s", "");
+ last_time=current_time;
+ }
+}
+
+/* reset keep alive timer without sending message */
+void kept_alive()
+{
+ current_time=timeval_ms();
+ last_time=current_time;
+}