mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-08-27 21:10:26 +00:00
GP-4403 Use OpenMode enum instead of DBConstants integer value. Disallow transactions when using immutable DomainObject (implemented for ProgramDB and Datatype Archives).
This commit is contained in:
parent
434c3f315d
commit
41712078e2
|
@ -21,7 +21,6 @@ import java.net.Socket;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import generic.test.AbstractGTest;
|
||||
import ghidra.GhidraApplicationLayout;
|
||||
|
@ -29,6 +28,7 @@ import ghidra.GhidraTestApplicationLayout;
|
|||
import ghidra.base.project.GhidraProject;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.GhidraApplicationConfiguration;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.framework.model.ProjectData;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
|
@ -139,7 +139,7 @@ public class IsfServer extends Thread {
|
|||
DBHandle dbh = db.openForUpdate(dummy);
|
||||
ProgramDB p = null;
|
||||
try {
|
||||
p = new ProgramDB(dbh, DBConstants.UPDATE, dummy, this);
|
||||
p = new ProgramDB(dbh, OpenMode.UPDATE, dummy, this);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable()) {
|
||||
|
@ -151,7 +151,7 @@ public class IsfServer extends Thread {
|
|||
}
|
||||
|
||||
dbh = db.openForUpdate(dummy);
|
||||
p = new ProgramDB(dbh, DBConstants.UPGRADE, dummy, this);
|
||||
p = new ProgramDB(dbh, OpenMode.UPGRADE, dummy, this);
|
||||
|
||||
if (!p.isChanged()) {
|
||||
throw new RuntimeException(p + " uses an older version and was not upgraded.");
|
||||
|
@ -161,8 +161,8 @@ public class IsfServer extends Thread {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||
GhidraApplicationLayout layout = new GhidraTestApplicationLayout(
|
||||
new File(AbstractGTest.getTestDirectoryPath()));
|
||||
GhidraApplicationLayout layout =
|
||||
new GhidraTestApplicationLayout(new File(AbstractGTest.getTestDirectoryPath()));
|
||||
GhidraApplicationConfiguration config = new GhidraApplicationConfiguration();
|
||||
config.setShowSplashScreen(false);
|
||||
Application.initializeApplication(layout, config);
|
||||
|
|
|
@ -26,6 +26,7 @@ import db.DBHandle;
|
|||
import db.Transaction;
|
||||
import generic.depends.DependentService;
|
||||
import generic.depends.err.ServiceConstructionException;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainObjectChangeRecord;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.lifecycle.Internal;
|
||||
|
@ -64,7 +65,8 @@ import ghidra.trace.util.*;
|
|||
import ghidra.trace.util.CopyOnWrite.WeakHashCowSet;
|
||||
import ghidra.trace.util.CopyOnWrite.WeakValueHashCowMap;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.database.*;
|
||||
import ghidra.util.database.DBCachedDomainObjectAdapter;
|
||||
import ghidra.util.database.DBCachedObjectStoreFactory;
|
||||
import ghidra.util.datastruct.ListenerSet;
|
||||
import ghidra.util.exception.*;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -154,7 +156,7 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
|||
|
||||
public DBTrace(String name, CompilerSpec baseCompilerSpec, Object consumer)
|
||||
throws IOException, LanguageNotFoundException {
|
||||
super(new DBHandle(), DBOpenMode.CREATE, TaskMonitor.DUMMY, name, DB_TIME_INTERVAL,
|
||||
super(new DBHandle(), OpenMode.CREATE, TaskMonitor.DUMMY, name, DB_TIME_INTERVAL,
|
||||
DB_BUFFER_SIZE, consumer);
|
||||
|
||||
this.storeFactory = new DBCachedObjectStoreFactory(this);
|
||||
|
@ -167,7 +169,7 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
|||
space -> getAddressSet(space));
|
||||
|
||||
try (Transaction tx = this.openTransaction("Create")) {
|
||||
initOptions(DBOpenMode.CREATE);
|
||||
initOptions(OpenMode.CREATE);
|
||||
init();
|
||||
}
|
||||
catch (VersionException | CancelledException e) {
|
||||
|
@ -189,7 +191,7 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
|||
return new AddressSet(space.getMinAddress(), space.getMaxAddress());
|
||||
}
|
||||
|
||||
public DBTrace(DBHandle dbh, DBOpenMode openMode, TaskMonitor monitor, Object consumer)
|
||||
public DBTrace(DBHandle dbh, OpenMode openMode, TaskMonitor monitor, Object consumer)
|
||||
throws CancelledException, VersionException, IOException, LanguageNotFoundException {
|
||||
super(dbh, openMode, monitor, "Untitled", DB_TIME_INTERVAL, DB_BUFFER_SIZE, consumer);
|
||||
this.storeFactory = new DBCachedObjectStoreFactory(this);
|
||||
|
@ -209,9 +211,9 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
|||
programView = createProgramView(0);
|
||||
}
|
||||
|
||||
protected void initOptions(DBOpenMode openMode) throws IOException, CancelledException {
|
||||
protected void initOptions(OpenMode openMode) throws IOException, CancelledException {
|
||||
Options traceInfo = getOptions(TRACE_INFO);
|
||||
if (openMode == DBOpenMode.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
traceInfo.setString(NAME, name);
|
||||
traceInfo.setDate(DATE_CREATED, new Date());
|
||||
traceInfo.setString(BASE_LANGUAGE, baseLanguage.getLanguageID().getIdAsString());
|
||||
|
@ -659,9 +661,8 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
|||
if (recordChanges) {
|
||||
traceChangeSet.sourceArchiveChanged(sourceArchiveID.getValue());
|
||||
}
|
||||
setChanged(
|
||||
new TraceChangeRecord<>(TraceEvents.SOURCE_TYPE_ARCHIVE_CHANGED, null,
|
||||
sourceArchiveID));
|
||||
setChanged(new TraceChangeRecord<>(TraceEvents.SOURCE_TYPE_ARCHIVE_CHANGED, null,
|
||||
sourceArchiveID));
|
||||
}
|
||||
|
||||
public void sourceArchiveAdded(UniversalID sourceArchiveID) {
|
||||
|
@ -684,8 +685,7 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
|||
if (recordChanges) {
|
||||
traceChangeSet.dataTypeAdded(addedID);
|
||||
}
|
||||
setChanged(
|
||||
new TraceChangeRecord<>(TraceEvents.DATA_TYPE_ADDED, null, addedID, addedType));
|
||||
setChanged(new TraceChangeRecord<>(TraceEvents.DATA_TYPE_ADDED, null, addedID, addedType));
|
||||
}
|
||||
|
||||
public void dataTypeReplaced(long replacedID, DataTypePath replacedPath, DataTypePath newPath) {
|
||||
|
@ -700,16 +700,16 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
|
|||
if (recordChanges) {
|
||||
traceChangeSet.dataTypeChanged(movedID);
|
||||
}
|
||||
setChanged(new TraceChangeRecord<>(TraceEvents.DATA_TYPE_MOVED, null, movedID, oldPath,
|
||||
newPath));
|
||||
setChanged(
|
||||
new TraceChangeRecord<>(TraceEvents.DATA_TYPE_MOVED, null, movedID, oldPath, newPath));
|
||||
}
|
||||
|
||||
public void dataTypeNameChanged(long renamedID, String oldName, String newName) {
|
||||
if (recordChanges) {
|
||||
traceChangeSet.dataTypeChanged(renamedID);
|
||||
}
|
||||
setChanged(new TraceChangeRecord<>(TraceEvents.DATA_TYPE_RENAMED, null, renamedID,
|
||||
oldName, newName));
|
||||
setChanged(new TraceChangeRecord<>(TraceEvents.DATA_TYPE_RENAMED, null, renamedID, oldName,
|
||||
newName));
|
||||
}
|
||||
|
||||
public void dataTypeDeleted(long deletedID, DataTypePath deletedPath) {
|
||||
|
|
|
@ -22,15 +22,13 @@ import javax.swing.Icon;
|
|||
import db.DBHandle;
|
||||
import db.buffers.BufferFile;
|
||||
import db.buffers.ManagedBufferFile;
|
||||
import ghidra.framework.data.DBWithUserDataContentHandler;
|
||||
import ghidra.framework.data.DomainObjectMergeManager;
|
||||
import ghidra.framework.data.*;
|
||||
import ghidra.framework.model.ChangeSet;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.framework.store.*;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.util.InvalidNameException;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -71,7 +69,7 @@ public class DBTraceContentHandler extends DBWithUserDataContentHandler<DBTrace>
|
|||
try {
|
||||
bf = dbItem.open(version, minChangeVersion);
|
||||
dbh = new DBHandle(bf);
|
||||
DBOpenMode openMode = DBOpenMode.READ_ONLY;
|
||||
OpenMode openMode = OpenMode.IMMUTABLE;
|
||||
trace = new DBTrace(dbh, openMode, monitor, consumer);
|
||||
getTraceChangeSet(trace, bf);
|
||||
success = true;
|
||||
|
@ -119,7 +117,7 @@ public class DBTraceContentHandler extends DBWithUserDataContentHandler<DBTrace>
|
|||
try {
|
||||
bf = dbItem.open(version);
|
||||
dbh = new DBHandle(bf);
|
||||
DBOpenMode openMode = okToUpgrade ? DBOpenMode.UPGRADE : DBOpenMode.UPDATE;
|
||||
OpenMode openMode = okToUpgrade ? OpenMode.UPGRADE : OpenMode.UPDATE;
|
||||
trace = new DBTrace(dbh, openMode, monitor, consumer);
|
||||
getTraceChangeSet(trace, bf);
|
||||
trace.setTraceUserData(new DBTraceUserData(trace));
|
||||
|
@ -169,7 +167,7 @@ public class DBTraceContentHandler extends DBWithUserDataContentHandler<DBTrace>
|
|||
try {
|
||||
bf = dbItem.openForUpdate(checkoutId);
|
||||
dbh = new DBHandle(bf, recover, monitor);
|
||||
DBOpenMode openMode = okToUpgrade ? DBOpenMode.UPGRADE : DBOpenMode.UPDATE;
|
||||
OpenMode openMode = okToUpgrade ? OpenMode.UPGRADE : OpenMode.UPDATE;
|
||||
trace = new DBTrace(dbh, openMode, monitor, consumer);
|
||||
if (checkoutId == FolderItem.DEFAULT_CHECKOUT_ID) {
|
||||
getTraceChangeSet(trace, bf);
|
||||
|
@ -275,7 +273,7 @@ public class DBTraceContentHandler extends DBWithUserDataContentHandler<DBTrace>
|
|||
try {
|
||||
bf = dbItem.open(toVer, fromVer);
|
||||
dbh = new DBHandle(bf);
|
||||
DBOpenMode openMode = DBOpenMode.READ_ONLY;
|
||||
OpenMode openMode = OpenMode.IMMUTABLE;
|
||||
trace = new DBTrace(dbh, openMode, null, this);
|
||||
return getTraceChangeSet(trace, bf);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.*;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramAddressFactory;
|
||||
import ghidra.program.database.ProgramOverlayAddressSpace;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -149,7 +150,7 @@ public class DBTraceOverlaySpaceAdapter implements DBTraceManager {
|
|||
protected final DBCachedObjectStore<DBTraceOverlaySpaceEntry> overlayStore;
|
||||
protected final DBCachedObjectIndex<String, DBTraceOverlaySpaceEntry> overlaysByName;
|
||||
|
||||
public DBTraceOverlaySpaceAdapter(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceOverlaySpaceAdapter(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, DBTrace trace) throws VersionException, IOException {
|
||||
this.dbh = dbh;
|
||||
this.lock = lock;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
import javax.swing.Icon;
|
||||
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -39,7 +40,6 @@ import ghidra.trace.util.TraceChangeRecord;
|
|||
import ghidra.trace.util.TraceEvents;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
@ -167,7 +167,7 @@ public class DBTraceBookmarkManager extends AbstractDBTraceSpaceBasedManager<DBT
|
|||
protected final Collection<DBTraceBookmarkType> typesView =
|
||||
Collections.unmodifiableCollection(typesByName.values());
|
||||
|
||||
public DBTraceBookmarkManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceBookmarkManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws VersionException, IOException {
|
||||
super(NAME, dbh, openMode, lock, monitor, baseLanguage, trace, threadManager);
|
||||
|
@ -182,8 +182,8 @@ public class DBTraceBookmarkManager extends AbstractDBTraceSpaceBasedManager<DBT
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DBTraceBookmarkSpace createRegisterSpace(AddressSpace space,
|
||||
TraceThread thread, DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
protected DBTraceBookmarkSpace createRegisterSpace(AddressSpace space, TraceThread thread,
|
||||
DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
return new DBTraceBookmarkSpace(this, space, thread, ent.getFrameLevel());
|
||||
}
|
||||
|
||||
|
@ -292,8 +292,8 @@ public class DBTraceBookmarkManager extends AbstractDBTraceSpaceBasedManager<DBT
|
|||
}
|
||||
|
||||
@Override
|
||||
public DBTraceBookmark addBookmark(Lifespan lifespan, Address address,
|
||||
TraceBookmarkType type, String category, String comment) {
|
||||
public DBTraceBookmark addBookmark(Lifespan lifespan, Address address, TraceBookmarkType type,
|
||||
String category, String comment) {
|
||||
return delegateWrite(address.getAddressSpace(),
|
||||
m -> m.addBookmark(lifespan, address, type, category, comment));
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
|
||||
import db.DBHandle;
|
||||
import ghidra.dbg.target.TargetBreakpointLocation;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -33,7 +34,6 @@ import ghidra.trace.model.Lifespan;
|
|||
import ghidra.trace.model.breakpoint.*;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -43,7 +43,7 @@ public class DBTraceBreakpointManager
|
|||
implements TraceBreakpointManager, DBTraceDelegatingManager<DBTraceBreakpointSpace> {
|
||||
protected static final String NAME = "Breakpoint";
|
||||
|
||||
public DBTraceBreakpointManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceBreakpointManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws VersionException, IOException {
|
||||
super(NAME, dbh, openMode, lock, monitor, baseLanguage, trace, threadManager);
|
||||
|
@ -129,8 +129,7 @@ public class DBTraceBreakpointManager
|
|||
.getObjectByPath(snap, path, TraceObjectBreakpointLocation.class);
|
||||
}
|
||||
try (LockHold hold = LockHold.lock(lock.readLock())) {
|
||||
return getBreakpointsByPath(path)
|
||||
.stream()
|
||||
return getBreakpointsByPath(path).stream()
|
||||
.filter(b -> b.getLifespan().contains(snap))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
|
||||
import db.DBHandle;
|
||||
import db.DBRecord;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.*;
|
||||
import ghidra.program.model.listing.ProgramContext;
|
||||
|
@ -40,15 +41,15 @@ import ghidra.trace.model.TraceAddressSnapRange;
|
|||
import ghidra.trace.model.context.TraceRegisterContextManager;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.database.*;
|
||||
import ghidra.util.database.DBCachedObjectStore;
|
||||
import ghidra.util.database.DBObjectColumn;
|
||||
import ghidra.util.database.annot.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class DBTraceRegisterContextManager
|
||||
extends AbstractDBTraceSpaceBasedManager<DBTraceRegisterContextSpace>
|
||||
implements TraceRegisterContextManager,
|
||||
DBTraceDelegatingManager<DBTraceRegisterContextSpace> {
|
||||
extends AbstractDBTraceSpaceBasedManager<DBTraceRegisterContextSpace> implements
|
||||
TraceRegisterContextManager, DBTraceDelegatingManager<DBTraceRegisterContextSpace> {
|
||||
public static final String NAME = "RegisterContext";
|
||||
|
||||
@DBAnnotatedObjectInfo(version = 0)
|
||||
|
@ -87,7 +88,7 @@ public class DBTraceRegisterContextManager
|
|||
|
||||
protected final Map<Language, ProgramContext> defaultContexts = new HashMap<>();
|
||||
|
||||
public DBTraceRegisterContextManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceRegisterContextManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager, DBTracePlatformManager languageManager)
|
||||
throws VersionException, IOException {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
|
||||
import db.DBHandle;
|
||||
import db.DBRecord;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -176,7 +177,7 @@ public class DBTraceDataSettingsAdapter
|
|||
}
|
||||
}
|
||||
|
||||
public DBTraceDataSettingsAdapter(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceDataSettingsAdapter(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws IOException, VersionException {
|
||||
super(NAME, dbh, openMode, lock, monitor, baseLanguage, trace, threadManager,
|
||||
|
@ -184,17 +185,16 @@ public class DBTraceDataSettingsAdapter
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DBTraceDataSettingsSpace createSpace(
|
||||
AddressSpace space, DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
protected DBTraceDataSettingsSpace createSpace(AddressSpace space, DBTraceSpaceEntry ent)
|
||||
throws VersionException, IOException {
|
||||
return new DBTraceDataSettingsSpace(
|
||||
tableName(space, ent.getThreadKey(), ent.getFrameLevel()), trace.getStoreFactory(),
|
||||
lock, space, null, 0, dataType, dataFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DBTraceDataSettingsSpace createRegisterSpace(
|
||||
AddressSpace space, TraceThread thread, DBTraceSpaceEntry ent)
|
||||
throws VersionException, IOException {
|
||||
protected DBTraceDataSettingsSpace createRegisterSpace(AddressSpace space, TraceThread thread,
|
||||
DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
return new DBTraceDataSettingsSpace(
|
||||
tableName(space, ent.getThreadKey(), ent.getFrameLevel()), trace.getStoreFactory(),
|
||||
lock, space, thread, ent.getFrameLevel(), dataType, dataFactory);
|
||||
|
@ -206,8 +206,7 @@ public class DBTraceDataSettingsAdapter
|
|||
}
|
||||
|
||||
@Override
|
||||
public DBTraceDataSettingsSpace getRegisterSpace(TraceThread thread,
|
||||
boolean createIfAbsent) {
|
||||
public DBTraceDataSettingsSpace getRegisterSpace(TraceThread thread, boolean createIfAbsent) {
|
||||
return (DBTraceDataSettingsSpace) super.getRegisterSpace(thread, createIfAbsent);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
|
||||
import db.DBHandle;
|
||||
import db.Transaction;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.program.database.data.ProgramBasedDataTypeManagerDB;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -33,7 +34,6 @@ import ghidra.trace.database.DBTraceManager;
|
|||
import ghidra.trace.model.data.TraceBasedDataTypeManager;
|
||||
import ghidra.util.InvalidNameException;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -46,11 +46,10 @@ public class DBTraceDataTypeManager extends ProgramBasedDataTypeManagerDB
|
|||
|
||||
private static final String INSTANCE_TABLE_PREFIX = null; // placeholder only
|
||||
|
||||
public DBTraceDataTypeManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceDataTypeManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, DBTrace trace)
|
||||
throws CancelledException, VersionException, IOException {
|
||||
super(dbh, null, openMode.toInteger(), INSTANCE_TABLE_PREFIX, trace, trace.getLock(),
|
||||
monitor);
|
||||
super(dbh, null, openMode, INSTANCE_TABLE_PREFIX, trace, trace.getLock(), monitor);
|
||||
this.lock = lock; // TODO: nothing uses this local lock - not sure what its purpose is
|
||||
this.trace = trace;
|
||||
|
||||
|
@ -72,7 +71,7 @@ public class DBTraceDataTypeManager extends ProgramBasedDataTypeManagerDB
|
|||
}
|
||||
}, null, false, monitor);
|
||||
|
||||
if (openMode == DBOpenMode.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
saveDataOrganization();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.*;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.lifecycle.Internal;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.*;
|
||||
|
@ -32,7 +33,8 @@ import ghidra.trace.model.guest.*;
|
|||
import ghidra.trace.util.TraceChangeRecord;
|
||||
import ghidra.trace.util.TraceEvents;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.database.*;
|
||||
import ghidra.util.database.DBCachedObjectStore;
|
||||
import ghidra.util.database.DBCachedObjectStoreFactory;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -141,7 +143,7 @@ public class DBTracePlatformManager implements DBTraceManager, TracePlatformMana
|
|||
}
|
||||
};
|
||||
|
||||
public DBTracePlatformManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTracePlatformManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, CompilerSpec baseCompilerSpec, DBTrace trace)
|
||||
throws VersionException, IOException {
|
||||
this.dbh = dbh;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package ghidra.trace.database.listing;
|
||||
|
||||
import static ghidra.lifecycle.Unfinished.TODO;
|
||||
import static ghidra.lifecycle.Unfinished.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
|
@ -25,6 +25,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
|
||||
import db.DBHandle;
|
||||
import db.DBRecord;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.lifecycle.Internal;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.*;
|
||||
|
@ -323,7 +324,7 @@ public class DBTraceCodeManager extends AbstractDBTraceSpaceBasedManager<DBTrace
|
|||
protected final Map<AddressSnap, UndefinedDBTraceData> undefinedCache =
|
||||
new WeakValueHashMap<>();
|
||||
|
||||
public DBTraceCodeManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceCodeManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager, DBTracePlatformManager platformManager,
|
||||
DBTraceDataTypeManager dataTypeManager, DBTraceOverlaySpaceAdapter overlayAdapter,
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import db.DBHandle;
|
||||
import db.DBRecord;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
|
@ -39,7 +40,8 @@ import ghidra.trace.model.*;
|
|||
import ghidra.trace.util.TraceChangeRecord;
|
||||
import ghidra.trace.util.TraceEvents;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.database.*;
|
||||
import ghidra.util.database.DBCachedObjectStore;
|
||||
import ghidra.util.database.DBObjectColumn;
|
||||
import ghidra.util.database.annot.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -106,7 +108,7 @@ public class DBTraceCommentAdapter
|
|||
/**
|
||||
* Construct the adapter
|
||||
*/
|
||||
public DBTraceCommentAdapter(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceCommentAdapter(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws IOException, VersionException {
|
||||
super("Comments", dbh, openMode, lock, monitor, baseLanguage, trace, threadManager,
|
||||
|
@ -140,8 +142,8 @@ public class DBTraceCommentAdapter
|
|||
}
|
||||
String oldValue = null;
|
||||
try (LockHold hold = LockHold.lock(lock.writeLock())) {
|
||||
for (DBTraceCommentEntry entry : reduce(TraceAddressSnapRangeQuery.intersecting(
|
||||
new AddressRangeImpl(address, address), lifespan)).values()) {
|
||||
for (DBTraceCommentEntry entry : reduce(TraceAddressSnapRangeQuery
|
||||
.intersecting(new AddressRangeImpl(address, address), lifespan)).values()) {
|
||||
if (entry.type == commentType) {
|
||||
if (entry.getLifespan().contains(lifespan.lmin())) {
|
||||
oldValue = entry.comment;
|
||||
|
@ -157,8 +159,7 @@ public class DBTraceCommentAdapter
|
|||
trace.setChanged(new TraceChangeRecord<TraceAddressSnapRange, String>(
|
||||
TraceEvents.byCommentType(commentType),
|
||||
DBTraceSpaceKey.create(address.getAddressSpace(), null, 0),
|
||||
new ImmutableTraceAddressSnapRange(address, lifespan),
|
||||
oldValue, comment));
|
||||
new ImmutableTraceAddressSnapRange(address, lifespan), oldValue, comment));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -191,8 +192,8 @@ public class DBTraceCommentAdapter
|
|||
*/
|
||||
public String getComment(long snap, Address address, int commentType) {
|
||||
try (LockHold hold = LockHold.lock(lock.readLock())) {
|
||||
for (DBTraceCommentEntry entry : reduce(
|
||||
TraceAddressSnapRangeQuery.at(address, snap)).values()) {
|
||||
for (DBTraceCommentEntry entry : reduce(TraceAddressSnapRangeQuery.at(address, snap))
|
||||
.values()) {
|
||||
if (entry.type != commentType) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -23,10 +23,12 @@ import java.util.Map.Entry;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
import ghidra.trace.database.DBTraceUtils;
|
||||
import ghidra.trace.database.map.AbstractDBTracePropertyMap.DBTraceSaveablePropertyMapEntry;
|
||||
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.AbstractDBTraceAddressSnapRangePropertyMapData;
|
||||
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.TraceAddressSnapRangeQuery;
|
||||
import ghidra.trace.database.thread.DBTraceThreadManager;
|
||||
|
@ -45,7 +47,7 @@ import ghidra.util.task.TaskMonitor;
|
|||
public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAddressSnapRangePropertyMapData<T>>
|
||||
extends DBTraceAddressSnapRangePropertyMap<T, DR> implements TracePropertyMap<T> {
|
||||
|
||||
public AbstractDBTracePropertyMap(String name, DBHandle dbh, DBOpenMode openMode,
|
||||
public AbstractDBTracePropertyMap(String name, DBHandle dbh, OpenMode openMode,
|
||||
ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager, Class<DR> dataType,
|
||||
DBTraceAddressSnapRangePropertyMapDataFactory<T, DR> dataFactory)
|
||||
|
@ -120,17 +122,16 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DBTracePropertyMapSpace createSpace(AddressSpace space,
|
||||
DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
protected DBTracePropertyMapSpace createSpace(AddressSpace space, DBTraceSpaceEntry ent)
|
||||
throws VersionException, IOException {
|
||||
return new DBTracePropertyMapSpace(
|
||||
tableName(space, ent.getThreadKey(), ent.getFrameLevel()), trace.getStoreFactory(),
|
||||
lock, space, null, 0, dataType, dataFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DBTracePropertyMapSpace createRegisterSpace(
|
||||
AddressSpace space, TraceThread thread, DBTraceSpaceEntry ent)
|
||||
throws VersionException, IOException {
|
||||
protected DBTracePropertyMapSpace createRegisterSpace(AddressSpace space, TraceThread thread,
|
||||
DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
return new DBTracePropertyMapSpace(
|
||||
tableName(space, ent.getThreadKey(), ent.getFrameLevel()), trace.getStoreFactory(),
|
||||
lock, space, thread, ent.getFrameLevel(), dataType, dataFactory);
|
||||
|
@ -143,10 +144,9 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
}
|
||||
|
||||
@Override
|
||||
public TracePropertyMapSpace<T> getPropertyMapRegisterSpace(TraceThread thread,
|
||||
int frameLevel, boolean createIfAbsent) {
|
||||
return (DBTracePropertyMapSpace) getForRegisterSpace(thread, frameLevel,
|
||||
createIfAbsent);
|
||||
public TracePropertyMapSpace<T> getPropertyMapRegisterSpace(TraceThread thread, int frameLevel,
|
||||
boolean createIfAbsent) {
|
||||
return (DBTracePropertyMapSpace) getForRegisterSpace(thread, frameLevel, createIfAbsent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,8 +154,7 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
throw new NotYetImplementedException();
|
||||
}
|
||||
|
||||
public class DBTracePropertyMapSpace
|
||||
extends DBTraceAddressSnapRangePropertyMapSpace<T, DR>
|
||||
public class DBTracePropertyMapSpace extends DBTraceAddressSnapRangePropertyMapSpace<T, DR>
|
||||
implements TracePropertyMapSpace<T> {
|
||||
|
||||
public DBTracePropertyMapSpace(String tableName, DBCachedObjectStoreFactory storeFactory,
|
||||
|
@ -242,7 +241,7 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
public static class DBTraceIntPropertyMap
|
||||
extends AbstractDBTracePropertyMap<Integer, DBTraceIntPropertyMapEntry> {
|
||||
|
||||
public DBTraceIntPropertyMap(String name, DBHandle dbh, DBOpenMode openMode,
|
||||
public DBTraceIntPropertyMap(String name, DBHandle dbh, OpenMode openMode,
|
||||
ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws IOException, VersionException {
|
||||
super(name, dbh, openMode, lock, monitor, baseLanguage, trace, threadManager,
|
||||
|
@ -287,7 +286,7 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
public static class DBTraceLongPropertyMap
|
||||
extends AbstractDBTracePropertyMap<Long, DBTraceLongPropertyMapEntry> {
|
||||
|
||||
public DBTraceLongPropertyMap(String name, DBHandle dbh, DBOpenMode openMode,
|
||||
public DBTraceLongPropertyMap(String name, DBHandle dbh, OpenMode openMode,
|
||||
ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws IOException, VersionException {
|
||||
super(name, dbh, openMode, lock, monitor, baseLanguage, trace, threadManager,
|
||||
|
@ -340,7 +339,7 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
return (Class) DBTraceSaveablePropertyMapEntry.class;
|
||||
}
|
||||
|
||||
public DBTraceSaveablePropertyMap(String name, DBHandle dbh, DBOpenMode openMode,
|
||||
public DBTraceSaveablePropertyMap(String name, DBHandle dbh, OpenMode openMode,
|
||||
ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager, Class<T> valueClass)
|
||||
throws IOException, VersionException {
|
||||
|
@ -456,7 +455,7 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
public static class DBTraceStringPropertyMap
|
||||
extends AbstractDBTracePropertyMap<String, DBTraceStringPropertyMapEntry> {
|
||||
|
||||
public DBTraceStringPropertyMap(String name, DBHandle dbh, DBOpenMode openMode,
|
||||
public DBTraceStringPropertyMap(String name, DBHandle dbh, OpenMode openMode,
|
||||
ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws IOException, VersionException {
|
||||
super(name, dbh, openMode, lock, monitor, baseLanguage, trace, threadManager,
|
||||
|
@ -501,7 +500,7 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
public static class DBTraceVoidPropertyMap
|
||||
extends AbstractDBTracePropertyMap<Void, DBTraceVoidPropertyMapEntry> {
|
||||
|
||||
public DBTraceVoidPropertyMap(String name, DBHandle dbh, DBOpenMode openMode,
|
||||
public DBTraceVoidPropertyMap(String name, DBHandle dbh, OpenMode openMode,
|
||||
ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws IOException, VersionException {
|
||||
super(name, dbh, openMode, lock, monitor, baseLanguage, trace, threadManager,
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.function.Predicate;
|
|||
|
||||
import db.DBHandle;
|
||||
import db.DBRecord;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.lang.Language;
|
||||
|
@ -40,7 +41,6 @@ import ghidra.trace.model.stack.TraceStackFrame;
|
|||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.UnionAddressSetView;
|
||||
import ghidra.util.database.DBCachedObjectStore;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.database.spatial.SpatialMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -58,7 +58,7 @@ public class DBTraceAddressSnapRangePropertyMap<T, DR extends AbstractDBTraceAdd
|
|||
protected final Class<DR> dataType;
|
||||
protected final DBTraceAddressSnapRangePropertyMapDataFactory<T, DR> dataFactory;
|
||||
|
||||
public DBTraceAddressSnapRangePropertyMap(String name, DBHandle dbh, DBOpenMode openMode,
|
||||
public DBTraceAddressSnapRangePropertyMap(String name, DBHandle dbh, OpenMode openMode,
|
||||
ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager, Class<DR> dataType,
|
||||
DBTraceAddressSnapRangePropertyMapDataFactory<T, DR> dataFactory)
|
||||
|
@ -84,23 +84,22 @@ public class DBTraceAddressSnapRangePropertyMap<T, DR extends AbstractDBTraceAdd
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DBTraceAddressSnapRangePropertyMapSpace<T, DR> createRegisterSpace(
|
||||
AddressSpace space, TraceThread thread, DBTraceSpaceEntry ent)
|
||||
throws VersionException, IOException {
|
||||
protected DBTraceAddressSnapRangePropertyMapSpace<T, DR> createRegisterSpace(AddressSpace space,
|
||||
TraceThread thread, DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
return new DBTraceAddressSnapRangePropertyMapSpace<>(
|
||||
tableName(space, ent.getThreadKey(), ent.getFrameLevel()), trace.getStoreFactory(),
|
||||
lock, space, thread, ent.getFrameLevel(), dataType, dataFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DBTraceAddressSnapRangePropertyMapSpace<T, DR> getRegisterSpace(
|
||||
TraceThread thread, boolean createIfAbsent) {
|
||||
public DBTraceAddressSnapRangePropertyMapSpace<T, DR> getRegisterSpace(TraceThread thread,
|
||||
boolean createIfAbsent) {
|
||||
return getForRegisterSpace(thread, 0, createIfAbsent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DBTraceAddressSnapRangePropertyMapSpace<T, DR> getRegisterSpace(
|
||||
TraceStackFrame frame, boolean createIfAbsent) {
|
||||
public DBTraceAddressSnapRangePropertyMapSpace<T, DR> getRegisterSpace(TraceStackFrame frame,
|
||||
boolean createIfAbsent) {
|
||||
return getForRegisterSpace(frame, createIfAbsent);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.function.Predicate;
|
|||
|
||||
import db.DBHandle;
|
||||
import ghidra.dbg.target.TargetMemoryRegion;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.model.mem.MemBuffer;
|
||||
|
@ -41,7 +42,6 @@ import ghidra.trace.model.stack.TraceStackFrame;
|
|||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.MathUtilities;
|
||||
import ghidra.util.UnionAddressSetView;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.*;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class DBTraceMemoryManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
|
||||
protected final DBTraceOverlaySpaceAdapter overlayAdapter;
|
||||
|
||||
public DBTraceMemoryManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceMemoryManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager, DBTraceOverlaySpaceAdapter overlayAdapter)
|
||||
throws IOException, VersionException {
|
||||
|
@ -91,8 +91,8 @@ public class DBTraceMemoryManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DBTraceMemorySpace createRegisterSpace(AddressSpace space,
|
||||
TraceThread thread, DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
protected DBTraceMemorySpace createRegisterSpace(AddressSpace space, TraceThread thread,
|
||||
DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
return new DBTraceMemorySpace(this, dbh, space, ent, thread);
|
||||
}
|
||||
|
||||
|
@ -117,8 +117,7 @@ public class DBTraceMemoryManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
}
|
||||
|
||||
@Override
|
||||
public DBTraceMemorySpace getMemoryRegisterSpace(TraceThread thread,
|
||||
boolean createIfAbsent) {
|
||||
public DBTraceMemorySpace getMemoryRegisterSpace(TraceThread thread, boolean createIfAbsent) {
|
||||
return getForRegisterSpace(thread, 0, createIfAbsent);
|
||||
}
|
||||
|
||||
|
@ -135,8 +134,8 @@ public class DBTraceMemoryManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
}
|
||||
|
||||
@Override
|
||||
public TraceMemoryRegion addRegion(String path, Lifespan lifespan,
|
||||
AddressRange range, Collection<TraceMemoryFlag> flags)
|
||||
public TraceMemoryRegion addRegion(String path, Lifespan lifespan, AddressRange range,
|
||||
Collection<TraceMemoryFlag> flags)
|
||||
throws TraceOverlappedRegionException, DuplicateNameException {
|
||||
if (trace.getObjectManager().hasSchema()) {
|
||||
return trace.getObjectManager().addMemoryRegion(path, lifespan, range, flags);
|
||||
|
@ -223,9 +222,8 @@ public class DBTraceMemoryManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
.getObjectsAddressSet(snap, TargetMemoryRegion.RANGE_ATTRIBUTE_NAME,
|
||||
TraceObjectMemoryRegion.class, r -> true);
|
||||
}
|
||||
return new UnionAddressSetView(getActiveMemorySpaces().stream()
|
||||
.map(m -> m.getRegionsAddressSet(snap))
|
||||
.toList());
|
||||
return new UnionAddressSetView(
|
||||
getActiveMemorySpaces().stream().map(m -> m.getRegionsAddressSet(snap)).toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -397,9 +395,9 @@ public class DBTraceMemoryManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
}
|
||||
Collection<DBTraceMemoryRegion> result = new ArrayList<>();
|
||||
for (DBTraceMemorySpace space : memSpaces.values()) {
|
||||
result.addAll(space.regionMapSpace
|
||||
.reduce(TraceAddressSnapRangeQuery.added(from, to, space.space))
|
||||
.values());
|
||||
result.addAll(
|
||||
space.regionMapSpace.reduce(TraceAddressSnapRangeQuery.added(from, to, space.space))
|
||||
.values());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -429,9 +427,9 @@ public class DBTraceMemoryManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
for (DBTraceMemorySpace space : memSpaces.values()) {
|
||||
AddressRange rng =
|
||||
new AddressRangeImpl(space.space.getMinAddress(), space.space.getMaxAddress());
|
||||
result.addAll(space.stateMapSpace
|
||||
.reduce(TraceAddressSnapRangeQuery.enclosed(rng, between))
|
||||
.entries());
|
||||
result.addAll(
|
||||
space.stateMapSpace.reduce(TraceAddressSnapRangeQuery.enclosed(rng, between))
|
||||
.entries());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
import db.DBHandle;
|
||||
import ghidra.dbg.target.TargetModule;
|
||||
import ghidra.dbg.target.TargetSection;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -34,7 +35,6 @@ import ghidra.trace.model.thread.TraceThread;
|
|||
import ghidra.trace.util.TraceChangeRecord;
|
||||
import ghidra.trace.util.TraceEvents;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -43,7 +43,7 @@ public class DBTraceModuleManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
implements TraceModuleManager, DBTraceDelegatingManager<DBTraceModuleSpace> {
|
||||
public static final String NAME = "Module";
|
||||
|
||||
public DBTraceModuleManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceModuleManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace)
|
||||
throws VersionException, IOException {
|
||||
super(NAME, dbh, openMode, lock, monitor, baseLanguage, trace, null);
|
||||
|
@ -70,8 +70,8 @@ public class DBTraceModuleManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
if (!pc.getLifespan().intersects(moduleLifespan)) {
|
||||
continue;
|
||||
}
|
||||
throw new DuplicateNameException("Module with path '" +
|
||||
modulePath + "' already exists within an overlapping snap");
|
||||
throw new DuplicateNameException(
|
||||
"Module with path '" + modulePath + "' already exists within an overlapping snap");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,8 +132,7 @@ public class DBTraceModuleManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
.getObjectByPath(snap, modulePath, TraceObjectModule.class);
|
||||
}
|
||||
try (LockHold hold = LockHold.lock(lock.readLock())) {
|
||||
return doGetModulesByPath(modulePath)
|
||||
.stream()
|
||||
return doGetModulesByPath(modulePath).stream()
|
||||
.filter(m -> m.getLifespan().contains(snap))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
|
@ -163,8 +162,8 @@ public class DBTraceModuleManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
.getObjectsContaining(snap, address, TargetModule.RANGE_ATTRIBUTE_NAME,
|
||||
TraceObjectModule.class);
|
||||
}
|
||||
return delegateRead(address.getAddressSpace(),
|
||||
m -> m.getModulesAt(snap, address), Set.of());
|
||||
return delegateRead(address.getAddressSpace(), m -> m.getModulesAt(snap, address),
|
||||
Set.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -175,8 +174,8 @@ public class DBTraceModuleManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
.getObjectsIntersecting(lifespan, range, TargetModule.RANGE_ATTRIBUTE_NAME,
|
||||
TraceObjectModule.class);
|
||||
}
|
||||
return delegateRead(range.getAddressSpace(),
|
||||
m -> m.getModulesIntersecting(lifespan, range), Set.of());
|
||||
return delegateRead(range.getAddressSpace(), m -> m.getModulesIntersecting(lifespan, range),
|
||||
Set.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -191,8 +190,8 @@ public class DBTraceModuleManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
.getObjectsContaining(snap, address, TargetSection.RANGE_ATTRIBUTE_NAME,
|
||||
TraceObjectSection.class);
|
||||
}
|
||||
return delegateRead(address.getAddressSpace(),
|
||||
m -> m.getSectionsAt(snap, address), Set.of());
|
||||
return delegateRead(address.getAddressSpace(), m -> m.getSectionsAt(snap, address),
|
||||
Set.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -274,8 +273,7 @@ public class DBTraceModuleManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
.getObjectByPath(snap, sectionPath, TraceObjectSection.class);
|
||||
}
|
||||
try (LockHold hold = LockHold.lock(lock.readLock())) {
|
||||
return doGetSectionsByPath(sectionPath)
|
||||
.stream()
|
||||
return doGetSectionsByPath(sectionPath).stream()
|
||||
.filter(s -> s.getModule().getLifespan().contains(snap))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.*;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -49,7 +50,7 @@ public class DBTraceStaticMappingManager implements TraceStaticMappingManager, D
|
|||
protected final DBCachedObjectIndex<Address, DBTraceStaticMapping> mappingsByAddress;
|
||||
protected final Collection<DBTraceStaticMapping> view;
|
||||
|
||||
public DBTraceStaticMappingManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceStaticMappingManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, DBTrace trace, DBTraceOverlaySpaceAdapter overlayAdapter)
|
||||
throws VersionException, IOException {
|
||||
this.dbh = dbh;
|
||||
|
@ -118,8 +119,9 @@ public class DBTraceStaticMappingManager implements TraceStaticMappingManager, D
|
|||
|
||||
@Override
|
||||
public DBTraceStaticMapping findContaining(Address address, long snap) {
|
||||
for (DBTraceStaticMapping mapping : mappingsByAddress.head(address,
|
||||
true).descending().values()) {
|
||||
for (DBTraceStaticMapping mapping : mappingsByAddress.head(address, true)
|
||||
.descending()
|
||||
.values()) {
|
||||
if (!mapping.getLifespan().contains(snap)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -134,8 +136,9 @@ public class DBTraceStaticMappingManager implements TraceStaticMappingManager, D
|
|||
@Override
|
||||
public DBTraceStaticMapping findAnyConflicting(AddressRange range, Lifespan lifespan,
|
||||
URL toProgramURL, String toAddress) {
|
||||
for (DBTraceStaticMapping mapping : mappingsByAddress.head(range.getMaxAddress(),
|
||||
true).descending().values()) {
|
||||
for (DBTraceStaticMapping mapping : mappingsByAddress.head(range.getMaxAddress(), true)
|
||||
.descending()
|
||||
.values()) {
|
||||
if (!mapping.conflictsWith(range, lifespan, toProgramURL, toAddress)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -154,8 +157,9 @@ public class DBTraceStaticMappingManager implements TraceStaticMappingManager, D
|
|||
public Collection<? extends DBTraceStaticMapping> findAllOverlapping(AddressRange range,
|
||||
Lifespan lifespan) {
|
||||
Set<DBTraceStaticMapping> result = new HashSet<>();
|
||||
for (DBTraceStaticMapping mapping : mappingsByAddress.head(range.getMaxAddress(),
|
||||
true).descending().values()) {
|
||||
for (DBTraceStaticMapping mapping : mappingsByAddress.head(range.getMaxAddress(), true)
|
||||
.descending()
|
||||
.values()) {
|
||||
if (!mapping.getLifespan().intersects(lifespan)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.function.OverlappingFunctionException;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -173,7 +174,7 @@ public class DBTraceProgramViewFunctionManager implements FunctionManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void programReady(int openMode, int currentRevision, TaskMonitor monitor)
|
||||
public void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
|
||||
import db.DBHandle;
|
||||
import db.DBRecord;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.model.listing.ProgramUserData;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -95,7 +96,7 @@ public class DBTraceAddressPropertyManager implements TraceAddressPropertyManage
|
|||
protected final TraceAddressPropertyManager apiView =
|
||||
new DBTraceAddressPropertyManagerApiView(this);
|
||||
|
||||
public DBTraceAddressPropertyManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceAddressPropertyManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws VersionException, IOException {
|
||||
this.dbh = dbh;
|
||||
|
@ -117,7 +118,7 @@ public class DBTraceAddressPropertyManager implements TraceAddressPropertyManage
|
|||
if (ent.map == null) {
|
||||
try {
|
||||
propertyMapsByName.put(ent.name,
|
||||
ent.map = doCreateMap(ent.name, DBOpenMode.UPDATE, ent.getValueClass()));
|
||||
ent.map = doCreateMap(ent.name, OpenMode.UPDATE, ent.getValueClass()));
|
||||
}
|
||||
catch (Exception e) {
|
||||
Msg.error(this, "Cannot load address property " + ent.name, e);
|
||||
|
@ -130,7 +131,7 @@ public class DBTraceAddressPropertyManager implements TraceAddressPropertyManage
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> AbstractDBTracePropertyMap<T, ?> doCreateMap(String name, DBOpenMode openMode,
|
||||
protected <T> AbstractDBTracePropertyMap<T, ?> doCreateMap(String name, OpenMode openMode,
|
||||
Class<T> valueClass) {
|
||||
String tableName = "AddressProperty: " + name;
|
||||
try {
|
||||
|
@ -175,7 +176,7 @@ public class DBTraceAddressPropertyManager implements TraceAddressPropertyManage
|
|||
}
|
||||
DBTraceAddressPropertyEntry ent = propertyStore.create();
|
||||
ent.set(name, valueClass);
|
||||
AbstractDBTracePropertyMap<T, ?> map = doCreateMap(name, DBOpenMode.CREATE, valueClass);
|
||||
AbstractDBTracePropertyMap<T, ?> map = doCreateMap(name, OpenMode.CREATE, valueClass);
|
||||
ent.map = map;
|
||||
propertyMapsByName.put(name, map);
|
||||
return map;
|
||||
|
|
|
@ -24,6 +24,7 @@ import db.DBHandle;
|
|||
import db.DBRecord;
|
||||
import generic.CatenatedCollection;
|
||||
import ghidra.dbg.target.TargetRegisterContainer;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.*;
|
||||
|
@ -125,7 +126,7 @@ public abstract class AbstractDBTraceSpaceBasedManager<M extends DBTraceSpaceBas
|
|||
protected final Collection<M> allSpacesView =
|
||||
new CatenatedCollection<>(memSpacesView, regSpacesView);
|
||||
|
||||
public AbstractDBTraceSpaceBasedManager(String name, DBHandle dbh, DBOpenMode openMode,
|
||||
public AbstractDBTraceSpaceBasedManager(String name, DBHandle dbh, OpenMode openMode,
|
||||
ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws IOException, VersionException {
|
||||
this.name = name;
|
||||
|
|
|
@ -23,6 +23,7 @@ import db.DBHandle;
|
|||
import generic.NestedIterator;
|
||||
import ghidra.dbg.target.*;
|
||||
import ghidra.dbg.util.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -57,10 +58,9 @@ public class DBTraceStackManager implements TraceStackManager, DBTraceManager {
|
|||
protected final DBCachedObjectStore<DBTraceStackFrame> frameStore;
|
||||
protected final DBCachedObjectIndex<Address, DBTraceStackFrame> framesByPC;
|
||||
|
||||
public DBTraceStackManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceStackManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, DBTrace trace, DBTraceThreadManager threadManager,
|
||||
DBTraceOverlaySpaceAdapter overlayAdapter)
|
||||
throws VersionException, IOException {
|
||||
DBTraceOverlaySpaceAdapter overlayAdapter) throws VersionException, IOException {
|
||||
this.dbh = dbh;
|
||||
this.lock = lock;
|
||||
this.trace = trace;
|
||||
|
@ -69,8 +69,8 @@ public class DBTraceStackManager implements TraceStackManager, DBTraceManager {
|
|||
|
||||
DBCachedObjectStoreFactory factory = trace.getStoreFactory();
|
||||
|
||||
stackStore = factory.getOrCreateCachedStore(DBTraceStack.TABLE_NAME,
|
||||
DBTraceStack.class, (s, r) -> new DBTraceStack(this, s, r), true);
|
||||
stackStore = factory.getOrCreateCachedStore(DBTraceStack.TABLE_NAME, DBTraceStack.class,
|
||||
(s, r) -> new DBTraceStack(this, s, r), true);
|
||||
stacksByThreadSnap = stackStore.getIndex(ThreadSnap.class, DBTraceStack.THREAD_SNAP_COLUMN);
|
||||
|
||||
frameStore = factory.getOrCreateCachedStore(DBTraceStackFrame.TABLE_NAME,
|
||||
|
@ -113,9 +113,8 @@ public class DBTraceStackManager implements TraceStackManager, DBTraceManager {
|
|||
PathPredicates predicates = single(obj, TargetStack.class);
|
||||
if (createIfAbsent) {
|
||||
try (LockHold hold = trace.lockWrite()) {
|
||||
TraceObjectStack stack =
|
||||
trace.getObjectManager()
|
||||
.getSuccessor(obj, predicates, snap, TraceObjectStack.class);
|
||||
TraceObjectStack stack = trace.getObjectManager()
|
||||
.getSuccessor(obj, predicates, snap, TraceObjectStack.class);
|
||||
if (stack != null) {
|
||||
return stack;
|
||||
}
|
||||
|
@ -187,15 +186,16 @@ public class DBTraceStackManager implements TraceStackManager, DBTraceManager {
|
|||
// TODO: Should probably include a lifespan parameter?
|
||||
public Iterable<TraceStackFrame> getFramesIn(AddressSetView set) {
|
||||
if (trace.getObjectManager().hasSchema()) {
|
||||
return () -> NestedIterator.start(set.iterator(), rng -> trace.getObjectManager()
|
||||
.getObjectsIntersecting(Lifespan.ALL, rng, TargetStackFrame.PC_ATTRIBUTE_NAME,
|
||||
TraceObjectStackFrame.class)
|
||||
.iterator());
|
||||
return () -> NestedIterator.start(set.iterator(),
|
||||
rng -> trace.getObjectManager()
|
||||
.getObjectsIntersecting(Lifespan.ALL, rng,
|
||||
TargetStackFrame.PC_ATTRIBUTE_NAME, TraceObjectStackFrame.class)
|
||||
.iterator());
|
||||
}
|
||||
return () -> NestedIterator.start(set.iterator(), rng -> framesByPC
|
||||
.sub(rng.getMinAddress(), true, rng.getMaxAddress(), true)
|
||||
.values()
|
||||
.iterator());
|
||||
return () -> NestedIterator.start(set.iterator(),
|
||||
rng -> framesByPC.sub(rng.getMinAddress(), true, rng.getMaxAddress(), true)
|
||||
.values()
|
||||
.iterator());
|
||||
}
|
||||
|
||||
protected void deleteStack(DBTraceStack stack) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.locks.Lock;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -47,10 +48,9 @@ public class DBTraceEquateManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
protected final DBCachedObjectIndex<String, DBTraceEquate> equatesByName;
|
||||
protected final DBCachedObjectIndex<Long, DBTraceEquate> equatesByValue;
|
||||
|
||||
public DBTraceEquateManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor,
|
||||
Language baseLanguage, DBTrace trace, DBTraceThreadManager threadManager)
|
||||
throws VersionException, IOException {
|
||||
public DBTraceEquateManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager) throws VersionException, IOException {
|
||||
super(NAME, dbh, openMode, lock, monitor, baseLanguage, trace, threadManager);
|
||||
|
||||
DBCachedObjectStoreFactory factory = trace.getStoreFactory();
|
||||
|
@ -93,8 +93,7 @@ public class DBTraceEquateManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
}
|
||||
|
||||
@Override
|
||||
public DBTraceEquateSpace getEquateRegisterSpace(TraceThread thread,
|
||||
boolean createIfAbsent) {
|
||||
public DBTraceEquateSpace getEquateRegisterSpace(TraceThread thread, boolean createIfAbsent) {
|
||||
return getForRegisterSpace(thread, 0, createIfAbsent);
|
||||
}
|
||||
|
||||
|
@ -111,8 +110,8 @@ public class DBTraceEquateManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DBTraceEquateSpace createRegisterSpace(AddressSpace space,
|
||||
TraceThread thread, DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
protected DBTraceEquateSpace createRegisterSpace(AddressSpace space, TraceThread thread,
|
||||
DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
return new DBTraceEquateSpace(this, dbh, space, ent, thread);
|
||||
}
|
||||
|
||||
|
@ -193,8 +192,7 @@ public class DBTraceEquateManager extends AbstractDBTraceSpaceBasedManager<DBTra
|
|||
public Collection<? extends DBTraceEquate> getReferenced(long snap, Address address,
|
||||
int operandIndex) {
|
||||
return delegateRead(address.getAddressSpace(),
|
||||
m -> m.getReferenced(snap, address, operandIndex),
|
||||
Collections.emptyList());
|
||||
m -> m.getReferenced(snap, address, operandIndex), Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.locks.Lock;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.model.lang.Register;
|
||||
|
@ -38,7 +39,6 @@ import ghidra.trace.model.symbol.TraceReference;
|
|||
import ghidra.trace.model.symbol.TraceReferenceManager;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.UnionAddressSetView;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class DBTraceReferenceManager extends AbstractDBTraceSpaceBasedManager<DB
|
|||
|
||||
protected final DBTraceOverlaySpaceAdapter overlayAdapter;
|
||||
|
||||
public DBTraceReferenceManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceReferenceManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager, DBTraceOverlaySpaceAdapter overlayAdapter)
|
||||
throws VersionException, IOException {
|
||||
|
@ -65,8 +65,8 @@ public class DBTraceReferenceManager extends AbstractDBTraceSpaceBasedManager<DB
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DBTraceReferenceSpace createRegisterSpace(AddressSpace space,
|
||||
TraceThread thread, DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
protected DBTraceReferenceSpace createRegisterSpace(AddressSpace space, TraceThread thread,
|
||||
DBTraceSpaceEntry ent) throws VersionException, IOException {
|
||||
return new DBTraceReferenceSpace(this, dbh, space, ent, thread);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.*;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.lifecycle.Internal;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.DataType;
|
||||
|
@ -138,10 +139,7 @@ public class DBTraceSymbolManager implements TraceSymbolManager, DBTraceManager
|
|||
@DBAnnotatedColumn(STORAGE_COLUMN_NAME)
|
||||
static DBObjectColumn STORAGE_COLUMN;
|
||||
|
||||
@DBAnnotatedField(
|
||||
column = STORAGE_COLUMN_NAME,
|
||||
indexed = true,
|
||||
codec = VariableStorageDBFieldCodec.class)
|
||||
@DBAnnotatedField(column = STORAGE_COLUMN_NAME, indexed = true, codec = VariableStorageDBFieldCodec.class)
|
||||
private VariableStorage storage;
|
||||
|
||||
protected final DBTraceSymbolManager manager;
|
||||
|
@ -238,7 +236,7 @@ public class DBTraceSymbolManager implements TraceSymbolManager, DBTraceManager
|
|||
|
||||
protected final Map<Byte, AbstractDBTraceSymbolSingleTypeView<?>> symbolViews = new HashMap<>();
|
||||
|
||||
public DBTraceSymbolManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceSymbolManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace,
|
||||
DBTraceThreadManager threadManager, DBTraceDataTypeManager dataTypeManager,
|
||||
DBTraceOverlaySpaceAdapter overlayAdapter) throws VersionException, IOException {
|
||||
|
|
|
@ -31,6 +31,7 @@ import ghidra.dbg.target.TargetObject;
|
|||
import ghidra.dbg.target.schema.*;
|
||||
import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
|
||||
import ghidra.dbg.util.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
|
@ -68,8 +69,8 @@ import ghidra.util.task.TaskMonitor;
|
|||
public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager {
|
||||
private static final int OBJECTS_CONTAINING_CACHE_SIZE = 100;
|
||||
|
||||
public static class DBTraceObjectSchemaDBFieldCodec extends
|
||||
AbstractDBFieldCodec<SchemaContext, DBTraceObjectSchemaEntry, StringField> {
|
||||
public static class DBTraceObjectSchemaDBFieldCodec
|
||||
extends AbstractDBFieldCodec<SchemaContext, DBTraceObjectSchemaEntry, StringField> {
|
||||
public DBTraceObjectSchemaDBFieldCodec(Class<DBTraceObjectSchemaEntry> objectType,
|
||||
Field field, int column) {
|
||||
super(SchemaContext.class, objectType, StringField.class, field, column);
|
||||
|
@ -118,9 +119,7 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
@DBAnnotatedColumn(SCHEMA_COLUMN_NAME)
|
||||
static DBObjectColumn SCHEMA_COLUMN;
|
||||
|
||||
@DBAnnotatedField(
|
||||
column = CONTEXT_COLUMN_NAME,
|
||||
codec = DBTraceObjectSchemaDBFieldCodec.class)
|
||||
@DBAnnotatedField(column = CONTEXT_COLUMN_NAME, codec = DBTraceObjectSchemaDBFieldCodec.class)
|
||||
private SchemaContext context;
|
||||
@DBAnnotatedField(column = SCHEMA_COLUMN_NAME)
|
||||
private String schemaName;
|
||||
|
@ -175,7 +174,7 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
protected final Map<Class<? extends TraceObjectInterface>, Set<TargetObjectSchema>> //
|
||||
schemasByInterface = new HashMap<>();
|
||||
|
||||
public DBTraceObjectManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceObjectManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, Language baseLanguage, DBTrace trace)
|
||||
throws IOException, VersionException {
|
||||
this.lock = lock;
|
||||
|
@ -185,16 +184,15 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
schemaStore = factory.getOrCreateCachedStore(DBTraceObjectSchemaEntry.TABLE_NAME,
|
||||
DBTraceObjectSchemaEntry.class, DBTraceObjectSchemaEntry::new, true);
|
||||
loadRootSchema();
|
||||
objectStore = factory.getOrCreateCachedStore(DBTraceObject.TABLE_NAME,
|
||||
DBTraceObject.class, (s, r) -> new DBTraceObject(this, s, r), true);
|
||||
objectStore = factory.getOrCreateCachedStore(DBTraceObject.TABLE_NAME, DBTraceObject.class,
|
||||
(s, r) -> new DBTraceObject(this, s, r), true);
|
||||
|
||||
valueTree = new DBTraceObjectValueRStarTree(this, factory,
|
||||
DBTraceObjectValueData.TABLE_NAME, ValueSpace.INSTANCE, DBTraceObjectValueData.class,
|
||||
DBTraceObjectValueNode.class, false, 50);
|
||||
valueMap = valueTree.asSpatialMap();
|
||||
|
||||
objectsByPath =
|
||||
objectStore.getIndex(TraceObjectKeyPath.class, DBTraceObject.PATH_COLUMN);
|
||||
objectsByPath = objectStore.getIndex(TraceObjectKeyPath.class, DBTraceObject.PATH_COLUMN);
|
||||
|
||||
valueWbCache = new DBTraceObjectValueWriteBehindCache(this);
|
||||
|
||||
|
@ -297,12 +295,12 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
return entry;
|
||||
}
|
||||
|
||||
protected DBTraceObjectValue doCreateValue(Lifespan lifespan,
|
||||
DBTraceObject parent, String key, Object value) {
|
||||
protected DBTraceObjectValue doCreateValue(Lifespan lifespan, DBTraceObject parent, String key,
|
||||
Object value) {
|
||||
// Root is never in write-behind cache
|
||||
DBTraceObjectValue entry = parent == null
|
||||
? doCreateValueData(lifespan, parent, key, value).getWrapper()
|
||||
: valueWbCache.doCreateValue(lifespan, parent, key, value).getWrapper();
|
||||
DBTraceObjectValue entry =
|
||||
parent == null ? doCreateValueData(lifespan, parent, key, value).getWrapper()
|
||||
: valueWbCache.doCreateValue(lifespan, parent, key, value).getWrapper();
|
||||
if (parent != null) {
|
||||
parent.notifyValueCreated(entry);
|
||||
}
|
||||
|
@ -420,18 +418,17 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
|
||||
@Override
|
||||
public Stream<DBTraceObjectValue> getAllValues() {
|
||||
return Stream.concat(
|
||||
valueMap.values().stream().map(v -> v.getWrapper()),
|
||||
StreamUtils.lock(lock.readLock(),
|
||||
valueWbCache.streamAllValues().map(v -> v.getWrapper())));
|
||||
return Stream.concat(valueMap.values().stream().map(v -> v.getWrapper()), StreamUtils
|
||||
.lock(lock.readLock(), valueWbCache.streamAllValues().map(v -> v.getWrapper())));
|
||||
}
|
||||
|
||||
protected Stream<DBTraceObjectValueData> streamValuesIntersectingData(Lifespan span,
|
||||
AddressRange range, String entryKey) {
|
||||
return valueMap.reduce(TraceObjectValueQuery.intersecting(
|
||||
entryKey != null ? entryKey : EntryKeyDimension.INSTANCE.absoluteMin(),
|
||||
entryKey != null ? entryKey : EntryKeyDimension.INSTANCE.absoluteMax(),
|
||||
span, range)).values().stream();
|
||||
entryKey != null ? entryKey : EntryKeyDimension.INSTANCE.absoluteMax(), span, range))
|
||||
.values()
|
||||
.stream();
|
||||
}
|
||||
|
||||
protected Stream<DBTraceObjectValueBehind> streamValuesIntersectingBehind(Lifespan span,
|
||||
|
@ -442,9 +439,10 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
@Override
|
||||
public Collection<? extends TraceObjectValue> getValuesIntersecting(Lifespan span,
|
||||
AddressRange range, String entryKey) {
|
||||
return Stream.concat(
|
||||
streamValuesIntersectingData(span, range, entryKey).map(v -> v.getWrapper()),
|
||||
streamValuesIntersectingBehind(span, range, entryKey).map(v -> v.getWrapper()))
|
||||
return Stream
|
||||
.concat(
|
||||
streamValuesIntersectingData(span, range, entryKey).map(v -> v.getWrapper()),
|
||||
streamValuesIntersectingBehind(span, range, entryKey).map(v -> v.getWrapper()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
@ -460,9 +458,9 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
|
||||
public Collection<? extends TraceObjectValue> getValuesAt(long snap, Address address,
|
||||
String entryKey) {
|
||||
return Stream.concat(
|
||||
streamValuesAtData(snap, address, entryKey).map(v -> v.getWrapper()),
|
||||
streamValuesAtBehind(snap, address, entryKey).map(v -> v.getWrapper()))
|
||||
return Stream
|
||||
.concat(streamValuesAtData(snap, address, entryKey).map(v -> v.getWrapper()),
|
||||
streamValuesAtBehind(snap, address, entryKey).map(v -> v.getWrapper()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
@ -474,16 +472,14 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
}
|
||||
Class<? extends TargetObject> targetIf = TraceObjectInterfaceUtils.toTargetIf(ifClass);
|
||||
PathMatcher matcher = rootSchema.searchFor(targetIf, true);
|
||||
return getValuePaths(span, matcher)
|
||||
.filter(p -> {
|
||||
TraceObject object = p.getDestination(getRootObject());
|
||||
if (object == null) {
|
||||
Msg.error(this, "NULL VALUE! " + p.getLastEntry());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.map(p -> p.getDestination(getRootObject()).queryInterface(ifClass));
|
||||
return getValuePaths(span, matcher).filter(p -> {
|
||||
TraceObject object = p.getDestination(getRootObject());
|
||||
if (object == null) {
|
||||
Msg.error(this, "NULL VALUE! " + p.getLastEntry());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).map(p -> p.getDestination(getRootObject()).queryInterface(ifClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -632,8 +628,8 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
return Set.copyOf(result);
|
||||
}
|
||||
|
||||
public <I extends TraceObjectInterface> Collection<I> getObjectsIntersecting(
|
||||
Lifespan lifespan, AddressRange range, String key, Class<I> iface) {
|
||||
public <I extends TraceObjectInterface> Collection<I> getObjectsIntersecting(Lifespan lifespan,
|
||||
AddressRange range, String key, Class<I> iface) {
|
||||
try (LockHold hold = trace.lockRead()) {
|
||||
Set<TargetObjectSchema> schemas;
|
||||
synchronized (schemasByInterface) {
|
||||
|
@ -802,8 +798,8 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
|
|||
if (!exists.getLife().intersects(lifespan)) {
|
||||
return;
|
||||
}
|
||||
throw new DuplicateNameException("A thread having path '" + path +
|
||||
"' already exists within an overlapping snap");
|
||||
throw new DuplicateNameException(
|
||||
"A thread having path '" + path + "' already exists within an overlapping snap");
|
||||
}
|
||||
|
||||
public TraceObjectThread addThread(String path, String display, Lifespan lifespan)
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
import ghidra.trace.database.DBTraceManager;
|
||||
import ghidra.trace.database.target.DBTraceObject;
|
||||
|
@ -44,7 +45,7 @@ public class DBTraceThreadManager implements TraceThreadManager, DBTraceManager
|
|||
protected final DBCachedObjectStore<DBTraceThread> threadStore;
|
||||
protected final DBCachedObjectIndex<String, DBTraceThread> threadsByPath;
|
||||
|
||||
public DBTraceThreadManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceThreadManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, DBTrace trace, DBTraceObjectManager objectManager)
|
||||
throws IOException, VersionException {
|
||||
this.lock = lock;
|
||||
|
@ -104,8 +105,7 @@ public class DBTraceThreadManager implements TraceThreadManager, DBTraceManager
|
|||
}
|
||||
|
||||
@Override
|
||||
public TraceThread addThread(String path, Lifespan lifespan)
|
||||
throws DuplicateNameException {
|
||||
public TraceThread addThread(String path, Lifespan lifespan) throws DuplicateNameException {
|
||||
return addThread(path, path, lifespan);
|
||||
}
|
||||
|
||||
|
@ -168,8 +168,7 @@ public class DBTraceThreadManager implements TraceThreadManager, DBTraceManager
|
|||
public Collection<? extends TraceThread> getLiveThreads(long snap) {
|
||||
if (objectManager.hasSchema()) {
|
||||
try (LockHold hold = LockHold.lock(lock.readLock())) {
|
||||
return objectManager
|
||||
.queryAllInterface(Lifespan.at(snap), TraceObjectThread.class)
|
||||
return objectManager.queryAllInterface(Lifespan.at(snap), TraceObjectThread.class)
|
||||
// Exclude the destruction
|
||||
.filter(thread -> thread.getCreationSnap() <= snap &&
|
||||
snap < thread.getDestructionSnap())
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Map.Entry;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
import ghidra.trace.database.DBTraceManager;
|
||||
import ghidra.trace.database.thread.DBTraceThreadManager;
|
||||
|
@ -44,7 +45,7 @@ public class DBTraceTimeManager implements TraceTimeManager, DBTraceManager {
|
|||
protected final DBCachedObjectStore<DBTraceSnapshot> snapshotStore;
|
||||
protected final DBCachedObjectIndex<String, DBTraceSnapshot> snapshotsBySchedule;
|
||||
|
||||
public DBTraceTimeManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
public DBTraceTimeManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, DBTrace trace, DBTraceThreadManager threadManager)
|
||||
throws VersionException, IOException {
|
||||
this.trace = trace;
|
||||
|
|
|
@ -34,6 +34,7 @@ import generic.theme.GThemeDefaults.Colors.Messages;
|
|||
import ghidra.app.plugin.processors.sleigh.SleighLanguage;
|
||||
import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
|
||||
import ghidra.dbg.util.PathPredicates;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.pcode.exec.*;
|
||||
import ghidra.pcode.exec.trace.TraceSleighUtils;
|
||||
import ghidra.program.disassemble.Disassembler;
|
||||
|
@ -61,7 +62,6 @@ import ghidra.trace.model.target.TraceObject.ConflictResolution;
|
|||
import ghidra.trace.model.thread.TraceObjectThread;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.*;
|
||||
import ghidra.util.task.ConsoleTaskMonitor;
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
public ToyDBTraceBuilder(File file)
|
||||
throws CancelledException, VersionException, LanguageNotFoundException, IOException {
|
||||
DBHandle handle = new DBHandle(file);
|
||||
this.trace = new DBTrace(handle, DBOpenMode.UPDATE, new ConsoleTaskMonitor(), this);
|
||||
this.trace = new DBTrace(handle, OpenMode.UPDATE, new ConsoleTaskMonitor(), this);
|
||||
this.language = trace.getBaseLanguage();
|
||||
this.host = trace.getPlatformManager().getHostPlatform();
|
||||
}
|
||||
|
@ -553,8 +553,8 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
* @return the instruction unit
|
||||
* @throws CodeUnitInsertionException if the instruction cannot be created
|
||||
*/
|
||||
public DBTraceInstruction addInstruction(long snap, Address start,
|
||||
TracePlatform platform) throws CodeUnitInsertionException {
|
||||
public DBTraceInstruction addInstruction(long snap, Address start, TracePlatform platform)
|
||||
throws CodeUnitInsertionException {
|
||||
DBTraceCodeManager code = trace.getCodeManager();
|
||||
Language platformLanguage = platform.getLanguage();
|
||||
Disassembler dis =
|
||||
|
@ -637,8 +637,8 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
public DBTraceReference addMemoryReference(long creationSnap, Address from, Address to,
|
||||
int operandIndex) {
|
||||
return trace.getReferenceManager()
|
||||
.addMemoryReference(Lifespan.nowOn(creationSnap), from, to,
|
||||
RefType.DATA, SourceType.DEFAULT, operandIndex);
|
||||
.addMemoryReference(Lifespan.nowOn(creationSnap), from, to, RefType.DATA,
|
||||
SourceType.DEFAULT, operandIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -655,8 +655,8 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
public DBTraceReference addOffsetReference(long creationSnap, Address from, Address to,
|
||||
boolean toAddrIsBase, long offset) {
|
||||
return trace.getReferenceManager()
|
||||
.addOffsetReference(Lifespan.nowOn(creationSnap), from, to, toAddrIsBase,
|
||||
offset, RefType.DATA, SourceType.DEFAULT, -1);
|
||||
.addOffsetReference(Lifespan.nowOn(creationSnap), from, to, toAddrIsBase, offset,
|
||||
RefType.DATA, SourceType.DEFAULT, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -677,8 +677,8 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
public DBTraceReference addShiftedReference(long creationSnap, Address from, Address to,
|
||||
int shift) {
|
||||
return trace.getReferenceManager()
|
||||
.addShiftedReference(Lifespan.nowOn(creationSnap), from,
|
||||
to, shift, RefType.DATA, SourceType.DEFAULT, -1);
|
||||
.addShiftedReference(Lifespan.nowOn(creationSnap), from, to, shift, RefType.DATA,
|
||||
SourceType.DEFAULT, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -696,8 +696,8 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
*/
|
||||
public DBTraceReference addRegisterReference(long creationSnap, Address from, String to) {
|
||||
return trace.getReferenceManager()
|
||||
.addRegisterReference(Lifespan.nowOn(creationSnap), from,
|
||||
language.getRegister(to), RefType.DATA, SourceType.DEFAULT, -1);
|
||||
.addRegisterReference(Lifespan.nowOn(creationSnap), from, language.getRegister(to),
|
||||
RefType.DATA, SourceType.DEFAULT, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -715,8 +715,8 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
*/
|
||||
public DBTraceReference addStackReference(long creationSnap, Address from, int to) {
|
||||
return trace.getReferenceManager()
|
||||
.addStackReference(Lifespan.nowOn(creationSnap), from, to,
|
||||
RefType.DATA, SourceType.DEFAULT, -1);
|
||||
.addStackReference(Lifespan.nowOn(creationSnap), from, to, RefType.DATA,
|
||||
SourceType.DEFAULT, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.function.Predicate;
|
|||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.model.lang.LanguageID;
|
||||
|
@ -43,7 +44,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
|
|||
extends AbstractGhidraHeadlessIntegrationTest {
|
||||
protected static class MyObject extends DBCachedDomainObjectAdapter {
|
||||
protected MyObject(Object consumer) throws IOException {
|
||||
super(new DBHandle(), DBOpenMode.CREATE, new ConsoleTaskMonitor(), "Testing", 500, 1000,
|
||||
super(new DBHandle(), OpenMode.CREATE, new ConsoleTaskMonitor(), "Testing", 500, 1000,
|
||||
consumer);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
|||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.model.lang.LanguageID;
|
||||
|
@ -42,7 +43,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterableTest
|
|||
extends AbstractGhidraHeadlessIntegrationTest {
|
||||
protected static class MyObject extends DBCachedDomainObjectAdapter {
|
||||
protected MyObject(Object consumer) throws IOException {
|
||||
super(new DBHandle(), DBOpenMode.CREATE, new ConsoleTaskMonitor(), "Testing", 500, 1000,
|
||||
super(new DBHandle(), OpenMode.CREATE, new ConsoleTaskMonitor(), "Testing", 500, 1000,
|
||||
consumer);
|
||||
}
|
||||
|
||||
|
@ -152,8 +153,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterableTest
|
|||
@Before
|
||||
public void setUp() throws IOException, VersionException {
|
||||
toy = DefaultLanguageService.getLanguageService()
|
||||
.getLanguage(
|
||||
new LanguageID("Toy:BE:64:default"));
|
||||
.getLanguage(new LanguageID("Toy:BE:64:default"));
|
||||
obj = new MyObject(this);
|
||||
factory = new DBCachedObjectStoreFactory(obj);
|
||||
try (Transaction tx = obj.openTransaction("CreateTable")) {
|
||||
|
@ -240,12 +240,10 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterableTest
|
|||
}
|
||||
|
||||
it = makeOcclusionIterable(tasr(0x0000, -0x0001, Long.MIN_VALUE, Long.MAX_VALUE));
|
||||
assertEquals(list(
|
||||
ent(0x0000, 0x0fff, 5, 10, "W"),
|
||||
assertEquals(list(ent(0x0000, 0x0fff, 5, 10, "W"),
|
||||
ent(0x1000, 0x1fff, Long.MIN_VALUE, Long.MIN_VALUE + 10, "S"),
|
||||
ent(0x2000, 0x2fff, Long.MAX_VALUE - 10, Long.MAX_VALUE, "N"),
|
||||
ent(-0x1000, -0x0001, 5, 10, "E")),
|
||||
list(it));
|
||||
ent(-0x1000, -0x0001, 5, 10, "E")), list(it));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
|||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.model.lang.LanguageID;
|
||||
|
@ -42,7 +43,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterableTest
|
|||
extends AbstractGhidraHeadlessIntegrationTest {
|
||||
protected static class MyObject extends DBCachedDomainObjectAdapter {
|
||||
protected MyObject(Object consumer) throws IOException {
|
||||
super(new DBHandle(), DBOpenMode.CREATE, new ConsoleTaskMonitor(), "Testing", 500, 1000,
|
||||
super(new DBHandle(), OpenMode.CREATE, new ConsoleTaskMonitor(), "Testing", 500, 1000,
|
||||
consumer);
|
||||
}
|
||||
|
||||
|
@ -152,8 +153,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterableTest
|
|||
@Before
|
||||
public void setUp() throws IOException, VersionException {
|
||||
toy = DefaultLanguageService.getLanguageService()
|
||||
.getLanguage(
|
||||
new LanguageID("Toy:BE:64:default"));
|
||||
.getLanguage(new LanguageID("Toy:BE:64:default"));
|
||||
obj = new MyObject(this);
|
||||
factory = new DBCachedObjectStoreFactory(obj);
|
||||
try (Transaction tid = obj.openTransaction("CreateTable")) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
|||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.model.lang.LanguageID;
|
||||
|
@ -61,7 +62,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
|
|||
private DBTraceAddressSnapRangePropertyMapSpace<MyEntry, MyEntry> space2;
|
||||
private DBTraceAddressSnapRangePropertyMapSpace<String, AltEntry> space3;
|
||||
|
||||
protected MyObject(DBHandle dbh, DBOpenMode openMode, Language toy, Object consumer)
|
||||
protected MyObject(DBHandle dbh, OpenMode openMode, Language toy, Object consumer)
|
||||
throws VersionException, IOException {
|
||||
super(dbh, openMode, new ConsoleTaskMonitor(), "Testing", 500, 1000, consumer);
|
||||
this.toy = toy;
|
||||
|
@ -70,12 +71,12 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
|
|||
}
|
||||
|
||||
protected MyObject(Language toy, Object consumer) throws IOException, VersionException {
|
||||
this(new DBHandle(), DBOpenMode.CREATE, toy, consumer);
|
||||
this(new DBHandle(), OpenMode.CREATE, toy, consumer);
|
||||
}
|
||||
|
||||
protected MyObject(File file, Language toy, Object consumer)
|
||||
throws IOException, VersionException {
|
||||
this(new DBHandle(file), DBOpenMode.UPDATE, toy, consumer);
|
||||
this(new DBHandle(file), OpenMode.UPDATE, toy, consumer);
|
||||
}
|
||||
|
||||
protected void loadSpaces() throws VersionException, IOException {
|
||||
|
@ -211,8 +212,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
|
|||
@Before
|
||||
public void setUp() throws IOException, VersionException {
|
||||
toy = DefaultLanguageService.getLanguageService()
|
||||
.getLanguage(
|
||||
new LanguageID("Toy:BE:64:default"));
|
||||
.getLanguage(new LanguageID("Toy:BE:64:default"));
|
||||
obj = new MyObject(toy, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@ import java.util.*;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import db.Transaction;
|
||||
import db.DBHandle;
|
||||
import db.Transaction;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
import ghidra.trace.model.TraceAddressSnapRange;
|
||||
import ghidra.trace.model.memory.TraceMemoryState;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.task.ConsoleTaskMonitor;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
@ -683,62 +683,52 @@ public abstract class AbstractDBTraceMemoryManagerMemoryTest
|
|||
}
|
||||
|
||||
try {
|
||||
memory.findBytes(3, b.range(0x4000, 0x4003), b.buf(1, 2, 3, 4), b.buf(-1, -1, -1),
|
||||
true, TaskMonitor.DUMMY);
|
||||
memory.findBytes(3, b.range(0x4000, 0x4003), b.buf(1, 2, 3, 4), b.buf(-1, -1, -1), true,
|
||||
TaskMonitor.DUMMY);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
// Degenerate
|
||||
assertNull(
|
||||
memory.findBytes(2, b.range(0x4000, 0x4003), b.buf(), b.buf(),
|
||||
true, TaskMonitor.DUMMY));
|
||||
assertNull(memory.findBytes(2, b.range(0x4000, 0x4003), b.buf(), b.buf(), true,
|
||||
TaskMonitor.DUMMY));
|
||||
|
||||
// Too soon
|
||||
assertNull(
|
||||
memory.findBytes(2, b.range(0x4000, 0x4003), b.buf(1, 2, 3, 4), b.buf(-1, -1, -1, -1),
|
||||
true, TaskMonitor.DUMMY));
|
||||
assertNull(memory.findBytes(2, b.range(0x4000, 0x4003), b.buf(1, 2, 3, 4),
|
||||
b.buf(-1, -1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
|
||||
// Too small
|
||||
assertNull(
|
||||
memory.findBytes(3, b.range(0x4000, 0x4002), b.buf(1, 2, 3, 4), b.buf(-1, -1, -1, -1),
|
||||
true, TaskMonitor.DUMMY));
|
||||
assertNull(memory.findBytes(3, b.range(0x4000, 0x4002), b.buf(1, 2, 3, 4),
|
||||
b.buf(-1, -1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
|
||||
// Too high
|
||||
assertNull(
|
||||
memory.findBytes(3, b.range(0x4001, 0x4004), b.buf(1, 2, 3, 4), b.buf(-1, -1, -1, -1),
|
||||
true, TaskMonitor.DUMMY));
|
||||
assertNull(memory.findBytes(3, b.range(0x4001, 0x4004), b.buf(1, 2, 3, 4),
|
||||
b.buf(-1, -1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
|
||||
// Too high, into unknown
|
||||
assertNull(
|
||||
memory.findBytes(3, b.range(0x4001, 0x4005), b.buf(1, 2, 3, 4, 5),
|
||||
b.buf(-1, -1, -1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
assertNull(memory.findBytes(3, b.range(0x4001, 0x4005), b.buf(1, 2, 3, 4, 5),
|
||||
b.buf(-1, -1, -1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
|
||||
// Too low
|
||||
assertNull(
|
||||
memory.findBytes(3, b.range(0x3fff, 0x4002), b.buf(1, 2, 3, 4), b.buf(-1, -1, -1, -1),
|
||||
true, TaskMonitor.DUMMY));
|
||||
assertNull(memory.findBytes(3, b.range(0x3fff, 0x4002), b.buf(1, 2, 3, 4),
|
||||
b.buf(-1, -1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
|
||||
// Perfect match
|
||||
assertEquals(b.addr(0x4000),
|
||||
memory.findBytes(3, b.range(0x4000, 0x4003), b.buf(1, 2, 3, 4), b.buf(-1, -1, -1, -1),
|
||||
true, TaskMonitor.DUMMY));
|
||||
assertEquals(b.addr(0x4000), memory.findBytes(3, b.range(0x4000, 0x4003), b.buf(1, 2, 3, 4),
|
||||
b.buf(-1, -1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
|
||||
// Make it work for the match
|
||||
assertEquals(b.addr(0x4000), memory.findBytes(3, b.range(0x0, -1), b.buf(1, 2, 3, 4),
|
||||
b.buf(-1, -1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
|
||||
// Make it work for the match
|
||||
assertEquals(b.addr(0x4000),
|
||||
memory.findBytes(3, b.range(0x0, -1), b.buf(1, 2, 3, 4), b.buf(-1, -1, -1, -1),
|
||||
true, TaskMonitor.DUMMY));
|
||||
|
||||
// Make it work for the match
|
||||
assertEquals(b.addr(0x4000),
|
||||
memory.findBytes(3, b.range(0x0, -1), b.buf(1), b.buf(-1),
|
||||
true, TaskMonitor.DUMMY));
|
||||
memory.findBytes(3, b.range(0x0, -1), b.buf(1), b.buf(-1), true, TaskMonitor.DUMMY));
|
||||
|
||||
// Sub match
|
||||
assertEquals(b.addr(0x4001),
|
||||
memory.findBytes(3, b.range(0x4000, 0x4003), b.buf(2, 3, 4), b.buf(-1, -1, -1),
|
||||
true, TaskMonitor.DUMMY));
|
||||
assertEquals(b.addr(0x4001), memory.findBytes(3, b.range(0x4000, 0x4003), b.buf(2, 3, 4),
|
||||
b.buf(-1, -1, -1), true, TaskMonitor.DUMMY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -811,7 +801,7 @@ public abstract class AbstractDBTraceMemoryManagerMemoryTest
|
|||
DBHandle opened = new DBHandle(tmp.toFile());
|
||||
DBTrace restored = null;
|
||||
try {
|
||||
restored = new DBTrace(opened, DBOpenMode.UPDATE, new ConsoleTaskMonitor(), this);
|
||||
restored = new DBTrace(opened, OpenMode.UPDATE, new ConsoleTaskMonitor(), this);
|
||||
|
||||
DBTraceMemorySpace rSpace =
|
||||
restored.getMemoryManager().getMemorySpace(b.language.getDefaultDataSpace(), true);
|
||||
|
|
|
@ -20,23 +20,22 @@ import java.io.IOException;
|
|||
import db.DBHandle;
|
||||
import generic.depends.DependentServiceResolver;
|
||||
import generic.depends.err.*;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public abstract class DBDomainObjectSupport extends DomainObjectAdapterDB {
|
||||
private DBOpenMode openMode;
|
||||
private OpenMode openMode;
|
||||
private TaskMonitor monitor;
|
||||
|
||||
private VersionException versionExc;
|
||||
|
||||
protected static interface ManagerSupplier<T> {
|
||||
T create(DBOpenMode openMode, TaskMonitor monitor)
|
||||
T create(OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, VersionException, CancelledException;
|
||||
}
|
||||
|
||||
protected DBDomainObjectSupport(DBHandle dbh, DBOpenMode openMode, TaskMonitor monitor,
|
||||
protected DBDomainObjectSupport(DBHandle dbh, OpenMode openMode, TaskMonitor monitor,
|
||||
String name, int timeInterval, int bufSize, Object consumer) {
|
||||
super(dbh, name, timeInterval, consumer);
|
||||
this.openMode = openMode;
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.concurrent.locks.*;
|
|||
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.DBDomainObjectSupport;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.Swing;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -163,7 +164,7 @@ public abstract class DBCachedDomainObjectAdapter extends DBDomainObjectSupport
|
|||
/**
|
||||
* @see {@link DBDomainObjectSupport}
|
||||
*/
|
||||
protected DBCachedDomainObjectAdapter(DBHandle dbh, DBOpenMode openMode, TaskMonitor monitor,
|
||||
protected DBCachedDomainObjectAdapter(DBHandle dbh, OpenMode openMode, TaskMonitor monitor,
|
||||
String name, int timeInterval, int bufSize, Object consumer) {
|
||||
super(dbh, openMode, monitor, name, timeInterval, bufSize, consumer);
|
||||
this.rwLock = new GhidraLockWrappingRWLock(lock);
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.util.database;
|
||||
|
||||
import db.DBConstants;
|
||||
|
||||
/**
|
||||
* An enum, providing a type-safe version of {@link DBConstants}.
|
||||
*/
|
||||
public enum DBOpenMode {
|
||||
CREATE(DBConstants.CREATE),
|
||||
UPDATE(DBConstants.UPDATE),
|
||||
READ_ONLY(DBConstants.READ_ONLY),
|
||||
UPGRADE(DBConstants.UPGRADE);
|
||||
|
||||
private final int openMode;
|
||||
|
||||
private DBOpenMode(int openMode) {
|
||||
this.openMode = openMode;
|
||||
}
|
||||
|
||||
public int toInteger() {
|
||||
return openMode;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import org.junit.Ignore;
|
|||
import org.junit.Test;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.UniversalIdGenerator;
|
||||
import ghidra.util.database.annot.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
@ -35,7 +36,7 @@ public class DBCachedObjectStoreFactoryTest {
|
|||
|
||||
public static class MyDomainObject extends DBCachedDomainObjectAdapter {
|
||||
protected MyDomainObject(DBHandle dbh, String name, Object consumer) {
|
||||
super(dbh, DBOpenMode.CREATE, TaskMonitor.DUMMY, name, 500, 1000, consumer);
|
||||
super(dbh, OpenMode.CREATE, TaskMonitor.DUMMY, name, 500, 1000, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
|||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.UniversalIdGenerator;
|
||||
import ghidra.util.database.DirectedIterator.Direction;
|
||||
import ghidra.util.database.annot.*;
|
||||
|
@ -67,7 +68,7 @@ public class DBCachedObjectStoreTest {
|
|||
|
||||
protected MyDomainObject(String name, int timeInterval, int bufSize, Object consumer)
|
||||
throws VersionException, IOException {
|
||||
super(new DBHandle(), DBOpenMode.CREATE, new ConsoleTaskMonitor(), name, timeInterval,
|
||||
super(new DBHandle(), OpenMode.CREATE, new ConsoleTaskMonitor(), name, timeInterval,
|
||||
bufSize, consumer);
|
||||
this.storeFactory = new DBCachedObjectStoreFactory(this);
|
||||
try (Transaction tx = dbh.openTransaction(this)) {
|
||||
|
@ -76,7 +77,7 @@ public class DBCachedObjectStoreTest {
|
|||
}
|
||||
}
|
||||
|
||||
protected MyDomainObject(DBHandle handle, DBOpenMode openMode, TaskMonitor monitor,
|
||||
protected MyDomainObject(DBHandle handle, OpenMode openMode, TaskMonitor monitor,
|
||||
int timeInterval, int bufSize, Object consumer)
|
||||
throws VersionException, IOException {
|
||||
super(handle, openMode, monitor, null, timeInterval, bufSize, consumer);
|
||||
|
@ -311,8 +312,8 @@ public class DBCachedObjectStoreTest {
|
|||
DBHandle opened = new DBHandle(tmp.toFile());
|
||||
MyDomainObject restored = null;
|
||||
try {
|
||||
restored = new MyDomainObject(opened, DBOpenMode.READ_ONLY, new ConsoleTaskMonitor(),
|
||||
500, 1000, this);
|
||||
restored = new MyDomainObject(opened, OpenMode.IMMUTABLE, new ConsoleTaskMonitor(), 500,
|
||||
1000, this);
|
||||
MyObject rObj = restored.store.getObjectAt(0x1234);
|
||||
assertEquals(0x811, rObj.f1);
|
||||
assertEquals(0x812, rObj.f2);
|
||||
|
@ -1941,15 +1942,15 @@ public class DBCachedObjectStoreTest {
|
|||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(List.of(-3L, -1L, 1L, 3L), list);
|
||||
list = ((List<Entry<Long, ?>>) (List) Arrays.asList(entrySet.toArray(new Entry[4])))
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
list =
|
||||
((List<Entry<Long, ?>>) (List) Arrays.asList(entrySet.toArray(new Entry[4]))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(List.of(-3L, -1L, 1L, 3L), list);
|
||||
list = ((List<Entry<Long, ?>>) (List) Arrays.asList(entrySet.toArray(new Entry[5])))
|
||||
.stream()
|
||||
.map(nullable(Entry::getKey))
|
||||
.collect(Collectors.toList());
|
||||
list =
|
||||
((List<Entry<Long, ?>>) (List) Arrays.asList(entrySet.toArray(new Entry[5]))).stream()
|
||||
.map(nullable(Entry::getKey))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(Arrays.asList(new Long[] { -3L, -1L, 1L, 3L, null }), list);
|
||||
|
||||
List<Long> rList =
|
||||
|
@ -1957,15 +1958,15 @@ public class DBCachedObjectStoreTest {
|
|||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(List.of(3L, 1L, -1L, -3L), rList);
|
||||
rList = ((List<Entry<Long, ?>>) (List) Arrays.asList(rEntrySet.toArray(new Entry[4])))
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
rList =
|
||||
((List<Entry<Long, ?>>) (List) Arrays.asList(rEntrySet.toArray(new Entry[4]))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(List.of(3L, 1L, -1L, -3L), rList);
|
||||
rList = ((List<Entry<Long, ?>>) (List) Arrays.asList(rEntrySet.toArray(new Entry[5])))
|
||||
.stream()
|
||||
.map(nullable(Entry::getKey))
|
||||
.collect(Collectors.toList());
|
||||
rList =
|
||||
((List<Entry<Long, ?>>) (List) Arrays.asList(rEntrySet.toArray(new Entry[5]))).stream()
|
||||
.map(nullable(Entry::getKey))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(Arrays.asList(new Long[] { 3L, 1L, -1L, -3L, null }), rList);
|
||||
}
|
||||
|
||||
|
@ -2083,20 +2084,21 @@ public class DBCachedObjectStoreTest {
|
|||
public void testAsEntrySetDescendingIterator() {
|
||||
populateStore(-3, -1, 1, 3);
|
||||
|
||||
assertEquals(List.of(3L, 1L, -1L, -3L), IteratorUtils.toList(entrySet.descendingIterator())
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-3L, -1L, 1L, 3L), IteratorUtils.toList(rEntrySet.descendingIterator())
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(3L, 1L, -1L, -3L),
|
||||
IteratorUtils.toList(entrySet.descendingIterator())
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-3L, -1L, 1L, 3L),
|
||||
IteratorUtils.toList(rEntrySet.descendingIterator())
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsEntrySetSubSet() {
|
||||
assertEquals(map.subMap(1L, 2L).keySet().keySpan,
|
||||
entrySet.subSet(ent(1), ent(2)).keySpan);
|
||||
assertEquals(map.subMap(1L, 2L).keySet().keySpan, entrySet.subSet(ent(1), ent(2)).keySpan);
|
||||
assertEquals(rMap.subMap(2L, 1L).keySet().keySpan,
|
||||
rEntrySet.subSet(ent(2), ent(1)).keySpan);
|
||||
assertEquals(map.subMap(1L, 2L).keySet().direction,
|
||||
|
@ -2123,10 +2125,10 @@ public class DBCachedObjectStoreTest {
|
|||
new ArrayList<>(rEntrySet.subSet(ent(3), false, ent(-3), true)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-3L, -1L, 1L), new ArrayList<>(entrySet.subSet(ent(-3), ent(3)))
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-3L, -1L, 1L),
|
||||
new ArrayList<>(entrySet.subSet(ent(-3), ent(3))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
assertEquals(List.of(-1L, 1L, 3L),
|
||||
new ArrayList<>(entrySet.subSet(ent(-3), false, ent(3), true)).stream()
|
||||
|
@ -2136,10 +2138,10 @@ public class DBCachedObjectStoreTest {
|
|||
new ArrayList<>(rEntrySet.subSet(ent(3), true, ent(-3), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(3L, 1L, -1L), new ArrayList<>(rEntrySet.subSet(ent(3), ent(-3)))
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(3L, 1L, -1L),
|
||||
new ArrayList<>(rEntrySet.subSet(ent(3), ent(-3))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
assertEquals(List.of(-3L, -1L, 1L, 3L),
|
||||
new ArrayList<>(entrySet.subSet(ent(-3), true, ent(3), true)).stream()
|
||||
|
@ -2160,27 +2162,32 @@ public class DBCachedObjectStoreTest {
|
|||
|
||||
populateStore(-5, -3, -1, 1, 3, 5);
|
||||
|
||||
assertEquals(List.of(-5L, -3L), new ArrayList<>(entrySet.headSet(ent(-1), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(5L, 3L), new ArrayList<>(rEntrySet.headSet(ent(1), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-5L, -3L),
|
||||
new ArrayList<>(entrySet.headSet(ent(-1), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(5L, 3L),
|
||||
new ArrayList<>(rEntrySet.headSet(ent(1), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
assertEquals(List.of(-5L, -3L, -1L), new ArrayList<>(entrySet.headSet(ent(-1), true))
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(5L, 3L, 1L), new ArrayList<>(rEntrySet.headSet(ent(1), true)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-5L, -3L, -1L),
|
||||
new ArrayList<>(entrySet.headSet(ent(-1), true)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(5L, 3L, 1L),
|
||||
new ArrayList<>(rEntrySet.headSet(ent(1), true)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
assertEquals(List.of(-5L, -3L), new ArrayList<>(entrySet.headSet(ent(-1))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(5L, 3L), new ArrayList<>(rEntrySet.headSet(ent(1))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-5L, -3L),
|
||||
new ArrayList<>(entrySet.headSet(ent(-1))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(5L, 3L),
|
||||
new ArrayList<>(rEntrySet.headSet(ent(1))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2192,27 +2199,32 @@ public class DBCachedObjectStoreTest {
|
|||
|
||||
populateStore(-5, -3, -1, 1, 3, 5);
|
||||
|
||||
assertEquals(List.of(3L, 5L), new ArrayList<>(entrySet.tailSet(ent(1), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-3L, -5L), new ArrayList<>(rEntrySet.tailSet(ent(-1), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(3L, 5L),
|
||||
new ArrayList<>(entrySet.tailSet(ent(1), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-3L, -5L),
|
||||
new ArrayList<>(rEntrySet.tailSet(ent(-1), false)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
assertEquals(List.of(1L, 3L, 5L), new ArrayList<>(entrySet.tailSet(ent(1), true)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-1L, -3L, -5L), new ArrayList<>(rEntrySet.tailSet(ent(-1), true))
|
||||
.stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(1L, 3L, 5L),
|
||||
new ArrayList<>(entrySet.tailSet(ent(1), true)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-1L, -3L, -5L),
|
||||
new ArrayList<>(rEntrySet.tailSet(ent(-1), true)).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
assertEquals(List.of(1L, 3L, 5L), new ArrayList<>(entrySet.tailSet(ent(1))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-1L, -3L, -5L), new ArrayList<>(rEntrySet.tailSet(ent(-1))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(1L, 3L, 5L),
|
||||
new ArrayList<>(entrySet.tailSet(ent(1))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
assertEquals(List.of(-1L, -3L, -5L),
|
||||
new ArrayList<>(rEntrySet.tailSet(ent(-1))).stream()
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.junit.*;
|
|||
|
||||
import db.*;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.ColorUtils;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.database.*;
|
||||
|
@ -540,8 +541,9 @@ public class RStarTreeMapTest {
|
|||
int x = e.getX() * rootWidth / getWidth();
|
||||
int y = e.getY() * rootHeight / getHeight();
|
||||
selected.clear();
|
||||
selected.addAll(asSpatialMap().reduce(
|
||||
IntRectQuery.intersecting(rect(x, x, y, y))).keys());
|
||||
selected.addAll(
|
||||
asSpatialMap().reduce(IntRectQuery.intersecting(rect(x, x, y, y)))
|
||||
.keys());
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
|
@ -632,23 +634,23 @@ public class RStarTreeMapTest {
|
|||
public final SpatialMap<IntRect, String, IntRectQuery> map;
|
||||
|
||||
public MyDomainObject(Object consumer) throws IOException, VersionException {
|
||||
super(new DBHandle(), DBOpenMode.CREATE, new ConsoleTaskMonitor(), "Testing", 500, 1000,
|
||||
super(new DBHandle(), OpenMode.CREATE, new ConsoleTaskMonitor(), "Testing", 500, 1000,
|
||||
consumer);
|
||||
storeFactory = new DBCachedObjectStoreFactory(this);
|
||||
try (Transaction tx = openTransaction("CreateMaps")) {
|
||||
tree = new IntRStarTree(storeFactory, DBIntRectStringDataRecord.TABLE_NAME,
|
||||
true, MAX_CHILDREN);
|
||||
tree = new IntRStarTree(storeFactory, DBIntRectStringDataRecord.TABLE_NAME, true,
|
||||
MAX_CHILDREN);
|
||||
map = tree.asSpatialMap();
|
||||
}
|
||||
}
|
||||
|
||||
protected MyDomainObject(File file, Object consumer) throws IOException, VersionException {
|
||||
super(new DBHandle(file), DBOpenMode.UPDATE, new ConsoleTaskMonitor(), "Testing", 500,
|
||||
super(new DBHandle(file), OpenMode.UPDATE, new ConsoleTaskMonitor(), "Testing", 500,
|
||||
1000, consumer);
|
||||
storeFactory = new DBCachedObjectStoreFactory(this);
|
||||
// No transaction, as tree should already exist
|
||||
tree = new IntRStarTree(storeFactory, DBIntRectStringDataRecord.TABLE_NAME,
|
||||
true, MAX_CHILDREN);
|
||||
tree = new IntRStarTree(storeFactory, DBIntRectStringDataRecord.TABLE_NAME, true,
|
||||
MAX_CHILDREN);
|
||||
map = tree.asSpatialMap();
|
||||
}
|
||||
|
||||
|
@ -767,10 +769,10 @@ public class RStarTreeMapTest {
|
|||
IntRect queryRect1 = rect(1, 1, 12, 13);
|
||||
IntRect queryRect2 = rect(4, 4, 12, 13);
|
||||
List<IntRect> expected = new ArrayList<>();
|
||||
IteratorUtils.filteredIterator(allRects(range),
|
||||
r -> queryRect1.intersects(r) && queryRect2.intersects(r))
|
||||
.forEachRemaining(
|
||||
expected::add);
|
||||
IteratorUtils
|
||||
.filteredIterator(allRects(range),
|
||||
r -> queryRect1.intersects(r) && queryRect2.intersects(r))
|
||||
.forEachRemaining(expected::add);
|
||||
|
||||
System.out.println(expected);
|
||||
|
||||
|
@ -934,8 +936,7 @@ public class RStarTreeMapTest {
|
|||
loaded = new MyDomainObject(tmp.toFile(), this);
|
||||
|
||||
assert loaded.map.entries()
|
||||
.contains(
|
||||
new ImmutablePair<>(rect(1, 5, 6, 10), "Some value"));
|
||||
.contains(new ImmutablePair<>(rect(1, 5, 6, 10), "Some value"));
|
||||
}
|
||||
finally {
|
||||
if (loaded != null) {
|
||||
|
@ -1002,18 +1003,16 @@ public class RStarTreeMapTest {
|
|||
obj.map.reduce(IntRectQuery.enclosed(rect(12, 12, 6, 6))).firstValue());
|
||||
|
||||
assertEquals("Point(12,6)",
|
||||
obj.map.reduce(IntRectQuery.enclosed(rect(1, 12, 6, 6))
|
||||
.starting(
|
||||
Rectangle2DDirection.RIGHTMOST))
|
||||
obj.map.reduce(
|
||||
IntRectQuery.enclosed(rect(1, 12, 6, 6)).starting(Rectangle2DDirection.RIGHTMOST))
|
||||
.firstValue());
|
||||
assertEquals("Point(6,1)",
|
||||
obj.map.reduce(
|
||||
IntRectQuery.enclosed(rect(6, 6, 1, 12)).starting(Rectangle2DDirection.BOTTOMMOST))
|
||||
.firstValue());
|
||||
assertEquals("Point(6,1)", obj.map.reduce(IntRectQuery.enclosed(rect(6, 6, 1, 12))
|
||||
.starting(
|
||||
Rectangle2DDirection.BOTTOMMOST))
|
||||
.firstValue());
|
||||
assertEquals("Point(6,12)",
|
||||
obj.map.reduce(IntRectQuery.enclosed(rect(6, 6, 1, 12))
|
||||
.starting(
|
||||
Rectangle2DDirection.TOPMOST))
|
||||
obj.map.reduce(
|
||||
IntRectQuery.enclosed(rect(6, 6, 1, 12)).starting(Rectangle2DDirection.TOPMOST))
|
||||
.firstValue());
|
||||
}
|
||||
|
||||
|
@ -1036,14 +1035,12 @@ public class RStarTreeMapTest {
|
|||
actual.clear();
|
||||
points.stream()
|
||||
.filter(e -> e.getKey().enclosedBy(rect(1, 6, 1, 12)))
|
||||
.forEach(
|
||||
e -> expected.put(e.getKey(), e.getValue()));
|
||||
.forEach(e -> expected.put(e.getKey(), e.getValue()));
|
||||
assertEquals(72, expected.size()); // Sanity check on expected
|
||||
obj.map.reduce(IntRectQuery.enclosed(rect(1, 6, 1, 12)))
|
||||
.entries()
|
||||
.stream()
|
||||
.forEach(
|
||||
e -> actual.put(e.getKey(), e.getValue()));
|
||||
.forEach(e -> actual.put(e.getKey(), e.getValue()));
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -1068,9 +1065,8 @@ public class RStarTreeMapTest {
|
|||
|
||||
expected = List.of("Point(6,6)", "Point(5,6)", "Point(4,6)", "Point(3,6)", "Point(2,6)",
|
||||
"Point(1,6)");
|
||||
actual = new ArrayList<>(obj.map.reduce(IntRectQuery.enclosed(rect(1, 6, 6, 6))
|
||||
.starting(
|
||||
Rectangle2DDirection.RIGHTMOST))
|
||||
actual = new ArrayList<>(obj.map.reduce(
|
||||
IntRectQuery.enclosed(rect(1, 6, 6, 6)).starting(Rectangle2DDirection.RIGHTMOST))
|
||||
.orderedValues());
|
||||
}
|
||||
|
||||
|
@ -1123,8 +1119,7 @@ public class RStarTreeMapTest {
|
|||
Map<IntRect, String> actual = new HashMap<>();
|
||||
points.stream()
|
||||
.filter(e -> e.getKey().enclosedBy(rect(7, 12, 1, 12)))
|
||||
.forEach(
|
||||
e -> expected.put(e.getKey(), e.getValue()));
|
||||
.forEach(e -> expected.put(e.getKey(), e.getValue()));
|
||||
obj.map.entries().stream().forEach(e -> actual.put(e.getKey(), e.getValue()));
|
||||
assertEquals(expected, actual);
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.model.lang.LanguageNotFoundException;
|
||||
|
@ -75,8 +75,8 @@ public class UpgradeTestProgramScript extends GhidraScript {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean upgradeProgramArchive(File gzf) throws IOException, CancelledException,
|
||||
VersionException {
|
||||
private boolean upgradeProgramArchive(File gzf)
|
||||
throws IOException, CancelledException, VersionException {
|
||||
|
||||
PackedDatabase db = PackedDatabase.getPackedDatabase(gzf, TaskMonitor.DUMMY);
|
||||
DBHandle dbh = null;
|
||||
|
@ -89,7 +89,7 @@ public class UpgradeTestProgramScript extends GhidraScript {
|
|||
}
|
||||
|
||||
try {
|
||||
p = new ProgramDB(dbh, DBConstants.UPDATE, monitor, this);
|
||||
p = new ProgramDB(dbh, OpenMode.UPDATE, monitor, this);
|
||||
return false;
|
||||
}
|
||||
catch (LanguageNotFoundException e) {
|
||||
|
@ -107,7 +107,7 @@ public class UpgradeTestProgramScript extends GhidraScript {
|
|||
}
|
||||
|
||||
dbh = db.openForUpdate(monitor);
|
||||
p = new ProgramDB(dbh, DBConstants.UPGRADE, monitor, this);
|
||||
p = new ProgramDB(dbh, OpenMode.UPGRADE, monitor, this);
|
||||
|
||||
if (!p.isChanged()) {
|
||||
return false;
|
||||
|
|
|
@ -20,12 +20,12 @@ import java.util.*;
|
|||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.framework.model.Project;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
|
@ -55,8 +55,8 @@ public class GdtLoader implements Loader {
|
|||
@Override
|
||||
public LoadResults<? extends DomainObject> load(ByteProvider provider, String filename,
|
||||
Project project, String projectFolderPath, LoadSpec loadSpec, List<Option> options,
|
||||
MessageLog messageLog, Object consumer, TaskMonitor monitor) throws IOException,
|
||||
CancelledException, VersionException {
|
||||
MessageLog messageLog, Object consumer, TaskMonitor monitor)
|
||||
throws IOException, CancelledException, VersionException {
|
||||
|
||||
DataTypeArchive dtArchive =
|
||||
loadPackedProgramDatabase(provider, filename, consumer, monitor);
|
||||
|
@ -78,15 +78,15 @@ public class GdtLoader implements Loader {
|
|||
boolean success = false;
|
||||
DBHandle dbh = null;
|
||||
try {
|
||||
if (!DataTypeArchiveContentHandler.DATA_TYPE_ARCHIVE_CONTENT_TYPE.equals(
|
||||
packedDatabase.getContentType())) {
|
||||
if (!DataTypeArchiveContentHandler.DATA_TYPE_ARCHIVE_CONTENT_TYPE
|
||||
.equals(packedDatabase.getContentType())) {
|
||||
throw new IOException("File imported is not a Program: " + programName);
|
||||
}
|
||||
|
||||
monitor.setMessage("Restoring " + provider.getName());
|
||||
|
||||
dbh = packedDatabase.open(monitor);
|
||||
dtArchive = new DataTypeArchiveDB(dbh, DBConstants.UPGRADE, monitor, consumer);
|
||||
dtArchive = new DataTypeArchiveDB(dbh, OpenMode.UPGRADE, monitor, consumer);
|
||||
success = true;
|
||||
}
|
||||
finally {
|
||||
|
@ -116,7 +116,8 @@ public class GdtLoader implements Loader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program program) {
|
||||
public String validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program) {
|
||||
if (options != null && options.size() > 0) {
|
||||
return "GDTLoader takes no options";
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ import java.util.*;
|
|||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.framework.model.Project;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
|
@ -57,7 +57,8 @@ public class GzfLoader implements Loader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program program) {
|
||||
public String validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program) {
|
||||
if (options != null && options.size() > 0) {
|
||||
return "GzfLoader takes no options";
|
||||
}
|
||||
|
@ -73,8 +74,8 @@ public class GzfLoader implements Loader {
|
|||
@Override
|
||||
public LoadResults<? extends DomainObject> load(ByteProvider provider, String programName,
|
||||
Project project, String projectFolderPath, LoadSpec loadSpec, List<Option> options,
|
||||
MessageLog messageLog, Object consumer, TaskMonitor monitor) throws IOException,
|
||||
CancelledException, VersionException {
|
||||
MessageLog messageLog, Object consumer, TaskMonitor monitor)
|
||||
throws IOException, CancelledException, VersionException {
|
||||
|
||||
Program program = loadPackedProgramDatabase(provider, programName, consumer, monitor);
|
||||
return new LoadResults<>(program, programName, projectFolderPath);
|
||||
|
@ -95,15 +96,15 @@ public class GzfLoader implements Loader {
|
|||
boolean success = false;
|
||||
DBHandle dbh = null;
|
||||
try {
|
||||
if (!ProgramContentHandler.PROGRAM_CONTENT_TYPE.equals(
|
||||
packedDatabase.getContentType())) {
|
||||
if (!ProgramContentHandler.PROGRAM_CONTENT_TYPE
|
||||
.equals(packedDatabase.getContentType())) {
|
||||
throw new IOException("File imported is not a Program: " + programName);
|
||||
}
|
||||
|
||||
monitor.setMessage("Restoring " + provider.getName());
|
||||
|
||||
dbh = packedDatabase.open(monitor);
|
||||
program = new ProgramDB(dbh, DBConstants.UPGRADE, monitor, consumer);
|
||||
program = new ProgramDB(dbh, OpenMode.UPGRADE, monitor, consumer);
|
||||
success = true;
|
||||
}
|
||||
finally {
|
||||
|
|
|
@ -18,12 +18,12 @@ package ghidra.test;
|
|||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import db.buffers.BufferFile;
|
||||
import generic.test.*;
|
||||
import ghidra.app.util.xml.*;
|
||||
import ghidra.framework.data.DomainObjectAdapterDB;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.store.db.PrivateDatabase;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
|
@ -289,7 +289,7 @@ public class TestProgramManager {
|
|||
boolean success = false;
|
||||
try {
|
||||
dbh = db.open(TaskMonitor.DUMMY);
|
||||
program = new ProgramDB(dbh, DBConstants.UPDATE, null, this);
|
||||
program = new ProgramDB(dbh, OpenMode.UPDATE, null, this);
|
||||
success = true;
|
||||
}
|
||||
catch (VersionException ve) {
|
||||
|
@ -320,7 +320,7 @@ public class TestProgramManager {
|
|||
|
||||
Msg.info(this, message + (endTime - startTime));
|
||||
dbh = db.open(TaskMonitor.DUMMY);
|
||||
program = new ProgramDB(dbh, DBConstants.UPDATE, null, this);
|
||||
program = new ProgramDB(dbh, OpenMode.UPDATE, null, this);
|
||||
dbh = null;
|
||||
success = true;
|
||||
}
|
||||
|
@ -466,8 +466,7 @@ public class TestProgramManager {
|
|||
|
||||
DBHandle dbh = db.openForUpdate(TaskMonitor.DUMMY);
|
||||
try {
|
||||
ProgramDB program =
|
||||
new ProgramDB(dbh, DBConstants.UPGRADE, TaskMonitor.DUMMY, this);
|
||||
ProgramDB program = new ProgramDB(dbh, OpenMode.UPGRADE, TaskMonitor.DUMMY, this);
|
||||
if (dbh != null) {
|
||||
dbh.save(null, null, TaskMonitor.DUMMY);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class FunctionWindowPluginTest extends AbstractGhidraHeadedIntegrationTes
|
|||
|
||||
int numData = functionTable.getRowCount();
|
||||
|
||||
CompoundCmd cmd = new CompoundCmd("Clear");
|
||||
CompoundCmd<Program> cmd = new CompoundCmd<>("Clear");
|
||||
FunctionIterator itr = program.getListing().getFunctions(true);
|
||||
while (itr.hasNext()) {
|
||||
Function f = itr.next();
|
||||
|
|
|
@ -23,8 +23,10 @@ import java.util.Iterator;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Table;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -153,9 +155,8 @@ public class DBPropertyMapManagerTest extends AbstractGhidraHeadedIntegrationTes
|
|||
program = null;
|
||||
|
||||
dbh = new DBHandle(dbFile);
|
||||
mgr =
|
||||
new DBPropertyMapManager(dbh, changeMgr, addrMap, DBConstants.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr = new DBPropertyMapManager(dbh, changeMgr, addrMap, OpenMode.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
PropertyMap<?> pmap = mgr.getPropertyMap("TEST");
|
||||
assertEquals(1, pmap.getSize());
|
||||
}
|
||||
|
@ -171,9 +172,8 @@ public class DBPropertyMapManagerTest extends AbstractGhidraHeadedIntegrationTes
|
|||
program = null;
|
||||
|
||||
dbh = new DBHandle(dbFile);
|
||||
mgr =
|
||||
new DBPropertyMapManager(dbh, changeMgr, addrMap, DBConstants.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr = new DBPropertyMapManager(dbh, changeMgr, addrMap, OpenMode.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
PropertyMap<?> pmap = mgr.getPropertyMap("TEST");
|
||||
assertEquals(1, pmap.getSize());
|
||||
}
|
||||
|
@ -189,9 +189,8 @@ public class DBPropertyMapManagerTest extends AbstractGhidraHeadedIntegrationTes
|
|||
program = null;
|
||||
|
||||
dbh = new DBHandle(dbFile);
|
||||
mgr =
|
||||
new DBPropertyMapManager(dbh, changeMgr, addrMap, DBConstants.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr = new DBPropertyMapManager(dbh, changeMgr, addrMap, OpenMode.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
PropertyMap<?> pmap = mgr.getPropertyMap("TEST");
|
||||
assertEquals(1, pmap.getSize());
|
||||
}
|
||||
|
@ -207,9 +206,8 @@ public class DBPropertyMapManagerTest extends AbstractGhidraHeadedIntegrationTes
|
|||
program = null;
|
||||
|
||||
dbh = new DBHandle(dbFile);
|
||||
mgr =
|
||||
new DBPropertyMapManager(dbh, changeMgr, addrMap, DBConstants.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr = new DBPropertyMapManager(dbh, changeMgr, addrMap, OpenMode.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
PropertyMap<?> pmap = mgr.getPropertyMap("TEST");
|
||||
assertEquals(1, pmap.getSize());
|
||||
}
|
||||
|
@ -226,9 +224,8 @@ public class DBPropertyMapManagerTest extends AbstractGhidraHeadedIntegrationTes
|
|||
program = null;
|
||||
|
||||
dbh = new DBHandle(dbFile);
|
||||
mgr =
|
||||
new DBPropertyMapManager(dbh, changeMgr, addrMap, DBConstants.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr = new DBPropertyMapManager(dbh, changeMgr, addrMap, OpenMode.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
PropertyMap<?> pmap = mgr.getPropertyMap("TEST");
|
||||
assertEquals(1, pmap.getSize());
|
||||
}
|
||||
|
@ -244,9 +241,8 @@ public class DBPropertyMapManagerTest extends AbstractGhidraHeadedIntegrationTes
|
|||
program = null;
|
||||
|
||||
dbh = new DBHandle(dbFile);
|
||||
mgr =
|
||||
new DBPropertyMapManager(dbh, changeMgr, addrMap, DBConstants.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr = new DBPropertyMapManager(dbh, changeMgr, addrMap, OpenMode.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
PropertyMap<?> pmap = mgr.getPropertyMap("TEST");
|
||||
assertEquals(1, pmap.getSize());
|
||||
}
|
||||
|
@ -263,9 +259,8 @@ public class DBPropertyMapManagerTest extends AbstractGhidraHeadedIntegrationTes
|
|||
|
||||
dbh = new DBHandle(dbFile);
|
||||
dbh.startTransaction();
|
||||
mgr =
|
||||
new DBPropertyMapManager(dbh, changeMgr, addrMap, DBConstants.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr = new DBPropertyMapManager(dbh, changeMgr, addrMap, OpenMode.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr.removePropertyMap("TEST");
|
||||
|
||||
assertNull(mgr.getIntPropertyMap("TEST"));
|
||||
|
@ -282,9 +277,8 @@ public class DBPropertyMapManagerTest extends AbstractGhidraHeadedIntegrationTes
|
|||
program = null;
|
||||
|
||||
dbh = new DBHandle(dbFile);
|
||||
mgr =
|
||||
new DBPropertyMapManager(dbh, changeMgr, addrMap, DBConstants.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
mgr = new DBPropertyMapManager(dbh, changeMgr, addrMap, OpenMode.UPDATE, new Lock("TEST"),
|
||||
TaskMonitor.DUMMY);
|
||||
|
||||
int cnt = 0;
|
||||
Iterator<String> iter = mgr.propertyManagers();
|
||||
|
|
|
@ -22,8 +22,10 @@ import java.util.Random;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Table;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -36,7 +38,8 @@ import ghidra.util.task.TaskMonitor;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class IntPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest implements ErrorHandler {
|
||||
public class IntPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest
|
||||
implements ErrorHandler {
|
||||
|
||||
private DBHandle db;
|
||||
private ProgramDB program;
|
||||
|
@ -81,8 +84,8 @@ public class IntPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest im
|
|||
}
|
||||
|
||||
private void createPropertyMap(String name) throws Exception {
|
||||
propertyMap = new IntPropertyMapDB(db, DBConstants.CREATE, this, null, addrMap, name,
|
||||
TaskMonitor.DUMMY);
|
||||
propertyMap =
|
||||
new IntPropertyMapDB(db, OpenMode.CREATE, this, null, addrMap, name, TaskMonitor.DUMMY);
|
||||
propertyMap.setCacheSize(2);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,10 @@ import java.util.Random;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Table;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -36,7 +38,8 @@ import ghidra.util.task.TaskMonitor;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class LongPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest implements ErrorHandler {
|
||||
public class LongPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest
|
||||
implements ErrorHandler {
|
||||
|
||||
private DBHandle db;
|
||||
private ProgramDB program;
|
||||
|
@ -81,7 +84,7 @@ public class LongPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest i
|
|||
}
|
||||
|
||||
private void createPropertyMap(String name) throws Exception {
|
||||
propertyMap = new LongPropertyMapDB(db, DBConstants.CREATE, this, null, addrMap, name,
|
||||
propertyMap = new LongPropertyMapDB(db, OpenMode.CREATE, this, null, addrMap, name,
|
||||
TaskMonitor.DUMMY);
|
||||
propertyMap.setCacheSize(2);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ import java.util.Random;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Table;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -35,7 +37,8 @@ import ghidra.util.task.TaskMonitor;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class ObjectPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest implements ErrorHandler {
|
||||
public class ObjectPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest
|
||||
implements ErrorHandler {
|
||||
|
||||
private DBHandle db;
|
||||
private ProgramDB program;
|
||||
|
@ -86,7 +89,7 @@ public class ObjectPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest
|
|||
}
|
||||
|
||||
private void createPropertyMap(String name) throws Exception {
|
||||
propertyMap = new ObjectPropertyMapDB<>(db, DBConstants.CREATE, this, null, addrMap, name,
|
||||
propertyMap = new ObjectPropertyMapDB<>(db, OpenMode.CREATE, this, null, addrMap, name,
|
||||
TestSaveable.class, TaskMonitor.DUMMY, true);
|
||||
propertyMap.setCacheSize(2);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ import java.util.Random;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Table;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -32,7 +34,8 @@ import ghidra.program.model.address.*;
|
|||
import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class StringPropertyMapDBTest extends AbstractGhidraHeadlessIntegrationTest implements ErrorHandler {
|
||||
public class StringPropertyMapDBTest extends AbstractGhidraHeadlessIntegrationTest
|
||||
implements ErrorHandler {
|
||||
|
||||
private DBHandle db;
|
||||
private ProgramDB program;
|
||||
|
@ -76,7 +79,7 @@ public class StringPropertyMapDBTest extends AbstractGhidraHeadlessIntegrationTe
|
|||
}
|
||||
|
||||
private void createPropertyMap(String name) throws Exception {
|
||||
propertyMap = new StringPropertyMapDB(db, DBConstants.CREATE, this, null, addrMap, name,
|
||||
propertyMap = new StringPropertyMapDB(db, OpenMode.CREATE, this, null, addrMap, name,
|
||||
TaskMonitor.DUMMY);
|
||||
propertyMap.setCacheSize(2);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,10 @@ import java.io.IOException;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Table;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -34,7 +36,8 @@ import ghidra.util.task.TaskMonitor;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class VoidPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest implements ErrorHandler {
|
||||
public class VoidPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest
|
||||
implements ErrorHandler {
|
||||
|
||||
private DBHandle db;
|
||||
private ProgramDB program;
|
||||
|
@ -83,7 +86,7 @@ public class VoidPropertyMapDBTest extends AbstractGhidraHeadedIntegrationTest i
|
|||
}
|
||||
|
||||
private void createPropertyMap(String name) throws Exception {
|
||||
propertyMap = new VoidPropertyMapDB(db, DBConstants.CREATE, this, null, addrMap, name,
|
||||
propertyMap = new VoidPropertyMapDB(db, OpenMode.CREATE, this, null, addrMap, name,
|
||||
TaskMonitor.DUMMY);
|
||||
propertyMap.setCacheSize(2);
|
||||
}
|
||||
|
|
|
@ -17,12 +17,14 @@ package ghidra.program.database;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.DBTestUtils;
|
||||
import db.buffers.BufferFile;
|
||||
import generic.test.AbstractGenericTest;
|
||||
import generic.test.AbstractGuiTest;
|
||||
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
||||
import ghidra.framework.data.GhidraFolder;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.framework.store.*;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
@ -122,8 +124,8 @@ public abstract class AbstractMTFModel {
|
|||
AbstractGenericTest.setInstanceField("isEnabled", analysisMgr, Boolean.FALSE);
|
||||
}
|
||||
|
||||
static DomainFile copyDatabaseDomainFile(DomainFile df, String newName) throws IOException,
|
||||
InvalidNameException, CancelledException {
|
||||
static DomainFile copyDatabaseDomainFile(DomainFile df, String newName)
|
||||
throws IOException, InvalidNameException, CancelledException {
|
||||
FileSystem fileSystem = (FileSystem) AbstractGenericTest.getInstanceField("fileSystem", df);
|
||||
|
||||
GhidraFolder parent = (GhidraFolder) df.getParent();
|
||||
|
@ -132,8 +134,7 @@ public abstract class AbstractMTFModel {
|
|||
BufferFile bufferFile = item.open();
|
||||
try {
|
||||
fileSystem.createDatabase(parent.getPathname(), newName, FileIDFactory.createFileID(),
|
||||
bufferFile, null, item.getContentType(), false, TaskMonitor.DUMMY,
|
||||
null);
|
||||
bufferFile, null, item.getContentType(), false, TaskMonitor.DUMMY, null);
|
||||
}
|
||||
finally {
|
||||
bufferFile.dispose();
|
||||
|
@ -183,8 +184,7 @@ public abstract class AbstractMTFModel {
|
|||
public static ProgramDB cloneProgram(ProgramDB prog, Object consumer) throws IOException {
|
||||
try {
|
||||
DBHandle newDbh = DBTestUtils.cloneDbHandle(prog.getDBHandle());
|
||||
ProgramDB newProg =
|
||||
new ProgramDB(newDbh, DBConstants.UPDATE, TaskMonitor.DUMMY, consumer);
|
||||
ProgramDB newProg = new ProgramDB(newDbh, OpenMode.UPDATE, TaskMonitor.DUMMY, consumer);
|
||||
newProg.setChangeSet(new ProgramDBChangeSet(newProg.getAddressMap(), 20));
|
||||
disableAutoAnalysis(newProg);
|
||||
return newProg;
|
||||
|
|
|
@ -25,6 +25,7 @@ import ghidra.feature.vt.api.impl.MarkupItemStorage;
|
|||
import ghidra.feature.vt.api.impl.VTEvent;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAssociationStatusException;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.util.Lock;
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Set;
|
|||
import db.*;
|
||||
import ghidra.feature.vt.api.main.VTAssociationStatus;
|
||||
import ghidra.feature.vt.api.main.VTAssociationType;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Set;
|
|||
import db.*;
|
||||
import ghidra.feature.vt.api.main.VTAssociationStatus;
|
||||
import ghidra.feature.vt.api.main.VTAssociationType;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
|
||||
import db.*;
|
||||
import ghidra.feature.vt.api.impl.MarkupItemStorage;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import ghidra.feature.vt.api.impl.MarkupItemStorage;
|
|||
import ghidra.feature.vt.api.main.VTSession;
|
||||
import ghidra.feature.vt.api.markuptype.VTMarkupTypeFactory;
|
||||
import ghidra.feature.vt.api.util.Stringable;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
|
|
@ -29,6 +29,7 @@ import ghidra.feature.vt.api.correlator.program.ImpliedMatchProgramCorrelator;
|
|||
import ghidra.feature.vt.api.correlator.program.ManualMatchProgramCorrelator;
|
||||
import ghidra.feature.vt.api.impl.*;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
|
||||
import db.*;
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.AddressSet;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jdom.output.XMLOutputter;
|
|||
|
||||
import db.*;
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.*;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
|
||||
import db.*;
|
||||
import ghidra.feature.vt.api.main.VTMatchInfo;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package ghidra.feature.vt.api.db;
|
|||
|
||||
import static ghidra.feature.vt.api.db.VTMatchTableDBAdapter.ColumnDescription.*;
|
||||
import ghidra.feature.vt.api.main.VTMatchInfo;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
package ghidra.feature.vt.api.db;
|
||||
|
||||
import static ghidra.feature.vt.api.db.VTMatchTagDBAdapter.ColumnDescription.TAG_NAME_COL;
|
||||
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import ghidra.feature.vt.api.impl.*;
|
|||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTSessionFileUtil;
|
||||
import ghidra.framework.data.DomainObjectAdapterDB;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.model.TransactionInfo.Status;
|
||||
import ghidra.framework.options.Options;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package db;
|
||||
|
||||
public interface DBConstants {
|
||||
public int CREATE = 0;
|
||||
public int UPDATE = 1;
|
||||
public int READ_ONLY = 2;
|
||||
public int UPGRADE = 3;
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package db;
|
||||
|
||||
public enum OpenMode {
|
||||
CREATE,
|
||||
UPDATE,
|
||||
READ_ONLY,
|
||||
UPGRADE,
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,10 +23,11 @@ public class TerminatedTransactionException extends RuntimeException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public TerminatedTransactionException() {
|
||||
super("Transaction has been terminated");
|
||||
}
|
||||
|
||||
public TerminatedTransactionException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ abstract class AbstractTransactionManager {
|
|||
|
||||
private volatile LockingTaskMonitor lockingTaskMonitor;
|
||||
|
||||
protected boolean isImmutable = false;
|
||||
|
||||
protected int lockCount = 0;
|
||||
protected String lockReason;
|
||||
|
||||
|
@ -196,6 +198,10 @@ abstract class AbstractTransactionManager {
|
|||
AbortedTransactionListener listener, boolean notify)
|
||||
throws TerminatedTransactionException {
|
||||
|
||||
if (isImmutable) {
|
||||
throw new TerminatedTransactionException("Transaction not permitted: read-only");
|
||||
}
|
||||
|
||||
checkLockingTask();
|
||||
|
||||
synchronized (this) {
|
||||
|
@ -314,4 +320,12 @@ abstract class AbstractTransactionManager {
|
|||
|
||||
abstract void doClose(DomainObjectAdapterDB object);
|
||||
|
||||
/**
|
||||
* Set instance as immutable by disabling use of transactions. Attempts to start a transaction
|
||||
* will result in a {@link TerminatedTransactionException}.
|
||||
*/
|
||||
public void setImmutable() {
|
||||
isImmutable = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,39 +33,12 @@ import ghidra.util.exception.CancelledException;
|
|||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Database version of the DomainObjectAdapter; this version adds the
|
||||
* Database version of the DomainObjectAdapter. Adds the
|
||||
* concept of starting a transaction before a change is made to the
|
||||
* domain object and ending the transaction. The transaction allows for
|
||||
* undo/redo changes.
|
||||
*
|
||||
* The implementation class must also satisfy the following requirements:
|
||||
* <pre>
|
||||
*
|
||||
* 1. The following constructor signature must be implemented:
|
||||
*
|
||||
* **
|
||||
* * Constructs new Domain Object
|
||||
* * @param dbh a handle to an open domain object database.
|
||||
* * @param openMode one of:
|
||||
* * READ_ONLY: the original database will not be modified
|
||||
* * UPDATE: the database can be written to.
|
||||
* * UPGRADE: the database is upgraded to the latest schema as it is opened.
|
||||
* * @param monitor TaskMonitor that allows the open to be cancelled.
|
||||
* * @param consumer the object that keeping the program open.
|
||||
* *
|
||||
* * @throws IOException if an error accessing the database occurs.
|
||||
* * @throws VersionException if database version does not match implementation. UPGRADE may be possible.
|
||||
* **
|
||||
* public DomainObjectAdapterDB(DBHandle dbh, int openMode, TaskMonitor monitor, Object consumer) throws IOException, VersionException
|
||||
*
|
||||
* 2. The following static field must be provided:
|
||||
*
|
||||
* public static final String CONTENT_TYPE
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
public abstract class DomainObjectAdapterDB extends DomainObjectAdapter
|
||||
implements ErrorHandler, DBConstants {
|
||||
public abstract class DomainObjectAdapterDB extends DomainObjectAdapter implements ErrorHandler {
|
||||
|
||||
protected static final int NUM_UNDOS = 50;
|
||||
|
||||
|
@ -297,6 +270,15 @@ public abstract class DomainObjectAdapterDB extends DomainObjectAdapter
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set instance as immutable by disabling use of transactions. Attempts to start a transaction
|
||||
* will result in a {@link TerminatedTransactionException}. This method should invoked at the end of
|
||||
* instance instatiation {@link OpenMode#IMMUTABLE} was used.
|
||||
*/
|
||||
protected void setImmutable() {
|
||||
transactionMgr.setImmutable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to obtain a modification lock on the domain object when generating a
|
||||
* background snapshot.
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.framework.data;
|
||||
|
||||
import ghidra.framework.model.DomainObject;
|
||||
|
||||
/**
|
||||
* {@link OpenMode} provides an instantiation mode for {@link DomainObject}
|
||||
* implementations and internal storage adapters. Implementation code
|
||||
* may impose restrictions on which modes are supported.
|
||||
*/
|
||||
public enum OpenMode {
|
||||
/**
|
||||
* Creating new domain object.
|
||||
* This mode is generally not supported by {@link DomainObject} object constructors since
|
||||
* object creation would generally have a dedicated constructor.
|
||||
*/
|
||||
CREATE,
|
||||
/**
|
||||
* Domain object opened as an immutable instance
|
||||
*/
|
||||
IMMUTABLE,
|
||||
/**
|
||||
* Domain object opened for modification
|
||||
*/
|
||||
UPDATE,
|
||||
/**
|
||||
* Domain object opened for modification with data upgrade permitted.
|
||||
*/
|
||||
UPGRADE,
|
||||
}
|
|
@ -19,13 +19,11 @@ import java.io.IOException;
|
|||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import db.buffers.BufferFile;
|
||||
import db.buffers.ManagedBufferFile;
|
||||
import generic.theme.GIcon;
|
||||
import ghidra.framework.data.DBContentHandler;
|
||||
import ghidra.framework.data.DomainObjectMergeManager;
|
||||
import ghidra.framework.data.*;
|
||||
import ghidra.framework.model.ChangeSet;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.framework.store.*;
|
||||
|
@ -81,8 +79,7 @@ public class DataTypeArchiveContentHandler extends DBContentHandler<DataTypeArch
|
|||
try {
|
||||
bf = dbItem.open(version, minChangeVersion);
|
||||
dbh = new DBHandle(bf);
|
||||
int openMode = DBConstants.READ_ONLY;
|
||||
dataTypeArchive = new DataTypeArchiveDB(dbh, openMode, monitor, consumer);
|
||||
dataTypeArchive = new DataTypeArchiveDB(dbh, OpenMode.IMMUTABLE, monitor, consumer);
|
||||
getDataTypeArchiveChangeSet(dataTypeArchive, bf);
|
||||
success = true;
|
||||
return dataTypeArchive;
|
||||
|
@ -136,7 +133,7 @@ public class DataTypeArchiveContentHandler extends DBContentHandler<DataTypeArch
|
|||
try {
|
||||
bf = dbItem.open(version);
|
||||
dbh = new DBHandle(bf);
|
||||
int openMode = okToUpgrade ? DBConstants.UPGRADE : DBConstants.UPDATE;
|
||||
OpenMode openMode = okToUpgrade ? OpenMode.UPGRADE : OpenMode.UPDATE;
|
||||
dataTypeArchive = new DataTypeArchiveDB(dbh, openMode, monitor, consumer);
|
||||
getDataTypeArchiveChangeSet(dataTypeArchive, bf);
|
||||
success = true;
|
||||
|
@ -191,7 +188,7 @@ public class DataTypeArchiveContentHandler extends DBContentHandler<DataTypeArch
|
|||
try {
|
||||
bf = dbItem.openForUpdate(checkoutId);
|
||||
dbh = new DBHandle(bf, recover, monitor);
|
||||
int openMode = okToUpgrade ? DBConstants.UPGRADE : DBConstants.UPDATE;
|
||||
OpenMode openMode = okToUpgrade ? OpenMode.UPGRADE : OpenMode.UPDATE;
|
||||
dataTypeArchive = new DataTypeArchiveDB(dbh, openMode, monitor, consumer);
|
||||
if (checkoutId == FolderItem.DEFAULT_CHECKOUT_ID) {
|
||||
getDataTypeArchiveChangeSet(dataTypeArchive, bf);
|
||||
|
@ -298,8 +295,7 @@ public class DataTypeArchiveContentHandler extends DBContentHandler<DataTypeArch
|
|||
try {
|
||||
bf = dbItem.open(toVer, fromVer);
|
||||
dbh = new DBHandle(bf);
|
||||
int openMode = DBConstants.READ_ONLY;
|
||||
dataTypeArchive = new DataTypeArchiveDB(dbh, openMode, null, this);
|
||||
dataTypeArchive = new DataTypeArchiveDB(dbh, OpenMode.IMMUTABLE, null, this);
|
||||
return getDataTypeArchiveChangeSet(dataTypeArchive, bf);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.*;
|
|||
import db.*;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.data.DomainObjectAdapterDB;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.data.*;
|
||||
|
@ -113,11 +114,11 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
int id = startTransaction("create data type archive");
|
||||
|
||||
createDatabase();
|
||||
if (createManagers(CREATE, TaskMonitor.DUMMY) != null) {
|
||||
if (createManagers(OpenMode.CREATE, TaskMonitor.DUMMY) != null) {
|
||||
throw new AssertException("Unexpected version exception on create");
|
||||
}
|
||||
changeSet = new DataTypeArchiveDBChangeSet(NUM_UNDOS);
|
||||
initManagers(CREATE, TaskMonitor.DUMMY);
|
||||
initManagers(OpenMode.CREATE, TaskMonitor.DUMMY);
|
||||
propertiesCreate();
|
||||
endTransaction(id, true);
|
||||
clearUndo(false);
|
||||
|
@ -154,7 +155,7 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
* @throws VersionException if database version does not match implementation, UPGRADE may be possible.
|
||||
* @throws CancelledException if instantiation is canceled by monitor
|
||||
*/
|
||||
public DataTypeArchiveDB(DBHandle dbh, int openMode, TaskMonitor monitor, Object consumer)
|
||||
public DataTypeArchiveDB(DBHandle dbh, OpenMode openMode, TaskMonitor monitor, Object consumer)
|
||||
throws IOException, VersionException, CancelledException {
|
||||
|
||||
super(dbh, "Untitled", 500, consumer);
|
||||
|
@ -165,7 +166,7 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
try {
|
||||
int id = startTransaction("create data type archive");
|
||||
recordChanges = false;
|
||||
changeable = (openMode != READ_ONLY);
|
||||
changeable = (openMode != OpenMode.IMMUTABLE);
|
||||
|
||||
// check DB version and read name
|
||||
VersionException dbVersionExc = initializeDatabase(openMode);
|
||||
|
@ -182,7 +183,7 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
|
||||
initManagers(openMode, monitor);
|
||||
|
||||
if (openMode == UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
upgradeDatabase();
|
||||
changed = true;
|
||||
}
|
||||
|
@ -199,6 +200,10 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
}
|
||||
}
|
||||
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
setImmutable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -396,11 +401,12 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
* @throws VersionException if the data is newer than this version of Ghidra and can not be
|
||||
* upgraded or opened.
|
||||
*/
|
||||
private VersionException initializeDatabase(int openMode) throws IOException, VersionException {
|
||||
private VersionException initializeDatabase(OpenMode openMode)
|
||||
throws IOException, VersionException {
|
||||
|
||||
table = dbh.getTable(TABLE_NAME);
|
||||
if (table == null) {
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
createDatabase();
|
||||
}
|
||||
else {
|
||||
|
@ -412,10 +418,10 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
if (storedVersion > DB_VERSION) {
|
||||
throw new VersionException(VersionException.NEWER_VERSION, false);
|
||||
}
|
||||
if (openMode != DBConstants.UPGRADE && storedVersion < UPGRADE_REQUIRED_BEFORE_VERSION) {
|
||||
if (openMode != OpenMode.UPGRADE && storedVersion < UPGRADE_REQUIRED_BEFORE_VERSION) {
|
||||
return new VersionException(true);
|
||||
}
|
||||
if (openMode == DBConstants.UPDATE && storedVersion < DB_VERSION) {
|
||||
if (openMode == OpenMode.UPDATE && storedVersion < DB_VERSION) {
|
||||
return new VersionException(true);
|
||||
}
|
||||
return null;
|
||||
|
@ -446,7 +452,7 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
return 1;
|
||||
}
|
||||
|
||||
private void checkOldProperties(int openMode) {
|
||||
private void checkOldProperties(OpenMode openMode) {
|
||||
// Record record = table.getRecord(new StringField(EXECUTE_PATH));
|
||||
// if (record != null) {
|
||||
// if (openMode == READ_ONLY) {
|
||||
|
@ -468,7 +474,7 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
// int storedVersion = getStoredVersion();
|
||||
}
|
||||
|
||||
private VersionException createManagers(int openMode, TaskMonitor monitor)
|
||||
private VersionException createManagers(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException {
|
||||
|
||||
VersionException versionExc = null;
|
||||
|
@ -491,7 +497,7 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
|||
return versionExc;
|
||||
}
|
||||
|
||||
private void initManagers(int openMode, TaskMonitor monitor)
|
||||
private void initManagers(OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
monitor.checkCancelled();
|
||||
dataTypeManager.archiveReady(openMode, monitor);
|
||||
|
|
|
@ -17,6 +17,7 @@ package ghidra.program.database;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -43,7 +44,7 @@ public interface ManagerDB {
|
|||
* @throws IOException if a database io error occurs.
|
||||
* @throws CancelledException if the user cancelled the operation via the task monitor.
|
||||
*/
|
||||
void programReady(int openMode, int currentRevision, TaskMonitor monitor)
|
||||
void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor)
|
||||
throws IOException, CancelledException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.program.util.LanguageTranslator;
|
||||
|
@ -42,16 +43,16 @@ abstract class OverlaySpaceDBAdapter {
|
|||
this.db = dbHandle;
|
||||
}
|
||||
|
||||
static OverlaySpaceDBAdapter getOverlaySpaceAdapter(DBHandle dbHandle, int openMode,
|
||||
static OverlaySpaceDBAdapter getOverlaySpaceAdapter(DBHandle dbHandle, OpenMode openMode,
|
||||
TaskMonitor monitor) throws IOException, VersionException, CancelledException {
|
||||
try {
|
||||
return new OverlaySpaceDBAdapterV1(dbHandle, openMode);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
return upgrade(dbHandle, findReadOnlyAdapter(dbHandle), monitor);
|
||||
}
|
||||
if (e.isUpgradable() && openMode == DBConstants.READ_ONLY) {
|
||||
if (e.isUpgradable() && openMode == OpenMode.IMMUTABLE) {
|
||||
return findReadOnlyAdapter(dbHandle);
|
||||
}
|
||||
throw e;
|
||||
|
@ -82,13 +83,13 @@ abstract class OverlaySpaceDBAdapter {
|
|||
|
||||
try {
|
||||
OverlaySpaceDBAdapter tmpAdapter =
|
||||
new OverlaySpaceDBAdapterV1(tmpHandle, DBConstants.CREATE);
|
||||
new OverlaySpaceDBAdapterV1(tmpHandle, OpenMode.CREATE);
|
||||
copyRecords(oldAdapter, tmpAdapter, monitor);
|
||||
|
||||
dbHandle.deleteTable(TABLE_NAME);
|
||||
|
||||
OverlaySpaceDBAdapter newAdapter =
|
||||
new OverlaySpaceDBAdapterV1(dbHandle, DBConstants.CREATE);
|
||||
new OverlaySpaceDBAdapterV1(dbHandle, OpenMode.CREATE);
|
||||
copyRecords(tmpAdapter, newAdapter, monitor);
|
||||
|
||||
tmpHandle.deleteTable(TABLE_NAME);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.util.EmptyRecordIterator;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.lang.Language;
|
||||
|
@ -38,11 +39,12 @@ class OverlaySpaceDBAdapterV1 extends OverlaySpaceDBAdapter {
|
|||
static final int OV_SPACE_NAME_COL_V1 = 0;
|
||||
static final int OV_SPACE_BASE_COL_V1 = 1;
|
||||
|
||||
OverlaySpaceDBAdapterV1(DBHandle dbHandle, int openMode) throws IOException, VersionException {
|
||||
OverlaySpaceDBAdapterV1(DBHandle dbHandle, OpenMode openMode)
|
||||
throws IOException, VersionException {
|
||||
super(dbHandle);
|
||||
|
||||
Table table = dbHandle.getTable(TABLE_NAME);
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
if (table != null) {
|
||||
throw new IOException("Table already exists: " + TABLE_NAME);
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ import java.io.IOException;
|
|||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Field;
|
||||
import db.buffers.BufferFile;
|
||||
import db.buffers.ManagedBufferFile;
|
||||
import generic.theme.GIcon;
|
||||
import ghidra.framework.data.DBWithUserDataContentHandler;
|
||||
import ghidra.framework.data.DomainObjectMergeManager;
|
||||
import ghidra.framework.data.*;
|
||||
import ghidra.framework.model.ChangeSet;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.framework.store.*;
|
||||
|
@ -58,8 +58,7 @@ public class ProgramContentHandler extends DBWithUserDataContentHandler<ProgramD
|
|||
if (!(obj instanceof ProgramDB)) {
|
||||
throw new IOException("Unsupported domain object: " + obj.getClass().getName());
|
||||
}
|
||||
return createFile((ProgramDB) obj, PROGRAM_CONTENT_TYPE, fs, path, name,
|
||||
monitor);
|
||||
return createFile((ProgramDB) obj, PROGRAM_CONTENT_TYPE, fs, path, name, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,8 +77,7 @@ public class ProgramContentHandler extends DBWithUserDataContentHandler<ProgramD
|
|||
try {
|
||||
bf = dbItem.open(version, minChangeVersion);
|
||||
dbh = new DBHandle(bf);
|
||||
int openMode = DBConstants.READ_ONLY;
|
||||
program = new ProgramDB(dbh, openMode, monitor, consumer);
|
||||
program = new ProgramDB(dbh, OpenMode.IMMUTABLE, monitor, consumer);
|
||||
getProgramChangeSet(program, bf);
|
||||
success = true;
|
||||
return program;
|
||||
|
@ -130,7 +128,7 @@ public class ProgramContentHandler extends DBWithUserDataContentHandler<ProgramD
|
|||
try {
|
||||
bf = dbItem.open(version);
|
||||
dbh = new DBHandle(bf);
|
||||
int openMode = okToUpgrade ? DBConstants.UPGRADE : DBConstants.UPDATE;
|
||||
OpenMode openMode = okToUpgrade ? OpenMode.UPGRADE : OpenMode.UPDATE;
|
||||
program = new ProgramDB(dbh, openMode, monitor, consumer);
|
||||
getProgramChangeSet(program, bf);
|
||||
program.setProgramUserData(new ProgramUserDataDB(program));
|
||||
|
@ -183,7 +181,7 @@ public class ProgramContentHandler extends DBWithUserDataContentHandler<ProgramD
|
|||
try {
|
||||
bf = dbItem.openForUpdate(checkoutId);
|
||||
dbh = new DBHandle(bf, recover, monitor);
|
||||
int openMode = okToUpgrade ? DBConstants.UPGRADE : DBConstants.UPDATE;
|
||||
OpenMode openMode = okToUpgrade ? OpenMode.UPGRADE : OpenMode.UPDATE;
|
||||
program = new ProgramDB(dbh, openMode, monitor, consumer);
|
||||
if (checkoutId == FolderItem.DEFAULT_CHECKOUT_ID) {
|
||||
getProgramChangeSet(program, bf);
|
||||
|
@ -293,8 +291,7 @@ public class ProgramContentHandler extends DBWithUserDataContentHandler<ProgramD
|
|||
try {
|
||||
bf = dbItem.open(toVer, fromVer);
|
||||
dbh = new DBHandle(bf);
|
||||
int openMode = DBConstants.READ_ONLY;
|
||||
program = new ProgramDB(dbh, openMode, null, this);
|
||||
program = new ProgramDB(dbh, OpenMode.IMMUTABLE, null, this);
|
||||
return getProgramChangeSet(program, bf);
|
||||
}
|
||||
catch (VersionException | IOException e) {
|
||||
|
|
|
@ -21,11 +21,11 @@ import java.util.*;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import ghidra.app.plugin.processors.sleigh.SleighLanguage;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.data.DomainObjectAdapterDB;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.framework.store.FileSystem;
|
||||
|
@ -256,12 +256,12 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
int id = startTransaction("create program");
|
||||
|
||||
createProgramInfo();
|
||||
if (createManagers(CREATE, TaskMonitor.DUMMY) != null) {
|
||||
if (createManagers(OpenMode.CREATE, TaskMonitor.DUMMY) != null) {
|
||||
throw new AssertException("Unexpected version exception on create");
|
||||
}
|
||||
listing = new ListingDB();
|
||||
changeSet = new ProgramDBChangeSet(addrMap, NUM_UNDOS);
|
||||
initManagers(CREATE, TaskMonitor.DUMMY);
|
||||
initManagers(OpenMode.CREATE, TaskMonitor.DUMMY);
|
||||
createProgramInformationOptions();
|
||||
programUserData = new ProgramUserDataDB(this);
|
||||
endTransaction(id, true);
|
||||
|
@ -299,7 +299,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
* @throws CancelledException if instantiation is canceled by monitor
|
||||
* @throws LanguageNotFoundException if a language cannot be found for this program
|
||||
*/
|
||||
public ProgramDB(DBHandle dbh, int openMode, TaskMonitor monitor, Object consumer)
|
||||
public ProgramDB(DBHandle dbh, OpenMode openMode, TaskMonitor monitor, Object consumer)
|
||||
throws IOException, VersionException, LanguageNotFoundException, CancelledException {
|
||||
|
||||
super(dbh, "Untitled", 500, consumer);
|
||||
|
@ -308,11 +308,15 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
monitor = TaskMonitor.DUMMY;
|
||||
}
|
||||
|
||||
if (openMode == null || openMode == OpenMode.CREATE) {
|
||||
throw new IllegalArgumentException("invalid openMode: " + openMode);
|
||||
}
|
||||
|
||||
boolean success = false;
|
||||
try {
|
||||
int id = startTransaction("create program");
|
||||
recordChanges = false;
|
||||
changeable = (openMode != READ_ONLY);
|
||||
changeable = (openMode != OpenMode.IMMUTABLE);
|
||||
|
||||
// check DB version and read name, languageName, languageVersion and languageMinorVersion
|
||||
VersionException dbVersionExc = initializeProgramInfo(openMode);
|
||||
|
@ -348,7 +352,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
if (dbVersionExc != null) {
|
||||
versionExc = dbVersionExc.combine(versionExc);
|
||||
}
|
||||
if (languageVersionExc != null && openMode != UPGRADE) {
|
||||
if (languageVersionExc != null && openMode != OpenMode.UPGRADE) {
|
||||
// Language upgrade required
|
||||
versionExc = languageVersionExc.combine(versionExc);
|
||||
}
|
||||
|
@ -362,7 +366,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
|
||||
initManagers(openMode, monitor);
|
||||
|
||||
if (openMode == UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
int oldVersion = getStoredVersion();
|
||||
upgradeDatabase(monitor);
|
||||
if (languageUpgradeRequired) {
|
||||
|
@ -404,6 +408,10 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
}
|
||||
}
|
||||
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
setImmutable();
|
||||
}
|
||||
|
||||
// for tracking during testing
|
||||
ProgramUtilities.addTrackedProgram(this);
|
||||
}
|
||||
|
@ -1413,7 +1421,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
* @throws VersionException if the data is newer than this version of Ghidra and can not be
|
||||
* upgraded or opened.
|
||||
*/
|
||||
private VersionException initializeProgramInfo(int openMode)
|
||||
private VersionException initializeProgramInfo(OpenMode openMode)
|
||||
throws IOException, VersionException, LanguageNotFoundException {
|
||||
boolean requiresUpgrade = false;
|
||||
|
||||
|
@ -1430,7 +1438,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
}
|
||||
languageID = languageCompilerSpecPair.languageID;
|
||||
compilerSpecID = languageCompilerSpecPair.compilerSpecID;
|
||||
if (openMode != DBConstants.UPGRADE) {
|
||||
if (openMode != OpenMode.UPGRADE) {
|
||||
requiresUpgrade = true;
|
||||
}
|
||||
else {
|
||||
|
@ -1462,10 +1470,10 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
if (storedVersion > DB_VERSION) {
|
||||
throw new VersionException(VersionException.NEWER_VERSION, false);
|
||||
}
|
||||
if (openMode != DBConstants.UPGRADE && storedVersion < UPGRADE_REQUIRED_BEFORE_VERSION) {
|
||||
if (openMode != OpenMode.UPGRADE && storedVersion < UPGRADE_REQUIRED_BEFORE_VERSION) {
|
||||
requiresUpgrade = true;
|
||||
}
|
||||
if (openMode == DBConstants.UPDATE && storedVersion < DB_VERSION) {
|
||||
if (openMode == OpenMode.UPDATE && storedVersion < DB_VERSION) {
|
||||
requiresUpgrade = true;
|
||||
}
|
||||
return requiresUpgrade ? new VersionException(true) : null;
|
||||
|
@ -1518,14 +1526,14 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
return 1;
|
||||
}
|
||||
|
||||
private void checkOldProperties(int openMode, TaskMonitor monitor)
|
||||
private void checkOldProperties(OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, VersionException {
|
||||
String exePath = dataMap.get(EXECUTE_PATH);
|
||||
if (exePath != null) {
|
||||
if (openMode == READ_ONLY) {
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
return; // not important, get on path or format will return "unknown"
|
||||
}
|
||||
if (openMode != UPGRADE) {
|
||||
if (openMode != OpenMode.UPGRADE) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
|
||||
|
@ -1543,10 +1551,10 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
}
|
||||
int storedVersion = getStoredVersion();
|
||||
if (storedVersion < ANALYSIS_OPTIONS_MOVED_VERSION) {
|
||||
if (openMode == READ_ONLY) {
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
return;
|
||||
}
|
||||
if (openMode != UPGRADE) {
|
||||
if (openMode != OpenMode.UPGRADE) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
Options oldList = getOptions("Analysis");
|
||||
|
@ -1555,10 +1563,10 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
}
|
||||
}
|
||||
if (storedVersion < METADATA_ADDED_VERSION) {
|
||||
if (openMode == READ_ONLY) {
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
return;
|
||||
}
|
||||
if (openMode != UPGRADE) {
|
||||
if (openMode != OpenMode.UPGRADE) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
}
|
||||
|
@ -1590,7 +1598,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
}
|
||||
}
|
||||
|
||||
private VersionException createManagers(int openMode, TaskMonitor monitor)
|
||||
private VersionException createManagers(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException {
|
||||
|
||||
VersionException versionExc = null;
|
||||
|
@ -1602,7 +1610,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
versionExc = e.combine(versionExc);
|
||||
try {
|
||||
overlaySpaceAdapter =
|
||||
OverlaySpaceDBAdapter.getOverlaySpaceAdapter(dbh, READ_ONLY, monitor);
|
||||
OverlaySpaceDBAdapter.getOverlaySpaceAdapter(dbh, OpenMode.IMMUTABLE, monitor);
|
||||
}
|
||||
catch (VersionException e1) {
|
||||
if (e1.isUpgradable()) {
|
||||
|
@ -1633,8 +1641,8 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
catch (VersionException e) {
|
||||
versionExc = e.combine(versionExc);
|
||||
try {
|
||||
addrMap =
|
||||
new AddressMapDB(dbh, READ_ONLY, addressFactory, baseImageOffset, monitor);
|
||||
addrMap = new AddressMapDB(dbh, OpenMode.IMMUTABLE, addressFactory, baseImageOffset,
|
||||
monitor);
|
||||
}
|
||||
catch (VersionException e1) {
|
||||
if (e1.isUpgradable()) {
|
||||
|
@ -1673,7 +1681,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
// Attempt to instantiate the old function manager which may be used for upgrades
|
||||
try {
|
||||
oldFunctionMgr = new OldFunctionManager(dbh, this, addrMap);
|
||||
if (openMode != UPGRADE) {
|
||||
if (openMode != OpenMode.UPGRADE) {
|
||||
// Indicate that program is upgradable
|
||||
oldFunctionMgr = null;
|
||||
versionExc = (new VersionException(true)).combine(versionExc);
|
||||
|
@ -1681,7 +1689,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
else {
|
||||
// Prepare for upgrade of function manager
|
||||
managers[FUNCTION_MGR] =
|
||||
new FunctionManagerDB(dbh, addrMap, CREATE, lock, monitor);
|
||||
new FunctionManagerDB(dbh, addrMap, OpenMode.CREATE, lock, monitor);
|
||||
}
|
||||
}
|
||||
catch (VersionException e1) {
|
||||
|
@ -1790,7 +1798,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
return versionExc;
|
||||
}
|
||||
|
||||
private void initManagers(int openMode, TaskMonitor monitor)
|
||||
private void initManagers(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException {
|
||||
globalNamespace = new GlobalNamespace(getMemory());
|
||||
for (int i = 0; i < NUM_MANAGERS; i++) {
|
||||
|
@ -1799,13 +1807,13 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
}
|
||||
listing.setProgram(this);
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
getDataTypeManager().saveDataOrganization();
|
||||
}
|
||||
|
||||
monitor.checkCancelled();
|
||||
|
||||
if (openMode == UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
if (oldFunctionMgr != null) {
|
||||
// Upgrade Function Manager
|
||||
oldFunctionMgr.upgrade(this, monitor);
|
||||
|
@ -2106,7 +2114,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
|
||||
// Force function manager to reconcile calling conventions
|
||||
managers[FUNCTION_MGR].setProgram(this);
|
||||
managers[FUNCTION_MGR].programReady(UPDATE, getStoredVersion(), monitor);
|
||||
managers[FUNCTION_MGR].programReady(OpenMode.UPDATE, getStoredVersion(), monitor);
|
||||
|
||||
if (translator != null) {
|
||||
// allow complex language upgrades to transform instructions/context
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.*;
|
|||
|
||||
import db.*;
|
||||
import ghidra.framework.data.DomainObjectAdapterDB;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.store.FileSystem;
|
||||
import ghidra.program.database.map.AddressMapDB;
|
||||
import ghidra.program.database.properties.*;
|
||||
|
@ -134,7 +135,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
int id = startTransaction("create user data");
|
||||
|
||||
createDatabase();
|
||||
if (createManagers(CREATE, program, TaskMonitor.DUMMY) != null) {
|
||||
if (createManagers(OpenMode.CREATE, program, TaskMonitor.DUMMY) != null) {
|
||||
throw new AssertException("Unexpected version exception on create");
|
||||
}
|
||||
//initManagers(CREATE, TaskMonitorAdapter.DUMMY_MONITOR);
|
||||
|
@ -185,7 +186,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
|
||||
addressFactory = program.getAddressFactory();
|
||||
|
||||
VersionException versionExc = createManagers(UPGRADE, program, monitor);
|
||||
VersionException versionExc = createManagers(OpenMode.UPGRADE, program, monitor);
|
||||
if (dbVersionExc != null) {
|
||||
versionExc = dbVersionExc.combine(versionExc);
|
||||
}
|
||||
|
@ -373,8 +374,8 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
table.putRecord(record);
|
||||
}
|
||||
|
||||
private VersionException createManagers(int openMode, ProgramDB program1, TaskMonitor monitor)
|
||||
throws CancelledException, IOException {
|
||||
private VersionException createManagers(OpenMode openMode, ProgramDB program1,
|
||||
TaskMonitor monitor) throws CancelledException, IOException {
|
||||
|
||||
VersionException versionExc = null;
|
||||
|
||||
|
@ -389,8 +390,8 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
catch (VersionException e) {
|
||||
versionExc = e.combine(versionExc);
|
||||
try {
|
||||
addressMap =
|
||||
new AddressMapDB(dbh, READ_ONLY, addressFactory, baseImageOffset, monitor);
|
||||
addressMap = new AddressMapDB(dbh, OpenMode.IMMUTABLE, addressFactory,
|
||||
baseImageOffset, monitor);
|
||||
}
|
||||
catch (VersionException e1) {
|
||||
if (e1.isUpgradable()) {
|
||||
|
@ -522,26 +523,26 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
int type = rec.getIntValue(PROPERTY_TYPE_COL);
|
||||
switch (type) {
|
||||
case PROPERTY_TYPE_STRING:
|
||||
map = new StringPropertyMapDB(dbh, DBConstants.UPGRADE, this, changeMgr,
|
||||
map = new StringPropertyMapDB(dbh, OpenMode.UPGRADE, this, changeMgr,
|
||||
addressMap, rec.getString(PROPERTY_NAME_COL), TaskMonitor.DUMMY);
|
||||
break;
|
||||
case PROPERTY_TYPE_LONG:
|
||||
map = new LongPropertyMapDB(dbh, DBConstants.UPGRADE, this, changeMgr,
|
||||
addressMap, rec.getString(PROPERTY_NAME_COL), TaskMonitor.DUMMY);
|
||||
map = new LongPropertyMapDB(dbh, OpenMode.UPGRADE, this, changeMgr, addressMap,
|
||||
rec.getString(PROPERTY_NAME_COL), TaskMonitor.DUMMY);
|
||||
break;
|
||||
case PROPERTY_TYPE_INT:
|
||||
map = new IntPropertyMapDB(dbh, DBConstants.UPGRADE, this, changeMgr,
|
||||
addressMap, rec.getString(PROPERTY_NAME_COL), TaskMonitor.DUMMY);
|
||||
map = new IntPropertyMapDB(dbh, OpenMode.UPGRADE, this, changeMgr, addressMap,
|
||||
rec.getString(PROPERTY_NAME_COL), TaskMonitor.DUMMY);
|
||||
break;
|
||||
case PROPERTY_TYPE_BOOLEAN:
|
||||
map = new VoidPropertyMapDB(dbh, DBConstants.UPGRADE, this, changeMgr,
|
||||
addressMap, rec.getString(PROPERTY_NAME_COL), TaskMonitor.DUMMY);
|
||||
map = new VoidPropertyMapDB(dbh, OpenMode.UPGRADE, this, changeMgr, addressMap,
|
||||
rec.getString(PROPERTY_NAME_COL), TaskMonitor.DUMMY);
|
||||
break;
|
||||
case PROPERTY_TYPE_SAVEABLE:
|
||||
String className = rec.getString(PROPERTY_CLASS_COL);
|
||||
Class<? extends Saveable> c =
|
||||
ObjectPropertyMapDB.getSaveableClassForName(className);
|
||||
return new ObjectPropertyMapDB<>(dbh, DBConstants.UPGRADE, this, changeMgr,
|
||||
return new ObjectPropertyMapDB<>(dbh, OpenMode.UPGRADE, this, changeMgr,
|
||||
addressMap, rec.getString(PROPERTY_NAME_COL), c, TaskMonitor.DUMMY, true);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported property type: " + type);
|
||||
|
|
|
@ -16,13 +16,15 @@
|
|||
package ghidra.program.database;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.help.UnsupportedOperationException;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Transaction;
|
||||
import db.util.ErrorHandler;
|
||||
import generic.stl.Pair;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.framework.store.LockException;
|
||||
import ghidra.program.model.data.*;
|
||||
|
@ -65,7 +67,7 @@ public class ProjectDataTypeManager extends StandAloneDataTypeManager
|
|||
* @throws VersionException if the database does not match the expected version.
|
||||
* @throws IOException if a database I/O error occurs.
|
||||
*/
|
||||
ProjectDataTypeManager(DataTypeArchiveDB dataTypeArchive, DBHandle handle, int openMode,
|
||||
ProjectDataTypeManager(DataTypeArchiveDB dataTypeArchive, DBHandle handle, OpenMode openMode,
|
||||
ErrorHandler errHandler, Lock lock, TaskMonitor monitor)
|
||||
throws CancelledException, VersionException, IOException {
|
||||
super(handle, openMode, errHandler, lock, monitor);
|
||||
|
@ -238,9 +240,9 @@ public class ProjectDataTypeManager extends StandAloneDataTypeManager
|
|||
return ArchiveType.PROJECT;
|
||||
}
|
||||
|
||||
public void archiveReady(int openMode, TaskMonitor monitor)
|
||||
public void archiveReady(OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
doSourceArchiveUpdates(monitor);
|
||||
migrateOldFlexArrayComponentsIfRequired(monitor);
|
||||
}
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
*/
|
||||
package ghidra.program.database.bookmark;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
abstract class BookmarkDBAdapter {
|
||||
static final Schema SCHEMA = BookmarkDBAdapterV3.V3_SCHEMA;
|
||||
|
||||
|
@ -34,10 +34,10 @@ abstract class BookmarkDBAdapter {
|
|||
|
||||
static final String BOOKMARK_TABLE_NAME = "Bookmarks";
|
||||
|
||||
static BookmarkDBAdapter getAdapter(DBHandle dbHandle, int openMode, int[] typeIds,
|
||||
static BookmarkDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, int[] typeIds,
|
||||
AddressMap addrMap, TaskMonitor monitor) throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new BookmarkDBAdapterV3(dbHandle, true, typeIds, addrMap);
|
||||
}
|
||||
|
||||
|
@ -49,11 +49,11 @@ abstract class BookmarkDBAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
BookmarkDBAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap, typeIds);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, adapter, typeIds, addrMap, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
@ -87,8 +87,8 @@ abstract class BookmarkDBAdapter {
|
|||
}
|
||||
|
||||
private static BookmarkDBAdapter upgrade(DBHandle dbHandle, BookmarkDBAdapter oldAdapter,
|
||||
int[] typeIds, AddressMap addrMap, TaskMonitor monitor) throws VersionException,
|
||||
IOException {
|
||||
int[] typeIds, AddressMap addrMap, TaskMonitor monitor)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (oldAdapter instanceof BookmarkDBAdapterV0) {
|
||||
// Actually upgrade from Version 0 delayed until BookmarkDBManager.setProgram is invoked
|
||||
|
@ -110,8 +110,8 @@ abstract class BookmarkDBAdapter {
|
|||
BookmarkDBAdapter tmpAdapter = null;
|
||||
try {
|
||||
tmpAdapter = new BookmarkDBAdapterV3(tmpHandle, true, typeIds, addrMap);
|
||||
for (int i = 0; i < typeIds.length; i++) {
|
||||
RecordIterator it = oldAdapter.getRecordsByType(typeIds[i]);
|
||||
for (int typeId2 : typeIds) {
|
||||
RecordIterator it = oldAdapter.getRecordsByType(typeId2);
|
||||
while (it.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new IOException("Upgrade Cancelled");
|
||||
|
@ -126,13 +126,13 @@ abstract class BookmarkDBAdapter {
|
|||
}
|
||||
}
|
||||
dbHandle.deleteTable(BOOKMARK_TABLE_NAME);
|
||||
for (int i = 0; i < typeIds.length; i++) {
|
||||
dbHandle.deleteTable(BOOKMARK_TABLE_NAME + typeIds[i]);
|
||||
for (int typeId : typeIds) {
|
||||
dbHandle.deleteTable(BOOKMARK_TABLE_NAME + typeId);
|
||||
}
|
||||
BookmarkDBAdapter newAdapter =
|
||||
new BookmarkDBAdapterV3(dbHandle, true, typeIds, addrMap);
|
||||
for (int i = 0; i < typeIds.length; i++) {
|
||||
RecordIterator it = tmpAdapter.getRecordsByType(typeIds[i]);
|
||||
for (int typeId : typeIds) {
|
||||
RecordIterator it = tmpAdapter.getRecordsByType(typeId);
|
||||
while (it.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new IOException("Upgrade Cancelled");
|
||||
|
@ -220,8 +220,8 @@ abstract class BookmarkDBAdapter {
|
|||
abstract RecordIterator getRecordsByTypeStartingAtAddress(int typeID, long startAddress,
|
||||
boolean forward) throws IOException;
|
||||
|
||||
abstract RecordIterator getRecordsByTypeForAddressRange(int typeId, long startAddr, long endAddr)
|
||||
throws IOException;
|
||||
abstract RecordIterator getRecordsByTypeForAddressRange(int typeId, long startAddr,
|
||||
long endAddr) throws IOException;
|
||||
|
||||
/**
|
||||
* Get all bookmark records with a specific type ID and category.
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
*/
|
||||
package ghidra.program.database.bookmark;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
class BookmarkDBAdapterV0 extends BookmarkDBAdapter {
|
||||
|
||||
private DBHandle tmpHandle;
|
||||
|
@ -47,9 +47,8 @@ class BookmarkDBAdapterV0 extends BookmarkDBAdapter {
|
|||
// This is the easiest way to index into the old bookmarks
|
||||
tmpHandle = new DBHandle();
|
||||
try {
|
||||
conversionAdapter =
|
||||
BookmarkDBAdapter.getAdapter(tmpHandle, DBConstants.CREATE, new int[0], addrMap,
|
||||
monitor);
|
||||
conversionAdapter = BookmarkDBAdapter.getAdapter(tmpHandle, OpenMode.CREATE, new int[0],
|
||||
addrMap, monitor);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
throw new AssertException();
|
||||
|
@ -61,16 +60,16 @@ class BookmarkDBAdapterV0 extends BookmarkDBAdapter {
|
|||
|
||||
monitor.setMessage("Translating Old Bookmarks...");
|
||||
int max = 0;
|
||||
for (int i = 0; i < oldTypes.length; i++) {
|
||||
for (DBRecord oldType : oldTypes) {
|
||||
max +=
|
||||
oldMgr.getBookmarkCount(oldTypes[i].getString(BookmarkTypeDBAdapter.TYPE_NAME_COL));
|
||||
oldMgr.getBookmarkCount(oldType.getString(BookmarkTypeDBAdapter.TYPE_NAME_COL));
|
||||
}
|
||||
monitor.initialize(max);
|
||||
int cnt = 0;
|
||||
|
||||
for (int i = 0; i < oldTypes.length; i++) {
|
||||
String type = oldTypes[i].getString(BookmarkTypeDBAdapter.TYPE_NAME_COL);
|
||||
int typeId = (int) oldTypes[i].getKey();
|
||||
for (DBRecord oldType : oldTypes) {
|
||||
String type = oldType.getString(BookmarkTypeDBAdapter.TYPE_NAME_COL);
|
||||
int typeId = (int) oldType.getKey();
|
||||
conversionAdapter.addType(typeId);
|
||||
AddressIterator iter = oldMgr.getBookmarkAddresses(type);
|
||||
while (iter.hasNext()) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import generic.util.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.*;
|
||||
import ghidra.program.database.map.AddressIndexPrimaryKeyIterator;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -65,11 +66,11 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
|||
* schema
|
||||
* @throws IOException if there is a problem accessing the database.
|
||||
*/
|
||||
public BookmarkDBManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock,
|
||||
public BookmarkDBManager(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
this.addrMap = addrMap;
|
||||
this.lock = lock;
|
||||
upgrade = (openMode == DBConstants.UPGRADE);
|
||||
upgrade = (openMode == OpenMode.UPGRADE);
|
||||
bookmarkTypeAdapter = BookmarkTypeDBAdapter.getAdapter(handle, openMode);
|
||||
int[] types = bookmarkTypeAdapter.getTypeIds();
|
||||
bookmarkAdapter = BookmarkDBAdapter.getAdapter(handle, openMode, types, addrMap, monitor);
|
||||
|
@ -112,7 +113,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
|||
}
|
||||
|
||||
@Override
|
||||
public void programReady(int openMode, int currentRevision, TaskMonitor monitor)
|
||||
public void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
// Nothing to do
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.bookmark;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
abstract class BookmarkTypeDBAdapter {
|
||||
|
@ -29,9 +30,9 @@ abstract class BookmarkTypeDBAdapter {
|
|||
static final Schema SCHEMA =
|
||||
new Schema(0, "ID", new Field[] { StringField.INSTANCE }, new String[] { "Name" });
|
||||
|
||||
static BookmarkTypeDBAdapter getAdapter(DBHandle dbHandle, int openMode)
|
||||
static BookmarkTypeDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode)
|
||||
throws VersionException, IOException {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new BookmarkTypeDBAdapterV0(dbHandle, true);
|
||||
}
|
||||
|
||||
|
@ -39,11 +40,11 @@ abstract class BookmarkTypeDBAdapter {
|
|||
return new BookmarkTypeDBAdapterV0(dbHandle, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (openMode == DBConstants.UPDATE) {
|
||||
if (openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
BookmarkTypeDBAdapter adapter = findReadOnlyAdapter(dbHandle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, adapter);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.*;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.*;
|
||||
import ghidra.program.database.data.PointerTypedefInspector;
|
||||
import ghidra.program.database.data.ProgramDataTypeManager;
|
||||
|
@ -86,7 +87,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
* @throws IOException if a database io error occurs
|
||||
* @throws CancelledException if the user cancels the upgrade operation
|
||||
*/
|
||||
public CodeManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock,
|
||||
public CodeManager(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
|
||||
dbHandle = handle;
|
||||
|
@ -115,10 +116,10 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
* @throws IOException if a database io error occurs
|
||||
* @throws CancelledException if the user cancels the upgrade operation
|
||||
*/
|
||||
private void checkOldFallThroughMaps(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
private void checkOldFallThroughMaps(DBHandle handle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode != DBConstants.UPDATE) {
|
||||
if (openMode != OpenMode.UPDATE) {
|
||||
return;
|
||||
}
|
||||
LongPropertyMapDB oldFallThroughs =
|
||||
|
@ -139,10 +140,10 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
|
||||
ReferenceManager refMgr = program.getReferenceManager();
|
||||
|
||||
LongPropertyMapDB oldFallFroms = new LongPropertyMapDB(dbHandle, DBConstants.UPGRADE,
|
||||
this, null, addrMap, "FallFroms", monitor);
|
||||
LongPropertyMapDB oldFallFroms = new LongPropertyMapDB(dbHandle, OpenMode.UPGRADE, this,
|
||||
null, addrMap, "FallFroms", monitor);
|
||||
|
||||
LongPropertyMapDB oldFallThroughs = new LongPropertyMapDB(dbHandle, DBConstants.UPGRADE,
|
||||
LongPropertyMapDB oldFallThroughs = new LongPropertyMapDB(dbHandle, OpenMode.UPGRADE,
|
||||
this, null, addrMap, "FallThroughs", monitor);
|
||||
|
||||
int cnt = oldFallThroughs.getSize();
|
||||
|
@ -183,7 +184,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
}
|
||||
}
|
||||
|
||||
private void initializeAdapters(int openMode, TaskMonitor monitor)
|
||||
private void initializeAdapters(OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
VersionException versionExc = null;
|
||||
try {
|
||||
|
@ -232,9 +233,9 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void programReady(int openMode, int currentRevision, TaskMonitor monitor)
|
||||
public void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
upgradeOldFallThroughMaps(monitor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.code;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -44,10 +45,11 @@ abstract class CommentHistoryAdapter {
|
|||
static final int HISTORY_USER_COL = 5;
|
||||
static final int HISTORY_DATE_COL = 6;
|
||||
|
||||
static CommentHistoryAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
static CommentHistoryAdapter getAdapter(DBHandle dbHandle, OpenMode openMode,
|
||||
AddressMap addrMap, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new CommentHistoryAdapterV0(dbHandle, addrMap, true);
|
||||
}
|
||||
|
||||
|
@ -59,11 +61,11 @@ abstract class CommentHistoryAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
CommentHistoryAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, addrMap, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.code;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressKeyIterator;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -72,10 +73,10 @@ abstract class CommentsDBAdapter {
|
|||
// /** repeatable comment type */
|
||||
// static final int REPEATABLE_COMMENT = 4;
|
||||
|
||||
static CommentsDBAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
static CommentsDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new CommentsDBAdapterV1(dbHandle, addrMap, true);
|
||||
}
|
||||
|
||||
|
@ -87,11 +88,11 @@ abstract class CommentsDBAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
CommentsDBAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, addrMap, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.code;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressKeyIterator;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -38,10 +39,10 @@ abstract class DataDBAdapter {
|
|||
|
||||
static final int DATA_TYPE_ID_COL = 0;
|
||||
|
||||
static DataDBAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
static DataDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new DataDBAdapterV0(dbHandle, addrMap, true);
|
||||
}
|
||||
|
||||
|
@ -53,11 +54,11 @@ abstract class DataDBAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
DataDBAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, addrMap, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.code;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressKeyIterator;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -40,10 +41,10 @@ abstract class InstDBAdapter {
|
|||
static final int PROTO_ID_COL = 0;
|
||||
static final int FLAGS_COL = 1;
|
||||
|
||||
static InstDBAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
static InstDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new InstDBAdapterV1(dbHandle, addrMap, true);
|
||||
}
|
||||
|
||||
|
@ -55,11 +56,11 @@ abstract class InstDBAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
InstDBAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, addrMap, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import java.util.StringTokenizer;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.database.util.DatabaseVersionException;
|
||||
|
@ -92,19 +93,19 @@ class PrototypeManager {
|
|||
* @throws VersionException thrown if the database version doesn't match this adapter version
|
||||
* @throws IOException if a database io error occurs.
|
||||
*/
|
||||
PrototypeManager(DBHandle dbHandle, AddressMap addrMap, int openMode, TaskMonitor monitor)
|
||||
PrototypeManager(DBHandle dbHandle, AddressMap addrMap, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, IOException {
|
||||
|
||||
this.addrMap = addrMap;
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
createDBTables(dbHandle);
|
||||
contextTable = dbHandle.createTable(CONTEXT_TABLE_NAME, REGISTER_SCHEMA);
|
||||
}
|
||||
findAdapters(dbHandle, openMode);
|
||||
loadContextTable(dbHandle, openMode);
|
||||
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
upgradeTable(dbHandle, monitor);
|
||||
}
|
||||
// debug for enormous prototype problem
|
||||
|
@ -399,7 +400,7 @@ class PrototypeManager {
|
|||
|
||||
}
|
||||
|
||||
private void findAdapters(DBHandle handle, int openMode) throws VersionException {
|
||||
private void findAdapters(DBHandle handle, OpenMode openMode) throws VersionException {
|
||||
try {
|
||||
protoAdapter = new ProtoDBAdapterV1(handle);
|
||||
return;
|
||||
|
@ -410,18 +411,18 @@ class PrototypeManager {
|
|||
|
||||
protoAdapter = getOldAdapter(handle);
|
||||
|
||||
if (openMode == DBConstants.UPDATE) {
|
||||
if (openMode == OpenMode.UPDATE) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadContextTable(DBHandle dbHandle, int openMode)
|
||||
private void loadContextTable(DBHandle dbHandle, OpenMode openMode)
|
||||
throws VersionException, IOException {
|
||||
contextTable = dbHandle.getTable(CONTEXT_TABLE_NAME);
|
||||
if (contextTable == null) {
|
||||
contextTable = dbHandle.createTable(CONTEXT_TABLE_NAME, REGISTER_SCHEMA);
|
||||
}
|
||||
if ((openMode == DBConstants.UPDATE) &&
|
||||
if ((openMode == OpenMode.UPDATE) &&
|
||||
(contextTable.getSchema().getVersion() != CURRENT_CONTEXT_VERSION)) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -45,20 +46,20 @@ abstract class ArrayDBAdapter {
|
|||
* @throws IOException if there is a problem accessing the database.
|
||||
* @throws CancelledException task cancelled
|
||||
*/
|
||||
static ArrayDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
static ArrayDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new ArrayDBAdapterV1(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
return new ArrayDBAdapterV1(handle, tablePrefix, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
ArrayDBAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +40,9 @@ public abstract class BuiltinDBAdapter {
|
|||
* @throws VersionException if the database handle's version doesn't match the expected version.
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
static BuiltinDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix)
|
||||
static BuiltinDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix)
|
||||
throws VersionException, IOException {
|
||||
return new BuiltinDBAdapterV0(handle, tablePrefix, openMode == DBConstants.CREATE);
|
||||
return new BuiltinDBAdapterV0(handle, tablePrefix, openMode == OpenMode.CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,9 @@ import java.io.IOException;
|
|||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Schema;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -52,20 +54,21 @@ abstract class CallingConventionDBAdapter {
|
|||
* @throws IOException if there is a problem accessing the database.
|
||||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
static CallingConventionDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
static CallingConventionDBAdapter getAdapter(DBHandle handle, OpenMode openMode,
|
||||
String tablePrefix, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new CallingConventionDBAdapterV0(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
return new CallingConventionDBAdapterV0(handle, tablePrefix, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
CallingConventionDBAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.data.Category;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
|
@ -34,9 +35,9 @@ abstract class CategoryDBAdapter {
|
|||
* @throws VersionException if the database handle's version doesn't match the expected version.
|
||||
* @throws IOException if there is a problem accessing the database.
|
||||
*/
|
||||
static CategoryDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix)
|
||||
static CategoryDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix)
|
||||
throws VersionException, IOException {
|
||||
return new CategoryDBAdapterV0(handle, tablePrefix, openMode == DBConstants.CREATE);
|
||||
return new CategoryDBAdapterV0(handle, tablePrefix, openMode == OpenMode.CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
|
@ -47,9 +48,9 @@ abstract class ComponentDBAdapter {
|
|||
* @throws VersionException if the database handle's version doesn't match the expected version.
|
||||
* @throws IOException if there is a problem accessing the database.
|
||||
*/
|
||||
static ComponentDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix)
|
||||
static ComponentDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix)
|
||||
throws VersionException, IOException {
|
||||
return new ComponentDBAdapterV0(handle, tablePrefix, openMode == DBConstants.CREATE);
|
||||
return new ComponentDBAdapterV0(handle, tablePrefix, openMode == OpenMode.CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.util.DBRecordAdapter;
|
||||
import ghidra.program.model.data.CompositeInternal;
|
||||
import ghidra.util.UniversalID;
|
||||
|
@ -80,17 +81,17 @@ abstract class CompositeDBAdapter implements DBRecordAdapter {
|
|||
* @throws IOException if there is trouble accessing the database.
|
||||
* @throws CancelledException task cancelled
|
||||
*/
|
||||
static CompositeDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
static CompositeDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
try {
|
||||
return new CompositeDBAdapterV5V6(handle, openMode, tablePrefix);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
CompositeDBAdapter adapter = findReadOnlyAdapter(handle, tablePrefix);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
return upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
@ -108,7 +109,7 @@ abstract class CompositeDBAdapter implements DBRecordAdapter {
|
|||
private static CompositeDBAdapter findReadOnlyAdapter(DBHandle handle, String tablePrefix)
|
||||
throws VersionException, IOException {
|
||||
try {
|
||||
return new CompositeDBAdapterV5V6(handle, DBConstants.READ_ONLY, tablePrefix);
|
||||
return new CompositeDBAdapterV5V6(handle, OpenMode.IMMUTABLE, tablePrefix);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
// ignore
|
||||
|
@ -148,7 +149,7 @@ abstract class CompositeDBAdapter implements DBRecordAdapter {
|
|||
long id = tmpHandle.startTransaction();
|
||||
CompositeDBAdapter tmpAdapter = null;
|
||||
try {
|
||||
tmpAdapter = new CompositeDBAdapterV5V6(tmpHandle, DBConstants.CREATE, tablePrefix);
|
||||
tmpAdapter = new CompositeDBAdapterV5V6(tmpHandle, OpenMode.CREATE, tablePrefix);
|
||||
RecordIterator it = oldAdapter.getRecords();
|
||||
while (it.hasNext()) {
|
||||
monitor.checkCancelled();
|
||||
|
@ -157,7 +158,7 @@ abstract class CompositeDBAdapter implements DBRecordAdapter {
|
|||
}
|
||||
oldAdapter.deleteTable(handle);
|
||||
CompositeDBAdapter newAdapter =
|
||||
new CompositeDBAdapterV5V6(handle, DBConstants.CREATE, tablePrefix);
|
||||
new CompositeDBAdapterV5V6(handle, OpenMode.CREATE, tablePrefix);
|
||||
if (oldAdapter.getVersion() < FLEX_ARRAY_ELIMINATION_SCHEMA_VERSION) {
|
||||
newAdapter.flexArrayMigrationRequired = true;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Date;
|
|||
import javax.help.UnsupportedOperationException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.data.CompositeInternal;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
@ -74,10 +75,10 @@ class CompositeDBAdapterV5V6 extends CompositeDBAdapter {
|
|||
* for this adapter.
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
CompositeDBAdapterV5V6(DBHandle handle, int openMode, String tablePrefix)
|
||||
CompositeDBAdapterV5V6(DBHandle handle, OpenMode openMode, String tablePrefix)
|
||||
throws VersionException, IOException {
|
||||
String tableName = tablePrefix + COMPOSITE_TABLE_NAME;
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
compositeTable = handle.createTable(tableName, V5V6_COMPOSITE_SCHEMA,
|
||||
new int[] { V5V6_COMPOSITE_CAT_COL, V5V6_COMPOSITE_UNIVERSAL_DT_ID_COL });
|
||||
}
|
||||
|
@ -88,7 +89,7 @@ class CompositeDBAdapterV5V6 extends CompositeDBAdapter {
|
|||
}
|
||||
int version = compositeTable.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
if (version == V5_VERSION && openMode == DBConstants.READ_ONLY) {
|
||||
if (version == V5_VERSION && openMode == OpenMode.IMMUTABLE) {
|
||||
return; // StructureDB handles read-only flex-array migration
|
||||
}
|
||||
throw new VersionException(version < VERSION);
|
||||
|
@ -96,6 +97,7 @@ class CompositeDBAdapterV5V6 extends CompositeDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
int getVersion() {
|
||||
return compositeTable.getSchema().getVersion();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import generic.stl.Pair;
|
|||
import ghidra.app.plugin.core.datamgr.archive.BuiltInSourceArchive;
|
||||
import ghidra.docking.settings.*;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.RuntimeIOException;
|
||||
import ghidra.framework.store.db.PackedDBHandle;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
|
@ -231,7 +232,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
readOnlyMode = false;
|
||||
int id = startTransaction("");
|
||||
try {
|
||||
init(DBConstants.CREATE, TaskMonitor.DUMMY);
|
||||
init(OpenMode.CREATE, TaskMonitor.DUMMY);
|
||||
}
|
||||
catch (VersionException | CancelledException e) {
|
||||
throw new AssertException(e); // unexpected
|
||||
|
@ -251,23 +252,22 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
* NOTE: Default DataOrganization will be used for new archive.
|
||||
*
|
||||
* @param packedDBfile packed datatype archive file (i.e., *.gdt resource).
|
||||
* @param openMode open mode CREATE, READ_ONLY or UPDATE (see
|
||||
* {@link DBConstants}).
|
||||
* @param openMode open mode CREATE, READ_ONLY or UPDATE
|
||||
* @param monitor task monitor
|
||||
* @throws IOException a low-level IO error. This exception may also be thrown
|
||||
* when a version error occurs (cause is VersionException).
|
||||
* @throws CancelledException if task cancelled
|
||||
*/
|
||||
protected DataTypeManagerDB(ResourceFile packedDBfile, int openMode, TaskMonitor monitor)
|
||||
protected DataTypeManagerDB(ResourceFile packedDBfile, OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
|
||||
this.errHandler = new DbErrorHandler();
|
||||
this.lock = new Lock("DataTypeManagerDB");
|
||||
this.tablePrefix = "";
|
||||
this.readOnlyMode = (openMode == DBConstants.READ_ONLY);
|
||||
this.readOnlyMode = (openMode == OpenMode.IMMUTABLE);
|
||||
|
||||
File file = packedDBfile.getFile(false);
|
||||
if (file == null && openMode != DBConstants.READ_ONLY) {
|
||||
if (file == null && openMode != OpenMode.IMMUTABLE) {
|
||||
throw new IOException("Unsupported mode (" + openMode +
|
||||
") for read-only Datatype Archive: " + packedDBfile.getAbsolutePath());
|
||||
}
|
||||
|
@ -276,14 +276,14 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
boolean openSuccess = false;
|
||||
PackedDatabase pdb = null;
|
||||
try {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
dbHandle = new PackedDBHandle(
|
||||
DataTypeArchiveContentHandler.DATA_TYPE_ARCHIVE_CONTENT_TYPE);
|
||||
}
|
||||
else {
|
||||
pdb = PackedDatabase.getPackedDatabase(packedDBfile, false, monitor);
|
||||
|
||||
if (openMode == DBConstants.READ_ONLY) {
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
dbHandle = pdb.open(monitor);
|
||||
}
|
||||
else { // UPDATE mode (allows upgrade use)
|
||||
|
@ -302,7 +302,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
boolean initSuccess = false;
|
||||
try {
|
||||
initPackedDatabase(packedDBfile, openMode, monitor); // performs upgrade if needed
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
// preserve UniversalID if it has been established
|
||||
Long uid = universalID != null ? universalID.getValue() : null;
|
||||
((PackedDBHandle) dbHandle).saveAs("Archive", file.getParentFile(),
|
||||
|
@ -317,17 +317,17 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void initPackedDatabase(ResourceFile packedDBfile, int openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException {
|
||||
private void initPackedDatabase(ResourceFile packedDBfile, OpenMode openMode,
|
||||
TaskMonitor monitor) throws CancelledException, IOException {
|
||||
try (Transaction tx = openTransaction("")) {
|
||||
init(openMode, monitor);
|
||||
|
||||
if (openMode != DBConstants.CREATE && hasDataOrganizationChange(true)) {
|
||||
if (openMode != OpenMode.CREATE && hasDataOrganizationChange(true)) {
|
||||
// check for data organization change with possible upgrade
|
||||
handleDataOrganizationChange(openMode, monitor);
|
||||
}
|
||||
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
migrateOldFlexArrayComponentsIfRequired(monitor);
|
||||
|
||||
Msg.showInfo(this, null, "Archive Upgraded",
|
||||
|
@ -335,8 +335,8 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
}
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (openMode == DBConstants.UPDATE && e.isUpgradable()) {
|
||||
initPackedDatabase(packedDBfile, DBConstants.UPGRADE, monitor);
|
||||
if (openMode == OpenMode.UPDATE && e.isUpgradable()) {
|
||||
initPackedDatabase(packedDBfile, OpenMode.UPGRADE, monitor);
|
||||
}
|
||||
else {
|
||||
// Unable to handle required upgrade
|
||||
|
@ -353,7 +353,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
*
|
||||
* @param handle database handle
|
||||
* @param addrMap address map (may be null)
|
||||
* @param openMode open mode CREATE, READ_ONLY, UPDATE, UPGRADE (see {@link DBConstants}).
|
||||
* @param openMode open mode CREATE, READ_ONLY, UPDATE, UPGRADE.
|
||||
* @param tablePrefix DB table prefix to be applied to all associated table names. This
|
||||
* need only be specified when using multiple instances with the same
|
||||
* DB handle (null or empty string for no-prefix).
|
||||
|
@ -365,19 +365,19 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
* @throws VersionException if any database handle's version doesn't match the expected version.
|
||||
* This exception will never be thrown in READ_ONLY mode.
|
||||
*/
|
||||
protected DataTypeManagerDB(DBHandle handle, AddressMap addrMap, int openMode,
|
||||
protected DataTypeManagerDB(DBHandle handle, AddressMap addrMap, OpenMode openMode,
|
||||
String tablePrefix, ErrorHandler errHandler, Lock lock, TaskMonitor monitor)
|
||||
throws CancelledException, IOException, VersionException {
|
||||
this.tablePrefix = tablePrefix != null ? tablePrefix : "";
|
||||
this.dbHandle = handle;
|
||||
this.readOnlyMode = (openMode == DBConstants.READ_ONLY);
|
||||
this.readOnlyMode = (openMode == OpenMode.IMMUTABLE);
|
||||
this.addrMap = addrMap;
|
||||
this.errHandler = errHandler;
|
||||
this.lock = lock;
|
||||
init(openMode, monitor);
|
||||
}
|
||||
|
||||
private void init(int openMode, TaskMonitor monitor)
|
||||
private void init(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException, VersionException {
|
||||
updateID();
|
||||
initializeAdapters(openMode, monitor);
|
||||
|
@ -394,7 +394,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void initializeAdapters(int openMode, TaskMonitor monitor)
|
||||
private void initializeAdapters(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException, VersionException {
|
||||
|
||||
//
|
||||
|
@ -522,23 +522,23 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
/**
|
||||
* Initialize other DB adapters after base implementation adapters has been
|
||||
* initialized.
|
||||
* @param openMode the DB open mode (see {@link DBConstants})
|
||||
* @param openMode the DB open mode
|
||||
* @param monitor the progress monitor
|
||||
* @throws CancelledException if the user cancels an upgrade
|
||||
* @throws VersionException if the database does not match the expected version.
|
||||
* @throws IOException if a database IO error occurs.
|
||||
*/
|
||||
protected void initializeOtherAdapters(int openMode, TaskMonitor monitor)
|
||||
protected void initializeOtherAdapters(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException, VersionException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
protected void handleDataOrganizationChange(int openMode, TaskMonitor monitor)
|
||||
protected void handleDataOrganizationChange(OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, LanguageVersionException, CancelledException {
|
||||
if (openMode == DBConstants.UPDATE) {
|
||||
if (openMode == OpenMode.UPDATE) {
|
||||
throw new LanguageVersionException("Data organization change detected", true);
|
||||
}
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
compilerSpecChanged(monitor);
|
||||
}
|
||||
// NOTE: No change for READ_ONLY mode
|
||||
|
@ -591,33 +591,33 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
* @throws VersionException if database is a newer unsupported version
|
||||
* @throws IOException if an IO error occurs
|
||||
*/
|
||||
private void checkManagerVersion(int openMode) throws IOException, VersionException {
|
||||
private void checkManagerVersion(OpenMode openMode) throws IOException, VersionException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check data map for overall manager version for compatibility.
|
||||
DBStringMapAdapter dataMap = getDataMap(openMode == DBConstants.UPGRADE);
|
||||
DBStringMapAdapter dataMap = getDataMap(openMode == OpenMode.UPGRADE);
|
||||
if (dataMap != null) {
|
||||
// verify that we are compatible with stored data
|
||||
int dbVersion = dataMap.getInt(DTM_DB_VERSION_KEY, 1);
|
||||
if (dbVersion > DB_VERSION) {
|
||||
throw new VersionException(false);
|
||||
}
|
||||
if (dbVersion < DB_VERSION && openMode == DBConstants.UPDATE) {
|
||||
if (dbVersion < DB_VERSION && openMode == OpenMode.UPDATE) {
|
||||
// Force upgrade if open for update
|
||||
throw new VersionException(true);
|
||||
}
|
||||
}
|
||||
else if (openMode == DBConstants.UPDATE) {
|
||||
else if (openMode == OpenMode.UPDATE) {
|
||||
// missing data map
|
||||
throw new VersionException(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateManagerAndAppVersion(int openMode) throws IOException {
|
||||
if (openMode == DBConstants.CREATE || openMode == DBConstants.UPGRADE) {
|
||||
private void updateManagerAndAppVersion(OpenMode openMode) throws IOException {
|
||||
if (openMode == OpenMode.CREATE || openMode == OpenMode.UPGRADE) {
|
||||
DBStringMapAdapter dataMap = getDataMap(true);
|
||||
dataMap.put(DTM_DB_VERSION_KEY, Integer.toString(DB_VERSION));
|
||||
dataMap.put(DTM_GHIDRA_VERSION_KEY, Application.getApplicationVersion());
|
||||
|
@ -4192,9 +4192,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
private boolean checkForSourceArchiveUpdatesNeeded(int openMode, TaskMonitor monitor)
|
||||
private boolean checkForSourceArchiveUpdatesNeeded(OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
if (openMode == DBConstants.CREATE || openMode == DBConstants.READ_ONLY) {
|
||||
if (openMode == OpenMode.CREATE || openMode == OpenMode.IMMUTABLE) {
|
||||
return false;
|
||||
}
|
||||
List<DBRecord> records = sourceArchiveAdapter.getRecords();
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
@ -53,9 +54,9 @@ abstract class EnumDBAdapter {
|
|||
* @throws IOException if there is trouble accessing the database.
|
||||
* @throws CancelledException if task cancelled
|
||||
*/
|
||||
static EnumDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
static EnumDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new EnumDBAdapterV1(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
|
@ -63,7 +64,7 @@ abstract class EnumDBAdapter {
|
|||
}
|
||||
catch (VersionException e) {
|
||||
EnumDBAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -24,6 +24,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -54,20 +55,20 @@ abstract class EnumValueDBAdapter implements RecordTranslator {
|
|||
* @throws IOException if there is trouble accessing the database.
|
||||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
static EnumValueDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
static EnumValueDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new EnumValueDBAdapterV1(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
return new EnumValueDBAdapterV1(handle, tablePrefix, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
EnumValueDBAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.util.DBRecordAdapter;
|
||||
import ghidra.program.model.data.GenericCallingConvention;
|
||||
import ghidra.program.model.lang.CompilerSpec;
|
||||
|
@ -65,29 +66,29 @@ abstract class FunctionDefinitionDBAdapter implements DBRecordAdapter {
|
|||
* @param tablePrefix prefix to be used with default table name
|
||||
* @param callConvAdapter calling convention table adapter suitable to add new conventions
|
||||
* (e.g., this adapter being used during upgrade operation). Only used when openMode is
|
||||
* {@link DBConstants#UPGRADE} when adding new calling conventions must be permitted.
|
||||
* {@link OpenMode#UPGRADE} when adding new calling conventions must be permitted.
|
||||
* @param monitor the monitor to use for displaying status or for canceling.
|
||||
* @return the adapter for accessing the table of function definition data types.
|
||||
* @throws VersionException if the database handle's version doesn't match the expected version.
|
||||
* @throws IOException if there is trouble accessing the database.
|
||||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
static FunctionDefinitionDBAdapter getAdapter(DBHandle handle, int openMode,
|
||||
static FunctionDefinitionDBAdapter getAdapter(DBHandle handle, OpenMode openMode,
|
||||
String tablePrefix, CallingConventionDBAdapter callConvAdapter, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new FunctionDefinitionDBAdapterV2(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
return new FunctionDefinitionDBAdapterV2(handle, tablePrefix, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
FunctionDefinitionDBAdapter adapter;
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = findReadOnlyAdapter(handle, tablePrefix, callConvAdapter);
|
||||
adapter = upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
|
@ -203,6 +204,7 @@ abstract class FunctionDefinitionDBAdapter implements DBRecordAdapter {
|
|||
* @return the function definition data type record iterator.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
@Override
|
||||
public abstract RecordIterator getRecords() throws IOException;
|
||||
|
||||
/**
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue