diff options
author | Willem Jan Palenstijn | 2017-05-26 18:34:29 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2017-06-10 21:32:35 +0200 |
commit | 423ecde8e0e20d664ad8e41496bdf98cf94407da (patch) | |
tree | 0b61db050e3b08e66715059af2bc61587e90e975 /engines/sci/engine | |
parent | 8e683db72b280fbe4319d68466c7f3c61a6c107d (diff) | |
download | scummvm-rg350-423ecde8e0e20d664ad8e41496bdf98cf94407da.tar.gz scummvm-rg350-423ecde8e0e20d664ad8e41496bdf98cf94407da.tar.bz2 scummvm-rg350-423ecde8e0e20d664ad8e41496bdf98cf94407da.zip |
SCI: Move printObject from console to scriptdebug
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 64 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.h | 2 |
2 files changed, 66 insertions, 0 deletions
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index c5a617a17a..ce1d2dd1f3 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -1005,6 +1005,70 @@ void logBacktrace() { } } +bool printObject(reg_t pos) { + Console *con = g_sci->getSciDebugger(); + EngineState *s = g_sci->getEngineState(); + const Object *obj = s->_segMan->getObject(pos); + const Object *var_container = obj; + uint i; + + if (!obj) { + con->debugPrintf("[%04x:%04x]: Not an object.\n", PRINT_REG(pos)); + return false; + } + + // Object header + con->debugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(pos), s->_segMan->getObjectName(pos), + obj->getVarCount(), obj->getMethodCount()); + + if (!obj->isClass()) + var_container = s->_segMan->getObject(obj->getSuperClassSelector()); + con->debugPrintf(" -- member variables:\n"); + + if (getSciVersion() == SCI_VERSION_3) { + con->debugPrintf(" (----) [---] -size- = 0000:%04x (%d)\n", obj->getVarCount(), obj->getVarCount()); + con->debugPrintf(" (----) [---] -classScript- = %04x:%04x (%d)\n", PRINT_REG(obj->getClassScriptSelector()), obj->getClassScriptSelector().getOffset()); + con->debugPrintf(" (----) [---] -species- = %04x:%04x (%s)\n", PRINT_REG(obj->getSpeciesSelector()), s->_segMan->getObjectName(obj->getSpeciesSelector())); + con->debugPrintf(" (----) [---] -super- = %04x:%04x (%s)\n", PRINT_REG(obj->getSuperClassSelector()), s->_segMan->getObjectName(obj->getSuperClassSelector())); + con->debugPrintf(" (----) [---] -info- = %04x:%04x (%d)\n", PRINT_REG(obj->getInfoSelector()), obj->getInfoSelector().getOffset()); + } + + for (i = 0; (uint)i < obj->getVarCount(); i++) { + con->debugPrintf(" "); + if (var_container && i < var_container->getVarCount()) { + uint16 varSelector = var_container->getVarSelector(i); + // Times two commented out for now for easy parsing of vocab.994 + con->debugPrintf("(%04x) [%03x] %s = ", i /* *2 */, varSelector, g_sci->getKernel()->getSelectorName(varSelector).c_str()); + } else + con->debugPrintf("p#%x = ", i); + + reg_t val = obj->getVariable(i); + con->debugPrintf("%04x:%04x", PRINT_REG(val)); + + if (!val.getSegment()) + con->debugPrintf(" (%d)", val.getOffset()); + + const Object *ref = s->_segMan->getObject(val); + if (ref) + con->debugPrintf(" (%s)", s->_segMan->getObjectName(val)); + + con->debugPrintf("\n"); + } + con->debugPrintf(" -- methods:\n"); + for (i = 0; i < obj->getMethodCount(); i++) { + reg_t fptr = obj->getFunction(i); + con->debugPrintf(" [%03x] %s = %04x:%04x\n", obj->getFuncSelector(i), g_sci->getKernel()->getSelectorName(obj->getFuncSelector(i)).c_str(), PRINT_REG(fptr)); + } + + Script *scr = s->_segMan->getScriptIfLoaded(pos.getSegment()); + if (scr) + con->debugPrintf("\nOwner script: %d\n", scr->getScriptNumber()); + + return true; +} + + + diff --git a/engines/sci/engine/scriptdebug.h b/engines/sci/engine/scriptdebug.h index 1d8a2ef6bb..f8930998e2 100644 --- a/engines/sci/engine/scriptdebug.h +++ b/engines/sci/engine/scriptdebug.h @@ -37,6 +37,8 @@ void logKernelCall(const KernelFunction *kernelCall, const KernelSubFunction *ke void logBacktrace(); +bool printObject(reg_t obj); + } #endif |