aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2010-07-23 20:59:27 +0000
committerMartin Kiewitz2010-07-23 20:59:27 +0000
commitb984d9afc09369f505482bfef9cda26a53efb572 (patch)
treea819d116e252c3e77967d769d7cc45468ca8cdd8 /engines/sci
parent9fc67f5c0b3eb7ad377372da7ccff87d5203de0c (diff)
downloadscummvm-rg350-b984d9afc09369f505482bfef9cda26a53efb572.tar.gz
scummvm-rg350-b984d9afc09369f505482bfef9cda26a53efb572.tar.bz2
scummvm-rg350-b984d9afc09369f505482bfef9cda26a53efb572.zip
SCI: logkernel changes
removing old manual debug code, use logkernel * on/off to log all calls svn-id: r51222
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/console.cpp2
-rw-r--r--engines/sci/engine/kernel.cpp20
-rw-r--r--engines/sci/engine/vm.cpp27
3 files changed, 23 insertions, 26 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 6bb2c52d84..501a0fa954 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -2695,7 +2695,7 @@ bool Console::cmdGo(int argc, const char **argv) {
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;
}
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index de64c1ea0b..21331335f7 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -651,15 +651,23 @@ void Kernel::mapFunctions() {
}
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() {
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 88d47cb22d..05164f2f76 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -642,7 +642,7 @@ static void addKernelCallToExecStack(EngineState *s, int kernelCallNr, int argc,
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 @@ static void logKernelCall(const KernelFunction *kernelCall, EngineState *s, int
}
}
}
- 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 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) {
// 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 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) {
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();