mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GT-3294 Added support for DB FixedField with improved indexing.
This commit is contained in:
parent
14d4c87ef4
commit
fcb3151f94
224 changed files with 9574 additions and 7913 deletions
|
@ -158,6 +158,7 @@ public class DBObjectCache<T extends DatabaseObject> {
|
|||
* within the specified keyRanges.
|
||||
* @param keyRanges key ranges to delete
|
||||
*/
|
||||
//TODO: Discourage large cases by only allowing a single range to be specified
|
||||
public synchronized void delete(List<KeyRange> keyRanges) {
|
||||
hardCache.clear();
|
||||
processQueue();
|
||||
|
|
|
@ -45,8 +45,11 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB
|
|||
* database schema associated with any of the managers.
|
||||
* 18-Sep-2008 - version 1 - added fields for synchronizing program data types with project archives.
|
||||
* 03-Dec-2009 - version 2 - Added source archive updating (consolidating windows.gdt, clib.gdt, ntddk.gdt)
|
||||
* 14-Nov-2019 - version 3 - Corrected fixed length indexing implementation causing
|
||||
* change in index table low-level storage for newly
|
||||
* created tables.
|
||||
*/
|
||||
static final int DB_VERSION = 2;
|
||||
static final int DB_VERSION = 3;
|
||||
|
||||
/**
|
||||
* UPGRADE_REQUIRED_BEFORE_VERSION should be changed to DB_VERSION any time the
|
||||
|
@ -76,10 +79,10 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB
|
|||
|
||||
private static final String DEFAULT_POINTER_SIZE = "Default Pointer Size";
|
||||
|
||||
private final static Class<?>[] COL_CLASS = new Class[] { StringField.class };
|
||||
private final static Field[] COL_FIELDS = new Field[] { StringField.INSTANCE };
|
||||
private final static String[] COL_TYPES = new String[] { "Value" };
|
||||
private final static Schema SCHEMA =
|
||||
new Schema(0, StringField.class, "Key", COL_CLASS, COL_TYPES);
|
||||
new Schema(0, StringField.INSTANCE, "Key", COL_FIELDS, COL_TYPES);
|
||||
|
||||
private ProjectDataTypeManager dataTypeManager;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import ghidra.program.model.listing.DataTypeArchiveChangeSet;
|
|||
class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObjectDBChangeSet {
|
||||
|
||||
private static final Schema STORED_ID_SCHEMA =
|
||||
new Schema(0, "Key", new Class[] { LongField.class }, new String[] { "value" });
|
||||
new Schema(0, "Key", new Field[] { LongField.INSTANCE }, new String[] { "value" });
|
||||
|
||||
private static final String DATATYPE_ADDITIONS = "DataType Additions";
|
||||
private static final String DATATYPE_CHANGES = "DataType Changes";
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.database.util.AddressRangeMapDB;
|
||||
import ghidra.program.model.address.*;
|
||||
|
@ -25,11 +28,6 @@ import ghidra.util.exception.CancelledException;
|
|||
import ghidra.util.exception.DuplicateNameException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
|
||||
public class IntRangeMapDB implements IntRangeMap {
|
||||
|
||||
private static final String MY_PREFIX = "IntMap - ";
|
||||
|
@ -65,8 +63,8 @@ public class IntRangeMapDB implements IntRangeMap {
|
|||
DBHandle dbh = program.getDBHandle();
|
||||
String tableName = TABLE_PREFIX + mapName;
|
||||
if (dbh.getTable(tableName) != null) {
|
||||
throw new DuplicateNameException("Address Set Property Map named " + mapName +
|
||||
" already exists.");
|
||||
throw new DuplicateNameException(
|
||||
"Address Set Property Map named " + mapName + " already exists.");
|
||||
}
|
||||
|
||||
return new IntRangeMapDB(program, mapName, program, addrMap, lock);
|
||||
|
@ -82,9 +80,8 @@ public class IntRangeMapDB implements IntRangeMap {
|
|||
this.mapName = mapName;
|
||||
this.lock = lock;
|
||||
|
||||
propertyMap =
|
||||
new AddressRangeMapDB(program.getDBHandle(), program.getAddressMap(),
|
||||
program.getLock(), MY_PREFIX + mapName, errHandler, IntField.class, true);
|
||||
propertyMap = new AddressRangeMapDB(program.getDBHandle(), program.getAddressMap(),
|
||||
program.getLock(), MY_PREFIX + mapName, errHandler, IntField.INSTANCE, true);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ import ghidra.util.exception.DuplicateNameException;
|
|||
class OverlaySpaceAdapterDB {
|
||||
private static String TABLE_NAME = "Overlay Spaces";
|
||||
static final Schema SCHEMA = new Schema(0, "ID",
|
||||
new Class[] { StringField.class, StringField.class, LongField.class, LongField.class },
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE,
|
||||
LongField.INSTANCE },
|
||||
new String[] { "Overlay Space", "Template Space", "Minimum Offset", "Maximum Offset" });
|
||||
|
||||
private static final int OV_SPACE_NAME_COL = 0;
|
||||
|
|
|
@ -93,8 +93,11 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
* Read of old symbol data3 format does not require upgrade.
|
||||
* 14-May-2020 - version 21 - added support for overlay mapped blocks and byte mapping
|
||||
* schemes other than the default 1:1
|
||||
* 19-Jun-2020 - version 22 - Corrected fixed length indexing implementation causing
|
||||
* change in index table low-level storage for newly
|
||||
* created tables.
|
||||
*/
|
||||
static final int DB_VERSION = 21;
|
||||
static final int DB_VERSION = 22;
|
||||
|
||||
/**
|
||||
* UPGRADE_REQUIRED_BFORE_VERSION should be changed to DB_VERSION anytime the
|
||||
|
@ -133,10 +136,10 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
private static final String EXECUTE_FORMAT = "Execute Format";
|
||||
private static final String IMAGE_OFFSET = "Image Offset";
|
||||
|
||||
private final static Class<?>[] COL_CLASS = new Class[] { StringField.class };
|
||||
private final static Field[] COL_FIELDS = new Field[] { StringField.INSTANCE };
|
||||
private final static String[] COL_TYPES = new String[] { "Value" };
|
||||
private final static Schema SCHEMA =
|
||||
new Schema(0, StringField.class, "Key", COL_CLASS, COL_TYPES);
|
||||
new Schema(0, StringField.INSTANCE, "Key", COL_FIELDS, COL_TYPES);
|
||||
|
||||
//
|
||||
// The numbering of managers controls the order in which they are notified.
|
||||
|
|
|
@ -34,10 +34,10 @@ import ghidra.program.model.listing.ProgramChangeSet;
|
|||
class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
|
||||
|
||||
private static final Schema STORED_ID_SCHEMA =
|
||||
new Schema(0, "Key", new Class[] { LongField.class }, new String[] { "value" });
|
||||
new Schema(0, "Key", new Field[] { LongField.INSTANCE }, new String[] { "value" });
|
||||
|
||||
private static final Schema STORED_ADDRESS_RANGE_SCHEMA = new Schema(0, "Key",
|
||||
new Class[] { LongField.class, LongField.class }, new String[] { "addr1", "addr2" });
|
||||
new Field[] { LongField.INSTANCE, LongField.INSTANCE }, new String[] { "addr1", "addr2" });
|
||||
|
||||
private static final String DATATYPE_ADDITIONS = "DataType Additions";
|
||||
private static final String DATATYPE_CHANGES = "DataType Changes";
|
||||
|
|
|
@ -51,7 +51,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
* DB_VERSION should be incremented any time a change is made to the overall
|
||||
* database schema associated with any of the managers.
|
||||
*/
|
||||
static final int DB_VERSION = 1;
|
||||
static final int DB_VERSION = 2;
|
||||
|
||||
/**
|
||||
* UPGRADE_REQUIRED_BFORE_VERSION should be changed to DB_VERSION any time the
|
||||
|
@ -59,13 +59,13 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
* until upgrade is performed). It is assumed that read-only mode is supported
|
||||
* if the data's version is >= UPGRADE_REQUIRED_BEFORE_VERSION and <= DB_VERSION.
|
||||
*/
|
||||
private static final int UPGRADE_REQUIRED_BEFORE_VERSION = 1;
|
||||
private static final int UPGRADE_REQUIRED_BEFORE_VERSION = 2;
|
||||
|
||||
private static final String TABLE_NAME = "ProgramUserData";
|
||||
private final static Class<?>[] COL_CLASS = new Class[] { StringField.class };
|
||||
private final static Field[] COL_FIELDS = new Field[] { StringField.INSTANCE };
|
||||
private final static String[] COL_NAMES = new String[] { "Value" };
|
||||
private final static Schema SCHEMA =
|
||||
new Schema(0, StringField.class, "Key", COL_CLASS, COL_NAMES);
|
||||
new Schema(0, StringField.INSTANCE, "Key", COL_FIELDS, COL_NAMES);
|
||||
private static final int VALUE_COL = 0;
|
||||
|
||||
private static final String STORED_DB_VERSION = "DB Version";
|
||||
|
@ -73,12 +73,12 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
private static final String LANGUAGE_ID = "Language ID";
|
||||
|
||||
private static final String REGISTRY_TABLE_NAME = "PropertyRegistry";
|
||||
private final static Class<?>[] REGISTRY_COL_CLASS =
|
||||
new Class[] { StringField.class, StringField.class, IntField.class, StringField.class };
|
||||
private final static Field[] REGISTRY_COL_FIELDS = new Field[] { StringField.INSTANCE,
|
||||
StringField.INSTANCE, IntField.INSTANCE, StringField.INSTANCE };
|
||||
private final static String[] REGISTRY_COL_NAMES =
|
||||
new String[] { "Owner", "PropertyName", "PropertyType", "SaveableClass" };
|
||||
private final static Schema REGISTRY_SCHEMA =
|
||||
new Schema(0, "ID", REGISTRY_COL_CLASS, REGISTRY_COL_NAMES);
|
||||
new Schema(0, "ID", REGISTRY_COL_FIELDS, REGISTRY_COL_NAMES);
|
||||
private static final int PROPERTY_OWNER_COL = 0;
|
||||
private static final int PROPERTY_NAME_COL = 1;
|
||||
private static final int PROPERTY_TYPE_COL = 2;
|
||||
|
@ -467,7 +467,8 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
Class<?> saveableClass, boolean create) throws PropertyTypeMismatchException {
|
||||
|
||||
try {
|
||||
for (long key : registryTable.findRecords(new StringField(owner), PROPERTY_OWNER_COL)) {
|
||||
for (Field key : registryTable.findRecords(new StringField(owner),
|
||||
PROPERTY_OWNER_COL)) {
|
||||
Record rec = registryTable.getRecord(key);
|
||||
if (propertyName.equals(rec.getString(PROPERTY_NAME_COL))) {
|
||||
int type = rec.getIntValue(PROPERTY_TYPE_COL);
|
||||
|
@ -573,7 +574,8 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
|||
public synchronized List<PropertyMap> getProperties(String owner) {
|
||||
List<PropertyMap> list = new ArrayList<PropertyMap>();
|
||||
try {
|
||||
for (long key : registryTable.findRecords(new StringField(owner), PROPERTY_OWNER_COL)) {
|
||||
for (Field key : registryTable.findRecords(new StringField(owner),
|
||||
PROPERTY_OWNER_COL)) {
|
||||
Record rec = registryTable.getRecord(key);
|
||||
list.add(getPropertyMap(rec));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,15 +15,14 @@
|
|||
*/
|
||||
package ghidra.program.database.bookmark;
|
||||
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.database.util.EmptyRecordIterator;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.database.util.EmptyRecordIterator;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
|
||||
|
||||
|
@ -35,8 +33,9 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
|
|||
static final int V3_COMMENT_COL = 2;
|
||||
|
||||
static final int VERSION = 3;
|
||||
static final Schema V3_SCHEMA = new Schema(VERSION, "ID", new Class[] { LongField.class,
|
||||
StringField.class, StringField.class }, new String[] { "Address", "Category", "Comment" });
|
||||
static final Schema V3_SCHEMA = new Schema(VERSION, "ID",
|
||||
new Field[] { LongField.INSTANCE, StringField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Address", "Category", "Comment" });
|
||||
|
||||
static int[] INDEXED_COLUMNS = new int[] { V3_ADDRESS_COL, V3_CATEGORY_COL };
|
||||
|
||||
|
|
|
@ -296,9 +296,8 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
|||
bm.setComment(comment);
|
||||
}
|
||||
else {
|
||||
Record rec =
|
||||
bookmarkAdapter.createBookmark(typeId, category, addrMap.getKey(addr, true),
|
||||
comment);
|
||||
Record rec = bookmarkAdapter.createBookmark(typeId, category,
|
||||
addrMap.getKey(addr, true), comment);
|
||||
bm = new BookmarkDB(this, cache, rec);
|
||||
|
||||
// fire event
|
||||
|
@ -606,9 +605,8 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
|||
RecordIterator it;
|
||||
try {
|
||||
if (bmt != null && bmt.hasBookmarks()) {
|
||||
it =
|
||||
bookmarkAdapter.getRecordsByTypeStartingAtAddress(bmt.getTypeId(),
|
||||
addrMap.getKey(startAddress, false), forward);
|
||||
it = bookmarkAdapter.getRecordsByTypeStartingAtAddress(bmt.getTypeId(),
|
||||
addrMap.getKey(startAddress, false), forward);
|
||||
}
|
||||
else {
|
||||
it = new EmptyRecordIterator();
|
||||
|
@ -761,11 +759,10 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
|||
try {
|
||||
Table table = bookmarkAdapter.getTable(typeId);
|
||||
if (table != null) {
|
||||
DBLongIterator it =
|
||||
new AddressIndexPrimaryKeyIterator(table, BookmarkDBAdapter.ADDRESS_COL,
|
||||
addrMap, set, true);
|
||||
DBFieldIterator it = new AddressIndexPrimaryKeyIterator(table,
|
||||
BookmarkDBAdapter.ADDRESS_COL, addrMap, set, true);
|
||||
while (it.hasNext()) {
|
||||
BookmarkDB bm = (BookmarkDB) getBookmark(it.next());
|
||||
BookmarkDB bm = (BookmarkDB) getBookmark(it.next().getLongValue());
|
||||
if (category == null || category.equals(bm.getCategory())) {
|
||||
doRemoveBookmark(bm);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.bookmark;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
abstract class BookmarkTypeDBAdapter {
|
||||
|
||||
|
@ -28,8 +26,8 @@ abstract class BookmarkTypeDBAdapter {
|
|||
|
||||
static final int TYPE_NAME_COL = 0;
|
||||
|
||||
static final Schema SCHEMA = new Schema(0, "ID", new Class[] { StringField.class },
|
||||
new String[] { "Name" });
|
||||
static final Schema SCHEMA =
|
||||
new Schema(0, "ID", new Field[] { StringField.INSTANCE }, new String[] { "Name" });
|
||||
|
||||
static BookmarkTypeDBAdapter getAdapter(DBHandle dbHandle, int openMode)
|
||||
throws VersionException, IOException {
|
||||
|
@ -58,8 +56,8 @@ abstract class BookmarkTypeDBAdapter {
|
|||
return new BookmarkTypeDBAdapterNoTable(dbHandle);
|
||||
}
|
||||
|
||||
private static BookmarkTypeDBAdapter upgrade(DBHandle dbHandle, BookmarkTypeDBAdapter oldAdapter)
|
||||
throws VersionException, IOException {
|
||||
private static BookmarkTypeDBAdapter upgrade(DBHandle dbHandle,
|
||||
BookmarkTypeDBAdapter oldAdapter) throws VersionException, IOException {
|
||||
return new BookmarkTypeDBAdapterV0(dbHandle, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ abstract class CommentHistoryAdapter {
|
|||
static final String COMMENT_HISTORY_TABLE_NAME = "Comment History";
|
||||
|
||||
static final Schema COMMENT_HISTORY_SCHEMA = new Schema(0, "Key",
|
||||
new Class[] { LongField.class, ByteField.class, IntField.class, IntField.class,
|
||||
StringField.class, StringField.class, LongField.class },
|
||||
new Field[] { LongField.INSTANCE, ByteField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE,
|
||||
StringField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Address", "Comment Type", "Pos1", "Pos2", "String Data", "User", "Date" });
|
||||
|
||||
static final int HISTORY_ADDRESS_COL = 0;
|
||||
|
|
|
@ -57,8 +57,8 @@ abstract class CommentsDBAdapter {
|
|||
NAMES[REPEATABLE_COMMENT_COL] = "Repeatable";
|
||||
|
||||
COMMENTS_SCHEMA =
|
||||
new Schema(1, "Address", new Class[] { StringField.class, StringField.class,
|
||||
StringField.class, StringField.class, StringField.class }, NAMES);
|
||||
new Schema(1, "Address", new Field[] { StringField.INSTANCE, StringField.INSTANCE,
|
||||
StringField.INSTANCE, StringField.INSTANCE, StringField.INSTANCE }, NAMES);
|
||||
}
|
||||
|
||||
// /** comment type for end of line */
|
||||
|
@ -110,8 +110,8 @@ abstract class CommentsDBAdapter {
|
|||
}
|
||||
|
||||
private static CommentsDBAdapter upgrade(DBHandle dbHandle, AddressMap addrMap,
|
||||
CommentsDBAdapter oldAdapter, TaskMonitor monitor) throws VersionException,
|
||||
IOException, CancelledException {
|
||||
CommentsDBAdapter oldAdapter, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
|
||||
AddressMap oldAddrMap = addrMap.getOldAddressMap();
|
||||
|
||||
|
|
|
@ -103,6 +103,8 @@ class DataDB extends CodeUnitDB implements Data {
|
|||
DataType dt;
|
||||
if (rec != null) {
|
||||
// ensure that record provided corresponds to a DataDB record
|
||||
// since following an undo/redo the record could correspond to
|
||||
// a different type of code unit (hopefully with a different record schema)
|
||||
if (!rec.hasSameSchema(DataDBAdapter.DATA_SCHEMA)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,6 +18,9 @@
|
|||
*/
|
||||
package ghidra.program.database.code;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressKeyIterator;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -27,10 +29,6 @@ import ghidra.util.exception.CancelledException;
|
|||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
/**
|
||||
* Adapter to access the Data table.
|
||||
*/
|
||||
|
@ -38,7 +36,7 @@ abstract class DataDBAdapter {
|
|||
|
||||
static final String DATA_TABLE_NAME = "Data";
|
||||
|
||||
static final Schema DATA_SCHEMA = new Schema(0, "Address", new Class[] { LongField.class },
|
||||
static final Schema DATA_SCHEMA = new Schema(0, "Address", new Field[] { LongField.INSTANCE },
|
||||
new String[] { "Data Type ID" });
|
||||
|
||||
static final int DATA_TYPE_ID_COL = 0;
|
||||
|
@ -75,8 +73,8 @@ abstract class DataDBAdapter {
|
|||
}
|
||||
|
||||
private static DataDBAdapter upgrade(DBHandle dbHandle, AddressMap addrMap,
|
||||
DataDBAdapter oldAdapter, TaskMonitor monitor) throws VersionException, IOException,
|
||||
CancelledException {
|
||||
DataDBAdapter oldAdapter, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
|
||||
AddressMap oldAddrMap = addrMap.getOldAddressMap();
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +15,9 @@
|
|||
*/
|
||||
package ghidra.program.database.code;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressKeyIterator;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -24,10 +26,6 @@ import ghidra.util.exception.CancelledException;
|
|||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
/**
|
||||
* Adapter that accesses the instruction table.
|
||||
*/
|
||||
|
@ -35,8 +33,9 @@ abstract class InstDBAdapter {
|
|||
|
||||
static final String INSTRUCTION_TABLE_NAME = "Instructions";
|
||||
|
||||
static final Schema INSTRUCTION_SCHEMA = new Schema(1, "Address", new Class[] { IntField.class,
|
||||
ByteField.class }, new String[] { "Proto ID", "Flags" });
|
||||
static final Schema INSTRUCTION_SCHEMA =
|
||||
new Schema(1, "Address", new Field[] { IntField.INSTANCE, ByteField.INSTANCE },
|
||||
new String[] { "Proto ID", "Flags" });
|
||||
|
||||
static final int PROTO_ID_COL = 0;
|
||||
static final int FLAGS_COL = 1;
|
||||
|
@ -79,8 +78,8 @@ abstract class InstDBAdapter {
|
|||
}
|
||||
|
||||
private static InstDBAdapter upgrade(DBHandle dbHandle, AddressMap addrMap,
|
||||
InstDBAdapter oldAdapter, TaskMonitor monitor) throws VersionException, IOException,
|
||||
CancelledException {
|
||||
InstDBAdapter oldAdapter, TaskMonitor monitor)
|
||||
throws VersionException, IOException, CancelledException {
|
||||
|
||||
AddressMap oldAddrMap = addrMap.getOldAddressMap();
|
||||
|
||||
|
|
|
@ -90,7 +90,9 @@ public class InstructionDB extends CodeUnitDB implements Instruction, Instructio
|
|||
return true;
|
||||
}
|
||||
}
|
||||
// ensure that record provided corresponds to an InstructionDB record
|
||||
// ensure that record provided corresponds to a DataDB record
|
||||
// since following an undo/redo the record could correspond to
|
||||
// a different type of code unit (hopefully with a different record schema)
|
||||
else if (!rec.hasSameSchema(InstDBAdapter.INSTRUCTION_SCHEMA)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -68,16 +68,15 @@ class PrototypeManager {
|
|||
final static Schema REGISTER_SCHEMA = createRegisterSchema();
|
||||
|
||||
private static Schema createPrototypeSchema() {
|
||||
Schema schema =
|
||||
new Schema(1, "Keys", new Class[] { BinaryField.class, LongField.class,
|
||||
BooleanField.class }, new String[] { "Bytes", "Address", "InDelaySlot" });
|
||||
Schema schema = new Schema(1, "Keys",
|
||||
new Field[] { BinaryField.INSTANCE, LongField.INSTANCE, BooleanField.INSTANCE },
|
||||
new String[] { "Bytes", "Address", "InDelaySlot" });
|
||||
return schema;
|
||||
}
|
||||
|
||||
private static Schema createRegisterSchema() {
|
||||
Schema schema =
|
||||
new Schema(1, "Keys", new Class[] { StringField.class },
|
||||
new String[] { "Register Context" });
|
||||
Schema schema = new Schema(1, "Keys", new Field[] { StringField.INSTANCE },
|
||||
new String[] { "Register Context" });
|
||||
return schema;
|
||||
}
|
||||
|
||||
|
@ -412,8 +411,8 @@ class PrototypeManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void loadContextTable(DBHandle dbHandle, int openMode) throws VersionException,
|
||||
IOException {
|
||||
private void loadContextTable(DBHandle dbHandle, int openMode)
|
||||
throws VersionException, IOException {
|
||||
contextTable = dbHandle.getTable(CONTEXT_TABLE_NAME);
|
||||
if (contextTable == null) {
|
||||
contextTable = dbHandle.createTable(CONTEXT_TABLE_NAME, REGISTER_SCHEMA);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -90,29 +88,16 @@ abstract class ArrayDBAdapter {
|
|||
abstract Record createRecord(long dataTypeID, int numberOfElements, int length, long catID)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* @param arrayID
|
||||
* @return
|
||||
*/
|
||||
abstract Record getRecord(long arrayID) throws IOException;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
abstract RecordIterator getRecords() throws IOException;
|
||||
|
||||
/**
|
||||
* @param dataID
|
||||
*/
|
||||
abstract boolean removeRecord(long dataID) throws IOException;
|
||||
|
||||
abstract void updateRecord(Record record) throws IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract void deleteTable(DBHandle handle) throws IOException;
|
||||
|
||||
abstract long[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
abstract Field[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -57,42 +55,27 @@ class ArrayDBAdapterV0 extends ArrayDBAdapter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#createRecord(long, int)
|
||||
*/
|
||||
@Override
|
||||
public Record createRecord(long dataTypeID, int numberOfElements, int length, long catID)
|
||||
throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#getRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getRecord(long arrayID) throws IOException {
|
||||
return translateRecord(table.getRecord(arrayID));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#getRecords()
|
||||
*/
|
||||
@Override
|
||||
public RecordIterator getRecords() throws IOException {
|
||||
return new TranslatedRecordIterator(table.iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#removeRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeRecord(long dataID) throws IOException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#updateRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
public void updateRecord(Record record) throws IOException {
|
||||
}
|
||||
|
@ -116,43 +99,42 @@ class ArrayDBAdapterV0 extends ArrayDBAdapter {
|
|||
this.it = it;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() throws IOException {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrevious() throws IOException {
|
||||
return it.hasPrevious();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record next() throws IOException {
|
||||
Record rec = it.next();
|
||||
return translateRecord(rec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record previous() throws IOException {
|
||||
Record rec = it.previous();
|
||||
return translateRecord(rec);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#deleteTable(ghidra.framework.store.db.DBHandle)
|
||||
*/
|
||||
@Override
|
||||
void deleteTable(DBHandle handle) throws IOException {
|
||||
handle.deleteTable(ARRAY_TABLE_NAME);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#getRecordIdsInCategory(long)
|
||||
*/
|
||||
@Override
|
||||
long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return new long[0];
|
||||
Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -38,9 +37,11 @@ class ArrayDBAdapterV1 extends ArrayDBAdapter {
|
|||
|
||||
private Table table;
|
||||
|
||||
public static final Schema V1_SCHEMA = new Schema(VERSION, "Array ID", new Class[] {
|
||||
LongField.class, IntField.class, IntField.class, LongField.class }, new String[] {
|
||||
"Data Type ID", "Dimension", "Length", "Cat ID" });
|
||||
public static final Schema V1_SCHEMA =
|
||||
new Schema(VERSION, "Array ID",
|
||||
new Field[] { LongField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE,
|
||||
LongField.INSTANCE },
|
||||
new String[] { "Data Type ID", "Dimension", "Length", "Cat ID" });
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -62,9 +63,6 @@ class ArrayDBAdapterV1 extends ArrayDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#createRecord(long, int)
|
||||
*/
|
||||
@Override
|
||||
public Record createRecord(long dataTypeID, int numberOfElements, int length, long catID)
|
||||
throws IOException {
|
||||
|
@ -84,52 +82,34 @@ class ArrayDBAdapterV1 extends ArrayDBAdapter {
|
|||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#getRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getRecord(long arrayID) throws IOException {
|
||||
return table.getRecord(arrayID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#getRecords()
|
||||
*/
|
||||
@Override
|
||||
public RecordIterator getRecords() throws IOException {
|
||||
return table.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#removeRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeRecord(long dataID) throws IOException {
|
||||
return table.deleteRecord(dataID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#updateRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
public void updateRecord(Record record) throws IOException {
|
||||
table.putRecord(record);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#deleteTable(ghidra.framework.store.db.DBHandle)
|
||||
*/
|
||||
@Override
|
||||
void deleteTable(DBHandle handle) throws IOException {
|
||||
handle.deleteTable(ARRAY_TABLE_NAME);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.ArrayDBAdapter#getRecordIdsInCategory(long)
|
||||
*/
|
||||
@Override
|
||||
long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), V1_ARRAY_CAT_COL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Database adapter for managing built-in data types.
|
||||
|
@ -67,11 +65,12 @@ public abstract class BuiltinDBAdapter {
|
|||
|
||||
/**
|
||||
* Returns an array containing the data type IDs for the given category ID
|
||||
* @return an array of the data type IDs;
|
||||
* empty array if no built-in data types.
|
||||
* @param categoryID category ID
|
||||
* @return an array of the data type IDs as LongFields within Field array;
|
||||
* empty array if no built-in data types found.
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract long[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
abstract Field[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
|
||||
/**
|
||||
* Update the built-ins table with the given record.
|
||||
|
@ -83,12 +82,15 @@ public abstract class BuiltinDBAdapter {
|
|||
/**
|
||||
* Remove the record with the given dataID.
|
||||
* @param dataID key
|
||||
* @return true if record was deleted successfully.
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract boolean removeRecord(long dataID) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an iterator over all records for built-in data types.
|
||||
* @return record iterator
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract RecordIterator getRecords() throws IOException;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,11 +18,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 0 implementation of the adapter for accessing the built-ins table.
|
||||
|
@ -33,8 +31,9 @@ class BuiltinDBAdapterV0 extends BuiltinDBAdapter {
|
|||
static final int V0_BUILT_IN_NAME_COL = 0;
|
||||
static final int V0_BUILT_IN_CLASSNAME_COL = 1;
|
||||
static final int V0_BUILT_IN_CAT_COL = 2;
|
||||
static final Schema V0_SCHEMA = new Schema(0, "Data Type ID", new Class[] { StringField.class,
|
||||
StringField.class, LongField.class }, new String[] { "Name", "Class Name", "Category ID" });
|
||||
static final Schema V0_SCHEMA = new Schema(0, "Data Type ID",
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Name", "Class Name", "Category ID" });
|
||||
private Table table;
|
||||
|
||||
/**
|
||||
|
@ -45,12 +44,12 @@ class BuiltinDBAdapterV0 extends BuiltinDBAdapter {
|
|||
* for this adapter.
|
||||
* @throws IOException if there is trouble accessing the database.
|
||||
*/
|
||||
public BuiltinDBAdapterV0(DBHandle handle, boolean create) throws VersionException, IOException {
|
||||
public BuiltinDBAdapterV0(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
table =
|
||||
handle.createTable(BUILT_IN_TABLE_NAME, V0_SCHEMA,
|
||||
new int[] { V0_BUILT_IN_CAT_COL });
|
||||
table = handle.createTable(BUILT_IN_TABLE_NAME, V0_SCHEMA,
|
||||
new int[] { V0_BUILT_IN_CAT_COL });
|
||||
}
|
||||
else {
|
||||
table = handle.getTable(BUILT_IN_TABLE_NAME);
|
||||
|
@ -70,7 +69,7 @@ class BuiltinDBAdapterV0 extends BuiltinDBAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), V0_BUILT_IN_CAT_COL);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.DatabaseObject;
|
||||
|
@ -181,10 +182,10 @@ class CategoryDB extends DatabaseObject implements Category {
|
|||
|
||||
private CategoryDB[] getCategories(long parentId) {
|
||||
try {
|
||||
long[] ids = mgr.getCategoryDBAdapter().getRecordIdsWithParent(parentId);
|
||||
Field[] ids = mgr.getCategoryDBAdapter().getRecordIdsWithParent(parentId);
|
||||
CategoryDB[] cats = new CategoryDB[ids.length];
|
||||
for (int i = 0; i < cats.length; i++) {
|
||||
cats[i] = mgr.getCategoryDB(ids[i]);
|
||||
cats[i] = mgr.getCategoryDB(ids[i].getLongValue());
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ package ghidra.program.database.data;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.DBHandle;
|
||||
import db.Record;
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
@ -38,31 +37,35 @@ abstract class CategoryDBAdapter {
|
|||
* Gets the category record for the given ID.
|
||||
* @param categoryID the key into the category table
|
||||
* @return the record for the given ID or null if no record with that id exists.
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getRecord(long categoryID) throws IOException;
|
||||
|
||||
/**
|
||||
* Updates the record in the database
|
||||
* @param categoryID
|
||||
* @param parentCategoryID
|
||||
* @param name
|
||||
* @throws IOException
|
||||
* @param categoryID category record key
|
||||
* @param parentCategoryID parent category record key (-1 for root category)
|
||||
* @param name category name
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract void updateRecord(long categoryID, long parentCategoryID, String name)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Returns a list of categoryIDs that have the given parent ID.
|
||||
* @param categoryID the key into the category table
|
||||
* @return an array of categoryIDs that have the specified parent
|
||||
* @param categoryID the key into the catagory table
|
||||
* @return an array of categoryIDs that have the specified parent. Field array
|
||||
* returned with LongField key values.
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract long[] getRecordIdsWithParent(long categoryID) throws IOException;
|
||||
abstract Field[] getRecordIdsWithParent(long categoryID) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a new category with the given name and parent ID.
|
||||
* @param name the name of the new category.
|
||||
* @param categoryID the key into the category table
|
||||
* @param parentID the parent key into the catagory table
|
||||
* @return a new record for the new category.
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record createCategory(String name, long parentID) throws IOException;
|
||||
|
||||
|
@ -70,11 +73,14 @@ abstract class CategoryDBAdapter {
|
|||
* Removes the category with the given ID.
|
||||
* @param categoryID the key into the category table
|
||||
* @return true if the a category with that id existed.
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract boolean removeCategory(long categoryID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get the record for the root category.
|
||||
* @return root category record
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getRootRecord() throws IOException;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,19 +18,18 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
class CategoryDBAdapterV0 extends CategoryDBAdapter {
|
||||
static final String CATEGORY_TABLE_NAME = "Categories";
|
||||
static final int V0_CATEGORY_NAME_COL = 0;
|
||||
static final int V0_CATEGORY_PARENT_COL = 1;
|
||||
static final Schema V0_SCHEMA = new Schema(0, "Category ID", new Class[] { StringField.class,
|
||||
LongField.class }, new String[] { "Name", "Parent ID" });
|
||||
static final Schema V0_SCHEMA =
|
||||
new Schema(0, "Category ID", new Field[] { StringField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Name", "Parent ID" });
|
||||
|
||||
private Table table;
|
||||
|
||||
|
@ -42,9 +40,8 @@ class CategoryDBAdapterV0 extends CategoryDBAdapter {
|
|||
public CategoryDBAdapterV0(DBHandle handle, int openMode) throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
table =
|
||||
handle.createTable(CATEGORY_TABLE_NAME, V0_SCHEMA,
|
||||
new int[] { V0_CATEGORY_PARENT_COL });
|
||||
table = handle.createTable(CATEGORY_TABLE_NAME, V0_SCHEMA,
|
||||
new int[] { V0_CATEGORY_PARENT_COL });
|
||||
}
|
||||
else {
|
||||
table = handle.getTable(CATEGORY_TABLE_NAME);
|
||||
|
@ -58,19 +55,13 @@ class CategoryDBAdapterV0 extends CategoryDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.CategoryDBAdapter#getRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getRecord(long categoryID) throws IOException {
|
||||
return table.getRecord(categoryID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.CategoryDBAdapter#getRecordIdsWithParent(long)
|
||||
*/
|
||||
@Override
|
||||
public long[] getRecordIdsWithParent(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsWithParent(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), V0_CATEGORY_PARENT_COL);
|
||||
}
|
||||
|
||||
|
@ -87,9 +78,6 @@ class CategoryDBAdapterV0 extends CategoryDBAdapter {
|
|||
table.putRecord(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.CategoryDBAdapter#createCategory(java.lang.String, long)
|
||||
*/
|
||||
@Override
|
||||
public Record createCategory(String name, long parentID) throws IOException {
|
||||
long key = table.getKey();
|
||||
|
@ -104,29 +92,20 @@ class CategoryDBAdapterV0 extends CategoryDBAdapter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.CategoryDBAdapter#removeCategory(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeCategory(long categoryID) throws IOException {
|
||||
return table.deleteRecord(categoryID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.CategoryDBAdapter#getRootRecord()
|
||||
*/
|
||||
@Override
|
||||
public Record getRootRecord() throws IOException {
|
||||
long[] keys = table.findRecords(new LongField(-1), V0_CATEGORY_PARENT_COL);
|
||||
if (keys.length > 1) {
|
||||
throw new AssertException("Found " + keys.length + " entries for root category");
|
||||
Field[] keys = table.findRecords(new LongField(-1), V0_CATEGORY_PARENT_COL);
|
||||
if (keys.length != 1) {
|
||||
throw new IOException("Found " + keys.length + " entries for root category");
|
||||
}
|
||||
return getRecord(keys[0]);
|
||||
return getRecord(keys[0].getLongValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.CategoryDBAdapter#getRecordCount()
|
||||
*/
|
||||
@Override
|
||||
int getRecordCount() {
|
||||
return table.getRecordCount();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Adapter to access the Component database table.
|
||||
|
@ -52,7 +50,7 @@ abstract class ComponentDBAdapter {
|
|||
*/
|
||||
static ComponentDBAdapter getAdapter(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
throws VersionException, IOException {
|
||||
return new ComponentDBAdapterV0(handle, openMode);
|
||||
return new ComponentDBAdapterV0(handle, openMode == DBConstants.CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,8 +94,8 @@ abstract class ComponentDBAdapter {
|
|||
/**
|
||||
* Gets an array with all of the IDs of the defined components within the composite data type indicated.
|
||||
* @param compositeID the ID of the composite data type whose components are desired.
|
||||
* @return an array of the defined component IDs.
|
||||
* @return an array of the defined component IDs as LongField values within Field array.
|
||||
* @throws IOException if there is a problem accessing the database.
|
||||
*/
|
||||
abstract long[] getComponentIdsInComposite(long compositeID) throws IOException;
|
||||
abstract Field[] getComponentIdsInComposite(long compositeID) throws IOException;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for accessing the Component database table.
|
||||
|
@ -37,10 +35,11 @@ class ComponentDBAdapterV0 extends ComponentDBAdapter {
|
|||
static final int V0_COMPONENT_SIZE_COL = 5;
|
||||
static final int V0_COMPONENT_ORDINAL_COL = 6;
|
||||
|
||||
static final Schema V0_COMPONENT_SCHEMA = new Schema(0, "Data Type ID", new Class[] {
|
||||
LongField.class, IntField.class, LongField.class, StringField.class, StringField.class,
|
||||
IntField.class, IntField.class }, new String[] { "Parent", "Offset", "Data Type ID",
|
||||
"Field Name", "Comment", "Component Size", "Ordinal" });
|
||||
static final Schema V0_COMPONENT_SCHEMA = new Schema(0, "Data Type ID",
|
||||
new Field[] { LongField.INSTANCE, IntField.INSTANCE, LongField.INSTANCE,
|
||||
StringField.INSTANCE, StringField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE },
|
||||
new String[] { "Parent", "Offset", "Data Type ID", "Field Name", "Comment",
|
||||
"Component Size", "Ordinal" });
|
||||
private Table componentTable;
|
||||
|
||||
/**
|
||||
|
@ -50,12 +49,12 @@ class ComponentDBAdapterV0 extends ComponentDBAdapter {
|
|||
* @throws VersionException if the the table's version does not match the expected version
|
||||
* for this adapter.
|
||||
*/
|
||||
public ComponentDBAdapterV0(DBHandle handle, int openMode) throws VersionException, IOException {
|
||||
public ComponentDBAdapterV0(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
componentTable =
|
||||
handle.createTable(COMPONENT_TABLE_NAME, V0_COMPONENT_SCHEMA,
|
||||
new int[] { V0_COMPONENT_PARENT_ID_COL });
|
||||
if (create) {
|
||||
componentTable = handle.createTable(COMPONENT_TABLE_NAME, V0_COMPONENT_SCHEMA,
|
||||
new int[] { V0_COMPONENT_PARENT_ID_COL });
|
||||
}
|
||||
else {
|
||||
componentTable = handle.getTable(COMPONENT_TABLE_NAME);
|
||||
|
@ -64,9 +63,8 @@ class ComponentDBAdapterV0 extends ComponentDBAdapter {
|
|||
}
|
||||
int version = componentTable.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + COMPONENT_TABLE_NAME +
|
||||
" but got " + componentTable.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + COMPONENT_TABLE_NAME +
|
||||
" but got " + componentTable.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -112,7 +110,7 @@ class ComponentDBAdapterV0 extends ComponentDBAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getComponentIdsInComposite(long compositeID) throws IOException {
|
||||
public Field[] getComponentIdsInComposite(long compositeID) throws IOException {
|
||||
return componentTable.findRecords(new LongField(compositeID),
|
||||
ComponentDBAdapter.COMPONENT_PARENT_ID_COL);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ abstract class CompositeDBAdapter {
|
|||
* @param handle handle to prior version of the database.
|
||||
* @return the read only Composite data type table adapter
|
||||
* @throws VersionException if a read only adapter can't be obtained for the database handle's version.
|
||||
* @throws IOException
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
static CompositeDBAdapter findReadOnlyAdapter(DBHandle handle)
|
||||
throws VersionException, IOException {
|
||||
|
@ -194,7 +194,7 @@ abstract class CompositeDBAdapter {
|
|||
/**
|
||||
* Updates the composite data type table with the provided record.
|
||||
* @param record the new record
|
||||
* @param setLastChangedTime true means change the last change time in the record to the
|
||||
* @param setLastChangeTime true means change the last change time in the record to the
|
||||
* current time before putting the record in the database.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
|
@ -218,10 +218,11 @@ abstract class CompositeDBAdapter {
|
|||
/**
|
||||
* Gets all the composite data types that are contained in the category that has the indicated ID.
|
||||
* @param categoryID the category whose composite data types are wanted.
|
||||
* @return an array of IDs for the composite data types in the category.
|
||||
* @return an array of IDs as LongField values within Field array for the
|
||||
* composite data types in the category.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract long[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
abstract Field[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
|
||||
/**
|
||||
* Gets an array with the IDs of all data types in the composite table that were derived
|
||||
|
@ -230,8 +231,15 @@ abstract class CompositeDBAdapter {
|
|||
* @return the array data type IDs.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract long[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
abstract Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get composite record whoose sourceID and datatypeID match the specified Universal IDs.
|
||||
* @param sourceID universal source archive ID
|
||||
* @param datatypeID universal datatype ID
|
||||
* @return composite record found or null
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID)
|
||||
throws IOException;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,16 +15,15 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.data.DataTypeManager;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.UniversalIdGenerator;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for accessing the Composite database table.
|
||||
*/
|
||||
|
@ -38,10 +36,11 @@ class CompositeDBAdapterV0 extends CompositeDBAdapter implements RecordTranslato
|
|||
static final int V0_COMPOSITE_LENGTH_COL = 4;
|
||||
static final int V0_COMPOSITE_NUM_COMPONENTS_COL = 5;
|
||||
|
||||
static final Schema V0_COMPOSITE_SCHEMA = new Schema(VERSION, "Data Type ID", new Class[] {
|
||||
StringField.class, StringField.class, BooleanField.class, LongField.class, IntField.class,
|
||||
IntField.class }, new String[] { "Name", "Comment", "Is Union", "Category ID", "Length",
|
||||
"Number Of Components" });
|
||||
static final Schema V0_COMPOSITE_SCHEMA = new Schema(VERSION, "Data Type ID",
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, BooleanField.INSTANCE,
|
||||
LongField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE },
|
||||
new String[] { "Name", "Comment", "Is Union", "Category ID", "Length",
|
||||
"Number Of Components" });
|
||||
|
||||
private Table compositeTable;
|
||||
|
||||
|
@ -59,9 +58,8 @@ class CompositeDBAdapterV0 extends CompositeDBAdapter implements RecordTranslato
|
|||
}
|
||||
int version = compositeTable.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + COMPOSITE_TABLE_NAME + " but got " +
|
||||
compositeTable.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + COMPOSITE_TABLE_NAME +
|
||||
" but got " + compositeTable.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -98,7 +96,7 @@ class CompositeDBAdapterV0 extends CompositeDBAdapter implements RecordTranslato
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return compositeTable.findRecords(new LongField(categoryID),
|
||||
CompositeDBAdapter.COMPOSITE_CAT_COL);
|
||||
}
|
||||
|
@ -109,13 +107,11 @@ class CompositeDBAdapterV0 extends CompositeDBAdapter implements RecordTranslato
|
|||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return new long[0];
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see db.RecordTranslator#translateRecord(db.Record)
|
||||
*/
|
||||
@Override
|
||||
public Record translateRecord(Record oldRec) {
|
||||
if (oldRec == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 1 implementation for accessing the Composite database table.
|
||||
|
@ -39,9 +37,10 @@ class CompositeDBAdapterV1 extends CompositeDBAdapter implements RecordTranslato
|
|||
static final int V1_COMPOSITE_SOURCE_SYNC_TIME_COL = 8;
|
||||
static final int V1_COMPOSITE_LAST_CHANGE_TIME_COL = 9;
|
||||
|
||||
static final Schema V1_COMPOSITE_SCHEMA = new Schema(VERSION, "Data Type ID", new Class[] {
|
||||
StringField.class, StringField.class, BooleanField.class, LongField.class, IntField.class,
|
||||
IntField.class, LongField.class, LongField.class, LongField.class, LongField.class },
|
||||
static final Schema V1_COMPOSITE_SCHEMA = new Schema(VERSION, "Data Type ID",
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, BooleanField.INSTANCE,
|
||||
LongField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE, LongField.INSTANCE,
|
||||
LongField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Name", "Comment", "Is Union", "Category ID", "Length",
|
||||
"Number Of Components", "Source Archive ID", "Source Data Type ID", "Source Sync Time",
|
||||
"Last Change Time" });
|
||||
|
@ -62,9 +61,8 @@ class CompositeDBAdapterV1 extends CompositeDBAdapter implements RecordTranslato
|
|||
}
|
||||
int version = compositeTable.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + COMPOSITE_TABLE_NAME + " but got " +
|
||||
compositeTable.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + COMPOSITE_TABLE_NAME +
|
||||
" but got " + compositeTable.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -106,13 +104,13 @@ class CompositeDBAdapterV1 extends CompositeDBAdapter implements RecordTranslato
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return compositeTable.findRecords(new LongField(categoryID),
|
||||
CompositeDBAdapter.COMPOSITE_CAT_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return compositeTable.findRecords(new LongField(archiveID),
|
||||
V1_COMPOSITE_SOURCE_ARCHIVE_ID_COL);
|
||||
}
|
||||
|
@ -120,6 +118,7 @@ class CompositeDBAdapterV1 extends CompositeDBAdapter implements RecordTranslato
|
|||
/* (non-Javadoc)
|
||||
* @see db.RecordTranslator#translateRecord(db.Record)
|
||||
*/
|
||||
@Override
|
||||
public Record translateRecord(Record oldRec) {
|
||||
if (oldRec == null) {
|
||||
return null;
|
||||
|
@ -148,9 +147,8 @@ class CompositeDBAdapterV1 extends CompositeDBAdapter implements RecordTranslato
|
|||
|
||||
@Override
|
||||
Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID) throws IOException {
|
||||
long[] keys =
|
||||
compositeTable.findRecords(new LongField(datatypeID.getValue()),
|
||||
V1_COMPOSITE_UNIVERSAL_DT_ID_COL);
|
||||
Field[] keys = compositeTable.findRecords(new LongField(datatypeID.getValue()),
|
||||
V1_COMPOSITE_UNIVERSAL_DT_ID_COL);
|
||||
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record record = compositeTable.getRecord(keys[i]);
|
||||
|
|
|
@ -54,9 +54,10 @@ class CompositeDBAdapterV2V3 extends CompositeDBAdapter {
|
|||
static final int V2_COMPOSITE_EXTERNAL_ALIGNMENT_COL = 11;
|
||||
|
||||
static final Schema V2_COMPOSITE_SCHEMA = new Schema(VERSION, "Data Type ID",
|
||||
new Class[] { StringField.class, StringField.class, BooleanField.class, LongField.class,
|
||||
IntField.class, IntField.class, LongField.class, LongField.class, LongField.class,
|
||||
LongField.class, IntField.class, IntField.class },
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, BooleanField.INSTANCE,
|
||||
LongField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE, LongField.INSTANCE,
|
||||
LongField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE, IntField.INSTANCE,
|
||||
IntField.INSTANCE },
|
||||
new String[] { "Name", "Comment", "Is Union", "Category ID", "Length",
|
||||
"Number Of Components", "Source Archive ID", "Source Data Type ID", "Source Sync Time",
|
||||
"Last Change Time", "Internal Alignment", "External Alignment" });
|
||||
|
@ -190,20 +191,20 @@ class CompositeDBAdapterV2V3 extends CompositeDBAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return compositeTable.findRecords(new LongField(categoryID),
|
||||
CompositeDBAdapter.COMPOSITE_CAT_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return compositeTable.findRecords(new LongField(archiveID),
|
||||
V2_COMPOSITE_SOURCE_ARCHIVE_ID_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID) throws IOException {
|
||||
long[] keys = compositeTable.findRecords(new LongField(datatypeID.getValue()),
|
||||
Field[] keys = compositeTable.findRecords(new LongField(datatypeID.getValue()),
|
||||
V2_COMPOSITE_UNIVERSAL_DT_ID_COL);
|
||||
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
|
|
|
@ -1848,9 +1848,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
* @param parentID the parentData type's ID
|
||||
*/
|
||||
private void removeParameters(long parentID) throws IOException {
|
||||
long[] paramIDs = paramAdapter.getParameterIdsInFunctionDef(parentID);
|
||||
for (long paramID : paramIDs) {
|
||||
deleteDataTypeRecord(paramID);
|
||||
Field[] paramIDs = paramAdapter.getParameterIdsInFunctionDef(parentID);
|
||||
for (Field paramID : paramIDs) {
|
||||
deleteDataTypeRecord(paramID.getLongValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1860,9 +1860,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
* @param parentID the parentData type's ID
|
||||
*/
|
||||
private void removeComponents(long parentID) throws IOException {
|
||||
long[] componentIDs = componentAdapter.getComponentIdsInComposite(parentID);
|
||||
for (long componentID : componentIDs) {
|
||||
deleteDataTypeRecord(componentID);
|
||||
Field[] componentIDs = componentAdapter.getComponentIdsInComposite(parentID);
|
||||
for (Field componentID : componentIDs) {
|
||||
deleteDataTypeRecord(componentID.getLongValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1954,7 +1954,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
lock.acquire();
|
||||
ArrayList<DataType> list = new ArrayList<>();
|
||||
try {
|
||||
long[] ids = builtinAdapter.getRecordIdsInCategory(categoryID);
|
||||
Field[] ids = builtinAdapter.getRecordIdsInCategory(categoryID);
|
||||
getDataTypes(ids, list);
|
||||
|
||||
ids = typedefAdapter.getRecordIdsInCategory(categoryID);
|
||||
|
@ -2011,9 +2011,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void getDataTypes(long[] ids, ArrayList<DataType> list) {
|
||||
for (long id : ids) {
|
||||
DataType dt = getDataType(id);
|
||||
private void getDataTypes(Field[] ids, ArrayList<DataType> list) {
|
||||
for (Field id : ids) {
|
||||
DataType dt = getDataType(id.getLongValue());
|
||||
if (dt == null) {
|
||||
throw new AssertException("Could not find data type id: " + id);
|
||||
}
|
||||
|
@ -2850,14 +2850,16 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
void dataTypeCategoryPathChanged(DataTypeDB dt, CategoryPath oldPath, long oldCatId) {
|
||||
if (!(dt instanceof Array) && !(dt instanceof Pointer)) {
|
||||
try {
|
||||
for (long arrayId : arrayAdapter.getRecordIdsInCategory(oldCatId)) {
|
||||
Record rec = arrayAdapter.getRecord(arrayId);
|
||||
ArrayDB array = (ArrayDB) getDataType(arrayId, rec);
|
||||
for (Field arrayId : arrayAdapter.getRecordIdsInCategory(oldCatId)) {
|
||||
long id = arrayId.getLongValue();
|
||||
Record rec = arrayAdapter.getRecord(id);
|
||||
ArrayDB array = (ArrayDB) getDataType(id, rec);
|
||||
array.updatePath(dt);
|
||||
}
|
||||
for (long ptrId : pointerAdapter.getRecordIdsInCategory(oldCatId)) {
|
||||
Record rec = pointerAdapter.getRecord(ptrId);
|
||||
PointerDB ptr = (PointerDB) getDataType(ptrId, rec);
|
||||
for (Field ptrId : pointerAdapter.getRecordIdsInCategory(oldCatId)) {
|
||||
long id = ptrId.getLongValue();
|
||||
Record rec = pointerAdapter.getRecord(id);
|
||||
PointerDB ptr = (PointerDB) getDataType(id, rec);
|
||||
ptr.updatePath(dt);
|
||||
}
|
||||
}
|
||||
|
@ -3147,9 +3149,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
lock.acquire();
|
||||
try {
|
||||
settingsCache.clear();
|
||||
long[] keys = instanceSettingsAdapter.getInstanceKeys(addrMap.getKey(dataAddr, false));
|
||||
for (long key : keys) {
|
||||
instanceSettingsAdapter.removeInstanceRecord(key);
|
||||
Field[] keys = instanceSettingsAdapter.getInstanceKeys(addrMap.getKey(dataAddr, false));
|
||||
for (Field key : keys) {
|
||||
instanceSettingsAdapter.removeInstanceRecord(key.getLongValue());
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
@ -3282,10 +3284,10 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
}
|
||||
lock.acquire();
|
||||
try {
|
||||
long[] keys = instanceSettingsAdapter.getInstanceKeys(addrMap.getKey(dataAddr, false));
|
||||
Field[] keys = instanceSettingsAdapter.getInstanceKeys(addrMap.getKey(dataAddr, false));
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for (long key : keys) {
|
||||
Record rec = instanceSettingsAdapter.getInstanceRecord(key);
|
||||
for (Field key : keys) {
|
||||
Record rec = instanceSettingsAdapter.getInstanceRecord(key.getLongValue());
|
||||
list.add(rec.getString(InstanceSettingsDBAdapter.INST_NAME_COL));
|
||||
}
|
||||
String[] names = new String[list.size()];
|
||||
|
@ -3392,9 +3394,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
|
||||
private Record getInstanceRecord(long addr, String name) {
|
||||
try {
|
||||
long[] keys = instanceSettingsAdapter.getInstanceKeys(addr);
|
||||
for (long key : keys) {
|
||||
Record rec = instanceSettingsAdapter.getInstanceRecord(key);
|
||||
Field[] keys = instanceSettingsAdapter.getInstanceKeys(addr);
|
||||
for (Field key : keys) {
|
||||
Record rec = instanceSettingsAdapter.getInstanceRecord(key.getLongValue());
|
||||
if (rec.getString(InstanceSettingsDBAdapter.INST_NAME_COL).equals(name)) {
|
||||
return rec;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.docking.settings.SettingsDefinition;
|
||||
|
@ -84,10 +85,10 @@ class EnumDB extends DataTypeDB implements Enum {
|
|||
nameMap = new HashMap<>();
|
||||
valueMap = new HashMap<>();
|
||||
|
||||
long[] ids = valueAdapter.getValueIdsInEnum(key);
|
||||
Field[] ids = valueAdapter.getValueIdsInEnum(key);
|
||||
|
||||
for (long id : ids) {
|
||||
Record rec = valueAdapter.getRecord(id);
|
||||
for (Field id : ids) {
|
||||
Record rec = valueAdapter.getRecord(id.getLongValue());
|
||||
String valueName = rec.getString(EnumValueDBAdapter.ENUMVAL_NAME_COL);
|
||||
long value = rec.getLongValue(EnumValueDBAdapter.ENUMVAL_VALUE_COL);
|
||||
addToCache(valueName, value);
|
||||
|
@ -179,7 +180,9 @@ class EnumDB extends DataTypeDB implements Enum {
|
|||
try {
|
||||
checkIsValid();
|
||||
initializeIfNeeded();
|
||||
return nameMap.keySet().toArray(new String[nameMap.size()]);
|
||||
String[] names = nameMap.keySet().toArray(new String[nameMap.size()]);
|
||||
Arrays.sort(names);
|
||||
return names;
|
||||
}
|
||||
finally {
|
||||
lock.release();
|
||||
|
@ -250,12 +253,12 @@ class EnumDB extends DataTypeDB implements Enum {
|
|||
}
|
||||
bitGroups = null;
|
||||
|
||||
long[] ids = valueAdapter.getValueIdsInEnum(key);
|
||||
Field[] ids = valueAdapter.getValueIdsInEnum(key);
|
||||
|
||||
for (long id : ids) {
|
||||
Record rec = valueAdapter.getRecord(id);
|
||||
for (Field id : ids) {
|
||||
Record rec = valueAdapter.getRecord(id.getLongValue());
|
||||
if (valueName.equals(rec.getString(EnumValueDBAdapter.ENUMVAL_NAME_COL))) {
|
||||
valueAdapter.removeRecord(id);
|
||||
valueAdapter.removeRecord(id.getLongValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -284,9 +287,9 @@ class EnumDB extends DataTypeDB implements Enum {
|
|||
nameMap = new HashMap<>();
|
||||
valueMap = new HashMap<>();
|
||||
|
||||
long[] ids = valueAdapter.getValueIdsInEnum(key);
|
||||
for (long id : ids) {
|
||||
valueAdapter.removeRecord(id);
|
||||
Field[] ids = valueAdapter.getValueIdsInEnum(key);
|
||||
for (Field id : ids) {
|
||||
valueAdapter.removeRecord(id.getLongValue());
|
||||
}
|
||||
|
||||
int oldLength = getLength();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,13 +15,12 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Adapter to access the Enumeration data types tables.
|
||||
|
@ -188,7 +186,7 @@ abstract class EnumDBAdapter {
|
|||
* @return an array of IDs for the enumeration data types in the category.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract long[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
abstract Field[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
|
||||
/**
|
||||
* Gets an array with the IDs of all data types in the enumeration table that were derived
|
||||
|
@ -197,8 +195,15 @@ abstract class EnumDBAdapter {
|
|||
* @return the array data type IDs.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract long[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
abstract Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get enum record whoose sourceID and datatypeID match the specified Universal IDs.
|
||||
* @param sourceID universal source archive ID
|
||||
* @param datatypeID universal datatype ID
|
||||
* @return enum record found or null
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID)
|
||||
throws IOException;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.UniversalID;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.UniversalID;
|
||||
|
||||
/**
|
||||
* Adapter needed for a read-only version of data type manager that is not going
|
||||
|
@ -67,13 +65,13 @@ class EnumDBAdapterNoTable extends EnumDBAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return new long[0];
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return new long[0];
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,16 +15,15 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.data.DataTypeManager;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.UniversalIdGenerator;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for accessing the Enumeration database table.
|
||||
*/
|
||||
|
@ -38,9 +36,10 @@ class EnumDBAdapterV0 extends EnumDBAdapter implements RecordTranslator {
|
|||
static final int V0_ENUM_CAT_COL = 2;
|
||||
static final int V0_ENUM_SIZE_COL = 3;
|
||||
|
||||
static final Schema V0_ENUM_SCHEMA = new Schema(VERSION, "Enum ID", new Class[] {
|
||||
StringField.class, StringField.class, LongField.class, ByteField.class }, new String[] {
|
||||
"Name", "Comment", "Category ID", "Size" });
|
||||
static final Schema V0_ENUM_SCHEMA = new Schema(
|
||||
VERSION, "Enum ID", new Field[] { StringField.INSTANCE, StringField.INSTANCE,
|
||||
LongField.INSTANCE, ByteField.INSTANCE },
|
||||
new String[] { "Name", "Comment", "Category ID", "Size" });
|
||||
|
||||
private Table enumTable;
|
||||
|
||||
|
@ -58,9 +57,8 @@ class EnumDBAdapterV0 extends EnumDBAdapter implements RecordTranslator {
|
|||
}
|
||||
int version = enumTable.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + ENUM_TABLE_NAME + " but got " +
|
||||
enumTable.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + ENUM_TABLE_NAME +
|
||||
" but got " + enumTable.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -102,18 +100,16 @@ class EnumDBAdapterV0 extends EnumDBAdapter implements RecordTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return enumTable.findRecords(new LongField(categoryID), V0_ENUM_CAT_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return new long[0];
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see db.RecordTranslator#translateRecord(db.Record)
|
||||
*/
|
||||
@Override
|
||||
public Record translateRecord(Record oldRec) {
|
||||
if (oldRec == null) {
|
||||
return null;
|
||||
|
@ -135,16 +131,4 @@ class EnumDBAdapterV0 extends EnumDBAdapter implements RecordTranslator {
|
|||
return null;
|
||||
}
|
||||
|
||||
// private void testVersion(Table table, int expectedVersion, String name)
|
||||
// throws DatabaseVersionException {
|
||||
//
|
||||
// if (table == null) {
|
||||
// throw new DatabaseVersionException(name+ " not found");
|
||||
// }
|
||||
// int versionNumber = table.getSchema().getVersion();
|
||||
// if (versionNumber != expectedVersion) {
|
||||
// throw new DatabaseVersionException(
|
||||
// name+": Expected Version "+expectedVersion+ ", got " + versionNumber);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,13 +15,12 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 1 implementation for accessing the Enumeration database table.
|
||||
|
@ -40,11 +38,12 @@ class EnumDBAdapterV1 extends EnumDBAdapter {
|
|||
static final int V1_ENUM_SOURCE_SYNC_TIME_COL = 6;
|
||||
static final int V1_ENUM_LAST_CHANGE_TIME_COL = 7;
|
||||
|
||||
static final Schema V1_ENUM_SCHEMA = new Schema(VERSION, "Enum ID", new Class[] {
|
||||
StringField.class, StringField.class, LongField.class, ByteField.class, LongField.class,
|
||||
LongField.class, LongField.class, LongField.class }, new String[] { "Name", "Comment",
|
||||
"Category ID", "Size", "Source Archive ID", "Source Data Type ID", "Source Sync Time",
|
||||
"Last Change Time" });
|
||||
static final Schema V1_ENUM_SCHEMA = new Schema(VERSION, "Enum ID",
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE,
|
||||
ByteField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE,
|
||||
LongField.INSTANCE },
|
||||
new String[] { "Name", "Comment", "Category ID", "Size", "Source Archive ID",
|
||||
"Source Data Type ID", "Source Sync Time", "Last Change Time" });
|
||||
|
||||
private Table enumTable;
|
||||
|
||||
|
@ -58,9 +57,8 @@ class EnumDBAdapterV1 extends EnumDBAdapter {
|
|||
public EnumDBAdapterV1(DBHandle handle, boolean create) throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
enumTable =
|
||||
handle.createTable(ENUM_TABLE_NAME, V1_ENUM_SCHEMA, new int[] { V1_ENUM_CAT_COL,
|
||||
V1_ENUM_UNIVERSAL_DT_ID_COL });
|
||||
enumTable = handle.createTable(ENUM_TABLE_NAME, V1_ENUM_SCHEMA,
|
||||
new int[] { V1_ENUM_CAT_COL, V1_ENUM_UNIVERSAL_DT_ID_COL });
|
||||
}
|
||||
else {
|
||||
enumTable = handle.getTable(ENUM_TABLE_NAME);
|
||||
|
@ -69,9 +67,8 @@ class EnumDBAdapterV1 extends EnumDBAdapter {
|
|||
}
|
||||
int version = enumTable.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + ENUM_TABLE_NAME + " but got " +
|
||||
enumTable.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + ENUM_TABLE_NAME +
|
||||
" but got " + enumTable.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -128,19 +125,19 @@ class EnumDBAdapterV1 extends EnumDBAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return enumTable.findRecords(new LongField(categoryID), V1_ENUM_CAT_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return enumTable.findRecords(new LongField(archiveID), V1_ENUM_SOURCE_ARCHIVE_ID_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID) throws IOException {
|
||||
long[] keys =
|
||||
enumTable.findRecords(new LongField(datatypeID.getValue()), V1_ENUM_UNIVERSAL_DT_ID_COL);
|
||||
Field[] keys = enumTable.findRecords(new LongField(datatypeID.getValue()),
|
||||
V1_ENUM_UNIVERSAL_DT_ID_COL);
|
||||
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record record = enumTable.getRecord(keys[i]);
|
||||
|
@ -151,16 +148,4 @@ class EnumDBAdapterV1 extends EnumDBAdapter {
|
|||
return null;
|
||||
}
|
||||
|
||||
// private void testVersion(Table table, int expectedVersion, String name)
|
||||
// throws DatabaseVersionException {
|
||||
//
|
||||
// if (table == null) {
|
||||
// throw new DatabaseVersionException(name+ " not found");
|
||||
// }
|
||||
// int versionNumber = table.getSchema().getVersion();
|
||||
// if (versionNumber != expectedVersion) {
|
||||
// throw new DatabaseVersionException(
|
||||
// name+": Expected Version "+expectedVersion+ ", got " + versionNumber);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,12 +21,11 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Adapter to access the Enumeration data type values tables.
|
||||
|
@ -63,7 +61,7 @@ abstract class EnumValueDBAdapter {
|
|||
if (!e.isUpgradable() || openMode == DBConstants.UPDATE) {
|
||||
throw e;
|
||||
}
|
||||
EnumValueDBAdapter adapter = findReadOnlyAdapter(handle);
|
||||
EnumValueDBAdapter adapter = new EnumValueDBAdapterNoTable(handle);
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
adapter = upgrade(handle, adapter);
|
||||
}
|
||||
|
@ -71,16 +69,6 @@ abstract class EnumValueDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to get a read only adapter for the database whose handle is passed to this method.
|
||||
* @param handle handle to prior version of the database.
|
||||
* @return the read only Enumeration Data Type Values table adapter
|
||||
* @throws VersionException if a read only adapter can't be obtained for the database handle's version.
|
||||
*/
|
||||
static EnumValueDBAdapter findReadOnlyAdapter(DBHandle handle) {
|
||||
return new EnumValueDBAdapterNoTable(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrades the Enumeration Data Type Values table from the oldAdapter's version to the current version.
|
||||
* @param handle handle to the database whose table is to be upgraded to a newer version.
|
||||
|
@ -95,8 +83,21 @@ abstract class EnumValueDBAdapter {
|
|||
return new EnumValueDBAdapterV0(handle, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new enum value record corresponding to specified enum datatype ID
|
||||
* @param enumID enum datatype ID
|
||||
* @param name value name
|
||||
* @param value numeric value
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract void createRecord(long enumID, String name, long value) throws IOException;
|
||||
|
||||
/**
|
||||
* Get enum value record which corresponds to specified value record ID
|
||||
* @param valueID value record ID
|
||||
* @return value record or null
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getRecord(long valueID) throws IOException;
|
||||
|
||||
/**
|
||||
|
@ -113,6 +114,12 @@ abstract class EnumValueDBAdapter {
|
|||
*/
|
||||
abstract void updateRecord(Record record) throws IOException;
|
||||
|
||||
abstract long[] getValueIdsInEnum(long enumID) throws IOException;
|
||||
/**
|
||||
* Get enum value record IDs which correspond to specified enum datatype ID
|
||||
* @param enumID enum datatype ID
|
||||
* @return enum value record IDs as LongField values within Field array
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Field[] getValueIdsInEnum(long enumID) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,9 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.DBHandle;
|
||||
import db.Record;
|
||||
import db.*;
|
||||
|
||||
/**
|
||||
* Adapter needed for a read-only version of data type manager that is not going
|
||||
|
@ -32,14 +28,14 @@ class EnumValueDBAdapterNoTable extends EnumValueDBAdapter {
|
|||
/**
|
||||
* Gets a pre-table version of the adapter for the enumeration data type values database table.
|
||||
* @param handle handle to the database which doesn't contain the table.
|
||||
* @throws VersionException if the the table's version does not match the expected version
|
||||
* for this adapter.
|
||||
*/
|
||||
public EnumValueDBAdapterNoTable(DBHandle handle) {
|
||||
// no table needed
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRecord(long enumID, String name, long value) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,11 +50,12 @@ class EnumValueDBAdapterNoTable extends EnumValueDBAdapter {
|
|||
|
||||
@Override
|
||||
public void removeRecord(long valueID) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getValueIdsInEnum(long enumID) throws IOException {
|
||||
return new long[0];
|
||||
public Field[] getValueIdsInEnum(long enumID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for the enumeration tables adapter.
|
||||
|
@ -34,9 +32,9 @@ class EnumValueDBAdapterV0 extends EnumValueDBAdapter {
|
|||
static final int V0_ENUMVAL_VALUE_COL = 1;
|
||||
static final int V0_ENUMVAL_ID_COL = 2;
|
||||
|
||||
static final Schema V0_ENUM_VALUE_SCHEMA = new Schema(0, "Enum Value ID", new Class[] {
|
||||
StringField.class, LongField.class, LongField.class }, new String[] { "Name", "Value",
|
||||
"Enum ID" });
|
||||
static final Schema V0_ENUM_VALUE_SCHEMA = new Schema(0, "Enum Value ID",
|
||||
new Field[] { StringField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Name", "Value", "Enum ID" });
|
||||
|
||||
private Table valueTable;
|
||||
|
||||
|
@ -46,14 +44,14 @@ class EnumValueDBAdapterV0 extends EnumValueDBAdapter {
|
|||
* @param create true if this constructor should create the table.
|
||||
* @throws VersionException if the the table's version does not match the expected version
|
||||
* for this adapter.
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
public EnumValueDBAdapterV0(DBHandle handle, boolean create) throws VersionException,
|
||||
IOException {
|
||||
public EnumValueDBAdapterV0(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
valueTable =
|
||||
handle.createTable(ENUM_VALUE_TABLE_NAME, V0_ENUM_VALUE_SCHEMA,
|
||||
new int[] { V0_ENUMVAL_ID_COL });
|
||||
valueTable = handle.createTable(ENUM_VALUE_TABLE_NAME, V0_ENUM_VALUE_SCHEMA,
|
||||
new int[] { V0_ENUMVAL_ID_COL });
|
||||
}
|
||||
else {
|
||||
valueTable = handle.getTable(ENUM_VALUE_TABLE_NAME);
|
||||
|
@ -62,9 +60,8 @@ class EnumValueDBAdapterV0 extends EnumValueDBAdapter {
|
|||
}
|
||||
int version = valueTable.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + ENUM_VALUE_TABLE_NAME +
|
||||
" but got " + valueTable.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + ENUM_VALUE_TABLE_NAME +
|
||||
" but got " + valueTable.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -98,20 +95,7 @@ class EnumValueDBAdapterV0 extends EnumValueDBAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getValueIdsInEnum(long enumID) throws IOException {
|
||||
public Field[] getValueIdsInEnum(long enumID) throws IOException {
|
||||
return valueTable.findRecords(new LongField(enumID), V0_ENUMVAL_ID_COL);
|
||||
}
|
||||
|
||||
// private void testVersion(Table table, int expectedVersion, String name)
|
||||
// throws DatabaseVersionException {
|
||||
//
|
||||
// if (table == null) {
|
||||
// throw new DatabaseVersionException(name+ " not found");
|
||||
// }
|
||||
// int versionNumber = table.getSchema().getVersion();
|
||||
// if (versionNumber != expectedVersion) {
|
||||
// throw new DatabaseVersionException(
|
||||
// name+": Expected Version "+expectedVersion+ ", got " + versionNumber);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
|
@ -57,9 +58,9 @@ class FunctionDefinitionDB extends DataTypeDB implements FunctionDefinition {
|
|||
private void loadParameters() {
|
||||
parameters = new ArrayList<>();
|
||||
try {
|
||||
long[] ids = paramAdapter.getParameterIdsInFunctionDef(key);
|
||||
for (long id : ids) {
|
||||
Record rec = paramAdapter.getRecord(id);
|
||||
Field[] ids = paramAdapter.getParameterIdsInFunctionDef(key);
|
||||
for (Field id : ids) {
|
||||
Record rec = paramAdapter.getRecord(id.getLongValue());
|
||||
parameters.add(new ParameterDefinitionDB(dataMgr, paramAdapter, this, rec));
|
||||
}
|
||||
Collections.sort(parameters);
|
||||
|
|
|
@ -65,8 +65,8 @@ abstract class FunctionDefinitionDBAdapter {
|
|||
* @throws VersionException if the database handle's version doesn't match the expected version.
|
||||
* @throws IOException if there is trouble accessing the database.
|
||||
*/
|
||||
static FunctionDefinitionDBAdapter getAdapter(DBHandle handle, int openMode, TaskMonitor monitor)
|
||||
throws VersionException, IOException {
|
||||
static FunctionDefinitionDBAdapter getAdapter(DBHandle handle, int openMode,
|
||||
TaskMonitor monitor) throws VersionException, IOException {
|
||||
if (openMode == DBConstants.CREATE) {
|
||||
return new FunctionDefinitionDBAdapterV1(handle, true);
|
||||
}
|
||||
|
@ -91,7 +91,8 @@ abstract class FunctionDefinitionDBAdapter {
|
|||
* @return the read only Function Definition data type table adapter
|
||||
* @throws VersionException if a read only adapter can't be obtained for the database handle's version.
|
||||
*/
|
||||
static FunctionDefinitionDBAdapter findReadOnlyAdapter(DBHandle handle) throws VersionException {
|
||||
static FunctionDefinitionDBAdapter findReadOnlyAdapter(DBHandle handle)
|
||||
throws VersionException {
|
||||
try {
|
||||
return new FunctionDefinitionDBAdapterV0(handle);
|
||||
}
|
||||
|
@ -205,7 +206,7 @@ abstract class FunctionDefinitionDBAdapter {
|
|||
* @return an array of IDs for the function definition data types in the category.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract long[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
abstract Field[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
|
||||
/**
|
||||
* Gets an array with the IDs of all data types in the function definition table that were derived
|
||||
|
@ -214,8 +215,15 @@ abstract class FunctionDefinitionDBAdapter {
|
|||
* @return the array data type IDs.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract long[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
abstract Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get function definition record whoose sourceID and datatypeID match the specified Universal IDs.
|
||||
* @param sourceID universal source archive ID
|
||||
* @param datatypeID universal datatype ID
|
||||
* @return function definition record found or null
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID)
|
||||
throws IOException;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,14 +15,12 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.program.database.util.EmptyRecordIterator;
|
||||
import ghidra.program.model.data.GenericCallingConvention;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.util.EmptyRecordIterator;
|
||||
import ghidra.program.model.data.GenericCallingConvention;
|
||||
import ghidra.util.UniversalID;
|
||||
|
||||
/**
|
||||
* Adapter needed for a read-only version of data type manager that is not going
|
||||
|
@ -34,10 +31,9 @@ class FunctionDefinitionDBAdapterNoTable extends FunctionDefinitionDBAdapter {
|
|||
/**
|
||||
* Gets a pre-table version of the adapter for the Function Definition database table.
|
||||
* @param handle handle to the database which doesn't contain the table.
|
||||
* @throws VersionException if the the table's version does not match the expected version
|
||||
* for this adapter.
|
||||
*/
|
||||
public FunctionDefinitionDBAdapterNoTable(DBHandle handle) {
|
||||
// no table required
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,16 +66,17 @@ class FunctionDefinitionDBAdapterNoTable extends FunctionDefinitionDBAdapter {
|
|||
|
||||
@Override
|
||||
protected void deleteTable(DBHandle handle) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return new long[0];
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return new long[0];
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,19 +15,19 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.UniversalIdGenerator;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for accessing the Function Signature Definition database table.
|
||||
*/
|
||||
class FunctionDefinitionDBAdapterV0 extends FunctionDefinitionDBAdapter implements RecordTranslator {
|
||||
class FunctionDefinitionDBAdapterV0 extends FunctionDefinitionDBAdapter
|
||||
implements RecordTranslator {
|
||||
static final int VERSION = 0;
|
||||
static final int V0_FUNCTION_DEF_NAME_COL = 0;
|
||||
static final int V0_FUNCTION_DEF_COMMENT_COL = 1;
|
||||
|
@ -60,9 +59,8 @@ class FunctionDefinitionDBAdapterV0 extends FunctionDefinitionDBAdapter implemen
|
|||
}
|
||||
int version = table.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + FUNCTION_DEF_TABLE_NAME +
|
||||
" but got " + table.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + FUNCTION_DEF_TABLE_NAME +
|
||||
" but got " + table.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -104,18 +102,16 @@ class FunctionDefinitionDBAdapterV0 extends FunctionDefinitionDBAdapter implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), V0_FUNCTION_DEF_CAT_ID_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return new long[0];
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see db.RecordTranslator#translateRecord(db.Record)
|
||||
*/
|
||||
@Override
|
||||
public Record translateRecord(Record oldRec) {
|
||||
if (oldRec == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,15 +15,14 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.program.model.data.GenericCallingConvention;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.model.data.GenericCallingConvention;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 1 implementation for accessing the Function Signature Definition database table.
|
||||
|
@ -40,11 +38,12 @@ class FunctionDefinitionDBAdapterV1 extends FunctionDefinitionDBAdapter {
|
|||
static final int V1_FUNCTION_DEF_UNIVERSAL_DT_ID_COL = 6;
|
||||
static final int V1_FUNCTION_DEF_SOURCE_SYNC_TIME_COL = 7;
|
||||
static final int V1_FUNCTION_DEF_LAST_CHANGE_TIME_COL = 8;
|
||||
static final Schema V1_FUN_DEF_SCHEMA = new Schema(VERSION, "Data Type ID", new Class[] {
|
||||
StringField.class, StringField.class, LongField.class, LongField.class, ByteField.class,
|
||||
LongField.class, LongField.class, LongField.class, LongField.class }, new String[] {
|
||||
"Name", "Comment", "Category ID", "Return Type ID", "Flags", "Source Archive ID",
|
||||
"Source Data Type ID", "Source Sync Time", "Last Change Time" });
|
||||
static final Schema V1_FUN_DEF_SCHEMA = new Schema(VERSION, "Data Type ID",
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE,
|
||||
LongField.INSTANCE, ByteField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE,
|
||||
LongField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Name", "Comment", "Category ID", "Return Type ID", "Flags",
|
||||
"Source Archive ID", "Source Data Type ID", "Source Sync Time", "Last Change Time" });
|
||||
|
||||
private Table table;
|
||||
|
||||
|
@ -55,13 +54,12 @@ class FunctionDefinitionDBAdapterV1 extends FunctionDefinitionDBAdapter {
|
|||
* @throws VersionException if the the table's version does not match the expected version
|
||||
* for this adapter.
|
||||
*/
|
||||
public FunctionDefinitionDBAdapterV1(DBHandle handle, boolean create) throws VersionException,
|
||||
IOException {
|
||||
public FunctionDefinitionDBAdapterV1(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
table =
|
||||
handle.createTable(FUNCTION_DEF_TABLE_NAME, V1_FUN_DEF_SCHEMA, new int[] {
|
||||
V1_FUNCTION_DEF_CAT_ID_COL, V1_FUNCTION_DEF_UNIVERSAL_DT_ID_COL });
|
||||
table = handle.createTable(FUNCTION_DEF_TABLE_NAME, V1_FUN_DEF_SCHEMA,
|
||||
new int[] { V1_FUNCTION_DEF_CAT_ID_COL, V1_FUNCTION_DEF_UNIVERSAL_DT_ID_COL });
|
||||
}
|
||||
else {
|
||||
table = handle.getTable(FUNCTION_DEF_TABLE_NAME);
|
||||
|
@ -70,9 +68,8 @@ class FunctionDefinitionDBAdapterV1 extends FunctionDefinitionDBAdapter {
|
|||
}
|
||||
int version = table.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + FUNCTION_DEF_TABLE_NAME +
|
||||
" but got " + table.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " +
|
||||
FUNCTION_DEF_TABLE_NAME + " but got " + table.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -150,20 +147,19 @@ class FunctionDefinitionDBAdapterV1 extends FunctionDefinitionDBAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), V1_FUNCTION_DEF_CAT_ID_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return table.findRecords(new LongField(archiveID), V1_FUNCTION_DEF_SOURCE_ARCHIVE_ID_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID) throws IOException {
|
||||
long[] keys =
|
||||
table.findRecords(new LongField(datatypeID.getValue()),
|
||||
V1_FUNCTION_DEF_UNIVERSAL_DT_ID_COL);
|
||||
Field[] keys = table.findRecords(new LongField(datatypeID.getValue()),
|
||||
V1_FUNCTION_DEF_UNIVERSAL_DT_ID_COL);
|
||||
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record record = table.getRecord(keys[i]);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Adapter to access the Function Signature Definition Parameters database table.
|
||||
|
@ -134,31 +132,31 @@ abstract class FunctionParameterAdapter {
|
|||
abstract protected RecordIterator getRecords() throws IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param handle
|
||||
* @throws IOException
|
||||
* Delete underlying database table
|
||||
* @param handle database handle
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract protected void deleteTable(DBHandle handle) throws IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataTypeID
|
||||
* @param parentID
|
||||
* @param ordinal
|
||||
* @param name
|
||||
* @param comment
|
||||
* @param dtLength
|
||||
* @return
|
||||
* @throws IOException
|
||||
* Create new parameter definition record
|
||||
* @param dataTypeID parameter datatype ID
|
||||
* @param parentID parent function definition ID
|
||||
* @param ordinal parameter ordinal
|
||||
* @param name parameter name
|
||||
* @param comment parameter comment
|
||||
* @param dtLength datatype length if required, else -1
|
||||
* @return new record
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record createRecord(long dataTypeID, long parentID, int ordinal, String name,
|
||||
String comment, int dtLength) throws IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parameterID
|
||||
* @return
|
||||
* @throws IOException
|
||||
* Get parameter definition record
|
||||
* @param parameterID parameter record ID
|
||||
* @return parameter definition record or null
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getRecord(long parameterID) throws IOException;
|
||||
|
||||
|
@ -178,11 +176,11 @@ abstract class FunctionParameterAdapter {
|
|||
abstract boolean removeRecord(long parameterID) throws IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param functionDefID
|
||||
* @return
|
||||
* @throws IOException
|
||||
* Get parameter definition IDs for specified function definition
|
||||
* @param functionDefID function definition ID
|
||||
* @return parameter definition IDs as LongField values within Field array
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract long[] getParameterIdsInFunctionDef(long functionDefID) throws IOException;
|
||||
abstract Field[] getParameterIdsInFunctionDef(long functionDefID) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.program.database.util.EmptyRecordIterator;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.util.EmptyRecordIterator;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Adapter needed for a read-only version of data type manager that is not going
|
||||
|
@ -36,6 +34,7 @@ class FunctionParameterAdapterNoTable extends FunctionParameterAdapter {
|
|||
* for this adapter.
|
||||
*/
|
||||
public FunctionParameterAdapterNoTable(DBHandle handle) {
|
||||
// no table required
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,11 +65,12 @@ class FunctionParameterAdapterNoTable extends FunctionParameterAdapter {
|
|||
|
||||
@Override
|
||||
protected void deleteTable(DBHandle handle) throws IOException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getParameterIdsInFunctionDef(long functionDefID) throws IOException {
|
||||
return new long[0];
|
||||
public Field[] getParameterIdsInFunctionDef(long functionDefID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for accessing the Function Definition Parameters database table.
|
||||
|
@ -35,8 +33,9 @@ class FunctionParameterAdapterV0 extends FunctionParameterAdapter implements Rec
|
|||
static final int V0_PARAMETER_COMMENT_COL = 3;
|
||||
static final int V0_PARAMETER_ORDINAL_COL = 4;
|
||||
|
||||
static final Schema V0_PARAMETER_SCHEMA = new Schema(VERSION, "Parameter ID", new Class[] {
|
||||
LongField.class, LongField.class, StringField.class, StringField.class, IntField.class },
|
||||
static final Schema V0_PARAMETER_SCHEMA = new Schema(VERSION, "Parameter ID",
|
||||
new Field[] { LongField.INSTANCE, LongField.INSTANCE, StringField.INSTANCE,
|
||||
StringField.INSTANCE, IntField.INSTANCE },
|
||||
new String[] { "Parent ID", "Data Type ID", "Name", "Comment", "Ordinal" });
|
||||
|
||||
private Table parameterTable;
|
||||
|
@ -55,9 +54,8 @@ class FunctionParameterAdapterV0 extends FunctionParameterAdapter implements Rec
|
|||
}
|
||||
int version = parameterTable.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + PARAMETER_TABLE_NAME + " but got " +
|
||||
parameterTable.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + PARAMETER_TABLE_NAME +
|
||||
" but got " + parameterTable.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -110,13 +108,14 @@ class FunctionParameterAdapterV0 extends FunctionParameterAdapter implements Rec
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getParameterIdsInFunctionDef(long functionDefID) throws IOException {
|
||||
public Field[] getParameterIdsInFunctionDef(long functionDefID) throws IOException {
|
||||
return parameterTable.findRecords(new LongField(functionDefID), V0_PARAMETER_PARENT_ID_COL);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see db.RecordTranslator#translateRecord(db.Record)
|
||||
*/
|
||||
@Override
|
||||
public Record translateRecord(Record oldRec) {
|
||||
if (oldRec == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 1 implementation for accessing the Function Definition Parameters database table.
|
||||
|
@ -36,10 +34,11 @@ class FunctionParameterAdapterV1 extends FunctionParameterAdapter {
|
|||
static final int V1_PARAMETER_ORDINAL_COL = 4;
|
||||
static final int V1_PARAMETER_DT_LENGTH_COL = 5;
|
||||
|
||||
static final Schema V1_PARAMETER_SCHEMA = new Schema(VERSION, "Parameter ID", new Class[] {
|
||||
LongField.class, LongField.class, StringField.class, StringField.class, IntField.class,
|
||||
IntField.class }, new String[] { "Parent ID", "Data Type ID", "Name", "Comment", "Ordinal",
|
||||
"Data Type Length" });
|
||||
static final Schema V1_PARAMETER_SCHEMA = new Schema(VERSION, "Parameter ID",
|
||||
new Field[] { LongField.INSTANCE, LongField.INSTANCE, StringField.INSTANCE,
|
||||
StringField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE },
|
||||
new String[] { "Parent ID", "Data Type ID", "Name", "Comment", "Ordinal",
|
||||
"Data Type Length" });
|
||||
|
||||
private Table table;
|
||||
|
||||
|
@ -50,13 +49,12 @@ class FunctionParameterAdapterV1 extends FunctionParameterAdapter {
|
|||
* @throws VersionException if the the table's version does not match the expected version
|
||||
* for this adapter.
|
||||
*/
|
||||
public FunctionParameterAdapterV1(DBHandle handle, boolean create) throws VersionException,
|
||||
IOException {
|
||||
public FunctionParameterAdapterV1(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
table =
|
||||
handle.createTable(PARAMETER_TABLE_NAME, V1_PARAMETER_SCHEMA,
|
||||
new int[] { V1_PARAMETER_PARENT_ID_COL });
|
||||
table = handle.createTable(PARAMETER_TABLE_NAME, V1_PARAMETER_SCHEMA,
|
||||
new int[] { V1_PARAMETER_PARENT_ID_COL });
|
||||
}
|
||||
else {
|
||||
table = handle.getTable(PARAMETER_TABLE_NAME);
|
||||
|
@ -65,9 +63,8 @@ class FunctionParameterAdapterV1 extends FunctionParameterAdapter {
|
|||
}
|
||||
int version = table.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + PARAMETER_TABLE_NAME +
|
||||
" but got " + table.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + PARAMETER_TABLE_NAME +
|
||||
" but got " + table.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -122,7 +119,7 @@ class FunctionParameterAdapterV1 extends FunctionParameterAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getParameterIdsInFunctionDef(long functionDefID) throws IOException {
|
||||
public Field[] getParameterIdsInFunctionDef(long functionDefID) throws IOException {
|
||||
return table.findRecords(new LongField(functionDefID), V1_PARAMETER_PARENT_ID_COL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -141,7 +140,7 @@ abstract class InstanceSettingsDBAdapter {
|
|||
* Get keys for the instance settings applied at the given address.
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract long[] getInstanceKeys(long addr) throws IOException;
|
||||
abstract Field[] getInstanceKeys(long addr) throws IOException;
|
||||
|
||||
/**
|
||||
* Remove the instance record.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,13 +15,12 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -37,9 +35,9 @@ class InstanceSettingsDBAdapterV0 extends InstanceSettingsDBAdapter {
|
|||
static final int V0_INST_BYTE_VALUE_COL = 4;
|
||||
|
||||
static final Schema V0_INSTANCE_SCHEMA = new Schema(0, "Settings ID",
|
||||
new Class[] { LongField.class, StringField.class, LongField.class, StringField.class,
|
||||
BinaryField.class }, new String[] { "Address", "Settings Name", "Long Value",
|
||||
"String Value", "Byte Value" });
|
||||
new Field[] { LongField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE,
|
||||
StringField.INSTANCE, BinaryField.INSTANCE },
|
||||
new String[] { "Address", "Settings Name", "Long Value", "String Value", "Byte Value" });
|
||||
|
||||
private Table instanceTable;
|
||||
|
||||
|
@ -47,13 +45,12 @@ class InstanceSettingsDBAdapterV0 extends InstanceSettingsDBAdapter {
|
|||
* Constructor
|
||||
*
|
||||
*/
|
||||
InstanceSettingsDBAdapterV0(DBHandle handle, boolean create) throws VersionException,
|
||||
IOException {
|
||||
InstanceSettingsDBAdapterV0(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
instanceTable =
|
||||
handle.createTable(INSTANCE_TABLE_NAME, V0_INSTANCE_SCHEMA,
|
||||
new int[] { V0_INST_ADDR_COL });
|
||||
instanceTable = handle.createTable(INSTANCE_TABLE_NAME, V0_INSTANCE_SCHEMA,
|
||||
new int[] { V0_INST_ADDR_COL });
|
||||
}
|
||||
else {
|
||||
instanceTable = handle.getTable(INSTANCE_TABLE_NAME);
|
||||
|
@ -67,9 +64,6 @@ class InstanceSettingsDBAdapterV0 extends InstanceSettingsDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#createInstanceRecord(long, java.lang.String, java.lang.String, long, byte[])
|
||||
*/
|
||||
@Override
|
||||
public Record createInstanceRecord(long addr, String name, String strValue, long longValue,
|
||||
byte[] byteValue) throws IOException {
|
||||
|
@ -84,72 +78,47 @@ class InstanceSettingsDBAdapterV0 extends InstanceSettingsDBAdapter {
|
|||
return record;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#getInstanceKeys(long)
|
||||
*/
|
||||
@Override
|
||||
public long[] getInstanceKeys(long addr) throws IOException {
|
||||
public Field[] getInstanceKeys(long addr) throws IOException {
|
||||
return instanceTable.findRecords(new LongField(addr), V0_INST_ADDR_COL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#removeInstanceRecords(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeInstanceRecord(long settingsID) throws IOException {
|
||||
return instanceTable.deleteRecord(settingsID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#getInstanceRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getInstanceRecord(long settingsID) throws IOException {
|
||||
return instanceTable.getRecord(settingsID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#updateInstanceRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
public void updateInstanceRecord(Record record) throws IOException {
|
||||
instanceTable.putRecord(record);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#getRecords(long, long)
|
||||
*/
|
||||
@Override
|
||||
public RecordIterator getRecords(long start, long end) throws IOException {
|
||||
|
||||
return instanceTable.indexIterator(V0_INST_ADDR_COL, new LongField(start), new LongField(
|
||||
end), true);
|
||||
return instanceTable.indexIterator(V0_INST_ADDR_COL, new LongField(start),
|
||||
new LongField(end), true);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#getRecords()
|
||||
*/
|
||||
@Override
|
||||
RecordIterator getRecords() throws IOException {
|
||||
return instanceTable.iterator();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#getRecordCount()
|
||||
*/
|
||||
@Override
|
||||
int getRecordCount() {
|
||||
return instanceTable.getRecordCount();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ghidra.program.database.data.InstanceSettingsDBAdapter#delete(long, long, ghidra.util.task.TaskMonitor)
|
||||
*/
|
||||
@Override
|
||||
void delete(long start, long end, TaskMonitor monitor) throws CancelledException, IOException {
|
||||
DBLongIterator it =
|
||||
instanceTable.indexKeyIterator(V0_INST_ADDR_COL, new LongField(start), new LongField(
|
||||
end), true);
|
||||
DBFieldIterator it = instanceTable.indexKeyIterator(V0_INST_ADDR_COL, new LongField(start),
|
||||
new LongField(end), true);
|
||||
while (it.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new CancelledException();
|
||||
|
|
|
@ -67,32 +67,12 @@ abstract class ParentChildAdapter {
|
|||
|
||||
abstract boolean needsInitializing();
|
||||
|
||||
/**
|
||||
* Get the version number for this adapter
|
||||
*/
|
||||
abstract int getVersion();
|
||||
|
||||
/**
|
||||
* @param parentID
|
||||
* @param childID
|
||||
*/
|
||||
abstract void createRecord(long parentID, long childID) throws IOException;
|
||||
|
||||
/**
|
||||
* @param parentID
|
||||
* @param childID
|
||||
*/
|
||||
abstract void removeRecord(long parentID, long childID) throws IOException;
|
||||
|
||||
/**
|
||||
* @param childID
|
||||
* @return
|
||||
*/
|
||||
abstract long[] getParentIds(long childID) throws IOException;
|
||||
|
||||
/**
|
||||
* @param dataTypeID
|
||||
*/
|
||||
abstract void removeAllRecordsForParent(long parentID) throws IOException;
|
||||
|
||||
abstract void removeAllRecordsForChild(long childID) throws IOException;
|
||||
|
|
|
@ -28,50 +28,30 @@ class ParentChildDBAdapterNoTable extends ParentChildAdapter {
|
|||
* @throws VersionException if the the table's version does not match the expected version
|
||||
* for this adapter.
|
||||
*/
|
||||
public ParentChildDBAdapterNoTable(DBHandle handle) {
|
||||
ParentChildDBAdapterNoTable(DBHandle handle) {
|
||||
// no table required
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#getVersion()
|
||||
*/
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#createRecord(long, long)
|
||||
*/
|
||||
@Override
|
||||
void createRecord(long parentID, long childID) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#removeRecord(long, long)
|
||||
*/
|
||||
@Override
|
||||
void removeRecord(long parentID, long childID) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#getParentIds(long)
|
||||
*/
|
||||
@Override
|
||||
long[] getParentIds(long childID) throws IOException {
|
||||
return new long[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#needsInitializing()
|
||||
*/
|
||||
@Override
|
||||
boolean needsInitializing() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#removeAllRecordsForParent(long)
|
||||
*/
|
||||
@Override
|
||||
void removeAllRecordsForParent(long parentID) throws IOException {
|
||||
// stub
|
||||
|
|
|
@ -26,18 +26,14 @@ class ParentChildDBAdapterV0 extends ParentChildAdapter {
|
|||
|
||||
private static final int PARENT_COL = 0;
|
||||
private static final int CHILD_COL = 1;
|
||||
static final Schema V0_SCHEMA = new Schema(0, "KEY",
|
||||
new Class[] { LongField.class, LongField.class }, new String[] { "Parent ID", "Child ID" });
|
||||
static final Schema V0_SCHEMA =
|
||||
new Schema(0, "KEY", new Field[] { LongField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Parent ID", "Child ID" });
|
||||
|
||||
private Table table;
|
||||
private boolean needsInitializing = false;
|
||||
|
||||
/**
|
||||
* @param handle
|
||||
* @param b
|
||||
*/
|
||||
public ParentChildDBAdapterV0(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
ParentChildDBAdapterV0(DBHandle handle, boolean create) throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
table = handle.createTable(TABLE_NAME, V0_SCHEMA, new int[] { PARENT_COL, CHILD_COL });
|
||||
|
@ -54,17 +50,6 @@ class ParentChildDBAdapterV0 extends ParentChildAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#getVersion()
|
||||
*/
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.EnumDBAdapter#createEnumRecord(java.lang.String, java.lang.String, long, byte)
|
||||
*/
|
||||
@Override
|
||||
public void createRecord(long parentID, long childID) throws IOException {
|
||||
long key = table.getKey();
|
||||
|
@ -74,14 +59,11 @@ class ParentChildDBAdapterV0 extends ParentChildAdapter {
|
|||
table.putRecord(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#removeRecord(long, long)
|
||||
*/
|
||||
@Override
|
||||
void removeRecord(long parentID, long childID) throws IOException {
|
||||
|
||||
long[] ids = table.findRecords(new LongField(childID), CHILD_COL);
|
||||
for (long id : ids) {
|
||||
Field[] ids = table.findRecords(new LongField(childID), CHILD_COL);
|
||||
for (Field id : ids) {
|
||||
Record rec = table.getRecord(id);
|
||||
if (rec.getLongValue(PARENT_COL) == parentID) {
|
||||
table.deleteRecord(id);
|
||||
|
@ -90,12 +72,9 @@ class ParentChildDBAdapterV0 extends ParentChildAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#getParentIds(long)
|
||||
*/
|
||||
@Override
|
||||
long[] getParentIds(long childID) throws IOException {
|
||||
long[] ids = table.findRecords(new LongField(childID), CHILD_COL);
|
||||
Field[] ids = table.findRecords(new LongField(childID), CHILD_COL);
|
||||
long[] parentIds = new long[ids.length];
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
Record rec = table.getRecord(ids[i]);
|
||||
|
@ -108,29 +87,23 @@ class ParentChildDBAdapterV0 extends ParentChildAdapter {
|
|||
needsInitializing = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#needsInitializing()
|
||||
*/
|
||||
@Override
|
||||
boolean needsInitializing() {
|
||||
return needsInitializing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.ParentChildAdapter#removeAllRecordsForParent(long)
|
||||
*/
|
||||
@Override
|
||||
void removeAllRecordsForParent(long parentID) throws IOException {
|
||||
long[] ids = table.findRecords(new LongField(parentID), PARENT_COL);
|
||||
for (long id : ids) {
|
||||
Field[] ids = table.findRecords(new LongField(parentID), PARENT_COL);
|
||||
for (Field id : ids) {
|
||||
table.deleteRecord(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void removeAllRecordsForChild(long childID) throws IOException {
|
||||
long[] ids = table.findRecords(new LongField(childID), CHILD_COL);
|
||||
for (long id : ids) {
|
||||
Field[] ids = table.findRecords(new LongField(childID), CHILD_COL);
|
||||
for (Field id : ids) {
|
||||
table.deleteRecord(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,13 +15,12 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Adapter to access the Pointer database table for Pointer data types.
|
||||
|
@ -31,9 +29,9 @@ import db.*;
|
|||
abstract class PointerDBAdapter {
|
||||
static final String POINTER_TABLE_NAME = "Pointers";
|
||||
|
||||
static final Schema SCHEMA = new Schema(PointerDBAdapterV2.VERSION, "Pointer ID", new Class[] {
|
||||
LongField.class, LongField.class, ByteField.class }, new String[] { "Data Type ID",
|
||||
"Category ID", "Length" });
|
||||
static final Schema SCHEMA = new Schema(PointerDBAdapterV2.VERSION, "Pointer ID",
|
||||
new Field[] { LongField.INSTANCE, LongField.INSTANCE, ByteField.INSTANCE },
|
||||
new String[] { "Data Type ID", "Category ID", "Length" });
|
||||
|
||||
static final int PTR_DT_ID_COL = 0;
|
||||
static final int PTR_CATEGORY_COL = 1;
|
||||
|
@ -114,6 +112,7 @@ abstract class PointerDBAdapter {
|
|||
/**
|
||||
* Get the record with the given pointerID.
|
||||
* @param pointerID database key
|
||||
* @return requested pointer record or null if not found
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract Record getRecord(long pointerID) throws IOException;
|
||||
|
@ -130,11 +129,19 @@ abstract class PointerDBAdapter {
|
|||
|
||||
/**
|
||||
* Update the record in the table.
|
||||
* @param record pointer record to be updated
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract void updateRecord(Record record) throws IOException;
|
||||
|
||||
abstract long[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
/**
|
||||
* Gets all the pointer data types that are contained in the category that
|
||||
* have the indicated ID.
|
||||
* @param categoryID the category whose pointer data types are wanted.
|
||||
* @return an array of IDs for the pointer data types in the category.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract Field[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
|
||||
Record translateRecord(Record rec) {
|
||||
return rec;
|
||||
|
@ -147,23 +154,28 @@ abstract class PointerDBAdapter {
|
|||
this.it = it;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() throws IOException {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrevious() throws IOException {
|
||||
return it.hasPrevious();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record next() throws IOException {
|
||||
Record rec = it.next();
|
||||
return translateRecord(rec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record previous() throws IOException {
|
||||
Record rec = it.previous();
|
||||
return translateRecord(rec);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for the accessing the pointer database table.
|
||||
|
@ -38,10 +36,6 @@ class PointerDBAdapterV0 extends PointerDBAdapter {
|
|||
|
||||
private Table table;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
PointerDBAdapterV0(DBHandle handle) throws VersionException {
|
||||
|
||||
table = handle.getTable(POINTER_TABLE_NAME);
|
||||
|
@ -54,53 +48,34 @@ class PointerDBAdapterV0 extends PointerDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#createRecord(long, long)
|
||||
*/
|
||||
@Override
|
||||
Record createRecord(long dataTypeID, long categoryID, int length) throws IOException {
|
||||
throw new UnsupportedOperationException("Cannot update Version 0");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecord(long)
|
||||
*/
|
||||
@Override
|
||||
Record getRecord(long pointerID) throws IOException {
|
||||
return translateRecord(table.getRecord(pointerID));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecords()
|
||||
*/
|
||||
@Override
|
||||
RecordIterator getRecords() throws IOException {
|
||||
return new TranslatedRecordIterator(table.iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#removeRecord(long)
|
||||
*/
|
||||
@Override
|
||||
boolean removeRecord(long pointerID) throws IOException {
|
||||
throw new UnsupportedOperationException("Cannot update Version 0");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#updateRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
void updateRecord(Record record) throws IOException {
|
||||
throw new UnsupportedOperationException("Cannot update Version 0");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecordIdsInCategory(long)
|
||||
*/
|
||||
@Override
|
||||
long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return new long[0];
|
||||
Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,9 +89,6 @@ class PointerDBAdapterV0 extends PointerDBAdapter {
|
|||
return rec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#deleteTable()
|
||||
*/
|
||||
@Override
|
||||
void deleteTable(DBHandle handle) throws IOException {
|
||||
handle.deleteTable(POINTER_TABLE_NAME);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 1 adapter for the Pointer table.
|
||||
|
@ -30,8 +28,9 @@ class PointerDBAdapterV1 extends PointerDBAdapter {
|
|||
|
||||
static final int OLD_PTR_DT_ID_COL = 0;
|
||||
static final int OLD_PTR_CATEGORY_COL = 1;
|
||||
static final Schema V1_SCHEMA = new Schema(VERSION, "Pointer ID", new Class[] {
|
||||
LongField.class, LongField.class }, new String[] { "Data Type ID", "Category ID" });
|
||||
static final Schema V1_SCHEMA =
|
||||
new Schema(VERSION, "Pointer ID", new Field[] { LongField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Data Type ID", "Category ID" });
|
||||
|
||||
private Table table;
|
||||
|
||||
|
@ -66,49 +65,31 @@ class PointerDBAdapterV1 extends PointerDBAdapter {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecord(long)
|
||||
*/
|
||||
@Override
|
||||
Record getRecord(long pointerID) throws IOException {
|
||||
return translateRecord(table.getRecord(pointerID));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecords()
|
||||
*/
|
||||
@Override
|
||||
RecordIterator getRecords() throws IOException {
|
||||
return new TranslatedRecordIterator(table.iterator());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#removeRecord(long)
|
||||
*/
|
||||
@Override
|
||||
boolean removeRecord(long pointerID) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#updateRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
void updateRecord(Record record) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecordIdsInCategory(long)
|
||||
*/
|
||||
@Override
|
||||
long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), OLD_PTR_CATEGORY_COL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#deleteTable()
|
||||
*/
|
||||
@Override
|
||||
void deleteTable(DBHandle handle) throws IOException {
|
||||
handle.deleteTable(POINTER_TABLE_NAME);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
class PointerDBAdapterV2 extends PointerDBAdapter {
|
||||
final static int VERSION = 2;
|
||||
|
@ -47,9 +45,6 @@ class PointerDBAdapterV2 extends PointerDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#createRecord(long, int)
|
||||
*/
|
||||
@Override
|
||||
Record createRecord(long dataTypeID, long categoryID, int length) throws IOException {
|
||||
long tableKey = table.getKey();
|
||||
|
@ -63,49 +58,31 @@ class PointerDBAdapterV2 extends PointerDBAdapter {
|
|||
return record;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecord(long)
|
||||
*/
|
||||
@Override
|
||||
Record getRecord(long pointerID) throws IOException {
|
||||
return table.getRecord(pointerID);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecords()
|
||||
*/
|
||||
@Override
|
||||
RecordIterator getRecords() throws IOException {
|
||||
return table.iterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#removeRecord(long)
|
||||
*/
|
||||
@Override
|
||||
boolean removeRecord(long pointerID) throws IOException {
|
||||
return table.deleteRecord(pointerID);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#updateRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
void updateRecord(Record record) throws IOException {
|
||||
table.putRecord(record);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#getRecordIdsInCategory(long)
|
||||
*/
|
||||
@Override
|
||||
long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), PTR_CATEGORY_COL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#deleteTable()
|
||||
*/
|
||||
@Override
|
||||
void deleteTable(DBHandle handle) throws IOException {
|
||||
handle.deleteTable(POINTER_TABLE_NAME);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Adapter to access the default settings and instance settings database tables.
|
||||
|
@ -48,6 +46,7 @@ abstract class SettingsDBAdapter {
|
|||
|
||||
/**
|
||||
* Returns number of settings records
|
||||
* @return total settings record count
|
||||
*/
|
||||
abstract int getRecordCount();
|
||||
|
||||
|
@ -58,16 +57,20 @@ abstract class SettingsDBAdapter {
|
|||
* @param strValue string value; null if setting is not String
|
||||
* @param longValue long value; -1 if setting is not a long
|
||||
* @param byteValue byte array value; null if setting is not a byte array
|
||||
* @return new record
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract Record createSettingsRecord(long dataTypeID, String name, String strValue,
|
||||
long longValue, byte[] byteValue) throws IOException;
|
||||
|
||||
/**
|
||||
* Get keys for the default settings for the given data type ID.
|
||||
* Get settings record keys for the default settings corresponding to the
|
||||
* specified data type ID.
|
||||
* @param dataTypeID datatype ID
|
||||
* @return settings record keys returned as LongFields within Field array
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract long[] getSettingsKeys(long dataTypeID) throws IOException;
|
||||
abstract Field[] getSettingsKeys(long dataTypeID) throws IOException;
|
||||
|
||||
/**
|
||||
* Remove the default settings record.
|
||||
|
@ -80,6 +83,7 @@ abstract class SettingsDBAdapter {
|
|||
/**
|
||||
* Get the default settings record.
|
||||
* @param settingsID key for the record
|
||||
* @return record corresponding to settingsID or null
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract Record getSettingsRecord(long settingsID) throws IOException;
|
||||
|
|
|
@ -15,18 +15,13 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* {@literal Window>Preferences>Java>Code Generation>Code and Comments}
|
||||
*
|
||||
*
|
||||
* Version 0 implementation for the accessing the data type settings database table.
|
||||
*/
|
||||
class SettingsDBAdapterV0 extends SettingsDBAdapter {
|
||||
|
||||
|
@ -38,21 +33,17 @@ class SettingsDBAdapterV0 extends SettingsDBAdapter {
|
|||
static final int V0_SETTINGS_BYTE_VALUE_COL = 4;
|
||||
|
||||
static final Schema V0_SETTINGS_SCHEMA = new Schema(0, "DT Settings ID",
|
||||
new Class[] { LongField.class, StringField.class, LongField.class, StringField.class,
|
||||
BinaryField.class }, new String[] { "Data Type ID", "Settings Name", "Long Value",
|
||||
"String Value", "Byte Value" });
|
||||
new Field[] { LongField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE,
|
||||
StringField.INSTANCE, BinaryField.INSTANCE },
|
||||
new String[] { "Data Type ID", "Settings Name", "Long Value", "String Value",
|
||||
"Byte Value" });
|
||||
private Table settingsTable;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
SettingsDBAdapterV0(DBHandle handle, boolean create) throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
settingsTable =
|
||||
handle.createTable(SETTINGS_TABLE_NAME, V0_SETTINGS_SCHEMA,
|
||||
new int[] { V0_SETTINGS_DT_ID_COL });
|
||||
settingsTable = handle.createTable(SETTINGS_TABLE_NAME, V0_SETTINGS_SCHEMA,
|
||||
new int[] { V0_SETTINGS_DT_ID_COL });
|
||||
}
|
||||
else {
|
||||
settingsTable = handle.getTable(SETTINGS_TABLE_NAME);
|
||||
|
@ -66,9 +57,6 @@ class SettingsDBAdapterV0 extends SettingsDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.SettingsDBAdapter#createSettingsRecord(long, java.lang.String, java.lang.String, long, byte[])
|
||||
*/
|
||||
@Override
|
||||
public Record createSettingsRecord(long dataTypeID, String name, String strValue,
|
||||
long longValue, byte[] byteValue) throws IOException {
|
||||
|
@ -83,41 +71,26 @@ class SettingsDBAdapterV0 extends SettingsDBAdapter {
|
|||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.SettingsDBAdapter#getSettingsKeys(long)
|
||||
*/
|
||||
@Override
|
||||
public long[] getSettingsKeys(long dataTypeID) throws IOException {
|
||||
public Field[] getSettingsKeys(long dataTypeID) throws IOException {
|
||||
return settingsTable.findRecords(new LongField(dataTypeID), V0_SETTINGS_DT_ID_COL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.SettingsDBAdapter#removeSettingsRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeSettingsRecord(long settingsID) throws IOException {
|
||||
return settingsTable.deleteRecord(settingsID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.SettingsDBAdapter#getSettingsRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getSettingsRecord(long settingsID) throws IOException {
|
||||
return settingsTable.getRecord(settingsID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.SettingsDBAdapter#updateSettingsRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
public void updateSettingsRecord(Record record) throws IOException {
|
||||
settingsTable.putRecord(record);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ghidra.program.database.data.SettingsDBAdapter#getRecordCount()
|
||||
*/
|
||||
@Override
|
||||
int getRecordCount() {
|
||||
return settingsTable.getRecordCount();
|
||||
|
|
|
@ -15,17 +15,15 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.data.DataTypeComponent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import db.Record;
|
||||
|
||||
/**
|
||||
* Database implementation for settings.
|
||||
*
|
||||
|
@ -73,9 +71,7 @@ class SettingsDBManager implements Settings {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#getLong(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Long getLong(String name) {
|
||||
SettingsDB settingsDB = getSettingsDB(name);
|
||||
if (settingsDB != null) {
|
||||
|
@ -87,9 +83,7 @@ class SettingsDBManager implements Settings {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#getString(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String getString(String name) {
|
||||
SettingsDB settingsDB = getSettingsDB(name);
|
||||
if (settingsDB != null) {
|
||||
|
@ -101,9 +95,7 @@ class SettingsDBManager implements Settings {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#getByteArray(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public byte[] getByteArray(String name) {
|
||||
SettingsDB settingsDB = getSettingsDB(name);
|
||||
if (settingsDB != null) {
|
||||
|
@ -115,9 +107,7 @@ class SettingsDBManager implements Settings {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#getValue(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Object getValue(String name) {
|
||||
SettingsDB settingsDB = getSettingsDB(name);
|
||||
if (settingsDB != null) {
|
||||
|
@ -129,9 +119,7 @@ class SettingsDBManager implements Settings {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#setLong(java.lang.String, long)
|
||||
*/
|
||||
@Override
|
||||
public void setLong(String name, long value) {
|
||||
try {
|
||||
if (updateSettingsRecord(name, null, value, null)) {
|
||||
|
@ -144,9 +132,7 @@ class SettingsDBManager implements Settings {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#setString(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setString(String name, String value) {
|
||||
|
||||
try {
|
||||
|
@ -159,9 +145,7 @@ class SettingsDBManager implements Settings {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#setByteArray(java.lang.String, byte[])
|
||||
*/
|
||||
@Override
|
||||
public void setByteArray(String name, byte[] value) {
|
||||
try {
|
||||
if (updateSettingsRecord(name, null, -1, value)) {
|
||||
|
@ -173,9 +157,7 @@ class SettingsDBManager implements Settings {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#setValue(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void setValue(String name, Object value) {
|
||||
if (value instanceof Long) {
|
||||
setLong(name, ((Long) value).longValue());
|
||||
|
@ -191,18 +173,16 @@ class SettingsDBManager implements Settings {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#clearSetting(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void clearSetting(String name) {
|
||||
|
||||
try {
|
||||
long[] keys = adapter.getSettingsKeys(dataTypeID);
|
||||
Field[] keys = adapter.getSettingsKeys(dataTypeID);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record rec = adapter.getSettingsRecord(keys[i]);
|
||||
Record rec = adapter.getSettingsRecord(keys[i].getLongValue());
|
||||
String settingsName = rec.getString(SettingsDBAdapter.SETTINGS_NAME_COL);
|
||||
if (settingsName.equals(name)) {
|
||||
adapter.removeSettingsRecord(keys[i]);
|
||||
adapter.removeSettingsRecord(keys[i].getLongValue());
|
||||
settingsChanged();
|
||||
return;
|
||||
}
|
||||
|
@ -213,14 +193,12 @@ class SettingsDBManager implements Settings {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#clearAllSettings()
|
||||
*/
|
||||
@Override
|
||||
public void clearAllSettings() {
|
||||
try {
|
||||
long[] keys = adapter.getSettingsKeys(dataTypeID);
|
||||
Field[] keys = adapter.getSettingsKeys(dataTypeID);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
adapter.removeSettingsRecord(keys[i]);
|
||||
adapter.removeSettingsRecord(keys[i].getLongValue());
|
||||
}
|
||||
settingsChanged();
|
||||
}
|
||||
|
@ -229,15 +207,13 @@ class SettingsDBManager implements Settings {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#getNames()
|
||||
*/
|
||||
@Override
|
||||
public String[] getNames() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
try {
|
||||
long[] keys = adapter.getSettingsKeys(dataTypeID);
|
||||
Field[] keys = adapter.getSettingsKeys(dataTypeID);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record rec = adapter.getSettingsRecord(keys[i]);
|
||||
Record rec = adapter.getSettingsRecord(keys[i].getLongValue());
|
||||
String name = rec.getString(SettingsDBAdapter.SETTINGS_NAME_COL);
|
||||
if (!list.contains(name)) {
|
||||
list.add(name);
|
||||
|
@ -252,9 +228,7 @@ class SettingsDBManager implements Settings {
|
|||
return new String[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#isEmpty()
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
try {
|
||||
return adapter.getSettingsKeys(dataTypeID).length == 0;
|
||||
|
@ -274,7 +248,15 @@ class SettingsDBManager implements Settings {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compare values and return true if old and new values are different.
|
||||
* Following settings value change compare old and new values and return
|
||||
* true if old and new values are different.
|
||||
* @param oldStrValue old settings string value
|
||||
* @param newStrValue new settings string value
|
||||
* @param oldByteValue old settings byte array value
|
||||
* @param newByteValue new settings byte array value
|
||||
* @param oldLongValue old settings long value
|
||||
* @param newLongValue new settings long value
|
||||
* @return true true if value change detected else false
|
||||
*/
|
||||
static boolean valuesChanged(String oldStrValue, String newStrValue, byte[] oldByteValue,
|
||||
byte[] newByteValue, long oldLongValue, long newLongValue) {
|
||||
|
@ -295,9 +277,9 @@ class SettingsDBManager implements Settings {
|
|||
|
||||
private Record getRecord(String name) {
|
||||
try {
|
||||
long[] keys = adapter.getSettingsKeys(dataTypeID);
|
||||
Field[] keys = adapter.getSettingsKeys(dataTypeID);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record rec = adapter.getSettingsRecord(keys[i]);
|
||||
Record rec = adapter.getSettingsRecord(keys[i].getLongValue());
|
||||
if (rec.getString(SettingsDBAdapter.SETTINGS_NAME_COL).equals(name)) {
|
||||
return rec;
|
||||
}
|
||||
|
@ -333,9 +315,8 @@ class SettingsDBManager implements Settings {
|
|||
byte[] recByteValue = record.getBinaryData(SettingsDBAdapter.SETTINGS_BYTE_VALUE_COL);
|
||||
long recLongValue = record.getLongValue(SettingsDBAdapter.SETTINGS_LONG_VALUE_COL);
|
||||
|
||||
wasChanged =
|
||||
valuesChanged(recStrValue, strValue, recByteValue, byteValue, recLongValue,
|
||||
longValue);
|
||||
wasChanged = valuesChanged(recStrValue, strValue, recByteValue, byteValue, recLongValue,
|
||||
longValue);
|
||||
if (wasChanged) {
|
||||
record.setString(SettingsDBAdapter.SETTINGS_STRING_VALUE_COL, strValue);
|
||||
record.setLongValue(SettingsDBAdapter.SETTINGS_LONG_VALUE_COL, longValue);
|
||||
|
@ -346,9 +327,7 @@ class SettingsDBManager implements Settings {
|
|||
return wasChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.docking.settings.Settings#getDefaultSettings()
|
||||
*/
|
||||
@Override
|
||||
public Settings getDefaultSettings() {
|
||||
// This settings object already represents the default settings
|
||||
return null;
|
||||
|
|
|
@ -36,8 +36,8 @@ class SourceArchiveAdapterV0 extends SourceArchiveAdapter {
|
|||
static final int V0_ARCHIVE_ID_DIRTY_FLAG_COL = 4;
|
||||
|
||||
static final Schema V0_SCHEMA = new Schema(VERSION, "Archive ID",
|
||||
new Class[] { StringField.class, StringField.class, ByteField.class, LongField.class,
|
||||
BooleanField.class },
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, ByteField.INSTANCE,
|
||||
LongField.INSTANCE, BooleanField.INSTANCE },
|
||||
new String[] { "Domain File ID", "Name", "Type", "Last Sync Time", "Dirty Flag" });
|
||||
|
||||
private Table table;
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
|
@ -65,9 +66,9 @@ class StructureDB extends CompositeDB implements Structure {
|
|||
components = new ArrayList<>();
|
||||
|
||||
try {
|
||||
long[] ids = componentAdapter.getComponentIdsInComposite(key);
|
||||
for (long id : ids) {
|
||||
Record rec = componentAdapter.getRecord(id);
|
||||
Field[] ids = componentAdapter.getComponentIdsInComposite(key);
|
||||
for (Field id : ids) {
|
||||
Record rec = componentAdapter.getRecord(id.getLongValue());
|
||||
DataTypeComponentDB component =
|
||||
new DataTypeComponentDB(dataMgr, componentAdapter, this, rec);
|
||||
if (component.isFlexibleArrayComponent()) {
|
||||
|
@ -83,6 +84,7 @@ class StructureDB extends CompositeDB implements Structure {
|
|||
}
|
||||
|
||||
Collections.sort(components, componentComparator);
|
||||
|
||||
structLength = record.getIntValue(CompositeDBAdapter.COMPOSITE_LENGTH_COL);
|
||||
numComponents = record.getIntValue(CompositeDBAdapter.COMPOSITE_NUM_COMPONENTS_COL);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,13 +15,12 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* Adapter to access the database table for typedef data types.
|
||||
|
@ -177,7 +175,7 @@ abstract class TypedefDBAdapter {
|
|||
* @return an array of IDs for the type definition data types in the category.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract long[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
abstract Field[] getRecordIdsInCategory(long categoryID) throws IOException;
|
||||
|
||||
/**
|
||||
* Gets an array with the IDs of all data types in the type definition table that were derived
|
||||
|
@ -186,8 +184,15 @@ abstract class TypedefDBAdapter {
|
|||
* @return the array data type IDs.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
abstract long[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
abstract Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get typedef record whoose sourceID and datatypeID match the specified Universal IDs.
|
||||
* @param sourceID universal source archive ID
|
||||
* @param datatypeID universal datatype ID
|
||||
* @return typedef record found or null
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID)
|
||||
throws IOException;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,16 +15,15 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.data.DataTypeManager;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.UniversalIdGenerator;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for accessing the Typedef database table.
|
||||
*/
|
||||
|
@ -55,9 +53,8 @@ class TypedefDBAdapterV0 extends TypedefDBAdapter implements RecordTranslator {
|
|||
}
|
||||
int version = table.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + TYPEDEF_TABLE_NAME + " but got " +
|
||||
table.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + TYPEDEF_TABLE_NAME +
|
||||
" but got " + table.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -98,18 +95,16 @@ class TypedefDBAdapterV0 extends TypedefDBAdapter implements RecordTranslator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), V0_TYPEDEF_CAT_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return new long[0];
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return Field.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see db.RecordTranslator#translateRecord(db.Record)
|
||||
*/
|
||||
@Override
|
||||
public Record translateRecord(Record oldRec) {
|
||||
if (oldRec == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,13 +15,12 @@
|
|||
*/
|
||||
package ghidra.program.database.data;
|
||||
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.UniversalID;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 1 implementation for accessing the Typedef database table.
|
||||
|
@ -36,10 +34,11 @@ class TypedefDBAdapterV1 extends TypedefDBAdapter {
|
|||
static final int V1_TYPEDEF_UNIVERSAL_DT_ID_COL = 4;
|
||||
static final int V1_TYPEDEF_SOURCE_SYNC_TIME_COL = 5;
|
||||
static final int V1_TYPEDEF_LAST_CHANGE_TIME_COL = 6;
|
||||
static final Schema V1_SCHEMA = new Schema(VERSION, "Typedef ID", new Class[] {
|
||||
LongField.class, StringField.class, LongField.class, LongField.class, LongField.class,
|
||||
LongField.class, LongField.class }, new String[] { "Data Type ID", "Name", "Category ID",
|
||||
"Source Archive ID", "Universal Data Type ID", "Source Sync Time", "Last Change Time" });
|
||||
static final Schema V1_SCHEMA = new Schema(VERSION, "Typedef ID",
|
||||
new Field[] { LongField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE,
|
||||
LongField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Data Type ID", "Name", "Category ID", "Source Archive ID",
|
||||
"Universal Data Type ID", "Source Sync Time", "Last Change Time" });
|
||||
private Table table;
|
||||
|
||||
/**
|
||||
|
@ -49,12 +48,12 @@ class TypedefDBAdapterV1 extends TypedefDBAdapter {
|
|||
* @throws VersionException if the the table's version does not match the expected version
|
||||
* for this adapter.
|
||||
*/
|
||||
public TypedefDBAdapterV1(DBHandle handle, boolean create) throws VersionException, IOException {
|
||||
public TypedefDBAdapterV1(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
table =
|
||||
handle.createTable(TYPEDEF_TABLE_NAME, V1_SCHEMA, new int[] { V1_TYPEDEF_CAT_COL,
|
||||
V1_TYPEDEF_UNIVERSAL_DT_ID_COL });
|
||||
table = handle.createTable(TYPEDEF_TABLE_NAME, V1_SCHEMA,
|
||||
new int[] { V1_TYPEDEF_CAT_COL, V1_TYPEDEF_UNIVERSAL_DT_ID_COL });
|
||||
}
|
||||
else {
|
||||
table = handle.getTable(TYPEDEF_TABLE_NAME);
|
||||
|
@ -63,9 +62,8 @@ class TypedefDBAdapterV1 extends TypedefDBAdapter {
|
|||
}
|
||||
int version = table.getSchema().getVersion();
|
||||
if (version != VERSION) {
|
||||
String msg =
|
||||
"Expected version " + VERSION + " for table " + TYPEDEF_TABLE_NAME +
|
||||
" but got " + table.getSchema().getVersion();
|
||||
String msg = "Expected version " + VERSION + " for table " + TYPEDEF_TABLE_NAME +
|
||||
" but got " + table.getSchema().getVersion();
|
||||
if (version < VERSION) {
|
||||
throw new VersionException(msg, VersionException.OLDER_VERSION, true);
|
||||
}
|
||||
|
@ -126,18 +124,18 @@ class TypedefDBAdapterV1 extends TypedefDBAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
public Field[] getRecordIdsInCategory(long categoryID) throws IOException {
|
||||
return table.findRecords(new LongField(categoryID), V1_TYPEDEF_CAT_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
long[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException {
|
||||
return table.findRecords(new LongField(archiveID), V1_TYPEDEF_SOURCE_ARCHIVE_ID_COL);
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecordWithIDs(UniversalID sourceID, UniversalID datatypeID) throws IOException {
|
||||
long[] keys =
|
||||
Field[] keys =
|
||||
table.findRecords(new LongField(datatypeID.getValue()), V1_TYPEDEF_UNIVERSAL_DT_ID_COL);
|
||||
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.data;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
|
@ -55,9 +56,9 @@ class UnionDB extends CompositeDB implements Union {
|
|||
components = new ArrayList<>();
|
||||
|
||||
try {
|
||||
long[] ids = componentAdapter.getComponentIdsInComposite(key);
|
||||
for (long id : ids) {
|
||||
Record rec = componentAdapter.getRecord(id);
|
||||
Field[] ids = componentAdapter.getComponentIdsInComposite(key);
|
||||
for (Field id : ids) {
|
||||
Record rec = componentAdapter.getRecord(id.getLongValue());
|
||||
components.add(new DataTypeComponentDB(dataMgr, componentAdapter, this, rec));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,20 +15,20 @@
|
|||
*/
|
||||
package ghidra.program.database.external;
|
||||
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
class OldExtNameAdapter {
|
||||
|
||||
final static String EXT_NAME_TABLE_NAME = "External Program Names";
|
||||
|
||||
static final Schema EXT_NAME_SCHEMA = new Schema(0, "Key", new Class[] { StringField.class,
|
||||
StringField.class }, new String[] { "External Name", "External Pathname" });
|
||||
static final Schema EXT_NAME_SCHEMA =
|
||||
new Schema(0, "Key", new Field[] { StringField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "External Name", "External Pathname" });
|
||||
|
||||
static final int EXT_NAME_COL = 0;
|
||||
static final int EXT_PATHNAME_COL = 1;
|
||||
|
@ -66,8 +65,8 @@ class OldExtNameAdapter {
|
|||
return nameTable.getRecordCount();
|
||||
}
|
||||
|
||||
private void moveTable(DBHandle handle, TaskMonitor monitor) throws IOException,
|
||||
CancelledException {
|
||||
private void moveTable(DBHandle handle, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
|
||||
DBHandle tmpHandle = handle.getScratchPad();
|
||||
Table newRefTable = tmpHandle.createTable(EXT_NAME_TABLE_NAME, EXT_NAME_SCHEMA);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,22 +15,22 @@
|
|||
*/
|
||||
package ghidra.program.database.external;
|
||||
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
class OldExtRefAdapter {
|
||||
|
||||
static final String EXT_REF_TABLE_NAME = "External References";
|
||||
|
||||
static final Schema EXT_REF_SCHEMA = new Schema(0, "Key", new Class[] { LongField.class,
|
||||
ShortField.class, BooleanField.class, LongField.class, StringField.class, LongField.class,
|
||||
BooleanField.class }, new String[] { "From Address", "Op Index", "User Defined",
|
||||
"External Name ID", "Label", "External To", "External To Exists" });
|
||||
static final Schema EXT_REF_SCHEMA = new Schema(0, "Key",
|
||||
new Field[] { LongField.INSTANCE, ShortField.INSTANCE, BooleanField.INSTANCE,
|
||||
LongField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE, BooleanField.INSTANCE },
|
||||
new String[] { "From Address", "Op Index", "User Defined", "External Name ID", "Label",
|
||||
"External To", "External To Exists" });
|
||||
|
||||
static final int FROM_ADDR_COL = 0;
|
||||
static final int OP_INDEX_COL = 1;
|
||||
|
@ -73,8 +72,8 @@ class OldExtRefAdapter {
|
|||
return refTable.getRecordCount();
|
||||
}
|
||||
|
||||
private void moveTable(DBHandle handle, TaskMonitor monitor) throws IOException,
|
||||
CancelledException {
|
||||
private void moveTable(DBHandle handle, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
|
||||
DBHandle tmpHandle = handle.getScratchPad();
|
||||
Table newRefTable = tmpHandle.createTable(EXT_REF_TABLE_NAME, EXT_REF_SCHEMA);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.function;
|
||||
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Version 0 implementation for the calling conventions tables adapter.
|
||||
|
@ -34,8 +32,8 @@ class CallingConventionDBAdapterV0 extends CallingConventionDBAdapter {
|
|||
// Key field is the Calling convention ID, which is a Byte field.
|
||||
static final int V0_CALLING_CONVENTION_NAME_COL = 0;
|
||||
|
||||
static final Schema V0_CALLING_CONVENTION_SCHEMA = new Schema(0, ByteField.class, "ID",
|
||||
new Class[] { StringField.class }, new String[] { "Name" });
|
||||
static final Schema V0_CALLING_CONVENTION_SCHEMA = new Schema(0, ByteField.INSTANCE, "ID",
|
||||
new Field[] { StringField.INSTANCE }, new String[] { "Name" });
|
||||
|
||||
private Table callingConventionTable;
|
||||
|
||||
|
@ -43,14 +41,13 @@ class CallingConventionDBAdapterV0 extends CallingConventionDBAdapter {
|
|||
* Constructor
|
||||
*
|
||||
*/
|
||||
public CallingConventionDBAdapterV0(DBHandle handle, boolean create) throws VersionException,
|
||||
IOException {
|
||||
public CallingConventionDBAdapterV0(DBHandle handle, boolean create)
|
||||
throws VersionException, IOException {
|
||||
|
||||
if (create) {
|
||||
// No additional indexed fields.
|
||||
callingConventionTable =
|
||||
handle.createTable(CALLING_CONVENTION_TABLE_NAME, V0_CALLING_CONVENTION_SCHEMA,
|
||||
new int[] {});
|
||||
callingConventionTable = handle.createTable(CALLING_CONVENTION_TABLE_NAME,
|
||||
V0_CALLING_CONVENTION_SCHEMA, new int[] {});
|
||||
}
|
||||
else {
|
||||
callingConventionTable = handle.getTable(CALLING_CONVENTION_TABLE_NAME);
|
||||
|
@ -63,9 +60,6 @@ class CallingConventionDBAdapterV0 extends CallingConventionDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.function.CallingConventionDBAdapter#createCallingConventionRecord(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Record createCallingConventionRecord(String name) throws IOException {
|
||||
byte key = getFirstAvailableKey();
|
||||
|
@ -94,9 +88,6 @@ class CallingConventionDBAdapterV0 extends CallingConventionDBAdapter {
|
|||
return key;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.database.function.CallingConventionDBAdapter#getCallingConventionRecord(byte)
|
||||
*/
|
||||
@Override
|
||||
public Record getCallingConventionRecord(byte callingConventionID) throws IOException {
|
||||
return callingConventionTable.getRecord(new ByteField(callingConventionID));
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,16 +15,15 @@
|
|||
*/
|
||||
package ghidra.program.database.function;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
|
||||
/**
|
||||
* Database adapter for functions.
|
||||
*/
|
||||
|
@ -51,11 +49,11 @@ abstract class FunctionAdapter {
|
|||
|
||||
static final int FUNCTION_SIGNATURE_SOURCE_SHIFT = 4; // bit shift for flag storage of "signature SourceType"
|
||||
|
||||
final static Schema FUNCTION_SCHEMA =
|
||||
new Schema(CURRENT_VERSION, "ID", new Class[] { LongField.class, IntField.class,
|
||||
IntField.class, IntField.class, ByteField.class, ByteField.class, StringField.class },
|
||||
new String[] { "Return DataType ID", "StackPurge", "StackReturnOffset",
|
||||
"StackLocalSize", "Flags", "Calling Convention ID", "Return Storage" });
|
||||
final static Schema FUNCTION_SCHEMA = new Schema(CURRENT_VERSION, "ID",
|
||||
new Field[] { LongField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE,
|
||||
ByteField.INSTANCE, ByteField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Return DataType ID", "StackPurge", "StackReturnOffset", "StackLocalSize",
|
||||
"Flags", "Calling Convention ID", "Return Storage" });
|
||||
|
||||
protected AddressMap addrMap;
|
||||
|
||||
|
|
|
@ -30,18 +30,17 @@ class FunctionTagAdapterV0 extends FunctionTagAdapter implements DBListener {
|
|||
static final int V0_TAG_NAME_COL = 0;
|
||||
static final int V0_COMMENT_COL = 1;
|
||||
|
||||
final static Schema V0_SCHEMA =
|
||||
new Schema(CURRENT_VERSION, "ID", new Class[] { StringField.class, StringField.class },
|
||||
new String[] { "Tag", "Comment" });
|
||||
final static Schema V0_SCHEMA = new Schema(CURRENT_VERSION, "ID",
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Tag", "Comment" });
|
||||
|
||||
private Table table; // lazy creation, null if empty
|
||||
private final DBHandle dbHandle;
|
||||
|
||||
FunctionTagAdapterV0(DBHandle dbHandle, boolean create)
|
||||
throws VersionException {
|
||||
FunctionTagAdapterV0(DBHandle dbHandle, boolean create) throws VersionException {
|
||||
|
||||
this.dbHandle = dbHandle;
|
||||
|
||||
|
||||
// This deserves an explanation:
|
||||
//
|
||||
// Both function tag tables are transient, meaning they're created only when necessary,
|
||||
|
@ -62,10 +61,8 @@ class FunctionTagAdapterV0 extends FunctionTagAdapter implements DBListener {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
Record getRecord(String tag) throws IOException {
|
||||
if (table == null) {
|
||||
|
@ -84,8 +81,7 @@ class FunctionTagAdapterV0 extends FunctionTagAdapter implements DBListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
Record createTagRecord(String tag, String comment)
|
||||
throws IOException {
|
||||
Record createTagRecord(String tag, String comment) throws IOException {
|
||||
|
||||
// See if there is already a record for this tag name. If so,
|
||||
// just return that one.
|
||||
|
@ -136,10 +132,10 @@ class FunctionTagAdapterV0 extends FunctionTagAdapter implements DBListener {
|
|||
void updateRecord(Record record) throws IOException {
|
||||
getTable().putRecord(record);
|
||||
}
|
||||
|
||||
|
||||
private Table getTable() throws IOException {
|
||||
if (table == null) {
|
||||
table = dbHandle.createTable(TABLE_NAME, V0_SCHEMA);
|
||||
table = dbHandle.createTable(TABLE_NAME, V0_SCHEMA);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
|
|
@ -34,14 +34,14 @@ class FunctionTagMappingAdapterV0 extends FunctionTagMappingAdapter implements D
|
|||
public static final int V0_FUNCTION_ID_COL = 0;
|
||||
public static final int V0_TAG_ID_COL = 1;
|
||||
|
||||
final static Schema SCHEMA = new Schema(CURRENT_VERSION, "ID",
|
||||
new Class[] { LongField.class, LongField.class }, new String[] { "Function ID", "Tag ID" });
|
||||
final static Schema SCHEMA =
|
||||
new Schema(CURRENT_VERSION, "ID", new Field[] { LongField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Function ID", "Tag ID" });
|
||||
|
||||
private Table table; // lazy creation, null if empty
|
||||
private final DBHandle dbHandle;
|
||||
|
||||
FunctionTagMappingAdapterV0(DBHandle dbHandle, boolean create)
|
||||
throws VersionException {
|
||||
FunctionTagMappingAdapterV0(DBHandle dbHandle, boolean create) throws VersionException {
|
||||
|
||||
this.dbHandle = dbHandle;
|
||||
|
||||
|
@ -72,7 +72,7 @@ class FunctionTagMappingAdapterV0 extends FunctionTagMappingAdapter implements D
|
|||
|
||||
@Override
|
||||
Record getRecord(long functionID, long tagID) throws IOException {
|
||||
|
||||
|
||||
if (table == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -93,8 +93,7 @@ class FunctionTagMappingAdapterV0 extends FunctionTagMappingAdapter implements D
|
|||
}
|
||||
|
||||
@Override
|
||||
Record createFunctionTagRecord(long functionID, long tagID)
|
||||
throws IOException {
|
||||
Record createFunctionTagRecord(long functionID, long tagID) throws IOException {
|
||||
|
||||
Table t = getTable();
|
||||
Record rec = SCHEMA.createRecord(t.getKey());
|
||||
|
@ -106,8 +105,7 @@ class FunctionTagMappingAdapterV0 extends FunctionTagMappingAdapter implements D
|
|||
}
|
||||
|
||||
@Override
|
||||
boolean removeFunctionTagRecord(long functionID, long tagID)
|
||||
throws IOException {
|
||||
boolean removeFunctionTagRecord(long functionID, long tagID) throws IOException {
|
||||
|
||||
Record record = getRecord(functionID, tagID);
|
||||
if (record != null) {
|
||||
|
@ -123,7 +121,7 @@ class FunctionTagMappingAdapterV0 extends FunctionTagMappingAdapter implements D
|
|||
if (table == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Tag ID is not an indexed column in the mapping table, so we just have to iterate
|
||||
// over all records. This operation is only done when deleting a tag (ie: not often)
|
||||
// so it won't be indexed.
|
||||
|
@ -169,7 +167,7 @@ class FunctionTagMappingAdapterV0 extends FunctionTagMappingAdapter implements D
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private Table getTable() throws IOException {
|
||||
if (table == null) {
|
||||
table = dbHandle.createTable(TABLE_NAME, SCHEMA, new int[] { V0_FUNCTION_ID_COL });
|
||||
|
@ -194,5 +192,5 @@ class FunctionTagMappingAdapterV0 extends FunctionTagMappingAdapter implements D
|
|||
public void tableAdded(DBHandle dbh, Table table) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ abstract class ThunkFunctionAdapter {
|
|||
static final int LINKED_FUNCTION_ID_COL = 0;
|
||||
|
||||
final static Schema THUNK_FUNCTION_SCHEMA = new Schema(CURRENT_VERSION, "ID",
|
||||
new Class[] { LongField.class }, new String[] { "Linked Function ID" });
|
||||
new Field[] { LongField.INSTANCE }, new String[] { "Linked Function ID" });
|
||||
|
||||
protected AddressMap addrMap;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,24 +15,23 @@
|
|||
*/
|
||||
package ghidra.program.database.map;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.model.address.*;
|
||||
|
||||
/**
|
||||
* Long iterator over indexed addresses. The longs are primary keys returned ordered and restrained
|
||||
* by the address field they contain
|
||||
*/
|
||||
public class AddressIndexPrimaryKeyIterator implements DBLongIterator {
|
||||
public class AddressIndexPrimaryKeyIterator implements DBFieldIterator {
|
||||
|
||||
private Table table;
|
||||
|
||||
private List<KeyRange> keyRangeList;
|
||||
private DBLongIterator it;
|
||||
private DBFieldIterator it;
|
||||
private int keyRangeIndex = -1;
|
||||
private int indexCol;
|
||||
|
||||
|
@ -113,16 +111,14 @@ public class AddressIndexPrimaryKeyIterator implements DBLongIterator {
|
|||
if (atStart) {
|
||||
keyRangeIndex = 0;
|
||||
KeyRange keyRange = keyRangeList.get(keyRangeIndex);
|
||||
it =
|
||||
table.indexKeyIterator(indexCol, new LongField(keyRange.minKey), new LongField(
|
||||
keyRange.maxKey), true);
|
||||
it = table.indexKeyIterator(indexCol, new LongField(keyRange.minKey),
|
||||
new LongField(keyRange.maxKey), true);
|
||||
}
|
||||
else {
|
||||
keyRangeIndex = keyRangeList.size() - 1;
|
||||
KeyRange keyRange = keyRangeList.get(keyRangeIndex);
|
||||
it =
|
||||
table.indexKeyIterator(indexCol, new LongField(keyRange.minKey), new LongField(
|
||||
keyRange.maxKey), false);
|
||||
it = table.indexKeyIterator(indexCol, new LongField(keyRange.minKey),
|
||||
new LongField(keyRange.maxKey), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,15 +165,13 @@ public class AddressIndexPrimaryKeyIterator implements DBLongIterator {
|
|||
keyRangeIndex = -keyRangeIndex - 1;
|
||||
if (keyRangeIndex == 0) {
|
||||
KeyRange keyRange = keyRangeList.get(keyRangeIndex);
|
||||
it =
|
||||
table.indexKeyIterator(indexCol, new LongField(keyRange.minKey), new LongField(
|
||||
keyRange.maxKey), true);
|
||||
it = table.indexKeyIterator(indexCol, new LongField(keyRange.minKey),
|
||||
new LongField(keyRange.maxKey), true);
|
||||
}
|
||||
else {
|
||||
KeyRange keyRange = keyRangeList.get(--keyRangeIndex);
|
||||
it =
|
||||
table.indexKeyIterator(indexCol, new LongField(keyRange.minKey), new LongField(
|
||||
keyRange.maxKey), false);
|
||||
it = table.indexKeyIterator(indexCol, new LongField(keyRange.minKey),
|
||||
new LongField(keyRange.maxKey), false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -185,15 +179,12 @@ public class AddressIndexPrimaryKeyIterator implements DBLongIterator {
|
|||
KeyRange keyRange = keyRangeList.get(keyRangeIndex);
|
||||
long startKey =
|
||||
absolute ? addrMap.getAbsoluteEncoding(start, false) : addrMap.getKey(start, false);
|
||||
it =
|
||||
table.indexKeyIterator(indexCol, new LongField(keyRange.minKey), new LongField(
|
||||
keyRange.maxKey), new LongField(startKey), before);
|
||||
it = table.indexKeyIterator(indexCol, new LongField(keyRange.minKey),
|
||||
new LongField(keyRange.maxKey), new LongField(startKey), before);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see db.DBLongIterator#hasNext()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasNext() throws IOException {
|
||||
if (it == null) {
|
||||
return false;
|
||||
|
@ -201,9 +192,8 @@ public class AddressIndexPrimaryKeyIterator implements DBLongIterator {
|
|||
else if (!it.hasNext()) {
|
||||
while (keyRangeIndex < (keyRangeList.size() - 1)) {
|
||||
KeyRange keyRange = keyRangeList.get(++keyRangeIndex);
|
||||
it =
|
||||
table.indexKeyIterator(indexCol, new LongField(keyRange.minKey), new LongField(
|
||||
keyRange.maxKey), true);
|
||||
it = table.indexKeyIterator(indexCol, new LongField(keyRange.minKey),
|
||||
new LongField(keyRange.maxKey), true);
|
||||
if (it.hasPrevious()) {
|
||||
it.previous();
|
||||
}
|
||||
|
@ -216,9 +206,7 @@ public class AddressIndexPrimaryKeyIterator implements DBLongIterator {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see db.DBLongIterator#hasPrevious()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPrevious() throws IOException {
|
||||
if (it == null) {
|
||||
return false;
|
||||
|
@ -226,9 +214,8 @@ public class AddressIndexPrimaryKeyIterator implements DBLongIterator {
|
|||
else if (!it.hasPrevious()) {
|
||||
while (keyRangeIndex > 0) {
|
||||
KeyRange keyRange = keyRangeList.get(--keyRangeIndex);
|
||||
it =
|
||||
table.indexKeyIterator(indexCol, new LongField(keyRange.minKey), new LongField(
|
||||
keyRange.maxKey), false);
|
||||
it = table.indexKeyIterator(indexCol, new LongField(keyRange.minKey),
|
||||
new LongField(keyRange.maxKey), false);
|
||||
if (it.hasNext()) {
|
||||
it.next();
|
||||
}
|
||||
|
@ -241,29 +228,23 @@ public class AddressIndexPrimaryKeyIterator implements DBLongIterator {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see db.DBLongIterator#next()
|
||||
*/
|
||||
public long next() throws IOException {
|
||||
@Override
|
||||
public Field next() throws IOException {
|
||||
if (hasNext()) {
|
||||
return it.next();
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see db.DBLongIterator#previous()
|
||||
*/
|
||||
public long previous() throws IOException {
|
||||
@Override
|
||||
public Field previous() throws IOException {
|
||||
if (hasPrevious()) {
|
||||
return it.previous();
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see db.DBLongIterator#delete()
|
||||
*/
|
||||
@Override
|
||||
public boolean delete() throws IOException {
|
||||
if (it != null) {
|
||||
return it.delete();
|
||||
|
|
|
@ -15,22 +15,22 @@
|
|||
*/
|
||||
package ghidra.program.database.map;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Adapter version 0 (the first real adapter)
|
||||
*/
|
||||
class AddressMapDBAdapterV0 extends AddressMapDBAdapter {
|
||||
|
||||
final Schema SCHEMA = new Schema(0, "Key", new Class[] { StringField.class, IntField.class,
|
||||
ShortField.class }, new String[] { "Space Name", "Segment", "Not Used" });
|
||||
final Schema SCHEMA = new Schema(0, "Key",
|
||||
new Field[] { StringField.INSTANCE, IntField.INSTANCE, ShortField.INSTANCE },
|
||||
new String[] { "Space Name", "Segment", "Not Used" });
|
||||
|
||||
final int SPACE_NAME_COL = 0;
|
||||
final int SEGMENT_COL = 1;
|
||||
|
@ -40,8 +40,8 @@ class AddressMapDBAdapterV0 extends AddressMapDBAdapter {
|
|||
private AddressFactory factory;
|
||||
private Address[] addresses;
|
||||
|
||||
AddressMapDBAdapterV0(DBHandle handle, AddressFactory factory) throws VersionException,
|
||||
IOException {
|
||||
AddressMapDBAdapterV0(DBHandle handle, AddressFactory factory)
|
||||
throws VersionException, IOException {
|
||||
this.handle = handle;
|
||||
this.factory = factory;
|
||||
table = handle.getTable(TABLE_NAME);
|
||||
|
@ -65,9 +65,8 @@ class AddressMapDBAdapterV0 extends AddressMapDBAdapter {
|
|||
int segment = rec.getIntValue(SEGMENT_COL);
|
||||
AddressSpace space = factory.getAddressSpace(spaceName);
|
||||
if (space == null) {
|
||||
GenericAddressSpace sp =
|
||||
new GenericAddressSpace("Deleted_" + spaceName, 32, AddressSpace.TYPE_UNKNOWN,
|
||||
deletedID++);
|
||||
GenericAddressSpace sp = new GenericAddressSpace("Deleted_" + spaceName, 32,
|
||||
AddressSpace.TYPE_UNKNOWN, deletedID++);
|
||||
sp.setShowSpaceName(true);
|
||||
space = sp;
|
||||
}
|
||||
|
|
|
@ -15,22 +15,22 @@
|
|||
*/
|
||||
package ghidra.program.database.map;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Adapter version 0 (the first real adapter)
|
||||
*/
|
||||
class AddressMapDBAdapterV1 extends AddressMapDBAdapter {
|
||||
|
||||
final Schema SCHEMA = new Schema(CURRENT_VERSION, "Key", new Class[] { StringField.class,
|
||||
IntField.class, BooleanField.class }, new String[] { "Space Name", "Segment", "Deleted" });
|
||||
final Schema SCHEMA = new Schema(CURRENT_VERSION, "Key",
|
||||
new Field[] { StringField.INSTANCE, IntField.INSTANCE, BooleanField.INSTANCE },
|
||||
new String[] { "Space Name", "Segment", "Deleted" });
|
||||
|
||||
final int SPACE_NAME_COL = 0;
|
||||
final int SEGMENT_COL = 1;
|
||||
|
@ -75,9 +75,8 @@ class AddressMapDBAdapterV1 extends AddressMapDBAdapter {
|
|||
if (segment != 0) {
|
||||
spaceName += "_" + segment;
|
||||
}
|
||||
GenericAddressSpace sp =
|
||||
new GenericAddressSpace(deletedName, 32, AddressSpace.TYPE_DELETED,
|
||||
(int) rec.getKey());
|
||||
GenericAddressSpace sp = new GenericAddressSpace(deletedName, 32,
|
||||
AddressSpace.TYPE_DELETED, (int) rec.getKey());
|
||||
sp.setShowSpaceName(true);
|
||||
space = sp;
|
||||
segment = 0;
|
||||
|
@ -157,8 +156,8 @@ class AddressMapDBAdapterV1 extends AddressMapDBAdapter {
|
|||
|
||||
Address[] newAddrs = new Address[addresses.length + 1];
|
||||
System.arraycopy(addresses, 0, newAddrs, 0, addresses.length);
|
||||
newAddrs[addresses.length] =
|
||||
addr.getAddressSpace().getAddressInThisSpaceOnly(normalizedOffset & ~AddressMapDB.ADDR_OFFSET_MASK);
|
||||
newAddrs[addresses.length] = addr.getAddressSpace().getAddressInThisSpaceOnly(
|
||||
normalizedOffset & ~AddressMapDB.ADDR_OFFSET_MASK);
|
||||
addresses = newAddrs;
|
||||
|
||||
return addresses;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,15 +15,14 @@
|
|||
*/
|
||||
package ghidra.program.database.map;
|
||||
|
||||
import ghidra.program.database.util.RecordFilter;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.KeyRange;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.util.RecordFilter;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.KeyRange;
|
||||
|
||||
/**
|
||||
* Static methods to delete records from a table. Handles subtle issues with image base causing
|
||||
|
@ -76,10 +74,10 @@ public class AddressRecordDeleter {
|
|||
Address end, RecordFilter filter) throws IOException {
|
||||
|
||||
boolean success = false;
|
||||
DBLongIterator iter =
|
||||
DBFieldIterator iter =
|
||||
new AddressIndexPrimaryKeyIterator(table, colIx, addrMap, start, end, true);
|
||||
while (iter.hasNext()) {
|
||||
long next = iter.next();
|
||||
Field next = iter.next();
|
||||
if (filter != null) {
|
||||
Record record = table.getRecord(next);
|
||||
if (!filter.matches(record)) {
|
||||
|
|
|
@ -37,8 +37,8 @@ class FileBytesAdapterV0 extends FileBytesAdapter {
|
|||
public static final int V0_LAYERED_BUF_IDS_COL = 4;
|
||||
|
||||
static final Schema SCHEMA = new Schema(VERSION, "Key",
|
||||
new Class[] { StringField.class, LongField.class, LongField.class, BinaryField.class,
|
||||
BinaryField.class },
|
||||
new Field[] { StringField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE,
|
||||
BinaryField.INSTANCE, BinaryField.INSTANCE },
|
||||
new String[] { "Filename", "Offset", "Size", "Chain Buffer IDs",
|
||||
"Layered Chain Buffer IDs" });
|
||||
|
||||
|
|
|
@ -58,14 +58,14 @@ public class MemoryMapDBAdapterV3 extends MemoryMapDBAdapter {
|
|||
public static final byte V3_SUB_TYPE_FILE_BYTES = 4;
|
||||
|
||||
static Schema V3_BLOCK_SCHEMA = new Schema(V3_VERSION, "Key",
|
||||
new Class[] { StringField.class, StringField.class, StringField.class, ByteField.class,
|
||||
LongField.class, LongField.class, IntField.class },
|
||||
new Field[] { StringField.INSTANCE, StringField.INSTANCE, StringField.INSTANCE,
|
||||
ByteField.INSTANCE, LongField.INSTANCE, LongField.INSTANCE, IntField.INSTANCE },
|
||||
new String[] { "Name", "Comments", "Source Name", "Permissions", "Start Address", "Length",
|
||||
"Segment" });
|
||||
|
||||
static Schema V3_SUB_BLOCK_SCHEMA = new Schema(V3_VERSION, "Key",
|
||||
new Class[] { LongField.class, ByteField.class, LongField.class, LongField.class,
|
||||
IntField.class, LongField.class },
|
||||
new Field[] { LongField.INSTANCE, ByteField.INSTANCE, LongField.INSTANCE,
|
||||
LongField.INSTANCE, IntField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Parent ID", "Type", "Length", "Starting Offset", "Source ID",
|
||||
"Source Address/Offset" });
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.module;
|
|||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.DatabaseObject;
|
||||
|
@ -74,26 +75,17 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#contains(ghidra.program.model.listing.CodeUnit)
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(CodeUnit codeUnit) {
|
||||
return contains(codeUnit.getMinAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramFragment#getCodeUnits()
|
||||
*/
|
||||
@Override
|
||||
public CodeUnitIterator getCodeUnits() {
|
||||
checkIsValid();
|
||||
return moduleMgr.getCodeUnits(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getComment()
|
||||
*/
|
||||
@Override
|
||||
public String getComment() {
|
||||
lock.acquire();
|
||||
|
@ -106,9 +98,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
lock.acquire();
|
||||
|
@ -121,15 +110,12 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getNumParents()
|
||||
*/
|
||||
@Override
|
||||
public int getNumParents() {
|
||||
lock.acquire();
|
||||
try {
|
||||
checkIsValid();
|
||||
long[] keys = adapter.getParentChildKeys(-key, TreeManager.CHILD_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(-key, TreeManager.CHILD_ID_COL);
|
||||
return keys.length;
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
@ -141,25 +127,16 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getParentNames()
|
||||
*/
|
||||
@Override
|
||||
public String[] getParentNames() {
|
||||
return moduleMgr.getParentNames(-key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getParents()
|
||||
*/
|
||||
@Override
|
||||
public ProgramModule[] getParents() {
|
||||
return moduleMgr.getParents(-key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramFragment#move(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public void move(Address min, Address max) throws NotFoundException {
|
||||
lock.acquire();
|
||||
|
@ -172,9 +149,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#setComment(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setComment(String comment) {
|
||||
lock.acquire();
|
||||
|
@ -198,9 +172,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#setName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setName(String name) throws DuplicateNameException {
|
||||
lock.acquire();
|
||||
|
@ -230,17 +201,11 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getTreeName()
|
||||
*/
|
||||
@Override
|
||||
public String getTreeName() {
|
||||
return moduleMgr.getTreeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#contains(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Address start, Address end) {
|
||||
lock.acquire();
|
||||
|
@ -253,9 +218,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#contains(ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Address addr) {
|
||||
lock.acquire();
|
||||
|
@ -268,9 +230,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#contains(ghidra.program.model.address.AddressSetView)
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(AddressSetView rangeSet) {
|
||||
lock.acquire();
|
||||
|
@ -283,9 +242,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#equals(ghidra.program.model.address.AddressSetView)
|
||||
*/
|
||||
@Override
|
||||
public boolean hasSameAddresses(AddressSetView view) {
|
||||
lock.acquire();
|
||||
|
@ -298,10 +254,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see ghidra.program.model.address.AddressSetView#getAddresses(boolean)
|
||||
*/
|
||||
@Override
|
||||
public AddressIterator getAddresses(boolean forward) {
|
||||
lock.acquire();
|
||||
|
@ -314,10 +266,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see ghidra.program.model.address.AddressSetView#getAddresses(ghidra.program.model.address.Address, boolean)
|
||||
*/
|
||||
@Override
|
||||
public AddressIterator getAddresses(Address start, boolean forward) {
|
||||
lock.acquire();
|
||||
|
@ -330,9 +278,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#getAddressRanges()
|
||||
*/
|
||||
@Override
|
||||
public AddressRangeIterator getAddressRanges() {
|
||||
lock.acquire();
|
||||
|
@ -350,10 +295,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
return getAddressRanges();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see ghidra.program.model.address.AddressSetView#getAddressRanges(boolean)
|
||||
*/
|
||||
@Override
|
||||
public AddressRangeIterator getAddressRanges(boolean atStart) {
|
||||
lock.acquire();
|
||||
|
@ -366,9 +307,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#getMaxAddress()
|
||||
*/
|
||||
@Override
|
||||
public Address getMaxAddress() {
|
||||
lock.acquire();
|
||||
|
@ -381,9 +319,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#getMinAddress()
|
||||
*/
|
||||
@Override
|
||||
public Address getMinAddress() {
|
||||
lock.acquire();
|
||||
|
@ -396,9 +331,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#getNumAddresses()
|
||||
*/
|
||||
@Override
|
||||
public long getNumAddresses() {
|
||||
lock.acquire();
|
||||
|
@ -411,9 +343,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#getNumAddressRanges()
|
||||
*/
|
||||
@Override
|
||||
public int getNumAddressRanges() {
|
||||
lock.acquire();
|
||||
|
@ -426,9 +355,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#intersect(ghidra.program.model.address.AddressSetView)
|
||||
*/
|
||||
@Override
|
||||
public AddressSet intersect(AddressSetView view) {
|
||||
lock.acquire();
|
||||
|
@ -441,9 +367,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#intersectRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public AddressSet intersectRange(Address start, Address end) {
|
||||
lock.acquire();
|
||||
|
@ -456,9 +379,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#intersects(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public boolean intersects(Address start, Address end) {
|
||||
lock.acquire();
|
||||
|
@ -471,9 +391,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#intersects(ghidra.program.model.address.AddressSetView)
|
||||
*/
|
||||
@Override
|
||||
public boolean intersects(AddressSetView set) {
|
||||
lock.acquire();
|
||||
|
@ -486,9 +403,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#isEmpty()
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
lock.acquire();
|
||||
|
@ -501,9 +415,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#subtract(ghidra.program.model.address.AddressSetView)
|
||||
*/
|
||||
@Override
|
||||
public AddressSet subtract(AddressSetView set) {
|
||||
lock.acquire();
|
||||
|
@ -516,9 +427,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#union(ghidra.program.model.address.AddressSetView)
|
||||
*/
|
||||
@Override
|
||||
public AddressSet union(AddressSetView set) {
|
||||
lock.acquire();
|
||||
|
@ -531,9 +439,6 @@ class FragmentDB extends DatabaseObject implements ProgramFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressSetView#xor(ghidra.program.model.address.AddressSetView)
|
||||
*/
|
||||
@Override
|
||||
public AddressSet xor(AddressSetView set) {
|
||||
lock.acquire();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.module;
|
||||
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
|
||||
/**
|
||||
* Adapter to access the module, fragment, and parent/child database tables.
|
||||
|
@ -46,8 +45,8 @@ interface GroupDBAdapter {
|
|||
* @throws DuplicateNameException if a module or fragment already exists
|
||||
* having the given name
|
||||
*/
|
||||
Record createModule(long parentModuleID, String name) throws IOException,
|
||||
DuplicateNameException;
|
||||
Record createModule(long parentModuleID, String name)
|
||||
throws IOException, DuplicateNameException;
|
||||
|
||||
/**
|
||||
* Get the record for the module with the given key.
|
||||
|
@ -80,8 +79,8 @@ interface GroupDBAdapter {
|
|||
* @throws DuplicateNameException if a module or fragment already exists
|
||||
* having the given name
|
||||
*/
|
||||
Record createFragment(long parentModuleID, String name) throws IOException,
|
||||
DuplicateNameException;
|
||||
Record createFragment(long parentModuleID, String name)
|
||||
throws IOException, DuplicateNameException;
|
||||
|
||||
/**
|
||||
* Get the record for the fragment with the given key.
|
||||
|
@ -123,7 +122,7 @@ interface GroupDBAdapter {
|
|||
* @return zero-length array if no records were found
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
long[] getParentChildKeys(long ID, int indexedCol) throws IOException;
|
||||
Field[] getParentChildKeys(long ID, int indexedCol) throws IOException;
|
||||
|
||||
/**
|
||||
* Get the Parent/Child record with the given key.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.module;
|
||||
|
||||
import ghidra.util.exception.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,11 +43,9 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
testVersion(parentChildTable, 0, parentChildTableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#createModule(java.lang.String)
|
||||
*/
|
||||
public Record createModule(long parentModuleID, String name) throws IOException,
|
||||
DuplicateNameException {
|
||||
@Override
|
||||
public Record createModule(long parentModuleID, String name)
|
||||
throws IOException, DuplicateNameException {
|
||||
|
||||
if (getModuleRecord(name) != null || getFragmentRecord(name) != null) {
|
||||
throw new DuplicateNameException(name + " already exists");
|
||||
|
@ -67,11 +63,9 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#createFragment(java.lang.String)
|
||||
*/
|
||||
public Record createFragment(long parentModuleID, String name) throws IOException,
|
||||
DuplicateNameException {
|
||||
@Override
|
||||
public Record createFragment(long parentModuleID, String name)
|
||||
throws IOException, DuplicateNameException {
|
||||
|
||||
if (getFragmentRecord(name) != null || getModuleRecord(name) != null) {
|
||||
throw new DuplicateNameException(name + " already exists");
|
||||
|
@ -94,16 +88,12 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#getFragmentRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getFragmentRecord(long key) throws IOException {
|
||||
return fragmentTable.getRecord(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#getModuleRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getModuleRecord(long key) throws IOException {
|
||||
return moduleTable.getRecord(key);
|
||||
}
|
||||
|
@ -112,8 +102,9 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
* @see ghidra.program.database.module.GroupDBAdapter#getParentChildRecord(long, long)
|
||||
* @param childID negative value if child is a fragment
|
||||
*/
|
||||
@Override
|
||||
public Record getParentChildRecord(long parentID, long childID) throws IOException {
|
||||
long[] keys =
|
||||
Field[] keys =
|
||||
parentChildTable.findRecords(new LongField(parentID), TreeManager.PARENT_ID_COL);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record pcRec = parentChildTable.getRecord(keys[i]);
|
||||
|
@ -124,9 +115,7 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#addParentChildRecord(long, long)
|
||||
*/
|
||||
@Override
|
||||
public Record addParentChildRecord(long moduleID, long childID) throws IOException {
|
||||
|
||||
Record pcRec = TreeManager.PARENT_CHILD_SCHEMA.createRecord(parentChildTable.getKey());
|
||||
|
@ -136,25 +125,19 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
return pcRec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#removeParentChildRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeParentChildRecord(long key) throws IOException {
|
||||
return parentChildTable.deleteRecord(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#getParentChildRecords(long)
|
||||
*/
|
||||
public long[] getParentChildKeys(long parentID, int indexedCol) throws IOException {
|
||||
@Override
|
||||
public Field[] getParentChildKeys(long parentID, int indexedCol) throws IOException {
|
||||
return parentChildTable.findRecords(new LongField(parentID), indexedCol);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#getFragmentRecord(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Record getFragmentRecord(String name) throws IOException {
|
||||
long[] keys =
|
||||
Field[] keys =
|
||||
fragmentTable.findRecords(new StringField(name), TreeManager.FRAGMENT_NAME_COL);
|
||||
if (keys.length == 0) {
|
||||
return null;
|
||||
|
@ -165,11 +148,9 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
return fragmentTable.getRecord(keys[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#getModuleRecord(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Record getModuleRecord(String name) throws IOException {
|
||||
long[] keys = moduleTable.findRecords(new StringField(name), TreeManager.MODULE_NAME_COL);
|
||||
Field[] keys = moduleTable.findRecords(new StringField(name), TreeManager.MODULE_NAME_COL);
|
||||
if (keys.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -179,37 +160,27 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
return moduleTable.getRecord(keys[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#getParentChildRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getParentChildRecord(long key) throws IOException {
|
||||
return parentChildTable.getRecord(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#updateRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
public void updateModuleRecord(Record record) throws IOException {
|
||||
moduleTable.putRecord(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#updateFragmentRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
public void updateFragmentRecord(Record record) throws IOException {
|
||||
fragmentTable.putRecord(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#updateParentChildRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
public void updateParentChildRecord(Record record) throws IOException {
|
||||
parentChildTable.putRecord(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#createRootModule()
|
||||
*/
|
||||
@Override
|
||||
public Record createRootModule(String name) throws IOException {
|
||||
Record record = TreeManager.MODULE_SCHEMA.createRecord(0);
|
||||
record.setString(TreeManager.MODULE_NAME_COL, name);
|
||||
|
@ -217,29 +188,26 @@ class GroupDBAdapterV0 implements GroupDBAdapter {
|
|||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#removeFragmentRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeFragmentRecord(long childID) throws IOException {
|
||||
return fragmentTable.deleteRecord(childID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.GroupDBAdapter#removeModuleRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeModuleRecord(long childID) throws IOException {
|
||||
return moduleTable.deleteRecord(childID);
|
||||
}
|
||||
|
||||
private void testVersion(Table table, int expectedVersion, String name) throws VersionException {
|
||||
private void testVersion(Table table, int expectedVersion, String name)
|
||||
throws VersionException {
|
||||
|
||||
if (table == null) {
|
||||
throw new VersionException(name + " not found");
|
||||
}
|
||||
int versionNumber = table.getSchema().getVersion();
|
||||
if (versionNumber != expectedVersion) {
|
||||
throw new VersionException(name + ": Expected Version " + expectedVersion + ", got " +
|
||||
versionNumber);
|
||||
throw new VersionException(
|
||||
name + ": Expected Version " + expectedVersion + ", got " + versionNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.database.module;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.DatabaseObject;
|
||||
|
@ -65,7 +66,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
record = rec;
|
||||
childCount = 0;
|
||||
try {
|
||||
long[] keys = adapter.getParentChildKeys(key, TreeManager.PARENT_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(key, TreeManager.PARENT_ID_COL);
|
||||
childCount = keys.length;
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
@ -80,9 +81,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#add(ghidra.program.model.listing.ProgramFragment)
|
||||
*/
|
||||
@Override
|
||||
public void add(ProgramFragment fragment) throws DuplicateGroupException {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -92,8 +91,8 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
// add a row to the parent/child table
|
||||
Record parentChildRecord = adapter.getParentChildRecord(key, -fragID);
|
||||
if (parentChildRecord != null) {
|
||||
throw new DuplicateGroupException(frag.getName() + " already exists a child of " +
|
||||
getName());
|
||||
throw new DuplicateGroupException(
|
||||
frag.getName() + " already exists a child of " + getName());
|
||||
}
|
||||
|
||||
Record pcRec = adapter.addParentChildRecord(key, -fragID);
|
||||
|
@ -109,10 +108,9 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#add(ghidra.program.model.listing.ProgramModule)
|
||||
*/
|
||||
public void add(ProgramModule module) throws CircularDependencyException, DuplicateGroupException {
|
||||
@Override
|
||||
public void add(ProgramModule module)
|
||||
throws CircularDependencyException, DuplicateGroupException {
|
||||
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -122,12 +120,12 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
|
||||
Record parentChildRecord = adapter.getParentChildRecord(key, moduleID);
|
||||
if (parentChildRecord != null) {
|
||||
throw new DuplicateGroupException(module.getName() + " already exists a child of " +
|
||||
getName());
|
||||
throw new DuplicateGroupException(
|
||||
module.getName() + " already exists a child of " + getName());
|
||||
}
|
||||
if (moduleMgr.isDescendant(key, moduleID)) {
|
||||
throw new CircularDependencyException(getName() + " is already a descendant of " +
|
||||
module.getName());
|
||||
throw new CircularDependencyException(
|
||||
getName() + " is already a descendant of " + module.getName());
|
||||
}
|
||||
|
||||
Record pcRec = adapter.addParentChildRecord(key, moduleID);
|
||||
|
@ -143,9 +141,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#contains(ghidra.program.model.listing.ProgramFragment)
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(ProgramFragment fragment) {
|
||||
if (!(fragment instanceof FragmentDB)) {
|
||||
return false;
|
||||
|
@ -157,9 +153,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return contains(-frag.getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#contains(ghidra.program.model.listing.ProgramModule)
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(ProgramModule module) {
|
||||
if (!(module instanceof ModuleDB)) {
|
||||
return false;
|
||||
|
@ -171,9 +165,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return contains(moduleDB.getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#createFragment(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ProgramFragment createFragment(String fragmentName) throws DuplicateNameException {
|
||||
|
||||
lock.acquire();
|
||||
|
@ -196,9 +188,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#createModule(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ProgramModule createModule(String moduleName) throws DuplicateNameException {
|
||||
|
||||
lock.acquire();
|
||||
|
@ -221,9 +211,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getChildren()
|
||||
*/
|
||||
@Override
|
||||
public Group[] getChildren() {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -252,9 +240,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return new Group[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getComment()
|
||||
*/
|
||||
@Override
|
||||
public String getComment() {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -266,9 +252,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getFirstAddress()
|
||||
*/
|
||||
@Override
|
||||
public Address getFirstAddress() {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -280,9 +264,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getIndex(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public int getIndex(String name) {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -312,9 +294,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getLastAddress()
|
||||
*/
|
||||
@Override
|
||||
public Address getLastAddress() {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -326,9 +306,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getMaxAddress()
|
||||
*/
|
||||
@Override
|
||||
public Address getMaxAddress() {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -340,9 +318,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getMinAddress()
|
||||
*/
|
||||
@Override
|
||||
public Address getMinAddress() {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -354,9 +330,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getAddressSet()
|
||||
*/
|
||||
@Override
|
||||
public AddressSetView getAddressSet() {
|
||||
AddressSet set = new AddressSet();
|
||||
Group[] children = getChildren();
|
||||
|
@ -372,9 +346,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getNumChildren()
|
||||
*/
|
||||
@Override
|
||||
public int getNumChildren() {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -386,9 +358,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#isDescendant(ghidra.program.model.listing.ProgramFragment)
|
||||
*/
|
||||
@Override
|
||||
public boolean isDescendant(ProgramFragment fragment) {
|
||||
if (!(fragment instanceof FragmentDB)) {
|
||||
return false;
|
||||
|
@ -403,9 +373,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#isDescendant(ghidra.program.model.listing.ProgramModule)
|
||||
*/
|
||||
@Override
|
||||
public boolean isDescendant(ProgramModule module) {
|
||||
if (!(module instanceof ModuleDB)) {
|
||||
return false;
|
||||
|
@ -420,9 +388,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#moveChild(java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public void moveChild(String name, int index) throws NotFoundException {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -473,9 +439,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#removeChild(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeChild(String name) throws NotEmptyException {
|
||||
|
||||
lock.acquire();
|
||||
|
@ -492,7 +456,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
// check for module record
|
||||
return removeModuleRecord(name);
|
||||
}
|
||||
long[] keys = adapter.getParentChildKeys(-childID, TreeManager.CHILD_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(-childID, TreeManager.CHILD_ID_COL);
|
||||
if (keys.length == 1) {
|
||||
FragmentDB frag = moduleMgr.getFragmentDB(childID);
|
||||
if (!frag.isEmpty()) {
|
||||
|
@ -525,8 +489,8 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
if (pcRec == null) {
|
||||
return false;
|
||||
}
|
||||
long[] keys = adapter.getParentChildKeys(childID, TreeManager.CHILD_ID_COL);
|
||||
|
||||
Field[] keys = adapter.getParentChildKeys(childID, TreeManager.CHILD_ID_COL);
|
||||
if (keys.length == 1) {
|
||||
ProgramModule module = moduleMgr.getModuleDB(childID);
|
||||
if (module.getNumChildren() > 0) {
|
||||
|
@ -538,9 +502,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return removeChild(childID, pcRec, false, deleteChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#reparent(java.lang.String, ghidra.program.model.listing.ProgramModule)
|
||||
*/
|
||||
@Override
|
||||
public void reparent(String name, ProgramModule oldParent) throws NotFoundException {
|
||||
|
||||
Group group = null;
|
||||
|
@ -582,9 +544,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#contains(ghidra.program.model.listing.CodeUnit)
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(CodeUnit codeUnit) {
|
||||
FragmentDB frag = moduleMgr.getFragment(codeUnit);
|
||||
if (frag != null) {
|
||||
|
@ -593,9 +553,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -607,14 +565,12 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getNumParents()
|
||||
*/
|
||||
@Override
|
||||
public int getNumParents() {
|
||||
lock.acquire();
|
||||
try {
|
||||
checkIsValid();
|
||||
long[] keys = adapter.getParentChildKeys(key, TreeManager.CHILD_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(key, TreeManager.CHILD_ID_COL);
|
||||
return keys.length;
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
@ -626,30 +582,22 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getParentNames()
|
||||
*/
|
||||
@Override
|
||||
public String[] getParentNames() {
|
||||
return moduleMgr.getParentNames(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getParents()
|
||||
*/
|
||||
@Override
|
||||
public ProgramModule[] getParents() {
|
||||
return moduleMgr.getParents(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#getTreeName()
|
||||
*/
|
||||
@Override
|
||||
public String getTreeName() {
|
||||
return moduleMgr.getTreeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#setComment(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setComment(String comment) {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -671,9 +619,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.Group#setName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setName(String name) throws DuplicateNameException {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -754,11 +700,11 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
* Get sorted list based on child order column.
|
||||
*/
|
||||
private List<Record> getParentChildRecords() throws IOException {
|
||||
long[] keys = adapter.getParentChildKeys(key, TreeManager.PARENT_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(key, TreeManager.PARENT_ID_COL);
|
||||
List<Record> list = new ArrayList<Record>();
|
||||
Comparator<Record> c = new ParentChildRecordComparator();
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record rec = adapter.getParentChildRecord(keys[i]);
|
||||
Record rec = adapter.getParentChildRecord(keys[i].getLongValue());
|
||||
int index = Collections.binarySearch(list, rec, c);
|
||||
if (index < 0) {
|
||||
index = -index - 1;
|
||||
|
@ -921,7 +867,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
checkIsValid();
|
||||
childCount = 0;
|
||||
try {
|
||||
long[] keys = adapter.getParentChildKeys(key, TreeManager.PARENT_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(key, TreeManager.PARENT_ID_COL);
|
||||
childCount = keys.length;
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
@ -931,6 +877,7 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
|
||||
private class ParentChildRecordComparator implements Comparator<Record> {
|
||||
|
||||
@Override
|
||||
public int compare(Record r1, Record r2) {
|
||||
int index1 = r1.getIntValue(TreeManager.ORDER_COL);
|
||||
int index2 = r2.getIntValue(TreeManager.ORDER_COL);
|
||||
|
@ -945,23 +892,17 @@ class ModuleDB extends DatabaseObject implements ProgramModule {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.listing.ProgramModule#getVersionTag()
|
||||
*/
|
||||
@Override
|
||||
public Object getVersionTag() {
|
||||
return moduleMgr.getVersionTag();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.model.listing.Module#getModificationNumber()
|
||||
*/
|
||||
@Override
|
||||
public long getModificationNumber() {
|
||||
return moduleMgr.getModificationNumber();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.program.model.listing.Module#getTreeID()
|
||||
*/
|
||||
@Override
|
||||
public long getTreeID() {
|
||||
return moduleMgr.getTreeID();
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class ModuleManager {
|
|||
nameSet = new HashSet<>();
|
||||
errHandler = treeMgr.getErrorHandler();
|
||||
fragMap = new AddressRangeMapDB(handle, addrMap, lock,
|
||||
TreeManager.getFragAddressTableName(treeID), errHandler, LongField.class, true);
|
||||
TreeManager.getFragAddressTableName(treeID), errHandler, LongField.INSTANCE, true);
|
||||
if (createTables) {
|
||||
createDBTables(handle);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class ModuleManager {
|
|||
String mapName = TreeManager.getFragAddressTableName(treeID);
|
||||
|
||||
AddressRangeMapDB map = new AddressRangeMapDB(handle, addrMap.getOldAddressMap(),
|
||||
treeMgr.getLock(), mapName, errHandler, LongField.class, true);
|
||||
treeMgr.getLock(), mapName, errHandler, LongField.INSTANCE, true);
|
||||
if (map.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class ModuleManager {
|
|||
int count = 0;
|
||||
|
||||
AddressRangeMapDB tmpMap = new AddressRangeMapDB(tmpDb, addrMap,
|
||||
new Lock("Tmp Upgrade"), mapName, errHandler, LongField.class, false);
|
||||
new Lock("Tmp Upgrade"), mapName, errHandler, LongField.INSTANCE, false);
|
||||
|
||||
AddressRangeIterator iter = map.getAddressRanges();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -135,7 +135,7 @@ class ModuleManager {
|
|||
|
||||
// Copy ranges into new map
|
||||
map = new AddressRangeMapDB(handle, addrMap, treeMgr.getLock(), mapName, errHandler,
|
||||
LongField.class, true);
|
||||
LongField.INSTANCE, true);
|
||||
iter = tmpMap.getAddressRanges();
|
||||
while (iter.hasNext()) {
|
||||
monitor.checkCanceled();
|
||||
|
@ -457,22 +457,22 @@ class ModuleManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return true if ID is a descendant of moduleID.
|
||||
* Return true if specified id is a descendant of moduleID.
|
||||
*/
|
||||
boolean isDescendant(long ID, long moduleID) throws IOException {
|
||||
boolean isDescendant(long id, long moduleID) throws IOException {
|
||||
|
||||
long[] keys = adapter.getParentChildKeys(moduleID, TreeManager.PARENT_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(moduleID, TreeManager.PARENT_ID_COL);
|
||||
if (keys.length == 0) {
|
||||
return false;
|
||||
}
|
||||
for (long key : keys) {
|
||||
Record parentChildRecord = adapter.getParentChildRecord(key);
|
||||
for (Field key : keys) {
|
||||
Record parentChildRecord = adapter.getParentChildRecord(key.getLongValue());
|
||||
long childID = parentChildRecord.getLongValue(TreeManager.CHILD_ID_COL);
|
||||
|
||||
if (childID == ID) {
|
||||
if (childID == id) {
|
||||
return true;
|
||||
}
|
||||
if (isDescendant(ID, childID)) {
|
||||
if (isDescendant(id, childID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -645,10 +645,10 @@ class ModuleManager {
|
|||
String[] getParentNames(long childID) {
|
||||
lock.acquire();
|
||||
try {
|
||||
long[] keys = adapter.getParentChildKeys(childID, TreeManager.CHILD_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(childID, TreeManager.CHILD_ID_COL);
|
||||
String[] names = new String[keys.length];
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record parentChildRecord = adapter.getParentChildRecord(keys[i]);
|
||||
Record parentChildRecord = adapter.getParentChildRecord(keys[i].getLongValue());
|
||||
Record mrec = adapter.getModuleRecord(
|
||||
parentChildRecord.getLongValue(TreeManager.PARENT_ID_COL));
|
||||
names[i] = mrec.getString(TreeManager.MODULE_NAME_COL);
|
||||
|
@ -668,10 +668,10 @@ class ModuleManager {
|
|||
ProgramModule[] getParents(long childID) {
|
||||
lock.acquire();
|
||||
try {
|
||||
long[] keys = adapter.getParentChildKeys(childID, TreeManager.CHILD_ID_COL);
|
||||
Field[] keys = adapter.getParentChildKeys(childID, TreeManager.CHILD_ID_COL);
|
||||
ProgramModule[] modules = new ProgramModule[keys.length];
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record parentChildRecord = adapter.getParentChildRecord(keys[i]);
|
||||
Record parentChildRecord = adapter.getParentChildRecord(keys[i].getLongValue());
|
||||
Record mrec = adapter.getModuleRecord(
|
||||
parentChildRecord.getLongValue(TreeManager.PARENT_ID_COL));
|
||||
modules[i] = getModuleDB(mrec);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.module;
|
||||
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -51,9 +49,7 @@ class TreeDBAdapterV0 implements TreeDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.TreeDBAdapter#createRecord(long, java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public Record createRecord(String name) throws IOException {
|
||||
Record record = TreeManager.TREE_SCHEMA.createRecord(treeTable.getKey());
|
||||
record.setString(TreeManager.TREE_NAME_COL, name);
|
||||
|
@ -62,9 +58,7 @@ class TreeDBAdapterV0 implements TreeDBAdapter {
|
|||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.TreeDBAdapter#deleteRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteRecord(long treeID) throws IOException {
|
||||
|
||||
if (treeTable.deleteRecord(treeID)) {
|
||||
|
@ -76,18 +70,14 @@ class TreeDBAdapterV0 implements TreeDBAdapter {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.TreeDBAdapter#getRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getRecord(long treeID) throws IOException {
|
||||
return treeTable.getRecord(treeID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.TreeDBAdapter#getRecord(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Record getRecord(String name) throws IOException {
|
||||
long[] keys = treeTable.findRecords(new StringField(name), TreeManager.TREE_NAME_COL);
|
||||
Field[] keys = treeTable.findRecords(new StringField(name), TreeManager.TREE_NAME_COL);
|
||||
if (keys.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -97,17 +87,12 @@ class TreeDBAdapterV0 implements TreeDBAdapter {
|
|||
return treeTable.getRecord(keys[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.module.TreeDBAdapter#getRecords()
|
||||
*/
|
||||
@Override
|
||||
public RecordIterator getRecords() throws IOException {
|
||||
return treeTable.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see ghidra.program.database.module.TreeDBAdapter#updateRecord(ghidra.framework.store.db.Record)
|
||||
*/
|
||||
@Override
|
||||
public void updateRecord(Record record) throws IOException {
|
||||
treeTable.putRecord(record);
|
||||
}
|
||||
|
|
|
@ -78,23 +78,23 @@ public class TreeManager implements ManagerDB {
|
|||
static final Schema PARENT_CHILD_SCHEMA = createParentChildSchema();
|
||||
|
||||
private static Schema createTreeSchema() {
|
||||
return new Schema(0, "Key", new Class[] { StringField.class, LongField.class },
|
||||
return new Schema(0, "Key", new Field[] { StringField.INSTANCE, LongField.INSTANCE },
|
||||
new String[] { "Name", "Modification Number" });
|
||||
}
|
||||
|
||||
private static Schema createModuleSchema() {
|
||||
return new Schema(0, "Key", new Class[] { StringField.class, StringField.class },
|
||||
return new Schema(0, "Key", new Field[] { StringField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Name", "Comments" });
|
||||
}
|
||||
|
||||
private static Schema createFragmentSchema() {
|
||||
return new Schema(0, "Key", new Class[] { StringField.class, StringField.class },
|
||||
return new Schema(0, "Key", new Field[] { StringField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Name", "Comments" });
|
||||
}
|
||||
|
||||
private static Schema createParentChildSchema() {
|
||||
return new Schema(0, "Key",
|
||||
new Class[] { LongField.class, LongField.class, IntField.class },
|
||||
new Field[] { LongField.INSTANCE, LongField.INSTANCE, IntField.INSTANCE },
|
||||
new String[] { "Parent ID", "Child ID", "Child Index" });
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -41,9 +39,10 @@ class OldFunctionDBAdapterV1 extends OldFunctionDBAdapter {
|
|||
static final int V1_REPEATABLE_COMMENT_COL = 5;
|
||||
|
||||
final static Schema V1_FUNCTIONS_SCHEMA = new Schema(SCHEMA_VERSION, "Entry Point",
|
||||
new Class[] { LongField.class, IntField.class, IntField.class, IntField.class,
|
||||
IntField.class, StringField.class }, new String[] { "Return DataType ID", "StackDepth",
|
||||
"StackParamOffset", "StackReturnOffset", "StackLocalSize", "RepeatableComment" });
|
||||
new Field[] { LongField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE, IntField.INSTANCE,
|
||||
IntField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Return DataType ID", "StackDepth", "StackParamOffset", "StackReturnOffset",
|
||||
"StackLocalSize", "RepeatableComment" });
|
||||
protected Table table;
|
||||
|
||||
OldFunctionDBAdapterV1(DBHandle dbHandle, AddressMap addrMap) throws VersionException {
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -27,11 +32,6 @@ import ghidra.util.Msg;
|
|||
import ghidra.util.StringUtilities;
|
||||
import ghidra.util.exception.InvalidInputException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Record;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -50,8 +50,8 @@ class OldFunctionDataDB {
|
|||
private OldStackFrameDB frame;
|
||||
private List<Parameter> regParams;
|
||||
|
||||
OldFunctionDataDB(OldFunctionManager functionManager, AddressMap addrMap,
|
||||
Record functionRecord, AddressSetView body) {
|
||||
OldFunctionDataDB(OldFunctionManager functionManager, AddressMap addrMap, Record functionRecord,
|
||||
AddressSetView body) {
|
||||
|
||||
this.functionManager = functionManager;
|
||||
this.addrMap = addrMap;
|
||||
|
@ -200,9 +200,9 @@ class OldFunctionDataDB {
|
|||
return;
|
||||
regParams = new ArrayList<Parameter>();
|
||||
try {
|
||||
long[] keys = registerAdapter.getRegisterVariableKeys(functionRecord.getKey());
|
||||
Field[] keys = registerAdapter.getRegisterVariableKeys(functionRecord.getKey());
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record varRec = registerAdapter.getRegisterVariableRecord(keys[i]);
|
||||
Record varRec = registerAdapter.getRegisterVariableRecord(keys[i].getLongValue());
|
||||
regParams.add(getRegisterParameter(varRec, i));
|
||||
}
|
||||
// TODO Does register variable list need to be sorted?
|
||||
|
@ -266,10 +266,9 @@ class OldFunctionDataDB {
|
|||
try {
|
||||
Variable[] stackParams = frame.getParameters();
|
||||
for (int i = 0; i < stackParams.length; i++) {
|
||||
parms[ordinal++] =
|
||||
new OldFunctionParameter(stackParams[i].getName(), ordinal,
|
||||
stackParams[i].getDataType(), stackParams[i].getVariableStorage(), program,
|
||||
SourceType.USER_DEFINED);
|
||||
parms[ordinal++] = new OldFunctionParameter(stackParams[i].getName(), ordinal,
|
||||
stackParams[i].getDataType(), stackParams[i].getVariableStorage(), program,
|
||||
SourceType.USER_DEFINED);
|
||||
}
|
||||
}
|
||||
catch (InvalidInputException e) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Database adapter for register variables.
|
||||
|
@ -60,9 +58,9 @@ abstract class OldRegisterVariableDBAdapter {
|
|||
/**
|
||||
* Get all register variable keys which correspond to a function.
|
||||
* @param functionKey
|
||||
* @return array of register variable keys.
|
||||
* @throws IOException
|
||||
* @return array of register variable keys as LongField values within Field array.
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract long[] getRegisterVariableKeys(long functionKey) throws IOException;
|
||||
abstract Field[] getRegisterVariableKeys(long functionKey) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,9 +37,9 @@ class OldRegisterVariableDBAdapterV0 extends OldRegisterVariableDBAdapter {
|
|||
|
||||
static final String REG_PARMS_TABLE_NAME = "Register Parameters";
|
||||
static final Schema V0_REG_PARAMS_SCHEMA = new Schema(SCHEMA_VERSION, "Key",
|
||||
new Class[] { LongField.class, StringField.class, LongField.class, StringField.class,
|
||||
StringField.class }, new String[] { "Function ID", "Register", "DataType ID", "Name",
|
||||
"Comment" });
|
||||
new Field[] { LongField.INSTANCE, StringField.INSTANCE, LongField.INSTANCE,
|
||||
StringField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Function ID", "Register", "DataType ID", "Name", "Comment" });
|
||||
|
||||
private Table table;
|
||||
|
||||
|
@ -52,34 +50,22 @@ class OldRegisterVariableDBAdapterV0 extends OldRegisterVariableDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.function.FunctionDBAdapter#getRegisterVariableRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getRegisterVariableRecord(long key) throws IOException {
|
||||
return table.getRecord(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.function.FunctionDBAdapter#getRegisterVariableKeys(long)
|
||||
*/
|
||||
@Override
|
||||
public long[] getRegisterVariableKeys(long functionKey) throws IOException {
|
||||
public Field[] getRegisterVariableKeys(long functionKey) throws IOException {
|
||||
return table.findRecords(new LongField(functionKey),
|
||||
OldStackVariableDBAdapter.STACK_VAR_FUNCTION_KEY_COL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.function.RegisterVariableDBAdapter#deleteTable(db.DBHandle)
|
||||
*/
|
||||
@Override
|
||||
void deleteTable(DBHandle handle) throws IOException {
|
||||
handle.deleteTable(REG_PARMS_TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.function.RegisterVariableDBAdapter#getRecordCount()
|
||||
*/
|
||||
@Override
|
||||
int getRecordCount() {
|
||||
return table.getRecordCount();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Field;
|
||||
import db.Record;
|
||||
import ghidra.program.model.address.AddressOutOfBoundsException;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -23,11 +27,6 @@ import ghidra.program.model.symbol.SourceType;
|
|||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.InvalidInputException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import db.Record;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -89,9 +88,9 @@ class OldStackFrameDB implements StackFrame {
|
|||
return;
|
||||
try {
|
||||
variables = new ArrayList<Variable>();
|
||||
long[] keys = adapter.getStackVariableKeys(function.getKey());
|
||||
Field[] keys = adapter.getStackVariableKeys(function.getKey());
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
Record varRec = adapter.getStackVariableRecord(keys[i]);
|
||||
Record varRec = adapter.getStackVariableRecord(keys[i].getLongValue());
|
||||
variables.add(getStackVariable(varRec));
|
||||
}
|
||||
Collections.sort(variables, StackVariableComparator.get());
|
||||
|
@ -124,13 +123,11 @@ class OldStackFrameDB implements StackFrame {
|
|||
throw new RuntimeException(e); // unexpected
|
||||
}
|
||||
catch (AddressOutOfBoundsException e) {
|
||||
Msg.error(this,
|
||||
"Invalid stack variable '" + name + "' in function at " + function.getEntryPoint() +
|
||||
": " + e.getMessage());
|
||||
Msg.error(this, "Invalid stack variable '" + name + "' in function at " +
|
||||
function.getEntryPoint() + ": " + e.getMessage());
|
||||
try {
|
||||
var =
|
||||
new LocalVariableImpl(name, 0, dataType, VariableStorage.BAD_STORAGE,
|
||||
functionManager.getProgram());
|
||||
var = new LocalVariableImpl(name, 0, dataType, VariableStorage.BAD_STORAGE,
|
||||
functionManager.getProgram());
|
||||
}
|
||||
catch (InvalidInputException e1) {
|
||||
throw new RuntimeException(e); // unexpected
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
* Database adapter for stack variables.
|
||||
|
@ -56,23 +54,26 @@ abstract class OldStackVariableDBAdapter {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Delete associated database table
|
||||
* @param handle database handle
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract void deleteTable(DBHandle handle) throws IOException;
|
||||
|
||||
/**
|
||||
* Get a stack variable record.
|
||||
* @param key
|
||||
* @return Record
|
||||
* @param key stack variable record
|
||||
* @return Record record or null
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract Record getStackVariableRecord(long key) throws IOException;
|
||||
|
||||
/**
|
||||
* Get all stack variable keys which correspond to a function.
|
||||
* @param functionKey
|
||||
* @return array of stack variable keys.
|
||||
* @throws IOException
|
||||
* @param functionKey parent function ID
|
||||
* @return array of stack variable keys as LongField values within Field array.
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
abstract long[] getStackVariableKeys(long functionKey) throws IOException;
|
||||
abstract Field[] getStackVariableKeys(long functionKey) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -40,8 +38,9 @@ class OldStackVariableDBAdapterV0 extends OldStackVariableDBAdapter {
|
|||
static final int V0_STACK_VAR_NAME_COL = 3;
|
||||
static final int V0_STACK_VAR_COMMENT_COL = 4;
|
||||
|
||||
static final Schema V0_STACK_VARS_SCHEMA = new Schema(SCHEMA_VERSION, "Key", new Class[] {
|
||||
LongField.class, IntField.class, LongField.class, StringField.class, StringField.class },
|
||||
static final Schema V0_STACK_VARS_SCHEMA = new Schema(SCHEMA_VERSION, "Key",
|
||||
new Field[] { LongField.INSTANCE, IntField.INSTANCE, LongField.INSTANCE,
|
||||
StringField.INSTANCE, StringField.INSTANCE },
|
||||
new String[] { "Function ID", "Offset", "DataType ID", "Name", "Comment" });
|
||||
|
||||
private Table table;
|
||||
|
@ -58,19 +57,13 @@ class OldStackVariableDBAdapterV0 extends OldStackVariableDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.function.FunctionDBAdapter#getStackVariableRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getStackVariableRecord(long key) throws IOException {
|
||||
return translateRecord(table.getRecord(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.function.FunctionDBAdapter#getStackVariableKeys(long)
|
||||
*/
|
||||
@Override
|
||||
public long[] getStackVariableKeys(long functionKey) throws IOException {
|
||||
public Field[] getStackVariableKeys(long functionKey) throws IOException {
|
||||
return table.findRecords(new LongField(functionKey), V0_STACK_VAR_FUNCTION_KEY_COL);
|
||||
}
|
||||
|
||||
|
@ -94,9 +87,6 @@ class OldStackVariableDBAdapterV0 extends OldStackVariableDBAdapter {
|
|||
return rec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#deleteTable()
|
||||
*/
|
||||
@Override
|
||||
void deleteTable(DBHandle handle) throws IOException {
|
||||
handle.deleteTable(STACK_VARS_TABLE_NAME);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,11 @@
|
|||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.util.exception.VersionException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -41,11 +39,12 @@ class OldStackVariableDBAdapterV1 extends OldStackVariableDBAdapter {
|
|||
static final int V1_STACK_VAR_COMMENT_COL = 4;
|
||||
static final int V1_STACK_VAR_DT_LENGTH_COL = 5;
|
||||
|
||||
static final Schema V1_STACK_VARS_SCHEMA = new Schema(SCHEMA_VERSION, "Key", new Class[] {
|
||||
LongField.class, IntField.class, LongField.class, StringField.class, StringField.class,
|
||||
IntField.class },
|
||||
static final Schema V1_STACK_VARS_SCHEMA = new Schema(SCHEMA_VERSION, "Key",
|
||||
new Field[] { LongField.INSTANCE, IntField.INSTANCE, LongField.INSTANCE,
|
||||
StringField.INSTANCE, StringField.INSTANCE, IntField.INSTANCE },
|
||||
|
||||
new String[] { "Function ID", "Offset", "DataType ID", "Name", "Comment", "DataType Length" });
|
||||
new String[] { "Function ID", "Offset", "DataType ID", "Name", "Comment",
|
||||
"DataType Length" });
|
||||
|
||||
private Table table;
|
||||
|
||||
|
@ -64,25 +63,16 @@ class OldStackVariableDBAdapterV1 extends OldStackVariableDBAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.function.FunctionDBAdapter#getStackVariableRecord(long)
|
||||
*/
|
||||
@Override
|
||||
public Record getStackVariableRecord(long key) throws IOException {
|
||||
return table.getRecord(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.function.FunctionDBAdapter#getStackVariableKeys(long)
|
||||
*/
|
||||
@Override
|
||||
public long[] getStackVariableKeys(long functionKey) throws IOException {
|
||||
public Field[] getStackVariableKeys(long functionKey) throws IOException {
|
||||
return table.findRecords(new LongField(functionKey), V1_STACK_VAR_FUNCTION_KEY_COL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.database.data.PointerDBAdapter#deleteTable()
|
||||
*/
|
||||
@Override
|
||||
void deleteTable(DBHandle handle) throws IOException {
|
||||
handle.deleteTable(STACK_VARS_TABLE_NAME);
|
||||
|
|
|
@ -68,8 +68,8 @@ public class DBPropertyMapManager implements PropertyMapManager, ManagerDB {
|
|||
|
||||
static {
|
||||
|
||||
PROPERTIES_SCHEMA = new Schema(CURRENT_PROPERTIES_TABLE_VERSION, StringField.class, "Name",
|
||||
new Class[] { ByteField.class, StringField.class, IntField.class },
|
||||
PROPERTIES_SCHEMA = new Schema(CURRENT_PROPERTIES_TABLE_VERSION, StringField.INSTANCE,
|
||||
"Name", new Field[] { ByteField.INSTANCE, StringField.INSTANCE, IntField.INSTANCE },
|
||||
new String[] { "Type", "Object Class", "Version" });
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.properties;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.util.IntPropertyMap;
|
||||
|
@ -24,11 +27,6 @@ import ghidra.util.exception.*;
|
|||
import ghidra.util.prop.PropertyVisitor;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* Property manager that deals with properties that are of
|
||||
* int type and stored with a database table.
|
||||
|
@ -58,6 +56,7 @@ public class IntPropertyMapDB extends PropertyMapDB implements IntPropertyMap {
|
|||
/**
|
||||
* @see ghidra.program.model.util.IntPropertyMap#add(ghidra.program.model.address.Address, int)
|
||||
*/
|
||||
@Override
|
||||
public void add(Address addr, int value) {
|
||||
lock.acquire();
|
||||
try {
|
||||
|
@ -66,7 +65,7 @@ public class IntPropertyMapDB extends PropertyMapDB implements IntPropertyMap {
|
|||
long key = addrMap.getKey(addr, true);
|
||||
|
||||
if (propertyTable == null) {
|
||||
createTable(IntField.class);
|
||||
createTable(IntField.INSTANCE);
|
||||
}
|
||||
else {
|
||||
oldValue = (Integer) cache.get(key);
|
||||
|
@ -96,6 +95,7 @@ public class IntPropertyMapDB extends PropertyMapDB implements IntPropertyMap {
|
|||
/**
|
||||
* @see ghidra.program.model.util.IntPropertyMap#getInt(ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public int getInt(Address addr) throws NoValueException {
|
||||
if (propertyTable == null) {
|
||||
throw NO_VALUE_EXCEPTION;
|
||||
|
@ -130,6 +130,7 @@ public class IntPropertyMapDB extends PropertyMapDB implements IntPropertyMap {
|
|||
/**
|
||||
* @see ghidra.program.model.util.PropertyMap#getObject(ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public Object getObject(Address addr) {
|
||||
try {
|
||||
return new Integer(getInt(addr));
|
||||
|
@ -142,6 +143,7 @@ public class IntPropertyMapDB extends PropertyMapDB implements IntPropertyMap {
|
|||
/**
|
||||
* @see ghidra.program.model.util.PropertyMap#applyValue(ghidra.util.prop.PropertyVisitor, ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public void applyValue(PropertyVisitor visitor, Address addr) {
|
||||
try {
|
||||
visitor.visit(getInt(addr));
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +15,10 @@
|
|||
*/
|
||||
package ghidra.program.database.properties;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.util.LongPropertyMap;
|
||||
|
@ -24,11 +27,6 @@ import ghidra.util.exception.*;
|
|||
import ghidra.util.prop.PropertyVisitor;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.*;
|
||||
import db.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* Property manager that deals with properties that are of
|
||||
* long type and stored with a database table.
|
||||
|
@ -58,13 +56,14 @@ public class LongPropertyMapDB extends PropertyMapDB implements LongPropertyMap
|
|||
/**
|
||||
* @see ghidra.program.model.util.LongPropertyMap#add(ghidra.program.model.address.Address, long)
|
||||
*/
|
||||
@Override
|
||||
public void add(Address addr, long value) {
|
||||
Long oldValue = null;
|
||||
lock.acquire();
|
||||
try {
|
||||
long key = addrMap.getKey(addr, true);
|
||||
if (propertyTable == null) {
|
||||
createTable(LongField.class);
|
||||
createTable(LongField.INSTANCE);
|
||||
}
|
||||
else {
|
||||
oldValue = (Long) cache.get(key);
|
||||
|
@ -93,6 +92,7 @@ public class LongPropertyMapDB extends PropertyMapDB implements LongPropertyMap
|
|||
/**
|
||||
* @see ghidra.program.model.util.LongPropertyMap#getLong(ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public long getLong(Address addr) throws NoValueException {
|
||||
if (propertyTable == null) {
|
||||
throw NO_VALUE_EXCEPTION;
|
||||
|
@ -127,6 +127,7 @@ public class LongPropertyMapDB extends PropertyMapDB implements LongPropertyMap
|
|||
/**
|
||||
* @see ghidra.program.model.util.PropertyMap#getObject(ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public Object getObject(Address addr) {
|
||||
try {
|
||||
return new Long(getLong(addr));
|
||||
|
@ -139,6 +140,7 @@ public class LongPropertyMapDB extends PropertyMapDB implements LongPropertyMap
|
|||
/**
|
||||
* @see ghidra.program.model.util.PropertyMap#applyValue(ghidra.util.prop.PropertyVisitor, ghidra.program.model.address.Address)
|
||||
*/
|
||||
@Override
|
||||
public void applyValue(PropertyVisitor visitor, Address addr) {
|
||||
throw new NotYetImplementedException();
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public abstract class PropertyMapDB implements PropertyMap {
|
|||
|
||||
protected static final String[] SCHEMA_FIELD_NAMES = new String[] { "Value" };
|
||||
protected static final String[] NO_SCHEMA_FIELD_NAMES = new String[0];
|
||||
protected static final Class<?>[] NO_SCHEMA_FIELD_CLASSES = new Class<?>[0];
|
||||
protected static final Field[] NO_SCHEMA_FIELDS = new Field[0];
|
||||
|
||||
protected static final int PROPERTY_VALUE_COL = 0;
|
||||
|
||||
|
@ -92,8 +92,8 @@ public abstract class PropertyMapDB implements PropertyMap {
|
|||
}
|
||||
}
|
||||
|
||||
void checkMapVersion(int openMode, TaskMonitor monitor) throws VersionException,
|
||||
CancelledException, IOException {
|
||||
void checkMapVersion(int openMode, TaskMonitor monitor)
|
||||
throws VersionException, CancelledException, IOException {
|
||||
if (propertyTable != null && addrMap.isUpgraded()) {
|
||||
if (openMode == DBConstants.UPGRADE) {
|
||||
upgradeTable(monitor);
|
||||
|
@ -175,15 +175,15 @@ public abstract class PropertyMapDB implements PropertyMap {
|
|||
* is null.
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void createTable(Class<?> valueFieldClass) throws IOException {
|
||||
if (valueFieldClass != null) {
|
||||
protected void createTable(Field valueField) throws IOException {
|
||||
if (valueField != null) {
|
||||
// Create default table schema with a value column and an long Address key
|
||||
Class<?>[] classes = new Class<?>[] { valueFieldClass };
|
||||
schema = new Schema(0, "Address", classes, SCHEMA_FIELD_NAMES);
|
||||
Field[] fields = new Field[] { valueField };
|
||||
schema = new Schema(0, "Address", fields, SCHEMA_FIELD_NAMES);
|
||||
}
|
||||
else {
|
||||
// Table contains only a long Address key
|
||||
schema = new Schema(0, "Address", NO_SCHEMA_FIELD_CLASSES, NO_SCHEMA_FIELD_NAMES);
|
||||
schema = new Schema(0, "Address", NO_SCHEMA_FIELDS, NO_SCHEMA_FIELD_NAMES);
|
||||
}
|
||||
propertyTable = dbHandle.createTable(getTableName(), schema);
|
||||
}
|
||||
|
@ -412,9 +412,8 @@ public abstract class PropertyMapDB implements PropertyMap {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
AddressKeyIterator iter =
|
||||
new AddressKeyIterator(propertyTable, addrMap,
|
||||
addrMap.getAddressFactory().getAddressSet().getMaxAddress(), false);
|
||||
AddressKeyIterator iter = new AddressKeyIterator(propertyTable, addrMap,
|
||||
addrMap.getAddressFactory().getAddressSet().getMaxAddress(), false);
|
||||
return addrMap.decodeAddress(iter.previous());
|
||||
}
|
||||
catch (NoSuchElementException e) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue