#include "command.h"
#include "replacements.h"
#include "time_support.h"
+#include <server/server.h>
#include <stdarg.h>
if (f)
file = f + 1;
- if (strlen(string) > 0) {
- if (debug_level >= LOG_LVL_DEBUG) {
- /* print with count and time information */
- int64_t t = timeval_ms() - start;
+ if (debug_level >= LOG_LVL_DEBUG) {
+ /* print with count and time information */
+ int64_t t = timeval_ms() - start;
#ifdef _DEBUG_FREE_SPACE_
- struct mallinfo info;
- info = mallinfo();
+ struct mallinfo info;
+ info = mallinfo();
#endif
- fprintf(log_output, "%s%d %" PRId64 " %s:%d %s()"
+ fprintf(log_output, "%s%d %" PRId64 " %s:%d %s()"
#ifdef _DEBUG_FREE_SPACE_
- " %d"
+ " %d"
#endif
- ": %s", log_strings[level + 1], count, t, file, line, function,
+ ": %s", log_strings[level + 1], count, t, file, line, function,
#ifdef _DEBUG_FREE_SPACE_
- info.fordblks,
+ info.fordblks,
#endif
- string);
- } else {
- /* if we are using gdb through pipes then we do not want any output
- * to the pipe otherwise we get repeated strings */
- fprintf(log_output, "%s%s",
- (level > LOG_LVL_USER) ? log_strings[level + 1] : "", string);
- }
+ string);
} else {
- /* Empty strings are sent to log callbacks to keep e.g. gdbserver alive, here we do
- *nothing. */
+ /* if we are using gdb through pipes then we do not want any output
+ * to the pipe otherwise we get repeated strings */
+ fprintf(log_output, "%s%s",
+ (level > LOG_LVL_USER) ? log_strings[level + 1] : "", string);
}
fflush(log_output);
last_time = current_time;
/* this will keep the GDB connection alive */
- LOG_USER_N("%s", "");
+ server_keep_clients_alive();
/* DANGER!!!! do not add code to invoke e.g. target event processing,
* jim timer processing, etc. it can cause infinite recursion +
return ERROR_OK;
}
+static void gdb_keep_client_alive(struct connection *connection)
+{
+ struct gdb_connection *gdb_con = connection->priv;
+
+ if (gdb_con->busy) {
+ /* do not send packets, retry asap */
+ return;
+ }
+
+ switch (gdb_con->output_flag) {
+ case GDB_OUTPUT_NO:
+ /* no need for keep-alive */
+ break;
+ case GDB_OUTPUT_ALL:
+ /* send an empty O packet */
+ gdb_output_con(connection, "");
+ break;
+ default:
+ break;
+ }
+}
+
static const struct service_driver gdb_service_driver = {
.name = "gdb",
.new_connection_during_keep_alive_handler = NULL,
.new_connection_handler = gdb_new_connection,
.input_handler = gdb_input,
.connection_closed_handler = gdb_connection_closed,
- .keep_client_alive_handler = NULL,
+ .keep_client_alive_handler = gdb_keep_client_alive,
};
static int gdb_target_start(struct target *target, const char *port)