comparison 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
comparison
equal deleted inserted replaced
2031:0757da8ee702 2032:441d5d6cea2f
3807 context->kmod_msg_buffer = realloc(context->kmod_msg_buffer, context->kmod_buffer_storage); 3807 context->kmod_msg_buffer = realloc(context->kmod_msg_buffer, context->kmod_buffer_storage);
3808 } 3808 }
3809 context->kmod_msg_buffer[context->kmod_buffer_length - 1] = c; 3809 context->kmod_msg_buffer[context->kmod_buffer_length - 1] = c;
3810 } else if (context->kmod_buffer_length) { 3810 } else if (context->kmod_buffer_length) {
3811 context->kmod_msg_buffer[context->kmod_buffer_length] = 0; 3811 context->kmod_msg_buffer[context->kmod_buffer_length] = 0;
3812 init_terminal(); 3812 if (is_stdout_enabled()) {
3813 printf("KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer); 3813 init_terminal();
3814 printf("KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer);
3815 } else {
3816 // GDB remote debugging is enabled, use stderr instead
3817 fprintf(stderr, "KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer);
3818 }
3814 context->kmod_buffer_length = 0; 3819 context->kmod_buffer_length = 0;
3815 } 3820 }
3816 } else if (reg == REG_KMOD_TIMER) { 3821 } else if (reg == REG_KMOD_TIMER) {
3817 if (!(value & 0x80)) { 3822 if (!(value & 0x80)) {
3818 init_terminal(); 3823 if (is_stdout_enabled()) {
3819 printf("KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7); 3824 init_terminal();
3825 printf("KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7);
3826 } else {
3827 // GDB remote debugging is enabled, use stderr instead
3828 fprintf(stderr, "KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7);
3829 }
3820 } 3830 }
3821 if (value & 0xC0) { 3831 if (value & 0xC0) {
3822 context->timer_start_cycle = context->cycles; 3832 context->timer_start_cycle = context->cycles;
3823 } 3833 }
3824 } 3834 }