GP-696 Raised ProgramDB version to 23 (upgrade not required). Implement BigRefList for from-refs

This commit is contained in:
dragonmacher 2021-02-23 12:33:16 -05:00 committed by ghidra1
parent 45927bb9c3
commit 0ed83875fc
4 changed files with 20 additions and 9 deletions

View file

@ -96,8 +96,10 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
* 19-Jun-2020 - version 22 - Corrected fixed length indexing implementation causing * 19-Jun-2020 - version 22 - Corrected fixed length indexing implementation causing
* change in index table low-level storage for newly * change in index table low-level storage for newly
* created tables. * created tables.
* 18-Feb-2021 - version 23 Added support for Big Reflist for tracking FROM references.
* Primarily used for large numbers of Entry Point references.
*/ */
static final int DB_VERSION = 22; static final int DB_VERSION = 23;
/** /**
* UPGRADE_REQUIRED_BFORE_VERSION should be changed to DB_VERSION anytime the * UPGRADE_REQUIRED_BFORE_VERSION should be changed to DB_VERSION anytime the

View file

@ -62,17 +62,17 @@ class BigRefListV0 extends RefList {
* @param address address associated with this list * @param address address associated with this list
* @param adapter entry record storage adapter * @param adapter entry record storage adapter
* @param addrMap address map for encoding/decoding addresses * @param addrMap address map for encoding/decoding addresses
* @param program * @param program associated Program
* @param cache RefList object cache * @param cache RefList object cache
* @param isFrom true for from-adapter use, false for to-adapter use * @param isFrom true for from-adapter use, false for to-adapter use
* @throws IOException * @throws IOException if database IO error occurs
*/ */
BigRefListV0(Address address, RecordAdapter adapter, AddressMap addrMap, ProgramDB program, BigRefListV0(Address address, RecordAdapter adapter, AddressMap addrMap, ProgramDB program,
DBObjectCache<RefList> cache, boolean isFrom) throws IOException { DBObjectCache<RefList> cache, boolean isFrom) throws IOException {
super(addrMap.getKey(address, true), address, adapter, addrMap, program, cache, isFrom); super(addrMap.getKey(address, true), address, adapter, addrMap, program, cache, isFrom);
record = ToAdapter.TO_REFS_SCHEMA.createRecord(key); record = ToAdapter.TO_REFS_SCHEMA.createRecord(key);
table = program.getDBHandle().createTable(BASE_TABLE_NAME + Long.toHexString(key), table = program.getDBHandle()
BIG_REFS_SCHEMA, new int[] { ADDRESS_COL }); .createTable(getTableName(), BIG_REFS_SCHEMA, new int[] { ADDRESS_COL });
} }
/** /**
@ -80,9 +80,10 @@ class BigRefListV0 extends RefList {
* @param rec existing refList record * @param rec existing refList record
* @param adapter entry record storage adapter * @param adapter entry record storage adapter
* @param addrMap address map for encoding/decoding addresses * @param addrMap address map for encoding/decoding addresses
* @param program * @param program associated Program
* @param cache RefList object cache * @param cache RefList object cache
* @param isFrom true for from-adapter use, false for to-adapter use * @param isFrom true for from-adapter use, false for to-adapter use
* @throws IOException if database IO error occurs
*/ */
BigRefListV0(DBRecord rec, RecordAdapter adapter, AddressMap addrMap, ProgramDB program, BigRefListV0(DBRecord rec, RecordAdapter adapter, AddressMap addrMap, ProgramDB program,
DBObjectCache<RefList> cache, boolean isFrom) throws IOException { DBObjectCache<RefList> cache, boolean isFrom) throws IOException {
@ -91,11 +92,10 @@ class BigRefListV0 extends RefList {
if (rec.getBinaryData(ToAdapter.REF_DATA_COL) != null) { if (rec.getBinaryData(ToAdapter.REF_DATA_COL) != null) {
throw new IllegalArgumentException("Invalid reference record"); throw new IllegalArgumentException("Invalid reference record");
} }
String tableName = BASE_TABLE_NAME + Long.toHexString(rec.getKey()); table = program.getDBHandle().getTable(getTableName());
table = program.getDBHandle().getTable(tableName);
if (table == null) { if (table == null) {
throw new IOException( throw new IOException(
"BigRefList table not found for " + address + " (" + tableName + ")"); "BigRefList table not found for " + address + " (" + getTableName() + ")");
} }
if (!isFrom) { if (!isFrom) {
refLevel = rec.getByteValue(ToAdapter.REF_LEVEL_COL); refLevel = rec.getByteValue(ToAdapter.REF_LEVEL_COL);
@ -103,6 +103,11 @@ class BigRefListV0 extends RefList {
record = rec; record = rec;
} }
private String getTableName() {
String prefix = isFrom ? "From" : "";
return prefix + BASE_TABLE_NAME + Long.toHexString(key);
}
@Override @Override
public RefList checkRefListSize(DBObjectCache<RefList> cache, int newSpaceRequired) { public RefList checkRefListSize(DBObjectCache<RefList> cache, int newSpaceRequired) {
return this; return this;

View file

@ -60,6 +60,9 @@ class FromAdapterV0 extends FromAdapter {
long fromAddr) throws IOException { long fromAddr) throws IOException {
DBRecord rec = table.getRecord(fromAddr); DBRecord rec = table.getRecord(fromAddr);
if (rec != null) { if (rec != null) {
if (rec.getBinaryData(REF_DATA_COL) == null) {
return new BigRefListV0(rec, this, addrMap, program, cache, true);
}
return new RefListV0(rec, this, addrMap, program, cache, true); return new RefListV0(rec, this, addrMap, program, cache, true);
} }
return null; return null;

View file

@ -382,6 +382,7 @@ public class ReferenceDBManager implements ReferenceManager, ManagerDB, ErrorHan
if (fromRefs == null) { if (fromRefs == null) {
fromRefs = fromAdapter.createRefList(program, fromCache, fromAddr); fromRefs = fromAdapter.createRefList(program, fromCache, fromAddr);
} }
fromRefs = fromRefs.checkRefListSize(fromCache, 1);
fromRefs.addRef(fromAddr, toAddr, type, opIndex, -1, isPrimary, sourceType, isOffset, fromRefs.addRef(fromAddr, toAddr, type, opIndex, -1, isPrimary, sourceType, isOffset,
isShifted, offsetOrShift); isShifted, offsetOrShift);