aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2017-02-03 09:58:57 -0600
committerColin Snover2017-03-30 20:49:36 -0500
commita1153661c4747711abc52a35a54bc04c8f56f0cf (patch)
treeebd55649b36a7c0d5f7c59b9d26671fcafdb67b2
parent5723f2f5feb4dc0b51423e7d03c6fc05dc201c9e (diff)
downloadscummvm-rg350-a1153661c4747711abc52a35a54bc04c8f56f0cf.tar.gz
scummvm-rg350-a1153661c4747711abc52a35a54bc04c8f56f0cf.tar.bz2
scummvm-rg350-a1153661c4747711abc52a35a54bc04c8f56f0cf.zip
SCI: Stop getCurrentCallOrigin from mutating stack frames
This fixes incorrect backtraces after a workaround failure or other call to getCurrentCallOrigin when one or more stack frames are calls to local procedures.
-rw-r--r--engines/sci/engine/state.cpp17
-rw-r--r--engines/sci/engine/workarounds.cpp2
2 files changed, 11 insertions, 8 deletions
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index c23add1211..76df322b30 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -390,26 +390,29 @@ SciCallOrigin EngineState::getCurrentCallOrigin() const {
const Script *localScript = _segMan->getScriptIfLoaded(xs->local_segment);
int curScriptNr = localScript->getScriptNumber();
+ Selector debugSelector = xs->debugSelector;
+ int debugExportId = xs->debugExportId;
+
if (xs->debugLocalCallOffset != -1) {
// if lastcall was actually a local call search back for a real call
Common::List<ExecStack>::const_iterator callIterator = _executionStack.end();
while (callIterator != _executionStack.begin()) {
callIterator--;
const ExecStack &loopCall = *callIterator;
- if ((loopCall.debugSelector != -1) || (loopCall.debugExportId != -1)) {
- xs->debugSelector = loopCall.debugSelector;
- xs->debugExportId = loopCall.debugExportId;
+ if (loopCall.debugSelector != -1 || loopCall.debugExportId != -1) {
+ debugSelector = loopCall.debugSelector;
+ debugExportId = loopCall.debugExportId;
break;
}
}
}
if (xs->type == EXEC_STACK_TYPE_CALL) {
- if (xs->debugSelector != -1) {
- curMethodName = g_sci->getKernel()->getSelectorName(xs->debugSelector);
- } else if (xs->debugExportId != -1) {
+ if (debugSelector != -1) {
+ curMethodName = g_sci->getKernel()->getSelectorName(debugSelector);
+ } else if (debugExportId != -1) {
curObjectName = "";
- curMethodName = Common::String::format("export %d", xs->debugExportId);
+ curMethodName = Common::String::format("export %d", debugExportId);
}
}
diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index 148e9e77c3..025e94ad76 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -876,7 +876,7 @@ const SciWorkaroundEntry kScrollWindowAdd_workarounds[] = {
SciWorkaroundSolution trackOriginAndFindWorkaround(int index, const SciWorkaroundEntry *workaroundList, SciCallOrigin *trackOrigin) {
const EngineState *state = g_sci->getEngineState();
- ExecStack *lastCall = state->xs;
+ const ExecStack *lastCall = state->xs;
const SciGameId gameId = g_sci->getGameId();
*trackOrigin = state->getCurrentCallOrigin();