Fixed another reset-while-debugging deadlock in Cocoa

This commit is contained in:
Lior Halphon 2016-09-07 00:37:11 +03:00
parent 01fc137256
commit 62ecadeb57
3 changed files with 6 additions and 2 deletions

View File

@ -153,6 +153,7 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
- (void) stop - (void) stop
{ {
if (!running) return; if (!running) return;
gb.debug_disable = true;
if (gb.debug_stopped) { if (gb.debug_stopped) {
gb.debug_stopped = false; gb.debug_stopped = false;
[self consoleInput:nil]; [self consoleInput:nil];
@ -160,6 +161,7 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
stopping = true; stopping = true;
running = false; running = false;
while (stopping); while (stopping);
gb.debug_disable = false;
} }
- (IBAction)reset:(id)sender - (IBAction)reset:(id)sender

View File

@ -1463,6 +1463,8 @@ bool GB_debugger_do_command(GB_gameboy_t *gb, char *input)
void GB_debugger_run(GB_gameboy_t *gb) void GB_debugger_run(GB_gameboy_t *gb)
{ {
if (gb->debug_disable) return;
char *input = NULL; char *input = NULL;
if (gb->debug_next_command && gb->debug_call_depth <= 0) { if (gb->debug_next_command && gb->debug_call_depth <= 0) {
gb->debug_stopped = true; gb->debug_stopped = true;
@ -1482,7 +1484,7 @@ next_command:
GB_log(gb, "Breakpoint: PC = %s\n", value_to_string(gb, gb->pc, true)); GB_log(gb, "Breakpoint: PC = %s\n", value_to_string(gb, gb->pc, true));
GB_cpu_disassemble(gb, gb->pc, 5); GB_cpu_disassemble(gb, gb->pc, 5);
} }
if (gb->debug_stopped) { if (gb->debug_stopped && !gb->debug_disable) {
gb->debug_next_command = false; gb->debug_next_command = false;
gb->debug_fin_command = false; gb->debug_fin_command = false;
gb->stack_leak_detection = false; gb->stack_leak_detection = false;

View File

@ -380,7 +380,7 @@ typedef struct GB_gameboy_s {
size_t ir_queue_length; size_t ir_queue_length;
/*** Debugger ***/ /*** Debugger ***/
volatile bool debug_stopped; volatile bool debug_stopped, debug_disable;
bool debug_fin_command, debug_next_command; bool debug_fin_command, debug_next_command;
/* Breakpoints */ /* Breakpoints */