changeset 849:1416c4261d5b

Fix some debug commands that got broken when I added support for the command command
author Michael Pavone <pavone@retrodev.com>
date Sun, 01 Nov 2015 20:39:40 -0800
parents 7068a9db6dd0
children 215b5dabbc20
files debug.c
diffstat 1 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/debug.c	Sun Nov 01 12:55:08 2015 -0800
+++ b/debug.c	Sun Nov 01 20:39:40 2015 -0800
@@ -515,12 +515,11 @@
 static uint32_t branch_t;
 static uint32_t branch_f;
 
-int run_debugger_command(m68k_context *context, char *input_buf)
+int run_debugger_command(m68k_context *context, char *input_buf, m68kinst inst, uint32_t after)
 {
-	m68kinst inst;
 	char * param;
 	char format_char;
-	uint32_t value, after;
+	uint32_t value;
 	bp_def *new_bp, **this_bp;
 	switch(input_buf[0])
 	{
@@ -845,6 +844,17 @@
 		}
 		branch_t = branch_f = 0;
 	}
+
+	uint16_t * pc;
+	if (address < 0x400000) {
+		pc = cart + address/2;
+	} else if(address > 0xE00000) {
+		pc = ram + (address & 0xFFFF)/2;
+	} else {
+		fatal_error("Entered 68K debugger at address %X\n", address);
+	}
+	uint16_t * after_pc = m68k_decode(pc, &inst, address);
+	uint32_t after = address + (after_pc-pc)*2;
 	int debugging = 1;
 	//Check if this is a user set breakpoint, or just a temporary one
 	bp_def ** this_bp = find_breakpoint(&breakpoints, address);
@@ -860,7 +870,7 @@
 				char *cmd = commands;
 				strip_nl(cmd);
 				commands += strlen(cmd) + 1;
-				debugging = run_debugger_command(context, cmd);
+				debugging = run_debugger_command(context, cmd, inst, after);
 			}
 			free(copy);
 		}
@@ -875,18 +885,8 @@
 	for (disp_def * cur = displays; cur; cur = cur->next) {
 		debugger_print(context, cur->format_char, cur->param);
 	}
-	uint16_t * pc;
-	if (address < 0x400000) {
-		pc = cart + address/2;
-	} else if(address > 0xE00000) {
-		pc = ram + (address & 0xFFFF)/2;
-	} else {
-		fatal_error("Entered 68K debugger at address %X\n", address);
-	}
-	uint16_t * after_pc = m68k_decode(pc, &inst, address);
 	m68k_disasm(&inst, input_buf);
 	printf("%X: %s\n", address, input_buf);
-	uint32_t after = address + (after_pc-pc)*2;
 #ifdef _WIN32
 #define prompt 1
 #else
@@ -923,7 +923,7 @@
 		} else {
 			strcpy(input_buf, last_cmd);
 		}
-		debugging = run_debugger_command(context, input_buf);
+		debugging = run_debugger_command(context, input_buf, inst, after);
 	}
 	return context;
 }