diff options
| author | Willem Jan Palenstijn | 2009-09-30 00:13:59 +0000 | 
|---|---|---|
| committer | Willem Jan Palenstijn | 2009-09-30 00:13:59 +0000 | 
| commit | 77bd8d0bfbfaea6c05ca606ead77334d88cd22d1 (patch) | |
| tree | 37cd9782c6b85de6c37e8b6ea65d4feb10d6f198 | |
| parent | ff70b554eace73fafb0165fb0dc16da91f377ce4 (diff) | |
| download | scummvm-rg350-77bd8d0bfbfaea6c05ca606ead77334d88cd22d1.tar.gz scummvm-rg350-77bd8d0bfbfaea6c05ca606ead77334d88cd22d1.tar.bz2 scummvm-rg350-77bd8d0bfbfaea6c05ca606ead77334d88cd22d1.zip  | |
SCI: Add callk stackframe directly in run_vm
svn-id: r44473
| -rw-r--r-- | engines/sci/engine/selector.cpp | 10 | ||||
| -rw-r--r-- | engines/sci/engine/vm.cpp | 15 | 
2 files changed, 14 insertions, 11 deletions
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index 7711c756ab..e6d40f8155 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -84,15 +84,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc  	}  	va_end(argp); -	// Write "kernel" call to the stack, for debugging:  	ExecStack *xstack; -	xstack = add_exec_stack_entry(s, NULL_REG, NULL, NULL_REG, k_argc, k_argp - 1, 0, NULL_REG, -	                              s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS); -	// FIXME: With this hack, selector was set to -42 - kfunct, which has been changed, as we -	// no longer pass the function number to each function (commit #44461). Therefore, this no -	// longer works. A better alternative needs to be done to restore the previous functionality -	xstack->selector = -42 + 1; // Evil debugging hack to identify kernel function -	xstack->type = EXEC_STACK_TYPE_KERNEL;  	// Now commit the actual function:  	xstack = send_selector(s, object, object, stackframe, framesize, stackframe); @@ -102,8 +94,6 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc  	run_vm(s, 0); // Start a new vm -	s->_executionStack.pop_back(); // Get rid of the extra stack entry -  	return 0;  } diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index de910e012b..c9b665d881 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -946,7 +946,21 @@ void run_vm(EngineState *s, int restoring) {  					reg_t *argv = scriptState.xs->sp + 1;  					if (!kfun.isDummy) { +						// 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, NULL_REG, NULL, NULL_REG, argc, argv - 1, 0, NULL_REG, +	                              s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS); +						// Debugging hack to identify kernel function +						xstack->selector = -42 - opparams[0]; +						xstack->type = EXEC_STACK_TYPE_KERNEL; + +						// Call kernel function  						s->r_acc = kfun.fun(s, argc, argv); + +						// Remove callk stack frame again +						s->_executionStack.pop_back();  					} else {  						Common::String warningMsg = "Dummy function " + kfun.orig_name + "[";  						warningMsg += warningMsg.printf("0x%x", opparams[0]); @@ -962,7 +976,6 @@ void run_vm(EngineState *s, int restoring) {  						warning(warningMsg.c_str());  					}  				} -				// Call kernel function  				// Calculate xs again: The kernel function might  				// have spawned a new VM  | 
