[Scummvm-cvs-logs] SF.net SVN: scummvm:[42043] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Jul 3 01:16:40 CEST 2009


Revision: 42043
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42043&view=rev
Author:   thebluegr
Date:     2009-07-02 23:16:40 +0000 (Thu, 02 Jul 2009)

Log Message:
-----------
Moved all the debug state variables in a separate struct and re-enabled several places where they're used

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/debug.h
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-07-02 22:34:59 UTC (rev 42042)
+++ scummvm/trunk/engines/sci/console.cpp	2009-07-02 23:16:40 UTC (rev 42043)
@@ -54,6 +54,7 @@
 int g_debug_seeking = 0; // Stepping forward until some special condition is met
 int g_debug_seek_special = 0;  // Used for special seeks
 int g_debug_seek_level = 0; // Used for seekers that want to check their exec stack depth
+extern DebugState debugState;
 
 Console::Console(SciEngine *vm) : GUI::Debugger() {
 	_vm = vm;
@@ -522,16 +523,13 @@
 
 bool Console::cmdRegisters(int argc, const char **argv) {
 	DebugPrintf("Current register values:\n");
-#if 0
-		// TODO: p_restadjust
-	DebugPrintf("acc=%04x:%04x prev=%04x:%04x &rest=%x\n", PRINT_REG(_vm->_gamestate->r_acc), PRINT_REG(_vm->_gamestate->r_prev), *p_restadjust);
-#endif
+	DebugPrintf("acc=%04x:%04x prev=%04x:%04x &rest=%x\n", PRINT_REG(_vm->_gamestate->r_acc), PRINT_REG(_vm->_gamestate->r_prev), *debugState.p_restadjust);
 
 	if (!_vm->_gamestate->_executionStack.empty()) {
-#if 0
-		// TODO: p_pc, p_objp, p_pp, p_sp
-		DebugPrintf("pc=%04x:%04x obj=%04x:%04x fp=ST:%04x sp=ST:%04x\n", PRINT_REG(*p_pc), PRINT_REG(*p_objp), PRINT_STK(*p_pp), PRINT_STK(*p_sp));
-#endif
+		EngineState *s = _vm->_gamestate;	// for PRINT_STK
+		DebugPrintf("pc=%04x:%04x obj=%04x:%04x fp=ST:%04x sp=ST:%04x\n", 
+					PRINT_REG(*debugState.p_pc), PRINT_REG(*debugState.p_objp), 
+					PRINT_STK(*debugState.p_pp), PRINT_STK(*debugState.p_sp));
 	} else
 		DebugPrintf("<no execution stack: pc,obj,fp omitted>\n");
 
@@ -1689,20 +1687,16 @@
 }
 
 bool Console::cmdVMVarlist(int argc, const char **argv) {
-	//const char *varnames[] = {"global", "local", "temp", "param"};
+	const char *varnames[] = {"global", "local", "temp", "param"};
 
 	DebugPrintf("Addresses of variables in the VM:\n");
 
-#if 0
-	// TODO: p_var_segs, p_vars, p_var_base, p_var_max
-
 	for (int i = 0; i < 4; i++) {
-		DebugPrintf("%s vars at %04x:%04x ", varnames[i], PRINT_REG(make_reg(p_var_segs[i], p_vars[i] - p_var_base[i])));
-		if (p_var_max)
-			DebugPrintf("  total %d", p_var_max[i]);
+		DebugPrintf("%s vars at %04x:%04x ", varnames[i], PRINT_REG(make_reg(debugState.p_var_segs[i], debugState.p_vars[i] - debugState.p_var_base[i])));
+		if (debugState.p_var_max)
+			DebugPrintf("  total %d", debugState.p_var_max[i]);
 		DebugPrintf("\n");
 	}
-#endif
 
 	return true;
 }
@@ -1718,7 +1712,7 @@
 		return true;
 	}
 
-	//const char *varnames[] = {"global", "local", "temp", "param"};
+	const char *varnames[] = {"global", "local", "temp", "param"};
 	const char *varabbrev = "gltp";
 	const char *vartype_pre = strchr(varabbrev, *argv[1]);
 	int vartype;
@@ -1736,31 +1730,21 @@
 		return true;
 	}
 
