mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Merge remote-tracking branch
'origin/GP-4403_ghidra1_ImmutableDomainObject--SQUASHED' Conflicts: Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramContentHandler.java
This commit is contained in:
commit
5a970158d5
161 changed files with 1240 additions and 1126 deletions
|
@ -19,7 +19,6 @@ import java.io.IOException;
|
|||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import db.buffers.*;
|
||||
import generic.theme.GIcon;
|
||||
|
@ -80,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;
|
||||
|
@ -135,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;
|
||||
|
@ -190,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);
|
||||
|
@ -297,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,7 +19,8 @@ import java.io.IOException;
|
|||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Field;
|
||||
import db.buffers.*;
|
||||
import generic.theme.GIcon;
|
||||
import ghidra.framework.data.*;
|
||||
|
@ -76,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;
|
||||
|
@ -128,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));
|
||||
|
@ -181,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);
|
||||
|
@ -291,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);
|
||||
|
@ -2100,7 +2108,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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
@ -50,21 +51,21 @@ abstract class FunctionParameterAdapter {
|
|||
* @throws IOException if there is trouble accessing the database.
|
||||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
static FunctionParameterAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
TaskMonitor monitor)
|
||||
static FunctionParameterAdapter getAdapter(DBHandle handle, OpenMode openMode,
|
||||
String tablePrefix, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new FunctionParameterAdapterV1(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
return new FunctionParameterAdapterV1(handle, tablePrefix, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
FunctionParameterAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,8 +18,8 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
|
@ -41,21 +41,21 @@ abstract class ParentChildAdapter {
|
|||
* @throws VersionException if the database handle's version doesn't match the expected version.
|
||||
* @throws IOException if there is trouble accessing the database.
|
||||
*/
|
||||
static ParentChildAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix)
|
||||
static ParentChildAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new ParentChildDBAdapterV0(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
return new ParentChildDBAdapterV0(handle, tablePrefix, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
ParentChildAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, tablePrefix);
|
||||
}
|
||||
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.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -49,21 +50,21 @@ abstract class PointerDBAdapter implements RecordTranslator {
|
|||
* @throws IOException if there is trouble accessing the database.
|
||||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
static PointerDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
static PointerDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new PointerDBAdapterV2(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
return new PointerDBAdapterV2(handle, tablePrefix, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
PointerDBAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.docking.settings.SettingsDefinition;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.*;
|
||||
|
@ -48,7 +49,7 @@ public abstract class ProgramBasedDataTypeManagerDB extends DataTypeManagerDB
|
|||
* Constructor
|
||||
* @param handle open database handle
|
||||
* @param addrMap the address map (instance settings not supported if null)
|
||||
* @param openMode the program open mode (see {@link DBConstants})
|
||||
* @param openMode the program open mode
|
||||
* @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).
|
||||
|
@ -59,14 +60,14 @@ public abstract class ProgramBasedDataTypeManagerDB extends DataTypeManagerDB
|
|||
* @throws VersionException if the database does not match the expected version.
|
||||
* @throws IOException if a database IO error occurs.
|
||||
*/
|
||||
protected ProgramBasedDataTypeManagerDB(DBHandle handle, AddressMap addrMap, int openMode,
|
||||
protected ProgramBasedDataTypeManagerDB(DBHandle handle, AddressMap addrMap, OpenMode openMode,
|
||||
String tablePrefix, ErrorHandler errHandler, Lock lock, TaskMonitor monitor)
|
||||
throws CancelledException, VersionException, IOException {
|
||||
super(handle, addrMap, openMode, tablePrefix, errHandler, lock, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeOtherAdapters(int openMode, TaskMonitor monitor)
|
||||
protected void initializeOtherAdapters(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException, VersionException {
|
||||
if (addrMap != null) {
|
||||
instanceSettingsAdapter = SettingsDBAdapter.getAdapter(
|
||||
|
|
|
@ -19,8 +19,10 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Transaction;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.database.ManagerDB;
|
||||
|
@ -48,7 +50,7 @@ public class ProgramDataTypeManager extends ProgramBasedDataTypeManagerDB implem
|
|||
* Constructor
|
||||
* @param handle open database handle
|
||||
* @param addrMap the address map
|
||||
* @param openMode the program open mode (see {@link DBConstants})
|
||||
* @param openMode the program open mode
|
||||
* @param errHandler the database io error handler
|
||||
* @param lock the program synchronization lock
|
||||
* @param monitor the progress monitor
|
||||
|
@ -56,11 +58,11 @@ public class ProgramDataTypeManager extends ProgramBasedDataTypeManagerDB implem
|
|||
* @throws VersionException if the database does not match the expected version.
|
||||
* @throws IOException if a database IO error occurs.
|
||||
*/
|
||||
public ProgramDataTypeManager(DBHandle handle, AddressMap addrMap, int openMode,
|
||||
public ProgramDataTypeManager(DBHandle handle, AddressMap addrMap, OpenMode openMode,
|
||||
ErrorHandler errHandler, Lock lock, TaskMonitor monitor)
|
||||
throws CancelledException, VersionException, IOException {
|
||||
super(handle, addrMap, openMode, null, errHandler, lock, monitor);
|
||||
upgrade = (openMode == DBConstants.UPGRADE);
|
||||
upgrade = (openMode == OpenMode.UPGRADE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,9 +121,9 @@ public class ProgramDataTypeManager extends ProgramBasedDataTypeManagerDB implem
|
|||
}
|
||||
|
||||
@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) {
|
||||
doSourceArchiveUpdates(monitor);
|
||||
migrateOldFlexArrayComponentsIfRequired(monitor);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.util.Set;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -55,15 +56,15 @@ abstract class SettingsDBAdapter {
|
|||
* @throws IOException if there was a problem accessing the database
|
||||
* @throws CancelledException if task cancelled
|
||||
*/
|
||||
static SettingsDBAdapter getAdapter(String tableName, DBHandle handle, int openMode,
|
||||
static SettingsDBAdapter getAdapter(String tableName, DBHandle handle, OpenMode openMode,
|
||||
AddressMap addrMap, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new SettingsDBAdapterV1(tableName, handle, true);
|
||||
}
|
||||
|
||||
if (openMode == DBConstants.READ_ONLY) {
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
return findReadOnlyAdapter(tableName, handle);
|
||||
}
|
||||
|
||||
|
@ -75,11 +76,11 @@ abstract class SettingsDBAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
SettingsDBAdapter adapter = findReadOnlyAdapter(tableName, handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, addrMap, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
@ -126,8 +127,7 @@ abstract class SettingsDBAdapter {
|
|||
rec.setLongValue(SETTINGS_ASSOCIATION_ID_COL, addrMap.getKey(addr, true));
|
||||
}
|
||||
tmpAdapter.createSettingsRecord(rec.getLongValue(SETTINGS_ASSOCIATION_ID_COL),
|
||||
oldAdapter.getSettingName(rec),
|
||||
rec.getString(SETTINGS_STRING_VALUE_COL),
|
||||
oldAdapter.getSettingName(rec), rec.getString(SETTINGS_STRING_VALUE_COL),
|
||||
rec.getLongValue(SETTINGS_LONG_VALUE_COL));
|
||||
monitor.setProgress(++cnt);
|
||||
}
|
||||
|
@ -143,8 +143,7 @@ abstract class SettingsDBAdapter {
|
|||
}
|
||||
DBRecord rec = iter.next();
|
||||
newAdapter.createSettingsRecord(rec.getLongValue(SETTINGS_ASSOCIATION_ID_COL),
|
||||
tmpAdapter.getSettingName(rec),
|
||||
rec.getString(SETTINGS_STRING_VALUE_COL),
|
||||
tmpAdapter.getSettingName(rec), rec.getString(SETTINGS_STRING_VALUE_COL),
|
||||
rec.getLongValue(SETTINGS_LONG_VALUE_COL));
|
||||
monitor.setProgress(++cnt);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.data.SourceArchive;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -62,20 +63,20 @@ abstract class SourceArchiveAdapter {
|
|||
* @throws IOException if there is trouble accessing the database.
|
||||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
static SourceArchiveAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
static SourceArchiveAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new SourceArchiveAdapterV0(handle, tablePrefix, true);
|
||||
}
|
||||
try {
|
||||
return new SourceArchiveAdapterV0(handle, tablePrefix, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
SourceArchiveAdapter 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.UniversalID;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
@ -59,17 +60,17 @@ abstract class TypedefDBAdapter {
|
|||
* @throws IOException if there is trouble accessing the database.
|
||||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
static TypedefDBAdapter getAdapter(DBHandle handle, int openMode, String tablePrefix,
|
||||
static TypedefDBAdapter getAdapter(DBHandle handle, OpenMode openMode, String tablePrefix,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
try {
|
||||
return new TypedefDBAdapterV2(handle, tablePrefix, openMode == DBConstants.CREATE);
|
||||
return new TypedefDBAdapterV2(handle, tablePrefix, openMode == OpenMode.CREATE);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
TypedefDBAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, tablePrefix, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.*;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.store.FileSystem;
|
||||
import ghidra.program.database.ManagerDB;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
|
@ -66,7 +67,7 @@ public class ExternalManagerDB implements ManagerDB, ExternalManager {
|
|||
* @throws IOException if a database io error occurs.
|
||||
* @throws VersionException if the database version does not match the expected version
|
||||
*/
|
||||
public ExternalManagerDB(DBHandle handle, AddressMap addrMap, int openMode, Lock lock,
|
||||
public ExternalManagerDB(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock,
|
||||
TaskMonitor monitor) throws CancelledException, IOException, VersionException {
|
||||
|
||||
this.addrMap = addrMap;
|
||||
|
@ -74,7 +75,7 @@ public class ExternalManagerDB implements ManagerDB, ExternalManager {
|
|||
initializeOldAdapters(handle, openMode, monitor);
|
||||
}
|
||||
|
||||
private void initializeOldAdapters(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
private void initializeOldAdapters(DBHandle handle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
try {
|
||||
// Try old adapters needed for upgrade
|
||||
|
@ -84,7 +85,7 @@ public class ExternalManagerDB implements ManagerDB, ExternalManager {
|
|||
catch (VersionException ve) {
|
||||
//ignore
|
||||
}
|
||||
if (oldNameAdapter != null && oldExtRefAdapter != null && openMode != DBConstants.UPGRADE) {
|
||||
if (oldNameAdapter != null && oldExtRefAdapter != null && openMode != OpenMode.UPGRADE) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
}
|
||||
|
@ -98,9 +99,9 @@ public class ExternalManagerDB implements ManagerDB, ExternalManager {
|
|||
}
|
||||
|
||||
@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) {
|
||||
return;
|
||||
}
|
||||
if (upgradeOldExtRefAdapter(monitor)) {
|
||||
|
@ -226,7 +227,8 @@ public class ExternalManagerDB implements ManagerDB, ExternalManager {
|
|||
|
||||
@Override
|
||||
public ExternalLocation addExtLocation(Namespace extParentNamespace, String extLabel,
|
||||
Address extAddr, SourceType sourceType, boolean reuseExisting) throws InvalidInputException {
|
||||
Address extAddr, SourceType sourceType, boolean reuseExisting)
|
||||
throws InvalidInputException {
|
||||
lock.acquire();
|
||||
try {
|
||||
return addExtLocation(extParentNamespace, extLabel, extAddr, false, sourceType,
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.external;
|
|||
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;
|
||||
|
@ -85,11 +86,11 @@ class OldExtNameAdapter {
|
|||
nameTable = newRefTable;
|
||||
}
|
||||
|
||||
static OldExtNameAdapter getAdapter(DBHandle dbHandle, int openMode, TaskMonitor monitor)
|
||||
static OldExtNameAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
|
||||
OldExtNameAdapter adapter = new OldExtNameAdapter(dbHandle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter.moveTable(dbHandle, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.external;
|
|||
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;
|
||||
|
@ -92,11 +93,11 @@ class OldExtRefAdapter {
|
|||
refTable = newRefTable;
|
||||
}
|
||||
|
||||
static OldExtRefAdapter getAdapter(DBHandle dbHandle, int openMode, TaskMonitor monitor)
|
||||
static OldExtRefAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
|
||||
OldExtRefAdapter adapter = new OldExtRefAdapter(dbHandle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter.moveTable(dbHandle, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.function;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -57,10 +58,10 @@ abstract class FunctionAdapter {
|
|||
|
||||
protected AddressMap addrMap;
|
||||
|
||||
static FunctionAdapter getAdapter(DBHandle handle, int openMode, AddressMap map,
|
||||
static FunctionAdapter getAdapter(DBHandle handle, OpenMode openMode, AddressMap map,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new FunctionAdapterV3(handle, map, true);
|
||||
}
|
||||
try {
|
||||
|
@ -71,11 +72,11 @@ abstract class FunctionAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
FunctionAdapter adapter = findReadOnlyAdapter(handle, map);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, map, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
@ -93,7 +94,8 @@ abstract class FunctionAdapter {
|
|||
}
|
||||
|
||||
static byte getSignatureSourceFlagBits(SourceType signatureSource) {
|
||||
return (byte) (signatureSource.ordinal() << FunctionAdapter.FUNCTION_SIGNATURE_SOURCE_SHIFT);
|
||||
return (byte) (signatureSource
|
||||
.ordinal() << FunctionAdapter.FUNCTION_SIGNATURE_SOURCE_SHIFT);
|
||||
}
|
||||
|
||||
static FunctionAdapter findReadOnlyAdapter(DBHandle handle, AddressMap map)
|
||||
|
|
|
@ -344,7 +344,17 @@ public class FunctionDB extends DatabaseObject implements Function {
|
|||
|
||||
@Override
|
||||
public AddressSetView getBody() {
|
||||
return program.getNamespaceManager().getAddressSet(this);
|
||||
manager.lock.acquire();
|
||||
try {
|
||||
if (!checkIsValid()) {
|
||||
// Function or its symbol has been deleted
|
||||
return new AddressSet(entryPoint, entryPoint);
|
||||
}
|
||||
return program.getNamespaceManager().getAddressSet(this);
|
||||
}
|
||||
finally {
|
||||
manager.lock.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import db.*;
|
||||
import generic.FilteredIterator;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.code.CodeManager;
|
||||
|
@ -95,8 +96,7 @@ public class FunctionManagerDB implements FunctionManager {
|
|||
* Construct a new FunctionManager
|
||||
* @param dbHandle data base handle
|
||||
* @param addrMap address map for the program
|
||||
* @param openMode CREATE, UPDATE, READ_ONLY, or UPGRADE defined in
|
||||
* db.DBConstants
|
||||
* @param openMode CREATE, UPDATE, READ_ONLY, or UPGRADE
|
||||
* @param lock the program synchronization lock
|
||||
* @param monitor
|
||||
* @throws VersionException if function manager's version does not match
|
||||
|
@ -105,7 +105,7 @@ public class FunctionManagerDB implements FunctionManager {
|
|||
* and the user canceled the upgrade process
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
public FunctionManagerDB(DBHandle dbHandle, AddressMap addrMap, int openMode, Lock lock,
|
||||
public FunctionManagerDB(DBHandle dbHandle, AddressMap addrMap, OpenMode openMode, Lock lock,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
this.dbHandle = dbHandle;
|
||||
this.addrMap = addrMap;
|
||||
|
@ -115,7 +115,7 @@ public class FunctionManagerDB implements FunctionManager {
|
|||
functionTagManager = new FunctionTagManagerDB(dbHandle, openMode, lock, monitor);
|
||||
}
|
||||
|
||||
private void initializeAdapters(int openMode, TaskMonitor monitor)
|
||||
private void initializeAdapters(OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
try {
|
||||
FunctionAdapter oldAdapter = FunctionAdapter.findReadOnlyAdapter(dbHandle, addrMap);
|
||||
|
@ -647,10 +647,10 @@ public class FunctionManagerDB implements FunctionManager {
|
|||
}
|
||||
|
||||
@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) {
|
||||
upgradeAllDotDotDots(monitor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.function;
|
|||
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;
|
||||
|
@ -50,21 +51,21 @@ abstract class FunctionTagAdapter {
|
|||
* @throws CancelledException
|
||||
* @throws IOException
|
||||
*/
|
||||
static FunctionTagAdapter getAdapter(DBHandle handle, int openMode,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
static FunctionTagAdapter getAdapter(DBHandle handle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new FunctionTagAdapterV0(handle, true);
|
||||
}
|
||||
try {
|
||||
return new FunctionTagAdapterV0(handle, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
FunctionTagAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
@ -75,10 +76,8 @@ abstract class FunctionTagAdapter {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static FunctionTagAdapter upgrade(DBHandle handle,
|
||||
FunctionTagAdapter oldAdapter,
|
||||
TaskMonitor monitor)
|
||||
throws VersionException {
|
||||
private static FunctionTagAdapter upgrade(DBHandle handle, FunctionTagAdapter oldAdapter,
|
||||
TaskMonitor monitor) throws VersionException {
|
||||
return new FunctionTagAdapterV0(handle, true);
|
||||
}
|
||||
|
||||
|
@ -124,7 +123,7 @@ abstract class FunctionTagAdapter {
|
|||
* @throws IOException
|
||||
*/
|
||||
abstract void updateRecord(DBRecord record) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Removes the tag with the given name from the database.
|
||||
*
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.commons.collections4.map.LazyMap;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -61,7 +62,7 @@ public class FunctionTagManagerDB implements FunctionTagManager, ErrorHandler {
|
|||
* @throws IOException if there is a problem accessing the database.
|
||||
* @throws CancelledException if the program loading is cancelled
|
||||
*/
|
||||
FunctionTagManagerDB(DBHandle handle, int openMode, Lock lock, TaskMonitor monitor)
|
||||
FunctionTagManagerDB(DBHandle handle, OpenMode openMode, Lock lock, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
this.lock = lock;
|
||||
|
||||
|
@ -365,7 +366,7 @@ public class FunctionTagManagerDB implements FunctionTagManager, ErrorHandler {
|
|||
*
|
||||
*/
|
||||
private void invalidateFunctions() {
|
||||
FunctionManagerDB functionManager = (FunctionManagerDB) program.getFunctionManager();
|
||||
FunctionManagerDB functionManager = program.getFunctionManager();
|
||||
functionManager.functionTagsChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.function;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.symbol.SymbolTable;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -36,21 +37,21 @@ abstract class FunctionTagMappingAdapter {
|
|||
static final int FUNCTION_ID_COL = 0;
|
||||
static final int TAG_ID_COL = 1;
|
||||
|
||||
static FunctionTagMappingAdapter getAdapter(DBHandle handle, int openMode,
|
||||
static FunctionTagMappingAdapter getAdapter(DBHandle handle, OpenMode openMode,
|
||||
TaskMonitor monitor) throws VersionException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new FunctionTagMappingAdapterV0(handle, true);
|
||||
}
|
||||
try {
|
||||
return new FunctionTagMappingAdapterV0(handle, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
FunctionTagMappingAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
@ -62,9 +63,7 @@ abstract class FunctionTagMappingAdapter {
|
|||
}
|
||||
|
||||
private static FunctionTagMappingAdapter upgrade(DBHandle handle,
|
||||
FunctionTagMappingAdapter oldAdapter,
|
||||
TaskMonitor monitor)
|
||||
throws VersionException {
|
||||
FunctionTagMappingAdapter oldAdapter, TaskMonitor monitor) throws VersionException {
|
||||
return new FunctionTagMappingAdapterV0(handle, true);
|
||||
}
|
||||
|
||||
|
@ -96,8 +95,7 @@ abstract class FunctionTagMappingAdapter {
|
|||
* @return newly-created database record
|
||||
* @throws IOException if database error occurs
|
||||
*/
|
||||
abstract DBRecord createFunctionTagRecord(long functionID, long tagID)
|
||||
throws IOException;
|
||||
abstract DBRecord createFunctionTagRecord(long functionID, long tagID) throws IOException;
|
||||
|
||||
/**
|
||||
* Removes the record with the given function and tag IDs. There should be at most
|
||||
|
@ -108,8 +106,7 @@ abstract class FunctionTagMappingAdapter {
|
|||
* @return true if the remove was performed
|
||||
* @throws IOException if database error occurs
|
||||
*/
|
||||
abstract boolean removeFunctionTagRecord(long functionID, long tagID)
|
||||
throws IOException;
|
||||
abstract boolean removeFunctionTagRecord(long functionID, long tagID) throws IOException;
|
||||
|
||||
/**
|
||||
* Removes all records containing the given tag ID. This should be called
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.function;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -35,21 +36,21 @@ abstract class ThunkFunctionAdapter {
|
|||
|
||||
protected AddressMap addrMap;
|
||||
|
||||
static ThunkFunctionAdapter getAdapter(DBHandle handle, int openMode, AddressMap map,
|
||||
static ThunkFunctionAdapter getAdapter(DBHandle handle, OpenMode openMode, AddressMap map,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new ThunkFunctionAdapterV0(handle, map, true);
|
||||
}
|
||||
try {
|
||||
return new ThunkFunctionAdapterV0(handle, map, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
ThunkFunctionAdapter adapter = findReadOnlyAdapter(handle, map);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, map, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,8 +18,8 @@ package ghidra.program.database.map;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramAddressFactory;
|
||||
import ghidra.program.database.map.AddressMapDBAdapter.AddressMapEntry;
|
||||
import ghidra.program.database.mem.MemoryMapDB;
|
||||
|
@ -181,15 +181,15 @@ public class AddressMapDB implements AddressMap {
|
|||
* @throws IOException thrown if a dabase io error occurs.
|
||||
* @throws VersionException if the database version does not match the expected version.
|
||||
*/
|
||||
public AddressMapDB(DBHandle handle, int openMode, AddressFactory factory, long baseImageOffset,
|
||||
TaskMonitor monitor) throws IOException, VersionException {
|
||||
this.readOnly = (openMode == DBConstants.READ_ONLY);
|
||||
public AddressMapDB(DBHandle handle, OpenMode openMode, AddressFactory factory,
|
||||
long baseImageOffset, TaskMonitor monitor) throws IOException, VersionException {
|
||||
this.readOnly = (openMode == OpenMode.IMMUTABLE);
|
||||
this.addrFactory = factory;
|
||||
this.baseImageOffset = baseImageOffset;
|
||||
defaultAddrSpace = addrFactory.getDefaultAddressSpace();
|
||||
adapter = AddressMapDBAdapter.getAdapter(handle, openMode, addrFactory, monitor);
|
||||
oldAddrMap = (adapter.oldAddrMap != null) ? adapter.oldAddrMap : this;
|
||||
useOldAddrMap = (openMode == DBConstants.READ_ONLY && oldAddrMap != this);
|
||||
useOldAddrMap = (openMode == OpenMode.IMMUTABLE && oldAddrMap != this);
|
||||
baseAddrs = adapter.getBaseAddresses(false);
|
||||
init(true);
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ package ghidra.program.database.map;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressFactory;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
@ -35,21 +35,21 @@ abstract class AddressMapDBAdapter {
|
|||
|
||||
AddressMap oldAddrMap;
|
||||
|
||||
static AddressMapDBAdapter getAdapter(DBHandle handle, int openMode, AddressFactory factory,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
static AddressMapDBAdapter getAdapter(DBHandle handle, OpenMode openMode,
|
||||
AddressFactory factory, TaskMonitor monitor) throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new AddressMapDBAdapterV1(handle, factory, true);
|
||||
}
|
||||
try {
|
||||
return new AddressMapDBAdapterV1(handle, factory, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
AddressMapDBAdapter adapter = findReadOnlyAdapter(handle, factory);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, factory, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -19,7 +19,9 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import db.*;
|
||||
import db.DBBuffer;
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.MonitoredInputStream;
|
||||
import ghidra.util.exception.IOCancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
@ -46,21 +48,21 @@ abstract class FileBytesAdapter {
|
|||
this.handle = handle;
|
||||
}
|
||||
|
||||
static FileBytesAdapter getAdapter(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
static FileBytesAdapter getAdapter(DBHandle handle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new FileBytesAdapterV0(handle, true);
|
||||
}
|
||||
try {
|
||||
return new FileBytesAdapterV0(handle, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
FileBytesAdapter adapter = findReadOnlyAdapter(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -19,8 +19,8 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.DomainObjectChangeRecord;
|
||||
import ghidra.framework.model.DomainObjectEvent;
|
||||
import ghidra.framework.store.LockException;
|
||||
|
@ -94,8 +94,9 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
* @throws IOException if a database io error occurs.
|
||||
* @throws VersionException if the database version is different from the expected version
|
||||
*/
|
||||
public MemoryMapDB(DBHandle handle, AddressMapDB addrMap, int openMode, boolean isBigEndian,
|
||||
Lock lock, TaskMonitor monitor) throws IOException, VersionException {
|
||||
public MemoryMapDB(DBHandle handle, AddressMapDB addrMap, OpenMode openMode,
|
||||
boolean isBigEndian, Lock lock, TaskMonitor monitor)
|
||||
throws IOException, VersionException {
|
||||
this.addrMap = addrMap;
|
||||
this.lock = lock;
|
||||
defaultEndian = isBigEndian ? BIG_ENDIAN : LITTLE_ENDIAN;
|
||||
|
@ -106,8 +107,7 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
}
|
||||
|
||||
// for testing
|
||||
MemoryMapDB(DBHandle handle, AddressMapDB addrMap, int openMode, boolean isBigEndian,
|
||||
Lock lock) {
|
||||
MemoryMapDB(DBHandle handle, AddressMapDB addrMap, boolean isBigEndian, Lock lock) {
|
||||
this.addrMap = addrMap;
|
||||
this.lock = lock;
|
||||
defaultEndian = isBigEndian ? BIG_ENDIAN : LITTLE_ENDIAN;
|
||||
|
@ -271,9 +271,9 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
}
|
||||
|
||||
@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) {
|
||||
// Ensure that the key has been generated for the end address of each block
|
||||
// This will allow undefined data to be returned for all address contained
|
||||
// within any 32-bit block (see CodeManager handling of AddressMap.INVALID_ADDRESS_KEY).
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.InputStream;
|
|||
import java.util.List;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressOverflowException;
|
||||
import ghidra.program.model.mem.*;
|
||||
|
@ -75,21 +76,21 @@ abstract class MemoryMapDBAdapter {
|
|||
static final byte SUB_TYPE_UNINITIALIZED = MemoryMapDBAdapterV3.V3_SUB_TYPE_UNINITIALIZED;
|
||||
static final byte SUB_TYPE_FILE_BYTES = MemoryMapDBAdapterV3.V3_SUB_TYPE_FILE_BYTES;
|
||||
|
||||
static MemoryMapDBAdapter getAdapter(DBHandle handle, int openMode, MemoryMapDB memMap,
|
||||
static MemoryMapDBAdapter getAdapter(DBHandle handle, OpenMode openMode, MemoryMapDB memMap,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new MemoryMapDBAdapterV3(handle, memMap, Memory.GBYTE, true);
|
||||
}
|
||||
try {
|
||||
return new MemoryMapDBAdapterV3(handle, memMap, Memory.GBYTE, false);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
MemoryMapDBAdapter adapter = findReadOnlyAdapter(handle, memMap);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter, memMap, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -17,7 +17,9 @@ package ghidra.program.database.module;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.DBRecord;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
abstract class FragmentDBAdapter {
|
||||
|
@ -36,9 +38,9 @@ abstract class FragmentDBAdapter {
|
|||
* @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 FragmentDBAdapter getAdapter(DBHandle handle, int openMode, long treeID)
|
||||
static FragmentDBAdapter getAdapter(DBHandle handle, OpenMode openMode, long treeID)
|
||||
throws VersionException, IOException {
|
||||
return new FragmentDBAdapterV0(handle, openMode == DBConstants.CREATE, treeID);
|
||||
return new FragmentDBAdapterV0(handle, openMode == OpenMode.CREATE, treeID);
|
||||
}
|
||||
|
||||
static final String getTableName(long treeID) {
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.module;
|
|||
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;
|
||||
|
@ -40,16 +41,16 @@ abstract class ModuleDBAdapter {
|
|||
* @throws IOException if there is a problem accessing the database.
|
||||
* @throws CancelledException if task cancelled
|
||||
*/
|
||||
static ModuleDBAdapter getAdapter(ModuleManager moduleMgr, int openMode, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
static ModuleDBAdapter getAdapter(ModuleManager moduleMgr, OpenMode openMode,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
long treeID = moduleMgr.getTreeID();
|
||||
DBHandle handle = moduleMgr.getDatabaseHandle();
|
||||
try {
|
||||
return new ModuleDBAdapterV1(handle, openMode == DBConstants.CREATE, treeID);
|
||||
return new ModuleDBAdapterV1(handle, openMode == OpenMode.CREATE, treeID);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
// V0 read-only is slow - force upgrade
|
||||
if (!e.isUpgradable() || openMode != DBConstants.UPGRADE) {
|
||||
if (!e.isUpgradable() || openMode != OpenMode.UPGRADE) {
|
||||
throw e;
|
||||
}
|
||||
ModuleDBAdapter adapter = findReadOnlyAdapter(moduleMgr);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.HashSet;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -72,7 +73,7 @@ class ModuleManager {
|
|||
* @throws VersionException if opening an existing program tree and an underlying table
|
||||
* schema version differs from the expected version.
|
||||
*/
|
||||
ModuleManager(TreeManager treeMgr, DBRecord rec, int openMode, TaskMonitor monitor)
|
||||
ModuleManager(TreeManager treeMgr, DBRecord rec, OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, CancelledException, VersionException {
|
||||
|
||||
this.treeMgr = treeMgr;
|
||||
|
@ -89,7 +90,7 @@ class ModuleManager {
|
|||
moduleCache = new DBObjectCache<>(100);
|
||||
fragCache = new DBObjectCache<>(100);
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
createRootModule();
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +99,7 @@ class ModuleManager {
|
|||
return FRAGMENT_ADDRESS_TABLE_NAME + treeID;
|
||||
}
|
||||
|
||||
private void initializeAdapters(int openMode, TaskMonitor monitor)
|
||||
private void initializeAdapters(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException, VersionException {
|
||||
|
||||
DBHandle handle = treeMgr.getDatabaseHandle();
|
||||
|
@ -126,10 +127,10 @@ class ModuleManager {
|
|||
}
|
||||
|
||||
if (addrMap.isUpgraded()) {
|
||||
if (openMode == DBConstants.UPDATE) {
|
||||
if (openMode == OpenMode.UPDATE) {
|
||||
versionExc = (new VersionException(true)).combine(versionExc);
|
||||
}
|
||||
else if (openMode == DBConstants.UPGRADE) {
|
||||
else if (openMode == OpenMode.UPGRADE) {
|
||||
addressUpgrade(handle, monitor);
|
||||
}
|
||||
}
|
||||
|
@ -413,9 +414,8 @@ class ModuleManager {
|
|||
monitor.checkCancelled();
|
||||
fragMap.clearRange(fromAddr, rangeEnd);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
for (FragmentHolder fh : list) {
|
||||
monitor.checkCancelled();
|
||||
FragmentHolder fh = list.get(i);
|
||||
fragMap.paintRange(fh.range.getMinAddress(), fh.range.getMaxAddress(),
|
||||
new LongField(fh.frag.getKey()));
|
||||
fh.frag.addRange(fh.range);
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.module;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
abstract class ParentChildDBAdapter {
|
||||
|
@ -37,9 +38,9 @@ abstract class ParentChildDBAdapter {
|
|||
* @throws VersionException if the database handle's version doesn't match the expected version.
|
||||
* @throws IOException if database IO error occurs
|
||||
*/
|
||||
static ParentChildDBAdapter getAdapter(DBHandle handle, int openMode, long treeID)
|
||||
static ParentChildDBAdapter getAdapter(DBHandle handle, OpenMode openMode, long treeID)
|
||||
throws VersionException, IOException {
|
||||
return new ParentChildDBAdapterV0(handle, openMode == DBConstants.CREATE, treeID);
|
||||
return new ParentChildDBAdapterV0(handle, openMode == OpenMode.CREATE, treeID);
|
||||
}
|
||||
|
||||
static final String getTableName(long treeID) {
|
||||
|
|
|
@ -18,15 +18,16 @@ package ghidra.program.database.module;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
abstract class ProgramTreeDBAdapter {
|
||||
|
||||
|
||||
static final String PROGRAM_TREE_TABLE_NAME = "Trees";
|
||||
|
||||
|
||||
static final int TREE_NAME_COL = ProgramTreeDBAdapterV0.V0_TREE_NAME_COL;
|
||||
static final int MODIFICATION_NUM_COL = ProgramTreeDBAdapterV0.V0_MODIFICATION_NUM_COL;
|
||||
|
||||
|
||||
/**
|
||||
* Gets an adapter for working with the program tree database table.
|
||||
* @param handle handle to the database to be accessed.
|
||||
|
@ -35,9 +36,9 @@ abstract class ProgramTreeDBAdapter {
|
|||
* @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 ProgramTreeDBAdapter getAdapter(DBHandle handle, int openMode)
|
||||
static ProgramTreeDBAdapter getAdapter(DBHandle handle, OpenMode openMode)
|
||||
throws VersionException, IOException {
|
||||
return new ProgramTreeDBAdapterV0(handle, openMode == DBConstants.CREATE);
|
||||
return new ProgramTreeDBAdapterV0(handle, openMode == OpenMode.CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.*;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ManagerDB;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -66,8 +67,8 @@ public class TreeManager implements ManagerDB {
|
|||
* @throws VersionException if the database version is different from the expected version
|
||||
* @throws CancelledException if instantiation has been cancelled
|
||||
*/
|
||||
public TreeManager(DBHandle handle, ErrorHandler errHandler, AddressMap addrMap, int openMode,
|
||||
Lock lock, TaskMonitor monitor)
|
||||
public TreeManager(DBHandle handle, ErrorHandler errHandler, AddressMap addrMap,
|
||||
OpenMode openMode, Lock lock, TaskMonitor monitor)
|
||||
throws IOException, VersionException, CancelledException {
|
||||
|
||||
this.handle = handle;
|
||||
|
@ -90,7 +91,7 @@ public class TreeManager implements ManagerDB {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void programReady(int openMode1, int currentRevision, TaskMonitor monitor)
|
||||
public void programReady(OpenMode openMode1, int currentRevision, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
// Nothing to do
|
||||
}
|
||||
|
@ -123,8 +124,7 @@ public class TreeManager implements ManagerDB {
|
|||
"Root module named " + treeName + " already exists");
|
||||
}
|
||||
DBRecord record = treeAdapter.createRecord(treeName);
|
||||
ModuleManager m =
|
||||
new ModuleManager(this, record, DBConstants.CREATE, TaskMonitor.DUMMY);
|
||||
ModuleManager m = new ModuleManager(this, record, OpenMode.CREATE, TaskMonitor.DUMMY);
|
||||
treeMap.put(treeName, m);
|
||||
addMemoryBlocks(m);
|
||||
if (program != null) {
|
||||
|
@ -472,7 +472,7 @@ public class TreeManager implements ManagerDB {
|
|||
* @throws VersionException if a DB schema version differs from expected version
|
||||
* @throws CancelledException if operation cancelled
|
||||
*/
|
||||
private void initTreeMap(int openMode, TaskMonitor monitor)
|
||||
private void initTreeMap(OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, CancelledException, VersionException {
|
||||
treeMap = new HashMap<>();
|
||||
RecordIterator iter = treeAdapter.getRecords();
|
||||
|
@ -515,7 +515,7 @@ public class TreeManager implements ManagerDB {
|
|||
}
|
||||
if (mm == null) {
|
||||
try {
|
||||
mm = new ModuleManager(this, rec, DBConstants.UPDATE, TaskMonitor.DUMMY);
|
||||
mm = new ModuleManager(this, rec, OpenMode.UPDATE, TaskMonitor.DUMMY);
|
||||
}
|
||||
catch (VersionException | CancelledException e) {
|
||||
throw new RuntimeException(e); // unexpected exception
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Iterator;
|
|||
import java.util.TreeMap;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ManagerDB;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.bookmark.OldBookmark;
|
||||
|
@ -89,13 +90,13 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
public DBPropertyMapManager(DBHandle handle, ChangeManager changeMgr, AddressMap addrMap,
|
||||
int openMode, Lock lock, TaskMonitor monitor)
|
||||
OpenMode openMode, Lock lock, TaskMonitor monitor)
|
||||
throws IOException, VersionException, CancelledException {
|
||||
this.dbHandle = handle;
|
||||
this.changeMgr = changeMgr;
|
||||
this.addrMap = addrMap;
|
||||
this.lock = lock;
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
dbHandle.createTable(PROPERTIES_TABLE_NAME, PROPERTIES_SCHEMA);
|
||||
}
|
||||
findAdapters(handle);
|
||||
|
@ -103,32 +104,23 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
loadPropertyMaps(openMode, monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.ManagerDB#setProgram(ghidra.program.database.ProgramDB)
|
||||
*/
|
||||
@Override
|
||||
public void setProgram(ProgramDB program) {
|
||||
this.program = program;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.ManagerDB#programReady(int, int, ghidra.util.task.TaskMonitor)
|
||||
*/
|
||||
@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
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.ManagerDB#invalidateCache(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void invalidateCache(boolean all) throws IOException {
|
||||
lock.acquire();
|
||||
try {
|
||||
propertyMapCache.clear();
|
||||
loadPropertyMaps(-1, TaskMonitor.DUMMY);
|
||||
loadPropertyMaps(null, TaskMonitor.DUMMY);
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
// will not happen
|
||||
|
@ -141,7 +133,14 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
}
|
||||
}
|
||||
|
||||
private void loadPropertyMaps(int openMode, TaskMonitor monitor)
|
||||
/**
|
||||
* Load {@code propertyMapCache} with all property map instances.
|
||||
* @param openMode open mode or null if in response to a cache invalidate
|
||||
* @param monitor task monitor
|
||||
* @throws VersionException if a version error occurs
|
||||
* @throws CancelledException if task is cancelled
|
||||
*/
|
||||
private void loadPropertyMaps(OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException {
|
||||
try {
|
||||
VersionException ve = null;
|
||||
|
@ -177,7 +176,7 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
BookmarkManager.OLD_BOOKMARK_PROPERTY_OBJECT_CLASS2
|
||||
.equals(className)) {
|
||||
// Upgrade handled by new BookmarkManager
|
||||
if (openMode == DBConstants.UPDATE) {
|
||||
if (openMode == OpenMode.UPDATE) {
|
||||
throw new VersionException(VersionException.OLDER_VERSION,
|
||||
true);
|
||||
}
|
||||
|
@ -193,7 +192,7 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
|
||||
break;
|
||||
default:
|
||||
if (openMode >= 0) {
|
||||
if (openMode != null) {
|
||||
// employ unsupported property class
|
||||
Msg.showError(this, null, "Unsupported Property", "WARNING: " +
|
||||
" property ignored, unrecognized type: " + propertyType);
|
||||
|
@ -238,7 +237,7 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
}
|
||||
IntPropertyMapDB pm = null;
|
||||
try {
|
||||
pm = new IntPropertyMapDB(dbHandle, DBConstants.CREATE, program, changeMgr, addrMap,
|
||||
pm = new IntPropertyMapDB(dbHandle, OpenMode.CREATE, program, changeMgr, addrMap,
|
||||
propertyName, TaskMonitor.DUMMY);
|
||||
propertiesDBAdapter.putRecord(propertyName, INT_PROPERTY_TYPE, null);
|
||||
propertyMapCache.put(propertyName, pm);
|
||||
|
@ -276,8 +275,8 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
}
|
||||
LongPropertyMapDB pm = null;
|
||||
try {
|
||||
pm = new LongPropertyMapDB(dbHandle, DBConstants.CREATE, program, changeMgr,
|
||||
addrMap, propertyName, TaskMonitor.DUMMY);
|
||||
pm = new LongPropertyMapDB(dbHandle, OpenMode.CREATE, program, changeMgr, addrMap,
|
||||
propertyName, TaskMonitor.DUMMY);
|
||||
propertiesDBAdapter.putRecord(propertyName, LONG_PROPERTY_TYPE, null);
|
||||
propertyMapCache.put(propertyName, pm);
|
||||
}
|
||||
|
@ -315,8 +314,8 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
}
|
||||
StringPropertyMapDB pm = null;
|
||||
try {
|
||||
pm = new StringPropertyMapDB(dbHandle, DBConstants.CREATE, program, changeMgr,
|
||||
addrMap, propertyName, TaskMonitor.DUMMY);
|
||||
pm = new StringPropertyMapDB(dbHandle, OpenMode.CREATE, program, changeMgr, addrMap,
|
||||
propertyName, TaskMonitor.DUMMY);
|
||||
propertiesDBAdapter.putRecord(propertyName, STRING_PROPERTY_TYPE, null);
|
||||
propertyMapCache.put(propertyName, pm);
|
||||
}
|
||||
|
@ -348,7 +347,7 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
}
|
||||
ObjectPropertyMapDB<T> pm = null;
|
||||
try {
|
||||
pm = new ObjectPropertyMapDB<>(dbHandle, DBConstants.CREATE, program, changeMgr,
|
||||
pm = new ObjectPropertyMapDB<>(dbHandle, OpenMode.CREATE, program, changeMgr,
|
||||
addrMap, propertyName, objectClass, TaskMonitor.DUMMY, false);
|
||||
propertiesDBAdapter.putRecord(propertyName, OBJECT_PROPERTY_TYPE,
|
||||
objectClass.getName());
|
||||
|
@ -388,8 +387,8 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
}
|
||||
VoidPropertyMapDB pm = null;
|
||||
try {
|
||||
pm = new VoidPropertyMapDB(dbHandle, DBConstants.CREATE, program, changeMgr,
|
||||
addrMap, propertyName, TaskMonitor.DUMMY);
|
||||
pm = new VoidPropertyMapDB(dbHandle, OpenMode.CREATE, program, changeMgr, addrMap,
|
||||
propertyName, TaskMonitor.DUMMY);
|
||||
propertiesDBAdapter.putRecord(propertyName, VOID_PROPERTY_TYPE, null);
|
||||
propertyMapCache.put(propertyName, pm);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.util.IntPropertyMap;
|
||||
|
@ -35,7 +36,8 @@ public class IntPropertyMapDB extends PropertyMapDB<Integer> implements IntPrope
|
|||
/**
|
||||
* Construct a integer property map.
|
||||
* @param dbHandle database handle.
|
||||
* @param openMode the mode that the program was openned in.
|
||||
* @param openMode the mode that the program was openned in or null if instantiated during
|
||||
* cache invalidate. Used to detect versioning error only.
|
||||
* @param errHandler database error handler.
|
||||
* @param changeMgr change manager for event notification
|
||||
* @param addrMap address map.
|
||||
|
@ -45,7 +47,7 @@ public class IntPropertyMapDB extends PropertyMapDB<Integer> implements IntPrope
|
|||
* @throws CancelledException if the user cancels the upgrade operation.
|
||||
* @throws IOException if a database io error occurs.
|
||||
*/
|
||||
public IntPropertyMapDB(DBHandle dbHandle, int openMode, ErrorHandler errHandler,
|
||||
public IntPropertyMapDB(DBHandle dbHandle, OpenMode openMode, ErrorHandler errHandler,
|
||||
ChangeManager changeMgr, AddressMap addrMap, String name, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
super(dbHandle, errHandler, changeMgr, addrMap, name);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.util.LongPropertyMap;
|
||||
|
@ -35,7 +36,8 @@ public class LongPropertyMapDB extends PropertyMapDB<Long> implements LongProper
|
|||
/**
|
||||
* Construct a long property map.
|
||||
* @param dbHandle database handle.
|
||||
* @param openMode the mode that the program was openned in.
|
||||
* @param openMode the mode that the program was openned in or null if instantiated during
|
||||
* cache invalidate. Used to detect versioning error only.
|
||||
* @param errHandler database error handler.
|
||||
* @param changeMgr change manager for event notification
|
||||
* @param addrMap address map.
|
||||
|
@ -45,7 +47,7 @@ public class LongPropertyMapDB extends PropertyMapDB<Long> implements LongProper
|
|||
* @throws CancelledException if the user cancels the upgrade operation.
|
||||
* @throws IOException if a database io error occurs.
|
||||
*/
|
||||
public LongPropertyMapDB(DBHandle dbHandle, int openMode, ErrorHandler errHandler,
|
||||
public LongPropertyMapDB(DBHandle dbHandle, OpenMode openMode, ErrorHandler errHandler,
|
||||
ChangeManager changeMgr, AddressMap addrMap, String name, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
super(dbHandle, errHandler, changeMgr, addrMap, name);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.util.ObjectPropertyMap;
|
||||
|
@ -40,12 +41,12 @@ public class ObjectPropertyMapDB<T extends Saveable> extends PropertyMapDB<T>
|
|||
private Class<T> saveableObjectClass;
|
||||
private int saveableObjectVersion;
|
||||
private boolean supportsPrivate;
|
||||
private boolean saveableErrorReported = false;
|
||||
|
||||
/**
|
||||
* Construct an Saveable object property map.
|
||||
* @param dbHandle database handle.
|
||||
* @param openMode the mode that the program was opened in.
|
||||
* @param openMode the mode that the program was openned in or null if instantiated during
|
||||
* cache invalidate. Used to detect versioning error only.
|
||||
* @param errHandler database error handler.
|
||||
* @param changeMgr change manager for event notification
|
||||
* @param addrMap address map.
|
||||
|
@ -60,9 +61,9 @@ public class ObjectPropertyMapDB<T extends Saveable> extends PropertyMapDB<T>
|
|||
* if upgrade is true.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ObjectPropertyMapDB(DBHandle dbHandle, int openMode, ErrorHandler errHandler,
|
||||
ChangeManager changeMgr, AddressMap addrMap, String name,
|
||||
Class<T> saveableObjectClass, TaskMonitor monitor, boolean supportsPrivate)
|
||||
public ObjectPropertyMapDB(DBHandle dbHandle, OpenMode openMode, ErrorHandler errHandler,
|
||||
ChangeManager changeMgr, AddressMap addrMap, String name, Class<T> saveableObjectClass,
|
||||
TaskMonitor monitor, boolean supportsPrivate)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
super(dbHandle, errHandler, changeMgr, addrMap, name);
|
||||
this.saveableObjectClass = saveableObjectClass;
|
||||
|
@ -130,7 +131,7 @@ public class ObjectPropertyMapDB<T extends Saveable> extends PropertyMapDB<T>
|
|||
* @throws CancelledException if task is cancelled
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
private void checkMapVersion(int openMode, T tokenInstance, TaskMonitor monitor)
|
||||
private void checkMapVersion(OpenMode openMode, T tokenInstance, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
if (propertyTable == null) {
|
||||
return;
|
||||
|
@ -145,7 +146,7 @@ public class ObjectPropertyMapDB<T extends Saveable> extends PropertyMapDB<T>
|
|||
}
|
||||
else if (addrMap.isUpgraded() || schemaVersion < saveableObjectVersion) {
|
||||
// An older version was used to create the database
|
||||
if (openMode != DBConstants.UPGRADE) {
|
||||
if (openMode != OpenMode.UPGRADE) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
if (!upgradeTable(tokenInstance, monitor)) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.*;
|
||||
import ghidra.program.database.util.DatabaseTableUtils;
|
||||
import ghidra.program.model.address.*;
|
||||
|
@ -91,13 +92,22 @@ public abstract class PropertyMapDB<T> implements PropertyMap<T> {
|
|||
}
|
||||
}
|
||||
|
||||
void checkMapVersion(int openMode, TaskMonitor monitor)
|
||||
/**
|
||||
* Check if a table upgrade should be performed or a version error thrown.
|
||||
* @param openMode the mode that the program was openned in or null if instantiated during
|
||||
* cache invalidate. Used to detect versioning error only.
|
||||
* @param monitor task monitor
|
||||
* @throws VersionException if the database version is not the expected version.
|
||||
* @throws CancelledException if the user cancels the upgrade operation.
|
||||
* @throws IOException if an IO error occurs
|
||||
*/
|
||||
void checkMapVersion(OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
if (propertyTable != null && addrMap.isUpgraded()) {
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
upgradeTable(monitor);
|
||||
}
|
||||
else if (openMode != -1) {
|
||||
else if (openMode != null) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.util.StringPropertyMap;
|
||||
|
@ -36,7 +37,8 @@ public class StringPropertyMapDB extends PropertyMapDB<String> implements String
|
|||
/**
|
||||
* Construct an String property map.
|
||||
* @param dbHandle database handle.
|
||||
* @param openMode the mode that the program was openned in.
|
||||
* @param openMode the mode that the program was openned in or null if instantiated during
|
||||
* cache invalidate. Used to detect versioning error only.
|
||||
* @param errHandler database error handler.
|
||||
* @param changeMgr change manager for event notification
|
||||
* @param addrMap address map.
|
||||
|
@ -46,7 +48,7 @@ public class StringPropertyMapDB extends PropertyMapDB<String> implements String
|
|||
* @throws CancelledException if the user cancels the upgrade operation.
|
||||
* @throws IOException if a database io error occurs.
|
||||
*/
|
||||
public StringPropertyMapDB(DBHandle dbHandle, int openMode, ErrorHandler errHandler,
|
||||
public StringPropertyMapDB(DBHandle dbHandle, OpenMode openMode, ErrorHandler errHandler,
|
||||
ChangeManager changeMgr, AddressMap addrMap, String name, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
super(dbHandle, errHandler, changeMgr, addrMap, name);
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.help.UnsupportedOperationException;
|
|||
|
||||
import db.DBHandle;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.util.ChangeManager;
|
||||
|
@ -36,7 +37,8 @@ public class UnsupportedMapDB extends PropertyMapDB<Object> {
|
|||
/**
|
||||
* Construct a dummy property map.
|
||||
* @param dbHandle database handle.
|
||||
* @param openMode the mode that the program was openned in.
|
||||
* @param openMode the mode that the program was openned in or null if instantiated during
|
||||
* cache invalidate. Used to detect versioning error only.
|
||||
* @param errHandler database error handler.
|
||||
* @param changeMgr change manager for event notification
|
||||
* @param addrMap address map.
|
||||
|
@ -46,7 +48,7 @@ public class UnsupportedMapDB extends PropertyMapDB<Object> {
|
|||
* @throws CancelledException if the user cancels the upgrade operation.
|
||||
* @throws IOException if a database io error occurs.
|
||||
*/
|
||||
UnsupportedMapDB(DBHandle dbHandle, int openMode, ErrorHandler errHandler,
|
||||
UnsupportedMapDB(DBHandle dbHandle, OpenMode openMode, ErrorHandler errHandler,
|
||||
ChangeManager changeMgr, AddressMap addrMap, String name, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
super(dbHandle, errHandler, changeMgr, addrMap, name);
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.IOException;
|
|||
import db.DBHandle;
|
||||
import db.DBRecord;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.util.VoidPropertyMap;
|
||||
|
@ -41,7 +42,8 @@ public class VoidPropertyMapDB extends PropertyMapDB<Boolean> implements VoidPro
|
|||
/**
|
||||
* Construct an void object property map.
|
||||
* @param dbHandle database handle.
|
||||
* @param openMode the mode that the program was openned in.
|
||||
* @param openMode the mode that the program was openned in or null if instantiated during
|
||||
* cache invalidate. Used to detect versioning error only.
|
||||
* @param errHandler database error handler.
|
||||
* @param changeMgr change manager for event notification
|
||||
* @param addrMap address map.
|
||||
|
@ -51,7 +53,7 @@ public class VoidPropertyMapDB extends PropertyMapDB<Boolean> implements VoidPro
|
|||
* @throws CancelledException if the user cancels the upgrade operation.
|
||||
* @throws IOException if a database io error occurs.
|
||||
*/
|
||||
public VoidPropertyMapDB(DBHandle dbHandle, int openMode, ErrorHandler errHandler,
|
||||
public VoidPropertyMapDB(DBHandle dbHandle, OpenMode openMode, ErrorHandler errHandler,
|
||||
ChangeManager changeMgr, AddressMap addrMap, String name, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
super(dbHandle, errHandler, changeMgr, addrMap, name);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -39,11 +40,11 @@ abstract class FromAdapter implements RecordAdapter {
|
|||
static final int REF_COUNT_COL = 0;
|
||||
static final int REF_DATA_COL = 1;
|
||||
|
||||
static FromAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
static FromAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
|
||||
ErrorHandler errHandler, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new FromAdapterV0(dbHandle, true, addrMap, errHandler);
|
||||
}
|
||||
|
||||
|
@ -55,11 +56,11 @@ abstract class FromAdapter implements RecordAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
FromAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap, errHandler);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, addrMap, adapter, errHandler, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.references;
|
|||
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;
|
||||
|
@ -91,11 +92,11 @@ class OldStackRefDBAdpater {
|
|||
refTable = newRefTable;
|
||||
}
|
||||
|
||||
static OldStackRefDBAdpater getAdapter(DBHandle dbHandle, int openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
static OldStackRefDBAdpater getAdapter(DBHandle dbHandle, OpenMode openMode,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
|
||||
OldStackRefDBAdpater adapter = new OldStackRefDBAdpater(dbHandle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter.moveTable(dbHandle, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.commons.collections4.map.LazySortedMap;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.*;
|
||||
import ghidra.program.database.external.ExternalManagerDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -71,7 +72,7 @@ public class ReferenceDBManager implements ReferenceManager, ManagerDB, ErrorHan
|
|||
* @throws IOException if a database io error occurs.
|
||||
* @throws VersionException if the database version is different from the expected version
|
||||
*/
|
||||
public ReferenceDBManager(DBHandle dbHandle, AddressMap addrMap, int openMode, Lock lock,
|
||||
public ReferenceDBManager(DBHandle dbHandle, AddressMap addrMap, OpenMode openMode, Lock lock,
|
||||
TaskMonitor monitor) throws CancelledException, IOException, VersionException {
|
||||
this.addrMap = addrMap;
|
||||
this.lock = lock;
|
||||
|
@ -87,7 +88,7 @@ public class ReferenceDBManager implements ReferenceManager, ManagerDB, ErrorHan
|
|||
}
|
||||
try {
|
||||
oldStackRefAdapter = OldStackRefDBAdpater.getAdapter(dbHandle, openMode, monitor);
|
||||
if (openMode != DBConstants.UPGRADE) {
|
||||
if (openMode != OpenMode.UPGRADE) {
|
||||
// Upgrade required
|
||||
versionExc = (new VersionException(true)).combine(versionExc);
|
||||
}
|
||||
|
@ -100,7 +101,7 @@ public class ReferenceDBManager implements ReferenceManager, ManagerDB, ErrorHan
|
|||
}
|
||||
}
|
||||
|
||||
private void initializeAdapters(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
private void initializeAdapters(DBHandle handle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
VersionException versionExc = null;
|
||||
try {
|
||||
|
@ -118,7 +119,7 @@ public class ReferenceDBManager implements ReferenceManager, ManagerDB, ErrorHan
|
|||
if (versionExc != null) {
|
||||
throw versionExc;
|
||||
}
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
// Delete old table which is no longer used
|
||||
handle.deleteTable("Memory References");
|
||||
}
|
||||
|
@ -127,13 +128,13 @@ public class ReferenceDBManager implements ReferenceManager, ManagerDB, ErrorHan
|
|||
@Override
|
||||
public void setProgram(ProgramDB program) {
|
||||
this.program = program;
|
||||
symbolMgr = (SymbolManager) program.getSymbolTable();
|
||||
symbolMgr = program.getSymbolTable();
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
// Eliminate old stack references table
|
||||
processOldAdapterStackRefs(monitor);
|
||||
|
@ -773,10 +774,8 @@ public class ReferenceDBManager implements ReferenceManager, ManagerDB, ErrorHan
|
|||
int outOfScopeOffset = scope.getOutOfScopeOffset();
|
||||
|
||||
SortedMap<Address, List<Reference>> subMap = dataReferences.tailMap(minStorageAddr);
|
||||
Iterator<List<Reference>> refListIter = subMap.values().iterator();
|
||||
while (refListIter.hasNext()) {
|
||||
for (List<Reference> refList : subMap.values()) {
|
||||
|
||||
List<Reference> refList = refListIter.next();
|
||||
for (Reference ref : refList) {
|
||||
|
||||
if (ref.getToAddress().compareTo(maxStorageAddr) > 0) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -46,11 +47,11 @@ abstract class ToAdapter implements RecordAdapter {
|
|||
static final int REF_DATA_COL = 1;
|
||||
static final int REF_LEVEL_COL = 2;
|
||||
|
||||
static ToAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
static ToAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
|
||||
ErrorHandler errHandler, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new ToAdapterV1(dbHandle, true, addrMap, errHandler);
|
||||
}
|
||||
|
||||
|
@ -62,11 +63,11 @@ abstract class ToAdapter implements RecordAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
ToAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap, errHandler);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, adapter, addrMap, errHandler, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.*;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ManagerDB;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -207,10 +208,8 @@ public class OldProgramContextDB implements ProgramContext, DefaultProgramContex
|
|||
|
||||
ArrayList<RegisterValueRange> ranges = new ArrayList<RegisterValueRange>();
|
||||
|
||||
Iterator<Address> it = changePoints.iterator();
|
||||
Address currentAddress = start;
|
||||
while (it.hasNext()) {
|
||||
Address nextChange = it.next();
|
||||
for (Address nextChange : changePoints) {
|
||||
addRange(reg, ranges, currentAddress, nextChange.previous());
|
||||
currentAddress = nextChange;
|
||||
}
|
||||
|
@ -327,7 +326,7 @@ public class OldProgramContextDB implements ProgramContext, DefaultProgramContex
|
|||
}
|
||||
|
||||
@Override
|
||||
public void programReady(int openMode, int currentRevision, TaskMonitor monitor)
|
||||
public void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@ import java.io.IOException;
|
|||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
|
||||
import db.*;
|
||||
import db.DBHandle;
|
||||
import db.Table;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ManagerDB;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.code.CodeManager;
|
||||
|
@ -46,7 +48,7 @@ public class ProgramRegisterContextDB extends AbstractStoredProgramContext imple
|
|||
private boolean changing = false;
|
||||
|
||||
public ProgramRegisterContextDB(DBHandle dbHandle, ErrorHandler errHandler, Language lang,
|
||||
CompilerSpec compilerSpec, AddressMap addrMap, Lock lock, int openMode,
|
||||
CompilerSpec compilerSpec, AddressMap addrMap, Lock lock, OpenMode openMode,
|
||||
CodeManager codeMgr, TaskMonitor monitor) throws VersionException, CancelledException {
|
||||
super(lang);
|
||||
this.addrMap = addrMap;
|
||||
|
@ -56,7 +58,7 @@ public class ProgramRegisterContextDB extends AbstractStoredProgramContext imple
|
|||
|
||||
boolean oldContextDataExists = OldProgramContextDB.oldContextDataExists(dbHandle);
|
||||
boolean upgrade = oldContextDataExists && !contextDataExists(dbHandle);
|
||||
if (openMode != DBConstants.UPGRADE && upgrade) {
|
||||
if (openMode != OpenMode.UPGRADE && upgrade) {
|
||||
throw new VersionException(true);
|
||||
}
|
||||
|
||||
|
@ -69,7 +71,7 @@ public class ProgramRegisterContextDB extends AbstractStoredProgramContext imple
|
|||
upgrade(addrMap, monitor);
|
||||
}
|
||||
|
||||
if (openMode == DBConstants.UPGRADE && oldContextDataExists) {
|
||||
if (openMode == OpenMode.UPGRADE && oldContextDataExists) {
|
||||
try {
|
||||
OldProgramContextDB.removeOldContextData(dbHandle);
|
||||
}
|
||||
|
@ -185,7 +187,7 @@ public class ProgramRegisterContextDB extends AbstractStoredProgramContext imple
|
|||
}
|
||||
|
||||
@Override
|
||||
public void programReady(int openMode, int currentRevision, TaskMonitor monitor)
|
||||
public void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.*;
|
||||
|
@ -62,24 +63,22 @@ abstract class RelocationDBAdapter {
|
|||
|
||||
final static String TABLE_NAME = "Relocations";
|
||||
|
||||
final static Schema SCHEMA = new Schema(
|
||||
RelocationDBAdapterV6.VERSION, "Index",
|
||||
final static Schema SCHEMA = new Schema(RelocationDBAdapterV6.VERSION, "Index",
|
||||
new Field[] { LongField.INSTANCE, ByteField.INSTANCE, IntField.INSTANCE,
|
||||
BinaryField.INSTANCE, BinaryField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Address", "Status", "Type", "Values", "Bytes", "Symbol Name" });
|
||||
|
||||
static RelocationDBAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
static RelocationDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
try {
|
||||
return new RelocationDBAdapterV6(dbHandle, addrMap, openMode == DBConstants.CREATE);
|
||||
return new RelocationDBAdapterV6(dbHandle, addrMap, openMode == OpenMode.CREATE);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
RelocationDBAdapter adapter =
|
||||
findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
RelocationDBAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, addrMap, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
@ -131,8 +130,7 @@ abstract class RelocationDBAdapter {
|
|||
try {
|
||||
tmpHandle.startTransaction();
|
||||
|
||||
RelocationDBAdapter tmpAdapter =
|
||||
new RelocationDBAdapterV6(tmpHandle, addrMap, true);
|
||||
RelocationDBAdapter tmpAdapter = new RelocationDBAdapterV6(tmpHandle, addrMap, true);
|
||||
RecordIterator iter = oldAdapter.iterator();
|
||||
while (iter.hasNext()) {
|
||||
DBRecord rec = iter.next();
|
||||
|
@ -147,8 +145,7 @@ abstract class RelocationDBAdapter {
|
|||
|
||||
dbHandle.deleteTable(TABLE_NAME);
|
||||
|
||||
RelocationDBAdapterV6 newAdapter =
|
||||
new RelocationDBAdapterV6(dbHandle, addrMap, true);
|
||||
RelocationDBAdapterV6 newAdapter = new RelocationDBAdapterV6(dbHandle, addrMap, true);
|
||||
|
||||
iter = tmpAdapter.iterator();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -270,23 +267,23 @@ abstract class RelocationDBAdapter {
|
|||
*/
|
||||
static void preV6DataMigrationUpgrade(RelocationDBAdapter adapter, Program program,
|
||||
TaskMonitor monitor) throws IOException, CancelledException {
|
||||
|
||||
|
||||
if (!(adapter instanceof RelocationDBAdapterV6 latestAdapter)) {
|
||||
throw new AssertException("latest relocation adapter version expected");
|
||||
}
|
||||
|
||||
|
||||
AddressMap addressMap = program.getAddressMap();
|
||||
Memory memory = program.getMemory();
|
||||
AddressSetView loadedAndInitializedAddressSet = memory.getLoadedAndInitializedAddressSet();
|
||||
|
||||
|
||||
ArrayList<DBRecord> list = new ArrayList<>();
|
||||
RecordIterator recIter = latestAdapter.iterator();
|
||||
while (recIter.hasNext()) {
|
||||
list.add(recIter.next());
|
||||
}
|
||||
|
||||
|
||||
// Sort on address and key order
|
||||
Collections.sort(list, (r1,r2) -> {
|
||||
Collections.sort(list, (r1, r2) -> {
|
||||
Address a1 = addressMap.decodeAddress(r1.getLongValue(ADDR_COL));
|
||||
Address a2 = addressMap.decodeAddress(r2.getLongValue(ADDR_COL));
|
||||
int c = a1.compareTo(a2);
|
||||
|
@ -295,7 +292,7 @@ abstract class RelocationDBAdapter {
|
|||
}
|
||||
return c;
|
||||
});
|
||||
|
||||
|
||||
// Update status/length of each relocation record
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
monitor.checkCancelled();
|
||||
|
@ -320,8 +317,7 @@ abstract class RelocationDBAdapter {
|
|||
status = Status.UNKNOWN;
|
||||
}
|
||||
else {
|
||||
status = rec.getIntValue(TYPE_COL) == 0 ? Status.APPLIED_OTHER
|
||||
: Status.APPLIED;
|
||||
status = rec.getIntValue(TYPE_COL) == 0 ? Status.APPLIED_OTHER : Status.APPLIED;
|
||||
}
|
||||
}
|
||||
rec.setByteValue(FLAGS_COL, getFlags(status, byteLength));
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.database.ManagerDB;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
|
@ -60,14 +61,14 @@ public class RelocationManager implements RelocationTable, ManagerDB {
|
|||
* @throws VersionException
|
||||
* @throws IOException
|
||||
*/
|
||||
public RelocationManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock,
|
||||
public RelocationManager(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
this.addrMap = addrMap;
|
||||
this.lock = lock;
|
||||
initializeAdapters(handle, openMode, monitor);
|
||||
}
|
||||
|
||||
private void initializeAdapters(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
private void initializeAdapters(DBHandle handle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, IOException {
|
||||
adapter = RelocationDBAdapter.getAdapter(handle, openMode, addrMap, monitor);
|
||||
}
|
||||
|
@ -83,10 +84,10 @@ public class RelocationManager implements RelocationTable, 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 &&
|
||||
currentRevision < ProgramDB.RELOCATION_STATUS_ADDED_VERSION) {
|
||||
RelocationDBAdapter.preV6DataMigrationUpgrade(adapter, program, monitor);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.symbol;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.util.exception.NotFoundException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -39,10 +40,10 @@ abstract class EquateDBAdapter {
|
|||
final static int NAME_COL = 0;
|
||||
final static int VALUE_COL = 1;
|
||||
|
||||
static EquateDBAdapter getAdapter(DBHandle dbHandle, int openMode, TaskMonitor monitor)
|
||||
static EquateDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new EquateDBAdapterV0(dbHandle, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.map.AddressKeyAddressIterator;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -58,7 +59,7 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {
|
|||
* @throws VersionException if the database version doesn't match the current version.
|
||||
* @throws IOException if a database error occurs.
|
||||
*/
|
||||
public EquateManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock,
|
||||
public EquateManager(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
|
||||
this.addrMap = addrMap;
|
||||
|
@ -72,7 +73,7 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {
|
|||
return program;
|
||||
}
|
||||
|
||||
private void initializeAdapters(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
private void initializeAdapters(DBHandle handle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, IOException {
|
||||
VersionException versionExc = null;
|
||||
try {
|
||||
|
@ -98,7 +99,7 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {
|
|||
}
|
||||
|
||||
@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.symbol;
|
|||
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;
|
||||
|
@ -44,10 +45,10 @@ abstract class EquateRefDBAdapter {
|
|||
static final int OP_INDEX_COL = 2;
|
||||
static final int HASH_COL = 3;
|
||||
|
||||
static EquateRefDBAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
static EquateRefDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new EquateRefDBAdapterV1(dbHandle, addrMap, true);
|
||||
}
|
||||
|
||||
|
@ -59,11 +60,11 @@ abstract class EquateRefDBAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
EquateRefDBAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, addrMap, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.util.Set;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -43,10 +44,10 @@ abstract class LabelHistoryAdapter {
|
|||
static final int HISTORY_USER_COL = 3;
|
||||
static final int HISTORY_DATE_COL = 4;
|
||||
|
||||
static LabelHistoryAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
static LabelHistoryAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new LabelHistoryAdapterV0(dbHandle, true);
|
||||
}
|
||||
|
||||
|
@ -58,11 +59,11 @@ abstract class LabelHistoryAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
LabelHistoryAdapter adapter = findReadOnlyAdapter(dbHandle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = LabelHistoryAdapterV0.upgrade(dbHandle, addrMap, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.*;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ManagerDB;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -57,7 +58,7 @@ public class NamespaceManager implements ManagerDB {
|
|||
* @throws VersionException if the table version is different from this adapter.
|
||||
*/
|
||||
public NamespaceManager(DBHandle handle, ErrorHandler errHandler, AddressMap addrMap,
|
||||
int openMode, Lock lock, TaskMonitor monitor) throws VersionException {
|
||||
OpenMode openMode, Lock lock, TaskMonitor monitor) throws VersionException {
|
||||
|
||||
this.errHandler = errHandler;
|
||||
this.addrMap = addrMap;
|
||||
|
@ -97,12 +98,12 @@ public class NamespaceManager implements ManagerDB {
|
|||
|
||||
@Override
|
||||
public void setProgram(ProgramDB program) {
|
||||
this.symbolMgr = (SymbolManager) program.getSymbolTable();
|
||||
this.symbolMgr = program.getSymbolTable();
|
||||
globalNamespace = program.getGlobalNamespace();
|
||||
}
|
||||
|
||||
@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
|
||||
}
|
||||
|
@ -114,6 +115,7 @@ public class NamespaceManager implements ManagerDB {
|
|||
|
||||
/**
|
||||
* Get the global namespace.
|
||||
* @return global namespace
|
||||
*/
|
||||
public Namespace getGlobalNamespace() {
|
||||
return globalNamespace;
|
||||
|
@ -123,8 +125,10 @@ public class NamespaceManager implements ManagerDB {
|
|||
* Sets the body of a namespace.
|
||||
* @param namespace the namespace whose body is to be modified.
|
||||
* @param set the address set for the new body.
|
||||
* @throws OverlappingNamespaceException if specified set overlaps another namespace
|
||||
*/
|
||||
public void setBody(Namespace namespace, AddressSetView set) throws OverlappingNamespaceException {
|
||||
public void setBody(Namespace namespace, AddressSetView set)
|
||||
throws OverlappingNamespaceException {
|
||||
if (set.getNumAddresses() > Integer.MAX_VALUE) {
|
||||
throw new IllegalArgumentException(
|
||||
"Namespace body size must be less than 0x7fffffff byte addresses");
|
||||
|
@ -135,7 +139,8 @@ public class NamespaceManager implements ManagerDB {
|
|||
AddressRange range = overlapsNamespace(set);
|
||||
if (range != null) {
|
||||
doSetBody(namespace, oldBody);
|
||||
throw new OverlappingNamespaceException(range.getMinAddress(), range.getMaxAddress());
|
||||
throw new OverlappingNamespaceException(range.getMinAddress(),
|
||||
range.getMaxAddress());
|
||||
}
|
||||
doSetBody(namespace, set);
|
||||
}
|
||||
|
@ -157,6 +162,7 @@ public class NamespaceManager implements ManagerDB {
|
|||
/**
|
||||
* Removes any associated body with the given namespace.
|
||||
* @param namespace the namespace whose body is to be cleared.
|
||||
* @return old body
|
||||
*/
|
||||
public AddressSetView removeBody(Namespace namespace) {
|
||||
lock.acquire();
|
||||
|
@ -180,6 +186,8 @@ public class NamespaceManager implements ManagerDB {
|
|||
* in a defined namespace (e.g., Function), the global namespace is
|
||||
* returned.
|
||||
* @param addr the address for which to find a namespace.
|
||||
* @return namespace which contains address or the
|
||||
* {@link #getGlobalNamespace() global namespace} if a specific namespace not found.
|
||||
*/
|
||||
public Namespace getNamespaceContaining(Address addr) {
|
||||
Field field = namespaceMap.getValue(addr);
|
||||
|
@ -198,13 +206,14 @@ public class NamespaceManager implements ManagerDB {
|
|||
/**
|
||||
* Checks if an existing namespace's address set intersects with
|
||||
* the given set. If so, return the first overlapping range.
|
||||
* @returns null if no overlaps, or an address range of the first overlap
|
||||
* @param set address set to check for intersection
|
||||
* @return null if no overlaps, or an address range of the first overlap
|
||||
*/
|
||||
public AddressRange overlapsNamespace(AddressSetView set) {
|
||||
AddressRangeIterator addressRanges = set.getAddressRanges();
|
||||
for (AddressRange addressRange : addressRanges) {
|
||||
AddressRangeIterator namesSpaceRanges = namespaceMap.getAddressRanges(
|
||||
addressRange.getMinAddress(), addressRange.getMaxAddress());
|
||||
AddressRangeIterator namesSpaceRanges = namespaceMap
|
||||
.getAddressRanges(addressRange.getMinAddress(), addressRange.getMaxAddress());
|
||||
AddressRange existingRange = namesSpaceRanges.next();
|
||||
if (existingRange != null) {
|
||||
return existingRange;
|
||||
|
@ -260,6 +269,7 @@ public class NamespaceManager implements ManagerDB {
|
|||
/**
|
||||
* Gets the body for the given namespace.
|
||||
* @param namespace the namespace for which to get its body.
|
||||
* @return body for the given namespace
|
||||
*/
|
||||
public AddressSetView getAddressSet(Namespace namespace) {
|
||||
lock.acquire();
|
||||
|
@ -267,6 +277,9 @@ public class NamespaceManager implements ManagerDB {
|
|||
if (namespace == lastBodyNamespace) {
|
||||
return lastBody;
|
||||
}
|
||||
|
||||
symbolMgr.checkValidNamespaceArgument(namespace);
|
||||
|
||||
AddressSetView mySet = getAddressSet(namespace.getID());
|
||||
AddressSet set = new AddressSet(mySet);
|
||||
SymbolIterator it = symbolMgr.getSymbols(namespace);
|
||||
|
@ -335,9 +348,8 @@ public class NamespaceManager implements ManagerDB {
|
|||
monitor.checkCancelled();
|
||||
namespaceMap.clearRange(fromAddr, rangeEnd);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
for (NamespaceHolder h : list) {
|
||||
monitor.checkCancelled();
|
||||
NamespaceHolder h = list.get(i);
|
||||
namespaceMap.paintRange(h.range.getMinAddress(), h.range.getMaxAddress(),
|
||||
new LongField(h.namespaceID));
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.database.util.*;
|
||||
import ghidra.program.model.address.*;
|
||||
|
@ -61,7 +62,7 @@ abstract class SymbolDatabaseAdapter {
|
|||
/**
|
||||
* Gets a new SymbolDatabaseAdapter
|
||||
* @param dbHandle the database handle
|
||||
* @param openMode the open mode. See {@link DBConstants}
|
||||
* @param openMode the open mode
|
||||
* @param addrMap the address map
|
||||
* @param monitor the progress monitor
|
||||
* @return a new SymbolDatabaseAdapter
|
||||
|
@ -69,10 +70,11 @@ abstract class SymbolDatabaseAdapter {
|
|||
* @throws CancelledException if the user cancels an upgrade
|
||||
* @throws IOException if a database io error occurs
|
||||
*/
|
||||
static SymbolDatabaseAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
|
||||
static SymbolDatabaseAdapter getAdapter(DBHandle dbHandle, OpenMode openMode,
|
||||
AddressMap addrMap, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new SymbolDatabaseAdapterV3(dbHandle, addrMap, true);
|
||||
}
|
||||
|
||||
|
@ -81,11 +83,11 @@ abstract class SymbolDatabaseAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
SymbolDatabaseAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = upgrade(dbHandle, addrMap, adapter, monitor);
|
||||
}
|
||||
else if (adapter instanceof SymbolDatabaseAdapterV0) {
|
||||
|
@ -138,8 +140,7 @@ abstract class SymbolDatabaseAdapter {
|
|||
|
||||
dbHandle.deleteTable(SYMBOL_TABLE_NAME);
|
||||
|
||||
SymbolDatabaseAdapter newAdapter =
|
||||
new SymbolDatabaseAdapterV3(dbHandle, addrMap, true);
|
||||
SymbolDatabaseAdapter newAdapter = new SymbolDatabaseAdapterV3(dbHandle, addrMap, true);
|
||||
|
||||
copyTempToNewAdapter(tmpAdapter, newAdapter, monitor);
|
||||
return newAdapter;
|
||||
|
@ -308,8 +309,7 @@ abstract class SymbolDatabaseAdapter {
|
|||
* @return a record iterator for all symbols in the range
|
||||
* @throws IOException if a database io error occurs
|
||||
*/
|
||||
abstract RecordIterator getSymbols(AddressSetView set, boolean forward)
|
||||
throws IOException;
|
||||
abstract RecordIterator getSymbols(AddressSetView set, boolean forward) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an iterator over the primary symbols in the given range
|
||||
|
@ -421,8 +421,7 @@ abstract class SymbolDatabaseAdapter {
|
|||
* @param addressKey the encoded address
|
||||
* @return a database Long field containing the computed hash
|
||||
*/
|
||||
protected static LongField computeLocatorHash(String name, long namespaceID,
|
||||
long addressKey) {
|
||||
protected static LongField computeLocatorHash(String name, long namespaceID, long addressKey) {
|
||||
// Default functions have no name, no point in storing a hash for those.
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
return null;
|
||||
|
@ -437,8 +436,8 @@ abstract class SymbolDatabaseAdapter {
|
|||
|
||||
// This wraps a record iterator to make sure it only returns records for symbols that match
|
||||
// the given name and name space.
|
||||
protected static RecordIterator getNameAndNamespaceFilterIterator(String name,
|
||||
long namespaceId, RecordIterator it) {
|
||||
protected static RecordIterator getNameAndNamespaceFilterIterator(String name, long namespaceId,
|
||||
RecordIterator it) {
|
||||
Query nameQuery = new FieldMatchQuery(SYMBOL_NAME_COL, new StringField(name));
|
||||
Query namespaceQuery = new FieldMatchQuery(SYMBOL_PARENT_COL, new LongField(namespaceId));
|
||||
Query nameAndNamespaceQuery = new AndQuery(nameQuery, namespaceQuery);
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.*;
|
||||
import ghidra.program.database.code.CodeManager;
|
||||
import ghidra.program.database.external.ExternalManagerDB;
|
||||
|
@ -90,8 +91,8 @@ public class SymbolManager implements SymbolTable, ManagerDB {
|
|||
* @throws IOException if a database io error occurs.
|
||||
* @throws VersionException if the database version doesn't match the current version.
|
||||
*/
|
||||
public SymbolManager(DBHandle handle, AddressMap addrMap, int openMode, ErrorHandler errHandler,
|
||||
Lock lock, TaskMonitor monitor)
|
||||
public SymbolManager(DBHandle handle, AddressMap addrMap, OpenMode openMode,
|
||||
ErrorHandler errHandler, Lock lock, TaskMonitor monitor)
|
||||
throws CancelledException, IOException, VersionException {
|
||||
|
||||
this.addrMap = addrMap;
|
||||
|
@ -104,13 +105,13 @@ public class SymbolManager implements SymbolTable, ManagerDB {
|
|||
variableStorageMgr =
|
||||
new VariableStorageManagerDB(handle, addrMap, openMode, errHandler, lock, monitor);
|
||||
|
||||
if (openMode == DBConstants.UPGRADE &&
|
||||
if (openMode == OpenMode.UPGRADE &&
|
||||
OldVariableStorageManagerDB.isOldVariableStorageManagerUpgradeRequired(handle)) {
|
||||
oldVariableStorageMgr = new OldVariableStorageManagerDB(handle, addrMap, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeAdapters(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
private void initializeAdapters(DBHandle handle, OpenMode openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
VersionException versionExc = null;
|
||||
try {
|
||||
|
@ -150,10 +151,10 @@ public class SymbolManager implements SymbolTable, 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) {
|
||||
processOldLocalSymbols(monitor);
|
||||
processOldExternalEntryPoints(monitor);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.symbol;
|
|||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.*;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -44,10 +45,11 @@ abstract class VariableStorageDBAdapter {
|
|||
* @throws CancelledException if the user cancels an upgrade.
|
||||
* @throws IOException if a database io error occurs.
|
||||
*/
|
||||
static VariableStorageDBAdapter getAdapter(DBHandle dbHandle, int openMode, AddressMap addrMap,
|
||||
TaskMonitor monitor) throws VersionException, IOException, CancelledException {
|
||||
static VariableStorageDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode,
|
||||
AddressMap addrMap, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
return new VariableStorageDBAdapterV2(dbHandle, true);
|
||||
}
|
||||
|
||||
|
@ -56,11 +58,11 @@ abstract class VariableStorageDBAdapter {
|
|||
return adapter;
|
||||
}
|
||||
catch (VersionException e) {
|
||||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
if (!e.isUpgradable() || openMode == OpenMode.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
VariableStorageDBAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap, openMode);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
VariableStorageDBAdapter adapter = findReadOnlyAdapter(dbHandle, addrMap);
|
||||
if (openMode == OpenMode.UPGRADE) {
|
||||
adapter = VariableStorageDBAdapterV2.upgrade(dbHandle, adapter, monitor);
|
||||
}
|
||||
return adapter;
|
||||
|
@ -68,7 +70,7 @@ abstract class VariableStorageDBAdapter {
|
|||
}
|
||||
|
||||
private static VariableStorageDBAdapter findReadOnlyAdapter(DBHandle dbHandle,
|
||||
AddressMap addrMap, int openMode) {
|
||||
AddressMap addrMap) {
|
||||
Table table = dbHandle.getTable(VARIABLE_STORAGE_TABLE_NAME);
|
||||
if (table == null) {
|
||||
return new VariableStorageDBAdapterNoTable();
|
||||
|
@ -82,9 +84,9 @@ abstract class VariableStorageDBAdapter {
|
|||
|
||||
/**
|
||||
* Locate the record key which corresponds to the specified hash value.
|
||||
* @param hash
|
||||
* @param hash record hash value
|
||||
* @return record key or -1 if not found
|
||||
* @throws IOException
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract long findRecordKey(long hash) throws IOException;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.DatabaseObject;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
|
@ -60,7 +61,7 @@ public class VariableStorageManagerDB implements VariableStorageManager {
|
|||
* @throws IOException if an IO error occurs
|
||||
* @throws CancelledException if the user cancels the upgrade.
|
||||
*/
|
||||
public VariableStorageManagerDB(DBHandle handle, AddressMap addrMap, int openMode,
|
||||
public VariableStorageManagerDB(DBHandle handle, AddressMap addrMap, OpenMode openMode,
|
||||
ErrorHandler errorHandler, Lock lock, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
this.errorHandler = errorHandler;
|
||||
|
|
|
@ -67,6 +67,7 @@ public final class BuiltInDataTypeManager extends StandAloneDataTypeManager {
|
|||
private BuiltInDataTypeManager() {
|
||||
super(BUILT_IN_DATA_TYPES_NAME);
|
||||
initialize();
|
||||
setImmutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,8 +18,8 @@ package ghidra.program.model.data;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import db.DBConstants;
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.store.db.PackedDBHandle;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
import ghidra.program.model.lang.CompilerSpec;
|
||||
|
@ -61,18 +61,21 @@ public class FileDataTypeManager extends StandAloneDataTypeManager
|
|||
* with a warning condition, architecture-specific data may not be available or up-to-date.
|
||||
*
|
||||
* @param packedDbfile file to load or create based upon openMode
|
||||
* @param openMode one of the DBConstants: CREATE, READ_ONLY or UPDATE
|
||||
* @param openMode CREATE, READ_ONLY or UPDATE
|
||||
* @param monitor the progress monitor
|
||||
* @throws IOException if an IO error occurs
|
||||
* @throws CancelledException if task cancelled
|
||||
*/
|
||||
private FileDataTypeManager(ResourceFile packedDbfile, int openMode, TaskMonitor monitor)
|
||||
private FileDataTypeManager(ResourceFile packedDbfile, OpenMode openMode, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
super(validateFilename(packedDbfile), openMode, monitor);
|
||||
file = packedDbfile;
|
||||
name = getRootName(file.getName());
|
||||
packedDB = ((PackedDBHandle) dbHandle).getPackedDatabase();
|
||||
logWarning();
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
setImmutable();
|
||||
}
|
||||
}
|
||||
|
||||
private static ResourceFile validateFilename(ResourceFile packedDbfile) {
|
||||
|
@ -90,7 +93,7 @@ public class FileDataTypeManager extends StandAloneDataTypeManager
|
|||
*/
|
||||
public static FileDataTypeManager createFileArchive(File packedDbfile) throws IOException {
|
||||
try {
|
||||
return new FileDataTypeManager(new ResourceFile(packedDbfile), DBConstants.CREATE,
|
||||
return new FileDataTypeManager(new ResourceFile(packedDbfile), OpenMode.CREATE,
|
||||
TaskMonitor.DUMMY);
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
|
@ -137,7 +140,7 @@ public class FileDataTypeManager extends StandAloneDataTypeManager
|
|||
*/
|
||||
public static FileDataTypeManager openFileArchive(ResourceFile packedDbfile,
|
||||
boolean openForUpdate) throws IOException {
|
||||
int mode = openForUpdate ? DBConstants.UPDATE : DBConstants.READ_ONLY;
|
||||
OpenMode mode = openForUpdate ? OpenMode.UPDATE : OpenMode.IMMUTABLE;
|
||||
try {
|
||||
return new FileDataTypeManager(packedDbfile, mode, TaskMonitor.DUMMY);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ package ghidra.program.model.data;
|
|||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.help.UnsupportedOperationException;
|
||||
|
||||
|
@ -26,7 +27,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import generic.jar.ResourceFile;
|
||||
import generic.stl.Pair;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.model.RuntimeIOException;
|
||||
import ghidra.framework.store.LockException;
|
||||
import ghidra.program.database.DBStringMapAdapter;
|
||||
|
@ -55,6 +56,7 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
private int transactionCount;
|
||||
private Long transaction;
|
||||
private boolean commitTransaction;
|
||||
private boolean isImmutable;
|
||||
|
||||
private LanguageTranslator languageUpgradeTranslator;
|
||||
private String programArchitectureSummary; // summary of expected program architecture
|
||||
|
@ -170,13 +172,13 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
* may be appropriate to use {@link #getWarning() check for warnings} prior to use.
|
||||
*
|
||||
* @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 the progress 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 StandAloneDataTypeManager(ResourceFile packedDbfile, int openMode,
|
||||
protected StandAloneDataTypeManager(ResourceFile packedDbfile, OpenMode openMode,
|
||||
TaskMonitor monitor) throws IOException, CancelledException {
|
||||
super(packedDbfile, openMode, monitor);
|
||||
}
|
||||
|
@ -190,7 +192,7 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
* may be appropriate to use {@link #getWarning() check for warnings} prior to use.
|
||||
*
|
||||
* @param handle open database handle
|
||||
* @param openMode open mode CREATE, READ_ONLY or UPDATE (see {@link DBConstants})
|
||||
* @param openMode open mode CREATE, READ_ONLY or UPDATE
|
||||
* @param errHandler the database I/O error handler
|
||||
* @param lock the program synchronization lock
|
||||
* @param monitor the progress monitor
|
||||
|
@ -198,15 +200,23 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
* @throws VersionException if the database does not match the expected version.
|
||||
* @throws IOException if a database I/O error occurs.
|
||||
*/
|
||||
protected StandAloneDataTypeManager(DBHandle handle, int openMode, ErrorHandler errHandler,
|
||||
protected StandAloneDataTypeManager(DBHandle handle, OpenMode openMode, ErrorHandler errHandler,
|
||||
Lock lock, TaskMonitor monitor)
|
||||
throws CancelledException, VersionException, IOException {
|
||||
super(handle, null, openMode, null, errHandler, lock, monitor);
|
||||
if (openMode != DBConstants.CREATE && hasDataOrganizationChange(true)) {
|
||||
if (openMode != OpenMode.CREATE && hasDataOrganizationChange(true)) {
|
||||
handleDataOrganizationChange(openMode, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set instance as immutable by disabling use of transactions. Attempts to start a transaction
|
||||
* will result in a {@link TerminatedTransactionException}.
|
||||
*/
|
||||
protected void setImmutable() {
|
||||
isImmutable = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link ArchiveWarning} which may have occured immediately following
|
||||
* instatiation of this {@link StandAloneDataTypeManager}. {@link ArchiveWarning#NONE}
|
||||
|
@ -303,11 +313,11 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void initializeOtherAdapters(int openMode, TaskMonitor monitor)
|
||||
protected void initializeOtherAdapters(OpenMode openMode, TaskMonitor monitor)
|
||||
throws CancelledException, IOException, VersionException {
|
||||
|
||||
warning = ArchiveWarning.NONE;
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
if (openMode == OpenMode.CREATE) {
|
||||
saveDataOrganization(); // save default dataOrg
|
||||
return; // optional program architecture is set after initialization is complete
|
||||
}
|
||||
|
@ -372,12 +382,12 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
languageUpgradeTranslator = languageVersionExc.getLanguageTranslator();
|
||||
|
||||
// language upgrade required
|
||||
if (openMode == DBConstants.READ_ONLY) {
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
// read-only mode - do not set program architecture - upgrade flag has been set
|
||||
return;
|
||||
}
|
||||
|
||||
if (openMode == DBConstants.UPDATE) {
|
||||
if (openMode == OpenMode.UPDATE) {
|
||||
throw languageVersionExc;
|
||||
}
|
||||
|
||||
|
@ -442,9 +452,9 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void handleDataOrganizationChange(int openMode, TaskMonitor monitor)
|
||||
protected void handleDataOrganizationChange(OpenMode openMode, TaskMonitor monitor)
|
||||
throws LanguageVersionException, CancelledException, IOException {
|
||||
if (openMode == DBConstants.READ_ONLY) {
|
||||
if (openMode == OpenMode.IMMUTABLE) {
|
||||
warning = ArchiveWarning.DATA_ORG_CHANGED;
|
||||
}
|
||||
super.handleDataOrganizationChange(openMode, monitor);
|
||||
|
@ -505,8 +515,8 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
|
||||
if (variableStorageMgr == null) { // TODO: may re-use if translation performed
|
||||
try {
|
||||
variableStorageMgr = new VariableStorageManagerDB(dbHandle, null,
|
||||
DBConstants.CREATE, errHandler, lock, TaskMonitor.DUMMY);
|
||||
variableStorageMgr = new VariableStorageManagerDB(dbHandle, null, OpenMode.CREATE,
|
||||
errHandler, lock, TaskMonitor.DUMMY);
|
||||
variableStorageMgr.setProgramArchitecture(programArchitecture);
|
||||
}
|
||||
catch (VersionException | CancelledException e) {
|
||||
|
@ -693,7 +703,7 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
if (VariableStorageManagerDB.exists(dbHandle)) {
|
||||
try {
|
||||
variableStorageMgr = new VariableStorageManagerDB(dbHandle, null,
|
||||
DBConstants.UPDATE, errHandler, lock, monitor);
|
||||
OpenMode.UPDATE, errHandler, lock, monitor);
|
||||
}
|
||||
catch (VersionException e) {
|
||||
throw new IOException(
|
||||
|
@ -835,6 +845,9 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
|
|||
|
||||
@Override
|
||||
public synchronized int startTransaction(String description) {
|
||||
if (isImmutable) {
|
||||
throw new TerminatedTransactionException("Transaction not permitted: read-only");
|
||||
}
|
||||
if (transaction == null) {
|
||||
transaction = dbHandle.startTransaction();
|
||||
commitTransaction = true;
|
||||
|
|
|
@ -22,9 +22,11 @@ import java.util.List;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import db.*;
|
||||
import db.DBBuffer;
|
||||
import db.DBHandle;
|
||||
import db.buffers.BufferFile;
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.framework.store.db.PrivateDatabase;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.model.lang.*;
|
||||
|
@ -269,7 +271,7 @@ public class FileBytesTest extends AbstractGenericTest {
|
|||
|
||||
private Program restoreProgram(PrivateDatabase db) throws Exception {
|
||||
DBHandle dbh = db.open(TaskMonitor.DUMMY);
|
||||
return new ProgramDB(dbh, DBConstants.UPDATE, null, this);
|
||||
return new ProgramDB(dbh, OpenMode.UPDATE, null, this);
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import db.DBConstants;
|
||||
import db.DBHandle;
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
|
@ -58,9 +57,7 @@ public class MemBlockDBTest extends AbstractGenericTest {
|
|||
addressFactory = language.getAddressFactory();
|
||||
AddressMapDB addrMap = program.getAddressMap();
|
||||
Lock lock = new Lock("Test");
|
||||
int openMode = DBConstants.CREATE;
|
||||
mem = new MemoryMapDB(handle, addrMap, openMode, true, lock);
|
||||
|
||||
mem = new MemoryMapDB(handle, addrMap, true, lock);
|
||||
MemoryMapDBAdapter adapter =
|
||||
new MemoryMapDBAdapterV3(handle, mem, MAX_SUB_BLOCK_SIZE, true);
|
||||
FileBytesAdapter fileBytesAdapter = new FileBytesAdapterV0(handle, true);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.framework.data.OpenMode;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.function.OverlappingFunctionException;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -151,7 +152,7 @@ public class StubFunctionManager 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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue