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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Mon Jun 28 16:21:56 CEST 2010


Revision: 50445
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50445&view=rev
Author:   m_kiewitz
Date:     2010-06-28 14:21:56 +0000 (Mon, 28 Jun 2010)

Log Message:
-----------
SCI: cleanup of execstack, output of backtrace slightly modified, is now also displaying local calls and exports

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

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-06-28 12:58:14 UTC (rev 50444)
+++ scummvm/trunk/engines/sci/console.cpp	2010-06-28 14:21:56 UTC (rev 50445)
@@ -2320,8 +2320,6 @@
 }
 
 bool Console::cmdBacktrace(int argc, const char **argv) {
-	DebugPrintf("Dumping the send/self/super/call/calle/callb stack:\n");
-
 	DebugPrintf("Call stack (current base: 0x%x):\n", _engine->_gamestate->executionStackBase);
 	Common::List<ExecStack>::iterator iter;
 	uint i = 0;
@@ -2333,19 +2331,25 @@
 		int paramc, totalparamc;
 
 		switch (call.type) {
-
 		case EXEC_STACK_TYPE_CALL: // Normal function
-			DebugPrintf(" %x:[%x]  %s::%s(", i, call.origin, objname, (call.selector == -1) ? "<call[be]?>" :
-			          _engine->getKernel()->getSelectorName(call.selector).c_str());
+			if (call.type == EXEC_STACK_TYPE_CALL)
+			DebugPrintf(" %x: script %d - ", i, (*(Script *)_engine->_gamestate->_segMan->_heap[call.addr.pc.segment]).getScriptNumber());
+			if (call.debugSelector != -1) {
+				DebugPrintf("%s::%s(", objname, _engine->getKernel()->getSelectorName(call.debugSelector).c_str());
+			} else if (call.debugExportId != -1) {
+				DebugPrintf("export %d (", call.debugExportId);
+			} else if (call.debugLocalCallOffset != -1) {
+				DebugPrintf("call %x (", call.debugLocalCallOffset);
+			}
 			break;
 
 		case EXEC_STACK_TYPE_KERNEL: // Kernel function
-			DebugPrintf(" %x:[%x]  k%s(", i, call.origin, _engine->getKernel()->getKernelName(call.selector).c_str());
+			DebugPrintf(" %x:[%x]  k%s(", i, call.debugOrigin, _engine->getKernel()->getKernelName(call.debugSelector).c_str());
 			break;
 
 		case EXEC_STACK_TYPE_VARSELECTOR:
-			DebugPrintf(" %x:[%x] vs%s %s::%s (", i, call.origin, (call.argc) ? "write" : "read",
-			          objname, _engine->getKernel()->getSelectorName(call.selector).c_str());
+			DebugPrintf(" %x:[%x] vs%s %s::%s (", i, call.debugOrigin, (call.argc) ? "write" : "read",
+			          objname, _engine->getKernel()->getSelectorName(call.debugSelector).c_str());
 			break;
 		}
 
@@ -2364,7 +2368,10 @@
 		if (call.argc > 16)
 			DebugPrintf("...");
 
-		DebugPrintf(")\n    obj@%04x:%04x", PRINT_REG(call.objp));
+		DebugPrintf(")\n     ");
+		if (call.debugOrigin != -1)
+			DebugPrintf("by %x ", call.debugOrigin);
+		DebugPrintf("obj@%04x:%04x", PRINT_REG(call.objp));
 		if (call.type == EXEC_STACK_TYPE_CALL) {
 			DebugPrintf(" pc=%04x:%04x", PRINT_REG(call.addr.pc));
 			if (call.sp == CALL_SP_CARRY)
@@ -2377,8 +2384,6 @@
 			DebugPrintf(" pc:none");
 
 		DebugPrintf(" argp:ST:%04x", (unsigned)(call.variables_argp - _engine->_gamestate->stack_base));
-		if (call.type == EXEC_STACK_TYPE_CALL)
-			DebugPrintf(" script: %d", (*(Script *)_engine->_gamestate->_segMan->_heap[call.addr.pc.segment]).getScriptNumber());
 		DebugPrintf("\n");
 	}
 

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-28 12:58:14 UTC (rev 50444)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-28 14:21:56 UTC (rev 50445)
@@ -301,15 +301,15 @@
 			Script *local_script = state->_segMan->getScriptIfLoaded(lastCall->local_segment);
 			int curScriptNr = local_script->getScriptNumber();
 
-			if (lastCall->localCallOffset != -1) {
+			if (lastCall->debugLocalCallOffset != -1) {
 				// if lastcall was actually a local call search back for a real call
 				Common::List<ExecStack>::iterator callIterator = state->_executionStack.end();
 				while (callIterator != state->_executionStack.begin()) {
 					callIterator--;
 					ExecStack loopCall = *callIterator;
-					if ((loopCall.selector != -1) || (loopCall.exportId != -1)) {
-						lastCall->selector = loopCall.selector;
-						lastCall->exportId = loopCall.exportId;
+					if ((loopCall.debugSelector != -1) || (loopCall.debugExportId != -1)) {
+						lastCall->debugSelector = loopCall.debugSelector;
+						lastCall->debugExportId = loopCall.debugExportId;
 						break;
 					}
 				}
@@ -320,11 +320,11 @@
 			const SciGameId gameId = g_sci->getGameId();
 
 			if (lastCall->type == EXEC_STACK_TYPE_CALL) {
-				if (lastCall->selector != -1) {
-					curMethodName = g_sci->getKernel()->getSelectorName(lastCall->selector);
-				} else if (lastCall->exportId != -1) {
+				if (lastCall->debugSelector != -1) {
+					curMethodName = g_sci->getKernel()->getSelectorName(lastCall->debugSelector);
+				} else if (lastCall->debugExportId != -1) {
 					curObjectName = "";
-					curMethodName = curMethodName.printf("export %d", lastCall->exportId);
+					curMethodName = curMethodName.printf("export %d", lastCall->debugExportId);
 				}
 			}
 
@@ -336,7 +336,7 @@
 				workaround = uninitializedReadWorkarounds;
 				while (workaround->objectName) {
 					if (workaround->gameId == gameId && workaround->scriptNr == curScriptNr && (workaround->objectName == searchObjectName)
-							&& workaround->methodName == curMethodName && workaround->localCallOffset == lastCall->localCallOffset && workaround->index == index) {
+							&& workaround->methodName == curMethodName && workaround->localCallOffset == lastCall->debugLocalCallOffset && workaround->index == index) {
 						// Workaround found
 						r[index] = make_reg(0, workaround->newValue);
 						return r[index];
@@ -348,7 +348,7 @@
 				if (!searchObject.isNull())
 					searchObjectName = state->_segMan->getObjectName(searchObject);
 			} while (!searchObject.isNull()); // no parent left?
-			error("Uninitialized read for temp %d from method %s::%s (script %d, localCall %x)", index, curObjectName.c_str(), curMethodName.c_str(), curScriptNr, lastCall->localCallOffset);
+			error("Uninitialized read for temp %d from method %s::%s (script %d, localCall %x)", index, curObjectName.c_str(), curMethodName.c_str(), curScriptNr, lastCall->debugLocalCallOffset);
 		}
 		return r[index];
 	} else
@@ -718,10 +718,10 @@
 	*argp = make_reg(0, argc);  // SCI code relies on the zeroeth argument to equal argc
 
 	// Additional debug information
-	xstack.selector = selector;
-	xstack.exportId = exportId;
-	xstack.localCallOffset = localCallOffset;
-	xstack.origin = origin;
+	xstack.debugSelector = selector;
+	xstack.debugExportId = exportId;
+	xstack.debugLocalCallOffset = localCallOffset;
+	xstack.debugOrigin = origin;
 
 	xstack.type = EXEC_STACK_TYPE_CALL; // Normal call
 
@@ -777,7 +777,7 @@
 		ExecStack *xstack;
 		xstack = add_exec_stack_entry(s->_executionStack, NULL_REG, NULL, NULL_REG, argc, argv - 1, 0, -1, -1, NULL_REG,
 				  s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS);
-		xstack->selector = kernelFuncNr;
+		xstack->debugSelector = kernelFuncNr;
 		xstack->type = EXEC_STACK_TYPE_KERNEL;
 
 		// Call kernel function

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2010-06-28 12:58:14 UTC (rev 50444)
+++ scummvm/trunk/engines/sci/engine/vm.h	2010-06-28 14:21:56 UTC (rev 50445)
@@ -97,10 +97,10 @@
 	StackPtr variables_argp; // Argument pointer
 	SegmentId local_segment; // local variables etc
 
-	Selector selector;      // The selector which was used to call or -1 if not applicable
-	int exportId;           // The exportId which was called or -1 if not applicable
-	int localCallOffset;    // Local call offset or -1 if not applicable
-	int origin;             // The stack frame position the call was made from, or -1 if it was the initial call
+	Selector debugSelector;   // The selector which was used to call or -1 if not applicable
+	int debugExportId;        // The exportId which was called or -1 if not applicable
+	int debugLocalCallOffset; // Local call offset or -1 if not applicable
+	int debugOrigin;          // The stack frame position the call was made from, or -1 if it was the initial call
 	ExecStackType type;
 
 	reg_t* getVarPointer(SegManager *segMan) const;


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