Ghidra is a software reverse engineering (SRE) framework
GT-3227 - Removed transactions from the equate manager
dragonmacher665a83d6c0ab
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/CreateEnumEquateCommand.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/CreateEnumEquateCommand.javaindex 6c3b68d706..4ea10b3bfd 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/CreateEnumEquateCommand.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/CreateEnumEquateCommand.java@@ -37,8 +37,7 @@ public class CreateEnumEquateCommand extends BackgroundCommand {* @param program The program to use* @param addresses The addresses to apply an enum to* @param enoom The enum to apply equates with- * @param shouldIncludeTypes True if the equate name should include the enum name.- * @param shouldDoOnSubOps True if the enum should also be applied to the sub-operands.+ * @param shouldDoOnSubOps true if the enum should also be applied to the sub-operands.*/public CreateEnumEquateCommand(Program program, AddressSetView addresses, Enum enoom,boolean shouldDoOnSubOps) {@@ -65,5 +64,4 @@ public class CreateEnumEquateCommand extends BackgroundCommand {public String getName() {return "Create Enum Equate Command";}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquatePlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquatePlugin.javaindex eaed5924b3..b861620245 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquatePlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquatePlugin.java@@ -30,7 +30,6 @@ import ghidra.app.plugin.PluginCategoryNames;import ghidra.app.util.bean.SetEquateDialog;import ghidra.app.util.bean.SetEquateDialog.SelectionType;import ghidra.app.util.datatype.ApplyEnumDialog;-import ghidra.app.util.datatype.DataTypeSelectionDialog;import ghidra.framework.cmd.BackgroundCommand;import ghidra.framework.cmd.CompoundBackgroundCommand;import ghidra.framework.plugintool.*;@@ -74,23 +73,14 @@ public class EquatePlugin extends Plugin {private SetEquateDialog setEquateDialog;private ApplyEnumDialog applyEnumDialog;- /**- * Constructor.- *- * @param tool- */public EquatePlugin(PluginTool tool) {super(tool);createActions();}- /**+ /** Returns the GUI for the {@link SetEquateDialog}. Note that this function will close* any instance of the dialog that is currently open and construct a new one.- *- * @param context- * @param scalar- * @return*/private SetEquateDialog createEquateDialog(ListingActionContext context, Scalar scalar) {if (setEquateDialog != null) {@@ -105,11 +95,9 @@ public class EquatePlugin extends Plugin {return setEquateDialog;}- /**+ /** Returns the GUI for the {@link DataTypeSelectionDialog}. Note that this function will* close any instance of the dialog that is currently open and construct a new one.- * @param context- * @return*/private ApplyEnumDialog applyEnumDialog(ListingActionContext context) {DataTypeManager dtm = context.getProgram().getDataTypeManager();@@ -122,11 +110,6 @@ public class EquatePlugin extends Plugin {return applyEnumDialog;}- /**- * Destroys the {@link SetEquateDialog}.- *- * @param dialog- */private void dispose(SetEquateDialog dialog) {if (setEquateDialog == dialog) {setEquateDialog.dispose();@@ -146,7 +129,7 @@ public class EquatePlugin extends Plugin {* array or composite (CreateEquateCmd does not currently support such data cases)</li>* </ul>* Currently markup of equates is not supported within composite or array data- * @param context+ * @param context the action context* @return true if current location satisfies the above constraints*/protected boolean isEquatePermitted(ListingActionContext context) {@@ -182,7 +165,7 @@ public class EquatePlugin extends Plugin {* ultimately create the background tasks that will create the proper equate(s) for* the selected addresses.*- * @param context+ * @param context the action context*/private void setEquate(ListingActionContext context) {@@ -252,7 +235,7 @@ public class EquatePlugin extends Plugin {/*** Called in response to the user selecting the Apply Enum action from the popup menu. This* action will apply enum values to scalars in a selection.- * @param context+ * @param context the action context*/private void applyEnum(ListingActionContext context) {applyEnumDialog = applyEnumDialog(context);@@ -281,7 +264,7 @@ public class EquatePlugin extends Plugin {/*** Called in response to the user activating rename action from the context menu.*- * @param context+ * @param context the action context*/private void renameEquate(ListingActionContext context) {@@ -348,12 +331,6 @@ public class EquatePlugin extends Plugin {dispose(setEquateDialog);}- /**- * Returns the equate for the given context listing.- *- * @param context- * @return- */private Equate getEquate(ListingActionContext context) {EquateTable equateTable = context.getProgram().getEquateTable();Scalar s = getScalar(context);@@ -363,15 +340,6 @@ public class EquatePlugin extends Plugin {return equateTable.getEquate(context.getAddress(), getOperandIndex(context), s.getValue());}- /**- * Renames all equates matching the given old equate name, within the address space identified- * by the iterator.- *- * @param context- * @param oldEquate- * @param newEquateName- * @param iter- */private void renameEquate(ListingActionContext context, Equate oldEquate, String newEquateName,CodeUnitIterator iter) {@@ -476,14 +444,6 @@ public class EquatePlugin extends Plugin {}}- /**- * Returns the list of operands for the given {@link Instruction} that match the given- * {@link Equate}.- *- * @param instruction- * @param equate- * @return an array of matches, in the format: [operand][operand-obj]- */private List<Integer> getInstructionMatches(Program program, Instruction instruction,Equate equate) {@@ -521,15 +481,6 @@ public class EquatePlugin extends Plugin {return matches;}- /**- * Returns true if the given {@link Data} object is a scalar value that has an equate- * that matches the one passed-in.- *- * @param data- * @param context- * @param equate- * @return- */private boolean isDataMatch(Data data, ListingActionContext context, Equate equate) {if (!data.isDefined()) {@@ -560,12 +511,10 @@ public class EquatePlugin extends Plugin {return false;}- /**+ /** Removes equates within the selected region, or a single equate if there's* no selection. The user will be prompted for confirmation before* removing multiple equates in a selection.- *- * @param context*/private void removeSelectedEquates(ListingActionContext context) {@@ -606,7 +555,8 @@ public class EquatePlugin extends Plugin {}/**- * Get the instruction at the location provided by the ProgramLocationProvider+ * Get the instruction at the location provided by the context+ * @param context the action context* @return code unit containing current location if found (component data unsupported)*/CodeUnit getCodeUnit(ListingActionContext context) {@@ -619,7 +569,7 @@ public class EquatePlugin extends Plugin {/*** Get the operand index at the location- *+ * @param context the action context* @return 0-3 for a good operand location, -1 otherwise*/int getOperandIndex(ListingActionContext context) {@@ -630,11 +580,6 @@ public class EquatePlugin extends Plugin {return -1;}- /**- *- * @param context- * @return- */int getSubOperandIndex(ListingActionContext context) {ProgramLocation location = context.getLocation();if (location instanceof OperandFieldLocation) {@@ -649,10 +594,6 @@ public class EquatePlugin extends Plugin {return scalar;}- ////////////////////////////////////////////////////////////////- // *** private methods ***- ////////////////////////////////////////////////////////////////-private Scalar getScalar(CodeUnit cu, ListingActionContext context) {int opIndex = getOperandIndex(context);int subOpIndex = getSubOperandIndex(context);@@ -664,7 +605,7 @@ public class EquatePlugin extends Plugin {* Get scalar value associated with the specified code unit,* opIndex and subOpindex. NOTE: this method does not support* composite or array data (null will always be returned).- * @param cu cpde unit+ * @param cu code unit* @param opIndex operand index* @param subOpIndex sub-operand index* @return scalar value or nulldiff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/symbol/EquateManagerTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/symbol/EquateManagerTest.javaindex a4027f5fa6..ab6965af92 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/symbol/EquateManagerTest.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/symbol/EquateManagerTest.java@@ -30,51 +30,34 @@ import ghidra.program.model.symbol.*;import ghidra.test.AbstractGhidraHeadedIntegrationTest;import ghidra.util.exception.DuplicateNameException;import ghidra.util.exception.InvalidInputException;-import ghidra.util.task.TaskMonitorAdapter;+import ghidra.util.task.TaskMonitor;-/**- * Test the equate manager for the database implementation.- *- *- */public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {private ProgramDB program;private AddressSpace space;private EquateTable equateTable;private int transactionID;- /**- * Constructor for EquateManagerTest.- * @param name- */- public EquateManagerTest() {- super();- }-- /*- * @see TestCase#setUp()- */- @Before- public void setUp() throws Exception {+ @Before+ public void setUp() throws Exception {program = createDefaultProgram("Test", ProgramBuilder._TOY, this);space = program.getAddressFactory().getDefaultAddressSpace();Memory memory = program.getMemory();transactionID = program.startTransaction("Test");- memory.createInitializedBlock("test", addr(0), 5000, (byte) 0,- TaskMonitorAdapter.DUMMY_MONITOR, false);+ memory.createInitializedBlock("test", addr(0), 5000, (byte) 0, TaskMonitor.DUMMY, false);equateTable = program.getEquateTable();}- @After- public void tearDown() throws Exception {+ @After+ public void tearDown() throws Exception {program.endTransaction(transactionID, true);program.release(this);}-@Test- public void testCreateEquate() throws Exception {+ @Test+ public void testCreateEquate() throws Exception {Equate equate = equateTable.createEquate("Test", 100);assertNotNull(equate);@@ -82,8 +65,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertNotNull(equate);}-@Test- public void testCreateEquateDuplicate() throws Exception {+ @Test+ public void testCreateEquateDuplicate() throws Exception {equateTable.createEquate("Test", 100);equateTable.createEquate("Test-2", 1000);try {@@ -91,35 +74,38 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {Assert.fail("Should have gotten duplicate name exception");}catch (DuplicateNameException e) {+ // expected}}-@Test- public void testBadNameForCreate() throws Exception {+ @Test+ public void testBadNameForCreate() throws Exception {try {equateTable.createEquate("", 100);Assert.fail("Should have gotten invalid input exception");}catch (InvalidInputException e) {+ // expected}try {equateTable.createEquate(null, 100);Assert.fail("Should have gotten invalid input exception");}catch (InvalidInputException e) {+ // expected}}-@Test- public void testBasicEquate() throws Exception {+ @Test+ public void testBasicEquate() throws Exception {Equate equate = equateTable.createEquate("Test", 100);assertEquals("Test", equate.getName());assertEquals(100, equate.getValue());}-@Test- public void testAddReferenceOnEquate() throws Exception {+ @Test+ public void testAddReferenceOnEquate() throws Exception {Equate eqTest = equateTable.createEquate("Test", 100);eqTest.addReference(addr(100), 0);EquateReference[] refs = eqTest.getReferences();@@ -150,8 +136,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {// assertEquals(1, eqTest3.getReferenceCount());}-@Test- public void testRemoveReference() throws Exception {+ @Test+ public void testRemoveReference() throws Exception {Equate eq = equateTable.createEquate("Test", 1);eq.addReference(addr(10), 0);@@ -185,8 +171,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertEquals(7, refs.length);}-@Test- public void testEquateIterator() throws Exception {+ @Test+ public void testEquateIterator() throws Exception {for (int i = 10; i < 20; i++) {equateTable.createEquate("Test_" + i, i);@@ -203,8 +189,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {}-@Test- public void testEquateAddressIterator() throws Exception {+ @Test+ public void testEquateAddressIterator() throws Exception {Equate eq = equateTable.createEquate("Test", 1);eq.addReference(addr(100), 3);@@ -228,8 +214,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertEquals(7, count);// should filter out duplicate ref addrs}-@Test- public void testEquateAddressIteratorStart() throws Exception {+ @Test+ public void testEquateAddressIteratorStart() throws Exception {Equate eq = equateTable.createEquate("Test", 1);eq.addReference(addr(100), 3);@@ -247,8 +233,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertEquals(2, count);// should filter out duplicate ref addrs}-@Test- public void testEquateAddressIteratorSet() throws Exception {+ @Test+ public void testEquateAddressIteratorSet() throws Exception {Equate eq = equateTable.createEquate("Test", 1);eq.addReference(addr(100), 3);@@ -287,8 +273,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {}-@Test- public void testGetEquatesByValue() throws Exception {+ @Test+ public void testGetEquatesByValue() throws Exception {// now create equates with the same valuefor (int i = 0; i < 10; i++) {equateTable.createEquate("EQ_0" + i, 500);@@ -299,8 +285,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertEquals(12, equates.size());}-@Test- public void testGetEquateByName() throws Exception {+ @Test+ public void testGetEquateByName() throws Exception {equateTable.createEquate("Test", 500);equateTable.createEquate("Test2", 1500);@@ -315,8 +301,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertNull(equateTable.getEquate("foo"));}-@Test- public void testRemoveEquate() throws Exception {+ @Test+ public void testRemoveEquate() throws Exception {equateTable.createEquate("Test", 500);equateTable.createEquate("Test2", 1500);@@ -325,8 +311,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertNotNull(equateTable.getEquate("Test2"));}-@Test- public void testRemoveEquateWithRefs() throws Exception {+ @Test+ public void testRemoveEquateWithRefs() throws Exception {Equate eq = equateTable.createEquate("Test", 1);eq.addReference(addr(100), 3);@@ -344,8 +330,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertNotNull(equateTable.getEquate("Test2"));}-@Test- public void testRemoveEquatesInRange() throws Exception {+ @Test+ public void testRemoveEquatesInRange() throws Exception {Equate eq = equateTable.createEquate("Test1", 100);equateTable.createEquate("Test2", 200);equateTable.createEquate("Test3", 200);@@ -370,7 +356,7 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {}assertEquals(6, count);- equateTable.deleteAddressRange(addr(50), addr(500), TaskMonitorAdapter.DUMMY_MONITOR);+ equateTable.deleteAddressRange(addr(50), addr(500), TaskMonitor.DUMMY);assertNull(equateTable.getEquate("Test1"));assertNotNull(equateTable.getEquate("Test4"));assertEquals(0, equateTable.getEquates(addr(100), 0).size());@@ -386,8 +372,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertEquals(5, count);}-@Test- public void testRenameEquate() throws Exception {+ @Test+ public void testRenameEquate() throws Exception {Equate eq = equateTable.createEquate("Test1", 100);equateTable.createEquate("Test2", 200);equateTable.createEquate("Test3", 200);@@ -407,8 +393,8 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {assertEquals(eq, temp);}-@Test- public void testRenameEquateDuplicate() throws Exception {+ @Test+ public void testRenameEquateDuplicate() throws Exception {Equate eq = equateTable.createEquate("Test1", 100);equateTable.createEquate("Test2", 200);equateTable.createEquate("Test3", 200);@@ -419,6 +405,7 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {Assert.fail("Should have gotten DuplicateNameException");}catch (DuplicateNameException e) {+ // expected}eq = equateTable.createEquate("foo", 100);eq.renameEquate("foo");// nothing should happen@@ -427,23 +414,26 @@ public class EquateManagerTest extends AbstractGhidraHeadedIntegrationTest {Assert.fail("Should have gotten DuplicateNameException");}catch (DuplicateNameException e) {+ // expected}}-@Test- public void testRenameEquateBadName() throws Exception {+ @Test+ public void testRenameEquateBadName() throws Exception {Equate eq = equateTable.createEquate("Test1", 100);try {eq.renameEquate("");Assert.fail("Empty string should be invalid!");}catch (InvalidInputException e) {+ // expected}try {eq.renameEquate(null);Assert.fail("Empty string should be invalid!");}catch (InvalidInputException e) {+ // expected}}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/symbol/EquateManager.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/symbol/EquateManager.javaindex ddedc6047f..5d6f26e75c 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/symbol/EquateManager.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/symbol/EquateManager.java@@ -27,7 +27,6 @@ import ghidra.program.database.*;import ghidra.program.database.map.AddressKeyAddressIterator;import ghidra.program.database.map.AddressMap;import ghidra.program.model.address.*;-import ghidra.program.model.data.DataTypeManager;import ghidra.program.model.data.Enum;import ghidra.program.model.listing.*;import ghidra.program.model.scalar.Scalar;@@ -40,9 +39,7 @@ import ghidra.util.exception.*;import ghidra.util.task.TaskMonitor;/**- * Implementation for the Equate Table.- *- *+ * Implementation of the Equate Table*/public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {@@ -60,14 +57,12 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {/*** Constructor* @param handle database handle- * @param addrMap map that converts addresses to longs and longs to- * addresses+ * @param addrMap map that converts addresses to longs and longs to addresses* @param openMode one of ProgramDB.CREATE, UPDATE, UPGRADE, or READ_ONLY* @param lock the program synchronization lock* @param monitor the progress monitor used when upgrading.* @throws VersionException if the database version doesn't match the current version.* @throws IOException if a database error occurs.- * @throws CancelledException if the user cancels the upgrade.*/public EquateManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock,TaskMonitor monitor) throws VersionException, IOException {@@ -103,26 +98,17 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}}- /**- * @see ghidra.program.database.ManagerDB#setProgram(ghidra.program.database.ProgramDB)- */@Overridepublic void setProgram(ProgramDB program) {this.program = program;}- /**- * @see ghidra.program.database.ManagerDB#programReady(int, int, ghidra.util.task.TaskMonitor)- */@Overridepublic void programReady(int openMode, int currentRevision, TaskMonitor monitor)throws IOException, CancelledException {// Nothing to do}- /**- * @see db.util.ErrorHandler#dbError(java.io.IOException)- */@Overridepublic void dbError(IOException e) {program.dbError(e);@@ -167,12 +153,9 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {InstructionIterator it = listing.getInstructions(addresses, true);Stream<Instruction> instructions = StreamSupport.stream(it.spliterator(), false);- DataTypeManager dtm = program.getDataTypeManager();try {lock.acquire();- int id = dtm.startTransaction("Apply Enum");instructions.forEach(applyEquates);- dtm.endTransaction(id, true);}finally {lock.release();@@ -198,13 +181,7 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}if (program.getDataTypeManager().findDataTypeForID(enoom.getUniversalID()) == null) {- int transactionID = program.startTransaction("Set Equate Dialog");- try {- enoom = (Enum) program.getDataTypeManager().addDataType(enoom, null);- }- finally {- program.endTransaction(transactionID, true);- }+ enoom = (Enum) program.getDataTypeManager().addDataType(enoom, null);}Address addr = instruction.getAddress();@@ -243,9 +220,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return equate;}- /**- * @see ghidra.program.model.symbol.EquateTable#createEquate(java.lang.String, long)- */@Overridepublic Equate createEquate(String name, long value)throws DuplicateNameException, InvalidInputException {@@ -271,9 +245,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return null;}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquate(ghidra.program.model.address.Address, int, long)- */@Overridepublic Equate getEquate(Address reference, int opIndex, long scalarValue) {lock.acquire();@@ -302,9 +273,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return null;}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquates(ghidra.program.model.address.Address, int)- */@Overridepublic List<Equate> getEquates(Address reference, int opIndex) {List<Equate> ret = new LinkedList<>();@@ -331,9 +299,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return ret;}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquates(ghidra.program.model.address.Address)- */@Overridepublic List<Equate> getEquates(Address reference) {List<Equate> ret = new LinkedList<>();@@ -358,9 +323,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return ret;}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquate(java.lang.String)- */@Overridepublic Equate getEquate(String name) {lock.acquire();@@ -369,6 +331,7 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return getEquateDB(equateID);}catch (NotFoundException e) {+ // just return null below}catch (IOException e) {program.dbError(e);@@ -379,9 +342,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return null;}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquateAddresses()- */@Overridepublic AddressIterator getEquateAddresses() {@@ -395,9 +355,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return new EmptyAddressIterator();}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquateAddresses(ghidra.program.model.address.Address)- */@Overridepublic AddressIterator getEquateAddresses(Address startAddr) {try {@@ -421,9 +378,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return new EmptyAddressIterator();}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquateAddresses(ghidra.program.model.address.AddressSetView)- */@Overridepublic AddressIterator getEquateAddresses(AddressSetView set) {try {@@ -436,9 +390,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return new EmptyAddressIterator();}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquates()- */@Overridepublic Iterator<Equate> getEquates() {try {@@ -451,9 +402,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return new EquateIterator(null);}- /**- * @see ghidra.program.model.symbol.EquateTable#getEquates(long)- */@Overridepublic List<Equate> getEquates(long value) {ArrayList<Equate> list = new ArrayList<>();@@ -473,9 +421,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return list;}- /**- * @see ghidra.program.database.ManagerDB#deleteAddressRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, ghidra.util.task.TaskMonitor)- */@Overridepublic void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor)throws CancelledException {@@ -516,9 +461,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}}- /**- * @see ghidra.program.model.symbol.EquateTable#removeEquate(java.lang.String)- */@Overridepublic boolean removeEquate(String name) {if (name == null) {@@ -562,30 +504,18 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}}- /**- * Return the address map.- */AddressMap getAddressMap() {return addrMap;}- /**- * Get the database adapter for equate table.- */EquateDBAdapter getEquateDatabaseAdapter() {return equateAdapter;}- /**- * Get the database adapter for the equate references table.- */EquateRefDBAdapter getRefDatabaseAdapter() {return refAdapter;}- /**- * Add a reference for an equate at the given operand position.- */void addReference(long equateID, Address address, int opIndex, long dynamicHash)throws IOException {lock.acquire();@@ -622,9 +552,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}}- /**- * Get the references for the given equate ID.- */EquateRefDB[] getReferences(long equateID) throws IOException {long[] keys = refAdapter.getRecordKeysForEquateID(equateID);EquateRefDB[] refs = new EquateRefDB[keys.length];@@ -634,19 +561,10 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {return refs;}- /**- * Get the number of references for the given equate ID.- */int getReferenceCount(long equateID) throws IOException {return getReferences(equateID).length;}- /**- * Remove the reference.- * @param equateDB equate- * @param refAddr ref address to remove- * @param opIndex operand index- */void removeReference(EquateDB equateDB, Address refAddr, short opIndex) throws IOException {long[] keys = refAdapter.getRecordKeysForEquateID(equateDB.getKey());@@ -659,13 +577,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}}- /**- * Remove the reference.- * @param equateDB equate- * @param dynamicHash hash value- * @param refAddr ref address to remove- * @param opIndex operand index- */void removeReference(EquateDB equateDB, long dynamicHash, Address refAddr) throws IOException {long[] keys = refAdapter.getRecordKeysForEquateID(equateDB.getKey());@@ -678,10 +589,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}}- /**- * Verify that the name is not null and not the empty string.- * @throws InvalidInputException if the name is null or is empty- */void validateName(String name) throws InvalidInputException {if (name == null) {throw new InvalidInputException("Name is null");@@ -693,7 +600,7 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}/**- * Send notification that the equate name changed.+ * Send notification that the equate name changed* @param oldName old name* @param newName new name*/@@ -784,66 +691,10 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {null);}- //////////////////////////////////////////////////////////////////////- private class EquateIterator implements Iterator<Equate> {- private RecordIterator iter;-- private EquateIterator(RecordIterator iter) {- this.iter = iter;- }-- /**- * @see java.util.Iterator#hasNext()- */- @Override- public boolean hasNext() {- if (iter != null) {- try {- return iter.hasNext();- }- catch (IOException e) {- program.dbError(e);- }- }- return false;- }-- /**- * @see java.util.Iterator#next()- */- @Override- public Equate next() {- if (iter != null) {- try {- Record record = iter.next();- if (record != null) {- return getEquateDB(record.getKey());- }- }- catch (IOException e) {- program.dbError(e);- }- }- return null;- }-- /**- * @see java.util.Iterator#remove()- */- @Override- public void remove() {- throw new UnsupportedOperationException("remove is not supported.");- }-- }-Lock getLock() {return lock;}- /**- * @see ghidra.program.database.ManagerDB#invalidateCache(boolean)- */@Overridepublic void invalidateCache(boolean all) {lock.acquire();@@ -856,9 +707,6 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}}- /**- * @see ghidra.program.database.ManagerDB#moveAddressRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, long, ghidra.util.task.TaskMonitor)- */@Overridepublic void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)throws CancelledException {@@ -879,7 +727,7 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {* Formats a string to the equate format given the enum UUID and the value for the equate. The* formatted strings are used when setting equates from datatypes so that information can be* stored with an equate to point back to that datatype.- * @param dtID The enums data type UUID+ * @param dtID The enum's data type UUID* @param equateValue The value intended for the equate* @return The formatted equate name*/@@ -922,4 +770,51 @@ public class EquateManager implements EquateTable, ErrorHandler, ManagerDB {}return -1;}++//==================================================================================================+// Inner Classes+//==================================================================================================++ private class EquateIterator implements Iterator<Equate> {+ private RecordIterator iter;++ private EquateIterator(RecordIterator iter) {+ this.iter = iter;+ }++ @Override+ public boolean hasNext() {+ if (iter != null) {+ try {+ return iter.hasNext();+ }+ catch (IOException e) {+ program.dbError(e);+ }+ }+ return false;+ }++ @Override+ public Equate next() {+ if (iter != null) {+ try {+ Record record = iter.next();+ if (record != null) {+ return getEquateDB(record.getKey());+ }+ }+ catch (IOException e) {+ program.dbError(e);+ }+ }+ return null;+ }++ @Override+ public void remove() {+ throw new UnsupportedOperationException("remove is not supported.");+ }++ }}