Mercurial > repos > blastem
diff util.c @ 1792:52a47611a273
Avoid printing a bunch of junk to stdout when GDB remote debugging is enabled as this can confuse GDB
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 20 Mar 2019 22:05:27 -0700 |
parents | eda8df5bc74c |
children | 243f3a7247f9 |
line wrap: on
line diff
--- a/util.c Wed Mar 20 21:36:32 2019 -0700 +++ b/util.c Wed Mar 20 22:05:27 2019 -0700 @@ -477,13 +477,16 @@ 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 @@ 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 @@ 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 <windows.h> #include <shlobj.h>