GP-3213: Prevent trace.undo where it might cause inconsistencies.

This commit is contained in:
Dan 2023-04-26 12:09:39 -04:00
parent 8aa9c8be3a
commit c0835bf903
3 changed files with 11 additions and 3 deletions

View File

@ -559,6 +559,8 @@ public class DebuggerEmulationServicePlugin extends Plugin implements DebuggerEm
try (Transaction tx = trace.openTransaction("Invalidate Emulator Cache")) {
trace.setEmulatorCacheVersion(version + 1);
}
// Do not call clearUndo() here. This is supposed to be undoable.
// NB. Success should already display on screen, since it's current.
// Failure should be reported by tool's task manager.
traceManager.materialize(current);
@ -749,19 +751,21 @@ public class DebuggerEmulationServicePlugin extends Plugin implements DebuggerEm
}
protected TraceSnapshot writeToScratch(CacheKey key, CachedEmulator ce) {
TraceSnapshot destSnap;
try (Transaction tx = key.trace.openTransaction("Emulate")) {
TraceSnapshot destSnap = findScratch(key.trace, key.time);
destSnap = findScratch(key.trace, key.time);
try {
ce.emulator().writeDown(key.platform, destSnap.getKey(), key.time.getSnap());
}
catch (Throwable e) {
Msg.showError(this, null, "Emulate",
"There was an issue writing the emulation result to trace trace. " +
"There was an issue writing the emulation result to the trace. " +
"The displayed state may be inaccurate and/or incomplete.",
e);
}
return destSnap;
}
key.trace.clearUndo();
return destSnap;
}
protected long doEmulate(CacheKey key, TaskMonitor monitor) throws CancelledException {
@ -798,6 +802,7 @@ public class DebuggerEmulationServicePlugin extends Plugin implements DebuggerEm
trace.getMemoryManager().getMemoryRegisterSpace(thread, 0, true);
}
}
trace.clearUndo();
}
protected void requireOpen(Trace trace) {

View File

@ -346,6 +346,7 @@ public enum ProgramEmulationUtils {
loadExecutable(initial, program);
doLaunchEmulationThread(trace, snap, program, pc, pc);
}
trace.clearUndo();
success = true;
return trace;
}

View File

@ -175,6 +175,7 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
e.unwrap(LanguageNotFoundException.class);
throw new AssertionError(e);
}
clearUndo(false);
changeSet = traceChangeSet = new DBTraceChangeSet();
recordChanges = true;
@ -194,6 +195,7 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
e.unwrap(LanguageNotFoundException.class);
throw new AssertionError(e);
}
clearUndo(false);
changeSet = traceChangeSet = new DBTraceChangeSet();
recordChanges = true;