diff options
author | Michael Pavone <pavone@retrodev.com> | 2021-02-20 14:52:32 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2021-02-20 14:52:32 -0800 |
commit | c9d42388d53aee083e6cb477b1017c49a9ea8bd9 (patch) | |
tree | 4718415a0759f76f42abe4177a4bc67e7f5c5c0a /vdp.c | |
parent | 472da34d7ac2915a4f21ea6b5c02475abc3619e3 (diff) |
Make KDEBUG functionality play nice with gdb remote debugging
Diffstat (limited to 'vdp.c')
-rw-r--r-- | vdp.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -3809,14 +3809,24 @@ int vdp_control_port_write(vdp_context * context, uint16_t value) 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; |