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")) { try (Transaction tx = trace.openTransaction("Invalidate Emulator Cache")) {
trace.setEmulatorCacheVersion(version + 1); 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. // NB. Success should already display on screen, since it's current.
// Failure should be reported by tool's task manager. // Failure should be reported by tool's task manager.
traceManager.materialize(current); traceManager.materialize(current);
@ -749,19 +751,21 @@ public class DebuggerEmulationServicePlugin extends Plugin implements DebuggerEm
} }
protected TraceSnapshot writeToScratch(CacheKey key, CachedEmulator ce) { protected TraceSnapshot writeToScratch(CacheKey key, CachedEmulator ce) {
TraceSnapshot destSnap;
try (Transaction tx = key.trace.openTransaction("Emulate")) { try (Transaction tx = key.trace.openTransaction("Emulate")) {
TraceSnapshot destSnap = findScratch(key.trace, key.time); destSnap = findScratch(key.trace, key.time);
try { try {
ce.emulator().writeDown(key.platform, destSnap.getKey(), key.time.getSnap()); ce.emulator().writeDown(key.platform, destSnap.getKey(), key.time.getSnap());
} }
catch (Throwable e) { catch (Throwable e) {
Msg.showError(this, null, "Emulate", 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.", "The displayed state may be inaccurate and/or incomplete.",
e); e);
} }
return destSnap;
} }
key.trace.clearUndo();
return destSnap;
} }
protected long doEmulate(CacheKey key, TaskMonitor monitor) throws CancelledException { 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.getMemoryManager().getMemoryRegisterSpace(thread, 0, true);
} }
} }
trace.clearUndo();
} }
protected void requireOpen(Trace trace) { protected void requireOpen(Trace trace) {

View file

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

View file

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