-#if 0
-	// TODO: p_var_max
-	if ((p_var_max) && (p_var_max[vartype] <= idx)) {
-		DebugPrintf("Max. index is %d (0x%x)\n", p_var_max[vartype], p_var_max[vartype]);
+	if ((debugState.p_var_max) && (debugState.p_var_max[vartype] <= idx)) {
+		DebugPrintf("Max. index is %d (0x%x)\n", debugState.p_var_max[vartype], debugState.p_var_max[vartype]);
 		return true;
 	}
-#endif
 
 	switch (argc) {
 	case 2:
-#if 0
-		// TODO: p_vars
-		DebugPrintf("%s var %d == %04x:%04x\n", varnames[vartype], idx, PRINT_REG(p_vars[vartype][idx]));
-#endif
+		DebugPrintf("%s var %d == %04x:%04x\n", varnames[vartype], idx, PRINT_REG(debugState.p_vars[vartype][idx]));
 		break;
 	case 3:
-#if 0
-		// TODO: p_vars
-
-		if (parse_reg_t(_vm->_gamestate, argv[3], &p_vars[vartype][idx])) {
+		if (parse_reg_t(_vm->_gamestate, argv[3], &debugState.p_vars[vartype][idx])) {
 			DebugPrintf("Invalid address passed.\n");
 			DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 			return true;
 		}
-#endif
 		break;
 	default:
 		DebugPrintf("Too many arguments\n");
@@ -1995,12 +1979,8 @@
 
 bool Console::cmdViewActiveObject(int argc, const char **argv) {
 	DebugPrintf("Information on the currently active object or class:\n");
+	printObject(_vm->_gamestate, *debugState.p_objp);
 
-#if 0
-	// TODO: p_objp
-	printObject(_vm->_gamestate, *p_objp);
-#endif
-
 	return true;
 }
 

Modified: scummvm/trunk/engines/sci/debug.h
===================================================================
--- scummvm/trunk/engines/sci/debug.h	2009-07-02 22:34:59 UTC (rev 42042)
+++ scummvm/trunk/engines/sci/debug.h	2009-07-02 23:16:40 UTC (rev 42043)
@@ -45,6 +45,18 @@
 extern int g_debug_seek_special;
 extern int g_debug_seek_level;
 
+struct DebugState {
+	reg_t *p_pc;
+	StackPtr *p_sp;
+	StackPtr *p_pp;
+	reg_t *p_objp;
+	int *p_restadjust;
+	SegmentId *p_var_segs;
+	reg_t **p_vars;
+	reg_t **p_var_base;
+	int *p_var_max; // May be NULL even in valid state!
+};
+
 } // End of namespace Sci
 
 #endif

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-07-02 22:34:59 UTC (rev 42042)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-07-02 23:16:40 UTC (rev 42043)
@@ -36,18 +36,10 @@
 int g_debug_step_running = 0; // Set to >0 to allow multiple stepping
 extern int g_debug_seek_special;
 
-static reg_t *p_pc;
-static StackPtr *p_sp;
-static StackPtr *p_pp;
-static reg_t *p_objp;
-static int *p_restadjust;
-static SegmentId *p_var_segs;
-static reg_t **p_vars;
-static reg_t **p_var_base;
-static int *p_var_max; // May be NULL even in valid state!
-
 extern const char *selector_name(EngineState *s, int selector);
 
+DebugState debugState;
+
 int propertyOffsetToId(EngineState *s, int prop_ofs, reg_t objp) {
 	Object *obj = obj_get(s, objp);
 	byte *selectoroffset;
@@ -238,11 +230,11 @@
 		}
 	}
 
-	if (pos == *p_pc) { // Extra information if debugging the current opcode
+	if (pos == *debugState.p_pc) { // Extra information if debugging the current opcode
 		if ((opcode == op_pTos) || (opcode == op_sTop) || (opcode == op_pToa) || (opcode == op_aTop) ||
 		        (opcode == op_dpToa) || (opcode == op_ipToa) || (opcode == op_dpTos) || (opcode == op_ipTos)) {
 			int prop_ofs = scr[pos.offset + 1];
-			int prop_id = propertyOffsetToId(s, prop_ofs, *p_objp);
+			int prop_id = propertyOffsetToId(s, prop_ofs, *debugState.p_objp);
 
 			sciprintf("	(%s)", selector_name(s, prop_id));
 		}
@@ -250,38 +242,38 @@
 
 	sciprintf("\n");
 
-	if (pos == *p_pc) { // Extra information if debugging the current opcode
+	if (pos == *debugState.p_pc) { // Extra information if debugging the current opcode
 		if (opcode == op_callk) {
-			int stackframe = (scr[pos.offset + 2] >> 1) + (*p_restadjust);
-			int argc = ((*p_sp)[- stackframe - 1]).offset;
+			int stackframe = (scr[pos.offset + 2] >> 1) + (*debugState.p_restadjust);
+			int argc = ((*debugState.p_sp)[- stackframe - 1]).offset;
 
 			if (!(s->_flags & GF_SCI0_OLD))
-				argc += (*p_restadjust);
+				argc += (*debugState.p_restadjust);
 
 			sciprintf(" Kernel params: (");
 
 			for (int j = 0; j < argc; j++) {
-				sciprintf("%04x:%04x", PRINT_REG((*p_sp)[j - stackframe]));
+				sciprintf("%04x:%04x", PRINT_REG((*debugState.p_sp)[j - stackframe]));
 				if (j + 1 < argc)
 					sciprintf(", ");
 			}
 			sciprintf(")\n");
 		} else if ((opcode == op_send) || (opcode == op_self)) {
-			int restmod = *p_restadjust;
+			int restmod = *debugState.p_restadjust;
 			int stackframe = (scr[pos.offset + 1] >> 1) + restmod;
-			reg_t *sb = *p_sp;
+			reg_t *sb = *debugState.p_sp;
 			uint16 selector;
 			reg_t fun_ref;
 
 			while (stackframe > 0) {
 				int argc = sb[- stackframe + 1].offset;
 				const char *name = NULL;
-				reg_t called_obj_addr = *p_objp;
+				reg_t called_obj_addr = *debugState.p_objp;
 
 				if (opcode == op_send)
 					called_obj_addr = s->r_acc;
 				else if (opcode == op_self)
-					called_obj_addr = *p_objp;
+					called_obj_addr = *debugState.p_objp;
 
 				selector = sb[- stackframe].offset;
 
@@ -331,15 +323,15 @@
 
 	int old_debugstate = g_debugstate_valid;
 
-	p_var_segs = segids;
-	p_vars = variables;
-	p_var_max = variables_nr;
-	p_var_base = variables_base;
-	p_pc = pc;
-	p_sp = sp;
-	p_pp = pp;
-	p_objp = objp;
-	p_restadjust = restadjust;
+	debugState.p_var_segs = segids;
+	debugState.p_vars = variables;
+	debugState.p_var_max = variables_nr;
+	debugState.p_var_base = variables_base;
+	debugState.p_pc = pc;
+	debugState.p_sp = sp;
+	debugState.p_pp = pp;
+	debugState.p_objp = objp;
+	debugState.p_restadjust = restadjust;
 	sciprintf("%d: acc=%04x:%04x  ", script_step_counter, PRINT_REG(s->r_acc));
 	g_debugstate_valid = 1;
 	disassemble(s, *pc, 0, 1);
@@ -399,15 +391,15 @@
 	g_debugstate_valid = (g_debug_step_running == 0);
 
 	if (g_debugstate_valid) {
-		p_pc = pc;
-		p_sp = sp;
-		p_pp = pp;
-		p_objp = objp;
-		p_restadjust = restadjust;
-		p_var_segs = segids;
-		p_vars = variables;
-		p_var_max = variables_nr;
-		p_var_base = variables_base;
+		debugState.p_pc = pc;
+		debugState.p_sp = sp;
+		debugState.p_pp = pp;
+		debugState.p_objp = objp;
+		debugState.p_restadjust = restadjust;
+		debugState.p_var_segs = segids;
+		debugState.p_vars = variables;
+		debugState.p_var_max = variables_nr;
+		debugState.p_var_base = variables_base;
 		
 		sciprintf("Step #%d\n", script_step_counter);
 		disassemble(s, *pc, 0, 1);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list