From a460f11a88ad30ff938327428e53319518cfdce4 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 20 Mar 2019 22:05:27 -0700 Subject: Avoid printing a bunch of junk to stdout when GDB remote debugging is enabled as this can confuse GDB --- util.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 88a6d4f..26dfc9c 100644 --- a/util.c +++ b/util.c @@ -477,13 +477,16 @@ void warning(char *format, ...) va_end(args); } +static uint8_t output_enabled = 1; void info_message(char *format, ...) { va_list args; va_start(args, format); #ifndef _WIN32 if (headless || (isatty(STDOUT_FILENO) && isatty(STDIN_FILENO))) { - info_printf(format, args); + if (output_enabled) { + info_printf(format, args); + } } else { #endif int32_t size = strlen(format) * 2; @@ -503,7 +506,9 @@ void info_message(char *format, ...) va_start(args, format); vsnprintf(buf, actual, format, args); } - info_puts(buf); + if (output_enabled) { + info_puts(buf); + } render_infobox("BlastEm Info", buf); free(buf); #ifndef _WIN32 @@ -512,6 +517,20 @@ void info_message(char *format, ...) va_end(args); } +void debug_message(char *format, ...) +{ + va_list args; + va_start(args, format); + if (output_enabled) { + info_printf(format, args); + } +} + +void disable_stdout_messages(void) +{ + output_enabled = 0; +} + #ifdef _WIN32 #include #include -- cgit v1.2.3