From c959694b4b9ce1a7b05a220f07f4e46a0b0de495 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 25 Mar 2017 19:25:33 +0200 Subject: [PATCH] Serial log without generic logging: show only serial messages. --- include/sysdeps.h | 10 +++++---- od-win32/serial_win32.cpp | 3 ++- od-win32/writelog.cpp | 45 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/include/sysdeps.h b/include/sysdeps.h index f8d9218d..887b1733 100644 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -439,11 +439,13 @@ extern void mallocemu_free (void *ptr); #endif #if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 6 -extern void write_log (const TCHAR *, ...); -extern void write_log (const char *, ...) __attribute__ ((format (printf, 1, 2))); +extern void write_log(const TCHAR *, ...); +extern void write_logx(const TCHAR *, ...); +extern void write_log(const char *, ...) __attribute__ ((format (printf, 1, 2))); #else -extern void write_log (const TCHAR *, ...); -extern void write_log (const char *, ...); +extern void write_log(const TCHAR *, ...); +extern void write_logx(const TCHAR *, ...); +extern void write_log(const char *, ...); #endif extern void write_dlog (const TCHAR *, ...); extern int read_log(void); diff --git a/od-win32/serial_win32.cpp b/od-win32/serial_win32.cpp index 9a77eae5..1e9bfada 100644 --- a/od-win32/serial_win32.cpp +++ b/od-win32/serial_win32.cpp @@ -227,6 +227,7 @@ void SERPER (uae_u16 w) if (log_sercon) { serial_period_hsyncs = 1; seriallog = 1; + write_logx(_T("\n")); } serial_period_hsync_counter = 0; @@ -476,7 +477,7 @@ static void serdatcopy(void) if (seriallog) { gotlogwrite = true; - write_log(_T("%c"), docharlog(serdatshift_masked)); + write_logx(_T("%c"), docharlog(serdatshift_masked)); } if (serper == 372) { diff --git a/od-win32/writelog.cpp b/od-win32/writelog.cpp index 70c503f0..a6b679cb 100644 --- a/od-win32/writelog.cpp +++ b/od-win32/writelog.cpp @@ -68,6 +68,7 @@ int console_logging = 0; static int debugger_type = -1; extern BOOL debuggerinitializing; extern int lof_store; +extern int seriallog; static int console_input_linemode = -1; int always_flush_log = 1; @@ -550,6 +551,47 @@ void write_log (const char *format, ...) va_end (parms); } +void write_logx(const TCHAR *format, ...) +{ + int count; + TCHAR buffer[WRITE_LOG_BUF_SIZE]; + int bufsize = WRITE_LOG_BUF_SIZE; + TCHAR *bufp; + va_list parms; + + if (!cs_init) + return; + + EnterCriticalSection (&cs); + va_start (parms, format); + bufp = buffer; + for (;;) { + count = _vsntprintf (bufp, bufsize - 1, format, parms); + if (count < 0) { + bufsize *= 10; + if (bufp != buffer) + xfree (bufp); + bufp = xmalloc (TCHAR, bufsize); + continue; + } + break; + } + bufp[bufsize - 1] = 0; + if (1) { + writeconsole (bufp); + } + if (debugfile) { + _ftprintf (debugfile, _T("%s"), bufp); + } + lfdetected = 0; + if (_tcslen (bufp) > 0 && bufp[_tcslen (bufp) - 1] == '\n') + lfdetected = 1; + va_end (parms); + if (bufp != buffer) + xfree (bufp); + LeaveCriticalSection (&cs); +} + void write_log (const TCHAR *format, ...) { int count; @@ -558,6 +600,9 @@ void write_log (const TCHAR *format, ...) TCHAR *bufp; va_list parms; + if (!SHOW_CONSOLE && !console_logging && !debugfile) + return; + if (!cs_init) return; -- 2.47.3