Skip to content

Ghidra is a software reverse engineering (SRE) framework

GT-61 - Key Bindings - fixed warnings

dragonmacher724281673932
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/test/TestProgramManager.java b/Ghidra/Features/Base/src/main/java/ghidra/test/TestProgramManager.java
index edf100700e..ae8b642f8f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/test/TestProgramManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/test/TestProgramManager.java
@@ -33,7 +33,8 @@ import ghidra.program.model.listing.Program;
import ghidra.program.util.DefaultLanguageService;
import ghidra.util.*;
import ghidra.util.exception.*;
-import ghidra.util.task.*;
+import ghidra.util.task.ConsoleTaskMonitor;
+import ghidra.util.task.TaskMonitor;
import utilities.util.FileUtilities;
/**
@@ -123,11 +124,14 @@ public class TestProgramManager {
/**
* Save a program to the cached program store. A SaveAs will be performed on the
* program to its cached storage location.
+ *
* @param progName program name
* @param program program object
* @param replace if true any existing cached database with the same name will be replaced
* @param monitor task monitor
+ * @throws IOException if the database cannot be created
* @throws DuplicateNameException if already cached
+ * @throws CancelledException if the save operation is cancelled
*/
public void saveToCache(String progName, ProgramDB program, boolean replace,
TaskMonitor monitor) throws IOException, DuplicateNameException, CancelledException {
@@ -205,7 +209,9 @@ public class TestProgramManager {
* the only reason to use this method vice openProgram().
*
* @param project the project into which the file will be restored
- * @param programName the name of the program zip file without the ".gzf" extension.
+ * @param programName the name of the program zip file without the ".gzf" extension
+ * @return the file
+ * @throws FileNotFoundException if the file cannot be found
*/
public DomainFile addProgramToProject(Project project, String programName)
throws FileNotFoundException {
@@ -221,6 +227,8 @@ public class TestProgramManager {
*
* @param folder the folder into which the domain file will be inserted
* @param programName the name of the program zip file without the ".gzf" extension.
+ * @return the file
+ * @throws FileNotFoundException if the file cannot be found
*/
public DomainFile addProgramToProject(DomainFolder folder, String programName)
throws FileNotFoundException {
@@ -234,7 +242,7 @@ public class TestProgramManager {
int oneUp = 0;
while (true) {
try {
- DomainFile df = folder.createFile(name, gzf, TaskMonitorAdapter.DUMMY_MONITOR);
+ DomainFile df = folder.createFile(name, gzf, TaskMonitor.DUMMY);
AbstractGenericTest.waitForPostedSwingRunnables();
DomainObject dobj = df.getDomainObject(this, true, false, null);
try {
@@ -281,7 +289,7 @@ public class TestProgramManager {
DBHandle dbh = null;
boolean success = false;
try {
- dbh = db.open(TaskMonitorAdapter.DUMMY_MONITOR);
+ dbh = db.open(TaskMonitor.DUMMY);
program = new ProgramDB(dbh, DBConstants.UPDATE, null, this);
success = true;
}
@@ -312,7 +320,7 @@ public class TestProgramManager {
}
Msg.info(this, message + (endTime - startTime));
- dbh = db.open(TaskMonitorAdapter.DUMMY_MONITOR);
+ dbh = db.open(TaskMonitor.DUMMY);
program = new ProgramDB(dbh, DBConstants.UPDATE, null, this);
dbh = null;
success = true;
@@ -341,7 +349,7 @@ public class TestProgramManager {
File gzf = AbstractGenericTest.findTestDataFile(programName + ".gzf");
if (gzf != null && gzf.exists()) {
Msg.info(this, "Unpacking: " + gzf);
- db = new PrivateDatabase(dbDir, gzf, TaskMonitorAdapter.DUMMY_MONITOR);
+ db = new PrivateDatabase(dbDir, gzf, TaskMonitor.DUMMY);
testPrograms.put(programName, db);
return db;
}
@@ -451,12 +459,12 @@ public class TestProgramManager {
private void upgradeDatabase(PrivateDatabase db) throws Exception {
- DBHandle dbh = db.openForUpdate(TaskMonitorAdapter.DUMMY_MONITOR);
+ DBHandle dbh = db.openForUpdate(TaskMonitor.DUMMY);
try {
ProgramDB program =
- new ProgramDB(dbh, DBConstants.UPGRADE, TaskMonitorAdapter.DUMMY_MONITOR, this);
+ new ProgramDB(dbh, DBConstants.UPGRADE, TaskMonitor.DUMMY, this);
if (dbh != null) {
- dbh.save(null, null, TaskMonitorAdapter.DUMMY_MONITOR);
+ dbh.save(null, null, TaskMonitor.DUMMY);
}
dbh = null;
program.release(this);
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/ProgramUserDataTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/ProgramUserDataTest.java
index 3a717e06f6..dc08557b6a 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/ProgramUserDataTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/ProgramUserDataTest.java
@@ -22,7 +22,7 @@ import java.util.Random;
import org.junit.*;
-import generic.test.AbstractGenericTest;
+import generic.test.AbstractGTest;
import ghidra.framework.data.ProjectFileManager;
import ghidra.framework.model.*;
import ghidra.program.model.address.Address;
@@ -35,12 +35,12 @@ import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.ProjectTestUtils;
import ghidra.util.Msg;
import ghidra.util.exception.VersionException;
-import ghidra.util.task.TaskMonitorAdapter;
+import ghidra.util.task.TaskMonitor;
import utilities.util.FileUtilities;
public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
- private String TEMP = AbstractGenericTest.getTestDirectoryPath();
+ private String TEMP = AbstractGTest.getTestDirectoryPath();
private static Random RAND = new Random();
private ProjectLocator projectLocator;
@@ -60,20 +60,22 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
userDir = new File(projectLocator.getProjectDir(), ProjectFileManager.USER_FOLDER_NAME);
ProgramBuilder builder = new ProgramBuilder("Test", ProgramBuilder._TOY);
- df = project.getProjectData().getRootFolder().createFile("test", builder.getProgram(),
- TaskMonitorAdapter.DUMMY_MONITOR);
+ df = project.getProjectData()
+ .getRootFolder()
+ .createFile("test", builder.getProgram(),
+ TaskMonitor.DUMMY);
builder.dispose();
Program program = null;
try {
program =
- (Program) df.getDomainObject(this, false, false, TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df.getDomainObject(this, false, false, TaskMonitor.DUMMY);
}
catch (VersionException e) {
assertTrue(e.isUpgradable());
program =
- (Program) df.getDomainObject(this, true, false, TaskMonitorAdapter.DUMMY_MONITOR);
- program.save("upgrade", TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df.getDomainObject(this, true, false, TaskMonitor.DUMMY);
+ program.save("upgrade", TaskMonitor.DUMMY);
}
finally {
program.release(this);
@@ -141,27 +143,27 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
DomainFile df2;
Program program =
- (Program) df.getDomainObject(this, false, false, TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df.getDomainObject(this, false, false, TaskMonitor.DUMMY);
space = program.getAddressFactory().getDefaultAddressSpace();
try {
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
assertTrue(program.canSave());
// Modify program content - no user data should be saved
change(program);
assertTrue(program.isChanged());
- program.save("save", TaskMonitorAdapter.DUMMY_MONITOR);
- assertTrue(!program.isChanged());
+ program.save("save", TaskMonitor.DUMMY);
+ assertFalse(program.isChanged());
assertFalse("User data directory should be empty", userDataSubDir.isDirectory());
// Modify user data content
ProgramUserData userData = program.getProgramUserData();
change(userData, "STRING", space.getAddress(0), "Str0");
change(userData, "STRING", space.getAddress(10), "Str10");
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
String newName = df.getName() + ".1";
- df2 = df.getParent().createFile(newName, program, TaskMonitorAdapter.DUMMY_MONITOR);
+ df2 = df.getParent().createFile(newName, program, TaskMonitor.DUMMY);
}
finally {
@@ -169,9 +171,9 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
}
program =
- (Program) df2.getDomainObject(this, false, false, TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df2.getDomainObject(this, false, false, TaskMonitor.DUMMY);
try {
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
// Verify user data content
ProgramUserData userData = program.getProgramUserData();
@@ -180,7 +182,7 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals("Str0", map.getString(space.getAddress(0)));
assertEquals("Str10", map.getString(space.getAddress(10)));
assertNull(map.getString(space.getAddress(20)));
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
}
finally {
program.release(this);
@@ -203,17 +205,17 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
int ver;
Program program =
- (Program) df.getDomainObject(this, false, false, TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df.getDomainObject(this, false, false, TaskMonitor.DUMMY);
space = program.getAddressFactory().getDefaultAddressSpace();
try {
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
assertTrue(program.canSave());
// Modify program content - no user data should be saved
change(program);
assertTrue(program.isChanged());
- program.save("save", TaskMonitorAdapter.DUMMY_MONITOR);
- assertTrue(!program.isChanged());
+ program.save("save", TaskMonitor.DUMMY);
+ assertFalse(program.isChanged());
assertFalse("User data directory should be empty", userDataSubDir.isDirectory());
ver = getLatestDbVersion(dbDir);
@@ -222,7 +224,7 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
ProgramUserData userData = program.getProgramUserData();
change(userData, "STRING", space.getAddress(0), "Str0");
change(userData, "STRING", space.getAddress(10), "Str10");
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
}
finally {
@@ -234,9 +236,9 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
getLatestDbVersion(dbDir));
program =
- (Program) df.getDomainObject(this, false, false, TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df.getDomainObject(this, false, false, TaskMonitor.DUMMY);
try {
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
// Verify user data content
ProgramUserData userData = program.getProgramUserData();
@@ -245,21 +247,21 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals("Str0", map.getString(space.getAddress(0)));
assertEquals("Str10", map.getString(space.getAddress(10)));
assertNull(map.getString(space.getAddress(20)));
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
// Modify user data content
change(userData, "STRING", space.getAddress(10), "Str10a");
change(userData, "STRING", space.getAddress(20), "Str20a");
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
}
finally {
program.release(this);
}
program =
- (Program) df.getDomainObject(this, false, false, TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df.getDomainObject(this, false, false, TaskMonitor.DUMMY);
try {
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
// Verify user data content
ProgramUserData userData = program.getProgramUserData();
@@ -268,7 +270,7 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals("Str0", map.getString(space.getAddress(0)));
assertEquals("Str10a", map.getString(space.getAddress(10)));
assertEquals("Str20a", map.getString(space.getAddress(20)));
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
}
finally {
program.release(this);
@@ -287,7 +289,7 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
// TODO: Multi-user repository connect case not tested
Program program =
- (Program) df.getDomainObject(this, false, false, TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df.getDomainObject(this, false, false, TaskMonitor.DUMMY);
space = program.getAddressFactory().getDefaultAddressSpace();
try {
// Create user data content
@@ -307,9 +309,9 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
df = project.getProjectData().getFile("/test");
program =
- (Program) df.getDomainObject(this, false, false, TaskMonitorAdapter.DUMMY_MONITOR);
+ (Program) df.getDomainObject(this, false, false, TaskMonitor.DUMMY);
try {
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
// Verify user data content
ProgramUserData userData = program.getProgramUserData();
@@ -318,7 +320,7 @@ public class ProgramUserDataTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals("Str0", map.getString(space.getAddress(0)));
assertEquals("Str10", map.getString(space.getAddress(10)));
assertNull(map.getString(space.getAddress(20)));
- assertTrue(!program.isChanged());
+ assertFalse(program.isChanged());
}
finally {
program.release(this);
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramDB.java
index fece367ff5..b9f75b8e03 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramDB.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramDB.java
@@ -57,7 +57,6 @@ import ghidra.program.util.*;
import ghidra.util.*;
import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor;
-import ghidra.util.task.TaskMonitorAdapter;
/**
* Database implementation for Program.
@@ -199,10 +198,8 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
private OverlaySpaceAdapterDB overlaySpaceAdapter;
- private HashMap<String, AddressSetPropertyMapDB> addrSetPropertyMap = new HashMap<>();
- private HashMap<String, IntRangeMapDB> intRangePropertyMap = new HashMap<>();
-
- private HashSet<Long> changedFunctionIDs = new HashSet<>();
+ private Map<String, AddressSetPropertyMapDB> addrSetPropertyMap = new HashMap<>();
+ private Map<String, IntRangeMapDB> intRangePropertyMap = new HashMap<>();
/**
* Constructs a new ProgramDB
@@ -232,12 +229,12 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
int id = startTransaction("create program");
createDatabase();
- if (createManagers(CREATE, TaskMonitorAdapter.DUMMY_MONITOR) != null) {
+ if (createManagers(CREATE, TaskMonitor.DUMMY) != null) {
throw new AssertException("Unexpected version exception on create");
}
listing = new ListingDB();
changeSet = new ProgramDBChangeSet(addrMap, NUM_UNDOS);
- initManagers(CREATE, TaskMonitorAdapter.DUMMY_MONITOR);
+ initManagers(CREATE, TaskMonitor.DUMMY);
propertiesCreate();
programUserData = new ProgramUserDataDB(this);
endTransaction(id, true);
@@ -273,7 +270,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
* @throws IOException if an error accessing the database occurs.
* @throws VersionException if database version does not match implementation, UPGRADE may be possible.
* @throws CancelledException if instantiation is canceled by monitor
- * @throws LanguageNotFoundException
+ * @throws LanguageNotFoundException if a language cannot be found for this program
*/
public ProgramDB(DBHandle dbh, int openMode, TaskMonitor monitor, Object consumer)
throws IOException, VersionException, LanguageNotFoundException, CancelledException {
@@ -281,7 +278,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
super(dbh, "Untitled", 500, 1000, consumer);
if (monitor == null) {
- monitor = TaskMonitorAdapter.DUMMY;
+ monitor = TaskMonitor.DUMMY;
}
boolean success = false;
@@ -369,7 +366,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
/**
* Initialize program compiler specification.
* During a language upgrade this will provide a temporary spec until setLanguage is complete.
- * @throws CompilerSpecNotFoundException
+ * @throws CompilerSpecNotFoundException if the compiler spec cannot be found
*/
private void initCompilerSpec() throws CompilerSpecNotFoundException {
try {
@@ -399,8 +396,8 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
* @param openMode one of:
* READ_ONLY: the original database will not be modified
* UPDATE: the database can be written to.
- * UPGRADE: the database is upgraded to the lastest schema as it is opened.
- * @throws LanguageNotFoundException
+ * UPGRADE: the database is upgraded to the latest schema as it is opened.
+ * @throws LanguageNotFoundException if a language cannot be found for this program
* @return VersionException if language upgrade required
*/
private VersionException checkLanguageVersion(int openMode) throws LanguageNotFoundException {
@@ -409,8 +406,9 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
Language newLanguage = language;
- Language oldLanguage = OldLanguageFactory.getOldLanguageFactory().getOldLanguage(
- languageID, languageVersion);
+ Language oldLanguage = OldLanguageFactory.getOldLanguageFactory()
+ .getOldLanguage(
+ languageID, languageVersion);
if (oldLanguage == null) {
// Assume minor version behavior - old language does not exist for current major version
Msg.error(this, "Old language specification not found: " + languageID +
@@ -420,8 +418,9 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
// Ensure that we can upgrade the language
languageUpgradeTranslator =
- LanguageTranslatorFactory.getLanguageTranslatorFactory().getLanguageTranslator(
- oldLanguage, newLanguage);
+ LanguageTranslatorFactory.getLanguageTranslatorFactory()
+ .getLanguageTranslator(
+ oldLanguage, newLanguage);
if (languageUpgradeTranslator == null) {
// TODO: This is a bad situation!! Most language revisions should be supportable, if not we have no choice but to throw
@@ -451,12 +450,12 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
/**
* Language specified by languageName was not found. Check for
- * valid language translation/migration. Old langauge version specified by
+ * valid language translation/migration. Old language version specified by
* languageVersion.
* @param openMode one of:
* READ_ONLY: the original database will not be modified
* UPDATE: the database can be written to.
- * UPGRADE: the database is upgraded to the lastest schema as it is opened.
+ * UPGRADE: the database is upgraded to the latest schema as it is opened.
* @return true if language upgrade required
* @throws LanguageNotFoundException if a suitable replacement language not found
*/
@@ -464,8 +463,9 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
throws LanguageNotFoundException {
languageUpgradeTranslator =
- LanguageTranslatorFactory.getLanguageTranslatorFactory().getLanguageTranslator(
- languageID, languageVersion);
+ LanguageTranslatorFactory.getLanguageTranslatorFactory()
+ .getLanguageTranslator(
+ languageID, languageVersion);
if (languageUpgradeTranslator == null) {
throw e;
}
@@ -514,10 +514,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
changed = origChangeState;
}
- /**
- * Set the program user data
- * @param programUserData
- */
void setProgramUserData(ProgramUserDataDB programUserData) {
this.programUserData = programUserData;
}
@@ -571,9 +567,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
return memoryManager;
}
- /**
- * returns the namespace manager
- */
public NamespaceManager getNamespaceManager() {
return (NamespaceManager) managers[NAMESPACE_MGR];
}
@@ -583,16 +576,10 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
return (ReferenceManager) managers[REF_MGR];
}
- /**
- * Returns the CodeManager
- */
public CodeManager getCodeManager() {
return (CodeManager) managers[CODE_MGR];
}
- /**
- * Returns the TreeManager
- */
public TreeManager getTreeManager() {
return (TreeManager) managers[TREE_MGR];
}
@@ -655,6 +642,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
format = pl.getString(EXECUTABLE_FORMAT, (String) null);
}
catch (Exception e) {
+ // handled below
}
return format == null ? UNKNOWN : format;
}
@@ -674,6 +662,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
format = pl.getString(EXECUTABLE_MD5, (String) null);
}
catch (Exception e) {
+ // handled below
}
return format == null ? UNKNOWN : format;
}
@@ -693,6 +682,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
format = pl.getString(EXECUTABLE_SHA256, (String) null);
}
catch (Exception e) {
+ // handled below
}
return format == null ? UNKNOWN : format;
}
@@ -910,6 +900,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
* Notification that a program tree was changed.
* @param id the id of the program tree that was changed.
* @param type the type of change
+ * @param affectedObj the object that was changed
* @param oldValue old value depends on the type of the change
* @param newValue old value depends on the type of the change
*/
@@ -960,7 +951,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
* @param symbol the symbol that was changed.
* @param type the type of change
* @param addr the address of the symbol that changed
- * @param affectedObj
+ * @param affectedObj the object that was changed
* @param oldValue old value depends on the type of the change
* @param newValue old value depends on the type of the change
*/
@@ -1023,10 +1014,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
fireEvent(new ProgramChangeRecord(type, addr, addr, null, oldValue, newValue));
}
- public HashSet<Long> getChangedFunctionTagIDs() {
- return this.changedFunctionIDs;
- }
-
@Override
public void setRegisterValuesChanged(Register register, Address start, Address end) {
if (recordChanges) {
@@ -1043,27 +1030,11 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
new ProgramChangeRecord(DOCR_REGISTER_VALUES_CHANGED, start, end, null, null, null));
}
- /**
- * Mark the state this Program as having changed and generate
- * the event. Any or all parameters may be null.
- * @param type event type
- * @param oldValue original value
- * @param newValue new value
- */
@Override
public void setChanged(int type, Object oldValue, Object newValue) {
setChanged(type, (Address) null, (Address) null, oldValue, newValue);
}
- /**
- * Mark the state this Program as having changed and generate
- * the event. Any or all parameters may be null.
- * @param type event type
- * @param start starting address that is affected by the event
- * @param end ending address that is affected by the event
- * @param oldValue original value
- * @param newValue new value
- */
@Override
public void setChanged(int type, Address start, Address end, Object oldValue, Object newValue) {
@@ -1084,37 +1055,12 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
fireEvent(new ProgramChangeRecord(type, newstart, newend, null, oldValue, newValue));
}
- /**
- * Mark the state of a Program as having changed and generate
- * the event. Any or all parameters may be null.
- * NOTE: ChangeSet data will not be updated since this a very generic
- * change not related to a specific address.
- * @param type event type
- * @param affectedObj object that is the subject of the event
- * @param oldValue original value or an Object that is related to
- * the event
- * @param newValue new value or an Object that is related to the
- * the event
- */
@Override
public void setObjChanged(int type, Object affectedObj, Object oldValue, Object newValue) {
changed = true;
fireEvent(new ProgramChangeRecord(type, null, null, affectedObj, oldValue, newValue));
}
- /**
- * Mark the state of a Program as having changed and generate
- * the event. Any or all parameters may be null.
- * NOTE: ChangeSet data will not be updated since this a very generic
- * change not related to a specific address.
- * @param type event type
- * @param subType event sub-type
- * @param affectedObj object that is the subject of the event
- * @param oldValue original value or an Object that is related to
- * the event
- * @param newValue new value or an Object that is related to the
- * the event
- */
@Override
public void setObjChanged(int type, int subType, Object affectedObj, Object oldValue,
Object newValue) {
@@ -1123,17 +1069,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
new ProgramChangeRecord(type, subType, null, null, affectedObj, oldValue, newValue));
}
- /**
- * Mark the state of a Program as having changed and generate
- * the event. Any or all parameters may be null.
- * @param type event type
- * @param addr program address affected
- * @param affectedObj object that is the subject of the event
- * @param oldValue original value or an Object that is related to
- * the event
- * @param newValue new value or an Object that is related to the
- * the event
- */
@Override
public void setObjChanged(int type, Address addr, Object affectedObj, Object oldValue,
Object newValue) {
@@ -1144,18 +1079,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
fireEvent(new ProgramChangeRecord(type, addr, addr, affectedObj, oldValue, newValue));
}
- /**
- * Mark the state of a Program as having changed and generate
- * the event. Any or all parameters may be null.
- * @param type event type
- * @param subType event sub-type
- * @param addr program address affected
- * @param affectedObj object that is the subject of the event
- * @param oldValue original value or an Object that is related to
- * the event
- * @param newValue new value or an Object that is related to the
- * the event
- */
@Override
public void setObjChanged(int type, int subType, Address addr, Object affectedObj,
Object oldValue, Object newValue) {
@@ -1167,17 +1090,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
new ProgramChangeRecord(type, subType, addr, addr, affectedObj, oldValue, newValue));
}
- /**
- * Mark the state of a Program as having changed and generate
- * the event. Any or all parameters may be null.
- * @param type event type
- * @param addrSet set of program addresses affected
- * @param affectedObj object that is the subject of the event
- * @param oldValue original value or an Object that is related to
- * the event
- * @param newValue new value or an Object that is related to the
- * the event
- */
@Override
public void setObjChanged(int type, AddressSetView addrSet, Object affectedObj, Object oldValue,
Object newValue) {
@@ -1188,9 +1100,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
fireEvent(new ProgramChangeRecord(type, null, null, affectedObj, oldValue, newValue));
}
- /**
- * Method updateChanges over range
- */
private void updateChangeSet(Address start, Address end) {
ProgramDBChangeSet pcs = (ProgramDBChangeSet) changeSet;
if (start != null) {
@@ -1201,23 +1110,12 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
}
}
- /**
- * Method updateChanges over address set
- */
private void updateChangeSet(AddressSetView addrSet) {
if (addrSet != null) {
((ProgramDBChangeSet) changeSet).add(addrSet);
}
}
- /**
- * Mark the state of a Program as having changed and generate
- * the DOCR_CODE_UNIT_PROPERTY_CHANGED event.
- * @param propertyName
- * @param codeUnitAddr address of the code unit with the property change
- * @param oldValue old value for the property
- * @param newValue new value for the property
- */
@Override
public void setPropertyChanged(String propertyName, Address codeUnitAddr, Object oldValue,
Object newValue) {
@@ -1228,13 +1126,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
fireEvent(new CodeUnitPropertyChangeRecord(propertyName, codeUnitAddr, oldValue, newValue));
}
- /**
- * Mark the state of a Program as having changed and generate
- * the DOCR_CODE_UNIT_PROPERTY_RANGE_REMOVED event.
- * @param propertyName name of the property
- * @param start start of range of the property being removed
- * @param end end of the range of the property being removed
- */
@Override
public void setPropertyRangeRemoved(String propertyName, Address start, Address end) {
if (recordChanges) {
@@ -1244,25 +1135,12 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
fireEvent(new CodeUnitPropertyChangeRecord(propertyName, start, end));
}
- /**
- * Notify program of a user data change
- * @param propertyName
- * @param codeUnitAddr
- * @param oldValue
- * @param newValue
- */
void userDataChanged(String propertyName, Address codeUnitAddr, Object oldValue,
Object newValue) {
// Do not update change set!
fireEvent(new CodeUnitUserDataChangeRecord(propertyName, codeUnitAddr, oldValue, newValue));
}
- /**
- * Notification of property change
- * @param propertyName
- * @param oldValue
- * @param newValue
- */
protected void userDataChanged(String propertyName, Object oldValue, Object newValue) {
fireEvent(new UserDataChangeRecord(propertyName, name, name));
}
@@ -1309,6 +1187,9 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
* Creates a new OverlayAddressSpace with the given name and base AddressSpace
* @param overlaySpaceName the name of the overlay space to create
* @param templateSpace the base AddressSpace to overlay
+ * @param minOffset the min offset of the space
+ * @param maxOffset the max offset of the space
+ * @return the new space
* @throws DuplicateNameException if an AddressSpace already exists with the given name.
* @throws LockException if the program is shared and not checked out exclusively.
* @throws MemoryConflictException if image base override is active
@@ -1526,8 +1407,8 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
* <li>LanguageMinorVersion</li>
* </ul>
* @param openMode program open mode
- * @return version exception if the current version is out of date and can be upgraded.
- * @throws IOException
+ * @return version exception if the current version is out of date and can be upgraded
+ * @throws IOException if there is an exception at the database level
* @throws VersionException if the data is newer than this version of Ghidra and can not be
* upgraded or opened.
*/
@@ -1617,12 +1498,8 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
table.putRecord(record);
}
- /**
- * Perform more complex upgrades which require all language version translation to
- * be completed
- * @param monitor
- * @throws IOException
- * @throws CancelledException
+ /*
+ * Perform more complex upgrades which require all language version translation to be completed
*/
private void postUpgrade(int oldVersion, TaskMonitor monitor)
throws CancelledException, IOException {
@@ -1646,16 +1523,13 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
public int getStoredVersion() throws IOException {
Record record = table.getRecord(new StringField(PROGRAM_DB_VERSION));
-
- // DB Version was added in 2.1 release (27-May-04)
- // if record does not exist return 1;
-
if (record != null) {
String s = record.getString(0);
try {
return Integer.parseInt(s);
}
catch (NumberFormatException e) {
+ // return 1 for invalid value
}
}
return 1;
@@ -1705,12 +1579,10 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
}
- /**
+ /*
* External function pointers had previously been wrapped in a function. This should know be
* handled by creating an external function which corresponds to the pointers external location
* reference.
- * @param monitor
- * @throws IOException
*/
private void checkFunctionWrappedPointers(TaskMonitor monitor)
throws IOException, CancelledException {
@@ -1795,11 +1667,11 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
}
catch (VersionException e) {
if (!e.isUpgradable()) {
- // Attempt to instatiate the old function manager which may be used for upgrades
+ // Attempt to instantiate the old function manager which may be used for upgrades
try {
oldFunctionMgr = new OldFunctionManager(dbh, this, addrMap);
if (openMode != UPGRADE) {
- // Indicate that program is upgradeable
+ // Indicate that program is upgradable
oldFunctionMgr = null;
versionExc = (new VersionException(true)).combine(versionExc);
}
@@ -1810,6 +1682,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
}
}
catch (VersionException e1) {
+ // TODO why does this happen? should we log this?
}
}
else {
@@ -2058,12 +1931,14 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
}
/**
- * Moves all information stored in the given range to the new location.
- * @param fromAddr the first address in the range to be moved.
- * @param toAddr the address to move to.
- * @param length the number of addresses to move.
- * @param monitor the task monitor to use while deleting information in the given range.
- * @throws RollbackException if the user cancelled the operation via the task monitor.
+ * Moves all information stored in the given range to the new location
+ *
+ * @param fromAddr the first address in the range to be moved
+ * @param toAddr the address to move to
+ * @param length the number of addresses to move
+ * @param monitor the task monitor to use while deleting information in the given range
+ * @throws AddressOverflowException if there is a problem moving address ranges
+ * @throws RollbackException if the user cancelled the operation via the task monitor
*/
public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)
throws AddressOverflowException, RollbackException {
@@ -2103,23 +1978,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
return globalNamespace;
}
-// private void updateCompilerSpec(Language currLanguage, CompilerSpecID currCompilerSpecID, TaskMonitor monitor) {
-// try {
-// compilerSpec = currLanguage.getCompilerSpecByID(currCompilerSpecID);
-// if (compilerSpec == null) {
-// throw new IllegalArgumentException("Language "
-// + currLanguage.getLanguageDescription().getDescription()
-// + " does not have a compiler spec " + currCompilerSpecID);
-// }
-// }
-// catch (CompilerSpecNotFoundException e) {
-// throw new IllegalArgumentException("Language "
-// + currLanguage.getLanguageDescription().getDescription()
-// + " does not have a compiler spec " + currCompilerSpecID);
-// }
-// this.compilerSpecID = currCompilerSpecID;
-// }
-
@Override
public void setLanguage(Language newLanguage, CompilerSpecID newCompilerSpecID,
boolean forceRedisassembly, TaskMonitor monitor)
@@ -2129,8 +1987,9 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
return;
}
LanguageTranslator languageTranslator =
- LanguageTranslatorFactory.getLanguageTranslatorFactory().getLanguageTranslator(language,
- newLanguage);
+ LanguageTranslatorFactory.getLanguageTranslatorFactory()
+ .getLanguageTranslator(language,
+ newLanguage);
if (languageTranslator == null) {
throw new IncompatibleLanguageException("Language translation not supported");
}
@@ -2255,13 +2114,9 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
}
}
- /**
- * Repair damaged context prior to language upgrade.
- * It is assumed that the context has already been upgrade and that the original
- * prototypes and instructions are still intact.
- * @param translator optional language translator
- * @param monitor
- * @throws CancelledException
+ /*
+ * Repair damaged context prior to language upgrade. It is assumed that the context has
+ * already been upgrade and that the original prototypes and instructions are still intact.
*/
private void repairContext(int oldLanguageVersion, int oldLanguageMinorVersion,
LanguageTranslator translator, TaskMonitor monitor) throws CancelledException {
@@ -2271,15 +2126,12 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
}
}
- /**
+ /*
* Repair damaged ARM/THUMB context prior to language upgrade. With the release of Ghidra 5.2
* (which corresponds to the ARM language version of 1.6) the stored context register
* value is write-protected where instructions exist.
* It is assumed that the context has already been upgrade and that the original
* prototypes and instructions are still intact.
- * @param translator optional language translator
- * @param monitor
- * @throws CancelledException
*/
private void repairARMContext(int oldLanguageVersion, int oldLanguageMinorVersion,
LanguageTranslator translator, TaskMonitor monitor) throws CancelledException {