mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Renamed Record class to DBRecord
This commit is contained in:
parent
04276e9522
commit
db1e3d1b62
305 changed files with 1902 additions and 1959 deletions
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import db.DBHandle;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.feature.fid.hash.FidHashQuad;
|
||||
import ghidra.framework.store.db.PackedDBHandle;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
|
@ -384,7 +384,7 @@ public class FidDB implements Closeable {
|
|||
public boolean getSuperiorFullRelation(FunctionRecord superiorFunction,
|
||||
FidHashQuad inferiorFunction) {
|
||||
try {
|
||||
Record libraryByID = librariesTable.getLibraryByID(superiorFunction.getLibraryID());
|
||||
DBRecord libraryByID = librariesTable.getLibraryByID(superiorFunction.getLibraryID());
|
||||
if (libraryByID != null) {
|
||||
return relationsTable.getSuperiorFullRelation(superiorFunction, inferiorFunction);
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ public class FidDB implements Closeable {
|
|||
public boolean getInferiorFullRelation(FidHashQuad superiorFunction,
|
||||
FunctionRecord inferiorFunction) {
|
||||
try {
|
||||
Record libraryByID = librariesTable.getLibraryByID(inferiorFunction.getLibraryID());
|
||||
DBRecord libraryByID = librariesTable.getLibraryByID(inferiorFunction.getLibraryID());
|
||||
if (libraryByID != null) {
|
||||
return relationsTable.getInferiorFullRelation(superiorFunction, inferiorFunction);
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ public class FidDB implements Closeable {
|
|||
*/
|
||||
public LibraryRecord getLibraryForFunction(FunctionRecord functionRecord) {
|
||||
try {
|
||||
Record record = librariesTable.getLibraryByID(functionRecord.getLibraryID());
|
||||
DBRecord record = librariesTable.getLibraryByID(functionRecord.getLibraryID());
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ public class FidDB implements Closeable {
|
|||
|
||||
try {
|
||||
checkUpdateAllowed();
|
||||
Record record = librariesTable.createLibrary(libraryFamilyName, libraryVersion,
|
||||
DBRecord record = librariesTable.createLibrary(libraryFamilyName, libraryVersion,
|
||||
libraryVariant, ghidraVersion, languageID, languageVersion, languageMinorVersion,
|
||||
compilerSpecID);
|
||||
return new LibraryRecord(record);
|
||||
|
|
|
@ -17,7 +17,7 @@ package ghidra.feature.fid.db;
|
|||
|
||||
import static ghidra.feature.fid.db.FunctionsTable.*;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.feature.fid.hash.FidHashQuad;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.DatabaseObject;
|
||||
|
@ -36,7 +36,7 @@ public class FunctionRecord extends DatabaseObject implements FidHashQuad {
|
|||
/**
|
||||
* All values are stored in the record instead of memoized.
|
||||
*/
|
||||
final Record record;
|
||||
final DBRecord record;
|
||||
/**
|
||||
* Need a reference to the FidDb because all strings are stored
|
||||
* via foreign key (considerable duplication of string values).
|
||||
|
@ -49,7 +49,7 @@ public class FunctionRecord extends DatabaseObject implements FidHashQuad {
|
|||
* @param cache FunctionRecord object cache
|
||||
* @param record record for this function
|
||||
*/
|
||||
FunctionRecord(FidDB fid, DBObjectCache<FunctionRecord> cache, Record record) {
|
||||
FunctionRecord(FidDB fid, DBObjectCache<FunctionRecord> cache, DBRecord record) {
|
||||
super(cache, record.getKey());
|
||||
this.record = record;
|
||||
this.fidDb = fid;
|
||||
|
|
|
@ -112,7 +112,7 @@ public class FunctionsTable {
|
|||
RecordIterator iterator = table.iterator();
|
||||
List<FunctionRecord> list = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
Record record = iterator.next();
|
||||
DBRecord record = iterator.next();
|
||||
if (record.getLongValue(SPECIFIC_HASH_COL) != hash) {
|
||||
continue;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class FunctionsTable {
|
|||
Field key = iterator.next();
|
||||
FunctionRecord functionRecord = functionCache.get(key.getLongValue());
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
functionRecord = new FunctionRecord(fidDb, functionCache, record);
|
||||
}
|
||||
list.add(functionRecord);
|
||||
|
@ -164,7 +164,7 @@ public class FunctionsTable {
|
|||
*/
|
||||
public FunctionRecord createFunctionRecord(long libraryID, FidHashQuad hashQuad, String name,
|
||||
long entryPoint, String domainPath, boolean hasTerminator) throws IOException {
|
||||
Record record = SCHEMA.createRecord(UniversalIdGenerator.nextID().getValue());
|
||||
DBRecord record = SCHEMA.createRecord(UniversalIdGenerator.nextID().getValue());
|
||||
record.setShortValue(CODE_UNIT_SIZE_COL, hashQuad.getCodeUnitSize());
|
||||
record.setLongValue(FULL_HASH_COL, hashQuad.getFullHash());
|
||||
record.setByteValue(SPECIFIC_HASH_ADDITIONAL_SIZE_COL,
|
||||
|
@ -191,7 +191,7 @@ public class FunctionsTable {
|
|||
* @throws IOException
|
||||
*/
|
||||
void modifyFlags(long functionID, int flagMask, boolean value) throws IOException {
|
||||
Record record = table.getRecord(functionID);
|
||||
DBRecord record = table.getRecord(functionID);
|
||||
if (record == null) {
|
||||
throw new IOException("Function record does not exist");
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class FunctionsTable {
|
|||
Field key = iterator.next();
|
||||
FunctionRecord functionRecord = functionCache.get(key.getLongValue());
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
long nameID = record.getLongValue(NAME_ID_COL);
|
||||
StringRecord nameRecord = stringsTable.lookupString(nameID);
|
||||
String name = nameRecord.getValue();
|
||||
|
@ -266,7 +266,7 @@ public class FunctionsTable {
|
|||
Field key = iterator.next();
|
||||
FunctionRecord functionRecord = functionCache.get(key.getLongValue());
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
long nameID = record.getLongValue(NAME_ID_COL);
|
||||
StringRecord nameRecord = stringsTable.lookupString(nameID);
|
||||
String name = nameRecord.getValue();
|
||||
|
@ -297,7 +297,7 @@ public class FunctionsTable {
|
|||
public FunctionRecord getFunctionByID(long functionID) throws IOException {
|
||||
FunctionRecord functionRecord = functionCache.get(functionID);
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(functionID);
|
||||
DBRecord record = table.getRecord(functionID);
|
||||
if (record != null) {
|
||||
functionRecord = new FunctionRecord(fidDb, functionCache, record);
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ public class FunctionsTable {
|
|||
RecordIterator iterator = table.iterator();
|
||||
List<FunctionRecord> list = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
Record record = iterator.next();
|
||||
DBRecord record = iterator.next();
|
||||
long domainPathID = record.getLongValue(DOMAIN_PATH_ID_COL);
|
||||
StringRecord domainPathRecord = stringsTable.lookupString(domainPathID);
|
||||
String domainPath = domainPathRecord.getValue();
|
||||
|
@ -358,7 +358,7 @@ public class FunctionsTable {
|
|||
Field key = iterator.next();
|
||||
FunctionRecord functionRecord = functionCache.get(key.getLongValue());
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
if (record.getLongValue(LIBRARY_ID_COL) == libraryKey) {
|
||||
functionRecord = new FunctionRecord(fidDb, functionCache, record);
|
||||
list.add(functionRecord);
|
||||
|
|
|
@ -110,10 +110,10 @@ public class LibrariesTable {
|
|||
* @return the new library record
|
||||
* @throws IOException if the database create fails
|
||||
*/
|
||||
public Record createLibrary(String libraryFamilyName, String libraryVersion,
|
||||
public DBRecord createLibrary(String libraryFamilyName, String libraryVersion,
|
||||
String libraryVariant, String ghidraVersion, LanguageID languageID, int languageVersion,
|
||||
int languageMinorVersion, CompilerSpecID compilerSpecID) throws IOException {
|
||||
Record record = SCHEMA.createRecord(UniversalIdGenerator.nextID().getValue());
|
||||
DBRecord record = SCHEMA.createRecord(UniversalIdGenerator.nextID().getValue());
|
||||
record.setString(LIBRARY_FAMILY_NAME_COL, libraryFamilyName);
|
||||
record.setString(LIBRARY_VERSION_COL, libraryVersion);
|
||||
record.setString(LIBRARY_VARIANT_COL, libraryVariant);
|
||||
|
@ -164,7 +164,7 @@ public class LibrariesTable {
|
|||
List<LibraryRecord> list = new ArrayList<LibraryRecord>();
|
||||
while (iterator.hasNext()) {
|
||||
Field key = iterator.next();
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
LibraryRecord libraryRecord = new LibraryRecord(record);
|
||||
if (version != null) {
|
||||
if (!libraryRecord.getLibraryVersion().equals(version)) {
|
||||
|
@ -187,8 +187,8 @@ public class LibrariesTable {
|
|||
* @return the library or null if not found
|
||||
* @throws IOException if database seek encounters an error
|
||||
*/
|
||||
public Record getLibraryByID(long id) throws IOException {
|
||||
Record record = table.getRecord(id);
|
||||
public DBRecord getLibraryByID(long id) throws IOException {
|
||||
DBRecord record = table.getRecord(id);
|
||||
return record;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package ghidra.feature.fid.db;
|
|||
import static ghidra.feature.fid.db.LibrariesTable.*;
|
||||
import ghidra.program.model.lang.CompilerSpecID;
|
||||
import ghidra.program.model.lang.LanguageID;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
/**
|
||||
* Represents a library record in the FID database.
|
||||
|
@ -27,13 +27,13 @@ public class LibraryRecord {
|
|||
/**
|
||||
* The record is stored, no memoization is performed.
|
||||
*/
|
||||
final Record record;
|
||||
final DBRecord record;
|
||||
|
||||
/**
|
||||
* Creates a new library record.
|
||||
* @param record the database record on which to base this library
|
||||
*/
|
||||
public LibraryRecord(Record record) {
|
||||
public LibraryRecord(DBRecord record) {
|
||||
if (record == null) {
|
||||
throw new IllegalArgumentException("null record");
|
||||
}
|
||||
|
|
|
@ -63,12 +63,12 @@ public class RelationsTable {
|
|||
RelationType relationType) throws IOException {
|
||||
long superiorKey =
|
||||
FidDBUtils.generateSuperiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record superiorRecord = SCHEMA.createRecord(superiorKey);
|
||||
DBRecord superiorRecord = SCHEMA.createRecord(superiorKey);
|
||||
superiorTable.putRecord(superiorRecord);
|
||||
if (relationType != RelationType.INTER_LIBRARY_CALL) {
|
||||
long inferiorKey =
|
||||
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record inferiorRecord = SCHEMA.createRecord(inferiorKey);
|
||||
DBRecord inferiorRecord = SCHEMA.createRecord(inferiorKey);
|
||||
inferiorTable.putRecord(inferiorRecord);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class RelationsTable {
|
|||
FunctionRecord inferiorFunction) throws IOException {
|
||||
long inferiorKey =
|
||||
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record inferiorRecord = SCHEMA.createRecord(inferiorKey);
|
||||
DBRecord inferiorRecord = SCHEMA.createRecord(inferiorKey);
|
||||
inferiorTable.putRecord(inferiorRecord);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class RelationsTable {
|
|||
FidHashQuad inferiorFunction) throws IOException {
|
||||
long superiorKey =
|
||||
FidDBUtils.generateSuperiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record record = superiorTable.getRecord(superiorKey);
|
||||
DBRecord record = superiorTable.getRecord(superiorKey);
|
||||
return (record != null);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class RelationsTable {
|
|||
FunctionRecord inferiorFunction) throws IOException {
|
||||
long inferiorKey =
|
||||
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record record = inferiorTable.getRecord(inferiorKey);
|
||||
DBRecord record = inferiorTable.getRecord(inferiorKey);
|
||||
return (record != null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class StringsTable {
|
|||
if (records == null || records.length == 0) {
|
||||
// create
|
||||
long key = UniversalIdGenerator.nextID().getValue();
|
||||
Record record = SCHEMA.createRecord(key);
|
||||
DBRecord record = SCHEMA.createRecord(key);
|
||||
record.setString(STRING_VALUE_COL, value);
|
||||
table.putRecord(record);
|
||||
return key;
|
||||
|
@ -101,7 +101,7 @@ public class StringsTable {
|
|||
StringRecord lookupString(long stringID) {
|
||||
StringRecord stringRecord = stringCache.get(stringID);
|
||||
if (stringRecord == null) {
|
||||
Record record;
|
||||
DBRecord record;
|
||||
try {
|
||||
record = table.getRecord(stringID);
|
||||
if (record != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue