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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Fri Jul 23 22:59:27 CEST 2010


Revision: 51222
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51222&view=rev
Author:   m_kiewitz
Date:     2010-07-23 20:59:27 +0000 (Fri, 23 Jul 2010)

Log Message:
-----------
SCI: logkernel changes

removing old manual debug code, use logkernel * on/off to log all calls

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

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-07-23 20:55:44 UTC (rev 51221)
+++ scummvm/trunk/engines/sci/console.cpp	2010-07-23 20:59:27 UTC (rev 51222)
@@ -2695,7 +2695,7 @@
 bool Console::cmdLogKernel(int argc, const char **argv) {
 	if (argc < 3) {
 		DebugPrintf("Logs calls to specified kernel function.\n");
-		DebugPrintf("Usage: %s <kernel-function> <on/off>\n", argv[0]);
+		DebugPrintf("Usage: %s <kernel-function/*> <on/off>\n", argv[0]);
 		DebugPrintf("Example: %s StrCpy on\n", argv[0]);
 		return true;
 	}

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2010-07-23 20:55:44 UTC (rev 51221)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2010-07-23 20:59:27 UTC (rev 51222)
@@ -651,15 +651,23 @@
 }
 
 bool Kernel::debugSetFunctionLogging(const char *kernelName, bool logging) {
-	for (uint id = 0; id < _kernelFuncs.size(); id++) {
-		if (_kernelFuncs[id].name) {
-			if (strcmp(kernelName, _kernelFuncs[id].name) == 0) {
-				_kernelFuncs[id].debugLogging = logging;
-				return true;
+	if (strcmp(kernelName, "*")) {
+		for (uint id = 0; id < _kernelFuncs.size(); id++) {
+			if (_kernelFuncs[id].name) {
+				if (strcmp(kernelName, _kernelFuncs[id].name) == 0) {
+					_kernelFuncs[id].debugLogging = logging;
+					return true;
+				}
 			}
 		}
+		return false;
 	}
-	return false;
+	// Set debugLogging for all calls
+	for (uint id = 0; id < _kernelFuncs.size(); id++) {
+		if (_kernelFuncs[id].name)
+			_kernelFuncs[id].debugLogging = logging;
+	}
+	return true;
 }
 
 void Kernel::setDefaultKernelNames() {

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-07-23 20:55:44 UTC (rev 51221)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-07-23 20:59:27 UTC (rev 51222)
@@ -642,7 +642,7 @@
 	xstack->type = EXEC_STACK_TYPE_KERNEL;
 }
 
-static void	logKernelCall(const KernelFunction *kernelCall, EngineState *s, int argc, reg_t *argv) {
+static void	logKernelCall(const KernelFunction *kernelCall, EngineState *s, int argc, reg_t *argv, reg_t result) {
 	Kernel *kernel = g_sci->getKernel();
 	printf("k%s: ", kernelCall->name);
 	for (int parmNr = 0; parmNr < argc; parmNr++) {
@@ -671,7 +671,10 @@
 			}
 		}
 	}
-	printf("\n");
+	if (result.segment)
+		printf(" = %04x:%04x\n", PRINT_REG(result));
+	else
+		printf(" = %04x\n", result.offset);
 }
 
 static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) {
@@ -708,10 +711,11 @@
 
 	// Call kernel function
 	if (!kernelCall.subFunctionCount) {
-		if (kernelCall.debugLogging)
-			logKernelCall(&kernelCall, s, argc, argv);
 		addKernelCallToExecStack(s, kernelCallNr, argc, argv);
 		s->r_acc = kernelCall.function(s, argc, argv);
+
+		if (kernelCall.debugLogging)
+			logKernelCall(&kernelCall, s, argc, argv, s->r_acc);
 	} else {
 		// Sub-functions available, check signature and call that one directly
 		if (argc < 1)
@@ -757,21 +761,6 @@
 		s->r_acc = kernelSubCall.function(s, argc, argv);
 	}
 
-#if 0
-		// Used for debugging
-		Common::String debugMsg = Common::String::printf("%s [0x%x]", kernelCall.name, kernelCallNr) +
-									Common::String::printf(", %d params: ", argc) +
-									" (";
-
-		for (int i = 0; i < argc; i++) {
-			debugMsg +=  Common::String::printf("%04x:%04x", PRINT_REG(argv[i]));
-			debugMsg += (i == argc - 1 ? ")" : ", ");
-		}
-
-		debugMsg += ", result: " + Common::String::printf("%04x:%04x", PRINT_REG(s->r_acc));
-		debug("%s", debugMsg.c_str());
-#endif
-
 	// Remove callk stack frame again, if there's still an execution stack
 	if (s->_executionStack.begin() != s->_executionStack.end())
 		s->_executionStack.pop_back();


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