changeset 2424:767ec72acca7

Avoid conflicts between watchpoints and normal debugger entry
author Michael Pavone <pavone@retrodev.com>
date Wed, 24 Jan 2024 18:51:44 -0800
parents b733a10488c6
children 794ba17f0716
files genesis.c m68k_core.c sms.c z80_to_x86.c
diffstat 4 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/genesis.c	Sat Jan 20 21:16:04 2024 -0800
+++ b/genesis.c	Wed Jan 24 18:51:44 2024 -0800
@@ -370,7 +370,7 @@
 	}
 
 	context->target_cycle = context->int_cycle < context->sync_cycle ? context->int_cycle : context->sync_cycle;
-	if (context->should_return || gen->header.enter_debugger) {
+	if (context->should_return || gen->header.enter_debugger || context->wp_hit) {
 		context->target_cycle = context->current_cycle;
 	} else if (context->target_cycle < context->current_cycle) {
 		//Changes to SR can result in an interrupt cycle that's in the past
@@ -611,8 +611,10 @@
 		context->target_cycle = gen->reset_cycle;
 	}
 	if (address) {
-		if (gen->header.enter_debugger) {
-			gen->header.enter_debugger = 0;
+		if (gen->header.enter_debugger || context->wp_hit) {
+			if (!context->wp_hit) {
+				gen->header.enter_debugger = 0;
+			}
 #ifndef IS_LIB
 			if (gen->header.debugger_type == DEBUGGER_NATIVE) {
 				debugger(context, address);
--- a/m68k_core.c	Sat Jan 20 21:16:04 2024 -0800
+++ b/m68k_core.c	Wed Jan 24 18:51:44 2024 -0800
@@ -867,7 +867,6 @@
 	context->wp_hit = 1;
 	context->target_cycle = context->sync_cycle = context->current_cycle;
 	system_header *system = context->system;
-	system->enter_debugger = 1;
 	return vcontext;
 }
 
@@ -892,7 +891,6 @@
 	context->wp_hit = 1;
 	context->target_cycle = context->sync_cycle = context->current_cycle;
 	system_header *system = context->system;
-	system->enter_debugger = 1;
 	return vcontext;
 }
 
--- a/sms.c	Sat Jan 20 21:16:04 2024 -0800
+++ b/sms.c	Wed Jan 24 18:51:44 2024 -0800
@@ -478,8 +478,10 @@
 				}
 			}
 		}
-		if (system->enter_debugger && sms->z80->pc) {
-			system->enter_debugger = 0;
+		if ((system->enter_debugger || sms->z80->wp_hit) && sms->z80->pc) {
+			if (!sms->z80->wp_hit) {
+				system->enter_debugger = 0;
+			}
 #ifndef IS_LIB
 			zdebugger(sms->z80, sms->z80->pc);
 #endif
@@ -495,7 +497,7 @@
 			}
 		}
 
-		if (system->enter_debugger) {
+		if (system->enter_debugger || sms->z80->wp_hit) {
 			target_cycle = sms->z80->Z80_CYCLE + 1;
 		}
 		z80_run(sms->z80, target_cycle);
--- a/z80_to_x86.c	Sat Jan 20 21:16:04 2024 -0800
+++ b/z80_to_x86.c	Wed Jan 24 18:51:44 2024 -0800
@@ -3923,7 +3923,6 @@
 	context->wp_hit = 1;
 	context->target_cycle = context->sync_cycle = context->current_cycle;
 	system_header *system = context->system;
-	system->enter_debugger = 1;
 	return vcontext;
 }