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

wjpalenstijn at users.sourceforge.net wjpalenstijn at users.sourceforge.net
Sat Jul 18 14:51:12 CEST 2009


Revision: 42587
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42587&view=rev
Author:   wjpalenstijn
Date:     2009-07-18 12:51:12 +0000 (Sat, 18 Jul 2009)

Log Message:
-----------
SCI: Fix stepping in debugger

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

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-07-18 12:08:18 UTC (rev 42586)
+++ scummvm/trunk/engines/sci/console.cpp	2009-07-18 12:51:12 UTC (rev 42587)
@@ -194,6 +194,7 @@
 	scriptState.seekLevel = 0;
 	scriptState.runningStep = 0;
 	scriptState.stopOnEvent = false;
+	scriptState.debugging = false;
 }
 
 Console::~Console() {
@@ -2098,21 +2099,24 @@
 bool Console::cmdStep(int argc, const char **argv) {
 	if (argc == 2 && atoi(argv[1]) > 0)
 		scriptState.runningStep = atoi(argv[1]) - 1;
+	scriptState.debugging = true;
 
-	return true;
+	return false;
 }
 
 bool Console::cmdStepEvent(int argc, const char **argv) {
 	scriptState.stopOnEvent = true;
+	scriptState.debugging = true;
 
-	return true;
+	return false;
 }
 
 bool Console::cmdStepRet(int argc, const char **argv) {
 	scriptState.seeking = kDebugSeekLevelRet;
 	scriptState.seekLevel = _vm->_gamestate->_executionStack.size() - 1;
+	scriptState.debugging = true;
 
-	return true;
+	return false;
 }
 
 bool Console::cmdStepGlobal(int argc, const char **argv) {
@@ -2124,8 +2128,9 @@
 
 	scriptState.seeking = kDebugSeekGlobal;
 	scriptState.seekSpecial = atoi(argv[1]);
+	scriptState.debugging = true;
 
-	return true;
+	return false;
 }
 
 bool Console::cmdStepCallk(int argc, const char **argv) {
@@ -2156,8 +2161,9 @@
 	} else {
 		scriptState.seeking = kDebugSeekCallk;
 	}
+	scriptState.debugging = true;
 
-	return true;
+	return false;
 }
 
 bool Console::cmdDissassemble(int argc, const char **argv) {
@@ -2322,14 +2328,16 @@
 	xstack->fp += argc;
 
 	_vm->_gamestate->_executionStackPosChanged = true;
+	scriptState.debugging = true;
 
-	return true;
+	return false;
 }
 
 bool Console::cmdGo(int argc, const char **argv) {
+	// CHECKME: is this necessary?
 	scriptState.seeking = kDebugSeekNothing;
 
-	return true;
+	return Cmd_Exit(argc, argv);
 }
 
 bool Console::cmdBreakpointList(int argc, const char **argv) {

Modified: scummvm/trunk/engines/sci/debug.h
===================================================================
--- scummvm/trunk/engines/sci/debug.h	2009-07-18 12:08:18 UTC (rev 42586)
+++ scummvm/trunk/engines/sci/debug.h	2009-07-18 12:51:12 UTC (rev 42587)
@@ -38,6 +38,7 @@
 };
 
 struct ScriptState {
+	bool debugging;
 	bool stopOnEvent;
 	DebugSeeking seeking;		// Stepping forward until some special condition is met
 	int runningStep;			// Set to > 0 to allow multiple stepping

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-07-18 12:08:18 UTC (rev 42586)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-07-18 12:51:12 UTC (rev 42587)
@@ -311,12 +311,19 @@
 void script_debug(EngineState *s, bool bp) {
 	// Do we support a separate console?
 
-	printf("%d: acc=%04x:%04x  ", script_step_counter, PRINT_REG(s->r_acc));
-	disassemble(s, scriptState.xs->addr.pc, 0, 1);
-	if (scriptState.seeking == kDebugSeekGlobal)
-		printf("Global %d (0x%x) = %04x:%04x\n", scriptState.seekSpecial,
-		          scriptState.seekSpecial, PRINT_REG(s->script_000->locals_block->_locals[scriptState.seekSpecial]));
+	/* if (sci_debug_flags & _DEBUG_FLAG_LOGGING) { */
+		printf("%d: acc=%04x:%04x  ", script_step_counter, PRINT_REG(s->r_acc));
+		disassemble(s, scriptState.xs->addr.pc, 0, 1);
+		if (scriptState.seeking == kDebugSeekGlobal)
+			printf("Global %d (0x%x) = %04x:%04x\n", scriptState.seekSpecial,
+			          scriptState.seekSpecial, PRINT_REG(s->script_000->locals_block->_locals[scriptState.seekSpecial]));
+	/* } */
 
+#if 0
+	if (!scriptState.debugging)
+		return;
+#endif
+
 	if (scriptState.seeking && !bp) { // Are we looking for something special?
 		MemObject *mobj = GET_SEGMENT(*s->seg_manager, scriptState.xs->addr.pc.segment, MEM_OBJ_SCRIPT);
 
@@ -370,9 +377,19 @@
 			// OK, found whatever we were looking for
 		}
 	}
-	
+
 	printf("Step #%d\n", script_step_counter);
 	disassemble(s, scriptState.xs->addr.pc, 0, 1);
+
+	if (scriptState.runningStep) {
+		scriptState.runningStep--;
+		return;
+	}
+
+	scriptState.debugging = false;
+
+	Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
+	con->attach();
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-07-18 12:08:18 UTC (rev 42586)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-07-18 12:51:12 UTC (rev 42587)
@@ -655,14 +655,16 @@
 		if (script_abort_flag)
 			return; // Emergency
 
-// TODO: re-enable this
-#if 0
 		// Debug if this has been requested:
-		if (script_debug_flag || sci_debug_flags) {
+		// TODO: re-implement sci_debug_flags
+		if (scriptState.debugging /* sci_debug_flags*/) {
 			script_debug(s, breakpointFlag);
 			breakpointFlag = false;
 		}
-#endif
+		Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
+		if (con->isAttached()) {
+			con->onFrame();
+		}
 
 #ifndef DISABLE_VALIDATIONS
 		if (scriptState.xs->sp < scriptState.xs->fp)

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-07-18 12:08:18 UTC (rev 42586)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-07-18 12:51:12 UTC (rev 42587)
@@ -1380,7 +1380,6 @@
 				// Open debug console
 				Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
 				con->attach();
-				con->onFrame();
 
 				// Clear keyboard event
 				input.type = SCI_EVT_NONE;


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