[Scummvm-cvs-logs] scummvm master -> 7f9f3051117d0101088c368c925e8f40d909dc6d

m-kiewitz m_kiewitz at users.sourceforge.net
Fri Mar 20 16:05:15 CET 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
7f9f305111 SCI: improve debug output for signature mismatch


Commit: 7f9f3051117d0101088c368c925e8f40d909dc6d
    https://github.com/scummvm/scummvm/commit/7f9f3051117d0101088c368c925e8f40d909dc6d
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2015-03-20T16:06:19+01:00

Commit Message:
SCI: improve debug output for signature mismatch

dump parameter list to debugger as well

Changed paths:
    engines/sci/engine/kernel.cpp
    engines/sci/engine/kernel.h
    engines/sci/engine/vm.cpp



diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index 2b16bb3..bfb7bfc 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -432,57 +432,66 @@ static const SignatureDebugType signatureDebugTypeList[] = {
 	{ 0,                      NULL }
 };
 
-static void kernelSignatureDebugType(const uint16 type) {
+static void kernelSignatureDebugType(Common::String &signatureDetailsStr, const uint16 type) {
 	bool firstPrint = true;
 
 	const SignatureDebugType *list = signatureDebugTypeList;
 	while (list->typeCheck) {
 		if (type & list->typeCheck) {
 			if (!firstPrint)
-				debugN(", ");
-			debugN("%s", list->text);
+//				debugN(", ");
+				signatureDetailsStr += ", ";
+//			debugN("%s", list->text);
+//			signatureDetailsStr += signatureDetailsStr.format("%s", list->text);
+			signatureDetailsStr += list->text;
 			firstPrint = false;
 		}
 		list++;
 	}
 }
 
-// Shows kernel call signature and current arguments for debugging purposes
-void Kernel::signatureDebug(const uint16 *sig, int argc, const reg_t *argv) {
+// Create string, that holds the details of a kernel call signature and current arguments
+//  For debugging purposes
+void Kernel::signatureDebug(Common::String &signatureDetailsStr, const uint16 *sig, int argc, const reg_t *argv) {
 	int argnr = 0;
+
+	// add ERROR: to debug output
+	debugN("ERROR:");
+
 	while (*sig || argc) {
-		debugN("parameter %d: ", argnr++);
+		// add leading spaces for additional parameters
+		signatureDetailsStr += signatureDetailsStr.format("parameter %d: ", argnr++);
 		if (argc) {
 			reg_t parameter = *argv;
-			debugN("%04x:%04x (", PRINT_REG(parameter));
+			signatureDetailsStr += signatureDetailsStr.format("%04x:%04x (", PRINT_REG(parameter));
 			int regType = findRegType(parameter);
 			if (regType)
-				kernelSignatureDebugType(regType);
+				kernelSignatureDebugType(signatureDetailsStr, regType);
 			else
-				debugN("unknown type of %04x:%04x", PRINT_REG(parameter));
-			debugN(")");
+				signatureDetailsStr += signatureDetailsStr.format("unknown type of %04x:%04x", PRINT_REG(parameter));
+			signatureDetailsStr += ")";
 			argv++;
 			argc--;
 		} else {
-			debugN("not passed");
+			signatureDetailsStr += "not passed";
 		}
 		if (*sig) {
 			const uint16 signature = *sig;
 			if ((signature & SIG_MAYBE_ANY) == SIG_MAYBE_ANY) {
-				debugN(", may be any");
+				signatureDetailsStr += ", may be any";
 			} else {
-				debugN(", should be ");
-				kernelSignatureDebugType(signature);
+				signatureDetailsStr += ", should be ";
+				kernelSignatureDebugType(signatureDetailsStr, signature);
 			}
 			if (signature & SIG_IS_OPTIONAL)
-				debugN(" (optional)");
+				signatureDetailsStr += " (optional)";
 			if (signature & SIG_NEEDS_MORE)
-				debugN(" (needs more)");
+				signatureDetailsStr += " (needs more)";
 			if (signature & SIG_MORE_MAY_FOLLOW)
-				debugN(" (more may follow)");
+				signatureDetailsStr += " (more may follow)";
 			sig++;
 		}
-		debugN("\n");
+		signatureDetailsStr += "\n";
 	}
 }
 
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index a65bcb7..57b4d94 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -186,7 +186,7 @@ public:
 	bool signatureMatch(const uint16 *sig, int argc, const reg_t *argv);
 
 	// Prints out debug information in case a signature check fails
-	void signatureDebug(const uint16 *sig, int argc, const reg_t *argv);
+	void signatureDebug(Common::String &signatureDetails, const uint16 *sig, int argc, const reg_t *argv);
 
 	/**
 	 * Determines the type of the object indicated by reg.
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 0685854..6f02c96 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -358,12 +358,15 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) {
 		SciTrackOriginReply originReply;
 		SciWorkaroundSolution solution = trackOriginAndFindWorkaround(0, kernelCall.workarounds, &originReply);
 		switch (solution.type) {
-		case WORKAROUND_NONE:
-			kernel->signatureDebug(kernelCall.signature, argc, argv);
-			error("[VM] k%s[%x]: signature mismatch via method %s::%s (room %d, script %d, localCall 0x%x)",
+		case WORKAROUND_NONE: {
+			Common::String signatureDetailsStr;
+			kernel->signatureDebug(signatureDetailsStr, kernelCall.signature, argc, argv);
+			error("\n%s[VM] k%s[%x]: signature mismatch in method %s::%s (room %d, script %d, localCall 0x%x)",
+				signatureDetailsStr.c_str(),
 				kernelCall.name, kernelCallNr, originReply.objectName.c_str(), originReply.methodName.c_str(),
 				s->currentRoomNumber(), originReply.scriptNr, originReply.localCallOffset);
 			break;
+			}
 		case WORKAROUND_IGNORE: // don't do kernel call, leave acc alone
 			return;
 		case WORKAROUND_STILLCALL: // call kernel anyway
@@ -408,15 +411,18 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) {
 			SciWorkaroundSolution solution = trackOriginAndFindWorkaround(0, kernelSubCall.workarounds, &originReply);
 			switch (solution.type) {
 			case WORKAROUND_NONE: {
-				kernel->signatureDebug(kernelSubCall.signature, argc, argv);
+				Common::String signatureDetailsStr;
+				kernel->signatureDebug(signatureDetailsStr, kernelSubCall.signature, argc, argv);
 				int callNameLen = strlen(kernelCall.name);
 				if (strncmp(kernelCall.name, kernelSubCall.name, callNameLen) == 0) {
 					const char *subCallName = kernelSubCall.name + callNameLen;
-					error("[VM] k%s(%s): signature mismatch via method %s::%s (room %d, script %d, localCall %x)",
+					error("\n%s[VM] k%s(%s): signature mismatch in method %s::%s (room %d, script %d, localCall %x)",
+						signatureDetailsStr.c_str(),
 						kernelCall.name, subCallName, originReply.objectName.c_str(), originReply.methodName.c_str(),
 						s->currentRoomNumber(), originReply.scriptNr, originReply.localCallOffset);
 				}
-				error("[VM] k%s: signature mismatch via method %s::%s (room %d, script %d, localCall %x)",
+				error("\n%s[VM] k%s: signature mismatch in method %s::%s (room %d, script %d, localCall %x)",
+					signatureDetailsStr.c_str(),
 					kernelSubCall.name, originReply.objectName.c_str(), originReply.methodName.c_str(),
 					s->currentRoomNumber(), originReply.scriptNr, originReply.localCallOffset);
 				break;






More information about the Scummvm-git-logs mailing list