mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 00:20:10 +00:00
spelling fixes
This commit is contained in:
parent
5e5b0790ad
commit
0248c4f1ba
@ -47,7 +47,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
|
||||
// Each of the following is a choice or possible resolution when merging data types.
|
||||
static final int CANCELED = -2; // user canceled the merge operation
|
||||
static final int ASK_USER = -1;// prompt the user to choose resolution
|
||||
static final int ASK_USER = -1;// prompt the user to choose resolution
|
||||
static final int OPTION_LATEST = 0; // Latest
|
||||
static final int OPTION_MY = 1; // My change
|
||||
static final int OPTION_ORIGINAL = 2; // Original
|
||||
@ -96,7 +96,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
* @param myDomainObject the program requesting to be checked in.
|
||||
* @param originalDomainObject the program that was checked out.
|
||||
* @param latestDomainObject the latest checked-in version of the program.
|
||||
* @param latestChanges the address set of changes between original and latest versioned program.
|
||||
* @param latestChanges the address set of changes between original and latest versioned program.
|
||||
* @param myChanges the address set of changes between original and my modified program.
|
||||
*/
|
||||
public DataTypeMergeManager(DomainObjectMergeManager mergeManager,
|
||||
@ -132,7 +132,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
public void apply() {
|
||||
if (catMergePanel != null && catMergePanel.isVisible()) {
|
||||
conflictOption = catMergePanel.getSelectedOption();
|
||||
// If the "Use For All" check box is selected
|
||||
// If the "Use For All" check box is selected
|
||||
// then save the option chosen for this conflict type.
|
||||
if (catMergePanel.getUseForAll()) {
|
||||
categoryChoice = conflictOption;
|
||||
@ -140,7 +140,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
else if (dtMergePanel != null && dtMergePanel.isVisible()) {
|
||||
conflictOption = dtMergePanel.getSelectedOption();
|
||||
// If the "Use For All" check box is selected
|
||||
// If the "Use For All" check box is selected
|
||||
// then save the option chosen for this conflict type.
|
||||
if (dtMergePanel.getUseForAll()) {
|
||||
dataTypeChoice = conflictOption;
|
||||
@ -148,7 +148,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
else {
|
||||
conflictOption = archiveMergePanel.getSelectedOption();
|
||||
// If the "Use For All" check box is selected
|
||||
// If the "Use For All" check box is selected
|
||||
// then save the option chosen for this conflict type.
|
||||
if (archiveMergePanel.getUseForAll()) {
|
||||
sourceArchiveChoice = conflictOption;
|
||||
@ -259,7 +259,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
|
||||
/**
|
||||
* For JUnit testing only, set the option for resolving a conflict.
|
||||
* @param option forced conflict resolution option
|
||||
* @param option forced conflict resolution option
|
||||
*/
|
||||
void setConflictResolution(int option) {
|
||||
conflictOption = option;
|
||||
@ -548,7 +548,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
changeSourceArchive(id);
|
||||
}
|
||||
|
||||
// Make sure the change time is updated (even if keeping the Latest version)
|
||||
// Make sure the change time is updated (even if keeping the Latest version)
|
||||
// since a conflict was resolved for the data type.
|
||||
DataType resultDt = dtms[RESULT].getDataType(id);
|
||||
if (resultDt != null) {
|
||||
@ -687,7 +687,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the data type name/category path in RESULT if it exists.
|
||||
* Update the data type name/category path in RESULT if it exists.
|
||||
* If it does not exist, add it to RESULT.
|
||||
* @param id id of data type
|
||||
* @param dt data type to use as the source name and category path
|
||||
@ -751,7 +751,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
/**
|
||||
* Set category path. If name conflict occurs within new category
|
||||
* the specified dt will remain within its current category
|
||||
* @param dt datatype whoose category is to changed
|
||||
* @param dt datatype whose category is to changed
|
||||
* @param newPath new category path
|
||||
*/
|
||||
private void setCategoryPath(DataType dt, CategoryPath newPath) {
|
||||
@ -842,7 +842,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
*
|
||||
* @param dataTypeID the ID (key) of the data type to be added.
|
||||
* @param dataType the data type to be added.
|
||||
* @param resolvedDataTypes table which maps the dataTypeID to the resulting data type within
|
||||
* @param resolvedDataTypes table which maps the dataTypeID to the resulting data type within
|
||||
* this data type manager.
|
||||
* @return the resulting data type in this data type manager.
|
||||
*/
|
||||
@ -888,7 +888,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resolved data type from the given table;
|
||||
* Get the resolved data type from the given table;
|
||||
* If the data type has not been resolved yet, then use the one from
|
||||
* the results if the id was not added in MY program.
|
||||
* @param id id of data type
|
||||
@ -906,12 +906,12 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
DataType resolvedDt = resolvedDataTypes.get(baseID);
|
||||
if (resolvedDt == null) {
|
||||
// Haven't resolved this yet.
|
||||
// use dt from results
|
||||
// use dt from results
|
||||
if (!myDtAddedList.contains(Long.valueOf(baseID))) {
|
||||
resolvedDt = dtms[RESULT].getDataType(baseID);
|
||||
if (resolvedDt == null) {
|
||||
if (origDtConflictList.contains(Long.valueOf(baseID))) {
|
||||
// was deleted, but add it back so we can create
|
||||
// was deleted, but add it back so we can create
|
||||
// data types depending on it; will get resolved later
|
||||
resolvedDt = addDataType(baseID, baseDt, resolvedDataTypes);
|
||||
}
|
||||
@ -1156,7 +1156,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
else {
|
||||
// must have been deleted in LATEST
|
||||
// put an entry in the fixup list if this is a conflict.
|
||||
// NOTE: This may also be caused by a replaced datatype but
|
||||
// NOTE: This may also be caused by a replaced datatype but
|
||||
// we have no indication as to what the replacment was
|
||||
deletedInLatest = true;
|
||||
}
|
||||
@ -1583,7 +1583,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process categories that were moved in MY program, but are not
|
||||
* Process categories that were moved in MY program, but are not
|
||||
* conflicts, i.e., not renamed, moved, or deleted in LATEST.
|
||||
* @param id category ID
|
||||
*/
|
||||
@ -1608,7 +1608,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process categories that were deleted in MY program, but are not
|
||||
* Process categories that were deleted in MY program, but are not
|
||||
* conflicts, i.e., not renamed, moved, or deleted in LATEST.
|
||||
* @param id category ID
|
||||
*/
|
||||
@ -1617,7 +1617,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
if (myCat == null) {
|
||||
Category resultCat = dtms[RESULT].getCategory(id);
|
||||
if (resultCat != null) {
|
||||
// check added data types that have this category path as
|
||||
// check added data types that have this category path as
|
||||
// the parent
|
||||
if (!isParent(resultCat.getCategoryPath())) {
|
||||
resultCat.getParent().removeCategory(resultCat.getName(), currentMonitor);
|
||||
@ -1662,7 +1662,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
throw new AssertException("Got DuplicateNameException");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// cannot move category
|
||||
// cannot move category
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2040,7 +2040,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
private void deleteLatestCategory(Category latestCat) {
|
||||
// delete the category from results program if the
|
||||
// paths on the data types in LATEST are different
|
||||
// from path on the data types in MY;
|
||||
// from path on the data types in MY;
|
||||
DataType[] dts = latestCat.getDataTypes();
|
||||
boolean doDelete = true;
|
||||
if (dts.length > 0) {
|
||||
@ -2204,11 +2204,11 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
|
||||
/**
|
||||
* See if there is a data type in the result file that matches My data type based on
|
||||
* name, path and contents.
|
||||
* name, path and contents.
|
||||
* If there is a data type that is the same then return true.
|
||||
* @param myDtID the database ID (key) for My data type.
|
||||
* @param myDt My data type.
|
||||
* @return true if the same named and equivalent data type is found in the result
|
||||
* @return true if the same named and equivalent data type is found in the result
|
||||
* data type manager.
|
||||
*/
|
||||
private boolean equivalentDataTypeFound(long myDtID, DataType myDt) {
|
||||
@ -2222,8 +2222,9 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
UniversalID resultDtUniversalID = resultDt.getUniversalID();
|
||||
UniversalID myDtUniversalID = myDt.getUniversalID();
|
||||
// UniversalID can be null if data type is BuiltIn.
|
||||
if (!resultSourceArchive.getSourceArchiveID().equals(
|
||||
mySourceArchive.getSourceArchiveID()) ||
|
||||
if (!resultSourceArchive.getSourceArchiveID()
|
||||
.equals(
|
||||
mySourceArchive.getSourceArchiveID()) ||
|
||||
!Objects.equals(resultDtUniversalID, myDtUniversalID)) {
|
||||
return false;
|
||||
}
|
||||
@ -2237,7 +2238,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
|
||||
private void cleanUpDataTypes() {
|
||||
// clean up data types
|
||||
List<Long> keys = new ArrayList<Long>(cleanupPlaceHolderList.keySet());
|
||||
List<Long> keys = new ArrayList<>(cleanupPlaceHolderList.keySet());
|
||||
for (long key : keys) {
|
||||
CleanUpInfo cleanUpInfo = cleanupPlaceHolderList.get(key);
|
||||
cleanUpInfo.cleanUp();
|
||||
@ -2506,7 +2507,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the number of contiguous undefined bytes in this structure starting
|
||||
* Determines the number of contiguous undefined bytes in this structure starting
|
||||
* at the indicated component ordinal.
|
||||
* @param struct the structure to check.
|
||||
* @param ordinal the ordinal of the component where checking for undefined bytes should begin.
|
||||
@ -2649,11 +2650,6 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param compID
|
||||
* @param dataTypeManager
|
||||
* @return
|
||||
*/
|
||||
private DataType resolve(long id, DataTypeManager dtm,
|
||||
Map<Long, DataType> resolvedDataTypes) {
|
||||
DataType dt = getResolvedComponent(id, resolvedDataTypes);
|
||||
@ -2943,9 +2939,9 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes my data types that were added and determines whether each is actually a
|
||||
* conflict, an added data type, or a changed data type relative to the Latest check in.
|
||||
* @param myDtAdds
|
||||
* Processes my data types that were added and determines whether each is actually a
|
||||
* conflict, an added data type, or a changed data type relative to the Latest check in.
|
||||
* @param myDtAdds the data type IDs
|
||||
*/
|
||||
private void processAddIDs(long[] myDtAdds) {
|
||||
myDtAddedList = new ArrayList<>();
|
||||
@ -3219,7 +3215,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
* or components were resolved.
|
||||
* @param id id of data type needed to be fixed up
|
||||
* @param compID id of either component or base type
|
||||
* @param index offset into non-packed structure, or ordinal into union or packed
|
||||
* @param index offset into non-packed structure, or ordinal into union or packed
|
||||
* structure; or parameter/return ordinal; for other data types index is not used (specify -1).
|
||||
* @param resolvedDataTypes hashtable used for resolving the data type
|
||||
*/
|
||||
@ -3329,7 +3325,7 @@ public class DataTypeMergeManager implements MergeResolver {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param index offset into non-packed structure, or ordinal into union or packed
|
||||
* @param index offset into non-packed structure, or ordinal into union or packed
|
||||
* structure; for other data types, offset is not used (specify -1)
|
||||
* @param resolvedDataTypes hashtable used for resolving the data type
|
||||
*/
|
||||
|
@ -24,47 +24,47 @@ public class DatabaseUtils {
|
||||
|
||||
private DatabaseUtils() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reassign the long key assigned to a contiguous group of records within a table.
|
||||
* A shift in the key value is computed as the difference of oldStart and newStart.
|
||||
* Existing records whoose keys lie within the new range will be removed prior to
|
||||
* Existing records whose keys lie within the new range will be removed prior to
|
||||
* moving the target set of records.
|
||||
* @param table table within which records should be moved.
|
||||
* @param oldStart old key value for start of range
|
||||
* @param newStart new key value for start of range
|
||||
* @param size determines the range of keys to be moved (oldStart to oldStart+size-1, inclusive)
|
||||
* @throws IOException
|
||||
* @throws IOException if there is an error moving the records
|
||||
*/
|
||||
public static void moveRecords(Table table, long oldStart, long newStart, long size) throws IOException{
|
||||
public static void moveRecords(Table table, long oldStart, long newStart, long size)
|
||||
throws IOException {
|
||||
if (oldStart == newStart) {
|
||||
return;
|
||||
}
|
||||
if (size <= 0) {
|
||||
throw new IllegalArgumentException("size must be > 0");
|
||||
}
|
||||
if ((oldStart + size -1 < 0) || (newStart+size-1 <0)){
|
||||
if ((oldStart + size - 1 < 0) || (newStart + size - 1 < 0)) {
|
||||
throw new IllegalArgumentException("Illegal range: end range overflow");
|
||||
}
|
||||
|
||||
|
||||
DBHandle tmp = new DBHandle();
|
||||
Table tmpTable = tmp.createTable("tmp", table.getSchema());
|
||||
long txID = tmp.startTransaction();
|
||||
|
||||
|
||||
long keyDiff = newStart - oldStart;
|
||||
RecordIterator it = table.iterator(oldStart, oldStart+size-1, oldStart);
|
||||
while(it.hasNext()) {
|
||||
RecordIterator it = table.iterator(oldStart, oldStart + size - 1, oldStart);
|
||||
while (it.hasNext()) {
|
||||
DBRecord rec = it.next();
|
||||
rec.setKey(rec.getKey()+keyDiff);
|
||||
rec.setKey(rec.getKey() + keyDiff);
|
||||
tmpTable.putRecord(rec);
|
||||
}
|
||||
|
||||
table.deleteRecords(oldStart, oldStart+size-1);
|
||||
table.deleteRecords(newStart, newStart+size-1);
|
||||
|
||||
it = tmpTable.iterator(newStart, newStart+size-1, newStart);
|
||||
while(it.hasNext()) {
|
||||
table.deleteRecords(oldStart, oldStart + size - 1);
|
||||
table.deleteRecords(newStart, newStart + size - 1);
|
||||
|
||||
it = tmpTable.iterator(newStart, newStart + size - 1, newStart);
|
||||
while (it.hasNext()) {
|
||||
DBRecord rec = it.next();
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import java.util.ArrayList;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* <code>FieldIndexTable</code> provides a simplified index table whoose key is
|
||||
* a fixed or variable length {@link IndexField} which consists of a concatenation of
|
||||
* <code>FieldIndexTable</code> provides a simplified index table whose key is
|
||||
* a fixed or variable length {@link IndexField} which consists of a concatenation of
|
||||
* the index field value and associated primary table key.
|
||||
*/
|
||||
public class FieldIndexTable extends IndexTable {
|
||||
@ -40,8 +40,10 @@ public class FieldIndexTable extends IndexTable {
|
||||
* @throws IOException thrown if IO error occurs
|
||||
*/
|
||||
FieldIndexTable(Table primaryTable, int colIndex) throws IOException {
|
||||
this(primaryTable, primaryTable.getDBHandle().getMasterTable().createTableRecord(
|
||||
primaryTable.getName(), getIndexTableSchema(primaryTable, colIndex), colIndex));
|
||||
this(primaryTable, primaryTable.getDBHandle()
|
||||
.getMasterTable()
|
||||
.createTableRecord(
|
||||
primaryTable.getName(), getIndexTableSchema(primaryTable, colIndex), colIndex));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +51,7 @@ public class FieldIndexTable extends IndexTable {
|
||||
* its root ID specified within the tableRecord.
|
||||
* @param primaryTable primary table.
|
||||
* @param indexTableRecord specifies the index parameters.
|
||||
* @throws IOException thrown if an IO error occurs
|
||||
* @throws IOException thrown if an IO error occurs
|
||||
*/
|
||||
FieldIndexTable(Table primaryTable, TableRecord indexTableRecord) throws IOException {
|
||||
super(primaryTable, indexTableRecord);
|
||||
@ -167,7 +169,7 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an index field iterator.
|
||||
* Construct an index field iterator.
|
||||
* @param minValue minimum index value or null if no minimum
|
||||
* @param maxValue maximum index value or null if no maximum
|
||||
* @param before if true initial position is before minValue, else position
|
||||
@ -213,7 +215,7 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an index field iterator. The iterator is positioned at index
|
||||
* Construct an index field iterator. The iterator is positioned at index
|
||||
* value identified by startValue.
|
||||
* @param minValue minimum index value or null if no minimum
|
||||
* @param maxValue maximum index value or null if no maximum
|
||||
@ -442,7 +444,7 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a key iterator. The iterator is positioned immediately before
|
||||
* Construct a key iterator. The iterator is positioned immediately before
|
||||
* the key associated with the first occurance of the startValue.
|
||||
* @param startValue indexed field value.
|
||||
* @param after if true the iterator is positioned immediately after
|
||||
@ -456,13 +458,13 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a key iterator. The iterator is positioned immediately before
|
||||
* Construct a key iterator. The iterator is positioned immediately before
|
||||
* or after the key associated with the specified startValue/primaryKey.
|
||||
* @param minValue minimum index value or null if no minimum
|
||||
* @param maxValue maximum index value or null if no maximum
|
||||
* @param startValue starting index value.
|
||||
* @param primaryKey starting primary key value (ignored if startValue is null).
|
||||
* @param after if true iterator is positioned immediately after
|
||||
* @param after if true iterator is positioned immediately after
|
||||
* the startValue/primaryKey,
|
||||
* otherwise immediately before.
|
||||
* @throws IOException thrown if IO error occurs
|
||||
@ -499,11 +501,11 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
|
||||
/**
|
||||
* If min or max index values was truncated, a comparison of the actual
|
||||
* If min or max index values was truncated, a comparison of the actual
|
||||
* indexed field value (i.e., primary table value) is done with the min and/or max values.
|
||||
* @param f index field from index table iterator
|
||||
* @return true if field value corresponding to f is outside the min/max range.
|
||||
* It is assumed that the underlying table iterator will not return index values
|
||||
* It is assumed that the underlying table iterator will not return index values
|
||||
* out of range which do not have the same truncated index value.
|
||||
* @throws IOException thrown if IO error occurs
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ import ghidra.util.task.TaskMonitor;
|
||||
* <code>LongKeyRecordNode</code> is an abstract implementation of a BTree leaf node
|
||||
* which utilizes long key values and stores records.
|
||||
* <p>
|
||||
* This type of node has the following partial layout within a single DataBuffer
|
||||
* This type of node has the following partial layout within a single DataBuffer
|
||||
* (field size in bytes):
|
||||
* <pre>
|
||||
* | NodeType(1) | KeyCount(4) | PrevLeafId(4) | NextLeafId(4) | ...
|
||||
@ -412,7 +412,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
|
||||
/**
|
||||
* Inserts the record at the given index if there is sufficient space in
|
||||
* the buffer.
|
||||
* the buffer.
|
||||
* @param index insertion index
|
||||
* @param record record to be inserted
|
||||
* @return true if the record was successfully inserted.
|
||||
@ -421,7 +421,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
abstract boolean insertRecord(int index, DBRecord record) throws IOException;
|
||||
|
||||
/**
|
||||
* Updates the record at the given index.
|
||||
* Updates the record at the given index.
|
||||
* @param index record index
|
||||
* @param record new record
|
||||
* @return root node which may have changed.
|
||||
@ -448,7 +448,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
abstract DBRecord getRecord(Schema schema, int index) throws IOException;
|
||||
|
||||
/**
|
||||
* Get the first record whoose key is less than the specified key.
|
||||
* Get the first record whose key is less than the specified key.
|
||||
* @param key record key
|
||||
* @param schema record data schema
|
||||
* @return Record requested or null if record not found.
|
||||
@ -470,7 +470,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first record whoose key is greater than the specified key.
|
||||
* Get the first record whose key is greater than the specified key.
|
||||
* @param key record key
|
||||
* @param schema record data schema
|
||||
* @return Record requested or null if record not found.
|
||||
@ -492,7 +492,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first record whoose key is less than or equal to the specified
|
||||
* Get the first record whose key is less than or equal to the specified
|
||||
* key.
|
||||
* @param key record key
|
||||
* @param schema record data schema
|
||||
@ -512,7 +512,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first record whoose key is greater than or equal to the specified
|
||||
* Get the first record whose key is greater than or equal to the specified
|
||||
* key.
|
||||
* @param key record key
|
||||
* @param schema record data 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,14 +15,14 @@
|
||||
*/
|
||||
package db.buffers;
|
||||
|
||||
import ghidra.util.datastruct.IntIntHashtable;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.NoValueException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import ghidra.util.datastruct.IntIntHashtable;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.NoValueException;
|
||||
|
||||
/**
|
||||
* <code>VersionFile</code> records buffer changes and parameters necessary to reconstruct an
|
||||
* older version of a LocalBufferFile.
|
||||
@ -31,7 +30,7 @@ import java.util.*;
|
||||
class RecoveryFile {
|
||||
|
||||
private static final int MAGIC_NUMBER = 0x38DE7654;
|
||||
|
||||
|
||||
private static final int VALID = 1;
|
||||
private static final int INVALID = 0;
|
||||
|
||||
@ -44,20 +43,21 @@ class RecoveryFile {
|
||||
private static final String TIMESTAMP_HI_PARM = RECOVERY_PARM_PREFIX + "TimestampHi";
|
||||
private static final String TIMESTAMP_LOW_PARM = RECOVERY_PARM_PREFIX + "TimestampLow";
|
||||
private static final String MAP_BUFFER_INDEX_PARM = RECOVERY_PARM_PREFIX + "MapIndex";
|
||||
private static final String FREE_LIST_BUFFER_INDEX_PARM = RECOVERY_PARM_PREFIX + "FreeListIndex";
|
||||
private static final String FREE_LIST_BUFFER_INDEX_PARM =
|
||||
RECOVERY_PARM_PREFIX + "FreeListIndex";
|
||||
private static final String FREE_LIST_SIZE_PARM = RECOVERY_PARM_PREFIX + "FreeListSize";
|
||||
private static final String INDEX_COUNT_PARM = RECOVERY_PARM_PREFIX + "BufferCount";
|
||||
|
||||
|
||||
// Exception messages
|
||||
private static final String BAD_FREE_LIST = "Recovery file is corrupt - bad free list";
|
||||
private static final String BAD_BUFFER_MAP = "Recovery file is corrupt - bad buffer map";
|
||||
|
||||
|
||||
// Used by both the Buffer Map and Free Index List
|
||||
private static final int NEXT_BUFFER_INDEX_OFFSET = 0;
|
||||
private static final int FIRST_ENTRY_OFFSET = 4;
|
||||
|
||||
|
||||
private boolean readOnly;
|
||||
|
||||
|
||||
private boolean valid = false;
|
||||
private long timestamp;
|
||||
private boolean modified = false;
|
||||
@ -67,75 +67,77 @@ class RecoveryFile {
|
||||
private IndexProvider vfIndexProvider;
|
||||
private int freeListIndex = -1;
|
||||
private int mapIndex = -1;
|
||||
|
||||
|
||||
private int[] freeIndexes; // sorted to facilitate binary search
|
||||
|
||||
|
||||
// maps buffer IDs to version file buffer indexes
|
||||
private IntIntHashtable bufferIndexMap = new IntIntHashtable();
|
||||
|
||||
/**
|
||||
* Construct a new recovery file for update/output.
|
||||
* Construct a new recovery file for update/output.
|
||||
* @param srcBf the original source buffer file to which this file applies.
|
||||
* @param rfile version buffer file to be updated/created
|
||||
* @throws IOException if vfile already exists or an IO error occurs
|
||||
* @param create true to create the file
|
||||
* @throws IOException if the file already exists or an IO error occurs
|
||||
*/
|
||||
RecoveryFile(LocalBufferFile srcBf, File rfile, boolean create) throws IOException {
|
||||
|
||||
|
||||
readOnly = false;
|
||||
|
||||
|
||||
if (create) {
|
||||
indexCnt = srcBf.getIndexCount();
|
||||
|
||||
|
||||
recoveryFile = new LocalBufferFile(rfile, srcBf.getBufferSize());
|
||||
|
||||
|
||||
// Save magic number for version file
|
||||
recoveryFile.setParameter(MAGIC_NUMBER_PARM, MAGIC_NUMBER);
|
||||
|
||||
|
||||
// Mark as invalid
|
||||
recoveryFile.setParameter(IS_VALID_PARM, INVALID);
|
||||
|
||||
// Save original and source file ID as user paramater values
|
||||
|
||||
// Save original and source file ID as user parameter values
|
||||
srcFileId = srcBf.getFileId();
|
||||
recoveryFile.setParameter(SRC_FILE_ID_HI_PARM, (int)(srcFileId >>> 32));
|
||||
recoveryFile.setParameter(SRC_FILE_ID_LOW_PARM, (int)(srcFileId & 0xffffffffL));
|
||||
|
||||
recoveryFile.setParameter(SRC_FILE_ID_HI_PARM, (int) (srcFileId >>> 32));
|
||||
recoveryFile.setParameter(SRC_FILE_ID_LOW_PARM, (int) (srcFileId & 0xffffffffL));
|
||||
|
||||
vfIndexProvider = new IndexProvider();
|
||||
|
||||
|
||||
modified = true;
|
||||
}
|
||||
else {
|
||||
recoveryFile = new LocalBufferFile(rfile, false);
|
||||
|
||||
|
||||
valid = (recoveryFile.getParameter(IS_VALID_PARM) == VALID);
|
||||
if (!valid) {
|
||||
throw new IOException("Can not update invalid recovery file");
|
||||
}
|
||||
|
||||
|
||||
parseFile();
|
||||
|
||||
|
||||
if (srcFileId != srcBf.getFileId()) {
|
||||
throw new IOException("Recovery file not associated with source file");
|
||||
}
|
||||
|
||||
vfIndexProvider = new IndexProvider(recoveryFile.getIndexCount(), recoveryFile.getFreeIndexes());
|
||||
vfIndexProvider =
|
||||
new IndexProvider(recoveryFile.getIndexCount(), recoveryFile.getFreeIndexes());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a read-only recovery file
|
||||
* @param srcBf the original source buffer file to which this file applies.
|
||||
* @param rfile version buffer file to be updated/created
|
||||
* @throws IOException
|
||||
* @throws IOException if vfile already exists or an IO error occurs
|
||||
* @throws IOException if the file already exists or an IO error occurs
|
||||
*/
|
||||
RecoveryFile(LocalBufferFile srcBf, File rfile) throws IOException {
|
||||
recoveryFile = new LocalBufferFile(rfile, true);
|
||||
readOnly = true;
|
||||
parseFile();
|
||||
valid = (recoveryFile.getParameter(IS_VALID_PARM) == VALID && srcFileId == srcBf.getFileId());
|
||||
valid =
|
||||
(recoveryFile.getParameter(IS_VALID_PARM) == VALID && srcFileId == srcBf.getFileId());
|
||||
}
|
||||
|
||||
|
||||
private void setModified() {
|
||||
if (valid) {
|
||||
recoveryFile.setParameter(IS_VALID_PARM, INVALID);
|
||||
@ -143,77 +145,77 @@ class RecoveryFile {
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File getFile() {
|
||||
return recoveryFile.getFile();
|
||||
}
|
||||
|
||||
|
||||
boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the version file.
|
||||
*/
|
||||
|
||||
void close() throws IOException {
|
||||
|
||||
if (recoveryFile == null)
|
||||
|
||||
if (recoveryFile == null) {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!readOnly && modified && !recoveryFile.isReadOnly()) {
|
||||
saveBufferMap();
|
||||
saveFreeIndexList();
|
||||
recoveryFile.setParameter(INDEX_COUNT_PARM, indexCnt);
|
||||
recoveryFile.setFreeIndexes(vfIndexProvider.getFreeIndexes());
|
||||
|
||||
|
||||
long t = (new Date()).getTime();
|
||||
recoveryFile.setParameter(TIMESTAMP_HI_PARM, (int)(t >>> 32));
|
||||
recoveryFile.setParameter(TIMESTAMP_LOW_PARM, (int)(t & 0xffffffffL));
|
||||
|
||||
recoveryFile.setParameter(TIMESTAMP_HI_PARM, (int) (t >>> 32));
|
||||
recoveryFile.setParameter(TIMESTAMP_LOW_PARM, (int) (t & 0xffffffffL));
|
||||
|
||||
recoveryFile.setParameter(IS_VALID_PARM, VALID); // mark as valid
|
||||
}
|
||||
recoveryFile.close();
|
||||
recoveryFile = null;
|
||||
recoveryFile = null;
|
||||
}
|
||||
|
||||
|
||||
private void parseFile() throws IOException {
|
||||
|
||||
|
||||
try {
|
||||
if (MAGIC_NUMBER != recoveryFile.getParameter(MAGIC_NUMBER_PARM)) {
|
||||
throw new IOException("Invalid recovery file");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
timestamp = ((long)recoveryFile.getParameter(TIMESTAMP_HI_PARM) << 32) |
|
||||
timestamp = ((long) recoveryFile.getParameter(TIMESTAMP_HI_PARM) << 32) |
|
||||
(recoveryFile.getParameter(TIMESTAMP_LOW_PARM) & 0xffffffffL);
|
||||
} catch (NoSuchElementException e) {
|
||||
}
|
||||
catch (NoSuchElementException e) {
|
||||
// Not as good - better than nothing
|
||||
timestamp = recoveryFile.getFile().lastModified();
|
||||
}
|
||||
|
||||
srcFileId = ((long)recoveryFile.getParameter(SRC_FILE_ID_HI_PARM) << 32) |
|
||||
|
||||
srcFileId = ((long) recoveryFile.getParameter(SRC_FILE_ID_HI_PARM) << 32) |
|
||||
(recoveryFile.getParameter(SRC_FILE_ID_LOW_PARM) & 0xffffffffL);
|
||||
|
||||
|
||||
indexCnt = recoveryFile.getParameter(INDEX_COUNT_PARM);
|
||||
|
||||
|
||||
readBufferMap();
|
||||
|
||||
|
||||
readFreeIndexList();
|
||||
|
||||
} catch (NoSuchElementException e) {
|
||||
|
||||
}
|
||||
catch (NoSuchElementException e) {
|
||||
throw new IOException("Corrupt recovery file");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void saveBufferMap() throws IOException {
|
||||
|
||||
|
||||
DataBuffer buf = new DataBuffer(recoveryFile.getBufferSize());
|
||||
|
||||
|
||||
if (mapIndex < 0) {
|
||||
mapIndex = vfIndexProvider.allocateIndex();
|
||||
buf.setId(mapIndex);
|
||||
@ -226,24 +228,24 @@ class RecoveryFile {
|
||||
|
||||
int maxOffset = (recoveryFile.getBufferSize() - 8) & ~0x07;
|
||||
int offset = FIRST_ENTRY_OFFSET;
|
||||
|
||||
|
||||
// Save new map entries
|
||||
int thisIndex = mapIndex;
|
||||
int[] realIndexes = bufferIndexMap.getKeys();
|
||||
for (int i = 0; i <= realIndexes.length; i++) {
|
||||
|
||||
|
||||
if (offset > maxOffset) {
|
||||
|
||||
|
||||
boolean newBuf = false;
|
||||
int nextIndex = buf.getInt(NEXT_BUFFER_INDEX_OFFSET);
|
||||
if (nextIndex < 0) {
|
||||
nextIndex = vfIndexProvider.allocateIndex();
|
||||
newBuf = true;
|
||||
}
|
||||
|
||||
|
||||
buf.putInt(NEXT_BUFFER_INDEX_OFFSET, nextIndex);
|
||||
recoveryFile.put(buf, thisIndex);
|
||||
|
||||
|
||||
thisIndex = nextIndex;
|
||||
if (newBuf) {
|
||||
buf.setId(thisIndex);
|
||||
@ -255,7 +257,7 @@ class RecoveryFile {
|
||||
|
||||
offset = FIRST_ENTRY_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
// Save map entry as single integer
|
||||
if (i == realIndexes.length) {
|
||||
buf.putInt(offset, -1);
|
||||
@ -264,42 +266,43 @@ class RecoveryFile {
|
||||
try {
|
||||
offset = buf.putInt(offset, realIndexes[i]);
|
||||
offset = buf.putInt(offset, bufferIndexMap.get(realIndexes[i]));
|
||||
} catch (NoValueException e) {
|
||||
}
|
||||
catch (NoValueException e) {
|
||||
throw new AssertException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make sure last buffer is saved
|
||||
recoveryFile.put(buf, thisIndex);
|
||||
}
|
||||
|
||||
|
||||
private void readBufferMap() throws NoSuchElementException, IOException {
|
||||
|
||||
mapIndex = recoveryFile.getParameter(MAP_BUFFER_INDEX_PARM);
|
||||
|
||||
|
||||
int maxOffset = (recoveryFile.getBufferSize() - 8) & ~0x07;
|
||||
|
||||
|
||||
int thisIndex = mapIndex;
|
||||
DataBuffer mapBuffer = new DataBuffer();
|
||||
recoveryFile.get(mapBuffer, thisIndex);
|
||||
if (mapBuffer.isEmpty()) {
|
||||
throw new IOException(BAD_BUFFER_MAP);
|
||||
throw new IOException(BAD_BUFFER_MAP);
|
||||
}
|
||||
|
||||
|
||||
int nextMapEntryOffset = FIRST_ENTRY_OFFSET;
|
||||
|
||||
|
||||
while (true) {
|
||||
if (nextMapEntryOffset > maxOffset) {
|
||||
// Get next map buffer
|
||||
thisIndex = mapBuffer.getInt(NEXT_BUFFER_INDEX_OFFSET);
|
||||
recoveryFile.get(mapBuffer, thisIndex);
|
||||
if (mapBuffer.isEmpty()) {
|
||||
throw new IOException(BAD_BUFFER_MAP);
|
||||
throw new IOException(BAD_BUFFER_MAP);
|
||||
}
|
||||
nextMapEntryOffset = FIRST_ENTRY_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
// Read map entry - end of list signified by -1
|
||||
int realIndex = mapBuffer.getInt(nextMapEntryOffset);
|
||||
if (realIndex < 0) {
|
||||
@ -311,9 +314,9 @@ class RecoveryFile {
|
||||
bufferIndexMap.put(realIndex, recoveryIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void saveFreeIndexList() throws IOException {
|
||||
|
||||
|
||||
DataBuffer buf = new DataBuffer(recoveryFile.getBufferSize());
|
||||
if (freeListIndex < 0) {
|
||||
freeListIndex = vfIndexProvider.allocateIndex();
|
||||
@ -328,23 +331,23 @@ class RecoveryFile {
|
||||
|
||||
int maxOffset = (recoveryFile.getBufferSize() - 4) & ~0x03;
|
||||
int offset = FIRST_ENTRY_OFFSET;
|
||||
|
||||
|
||||
// Save freeIndexes entries
|
||||
int thisIndex = freeListIndex;
|
||||
for (int i = 0; i <= freeIndexes.length; i++) {
|
||||
|
||||
if (offset > maxOffset) {
|
||||
|
||||
|
||||
boolean newBuf = false;
|
||||
int nextIndex = buf.getInt(NEXT_BUFFER_INDEX_OFFSET);
|
||||
if (nextIndex < 0) {
|
||||
nextIndex = vfIndexProvider.allocateIndex();
|
||||
newBuf = true;
|
||||
}
|
||||
|
||||
|
||||
buf.putInt(NEXT_BUFFER_INDEX_OFFSET, nextIndex);
|
||||
recoveryFile.put(buf, thisIndex);
|
||||
|
||||
|
||||
thisIndex = nextIndex;
|
||||
if (newBuf) {
|
||||
buf.setId(thisIndex);
|
||||
@ -356,45 +359,45 @@ class RecoveryFile {
|
||||
|
||||
offset = FIRST_ENTRY_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
// Save list entry as single integer
|
||||
int val = (i == freeIndexes.length ? -1 : freeIndexes[i]);
|
||||
offset = buf.putInt(offset, val);
|
||||
}
|
||||
|
||||
|
||||
// Make sure last buffer is saved
|
||||
recoveryFile.put(buf, thisIndex);
|
||||
}
|
||||
|
||||
|
||||
private void readFreeIndexList() throws NoSuchElementException, IOException {
|
||||
|
||||
freeListIndex = recoveryFile.getParameter(FREE_LIST_BUFFER_INDEX_PARM);
|
||||
|
||||
|
||||
int size = recoveryFile.getParameter(FREE_LIST_SIZE_PARM);
|
||||
freeIndexes = new int[size];
|
||||
|
||||
|
||||
int maxOffset = (recoveryFile.getBufferSize() - 4) & ~0x03;
|
||||
|
||||
|
||||
int thisIndex = freeListIndex;
|
||||
DataBuffer listBuffer = new DataBuffer();
|
||||
recoveryFile.get(listBuffer, thisIndex);
|
||||
if (listBuffer.isEmpty()) {
|
||||
throw new IOException(BAD_FREE_LIST);
|
||||
throw new IOException(BAD_FREE_LIST);
|
||||
}
|
||||
int offset = FIRST_ENTRY_OFFSET;
|
||||
int entryIx = 0;
|
||||
|
||||
|
||||
while (true) {
|
||||
if (offset > maxOffset) {
|
||||
// Get next list buffer
|
||||
thisIndex = listBuffer.getInt(NEXT_BUFFER_INDEX_OFFSET);
|
||||
recoveryFile.get(listBuffer, thisIndex);
|
||||
if (listBuffer.isEmpty()) {
|
||||
throw new IOException(BAD_FREE_LIST);
|
||||
throw new IOException(BAD_FREE_LIST);
|
||||
}
|
||||
offset = FIRST_ENTRY_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
// Read entry - end of list signified by -1
|
||||
int origIndex = listBuffer.getInt(offset);
|
||||
if (origIndex < 0) {
|
||||
@ -411,21 +414,22 @@ class RecoveryFile {
|
||||
}
|
||||
Arrays.sort(freeIndexes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current index count for the file
|
||||
* @param newIndexCnt
|
||||
* @param newIndexCount the count
|
||||
*/
|
||||
void setIndexCount(int newIndexCnt) {
|
||||
void setIndexCount(int newIndexCount) {
|
||||
setModified();
|
||||
for (int index = indexCnt; index < newIndexCnt; index++) {
|
||||
for (int index = indexCnt; index < newIndexCount; index++) {
|
||||
removeBuffer(index);
|
||||
}
|
||||
indexCnt = newIndexCnt;
|
||||
indexCnt = newIndexCount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the index count for the file
|
||||
* @return the count
|
||||
*/
|
||||
int getIndexCount() {
|
||||
return indexCnt;
|
||||
@ -433,29 +437,28 @@ class RecoveryFile {
|
||||
|
||||
/**
|
||||
* Set the free index list
|
||||
* @param freeIndexes
|
||||
* @param freeIndexes the indexes
|
||||
*/
|
||||
void setFreeIndexList(int[] freeIndexes) {
|
||||
setModified();
|
||||
this.freeIndexes = freeIndexes.clone();
|
||||
Arrays.sort(this.freeIndexes);
|
||||
for (int i = 0; i < freeIndexes.length; i++) {
|
||||
removeBuffer(freeIndexes[i]);
|
||||
for (int index : freeIndexes) {
|
||||
removeBuffer(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the list of free indexes associated with the original
|
||||
* buffer file.
|
||||
* Returns the list of free indexes associated with the original buffer file.
|
||||
* @return the indexes
|
||||
*/
|
||||
int[] getFreeIndexList() {
|
||||
return freeIndexes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store buffer which has been modified in the target.
|
||||
* Store buffer which has been modified in the target.
|
||||
* @param buf modified buffer
|
||||
* @param id buffer ID
|
||||
* @throws IOException if an IO error occurs
|
||||
*/
|
||||
void putBuffer(DataBuffer buf) throws IOException {
|
||||
@ -463,24 +466,25 @@ class RecoveryFile {
|
||||
throw new IOException("Version file is closed");
|
||||
}
|
||||
if (readOnly) {
|
||||
throw new IOException("Version file is read-only");
|
||||
throw new IOException("Version file is read-only");
|
||||
}
|
||||
setModified();
|
||||
int vfIndex;
|
||||
int id = buf.getId();
|
||||
try {
|
||||
vfIndex = bufferIndexMap.get(id);
|
||||
} catch (NoValueException e) {
|
||||
}
|
||||
catch (NoValueException e) {
|
||||
vfIndex = vfIndexProvider.allocateIndex();
|
||||
bufferIndexMap.put(id, vfIndex);
|
||||
}
|
||||
recoveryFile.put(buf, vfIndex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a buffer previously stored to the snapshot
|
||||
* by removing it from the map. It is OK to invoke
|
||||
* this method for an index whoose buffer was never
|
||||
* by removing it from the map. It is OK to invoke
|
||||
* this method for an index whose buffer was never
|
||||
* put into this file.
|
||||
* @param id buffer ID
|
||||
*/
|
||||
@ -489,12 +493,14 @@ class RecoveryFile {
|
||||
try {
|
||||
int vfIndex = bufferIndexMap.remove(id);
|
||||
vfIndexProvider.freeIndex(vfIndex);
|
||||
} catch (NoValueException e) {
|
||||
}
|
||||
catch (NoValueException e) {
|
||||
// ignore?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get modified buffer associated with the specified storage index in the
|
||||
* Get modified buffer associated with the specified storage index in the
|
||||
* original file.
|
||||
* @param buf data buffer
|
||||
* @param id buffer ID
|
||||
@ -508,16 +514,18 @@ class RecoveryFile {
|
||||
int vfIndex;
|
||||
try {
|
||||
vfIndex = bufferIndexMap.get(id);
|
||||
} catch (NoValueException e) {
|
||||
}
|
||||
catch (NoValueException e) {
|
||||
return null;
|
||||
}
|
||||
recoveryFile.get(buf, vfIndex);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns list of buffer indexes stored within this file.
|
||||
* These indexes reflect those buffers which have been modified and stored.
|
||||
* @return the indexes
|
||||
*/
|
||||
int[] getBufferIndexes() {
|
||||
return bufferIndexMap.getKeys();
|
||||
@ -525,36 +533,38 @@ class RecoveryFile {
|
||||
|
||||
/**
|
||||
* Returns file ID for original source buffer file which may be produced with this version file.
|
||||
* @return the id
|
||||
*/
|
||||
long getSourceFileID() {
|
||||
return srcFileId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of parameters defined within the original beffer file.
|
||||
* @throws IOException
|
||||
* Returns a list of parameters defined within the original buffer file.
|
||||
* @return the names
|
||||
* @throws IOException if the recovery file is null
|
||||
*/
|
||||
String[] getUserParameterNames() throws IOException {
|
||||
if (recoveryFile == null) {
|
||||
throw new IOException("Version file is closed");
|
||||
}
|
||||
String[] allNames = recoveryFile.getParameterNames();
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (int i = 0; i < allNames.length; i++) {
|
||||
if (!allNames[i].startsWith(RECOVERY_PARM_PREFIX)) {
|
||||
list.add(allNames[i]);
|
||||
}
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for (String name : allNames) {
|
||||
if (!name.startsWith(RECOVERY_PARM_PREFIX)) {
|
||||
list.add(name);
|
||||
}
|
||||
}
|
||||
String[] names = new String[list.size()];
|
||||
list.toArray(names);
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a parameter value associated with the original buffer file.
|
||||
* @param name parameter name
|
||||
* @return parameter value
|
||||
* @throws IOException
|
||||
* @throws IOException if the recovery file is null
|
||||
*/
|
||||
int getParameter(String name) throws IOException {
|
||||
if (recoveryFile == null) {
|
||||
@ -562,42 +572,42 @@ class RecoveryFile {
|
||||
}
|
||||
return recoveryFile.getParameter(name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all user parameters
|
||||
*/
|
||||
void clearParameters() {
|
||||
setModified();
|
||||
|
||||
|
||||
// Remember recovery parameters
|
||||
String[] allNames = recoveryFile.getParameterNames();
|
||||
Hashtable<String,Integer> recoveryProps = new Hashtable<String,Integer>();
|
||||
for (int i = 0; i < allNames.length; i++) {
|
||||
if (allNames[i].startsWith(RECOVERY_PARM_PREFIX)) {
|
||||
recoveryProps.put(allNames[i], new Integer(recoveryFile.getParameter(allNames[i])));
|
||||
}
|
||||
Hashtable<String, Integer> recoveryProps = new Hashtable<>();
|
||||
for (String name : allNames) {
|
||||
if (name.startsWith(RECOVERY_PARM_PREFIX)) {
|
||||
recoveryProps.put(name, recoveryFile.getParameter(name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Clear all parameters
|
||||
recoveryFile.clearParameters();
|
||||
|
||||
|
||||
// Restore recovery parameters
|
||||
Iterator<String> iter = recoveryProps.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
String name = iter.next();
|
||||
recoveryFile.setParameter(
|
||||
name, recoveryProps.get(name).intValue());
|
||||
name, recoveryProps.get(name).intValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set user parameter
|
||||
* @param name
|
||||
* @param value
|
||||
* @param name the name
|
||||
* @param value the value
|
||||
*/
|
||||
void setParameter(String name, int value) {
|
||||
setModified();
|
||||
recoveryFile.setParameter(name, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -287,8 +287,8 @@ public class VersionedDatabase extends Database {
|
||||
/**
|
||||
* Open a specific version of this database for non-update use.
|
||||
* @param version database version or LATEST_VERSION for current version
|
||||
* @param minChangeDataVer the minimum database version whoose change data
|
||||
* should be associated with the returned buffer file. A value of -1 indicates that
|
||||
* @param minChangeDataVer the minimum database version whose change data
|
||||
* should be associated with the returned buffer file. A value of -1 indicates that
|
||||
* change data is not required.
|
||||
* @return buffer file for non-update use.
|
||||
* @throws IOException
|
||||
@ -455,7 +455,7 @@ public class VersionedDatabase extends Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>VerDBBufferFileManager</code> provides buffer file management
|
||||
* <code>VerDBBufferFileManager</code> provides buffer file management
|
||||
* for this versioned database instead of the DBBufferFileManager.
|
||||
*/
|
||||
private class VerDBBufferFileManager implements BufferFileManager {
|
||||
@ -484,7 +484,7 @@ public class VersionedDatabase extends Database {
|
||||
return new File(dbDir,
|
||||
CHANGE_FILE_PREFIX + version + LocalBufferFile.BUFFER_FILE_EXTENSION);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File getChangeMapFile() {
|
||||
return null;
|
||||
|
@ -68,8 +68,8 @@ abstract class CompositeDBAdapter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an adapter for working with the composite data type database table.
|
||||
* The composite table is used to store structures and unions. The adapter is based
|
||||
* Gets an adapter for working with the composite data type database table.
|
||||
* The composite table is used to store structures and unions. The adapter is based
|
||||
* on the version of the database associated with the specified database handle and the openMode.
|
||||
* @param handle handle to the database to be accessed.
|
||||
* @param openMode the mode this adapter is to be opened for (CREATE, UPDATE, READ_ONLY, UPGRADE).
|
||||
@ -187,10 +187,10 @@ abstract class CompositeDBAdapter {
|
||||
* @param sourceArchiveID the ID for the source archive where this data type originated.
|
||||
* @param sourceDataTypeID the ID of the associated data type in the source archive.
|
||||
* @param lastChangeTime the time this data type was last changed.
|
||||
* @param packValue {@link CompositeInternal#NO_PACKING}, {@link CompositeInternal#DEFAULT_PACKING}
|
||||
* @param packValue {@link CompositeInternal#NO_PACKING}, {@link CompositeInternal#DEFAULT_PACKING}
|
||||
* or the explicit pack value currently in use by this data type (positive value).
|
||||
* @param minAlignment {@link CompositeInternal#DEFAULT_ALIGNMENT}, {@link CompositeInternal#MACHINE_ALIGNMENT}
|
||||
* or the minimum alignment value currently in use by this data type (positive value).
|
||||
* @param minAlignment {@link CompositeInternal#DEFAULT_ALIGNMENT}, {@link CompositeInternal#MACHINE_ALIGNMENT}
|
||||
* or the minimum alignment value currently in use by this data type (positive value).
|
||||
* @return the database record for this data type.
|
||||
* @throws IOException if the database can't be accessed.
|
||||
*/
|
||||
@ -216,7 +216,7 @@ abstract class CompositeDBAdapter {
|
||||
/**
|
||||
* Updates the composite data type table with the provided record.
|
||||
* @param record the new record
|
||||
* @param setLastChangeTime 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.
|
||||
*/
|
||||
@ -240,7 +240,7 @@ 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 as LongField values within Field array for the
|
||||
* @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.
|
||||
*/
|
||||
@ -256,7 +256,7 @@ abstract class CompositeDBAdapter {
|
||||
abstract Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get composite record whoose sourceID and datatypeID match the specified Universal IDs.
|
||||
* Get composite record whose 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
|
||||
|
@ -41,7 +41,7 @@ abstract class EnumDBAdapter {
|
||||
static final int ENUM_LAST_CHANGE_TIME_COL = EnumDBAdapterV1.V1_ENUM_LAST_CHANGE_TIME_COL;
|
||||
|
||||
/**
|
||||
* Gets an adapter for working with the enumeration data type database table. The adapter is based
|
||||
* Gets an adapter for working with the enumeration data type database table. The adapter is based
|
||||
* on the version of the database associated with the specified database handle and the openMode.
|
||||
* @param handle handle to the database to be accessed.
|
||||
* @param openMode the mode this adapter is to be opened for (CREATE, UPDATE, READ_ONLY, UPGRADE).
|
||||
@ -159,16 +159,17 @@ abstract class EnumDBAdapter {
|
||||
/**
|
||||
* Updates the enumeration 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.
|
||||
*/
|
||||
abstract void updateRecord(DBRecord record, boolean setLastChangeTime) throws IOException;
|
||||
|
||||
/**
|
||||
* Remove the record for the given enumeration ID, and remove all of its
|
||||
* associated value records.
|
||||
* Remove the record for the given enumeration ID, and remove all of its associated value
|
||||
* records.
|
||||
* @param enumID ID of enumerated data type to delete
|
||||
* @return true if successful
|
||||
* @throws IOException if there was a problem accessing the database
|
||||
*/
|
||||
abstract boolean removeRecord(long enumID) throws IOException;
|
||||
@ -198,7 +199,7 @@ abstract class EnumDBAdapter {
|
||||
abstract Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get enum record whoose sourceID and datatypeID match the specified Universal IDs.
|
||||
* Get enum record whose 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
|
||||
|
@ -56,7 +56,7 @@ abstract class FunctionDefinitionDBAdapter {
|
||||
static final int GENERIC_CALLING_CONVENTION_FLAG_SHIFT = 1;
|
||||
|
||||
/**
|
||||
* Gets an adapter for working with the function definition data type database table. The adapter is based
|
||||
* Gets an adapter for working with the function definition data type database table. The adapter is based
|
||||
* on the version of the database associated with the specified database handle and the openMode.
|
||||
* @param handle handle to the database to be accessed.
|
||||
* @param openMode the mode this adapter is to be opened for (CREATE, UPDATE, READ_ONLY, UPGRADE).
|
||||
@ -187,7 +187,7 @@ abstract class FunctionDefinitionDBAdapter {
|
||||
/**
|
||||
* Updates the function definition 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,7 +218,7 @@ abstract class FunctionDefinitionDBAdapter {
|
||||
abstract Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get function definition record whoose sourceID and datatypeID match the specified Universal IDs.
|
||||
* Get function definition record whose 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
|
||||
|
@ -43,7 +43,7 @@ abstract class TypedefDBAdapter {
|
||||
TypedefDBAdapterV1.V1_TYPEDEF_LAST_CHANGE_TIME_COL;
|
||||
|
||||
/**
|
||||
* Gets an adapter for working with the Typedef data type database table. The adapter is based
|
||||
* Gets an adapter for working with the Typedef data type database table. The adapter is based
|
||||
* on the version of the database associated with the specified database handle and the openMode.
|
||||
* @param handle handle to the database to be accessed.
|
||||
* @param openMode the mode this adapter is to be opened for (CREATE, UPDATE, READ_ONLY, UPGRADE).
|
||||
@ -156,7 +156,7 @@ abstract class TypedefDBAdapter {
|
||||
/**
|
||||
* Updates the type definition 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.
|
||||
*/
|
||||
@ -187,7 +187,7 @@ abstract class TypedefDBAdapter {
|
||||
abstract Field[] getRecordIdsForSourceArchive(long archiveID) throws IOException;
|
||||
|
||||
/**
|
||||
* Get typedef record whoose sourceID and datatypeID match the specified Universal IDs.
|
||||
* Get typedef record whose 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
|
||||
|
@ -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,13 @@
|
||||
*/
|
||||
package ghidra.program.database.oldfunction;
|
||||
|
||||
import db.DBHandle;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.database.util.SharedRangeMapDB;
|
||||
import ghidra.program.model.address.AddressSet;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.util.datastruct.IndexRange;
|
||||
import ghidra.util.datastruct.IndexRangeIterator;
|
||||
import db.DBHandle;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -52,7 +51,8 @@ class OldFunctionMapDB {
|
||||
|
||||
/**
|
||||
* Get the address set which makes up a function.
|
||||
* @param functionKey
|
||||
* @param functionKey the function key
|
||||
* @return the addresses
|
||||
*/
|
||||
synchronized AddressSetView getBody(long functionKey) {
|
||||
AddressSet body = new AddressSet();
|
||||
@ -81,7 +81,7 @@ class OldFunctionMapDB {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get all function keys whoose body contains the specified address.
|
||||
// * Get all function keys whose body contains the specified address.
|
||||
// * @param addr
|
||||
// * @return a LongField function key iterator.
|
||||
// */
|
||||
@ -89,9 +89,9 @@ class OldFunctionMapDB {
|
||||
// long index = addrMap.getKey(addr, false);
|
||||
// return rangeMap.getValueIterator(index, index);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Get all function keys whoose body overlaps the specified address set.
|
||||
// * Get all function keys whose body overlaps the specified address set.
|
||||
// * @param set
|
||||
// * @return a LongField function key iterator.
|
||||
// */
|
||||
|
@ -29,7 +29,7 @@ public interface CompositeInternal extends Composite {
|
||||
static final String DEFAULT_PACKING_NAME = "";
|
||||
|
||||
/**
|
||||
* The stored packing value which corresponds to a composite that will automatically pack
|
||||
* The stored packing value which corresponds to a composite that will automatically pack
|
||||
* based upon the alignment requirements of its components. A positive pack value will
|
||||
* also pack in a similar fashion but will use the pack value as a maximum alignment
|
||||
* for each component.
|
||||
@ -38,7 +38,7 @@ public interface CompositeInternal extends Composite {
|
||||
public final static int DEFAULT_PACKING = 0;
|
||||
|
||||
/**
|
||||
* The stored packing value which corresponds to a composite whoose packing has been disabled.
|
||||
* The stored packing value which corresponds to a composite whose packing has been disabled.
|
||||
* In the case of structures this will permit explicit component placement by
|
||||
* offset within the structure and undefined filler components will be used.
|
||||
* This is the initial state of all newly instantiated structures.
|
||||
@ -47,32 +47,32 @@ public interface CompositeInternal extends Composite {
|
||||
public final static int NO_PACKING = -1;
|
||||
|
||||
/**
|
||||
* The stored minimum alignment value which indicates the default alignment
|
||||
* The stored minimum alignment value which indicates the default alignment
|
||||
* should be used based upon the packing and component alignment requirements.
|
||||
* See {@link #getStoredMinimumAlignment}.
|
||||
*/
|
||||
public final static int DEFAULT_ALIGNMENT = 0;
|
||||
|
||||
/**
|
||||
* The stored minimum alignment value which indicates the machine alignment
|
||||
* should be used as the minimum alignment (as defined by the current
|
||||
* The stored minimum alignment value which indicates the machine alignment
|
||||
* should be used as the minimum alignment (as defined by the current
|
||||
* {@link DataOrganization#getMachineAlignment()}).
|
||||
* See {@link #getStoredMinimumAlignment()}.
|
||||
*/
|
||||
public final static int MACHINE_ALIGNMENT = -1;
|
||||
|
||||
/**
|
||||
* Gets the current packing value (typically a power of 2). Other special values
|
||||
* which may be returned include {@value #DEFAULT_PACKING} and {@value #NO_PACKING}.
|
||||
* Gets the current packing value (typically a power of 2). Other special values
|
||||
* which may be returned include {@value #DEFAULT_PACKING} and {@value #NO_PACKING}.
|
||||
* @return the current positive packing value, {@value #DEFAULT_PACKING} or {@value #NO_PACKING}.
|
||||
*/
|
||||
public int getStoredPackingValue();
|
||||
|
||||
/**
|
||||
* Sets the current packing behavior (positive value, usually a power of 2). If a positive
|
||||
* Sets the current packing behavior (positive value, usually a power of 2). If a positive
|
||||
* value is specified the use of packing will be enabled if it was previously disabled
|
||||
* (see {@link #setPackingEnabled(boolean)}. A positive value will set the maximum
|
||||
* alignment for this composite and each component within a structure
|
||||
* alignment for this composite and each component within a structure
|
||||
* (e.g., a value of 1 will eliminate any padding).
|
||||
* <br>
|
||||
* Special packing values which may be specified include:
|
||||
@ -87,9 +87,9 @@ public interface CompositeInternal extends Composite {
|
||||
// public void setStoredPackingValue(int packingValue);
|
||||
|
||||
/**
|
||||
* Get the minimum alignment setting for this Composite which contributes
|
||||
* Get the minimum alignment setting for this Composite which contributes
|
||||
* to the actual computed alignment value (see {@link #getAlignment()}.
|
||||
* @return the minimum alignment setting for this Composite or a reserved value to indicate
|
||||
* @return the minimum alignment setting for this Composite or a reserved value to indicate
|
||||
* either {@link #DEFAULT_ALIGNMENT} or {@link #MACHINE_ALIGNMENT}.
|
||||
*/
|
||||
public int getStoredMinimumAlignment();
|
||||
|
@ -69,14 +69,14 @@ public interface DataTypeManager {
|
||||
* Returns a unique name not currently used by any other dataType or category
|
||||
* with the same baseName
|
||||
*
|
||||
* @param path the path of the name
|
||||
* @param path the path of the name
|
||||
* @param baseName the base name to be made unique
|
||||
* @return a unique name starting with baseName
|
||||
*/
|
||||
public String getUniqueName(CategoryPath path, String baseName);
|
||||
|
||||
/**
|
||||
* Returns a dataType that is "in" (ie suitable implementation) this
|
||||
* Returns a dataType that is "in" (ie suitable implementation) this
|
||||
* Manager, creating a new one if necessary. Also the returned dataType
|
||||
* will be in a category in this dataTypeManager that is equivalent to the
|
||||
* category of the passed in dataType.
|
||||
@ -98,11 +98,11 @@ public interface DataTypeManager {
|
||||
public DataType addDataType(DataType dataType, DataTypeConflictHandler handler);
|
||||
|
||||
/**
|
||||
* Sequentially adds a collection of datatypes to this data manager.
|
||||
* Sequentially adds a collection of datatypes to this data manager.
|
||||
* This method provides the added benefit of equivalence caching
|
||||
* for improved performance.
|
||||
* <br>
|
||||
* WARNING: This is an experimental method whoose use may cause the GUI and
|
||||
* WARNING: This is an experimental method whose use may cause the GUI and
|
||||
* task monitor to become unresponsive due to extended hold times on the manager lock.
|
||||
* @param dataTypes collection of datatypes
|
||||
* @param handler conflict handler
|
||||
@ -165,7 +165,7 @@ public interface DataTypeManager {
|
||||
* @param updateCategoryPath if true, the replacementDt will have its categoryPath changed
|
||||
* to the exitingDt's path.
|
||||
* @return the resolved replacement dataType.
|
||||
* @throws DataTypeDependencyException if the replacement datatype depends on
|
||||
* @throws DataTypeDependencyException if the replacement datatype depends on
|
||||
* the existing dataType;
|
||||
*/
|
||||
public DataType replaceDataType(DataType existingDt, DataType replacementDt,
|
||||
@ -179,7 +179,7 @@ public interface DataTypeManager {
|
||||
* name of a category in the same category as the datatype. For example, if you call
|
||||
* getDataType("/a/b/c"), and "b/c" is the name of your datatype, it will find it unless
|
||||
* there is also a category "b" under category "a". A better solution is to use
|
||||
* the {@link #getDataType(DataTypePath)} method because the DataTypePath keeps the
|
||||
* the {@link #getDataType(DataTypePath)} method because the DataTypePath keeps the
|
||||
* category and datatype name separate.
|
||||
*
|
||||
* @param dataTypePath path
|
||||
@ -204,10 +204,10 @@ public interface DataTypeManager {
|
||||
public DataType getDataType(DataTypePath dataTypePath);
|
||||
|
||||
/**
|
||||
* Returns the dataTypeId for the given dataType. If the dataType is not
|
||||
* Returns the dataTypeId for the given dataType. If the dataType is not
|
||||
* currently in the dataTypeManger, it will be added
|
||||
*
|
||||
* @param dt the data type
|
||||
*
|
||||
* @param dt the data type
|
||||
* @return the ID of the resolved type
|
||||
*/
|
||||
public long getResolvedID(DataType dt);
|
||||
@ -222,15 +222,15 @@ public interface DataTypeManager {
|
||||
public long getID(DataType dt);
|
||||
|
||||
/**
|
||||
* Returns the dataType associated with the given dataTypeId or null if the dataTypeId is
|
||||
* Returns the dataType associated with the given dataTypeId or null if the dataTypeId is
|
||||
* not valid
|
||||
*
|
||||
* @param dataTypeID the ID
|
||||
* @param dataTypeID the ID
|
||||
* @return the type
|
||||
*/
|
||||
public DataType getDataType(long dataTypeID);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the Category with the given id
|
||||
*
|
||||
* @param categoryID id of the desired category
|
||||
@ -249,7 +249,7 @@ public interface DataTypeManager {
|
||||
/**
|
||||
* Notification when data type is changed.
|
||||
* @param dataType data type that is changed
|
||||
* @param isAutoChange true if change was an automatic change in response to
|
||||
* @param isAutoChange true if change was an automatic change in response to
|
||||
* another datatype's change (e.g., size, alignment).
|
||||
*/
|
||||
public void dataTypeChanged(DataType dataType, boolean isAutoChange);
|
||||
@ -291,7 +291,7 @@ public interface DataTypeManager {
|
||||
/**
|
||||
* Return true if the given dataType exists in this data type manager
|
||||
*
|
||||
* @param dataType the type
|
||||
* @param dataType the type
|
||||
* @return true if the type is in this manager
|
||||
*/
|
||||
public boolean contains(DataType dataType);
|
||||
@ -367,12 +367,12 @@ public interface DataTypeManager {
|
||||
|
||||
/**
|
||||
* Returns a pointer of the given size to the given datatype.
|
||||
* Note: It is preferred to use default sized pointers when possible (i.e., size=-1,
|
||||
* Note: It is preferred to use default sized pointers when possible (i.e., size=-1,
|
||||
* see {@link #getPointer(DataType)}) instead of explicitly specifying the size value.
|
||||
*
|
||||
* @param datatype the pointed to data type
|
||||
* @param size the size of the pointer to be created or -1 for a default sized pointer
|
||||
* @return the pointer
|
||||
* @return the pointer
|
||||
*/
|
||||
public Pointer getPointer(DataType datatype, int size);
|
||||
|
||||
@ -476,7 +476,7 @@ public interface DataTypeManager {
|
||||
public void associateDataTypeWithArchive(DataType datatype, SourceArchive archive);
|
||||
|
||||
/**
|
||||
* If the indicated data type is associated with a source archive, this will remove the
|
||||
* If the indicated data type is associated with a source archive, this will remove the
|
||||
* association and the data type will become local to this data type manager.
|
||||
* @param datatype the data type to be disassociated from a source archive.
|
||||
*/
|
||||
@ -501,8 +501,8 @@ public interface DataTypeManager {
|
||||
public boolean updateSourceArchiveName(UniversalID sourceID, String name);
|
||||
|
||||
/**
|
||||
* Get the data organization associated with this data type manager. Note that the
|
||||
* DataOrganization settings may not be changed dynamically.
|
||||
* Get the data organization associated with this data type manager. Note that the
|
||||
* DataOrganization settings may not be changed dynamically.
|
||||
* @return data organization (will never be null)
|
||||
*/
|
||||
public DataOrganization getDataOrganization();
|
||||
@ -523,14 +523,14 @@ public interface DataTypeManager {
|
||||
|
||||
/**
|
||||
* Returns or creates a persisted version of the given source archive
|
||||
* @param sourceArchive the archive
|
||||
* @param sourceArchive the archive
|
||||
* @return the archive
|
||||
*/
|
||||
public SourceArchive resolveSourceArchive(SourceArchive sourceArchive);
|
||||
|
||||
/**
|
||||
* Returns the data types within this data type manager that contain the specified data type.
|
||||
* @param dataType the data type
|
||||
* Returns the data types within this data type manager that contain the specified data type.
|
||||
* @param dataType the data type
|
||||
* @return a set of data types that contain the specified data type.
|
||||
*/
|
||||
public Set<DataType> getDataTypesContaining(DataType dataType);
|
||||
|
@ -194,7 +194,7 @@ public class VariableUtilities {
|
||||
|
||||
/**
|
||||
* Perform variable storage checks using the specified datatype.
|
||||
* @param storage variable storage whoose size must match the specified data type size
|
||||
* @param storage variable storage whose size must match the specified data type size
|
||||
* @param dataType a datatype checked using {@link #checkDataType(DataType, boolean, int, Program)}
|
||||
* @param allowSizeMismatch if true size mismatch will be ignore
|
||||
* @throws InvalidInputException
|
||||
@ -258,7 +258,7 @@ public class VariableUtilities {
|
||||
* <ul>
|
||||
* <li>Function definition datatype</li>
|
||||
* <li>An unsized/zero-element array</li>
|
||||
* </ul>
|
||||
* </ul>
|
||||
* @param dataType datatype to be checked
|
||||
* @param voidOK true if checking return datatype and void is allow, else false.
|
||||
* @param defaultSize Undefined datatype size to be used if specified datatype is null. A value less than 1
|
||||
@ -312,7 +312,7 @@ public class VariableUtilities {
|
||||
}
|
||||
|
||||
if (dataType.getLength() <= 0) {
|
||||
// Unexpected condition - only dynamic types are expected to have negative length and
|
||||
// Unexpected condition - only dynamic types are expected to have negative length and
|
||||
// none should report 0 has a length.
|
||||
throw new IllegalArgumentException("Unsupported data type length (" +
|
||||
dataType.getLength() + "): " + dataType.getName());
|
||||
@ -326,7 +326,7 @@ public class VariableUtilities {
|
||||
* <ul>
|
||||
* <li>Function definition datatype</li>
|
||||
* <li>An unsized/zero-element array</li>
|
||||
* </ul>
|
||||
* </ul>
|
||||
* @param dataType datatype to be checked
|
||||
* @param voidOK true if checking return datatype and void is allow, else false.
|
||||
* @param defaultSize Undefined datatype size to be used if specified datatype is null. A value less than 1
|
||||
@ -346,7 +346,7 @@ public class VariableUtilities {
|
||||
* <ul>
|
||||
* <li>Function definition datatype</li>
|
||||
* <li>An unsized/zero-element array</li>
|
||||
* </ul>
|
||||
* </ul>
|
||||
* @param dataType datatype to be checked. If null is specified the DEFAULT datatype will be
|
||||
* returned.
|
||||
* @param voidOK true if checking return datatype and void is allow, else false.
|
||||
@ -474,7 +474,7 @@ public class VariableUtilities {
|
||||
" bytes: " + curStorage.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vnAddr = newReg.getAddress();
|
||||
if (bigEndian) {
|
||||
vnAddr = vnAddr.add(newReg.getMinimumByteSize() - size);
|
||||
@ -746,7 +746,7 @@ public class VariableUtilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an empty placeholder class structure whose category is derived from
|
||||
* Create an empty placeholder class structure whose category is derived from
|
||||
* the function's class namespace. NOTE: The structure will not be added to the data
|
||||
* type manager.
|
||||
* @param classNamespace class namespace
|
||||
@ -768,14 +768,14 @@ public class VariableUtilities {
|
||||
|
||||
/**
|
||||
* Find the structure data type which corresponds to the specified class namespace
|
||||
* within the specified data type manager.
|
||||
* The preferred structure will utilize a namespace-based category path, however,
|
||||
* within the specified data type manager.
|
||||
* The preferred structure will utilize a namespace-based category path, however,
|
||||
* the match criteria can be fuzzy and relies primarily on the class name.
|
||||
* While a new empty structure may be returned, it will not be added to the program's data type
|
||||
* manager.
|
||||
* @param classNamespace class namespace
|
||||
* @param dataTypeManager data type manager which should be searched and whose
|
||||
* data organization should be used.
|
||||
* @param dataTypeManager data type manager which should be searched and whose
|
||||
* data organization should be used.
|
||||
* @return new or existing structure whose name matches the specified class namespace
|
||||
*/
|
||||
public static Structure findOrCreateClassStruct(GhidraClass classNamespace,
|
||||
@ -789,8 +789,8 @@ public class VariableUtilities {
|
||||
|
||||
/**
|
||||
* Find the structure data type which corresponds to the specified function's class namespace
|
||||
* within the function's program. One will be instantiated if not found.
|
||||
* The preferred structure will utilize a namespace-based category path, however,
|
||||
* within the function's program. One will be instantiated if not found.
|
||||
* The preferred structure will utilize a namespace-based category path, however,
|
||||
* the match criteria can be fuzzy and relies primarily on the class name.
|
||||
* @param function function's whose class namespace is the basis for the structure
|
||||
* @return new or existing structure whose name matches the function's class namespace or
|
||||
@ -807,8 +807,8 @@ public class VariableUtilities {
|
||||
|
||||
/**
|
||||
* Find the structure data type which corresponds to the specified class namespace
|
||||
* within the specified data type manager. .
|
||||
* The preferred structure will utilize a namespace-based category path, however,
|
||||
* within the specified data type manager. .
|
||||
* The preferred structure will utilize a namespace-based category path, however,
|
||||
* the match criteria can be fuzzy and relies primarily on the class name.
|
||||
* @param classNamespace class namespace
|
||||
* @param dataTypeManager data type manager which should be searched.
|
||||
@ -823,8 +823,8 @@ public class VariableUtilities {
|
||||
|
||||
/**
|
||||
* Find the structure data type which corresponds to the specified function's class namespace
|
||||
* within the function's program.
|
||||
* The preferred structure will utilize a namespace-based category path, however,
|
||||
* within the function's program.
|
||||
* The preferred structure will utilize a namespace-based category path, however,
|
||||
* the match criteria can be fuzzy and relies primarily on the class name.
|
||||
* @param func the function.
|
||||
* @return existing structure whose name matches the specified function's class namespace
|
||||
|
@ -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,18 +18,20 @@ package ghidra.program.model.symbol;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
||||
/**
|
||||
* <code>OffsetReference</code> is a memory reference whoose "to" address is
|
||||
* <code>OffsetReference</code> is a memory reference whose "to" address is
|
||||
* computed from a base address plus an offset.
|
||||
*/
|
||||
public interface OffsetReference extends Reference {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the offset.
|
||||
* @return the offset
|
||||
*/
|
||||
public long getOffset();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the base address.
|
||||
* @return the address
|
||||
*/
|
||||
public Address getBaseAddress();
|
||||
|
||||
|
@ -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.
|
||||
@ -17,18 +16,20 @@
|
||||
package ghidra.program.model.symbol;
|
||||
|
||||
/**
|
||||
* <code>ShiftedReference</code> is a memory reference whoose "to" address is
|
||||
* <code>ShiftedReference</code> is a memory reference whose "to" address is
|
||||
* computed from a base value left shifted by a shift amount.
|
||||
*/
|
||||
public interface ShiftedReference extends Reference {
|
||||
|
||||
/**
|
||||
* Returns the left shift amount.
|
||||
* @return the shift
|
||||
*/
|
||||
public int getShift();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the base value.
|
||||
* @return the value
|
||||
*/
|
||||
public long getValue();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user