Merge remote-tracking branch 'origin/patch'

Conflicts:
	Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/cli/blobs/CliAbstractSig.java
	Ghidra/Framework/DB/src/main/java/db/DBHandle.java
This commit is contained in:
ghidra1 2020-12-09 15:05:16 -05:00
commit 066a7d0305
32 changed files with 920 additions and 129 deletions

View file

@ -54,6 +54,7 @@ public class DBHandle {
/**
* Construct a temporary database handle.
* The saveAs method must be used to save the database.
* @throws IOException if a IO error occurs
*/
public DBHandle() throws IOException {
this(BufferMgr.DEFAULT_BUFFER_SIZE, BufferMgr.DEFAULT_CACHE_SIZE);
@ -62,18 +63,23 @@ public class DBHandle {
/**
* Construct a temporary database handle.
* The saveAs method must be used to save the database.
* @param requestedBufferSize requested buffer size. Actual buffer size may vary.
* @throws IOException if a IO error occurs
*/
public DBHandle(int requestBufferSize) throws IOException {
this(requestBufferSize, BufferMgr.DEFAULT_CACHE_SIZE);
public DBHandle(int requestedBufferSize) throws IOException {
this(requestedBufferSize, BufferMgr.DEFAULT_CACHE_SIZE);
}
/**
* Construct a temporary database handle.
* The saveAs method must be used to save the database.
* @param requestedBufferSize requested buffer size. Actual buffer size may vary.
* @param approxCacheSize approximate size of cache in Bytes.
* @throws IOException if a IO error occurs
*/
public DBHandle(int requestBufferSize, long approxCacheSize) throws IOException {
public DBHandle(int requestedBufferSize, long approxCacheSize) throws IOException {
bufferMgr =
new BufferMgr(requestBufferSize, approxCacheSize, BufferMgr.DEFAULT_CHECKPOINT_COUNT);
new BufferMgr(requestedBufferSize, approxCacheSize, BufferMgr.DEFAULT_CHECKPOINT_COUNT);
dbParms = new DBParms(bufferMgr, true);
dbParms.set(DBParms.MASTER_TABLE_ROOT_BUFFER_ID_PARM, -1);
masterTable = new MasterTable(this);
@ -108,7 +114,7 @@ public class DBHandle {
* @param recover if true an attempt will be made to recover unsaved data if the file is open for update
* @param monitor recovery monitor
* @throws IOException if IO error occurs
* @throws CancelledException
* @throws CancelledException if buffer file recovery is cancelled
*/
public DBHandle(BufferFile bufferFile, boolean recover, TaskMonitor monitor)
throws IOException, CancelledException {
@ -137,7 +143,7 @@ public class DBHandle {
* for non-update use. This method is provided primarily
* for testing.
* @param file buffer file
* @throws IOException
* @throws IOException if IO error occurs
*/
public DBHandle(File file) throws IOException {
BufferFile bfile = new LocalBufferFile(file, true);
@ -159,8 +165,9 @@ public class DBHandle {
/**
* Check the consistency of this database.
* @param monitor task monitor
* @return true if consistency check passed, else false
* @throws CancelledException
* @throws CancelledException if consistency check is cancelled
*/
public boolean isConsistent(TaskMonitor monitor) throws CancelledException {
int consistentCount = 0;
@ -182,8 +189,9 @@ public class DBHandle {
* Rebuild database tables to resolve certain consistency problems. Use of this
* method does not recover lost data which may have occurred during original
* database corruption.
* @param monitor task monitor
* @return true if rebuild succeeded, else false
* @throws CancelledException
* @throws CancelledException if rebuild is cancelled
*/
public boolean rebuild(TaskMonitor monitor) throws CancelledException {
for (Table table : getTables()) {
@ -205,8 +213,8 @@ public class DBHandle {
* WARNING! Use with extreme caution since this modifies
* the original file and could destroy data if used
* improperly.
* @param file
* @throws IOException
* @param file database buffer file to be updated
* @throws IOException if IO error occurs
*/
public static void resetDatabaseId(File file) throws IOException {
long databaseId = UniversalIdGenerator.nextID().getValue();
@ -226,7 +234,7 @@ public class DBHandle {
/**
* Read current databaseId
* @throws IOException
* @throws IOException if IO error occurs
*/
private void readDatabaseId() throws IOException {
try {
@ -239,7 +247,7 @@ public class DBHandle {
}
/**
* Returns unique database ID or 0 if this is an older read-only database.
* @return unique database ID or 0 if this is an older read-only database.
*/
public long getDatabaseId() {
return databaseId;
@ -249,7 +257,8 @@ public class DBHandle {
* Returns the recovery changeSet data file for reading or null if one is not available.
* The caller must dispose of the returned file before peforming generating any new
* recovery snapshots.
* @throws IOException
* @return recovery changeSet data file for reading or null if one is not available.
* @throws IOException if IO error occurs
*/
public LocalBufferFile getRecoveryChangeSetFile() throws IOException {
return bufferMgr.getRecoveryChangeSetFile();
@ -262,7 +271,7 @@ public class DBHandle {
* @param monitor task monitor
* @return true if snapshot successful or not needed, false if an active transaction prevented snapshot
* @throws CancelledException if cancelled by monitor
* @throws IOException
* @throws IOException if IO error occurs
*/
public boolean takeRecoverySnapshot(DBChangeSet changeSet, TaskMonitor monitor)
throws CancelledException, IOException {
@ -292,7 +301,8 @@ public class DBHandle {
* Returns a shared temporary database handle.
* This temporary handle will remain open unitl either this
* handle is closed or closeScratchPad is invoked.
* @throws IOException
* @return shared temporary database handle.
* @throws IOException if IO error occurs
*/
public DBHandle getScratchPad() throws IOException {
if (scratchPad == null) {
@ -314,7 +324,7 @@ public class DBHandle {
/**
* Add Database listener
* @param listener
* @param listener database listener
*/
public void addListener(DBListener listener) {
listenerList.add(listener);
@ -388,7 +398,7 @@ public class DBHandle {
}
/**
* Returns true if transaction is currently active
* @return true if transaction is currently active
*/
public boolean isTransactionActive() {
return txStarted;
@ -414,7 +424,7 @@ public class DBHandle {
* @param commit if true a new checkpoint will be established, if
* false all changes since the previous checkpoint will be discarded.
* @return true if new checkpoint established.
* @throws IOException
* @throws IOException if IO error occurs
*/
public synchronized boolean endTransaction(long id, boolean commit) throws IOException {
if (id != lastTransactionID) {
@ -467,7 +477,7 @@ public class DBHandle {
* All upper-levels must clear table-based cached data prior to
* invoking this method.
* @return true if an undo was successful
* @throws IOException
* @throws IOException if IO error occurs
*/
public synchronized boolean undo() throws IOException {
if (canUndo() && bufferMgr.undo(true)) {
@ -479,14 +489,14 @@ public class DBHandle {
}
/**
* Returns number of undo-able transactions
* @return number of undo-able transactions
*/
public int getAvailableUndoCount() {
return bufferMgr != null ? bufferMgr.getAvailableUndoCount() : 0;
}
/**
* Returns the number of redo-able transactions
* @return the number of redo-able transactions
*/
public int getAvailableRedoCount() {
return bufferMgr != null ? bufferMgr.getAvailableRedoCount() : 0;
@ -506,7 +516,7 @@ public class DBHandle {
* All upper-levels must clear table-based cached data prior to
* invoking this method.
* @return boolean
* @throws IOException
* @throws IOException if IO error occurs
*/
public synchronized boolean redo() throws IOException {
if (canRedo() && bufferMgr.redo()) {
@ -565,7 +575,8 @@ public class DBHandle {
/**
* Close the database and dispose of the underlying buffer manager.
* @param keepRecoveryData
* @param keepRecoveryData true if existing recovery data should be retained or false to remove
* any recovery data
*/
public synchronized void close(boolean keepRecoveryData) {
closeScratchPad();
@ -577,14 +588,14 @@ public class DBHandle {
}
/**
* Returns true if unsaved changes have been made.
* @return true if unsaved changes have been made.
*/
public synchronized boolean isChanged() {
return bufferMgr != null && bufferMgr.isChanged();
}
/**
* Returns true if this database handle has been closed.
* @return true if this database handle has been closed.
*/
public boolean isClosed() {
return bufferMgr == null;
@ -628,7 +639,6 @@ public class DBHandle {
* will be written and set as read-only. The caller is responsbile for disposing the outFile if
* this parameter is false.
* @param monitor progress monitor
* @param associateWithNewFile if true this handle will be associated with the new file
* @throws IOException if IO error occurs
* @throws CancelledException if monitor cancels operation
*/
@ -860,6 +870,8 @@ public class DBHandle {
/**
* Returns the Table that was created with the given name or null if
* no such table exists.
* @param name of requested table
* @return table instance or null if not found
*/
public Table getTable(String name) {
return tables.get(name);
@ -896,7 +908,7 @@ public class DBHandle {
* Create secondary indexes as specified by the array of column indexes.
* @param name table name
* @param schema table schema
* @param indexedColumns index table columns or null
* @param indexedColumns array of column indices which should have an index associated with them
* @return new table instance
* @throws IOException if IO error occurs during table creation
*/
@ -996,6 +1008,7 @@ public class DBHandle {
* buffer size. This value may be used to instatiate a
* new BufferFile which is compatible with this database
* when using the saveAs method.
* @return buffer size utilized by this database
*/
public int getBufferSize() {
return bufferMgr.getBufferSize();