diff options
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 29 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 13 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 7 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 14 | ||||
-rw-r--r-- | engines/sci/engine/vm.h | 5 |
5 files changed, 38 insertions, 30 deletions
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 92cfe9daf3..11dd56f2aa 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -311,11 +311,18 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod void script_debug(EngineState *s, bool bp) { // Do we support a separate console? - printf("%d: acc=%04x:%04x ", script_step_counter, PRINT_REG(s->r_acc)); - disassemble(s, scriptState.xs->addr.pc, 0, 1); - if (scriptState.seeking == kDebugSeekGlobal) - printf("Global %d (0x%x) = %04x:%04x\n", scriptState.seekSpecial, - scriptState.seekSpecial, PRINT_REG(s->script_000->locals_block->_locals[scriptState.seekSpecial])); + /* if (sci_debug_flags & _DEBUG_FLAG_LOGGING) { */ + printf("%d: acc=%04x:%04x ", script_step_counter, PRINT_REG(s->r_acc)); + disassemble(s, scriptState.xs->addr.pc, 0, 1); + if (scriptState.seeking == kDebugSeekGlobal) + printf("Global %d (0x%x) = %04x:%04x\n", scriptState.seekSpecial, + scriptState.seekSpecial, PRINT_REG(s->script_000->locals_block->_locals[scriptState.seekSpecial])); + /* } */ + +#if 0 + if (!scriptState.debugging) + return; +#endif if (scriptState.seeking && !bp) { // Are we looking for something special? MemObject *mobj = GET_SEGMENT(*s->seg_manager, scriptState.xs->addr.pc.segment, MEM_OBJ_SCRIPT); @@ -370,9 +377,19 @@ void script_debug(EngineState *s, bool bp) { // OK, found whatever we were looking for } } - + printf("Step #%d\n", script_step_counter); disassemble(s, scriptState.xs->addr.pc, 0, 1); + + if (scriptState.runningStep) { + scriptState.runningStep--; + return; + } + + scriptState.debugging = false; + + Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger(); + con->attach(); } } // End of namespace Sci diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 6752ba3e56..905cba9d94 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -169,7 +169,9 @@ int SegManager::initialiseScript(Script &scr, EngineState *s, int script_nr) { setScriptSize(scr, s, script_nr); scr.buf = (byte *)malloc(scr.buf_size); - dbgPrint("scr.buf ", scr.buf); +#ifdef DEBUG_SEG_MANAGER + printf("scr.buf = %p ", scr.buf); +#endif if (!scr.buf) { scr.freeScript(); warning("SegManager: Not enough memory space for script size"); @@ -864,14 +866,5 @@ int SegManager::freeDynmem(reg_t addr) { return 0; // OK } -void SegManager::dbgPrint(const char* msg, void *i) { -#ifdef DEBUG_SEG_MANAGER - char buf[1000]; - sprintf(buf, "%s = [0x%x], dec:[%d]", msg, i, i); - perror(buf); -#endif -} - - } // End of namespace Sci diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index a41d820014..9d406f559f 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -362,13 +362,6 @@ private: * 'seg' is a valid segment */ bool check(SegmentId seg); - - void dbgPrint(const char* msg, void *i); // for debug only - - // Perform garbage collection - // Parameters: (EngineState *) s: The state to operate on - // Effects : Unreachable objects in 's' are deallocated - //void sm_gc(EngineState *s); }; } // End of namespace Sci diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 99b5a86e53..0f8fee0876 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -258,6 +258,7 @@ ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackP if (bp->type == BREAK_EXPORT && bp->data.address == bpaddress) { Console *con = ((SciEngine *)g_engine)->getSciDebugger(); con->DebugPrintf("Break on script %d, export %d\n", script, pubfunct); + scriptState.debugging = true; breakpointFlag = true; break; } @@ -325,6 +326,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt con->DebugPrintf("Break on %s (in [%04x:%04x])\n", method_name, PRINT_REG(send_obj)); print_send_action = 1; breakpointFlag = true; + scriptState.debugging = true; break; } bp = bp->next; @@ -652,17 +654,19 @@ void run_vm(EngineState *s, int restoring) { } - if (script_abort_flag) + if (script_abort_flag || g_engine->shouldQuit()) return; // Emergency -// TODO: re-enable this -#if 0 // Debug if this has been requested: - if (script_debug_flag || sci_debug_flags) { + // TODO: re-implement sci_debug_flags + if (scriptState.debugging /* sci_debug_flags*/) { script_debug(s, breakpointFlag); breakpointFlag = false; } -#endif + Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger(); + if (con->isAttached()) { + con->onFrame(); + } #ifndef DISABLE_VALIDATIONS if (scriptState.xs->sp < scriptState.xs->fp) diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index f711570d11..ba225a9c00 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -266,18 +266,19 @@ struct ExecStack { }; +// These types are used both as identifiers and as elements of bitfields enum BreakpointType { /** * Break when selector is executed. data contains (char *) selector name * (in the format Object::Method) */ - BREAK_SELECTOR, + BREAK_SELECTOR = 1, /** * Break when an exported function is called. data contains * script_no << 16 | export_no. */ - BREAK_EXPORT + BREAK_EXPORT = 2 }; struct Breakpoint { |