From 47d044934727c3d5a57658ddd324b407dd73860a Mon Sep 17 00:00:00 2001 From: ntfreak Date: Mon, 15 Dec 2008 09:43:26 +0000 Subject: - add ability for openocd to communicate to gdb using pipes (stdin/stdout). - this is enabled by new command line option option --pipe. git-svn-id: svn://svn.berlios.de/openocd/trunk@1242 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/helper/log.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/helper/log.c') diff --git a/src/helper/log.c b/src/helper/log.c index d21b8e9f..8e320084 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -31,6 +31,7 @@ #include "configuration.h" #include "time_support.h" #include "command.h" +#include "server.h" #include #include @@ -108,9 +109,11 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch #endif string); } - else + else if(server_use_pipes == 0) { - if (strcmp(string, "\n")!=0) + /* if we are using gdb through pipes then we do not want any output + * to the pipe otherwise we get repeated strings */ + if (strcmp(string, "\n") != 0) { /* print human readable output - but skip empty lines */ fprintf(log_output, "%s%s", @@ -203,6 +206,18 @@ int handle_debug_level_command(struct command_context_s *cmd_ctx, char *cmd, cha if (debug_level > 3) debug_level = 3; + if (debug_level >= LOG_LVL_DEBUG && server_use_pipes == 1) + { + /* if we are enabling debug info then we need to write to a log file + * otherwise the pipe will get full and cause issues with gdb */ + FILE* file = fopen("openocd.log", "w"); + if (file) + { + log_output = file; + LOG_WARNING("enabling log output as we are using pipes"); + } + } + return ERROR_OK; } -- cgit v1.2.3