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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sun Jun 27 21:58:32 CEST 2010


Revision: 50388
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50388&view=rev
Author:   m_kiewitz
Date:     2010-06-27 19:58:32 +0000 (Sun, 27 Jun 2010)

Log Message:
-----------
SCI: added new command "p" / "stepover" to execute one command, but skip send/calls processing. single-step is now "trace" (alias "s" and "t"), stepping till ret is "step_ret" (alias "pret"), removed unused kDebugSeek

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h
    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	2010-06-27 18:41:07 UTC (rev 50387)
+++ scummvm/trunk/engines/sci/console.cpp	2010-06-27 19:58:32 UTC (rev 50388)
@@ -156,12 +156,15 @@
 	DCmd_Register("set_acc",			WRAP_METHOD(Console, cmdSetAccumulator));
 	DCmd_Register("backtrace",			WRAP_METHOD(Console, cmdBacktrace));
 	DCmd_Register("bt",					WRAP_METHOD(Console, cmdBacktrace));	// alias
-	DCmd_Register("step",				WRAP_METHOD(Console, cmdStep));
-	DCmd_Register("s",					WRAP_METHOD(Console, cmdStep));			// alias
+	DCmd_Register("trace",				WRAP_METHOD(Console, cmdTrace));
+	DCmd_Register("t",					WRAP_METHOD(Console, cmdTrace));		// alias
+	DCmd_Register("s",					WRAP_METHOD(Console, cmdTrace));		// alias
+	DCmd_Register("stepover",			WRAP_METHOD(Console, cmdStepOver));
+	DCmd_Register("p",					WRAP_METHOD(Console, cmdStepOver));		// alias
+	DCmd_Register("step_ret",			WRAP_METHOD(Console, cmdStepRet));
+	DCmd_Register("pret",				WRAP_METHOD(Console, cmdStepRet));		// alias
 	DCmd_Register("step_event",			WRAP_METHOD(Console, cmdStepEvent));
 	DCmd_Register("se",					WRAP_METHOD(Console, cmdStepEvent));	// alias
-	DCmd_Register("step_ret",			WRAP_METHOD(Console, cmdStepRet));
-	DCmd_Register("sret",				WRAP_METHOD(Console, cmdStepRet));		// alias
 	DCmd_Register("step_global",		WRAP_METHOD(Console, cmdStepGlobal));
 	DCmd_Register("sg",					WRAP_METHOD(Console, cmdStepGlobal));	// alias
 	DCmd_Register("step_callk",			WRAP_METHOD(Console, cmdStepCallk));
@@ -378,9 +381,10 @@
 	DebugPrintf(" dissect_script - Examines a script\n");
 	DebugPrintf(" set_acc - Sets the accumulator\n");
 	DebugPrintf(" backtrace / bt - Dumps the send/self/super/call/calle/callb stack\n");
-	DebugPrintf(" step / s - Executes one operation (no parameters) or several operations (specified as a parameter) \n");
+	DebugPrintf(" trace / t / s - Executes one operation (no parameters) or several operations (specified as a parameter) \n");
+	DebugPrintf(" stepover / p - Executes one operation, skips over call/send\n");
+	DebugPrintf(" step_ret / pret - Steps forward until ret is called on the current execution stack level.\n");
 	DebugPrintf(" step_event / se - Steps forward until a SCI event is received.\n");
-	DebugPrintf(" step_ret / sret - Steps forward until ret is called on the current execution stack level.\n");
 	DebugPrintf(" step_global / sg - Steps until the global variable with the specified index is modified.\n");
 	DebugPrintf(" step_callk / snk - Steps forward until it hits the next callk operation, or a specific callk (specified as a parameter)\n");
 	DebugPrintf(" disasm - Disassembles a method by name\n");
@@ -2405,7 +2409,7 @@
 	return true;
 }
 
