SCI: Fix stepping in debugger
svn-id: r42587
This commit is contained in:
parent
6235f9e176
commit
a1bb715611
5 changed files with 45 additions and 18 deletions
|
@ -194,6 +194,7 @@ Console::Console(SciEngine *vm) : GUI::Debugger() {
|
||||||
scriptState.seekLevel = 0;
|
scriptState.seekLevel = 0;
|
||||||
scriptState.runningStep = 0;
|
scriptState.runningStep = 0;
|
||||||
scriptState.stopOnEvent = false;
|
scriptState.stopOnEvent = false;
|
||||||
|
scriptState.debugging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::~Console() {
|
Console::~Console() {
|
||||||
|
@ -2098,21 +2099,24 @@ bool Console::cmdBacktrace(int argc, const char **argv) {
|
||||||
bool Console::cmdStep(int argc, const char **argv) {
|
bool Console::cmdStep(int argc, const char **argv) {
|
||||||
if (argc == 2 && atoi(argv[1]) > 0)
|
if (argc == 2 && atoi(argv[1]) > 0)
|
||||||
scriptState.runningStep = atoi(argv[1]) - 1;
|
scriptState.runningStep = atoi(argv[1]) - 1;
|
||||||
|
scriptState.debugging = true;
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Console::cmdStepEvent(int argc, const char **argv) {
|
bool Console::cmdStepEvent(int argc, const char **argv) {
|
||||||
scriptState.stopOnEvent = true;
|
scriptState.stopOnEvent = true;
|
||||||
|
scriptState.debugging = true;
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Console::cmdStepRet(int argc, const char **argv) {
|
bool Console::cmdStepRet(int argc, const char **argv) {
|
||||||
scriptState.seeking = kDebugSeekLevelRet;
|
scriptState.seeking = kDebugSeekLevelRet;
|
||||||
scriptState.seekLevel = _vm->_gamestate->_executionStack.size() - 1;
|
scriptState.seekLevel = _vm->_gamestate->_executionStack.size() - 1;
|
||||||
|
scriptState.debugging = true;
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Console::cmdStepGlobal(int argc, const char **argv) {
|
bool Console::cmdStepGlobal(int argc, const char **argv) {
|
||||||
|
@ -2124,8 +2128,9 @@ bool Console::cmdStepGlobal(int argc, const char **argv) {
|
||||||
|
|
||||||
scriptState.seeking = kDebugSeekGlobal;
|
scriptState.seeking = kDebugSeekGlobal;
|
||||||
scriptState.seekSpecial = atoi(argv[1]);
|
scriptState.seekSpecial = atoi(argv[1]);
|
||||||
|
scriptState.debugging = true;
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Console::cmdStepCallk(int argc, const char **argv) {
|
bool Console::cmdStepCallk(int argc, const char **argv) {
|
||||||
|
@ -2156,8 +2161,9 @@ bool Console::cmdStepCallk(int argc, const char **argv) {
|
||||||
} else {
|
} else {
|
||||||
scriptState.seeking = kDebugSeekCallk;
|
scriptState.seeking = kDebugSeekCallk;
|
||||||
}
|
}
|
||||||
|
scriptState.debugging = true;
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Console::cmdDissassemble(int argc, const char **argv) {
|
bool Console::cmdDissassemble(int argc, const char **argv) {
|
||||||
|
@ -2322,14 +2328,16 @@ bool Console::cmdSend(int argc, const char **argv) {
|
||||||
xstack->fp += argc;
|
xstack->fp += argc;
|
||||||
|
|
||||||
_vm->_gamestate->_executionStackPosChanged = true;
|
_vm->_gamestate->_executionStackPosChanged = true;
|
||||||
|
scriptState.debugging = true;
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Console::cmdGo(int argc, const char **argv) {
|
bool Console::cmdGo(int argc, const char **argv) {
|
||||||
|
// CHECKME: is this necessary?
|
||||||
scriptState.seeking = kDebugSeekNothing;
|
scriptState.seeking = kDebugSeekNothing;
|
||||||
|
|
||||||
return true;
|
return Cmd_Exit(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Console::cmdBreakpointList(int argc, const char **argv) {
|
bool Console::cmdBreakpointList(int argc, const char **argv) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ enum DebugSeeking {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ScriptState {
|
struct ScriptState {
|
||||||
|
bool debugging;
|
||||||
bool stopOnEvent;
|
bool stopOnEvent;
|
||||||
DebugSeeking seeking; // Stepping forward until some special condition is met
|
DebugSeeking seeking; // Stepping forward until some special condition is met
|
||||||
int runningStep; // Set to > 0 to allow multiple stepping
|
int runningStep; // Set to > 0 to allow multiple stepping
|
||||||
|
|
|
@ -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) {
|
void script_debug(EngineState *s, bool bp) {
|
||||||
// Do we support a separate console?
|
// Do we support a separate console?
|
||||||
|
|
||||||
|
/* if (sci_debug_flags & _DEBUG_FLAG_LOGGING) { */
|
||||||
printf("%d: acc=%04x:%04x ", script_step_counter, PRINT_REG(s->r_acc));
|
printf("%d: acc=%04x:%04x ", script_step_counter, PRINT_REG(s->r_acc));
|
||||||
disassemble(s, scriptState.xs->addr.pc, 0, 1);
|
disassemble(s, scriptState.xs->addr.pc, 0, 1);
|
||||||
if (scriptState.seeking == kDebugSeekGlobal)
|
if (scriptState.seeking == kDebugSeekGlobal)
|
||||||
printf("Global %d (0x%x) = %04x:%04x\n", scriptState.seekSpecial,
|
printf("Global %d (0x%x) = %04x:%04x\n", scriptState.seekSpecial,
|
||||||
scriptState.seekSpecial, PRINT_REG(s->script_000->locals_block->_locals[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?
|
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);
|
MemObject *mobj = GET_SEGMENT(*s->seg_manager, scriptState.xs->addr.pc.segment, MEM_OBJ_SCRIPT);
|
||||||
|
@ -373,6 +380,16 @@ void script_debug(EngineState *s, bool bp) {
|
||||||
|
|
||||||
printf("Step #%d\n", script_step_counter);
|
printf("Step #%d\n", script_step_counter);
|
||||||
disassemble(s, scriptState.xs->addr.pc, 0, 1);
|
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
|
} // End of namespace Sci
|
||||||
|
|
|
@ -655,14 +655,16 @@ void run_vm(EngineState *s, int restoring) {
|
||||||
if (script_abort_flag)
|
if (script_abort_flag)
|
||||||
return; // Emergency
|
return; // Emergency
|
||||||
|
|
||||||
// TODO: re-enable this
|
|
||||||
#if 0
|
|
||||||
// Debug if this has been requested:
|
// 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);
|
script_debug(s, breakpointFlag);
|
||||||
breakpointFlag = false;
|
breakpointFlag = false;
|
||||||
}
|
}
|
||||||
#endif
|
Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
|
||||||
|
if (con->isAttached()) {
|
||||||
|
con->onFrame();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_VALIDATIONS
|
#ifndef DISABLE_VALIDATIONS
|
||||||
if (scriptState.xs->sp < scriptState.xs->fp)
|
if (scriptState.xs->sp < scriptState.xs->fp)
|
||||||
|
|
|
@ -1380,7 +1380,6 @@ static sci_event_t scummvm_get_event(GfxDriver *drv) {
|
||||||
// Open debug console
|
// Open debug console
|
||||||
Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
|
Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
|
||||||
con->attach();
|
con->attach();
|
||||||
con->onFrame();
|
|
||||||
|
|
||||||
// Clear keyboard event
|
// Clear keyboard event
|
||||||
input.type = SCI_EVT_NONE;
|
input.type = SCI_EVT_NONE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue