mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-2970: Add 'Invalidate Emulator Cache' action.
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
##VERSION: 2.0
|
||||
Module.manifest||GHIDRA||||END|
|
||||
data/tracemodeling.theme.properties||GHIDRA||||END|
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
[Defaults]
|
||||
|
||||
icon.content.handler.trace = video-x-generic16.png
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
@@ -80,6 +80,7 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
||||
protected static final String BASE_COMPILER = "Base Compiler";
|
||||
protected static final String PLATFORM = "Platform";
|
||||
protected static final String EXECUTABLE_PATH = "Executable Location";
|
||||
protected static final String EMU_CACHE_VERSION = "Emulator Cache Version";
|
||||
|
||||
protected static final int DB_TIME_INTERVAL = 500;
|
||||
protected static final int DB_BUFFER_SIZE = 1000;
|
||||
@@ -754,6 +755,16 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
||||
return getOptions(TRACE_INFO).getDate(DATE_CREATED, new Date(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEmulatorCacheVersion(long version) {
|
||||
getOptions(TRACE_INFO).setLong(EMU_CACHE_VERSION, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEmulatorCacheVersion() {
|
||||
return getOptions(TRACE_INFO).getLong(EMU_CACHE_VERSION, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TraceProgramView> getAllProgramViews() {
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ package ghidra.trace.database;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import db.DBHandle;
|
||||
import db.buffers.BufferFile;
|
||||
@@ -39,7 +38,7 @@ import ghidra.util.task.TaskMonitor;
|
||||
public class DBTraceContentHandler extends DBWithUserDataContentHandler<DBTrace> {
|
||||
public static final String TRACE_CONTENT_TYPE = "Trace";
|
||||
|
||||
public static ImageIcon TRACE_ICON = Trace.TRACE_ICON;
|
||||
public static final Icon TRACE_ICON = Trace.TRACE_ICON;
|
||||
|
||||
static final Class<DBTrace> TRACE_DOMAIN_OBJECT_CLASS = DBTrace.class;
|
||||
static final String TRACE_CONTENT_DEFAULT_TOOL = "Debugger";
|
||||
|
||||
@@ -19,11 +19,9 @@ import java.io.IOException;
|
||||
|
||||
import db.DBRecord;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.Trace.TraceSnapshotChangeType;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.trace.model.time.TraceSnapshot;
|
||||
import ghidra.trace.model.time.schedule.TraceSchedule;
|
||||
import ghidra.trace.util.TraceChangeRecord;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.database.*;
|
||||
@@ -35,6 +33,7 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
|
||||
|
||||
protected static final String REAL_TIME_COLUMN_NAME = "RealTime";
|
||||
protected static final String SCHEDULE_COLUMN_NAME = "Schedule";
|
||||
protected static final String VERSION_COLUMN_NAME = "Version";
|
||||
protected static final String DESCRIPTION_COLUMN_NAME = "Description";
|
||||
protected static final String THREAD_COLUMN_NAME = "Thread";
|
||||
|
||||
@@ -42,6 +41,8 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
|
||||
static DBObjectColumn REAL_TIME_COLUMN;
|
||||
@DBAnnotatedColumn(SCHEDULE_COLUMN_NAME)
|
||||
static DBObjectColumn SCHEDULE_COLUMN;
|
||||
@DBAnnotatedColumn(VERSION_COLUMN_NAME)
|
||||
static DBObjectColumn VERSION_COLUMN;
|
||||
@DBAnnotatedColumn(DESCRIPTION_COLUMN_NAME)
|
||||
static DBObjectColumn DESCRIPTION_COLUMN;
|
||||
@DBAnnotatedColumn(THREAD_COLUMN_NAME)
|
||||
@@ -51,6 +52,8 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
|
||||
long realTime; // milliseconds
|
||||
@DBAnnotatedField(column = SCHEDULE_COLUMN_NAME, indexed = true)
|
||||
String scheduleStr = "";
|
||||
@DBAnnotatedField(column = VERSION_COLUMN_NAME)
|
||||
long version;
|
||||
@DBAnnotatedField(column = DESCRIPTION_COLUMN_NAME)
|
||||
String description;
|
||||
@DBAnnotatedField(column = THREAD_COLUMN_NAME)
|
||||
@@ -107,7 +110,9 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
|
||||
|
||||
@Override
|
||||
public long getRealTime() {
|
||||
return realTime;
|
||||
try (LockHold hold = LockHold.lock(manager.lock.readLock())) {
|
||||
return realTime;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,7 +126,9 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
try (LockHold hold = LockHold.lock(manager.lock.readLock())) {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,7 +142,9 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
|
||||
|
||||
@Override
|
||||
public TraceThread getEventThread() {
|
||||
return eventThread;
|
||||
try (LockHold hold = LockHold.lock(manager.lock.readLock())) {
|
||||
return eventThread;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,12 +165,16 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
|
||||
|
||||
@Override
|
||||
public TraceSchedule getSchedule() {
|
||||
return schedule;
|
||||
try (LockHold hold = LockHold.lock(manager.lock.readLock())) {
|
||||
return schedule;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheduleString() {
|
||||
return scheduleStr;
|
||||
try (LockHold hold = LockHold.lock(manager.lock.readLock())) {
|
||||
return scheduleStr;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,6 +187,22 @@ public class DBTraceSnapshot extends DBAnnotatedObject implements TraceSnapshot
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVersion() {
|
||||
try (LockHold hold = LockHold.lock(manager.lock.readLock())) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVersion(long version) {
|
||||
try (LockHold hold = LockHold.lock(manager.lock.writeLock())) {
|
||||
this.version = version;
|
||||
update(VERSION_COLUMN);
|
||||
manager.notifySnapshotChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
manager.deleteSnapshot(this);
|
||||
|
||||
@@ -17,8 +17,9 @@ package ghidra.trace.model;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.Icon;
|
||||
|
||||
import generic.theme.GIcon;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.lang.CompilerSpec;
|
||||
@@ -48,10 +49,20 @@ import ghidra.trace.model.time.TraceTimeManager;
|
||||
import ghidra.trace.util.DefaultTraceChangeType;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.UniversalID;
|
||||
import resources.ResourceManager;
|
||||
|
||||
/**
|
||||
* An indexed record of observations over the course of a target's execution
|
||||
*
|
||||
* <p>
|
||||
* Conceptually, this is the same as a {@link Program}, but multiplied by a concrete dimension of
|
||||
* time and organized into {@link TraceSnapshot snapshots}. This also includes information about
|
||||
* other objects not ordinarily of concern for static analysis, for example, {@link TraceThread
|
||||
* threads}, {@link TraceModule modules}, and {@link TraceBreakpoint breakpoints}. To view a
|
||||
* specific snapshot and/or manipulate the trace as if it were a program, use
|
||||
* {@link #getProgramView()}.
|
||||
*/
|
||||
public interface Trace extends DataTypeManagerDomainObject {
|
||||
ImageIcon TRACE_ICON = ResourceManager.loadImage("images/video-x-generic16.png");
|
||||
Icon TRACE_ICON = new GIcon("icon.content.handler.trace");
|
||||
|
||||
/**
|
||||
* TEMPORARY: An a/b switch while both table- (legacy) and object-mode traces are supported
|
||||
@@ -411,6 +422,10 @@ public interface Trace extends DataTypeManagerDomainObject {
|
||||
|
||||
CompilerSpec getBaseCompilerSpec();
|
||||
|
||||
void setEmulatorCacheVersion(long version);
|
||||
|
||||
long getEmulatorCacheVersion();
|
||||
|
||||
AddressFactory getBaseAddressFactory();
|
||||
|
||||
TraceAddressPropertyManager getAddressPropertyManager();
|
||||
|
||||
@@ -115,6 +115,22 @@ public interface TraceSnapshot {
|
||||
*/
|
||||
void setSchedule(TraceSchedule schedule);
|
||||
|
||||
/**
|
||||
* Get the snapshot's version, esp., when it represents a cache entry
|
||||
*
|
||||
* @see Trace#getEmulatorCacheVersion()
|
||||
* @return the version
|
||||
*/
|
||||
long getVersion();
|
||||
|
||||
/**
|
||||
* Set the snapshot's version, esp., when it represents a cache entry
|
||||
*
|
||||
* @see Trace#getEmulatorCacheVersion()
|
||||
* @param version the version
|
||||
*/
|
||||
void setVersion(long version);
|
||||
|
||||
/**
|
||||
* Delete this snapshot
|
||||
*
|
||||
|
||||
@@ -21,6 +21,12 @@ import java.util.*;
|
||||
|
||||
import ghidra.framework.model.DomainObjectChangeRecord;
|
||||
|
||||
/**
|
||||
* A trace change type, assigned a number at runtime
|
||||
*
|
||||
* @param <T> the type of object changed
|
||||
* @param <U> the type of the object's attribute that changed
|
||||
*/
|
||||
public class DefaultTraceChangeType<T, U> implements TraceChangeType<T, U> {
|
||||
private static int nextType = 0x3ACE; // Stay far away from manually-assigned types
|
||||
// But not too far, since it makes the bit set for events gigantic.
|
||||
|
||||
Reference in New Issue
Block a user