-bool Console::cmdStep(int argc, const char **argv) {
+bool Console::cmdTrace(int argc, const char **argv) {
 	if (argc == 2 && atoi(argv[1]) > 0)
 		g_debugState.runningStep = atoi(argv[1]) - 1;
 	g_debugState.debugging = true;
@@ -2413,6 +2417,14 @@
 	return false;
 }
 
+bool Console::cmdStepOver(int argc, const char **argv) {
+	g_debugState.seeking = kDebugSeekStepOver;
+	g_debugState.seekLevel = _engine->_gamestate->_executionStack.size();
+	g_debugState.debugging = true;
+
+	return false;
+}
+
 bool Console::cmdStepEvent(int argc, const char **argv) {
 	g_debugState.stopOnEvent = true;
 	g_debugState.debugging = true;

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2010-06-27 18:41:07 UTC (rev 50387)
+++ scummvm/trunk/engines/sci/console.h	2010-06-27 19:58:32 UTC (rev 50388)
@@ -120,7 +120,8 @@
 	bool cmdDissectScript(int argc, const char **argv);
 	bool cmdSetAccumulator(int argc, const char **argv);
 	bool cmdBacktrace(int argc, const char **argv);
-	bool cmdStep(int argc, const char **argv);
+	bool cmdTrace(int argc, const char **argv);
+	bool cmdStepOver(int argc, const char **argv);
 	bool cmdStepEvent(int argc, const char **argv);
 	bool cmdStepRet(int argc, const char **argv);
 	bool cmdStepGlobal(int argc, const char **argv);

Modified: scummvm/trunk/engines/sci/debug.h
===================================================================
--- scummvm/trunk/engines/sci/debug.h	2010-06-27 18:41:07 UTC (rev 50387)
+++ scummvm/trunk/engines/sci/debug.h	2010-06-27 19:58:32 UTC (rev 50388)
@@ -57,8 +57,8 @@
 	kDebugSeekCallk = 1,        // Step forward until callk is found
 	kDebugSeekLevelRet = 2,     // Step forward until returned from this level
 	kDebugSeekSpecialCallk = 3, // Step forward until a /special/ callk is found
-	kDebugSeekSO = 4,           // Step forward until specified PC (after the send command) and stack depth
-	kDebugSeekGlobal = 5        // Step forward until one specified global variable is modified
+	kDebugSeekGlobal = 4,       // Step forward until one specified global variable is modified
+	kDebugSeekStepOver = 5      // Step forward until we reach same stack-level again
 };
 
 struct DebugState {

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2010-06-27 18:41:07 UTC (rev 50387)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2010-06-27 19:58:32 UTC (rev 50388)
@@ -296,55 +296,59 @@
 #endif
 
 	if (g_debugState.seeking && !g_debugState.breakpointWasHit) { // Are we looking for something special?
-		SegmentObj *mobj = s->_segMan->getSegment(s->xs->addr.pc.segment, SEG_TYPE_SCRIPT);
+		if (g_debugState.seeking == kDebugSeekStepOver) {
+			// are we above seek-level? resume then
+			if (g_debugState.seekLevel < (int)s->_executionStack.size())
+				return;
+			g_debugState.seeking = kDebugSeekNothing;
+		}
 
-		if (mobj) {
-			Script *scr = (Script *)mobj;
-			byte *code_buf = scr->_buf;
-			int code_buf_size = scr->getBufSize();
-			int opcode = s->xs->addr.pc.offset >= code_buf_size ? 0 : code_buf[s->xs->addr.pc.offset];
-			int op = opcode >> 1;
-			int paramb1 = s->xs->addr.pc.offset + 1 >= code_buf_size ? 0 : code_buf[s->xs->addr.pc.offset + 1];
-			int paramf1 = (opcode & 1) ? paramb1 : (s->xs->addr.pc.offset + 2 >= code_buf_size ? 0 : (int16)READ_SCI11ENDIAN_UINT16(code_buf + s->xs->addr.pc.offset + 1));
+		if (g_debugState.seeking != kDebugSeekNothing) {
+			SegmentObj *mobj = s->_segMan->getSegment(s->xs->addr.pc.segment, SEG_TYPE_SCRIPT);
 
-			switch (g_debugState.seeking) {
-			case kDebugSeekSpecialCallk:
-				if (paramb1 != g_debugState.seekSpecial)
-					return;
+			if (mobj) {
+				Script *scr = (Script *)mobj;
+				byte *code_buf = scr->_buf;
+				int code_buf_size = scr->getBufSize();
+				int opcode = s->xs->addr.pc.offset >= code_buf_size ? 0 : code_buf[s->xs->addr.pc.offset];
+				int op = opcode >> 1;
+				int paramb1 = s->xs->addr.pc.offset + 1 >= code_buf_size ? 0 : code_buf[s->xs->addr.pc.offset + 1];
+				int paramf1 = (opcode & 1) ? paramb1 : (s->xs->addr.pc.offset + 2 >= code_buf_size ? 0 : (int16)READ_SCI11ENDIAN_UINT16(code_buf + s->xs->addr.pc.offset + 1));
 
-			case kDebugSeekCallk:
-				if (op != op_callk)
-					return;
-				break;
+				switch (g_debugState.seeking) {
+				case kDebugSeekSpecialCallk:
+					if (paramb1 != g_debugState.seekSpecial)
+						return;
 
-			case kDebugSeekLevelRet:
-				if ((op != op_ret) || (g_debugState.seekLevel < (int)s->_executionStack.size()-1))
-					return;
-				break;
+				case kDebugSeekCallk:
+					if (op != op_callk)
+						return;
+					break;
 
-			case kDebugSeekGlobal:
-				if (op < op_sag)
-					return;
-				if ((op & 0x3) > 1)
-					return; // param or temp
-				if ((op & 0x3) && s->_executionStack.back().local_segment > 0)
-					return; // locals and not running in script.000
-				if (paramf1 != g_debugState.seekSpecial)
-					return; // CORRECT global?
-				break;
+				case kDebugSeekLevelRet:
+					if ((op != op_ret) || (g_debugState.seekLevel < (int)s->_executionStack.size()-1))
+						return;
+					break;
 
-			case kDebugSeekSO:
-				// FIXME: Unhandled?
-				break;
+				case kDebugSeekGlobal:
+					if (op < op_sag)
+						return;
+					if ((op & 0x3) > 1)
+						return; // param or temp
+					if ((op & 0x3) && s->_executionStack.back().local_segment > 0)
+						return; // locals and not running in script.000
+					if (paramf1 != g_debugState.seekSpecial)
+						return; // CORRECT global?
+					break;
 
-			case kDebugSeekNothing:
-				// We seek nothing, so just continue
-				break;
+				default:
+					break;
+				}
+
+				g_debugState.seeking = kDebugSeekNothing;
 			}
-
-			g_debugState.seeking = kDebugSeekNothing;
-			// OK, found whatever we were looking for
 		}
+		// OK, found whatever we were looking for
 	}
 
 	printf("Step #%d\n", s->scriptStepCounter);


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