Merge remote-tracking branch 'origin/GP-6298_Dan_fixSnapshotIsNull' into patch

This commit is contained in:
ghidra1
2026-01-12 20:42:51 -05:00
4 changed files with 59 additions and 10 deletions

View File

@@ -228,16 +228,15 @@ public class DebuggerSnapshotTablePanel extends JPanel {
}
TraceSnapshot snapshot = row.getSnapshot();
if (snapshot.getSchedule().isSnapOnly() ||
snapshot.getVersion() >= current.getTrace().getEmulatorCacheVersion()) {
if (snapshot.isStale(true)) {
setForeground(
data.isSelected() ? COLOR_FOREGROUND_STALE_SEL : COLOR_FOREGROUND_STALE);
}
else {
JTable table = data.getTable();
setForeground(
data.isSelected() ? table.getSelectionForeground() : table.getForeground());
}
else {
setForeground(
data.isSelected() ? COLOR_FOREGROUND_STALE_SEL : COLOR_FOREGROUND_STALE);
}
return this;
}

View File

@@ -688,7 +688,7 @@ public class DebuggerEmulationServicePlugin extends Plugin implements DebuggerEm
TraceSchedule time = key.time;
TraceSnapshot tracePrefix = trace.getTimeManager().findSnapshotWithNearestPrefix(time);
if (tracePrefix.getSchedule().isSnapOnly()) {
if (tracePrefix != null && tracePrefix.isSnapOnly(true)) {
tracePrefix = null;
}
Map.Entry<CacheKey, CachedEmulator> cachePrefix = findNearestPrefix(key);

View File

@@ -227,6 +227,28 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
}
}
@Override
public boolean isSnapOnly(boolean whenInconsistent) {
if (schedule == null && key < 0) {
return whenInconsistent;
}
return schedule == null || schedule.isSnapOnly();
}
@Override
public boolean isStale(boolean whenInconsistent) {
if (schedule == null) {
if (key < 0) {
return whenInconsistent;
}
return false; // A recorded snapshot
}
if (schedule.isSnapOnly()) {
return false;
}
return version < manager.trace.getEmulatorCacheVersion();
}
@Override
public void delete() {
manager.deleteSnapshot(this);

View File

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,7 +43,7 @@ public interface TraceSnapshot {
/**
* Get the description of the snapshot
*
* @return
* @return the description
*/
String getDescription();
@@ -131,6 +131,34 @@ public interface TraceSnapshot {
*/
void setVersion(long version);
/**
* Check if a snapshot involves any steps of emulation
* <p>
* A scratch snapshot, i.e., whose key is negative, without a schedule set is considered
* inconsistent.
*
* @param whenInconsistent the value to return for a scratch snapshot without a set schedule
* @return true if no emulation is involved
*/
boolean isSnapOnly(boolean whenInconsistent);
/**
* For an emulated snapshot, check if re-emulation is necessary to produce an up-to-date
* snapshot.
* <p>
* For non-emulated snapshots, this always returns false. A non-emulated snapshot is a snapshot
* whose schedule includes no emulation steps. An emulation snapshot is stale when its version
* is less than the trace's emulator cache version. A scratch snapshot, i.e., whose key is
* negative, without a schedule set is considered inconsistent.
*
* @param whenInconsistent the value to return for a scratch snapshot without a set schedule
* @return true if re-emulation is needed
* @see #getVersion()
* @see #setVersion(long)
* @see Trace#getEmulatorCacheVersion()
*/
boolean isStale(boolean whenInconsistent);
/**
* Delete this snapshot
*