Improved DB error handling to better react to future DB schema revisions

This commit is contained in:
ghidra1 2019-11-26 12:30:39 -05:00
parent 4fc507f711
commit ea5b523f82
19 changed files with 191 additions and 330 deletions

View file

@ -22,6 +22,7 @@
package ghidra.app.plugin.core.misc; package ghidra.app.plugin.core.misc;
import java.awt.Color; import java.awt.Color;
import java.io.IOException;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
@ -43,8 +44,7 @@ import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.ProgramChangeSet; import ghidra.program.model.listing.ProgramChangeSet;
import ghidra.util.HelpLocation; import ghidra.util.*;
import ghidra.util.SystemUtilities;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
import ghidra.util.task.*; import ghidra.util.task.*;
import ghidra.util.worker.Job; import ghidra.util.worker.Job;
@ -439,6 +439,10 @@ public class MyProgramChangesDisplayPlugin extends ProgramPlugin implements Doma
try { try {
changes = (ProgramChangeSet) domainFile.getChangesByOthersSinceCheckout(); changes = (ProgramChangeSet) domainFile.getChangesByOthersSinceCheckout();
} }
catch (IOException e) {
Msg.warn(this, "Unable to determine program change set: " + e.getMessage());
return;
}
catch (Exception e) { catch (Exception e) {
ClientUtil.handleException(tool.getProject().getRepository(), e, "Get Change Set", ClientUtil.handleException(tool.getProject().getRepository(), e, "Get Change Set",
false, tool.getToolFrame()); false, tool.getToolFrame());

View file

@ -807,7 +807,7 @@ public class DBHandle {
* Load existing tables from database. * Load existing tables from database.
* @throws IOException thrown if IO error occurs. * @throws IOException thrown if IO error occurs.
*/ */
private void loadTables() { private void loadTables() throws IOException {
tables = new Hashtable<>(); tables = new Hashtable<>();
TableRecord[] tableRecords = masterTable.getTableRecords(); TableRecord[] tableRecords = masterTable.getTableRecords();

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +15,6 @@
*/ */
package db; package db;
import ghidra.util.exception.AssertException;
import java.io.IOException; import java.io.IOException;
/** /**
@ -308,10 +305,11 @@ public abstract class Field implements Comparable<Field> {
/** /**
* Get the field associated with the specified type value. * Get the field associated with the specified type value.
* @param fieldType * @param fieldType encoded Field type
* @return Field * @return Field
* @throws UnsupportedFieldException if unsupported fieldType specified
*/ */
static Field getField(byte fieldType) { static Field getField(byte fieldType) throws UnsupportedFieldException {
if ((fieldType & INDEX_TYPE_FLAG) == 0) { if ((fieldType & INDEX_TYPE_FLAG) == 0) {
switch (fieldType & BASE_TYPE_MASK) { switch (fieldType & BASE_TYPE_MASK) {
case LONG_TYPE: case LONG_TYPE:
@ -333,7 +331,13 @@ public abstract class Field implements Comparable<Field> {
else { else {
return IndexField.getIndexField(fieldType); return IndexField.getIndexField(fieldType);
} }
throw new AssertException(); throw new UnsupportedFieldException(fieldType);
}
public static class UnsupportedFieldException extends IOException {
UnsupportedFieldException(byte fieldType) {
super("Unsupported DB field type: 0x" + Integer.toHexString(fieldType & 0xff));
}
} }
} }

View file

@ -31,10 +31,9 @@ public class FieldIndexTable extends IndexTable {
/** /**
* Construct a new secondary index which is based upon a specific field within the * Construct a new secondary index which is based upon a specific field within the
* primary table specified by name. * primary table specified by name.
* @param db database handle
* @param primaryTable primary table. * @param primaryTable primary table.
* @param colIndex identifies the indexed column within the primary table. * @param colIndex identifies the indexed column within the primary table.
* @throws IOException * @throws IOException thrown if an IO error occurs
*/ */
FieldIndexTable(Table primaryTable, int colIndex) throws IOException { FieldIndexTable(Table primaryTable, int colIndex) throws IOException {
this(primaryTable, primaryTable.getDBHandle().getMasterTable().createTableRecord( this(primaryTable, primaryTable.getDBHandle().getMasterTable().createTableRecord(
@ -44,11 +43,11 @@ public class FieldIndexTable extends IndexTable {
/** /**
* Construct a new or existing secondary index. An existing index must have * Construct a new or existing secondary index. An existing index must have
* its' root ID specified within the tableRecord. * its' root ID specified within the tableRecord.
* @param db database handle * @param primaryTable primary table.
* @param bufferMgr database buffer manager
* @param indexTableRecord specifies the index parameters. * @param indexTableRecord specifies the index parameters.
* @throws IOException thrown if an IO error occurs
*/ */
FieldIndexTable(Table primaryTable, TableRecord indexTableRecord) { FieldIndexTable(Table primaryTable, TableRecord indexTableRecord) throws IOException {
super(primaryTable, indexTableRecord); super(primaryTable, indexTableRecord);
this.indexSchema = indexTable.getSchema(); this.indexSchema = indexTable.getSchema();
this.indexColumn = indexTableRecord.getIndexedColumn(); this.indexColumn = indexTableRecord.getIndexedColumn();

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,48 +27,45 @@ import java.util.NoSuchElementException;
*/ */
class FixedIndexTable extends IndexTable { class FixedIndexTable extends IndexTable {
private static final Class<?>[] fieldClasses = { private static final Class<?>[] fieldClasses = { BinaryField.class, // index data
BinaryField.class, // index data
}; };
private static final String[] fieldNames = { private static final String[] fieldNames = { "IndexBuffer" };
"IndexBuffer"
};
private static Schema indexSchema = new Schema(0, "IndexKey", fieldClasses, fieldNames); private static Schema indexSchema = new Schema(0, "IndexKey", fieldClasses, fieldNames);
/** /**
* Construct a new secondary index which is based upon a field within the * Construct a new secondary index which is based upon a field within the
* primary table specified by name. * primary table specified by name.
* @param db database handle
* @param primaryTable primary table. * @param primaryTable primary table.
* @param colIndex identifies the indexed column within the primary table. * @param colIndex identifies the indexed column within the primary table.
* @throws IOException * @throws IOException thrown if an IO error occurs
*/ */
FixedIndexTable(Table primaryTable, int colIndex) throws IOException { FixedIndexTable(Table primaryTable, int colIndex) throws IOException {
this(primaryTable, this(primaryTable, primaryTable.getDBHandle().getMasterTable().createTableRecord(
primaryTable.getDBHandle().getMasterTable().createTableRecord(primaryTable.getName(), indexSchema, colIndex)); primaryTable.getName(), indexSchema, colIndex));
} }
/** /**
* Construct a new or existing secondary index. An existing index must have * Construct a new or existing secondary index. An existing index must have
* its' root ID specified within the tableRecord. * its' root ID specified within the tableRecord.
* @param db database handle * @param primaryTable primary table.
* @param bufferMgr database buffer manager
* @param indexTableRecord specifies the index parameters. * @param indexTableRecord specifies the index parameters.
* @throws IOException thrown if an IO error occurs
*/ */
FixedIndexTable(Table primaryTable, TableRecord indexTableRecord) { FixedIndexTable(Table primaryTable, TableRecord indexTableRecord) throws IOException {
super(primaryTable, indexTableRecord); super(primaryTable, indexTableRecord);
} }
/** /**
* Find all primary keys which correspond to the specified indexed field * Find all primary keys which correspond to the specified indexed field
* value. * value.
* @param field the field value to search for. * @param indexValue the field value to search for.
* @return list of primary keys * @return list of primary keys
* @throws IOException thrown if an IO error occurs
*/ */
@Override @Override
long[] findPrimaryKeys(Field indexValue) throws IOException { long[] findPrimaryKeys(Field indexValue) throws IOException {
if (!indexValue.getClass().equals(fieldType.getClass())) if (!indexValue.getClass().equals(fieldType.getClass()))
throw new IllegalArgumentException("Incorrect indexed field type"); throw new IllegalArgumentException("Incorrect indexed field type");
Record indexRecord = indexTable.getRecord(indexValue.getLongValue()); Record indexRecord = indexTable.getRecord(indexValue.getLongValue());
@ -82,11 +78,11 @@ class FixedIndexTable extends IndexTable {
/** /**
* Get the number of primary keys which correspond to the specified indexed field * Get the number of primary keys which correspond to the specified indexed field
* value. * value.
* @param field the field value to search for. * @param indexValue the field value to search for.
* @return key count * @return key count
*/ */
@Override @Override
int getKeyCount(Field indexValue) throws IOException { int getKeyCount(Field indexValue) throws IOException {
if (!indexValue.getClass().equals(fieldType.getClass())) if (!indexValue.getClass().equals(fieldType.getClass()))
throw new IllegalArgumentException("Incorrect indexed field type"); throw new IllegalArgumentException("Incorrect indexed field type");
Record indexRecord = indexTable.getRecord(indexValue.getLongValue()); Record indexRecord = indexTable.getRecord(indexValue.getLongValue());
@ -100,7 +96,7 @@ class FixedIndexTable extends IndexTable {
* @see ghidra.framework.store.db.IndexTable#addEntry(ghidra.framework.store.db.Record) * @see ghidra.framework.store.db.IndexTable#addEntry(ghidra.framework.store.db.Record)
*/ */
@Override @Override
void addEntry(Record record) throws IOException { void addEntry(Record record) throws IOException {
Field indexField = record.getField(colIndex); Field indexField = record.getField(colIndex);
long secondaryKey = indexField.getLongValue(); long secondaryKey = indexField.getLongValue();
Record indexRecord = indexTable.getRecord(secondaryKey); Record indexRecord = indexTable.getRecord(secondaryKey);
@ -117,7 +113,7 @@ class FixedIndexTable extends IndexTable {
* @see ghidra.framework.store.db.IndexTable#deleteEntry(ghidra.framework.store.db.Record) * @see ghidra.framework.store.db.IndexTable#deleteEntry(ghidra.framework.store.db.Record)
*/ */
@Override @Override
void deleteEntry(Record record) throws IOException { void deleteEntry(Record record) throws IOException {
Field indexField = record.getField(colIndex); Field indexField = record.getField(colIndex);
long secondaryKey = indexField.getLongValue(); long secondaryKey = indexField.getLongValue();
Record indexRecord = indexTable.getRecord(secondaryKey); Record indexRecord = indexTable.getRecord(secondaryKey);
@ -150,7 +146,7 @@ class FixedIndexTable extends IndexTable {
* @see ghidra.framework.store.db.IndexTable#indexIterator() * @see ghidra.framework.store.db.IndexTable#indexIterator()
*/ */
@Override @Override
DBFieldIterator indexIterator() throws IOException { DBFieldIterator indexIterator() throws IOException {
return new IndexLongIterator(); return new IndexLongIterator();
} }
@ -158,7 +154,8 @@ class FixedIndexTable extends IndexTable {
* @see ghidra.framework.store.db.IndexTable#indexIterator(ghidra.framework.store.db.Field, ghidra.framework.store.db.Field, boolean) * @see ghidra.framework.store.db.IndexTable#indexIterator(ghidra.framework.store.db.Field, ghidra.framework.store.db.Field, boolean)
*/ */
@Override @Override
DBFieldIterator indexIterator(Field minField, Field maxField, boolean atMin) throws IOException { DBFieldIterator indexIterator(Field minField, Field maxField, boolean atMin)
throws IOException {
long min = minField != null ? minField.getLongValue() : Long.MIN_VALUE; long min = minField != null ? minField.getLongValue() : Long.MIN_VALUE;
long max = maxField != null ? maxField.getLongValue() : Long.MAX_VALUE; long max = maxField != null ? maxField.getLongValue() : Long.MAX_VALUE;
return new IndexLongIterator(min, max, atMin); return new IndexLongIterator(min, max, atMin);
@ -168,7 +165,8 @@ class FixedIndexTable extends IndexTable {
* @see db.IndexTable#indexIterator(db.Field, db.Field, db.Field, boolean) * @see db.IndexTable#indexIterator(db.Field, db.Field, db.Field, boolean)
*/ */
@Override @Override
DBFieldIterator indexIterator(Field minField, Field maxField, Field startField, boolean before) throws IOException { DBFieldIterator indexIterator(Field minField, Field maxField, Field startField, boolean before)
throws IOException {
if (startField == null) { if (startField == null) {
throw new IllegalArgumentException("starting index value required"); throw new IllegalArgumentException("starting index value required");
} }
@ -201,7 +199,7 @@ class FixedIndexTable extends IndexTable {
* @param startValue minimum index value or null if no minimum * @param startValue minimum index value or null if no minimum
* @param endValue maximum index value or null if no maximum * @param endValue maximum index value or null if no maximum
* @param atStart if true initial position is before startValue, else position * @param atStart if true initial position is before startValue, else position
* is after endValue * is after endValue
* @throws IOException * @throws IOException
*/ */
IndexLongIterator(long minValue, long maxValue, boolean atMin) throws IOException { IndexLongIterator(long minValue, long maxValue, boolean atMin) throws IOException {
@ -223,7 +221,8 @@ class FixedIndexTable extends IndexTable {
* @param longValue * @param longValue
* @param before * @param before
*/ */
public IndexLongIterator(long minValue, long maxValue, long start, boolean before) throws IOException { public IndexLongIterator(long minValue, long maxValue, long start, boolean before)
throws IOException {
indexIterator = indexTable.longKeyIterator(minValue, maxValue, start); indexIterator = indexTable.longKeyIterator(minValue, maxValue, start);
@ -235,6 +234,7 @@ class FixedIndexTable extends IndexTable {
} }
} }
@Override
public boolean hasNext() throws IOException { public boolean hasNext() throws IOException {
if (hasNext) if (hasNext)
return true; return true;
@ -244,12 +244,14 @@ class FixedIndexTable extends IndexTable {
keyField.setLongValue(key); keyField.setLongValue(key);
hasNext = true; hasNext = true;
hasPrev = false; hasPrev = false;
} catch (NoSuchElementException e) { }
catch (NoSuchElementException e) {
return false; return false;
} }
return true; return true;
} }
@Override
public boolean hasPrevious() throws IOException { public boolean hasPrevious() throws IOException {
if (hasPrev) if (hasPrev)
return true; return true;
@ -259,12 +261,14 @@ class FixedIndexTable extends IndexTable {
keyField.setLongValue(key); keyField.setLongValue(key);
hasNext = false; hasNext = false;
hasPrev = true; hasPrev = true;
} catch (NoSuchElementException e) { }
catch (NoSuchElementException e) {
return false; return false;
} }
return true; return true;
} }
@Override
public Field next() throws IOException { public Field next() throws IOException {
if (hasNext || hasNext()) { if (hasNext || hasNext()) {
hasNext = false; hasNext = false;
@ -275,6 +279,7 @@ class FixedIndexTable extends IndexTable {
return null; return null;
} }
@Override
public Field previous() throws IOException { public Field previous() throws IOException {
if (hasPrev || hasPrevious()) { if (hasPrev || hasPrevious()) {
hasNext = true; hasNext = true;
@ -290,6 +295,7 @@ class FixedIndexTable extends IndexTable {
* index value (lastKey). * index value (lastKey).
* @see db.DBFieldIterator#delete() * @see db.DBFieldIterator#delete()
*/ */
@Override
public boolean delete() throws IOException { public boolean delete() throws IOException {
if (lastKey == null) if (lastKey == null)
return false; return false;

View file

@ -68,7 +68,7 @@ abstract class IndexTable {
* @param indexTableRecord specifies the index parameters. * @param indexTableRecord specifies the index parameters.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
IndexTable(Table primaryTable, TableRecord indexTableRecord) { IndexTable(Table primaryTable, TableRecord indexTableRecord) throws IOException {
if (!primaryTable.useLongKeys()) if (!primaryTable.useLongKeys())
throw new AssertException("Only long-key tables may be indexed"); throw new AssertException("Only long-key tables may be indexed");
this.db = primaryTable.getDBHandle(); this.db = primaryTable.getDBHandle();
@ -87,7 +87,7 @@ abstract class IndexTable {
* @return IndexTable index table * @return IndexTable index table
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
static IndexTable getIndexTable(DBHandle db, TableRecord indexTableRecord) { static IndexTable getIndexTable(DBHandle db, TableRecord indexTableRecord) throws IOException {
String name = indexTableRecord.getName(); String name = indexTableRecord.getName();
Table primaryTable = db.getTable(name); Table primaryTable = db.getTable(name);
if (primaryTable == null) if (primaryTable == null)

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,11 +15,12 @@
*/ */
package db; package db;
import ghidra.util.exception.AssertException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import db.Field.UnsupportedFieldException;
import ghidra.util.exception.AssertException;
/** /**
* Class for definining the columns in a Ghidra Database table. * Class for definining the columns in a Ghidra Database table.
*/ */
@ -93,8 +93,10 @@ public class Schema {
* @param fieldTypes * @param fieldTypes
* @param packedFieldNames packed list of field names separated by ';'. * @param packedFieldNames packed list of field names separated by ';'.
* The first field name corresponds to the key name. * The first field name corresponds to the key name.
* @throws UnsupportedFieldException if unsupported fieldType specified
*/ */
Schema(int version, byte keyFieldType, byte[] fieldTypes, String packedFieldNames) { Schema(int version, byte keyFieldType, byte[] fieldTypes, String packedFieldNames)
throws UnsupportedFieldException {
this.version = version; this.version = version;
this.keyType = Field.getField(keyFieldType); this.keyType = Field.getField(keyFieldType);
parseNames(packedFieldNames); parseNames(packedFieldNames);
@ -257,8 +259,8 @@ public class Schema {
*/ */
public Record createRecord(Field key) { public Record createRecord(Field key) {
if (!getKeyFieldClass().equals(key.getClass())) { if (!getKeyFieldClass().equals(key.getClass())) {
throw new IllegalArgumentException("expected key field type of " + throw new IllegalArgumentException(
keyType.getClass().getSimpleName()); "expected key field type of " + keyType.getClass().getSimpleName());
} }
Field[] fieldValues = new Field[fieldClasses.length]; Field[] fieldValues = new Field[fieldClasses.length];
for (int i = 0; i < fieldClasses.length; i++) { for (int i = 0; i < fieldClasses.length; i++) {

View file

@ -18,6 +18,7 @@ package db;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import db.Field.UnsupportedFieldException;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.datastruct.IntObjectHashtable; import ghidra.util.datastruct.IntObjectHashtable;
import ghidra.util.exception.*; import ghidra.util.exception.*;
@ -56,8 +57,9 @@ public class Table {
* Construct a new or existing Table. * Construct a new or existing Table.
* @param db database handle * @param db database handle
* @param tableRecord master table record for this table. * @param tableRecord master table record for this table.
* @throws UnsupportedFieldException if unsupported schema field encountered
*/ */
Table(DBHandle db, TableRecord tableRecord) { Table(DBHandle db, TableRecord tableRecord) throws UnsupportedFieldException {
this.db = db; this.db = db;
this.tableRecord = tableRecord; this.tableRecord = tableRecord;

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +15,8 @@
*/ */
package db; package db;
import db.Field.UnsupportedFieldException;
/** /**
* <code>TableRecord</code> manages information about a table. Each TableRecord * <code>TableRecord</code> manages information about a table. Each TableRecord
* corresponds to a stored record within the master table. * corresponds to a stored record within the master table.
@ -32,29 +33,19 @@ class TableRecord implements Comparable<TableRecord> {
private static final int MAX_KEY_COLUMN = 7; private static final int MAX_KEY_COLUMN = 7;
private static final int RECORD_COUNT_COLUMN = 8; private static final int RECORD_COUNT_COLUMN = 8;
private static Class<?>[] fieldClasses = { private static Class<?>[] fieldClasses = { StringField.class, // name of table
StringField.class, // name of table IntField.class, // Schema version
IntField.class, // Schema version IntField.class, // Root buffer ID (first buffer)
IntField.class, // Root buffer ID (first buffer) ByteField.class, // Key field type
ByteField.class, // Key field type BinaryField.class, // Schema field types
BinaryField.class, // Schema field types StringField.class, // Schema key/field names
StringField.class, // Schema key/field names IntField.class, // indexing column (-1 = primary)
IntField.class, // indexing column (-1 = primary) LongField.class, // max primary key value ever used
LongField.class, // max primary key value ever used IntField.class // number of records
IntField.class // number of records
}; };
private static String[] tableRecordFieldNames = { private static String[] tableRecordFieldNames = { "TableName", "SchemaVersion", "RootBufferId",
"TableName", "KeyType", "FieldTypes", "FieldNames", "IndexColumn", "MaxKey", "RecordCount" };
"SchemaVersion",
"RootBufferId",
"KeyType",
"FieldTypes",
"FieldNames",
"IndexColumn",
"MaxKey",
"RecordCount"
};
private static Schema schema = new Schema(0, "TableNum", fieldClasses, tableRecordFieldNames); private static Schema schema = new Schema(0, "TableNum", fieldClasses, tableRecordFieldNames);
@ -158,12 +149,11 @@ class TableRecord implements Comparable<TableRecord> {
/** /**
* Get the table schema * Get the table schema
* @return table schema * @return table schema
* @throws UnsupportedFieldException if unsupported schema field encountered
*/ */
Schema getSchema() { Schema getSchema() throws UnsupportedFieldException {
return new Schema(record.getIntValue(VERSION_COLUMN), return new Schema(record.getIntValue(VERSION_COLUMN), record.getByteValue(KEY_TYPE_COLUMN),
record.getByteValue(KEY_TYPE_COLUMN), record.getBinaryData(FIELD_TYPES_COLUMN), record.getString(FIELD_NAMES_COLUMN));
record.getBinaryData(FIELD_TYPES_COLUMN),
record.getString(FIELD_NAMES_COLUMN));
} }
/** /**
@ -239,6 +229,7 @@ class TableRecord implements Comparable<TableRecord> {
* key of another table record (obj). * key of another table record (obj).
* @see java.lang.Comparable#compareTo(java.lang.Object) * @see java.lang.Comparable#compareTo(java.lang.Object)
*/ */
@Override
public int compareTo(TableRecord otherRecord) { public int compareTo(TableRecord otherRecord) {
long myKey = record.getKey(); long myKey = record.getKey();
long otherKey = otherRecord.record.getKey(); long otherKey = otherRecord.record.getKey();

View file

@ -36,10 +36,9 @@ class VarIndexTable extends IndexTable {
/** /**
* Construct a new secondary index which is based upon a field within the * Construct a new secondary index which is based upon a field within the
* primary table specified by name. * primary table specified by name.
* @param db database handle
* @param primaryTable primary table. * @param primaryTable primary table.
* @param colIndex identifies the indexed column within the primary table. * @param colIndex identifies the indexed column within the primary table.
* @throws IOException * @throws IOException thrown if an IO error occurs
*/ */
VarIndexTable(Table primaryTable, int colIndex) throws IOException { VarIndexTable(Table primaryTable, int colIndex) throws IOException {
this(primaryTable, this(primaryTable,
@ -52,11 +51,11 @@ class VarIndexTable extends IndexTable {
/** /**
* Construct a new or existing secondary index. An existing index must have * Construct a new or existing secondary index. An existing index must have
* its' root ID specified within the tableRecord. * its' root ID specified within the tableRecord.
* @param db database handle * @param primaryTable primary table.
* @param bufferMgr database buffer manager
* @param indexTableRecord specifies the index parameters. * @param indexTableRecord specifies the index parameters.
* @throws IOException thrown if an IO error occurs
*/ */
VarIndexTable(Table primaryTable, TableRecord indexTableRecord) { VarIndexTable(Table primaryTable, TableRecord indexTableRecord) throws IOException {
super(primaryTable, indexTableRecord); super(primaryTable, indexTableRecord);
this.indexSchema = indexTable.getSchema(); this.indexSchema = indexTable.getSchema();
} }
@ -64,8 +63,9 @@ class VarIndexTable extends IndexTable {
/** /**
* Find all primary keys which correspond to the specified indexed field * Find all primary keys which correspond to the specified indexed field
* value. * value.
* @param field the field value to search for. * @param indexValue the field value to search for.
* @return list of primary keys * @return list of primary keys
* @throws IOException thrown if an IO error occurs
*/ */
@Override @Override
long[] findPrimaryKeys(Field indexValue) throws IOException { long[] findPrimaryKeys(Field indexValue) throws IOException {
@ -81,8 +81,9 @@ class VarIndexTable extends IndexTable {
/** /**
* Get the number of primary keys which correspond to the specified indexed field * Get the number of primary keys which correspond to the specified indexed field
* value. * value.
* @param field the field value to search for. * @param indexValue the field value to search for.
* @return key count * @return key count
* @throws IOException thrown if an IO error occurs
*/ */
@Override @Override
int getKeyCount(Field indexValue) throws IOException { int getKeyCount(Field indexValue) throws IOException {

View file

@ -47,8 +47,9 @@ class VarKeyInteriorNode extends VarKeyNode {
* Construct an existing variable-length-key interior node. * Construct an existing variable-length-key interior node.
* @param nodeMgr table node manager instance * @param nodeMgr table node manager instance
* @param buf node buffer * @param buf node buffer
* @throws IOException if IO error occurs
*/ */
VarKeyInteriorNode(NodeMgr nodeMgr, DataBuffer buf) { VarKeyInteriorNode(NodeMgr nodeMgr, DataBuffer buf) throws IOException {
super(nodeMgr, buf); super(nodeMgr, buf);
} }

View file

@ -46,8 +46,9 @@ abstract class VarKeyNode implements BTreeNode {
* Construct an existing variable-length-key node. * Construct an existing variable-length-key node.
* @param nodeMgr table node manager instance * @param nodeMgr table node manager instance
* @param buf node buffer * @param buf node buffer
* @throws IOException if IO error occurs
*/ */
VarKeyNode(NodeMgr nodeMgr, DataBuffer buf) { VarKeyNode(NodeMgr nodeMgr, DataBuffer buf) throws IOException {
this.nodeMgr = nodeMgr; this.nodeMgr = nodeMgr;
this.buffer = buf; this.buffer = buf;
keyType = Field.getField(buf.getByte(KEY_TYPE_OFFSET)); keyType = Field.getField(buf.getByte(KEY_TYPE_OFFSET));

View file

@ -55,8 +55,9 @@ class VarKeyRecordNode extends VarKeyNode {
* Construct an existing variable-length-key record leaf node. * Construct an existing variable-length-key record leaf node.
* @param nodeMgr table node manager instance * @param nodeMgr table node manager instance
* @param buf node buffer * @param buf node buffer
* @throws IOException thrown if IO error occurs
*/ */
VarKeyRecordNode(NodeMgr nodeMgr, DataBuffer buf) { VarKeyRecordNode(NodeMgr nodeMgr, DataBuffer buf) throws IOException {
super(nodeMgr, buf); super(nodeMgr, buf);
} }

View file

@ -61,8 +61,8 @@ public interface ContentHandler extends ExtensionPoint {
* @throws CancelledException if the user cancels * @throws CancelledException if the user cancels
*/ */
long createFile(FileSystem fs, FileSystem userfs, String path, String name, long createFile(FileSystem fs, FileSystem userfs, String path, String name,
DomainObject domainObject, TaskMonitor monitor) throws IOException, DomainObject domainObject, TaskMonitor monitor)
InvalidNameException, CancelledException; throws IOException, InvalidNameException, CancelledException;
/** /**
* Open a folder item for immutable use. If any changes are attempted on the * Open a folder item for immutable use. If any changes are attempted on the
@ -83,8 +83,8 @@ public interface ContentHandler extends ExtensionPoint {
* difference which could not be handled. * difference which could not be handled.
*/ */
DomainObjectAdapter getImmutableObject(FolderItem item, Object consumer, int version, DomainObjectAdapter getImmutableObject(FolderItem item, Object consumer, int version,
int minChangeVersion, TaskMonitor monitor) throws IOException, CancelledException, int minChangeVersion, TaskMonitor monitor)
VersionException; throws IOException, CancelledException, VersionException;
/** /**
* Open a folder item for read-only use. While changes are permitted on the * Open a folder item for read-only use. While changes are permitted on the
@ -104,8 +104,8 @@ public interface ContentHandler extends ExtensionPoint {
* difference which could not be handled. * difference which could not be handled.
*/ */
DomainObjectAdapter getReadOnlyObject(FolderItem item, int version, boolean okToUpgrade, DomainObjectAdapter getReadOnlyObject(FolderItem item, int version, boolean okToUpgrade,
Object consumer, TaskMonitor monitor) throws IOException, VersionException, Object consumer, TaskMonitor monitor)
CancelledException; throws IOException, VersionException, CancelledException;
/** /**
* Open a folder item for update. Changes made to the returned object may be * Open a folder item for update. Changes made to the returned object may be
@ -138,7 +138,8 @@ public interface ContentHandler extends ExtensionPoint {
* @param newerVersion the newer version number * @param newerVersion the newer version number
* @return the set of changes that were made * @return the set of changes that were made
* @throws VersionException if a database version change prevents reading of data. * @throws VersionException if a database version change prevents reading of data.
* @throws IOException if a folder item access error occurs * @throws IOException if a folder item access error occurs or change set was
* produced by newer version of software and can not be read
*/ */
ChangeSet getChangeSet(FolderItem versionedFolderItem, int olderVersion, int newerVersion) ChangeSet getChangeSet(FolderItem versionedFolderItem, int olderVersion, int newerVersion)
throws VersionException, IOException; throws VersionException, IOException;

View file

@ -23,6 +23,7 @@ import java.util.Map;
import javax.swing.Icon; import javax.swing.Icon;
import db.DBHandle; import db.DBHandle;
import db.Field;
import db.buffers.*; import db.buffers.*;
import ghidra.framework.client.ClientUtil; import ghidra.framework.client.ClientUtil;
import ghidra.framework.client.NotConnectedException; import ghidra.framework.client.NotConnectedException;
@ -1748,6 +1749,9 @@ public class GhidraFileData {
catch (FileNotFoundException e) { catch (FileNotFoundException e) {
// file has been deleted, just return an empty map. // file has been deleted, just return an empty map.
} }
catch (Field.UnsupportedFieldException e) {
// file created with newer version of Ghidra
}
catch (IOException e) { catch (IOException e) {
Msg.error(this, "Read meta-data error", e); Msg.error(this, "Read meta-data error", e);
} }

View file

@ -107,7 +107,8 @@ public interface DomainFile extends Comparable<DomainFile> {
* Returns changes made to versioned file by others since checkout was performed. * Returns changes made to versioned file by others since checkout was performed.
* @return change set or null * @return change set or null
* @throws VersionException latest version was created with a newer version of software * @throws VersionException latest version was created with a newer version of software
* @throws IOException * @throws IOException if a folder item access error occurs or change set was
* produced by newer version of software and can not be read
*/ */
public ChangeSet getChangesByOthersSinceCheckout() throws VersionException, IOException; public ChangeSet getChangesByOthersSinceCheckout() throws VersionException, IOException;
@ -352,8 +353,8 @@ public interface DomainFile extends Comparable<DomainFile> {
* @throws IOException thrown if an IO or access error occurs. * @throws IOException thrown if an IO or access error occurs.
* @throws CancelledException if task monitor cancelled operation. * @throws CancelledException if task monitor cancelled operation.
*/ */
public boolean checkout(boolean exclusive, TaskMonitor monitor) throws IOException, public boolean checkout(boolean exclusive, TaskMonitor monitor)
CancelledException; throws IOException, CancelledException;
/** /**
* Performs check in to associated repository. File must be checked-out * Performs check in to associated repository. File must be checked-out
@ -379,8 +380,8 @@ public interface DomainFile extends Comparable<DomainFile> {
* If okToUpgrade was false, check exception to see if it can be upgraded * If okToUpgrade was false, check exception to see if it can be upgraded
* @throws CancelledException if task monitor cancelled operation * @throws CancelledException if task monitor cancelled operation
*/ */
public void merge(boolean okToUpgrade, TaskMonitor monitor) throws IOException, public void merge(boolean okToUpgrade, TaskMonitor monitor)
VersionException, CancelledException; throws IOException, VersionException, CancelledException;
/** /**
* Undo "checked-out" file. The original repository file is restored. * Undo "checked-out" file. The original repository file is restored.
@ -456,8 +457,8 @@ public interface DomainFile extends Comparable<DomainFile> {
* @throws IOException thrown if an IO or access error occurs. * @throws IOException thrown if an IO or access error occurs.
* @throws CancelledException if task monitor cancelled operation. * @throws CancelledException if task monitor cancelled operation.
*/ */
DomainFile copyTo(DomainFolder newParent, TaskMonitor monitor) throws IOException, DomainFile copyTo(DomainFolder newParent, TaskMonitor monitor)
CancelledException; throws IOException, CancelledException;
/** /**
* Copy a specific version of this file to the specified destFolder. * Copy a specific version of this file to the specified destFolder.

View file

@ -74,9 +74,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
addedSourceArchiveIds = new HashSet<Long>(); addedSourceArchiveIds = new HashSet<Long>();
} }
/**
* @see ghidra.program.model.listing.DataTypeChangeSet#dataTypeChanged(long)
*/
@Override @Override
public synchronized void dataTypeChanged(long id) { public synchronized void dataTypeChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -88,9 +85,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
} }
} }
/**
* @see ghidra.program.model.listing.DataTypeChangeSet#dataTypeAdded(long)
*/
@Override @Override
public synchronized void dataTypeAdded(long id) { public synchronized void dataTypeAdded(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -99,25 +93,16 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
tmpAddedDataTypeIds.add(new Long(id)); tmpAddedDataTypeIds.add(new Long(id));
} }
/**
* @see ghidra.program.model.listing.DataTypeChangeSet#getDataTypeChanges()
*/
@Override @Override
public synchronized long[] getDataTypeChanges() { public synchronized long[] getDataTypeChanges() {
return getLongs(changedDataTypeIds); return getLongs(changedDataTypeIds);
} }
/**
* @see ghidra.program.model.listing.DataTypeChangeSet#getDataTypeAdditions()
*/
@Override @Override
public synchronized long[] getDataTypeAdditions() { public synchronized long[] getDataTypeAdditions() {
return getLongs(addedDataTypeIds); return getLongs(addedDataTypeIds);
} }
/**
* @see ghidra.program.model.listing.DataTypeChangeSet#categoryChanged(long)
*/
@Override @Override
public synchronized void categoryChanged(long id) { public synchronized void categoryChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -129,9 +114,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
} }
} }
/**
* @see ghidra.program.model.listing.DataTypeChangeSet#categoryAdded(long)
*/
@Override @Override
public synchronized void categoryAdded(long id) { public synchronized void categoryAdded(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -140,25 +122,16 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
tmpAddedCategoryIds.add(new Long(id)); tmpAddedCategoryIds.add(new Long(id));
} }
/**
* @see ghidra.program.model.listing.DataTypeChangeSet#getCategoryChanges()
*/
@Override @Override
public synchronized long[] getCategoryChanges() { public synchronized long[] getCategoryChanges() {
return getLongs(changedCategoryIds); return getLongs(changedCategoryIds);
} }
/**
* @see ghidra.program.model.listing.DataTypeChangeSet#getCategoryAdditions()
*/
@Override @Override
public synchronized long[] getCategoryAdditions() { public synchronized long[] getCategoryAdditions() {
return getLongs(addedCategoryIds); return getLongs(addedCategoryIds);
} }
/* (non-Javadoc)
* @see ghidra.program.model.listing.DataTypeChangeSet#archiveAdded(long)
*/
@Override @Override
public void sourceArchiveAdded(long id) { public void sourceArchiveAdded(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -167,9 +140,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
tmpAddedSourceArchiveIds.add(new Long(id)); tmpAddedSourceArchiveIds.add(new Long(id));
} }
/* (non-Javadoc)
* @see ghidra.program.model.listing.DataTypeChangeSet#archiveChanged(long)
*/
@Override @Override
public void sourceArchiveChanged(long id) { public void sourceArchiveChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -181,17 +151,11 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
} }
} }
/* (non-Javadoc)
* @see ghidra.program.model.listing.DataTypeChangeSet#getArchiveAdditions()
*/
@Override @Override
public long[] getSourceArchiveAdditions() { public long[] getSourceArchiveAdditions() {
return getLongs(addedSourceArchiveIds); return getLongs(addedSourceArchiveIds);
} }
/* (non-Javadoc)
* @see ghidra.program.model.listing.DataTypeChangeSet#getArchiveChanges()
*/
@Override @Override
public long[] getSourceArchiveChanges() { public long[] getSourceArchiveChanges() {
return getLongs(changedSourceArchiveIds); return getLongs(changedSourceArchiveIds);
@ -213,9 +177,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
clearUndo(); clearUndo();
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#startTransaction()
*/
@Override @Override
public synchronized void startTransaction() { public synchronized void startTransaction() {
redoList.clear(); redoList.clear();
@ -229,9 +190,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
tmpAddedSourceArchiveIds = new HashSet<Long>(); tmpAddedSourceArchiveIds = new HashSet<Long>();
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#endTransaction(boolean)
*/
@Override @Override
public synchronized void endTransaction(boolean commit) { public synchronized void endTransaction(boolean commit) {
if (!inTransaction) { if (!inTransaction) {
@ -268,9 +226,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#undo()
*/
@Override @Override
public synchronized void undo() { public synchronized void undo() {
MyChangeDiff diff = undoList.removeLast(); MyChangeDiff diff = undoList.removeLast();
@ -283,9 +238,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
redoList.addLast(diff); redoList.addLast(diff);
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#redo()
*/
@Override @Override
public synchronized void redo() { public synchronized void redo() {
MyChangeDiff diff = redoList.removeLast(); MyChangeDiff diff = redoList.removeLast();
@ -298,26 +250,17 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
undoList.addLast(diff); undoList.addLast(diff);
} }
/**
* @see ghidra.framework.model.ChangeSet#clearUndo()
*/
@Override @Override
public synchronized void clearUndo() { public synchronized void clearUndo() {
undoList.clear(); undoList.clear();
redoList.clear(); redoList.clear();
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#setMaxUndos(int)
*/
@Override @Override
public synchronized void setMaxUndos(int numUndos) { public synchronized void setMaxUndos(int numUndos) {
this.numUndos = numUndos; this.numUndos = numUndos;
} }
/**
* @see ghidra.framework.model.ChangeSet#read(ghidra.framework.store.db.DBHandle)
*/
@Override @Override
public synchronized void read(DBHandle dbh) throws IOException { public synchronized void read(DBHandle dbh) throws IOException {
@ -343,6 +286,9 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
private void readIdRecords(DBHandle dbh, String tableName, Set<Long> ids) throws IOException { private void readIdRecords(DBHandle dbh, String tableName, Set<Long> ids) throws IOException {
Table table = dbh.getTable(tableName); Table table = dbh.getTable(tableName);
if (table != null) { if (table != null) {
if (table.getSchema().getVersion() != 0) {
throw new IOException("Change data produced with newer version of Ghidra");
}
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); Record rec = it.next();
@ -351,9 +297,6 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
} }
} }
/**
* @see ghidra.framework.model.ChangeSet#write(ghidra.framework.store.db.DBHandle)
*/
@Override @Override
public synchronized void write(DBHandle dbh, boolean isRecoverySave) throws IOException { public synchronized void write(DBHandle dbh, boolean isRecoverySave) throws IOException {

View file

@ -20,8 +20,7 @@ import java.io.IOException;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import db.DBConstants; import db.*;
import db.DBHandle;
import db.buffers.BufferFile; import db.buffers.BufferFile;
import db.buffers.ManagedBufferFile; import db.buffers.ManagedBufferFile;
import ghidra.framework.data.*; import ghidra.framework.data.*;
@ -80,6 +79,9 @@ public class ProgramContentHandler extends DBContentHandler {
success = true; success = true;
return program; return program;
} }
catch (Field.UnsupportedFieldException e) {
throw new VersionException(false);
}
catch (VersionException e) { catch (VersionException e) {
throw e; throw e;
} }
@ -136,6 +138,9 @@ public class ProgramContentHandler extends DBContentHandler {
success = true; success = true;
return program; return program;
} }
catch (Field.UnsupportedFieldException e) {
throw new VersionException(false);
}
catch (VersionException e) { catch (VersionException e) {
throw e; throw e;
} }
@ -199,6 +204,9 @@ public class ProgramContentHandler extends DBContentHandler {
success = true; success = true;
return program; return program;
} }
catch (Field.UnsupportedFieldException e) {
throw new VersionException(false);
}
catch (VersionException e) { catch (VersionException e) {
throw e; throw e;
} }

View file

@ -126,9 +126,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
addedTagIds = new HashSet<Long>(); addedTagIds = new HashSet<Long>();
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getAddressSet()
*/
@Override @Override
public synchronized AddressSetView getAddressSet() { public synchronized AddressSetView getAddressSet() {
SynchronizedAddressSetCollection addressSetCollection = SynchronizedAddressSetCollection addressSetCollection =
@ -149,9 +146,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#add(ghidra.program.model.address.AddressSetView)
*/
@Override @Override
public synchronized void add(AddressSetView addrSet) { public synchronized void add(AddressSetView addrSet) {
if (!inTransaction) { if (!inTransaction) {
@ -160,9 +154,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddrs.add(addrSet); tmpAddrs.add(addrSet);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#addRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
*/
@Override @Override
public synchronized void addRange(Address addr1, Address addr2) { public synchronized void addRange(Address addr1, Address addr2) {
if (!inTransaction) { if (!inTransaction) {
@ -173,9 +164,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#addRegisterRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
*/
@Override @Override
public synchronized void addRegisterRange(Address addr1, Address addr2) { public synchronized void addRegisterRange(Address addr1, Address addr2) {
if (!inTransaction) { if (!inTransaction) {
@ -184,9 +172,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpRegAddrs.addRange(addr1, addr2); tmpRegAddrs.addRange(addr1, addr2);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getRegisterAddressSet()
*/
@Override @Override
public synchronized AddressSetView getRegisterAddressSet() { public synchronized AddressSetView getRegisterAddressSet() {
SynchronizedAddressSetCollection addressSetCollection = SynchronizedAddressSetCollection addressSetCollection =
@ -195,9 +180,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
return addressSetCollection.getCombinedAddressSet(); return addressSetCollection.getCombinedAddressSet();
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#dataTypeChanged(long)
*/
@Override @Override
public synchronized void dataTypeChanged(long id) { public synchronized void dataTypeChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -209,9 +191,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#dataTypeAdded(long)
*/
@Override @Override
public synchronized void dataTypeAdded(long id) { public synchronized void dataTypeAdded(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -220,25 +199,16 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddedDataTypeIds.add(new Long(id)); tmpAddedDataTypeIds.add(new Long(id));
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getDataTypeChanges()
*/
@Override @Override
public synchronized long[] getDataTypeChanges() { public synchronized long[] getDataTypeChanges() {
return getLongs(changedDataTypeIds); return getLongs(changedDataTypeIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getDataTypeAdditions()
*/
@Override @Override
public synchronized long[] getDataTypeAdditions() { public synchronized long[] getDataTypeAdditions() {
return getLongs(addedDataTypeIds); return getLongs(addedDataTypeIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#categoryChanged(long)
*/
@Override @Override
public synchronized void categoryChanged(long id) { public synchronized void categoryChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -250,9 +220,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#categoryAdded(long)
*/
@Override @Override
public synchronized void categoryAdded(long id) { public synchronized void categoryAdded(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -261,25 +228,16 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddedCategoryIds.add(new Long(id)); tmpAddedCategoryIds.add(new Long(id));
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getCategoryChanges()
*/
@Override @Override
public synchronized long[] getCategoryChanges() { public synchronized long[] getCategoryChanges() {
return getLongs(changedCategoryIds); return getLongs(changedCategoryIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getCategoryAdditions()
*/
@Override @Override
public synchronized long[] getCategoryAdditions() { public synchronized long[] getCategoryAdditions() {
return getLongs(addedCategoryIds); return getLongs(addedCategoryIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#programTreeChanged(long)
*/
@Override @Override
public synchronized void programTreeChanged(long id) { public synchronized void programTreeChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -291,9 +249,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#programTreeAdded(long)
*/
@Override @Override
public synchronized void programTreeAdded(long id) { public synchronized void programTreeAdded(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -302,25 +257,16 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddedProgramTreeIds.add(new Long(id)); tmpAddedProgramTreeIds.add(new Long(id));
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getProgramTreeChanges()
*/
@Override @Override
public synchronized long[] getProgramTreeChanges() { public synchronized long[] getProgramTreeChanges() {
return getLongs(changedProgramTreeIds); return getLongs(changedProgramTreeIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getProgramTreeAdditions()
*/
@Override @Override
public synchronized long[] getProgramTreeAdditions() { public synchronized long[] getProgramTreeAdditions() {
return getLongs(addedProgramTreeIds); return getLongs(addedProgramTreeIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#symbolChanged(long)
*/
@Override @Override
public synchronized void symbolChanged(long id) { public synchronized void symbolChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -332,9 +278,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#symbolAdded(long)
*/
@Override @Override
public synchronized void symbolAdded(long id) { public synchronized void symbolAdded(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -343,25 +286,16 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddedSymbolIds.add(new Long(id)); tmpAddedSymbolIds.add(new Long(id));
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getSymbolChanges()
*/
@Override @Override
public synchronized long[] getSymbolChanges() { public synchronized long[] getSymbolChanges() {
return getLongs(changedSymbolIds); return getLongs(changedSymbolIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getSymbolAdditions()
*/
@Override @Override
public synchronized long[] getSymbolAdditions() { public synchronized long[] getSymbolAdditions() {
return getLongs(addedSymbolIds); return getLongs(addedSymbolIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#tagChanged(long)
*/
@Override @Override
public synchronized void tagChanged(long id) { public synchronized void tagChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -373,9 +307,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#tagCreated(long)
*/
@Override @Override
public synchronized void tagCreated(long id) { public synchronized void tagCreated(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -384,25 +315,16 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddedTagIds.add(new Long(id)); tmpAddedTagIds.add(new Long(id));
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getTagChanges()
*/
@Override @Override
public synchronized long[] getTagChanges() { public synchronized long[] getTagChanges() {
return getLongs(changedTagIds); return getLongs(changedTagIds);
} }
/**
* @see ghidra.program.model.listing.ProgramChangeSet#getTagCreations()
*/
@Override @Override
public synchronized long[] getTagCreations() { public synchronized long[] getTagCreations() {
return getLongs(addedTagIds); return getLongs(addedTagIds);
} }
/* (non-Javadoc)
* @see ghidra.program.model.listing.DataTypeChangeSet#archiveAdded(long)
*/
@Override @Override
public void sourceArchiveAdded(long id) { public void sourceArchiveAdded(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -411,9 +333,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddedSourceArchiveIds.add(new Long(id)); tmpAddedSourceArchiveIds.add(new Long(id));
} }
/* (non-Javadoc)
* @see ghidra.program.model.listing.DataTypeChangeSet#archiveChanged(long)
*/
@Override @Override
public void sourceArchiveChanged(long id) { public void sourceArchiveChanged(long id) {
if (!inTransaction) { if (!inTransaction) {
@ -425,25 +344,16 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
} }
/* (non-Javadoc)
* @see ghidra.program.model.listing.DataTypeChangeSet#getArchiveAdditions()
*/
@Override @Override
public long[] getSourceArchiveAdditions() { public long[] getSourceArchiveAdditions() {
return getLongs(addedSourceArchiveIds); return getLongs(addedSourceArchiveIds);
} }
/* (non-Javadoc)
* @see ghidra.program.model.listing.DataTypeChangeSet#getArchiveChanges()
*/
@Override @Override
public long[] getSourceArchiveChanges() { public long[] getSourceArchiveChanges() {
return getLongs(changedSourceArchiveIds); return getLongs(changedSourceArchiveIds);
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#clear()
*/
@Override @Override
public synchronized void clearUndo(boolean isCheckedOut) { public synchronized void clearUndo(boolean isCheckedOut) {
if (inTransaction) { if (inTransaction) {
@ -470,9 +380,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
clearUndo(); clearUndo();
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#startTransaction()
*/
@Override @Override
public synchronized void startTransaction() { public synchronized void startTransaction() {
inTransaction = true; inTransaction = true;
@ -493,9 +400,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddedTagIds = new HashSet<Long>(); tmpAddedTagIds = new HashSet<Long>();
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#endTransaction(boolean)
*/
@Override @Override
public synchronized void endTransaction(boolean commit) { public synchronized void endTransaction(boolean commit) {
if (!inTransaction) { if (!inTransaction) {
@ -556,9 +460,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
tmpAddedTagIds = null; tmpAddedTagIds = null;
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#undo()
*/
@Override @Override
public synchronized void undo() { public synchronized void undo() {
ChangeDiff diff = undoList.removeLast(); ChangeDiff diff = undoList.removeLast();
@ -579,9 +480,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
redoList.addLast(diff); redoList.addLast(diff);
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#redo()
*/
@Override @Override
public synchronized void redo() { public synchronized void redo() {
ChangeDiff diff = redoList.removeLast(); ChangeDiff diff = redoList.removeLast();
@ -602,26 +500,17 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
undoList.addLast(diff); undoList.addLast(diff);
} }
/**
* @see ghidra.framework.model.ChangeSet#clearUndo()
*/
@Override @Override
public synchronized void clearUndo() { public synchronized void clearUndo() {
undoList.clear(); undoList.clear();
redoList.clear(); redoList.clear();
} }
/**
* @see ghidra.framework.data.DomainObjectDBChangeSet#setMaxUndos(int)
*/
@Override @Override
public synchronized void setMaxUndos(int numUndos) { public synchronized void setMaxUndos(int numUndos) {
this.numUndos = numUndos; this.numUndos = numUndos;
} }
/**
* @see ghidra.framework.model.ChangeSet#read(ghidra.framework.store.db.DBHandle)
*/
@Override @Override
public synchronized void read(DBHandle dbh) throws IOException { public synchronized void read(DBHandle dbh) throws IOException {
@ -648,6 +537,9 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
private void readIdRecords(DBHandle dbh, String tableName, Set<Long> ids) throws IOException { private void readIdRecords(DBHandle dbh, String tableName, Set<Long> ids) throws IOException {
Table table = dbh.getTable(tableName); Table table = dbh.getTable(tableName);
if (table != null) { if (table != null) {
if (table.getSchema().getVersion() != 0) {
throw new IOException("Change data produced with newer version of Ghidra");
}
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); Record rec = it.next();
@ -660,6 +552,9 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
throws IOException { throws IOException {
Table table = dbh.getTable(tableName); Table table = dbh.getTable(tableName);
if (table != null) { if (table != null) {
if (table.getSchema().getVersion() != 0) {
throw new IOException("Change data produced with newer version of Ghidra");
}
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); Record rec = it.next();
@ -673,9 +568,6 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
} }
/**
* @see ghidra.framework.model.ChangeSet#write(ghidra.framework.store.db.DBHandle)
*/
@Override @Override
public synchronized void write(DBHandle dbh, boolean isRecoverySave) throws IOException { public synchronized void write(DBHandle dbh, boolean isRecoverySave) throws IOException {