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 | |
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
-rw-r--r-- | engines/sci/console.cpp | 59 | ||||
-rw-r--r-- | engines/sci/console.h | 1 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 64 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.h | 2 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 3 |
5 files changed, 68 insertions, 61 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 6c9be970cb..6efe6849bb 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -4745,65 +4745,6 @@ void Console::printBitmap(reg_t reg) { #endif -int Console::printObject(reg_t pos) { - EngineState *s = _engine->_gamestate; // for the several defines in this function - const Object *obj = s->_segMan->getObject(pos); - const Object *var_container = obj; - uint i; - - if (!obj) { - debugPrintf("[%04x:%04x]: Not an object.\n", PRINT_REG(pos)); - return 1; - } - - // Object header - 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()); - debugPrintf(" -- member variables:\n"); - - if (getSciVersion() == SCI_VERSION_3) { - debugPrintf(" (----) [---] -size- = 0000:%04x (%d)\n", obj->getVarCount(), obj->getVarCount()); - debugPrintf(" (----) [---] -classScript- = %04x:%04x (%d)\n", PRINT_REG(obj->getClassScriptSelector()), obj->getClassScriptSelector().getOffset()); - debugPrintf(" (----) [---] -species- = %04x:%04x (%s)\n", PRINT_REG(obj->getSpeciesSelector()), s->_segMan->getObjectName(obj->getSpeciesSelector())); - debugPrintf(" (----) [---] -super- = %04x:%04x (%s)\n", PRINT_REG(obj->getSuperClassSelector()), s->_segMan->getObjectName(obj->getSuperClassSelector())); - debugPrintf(" (----) [---] -info- = %04x:%04x (%d)\n", PRINT_REG(obj->getInfoSelector()), obj->getInfoSelector().getOffset()); - } - - for (i = 0; (uint)i < obj->getVarCount(); i++) { - 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 - debugPrintf("(%04x) [%03x] %s = ", i /* *2 */, varSelector, _engine->getKernel()->getSelectorName(varSelector).c_str()); - } else - debugPrintf("p#%x = ", i); - - reg_t val = obj->getVariable(i); - debugPrintf("%04x:%04x", PRINT_REG(val)); - - if (!val.getSegment()) - debugPrintf(" (%d)", val.getOffset()); - - const Object *ref = s->_segMan->getObject(val); - if (ref) - debugPrintf(" (%s)", s->_segMan->getObjectName(val)); - - debugPrintf("\n"); - } - debugPrintf(" -- methods:\n"); - for (i = 0; i < obj->getMethodCount(); i++) { - reg_t fptr = obj->getFunction(i); - debugPrintf(" [%03x] %s = %04x:%04x\n", obj->getFuncSelector(i), _engine->getKernel()->getSelectorName(obj->getFuncSelector(i)).c_str(), PRINT_REG(fptr)); - } - if (s->_segMan->_heap[pos.getSegment()]->getType() == SEG_TYPE_SCRIPT) - debugPrintf("\nOwner script: %d\n", s->_segMan->getScript(pos.getSegment())->getScriptNumber()); - - return 0; -} - static void printChar(byte c) { if (c < 32 || c >= 127) c = '.'; diff --git a/engines/sci/console.h b/engines/sci/console.h index d0faf8a030..75243e52b3 100644 --- a/engines/sci/console.h +++ b/engines/sci/console.h @@ -45,7 +45,6 @@ public: void printArray(reg_t reg); void printBitmap(reg_t reg); #endif - int printObject(reg_t reg); private: virtual void preEnter(); 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 diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 2226cdd63c..c7b9bc7995 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -42,6 +42,7 @@ #include "sci/engine/script.h" // for script_adjust_opcode_formats #include "sci/engine/script_patches.h" #include "sci/engine/selector.h" // for SELECTOR +#include "sci/engine/scriptdebug.h" #include "sci/sound/audio.h" #include "sci/sound/music.h" @@ -637,7 +638,7 @@ void SciEngine::initStackBaseWithSelector(Selector selector) { // Register the first element on the execution stack if (!send_selector(_gamestate, _gameObjectAddress, _gameObjectAddress, _gamestate->stack_base, 2, _gamestate->stack_base)) { - _console->printObject(_gameObjectAddress); + printObject(_gameObjectAddress); error("initStackBaseWithSelector: error while registering the first selector in the call stack"); } |