diff options
author | Martin Kiewitz | 2010-07-10 20:50:52 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-07-10 20:50:52 +0000 |
commit | 09fd47236d82c169a0c2886f6baa752beb401a3d (patch) | |
tree | 8b80c2f5a9fd6713e102af634c61debcba566b29 /engines/sci/engine | |
parent | 5e4d4fde678e0fda0bd371770046208d7082b8c4 (diff) | |
download | scummvm-rg350-09fd47236d82c169a0c2886f6baa752beb401a3d.tar.gz scummvm-rg350-09fd47236d82c169a0c2886f6baa752beb401a3d.tar.bz2 scummvm-rg350-09fd47236d82c169a0c2886f6baa752beb401a3d.zip |
SCI: adding to execstack only right before executing kernel call, otherwise it wouldnt be possible to skip over sub-function kernel calls via workarounds
svn-id: r50792
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/vm.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 4755db3922..b265170cad 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -776,6 +776,17 @@ static reg_t pointer_add(EngineState *s, reg_t base, int offset) { } } +static void addKernelCallToExecStack(EngineState *s, int kernelCallNr, int argc, reg_t *argv) { + // Add stack frame to indicate we're executing a callk. + // This is useful in debugger backtraces if this + // kernel function calls a script itself. + ExecStack *xstack; + xstack = add_exec_stack_entry(s->_executionStack, NULL_REG, NULL, NULL_REG, argc, argv - 1, 0, -1, -1, NULL_REG, + s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS); + xstack->debugSelector = kernelCallNr; + xstack->type = EXEC_STACK_TYPE_KERNEL; +} + static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { Kernel *kernel = g_sci->getKernel(); @@ -802,17 +813,10 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { return; } - // Add stack frame to indicate we're executing a callk. - // This is useful in debugger backtraces if this - // kernel function calls a script itself. - ExecStack *xstack; - xstack = add_exec_stack_entry(s->_executionStack, NULL_REG, NULL, NULL_REG, argc, argv - 1, 0, -1, -1, NULL_REG, - s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS); - xstack->debugSelector = kernelCallNr; - xstack->type = EXEC_STACK_TYPE_KERNEL; // Call kernel function if (!kernelCall.subFunctionCount) { + addKernelCallToExecStack(s, kernelCallNr, argc, argv); s->r_acc = kernelCall.function(s, argc, argv); } else { // Sub-functions available, check signature and call that one directly @@ -847,6 +851,7 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { } if (!kernelSubCall.function) error("[VM] k%s: subfunction-id %d requested, but not available", kernelCall.name, subId); + addKernelCallToExecStack(s, kernelCallNr, argc, argv); s->r_acc = kernelSubCall.function(s, argc, argv); } |