Mercurial > repos > blastem
diff vdp.c @ 2032:441d5d6cea2f
Make KDEBUG functionality play nice with gdb remote debugging
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 20 Feb 2021 14:52:32 -0800 |
parents | bcc85f6b06c2 |
children | a61b47d5489e |
line wrap: on
line diff
--- a/vdp.c Sat Feb 20 14:51:45 2021 -0800 +++ b/vdp.c Sat Feb 20 14:52:32 2021 -0800 @@ -3809,14 +3809,24 @@ context->kmod_msg_buffer[context->kmod_buffer_length - 1] = c; } else if (context->kmod_buffer_length) { context->kmod_msg_buffer[context->kmod_buffer_length] = 0; - init_terminal(); - printf("KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer); + if (is_stdout_enabled()) { + init_terminal(); + printf("KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer); + } else { + // GDB remote debugging is enabled, use stderr instead + fprintf(stderr, "KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer); + } context->kmod_buffer_length = 0; } } else if (reg == REG_KMOD_TIMER) { if (!(value & 0x80)) { - init_terminal(); - printf("KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7); + if (is_stdout_enabled()) { + init_terminal(); + printf("KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7); + } else { + // GDB remote debugging is enabled, use stderr instead + fprintf(stderr, "KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7); + } } if (value & 0xC0) { context->timer_start_cycle = context->cycles;