diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptEditorComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptEditorComponentProvider.java index 7fc3624725..c6936ed36b 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptEditorComponentProvider.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptEditorComponentProvider.java @@ -173,17 +173,14 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider { } private void updateChangedState() { - boolean hasChanges = !undoStack.isEmpty(); - if (saveAction != null && !isReadOnly(scriptSourceFile)) { - saveAction.setEnabled(hasChanges); - } - + boolean hasChanges = hasChanges(); if (hasChanges) { setTitle("*" + title); } else { setTitle(title); } + contextChanged(); } private void clearChanges() { @@ -268,7 +265,15 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider { @Override public boolean isEnabledForContext(ActionContext context) { Object contextObject = context.getContextObject(); - return contextObject == GhidraScriptEditorComponentProvider.this; + if (contextObject != GhidraScriptEditorComponentProvider.this) { + return false; + } + + if (isReadOnly(scriptSourceFile)) { + return false; + } + + return hasChanges(); } }; saveAction.setDescription("Save"); @@ -276,7 +281,7 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider { new ToolBarData(ResourceManager.loadImage("images/disk.png"), "Save")); saveAction.setKeyBindingData(new KeyBindingData( KeyStroke.getKeyStroke(KeyEvent.VK_S, DockingUtils.CONTROL_KEY_MODIFIER_MASK))); - saveAction.setEnabled(false); + plugin.getTool().addLocalAction(this, saveAction); DockingAction refreshAction = new DockingAction("Refresh Script", plugin.getName()) { @@ -607,8 +612,6 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider { writer.print(str); writer.close(); - saveAction.setEnabled(false); - provider.switchEditor(scriptSourceFile, saveAsFile); scriptSourceFile = saveAsFile; @@ -664,7 +667,7 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider { //================================================================================================== /** * Special JTextArea that knows how to properly handle it's key events. - * @see {@link #processKeyBinding(KeyStroke, KeyEvent, int, boolean)} + * See {@link #processKeyBinding(KeyStroke, KeyEvent, int, boolean)} */ private class KeyMasterTextArea extends JTextArea { @@ -713,7 +716,7 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider { return true; } - return SwingUtilities.notifyAction(action, ks, e, this, e.getModifiers()); + return SwingUtilities.notifyAction(action, ks, e, this, e.getModifiersEx()); } } return false; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/merge/listing/EquateMergeManager1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/merge/listing/EquateMergeManager1Test.java index 05a4931917..4418ef1c25 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/merge/listing/EquateMergeManager1Test.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/merge/listing/EquateMergeManager1Test.java @@ -15,7 +15,7 @@ */ package ghidra.app.merge.listing; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import java.util.List; @@ -59,8 +59,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { super(); } -@Test - public void testRemoveEquate() throws Exception { + @Test + public void testRemoveEquate() throws Exception { mtf.initialize("NotepadMergeListingTest", new ProgramModifierListener() { /* (non-Javadoc) @@ -139,8 +139,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { assertEquals(0, equates.size()); } -@Test - public void testChangeEquate() throws Exception { + @Test + public void testChangeEquate() throws Exception { mtf.initialize("NotepadMergeListingTest", new ProgramModifierListener() { /* (non-Javadoc) @@ -211,7 +211,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { Address addr = addr(program, address); Equate oldEquate = equateTab.getEquate(addr, opIndex, value); if (oldEquate.getName().equals(newName)) { - Assert.fail("Equate '" + oldEquate.getName() + "' already exists with value=" + value + "."); + Assert.fail( + "Equate '" + oldEquate.getName() + "' already exists with value=" + value + "."); } oldEquate.removeReference(addr, opIndex); try { @@ -220,8 +221,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { newEquate = equateTab.createEquate(newName, value); } if (newEquate.getValue() != value) { - Assert.fail("Can't create equate '" + newEquate.getName() + "' with value=" + value + - ". It already exists with value=" + newEquate.getValue() + "."); + Assert.fail("Can't create equate '" + newEquate.getName() + "' with value=" + + value + ". It already exists with value=" + newEquate.getValue() + "."); } newEquate.addReference(addr, opIndex); } @@ -230,8 +231,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { } } -@Test - public void testRemoveVsChangeEquate() throws Exception { + @Test + public void testRemoveVsChangeEquate() throws Exception { mtf.initialize("NotepadMergeListingTest", new ProgramModifierListener() { /* (non-Javadoc) @@ -285,7 +286,7 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { assertEquals(1L, eq.getValue()); } -@Test + @Test public void testAddNameDiffPickMy() throws Exception { mtf.initialize("NotepadMergeListingTest", new ProgramModifierListener() { @@ -344,53 +345,56 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { @Test public void testAddNameDiffOnWordDataUpperBit0PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new WordDataType(), new byte[] { (byte) 0x5f, - (byte) 0x5f }, 0x5f5f, true); + runTestAddNameDiffPickIndicated("0x1002d24", new WordDataType(), + new byte[] { (byte) 0x5f, (byte) 0x5f }, 0x5f5f, true); } @Test public void testAddNameDiffOnWordDataUpperBit1PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new WordDataType(), new byte[] { (byte) 0xad, - (byte) 0xad }, 0xadad, true); + runTestAddNameDiffPickIndicated("0x1002d24", new WordDataType(), + new byte[] { (byte) 0xad, (byte) 0xad }, 0xadad, true); } @Test public void testAddNameDiffOnSignedWordDataUpperBit0PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new SignedWordDataType(), new byte[] { - (byte) 0x5f, (byte) 0x5f }, 0x5f5fL, true); + runTestAddNameDiffPickIndicated("0x1002d24", new SignedWordDataType(), + new byte[] { (byte) 0x5f, (byte) 0x5f }, 0x5f5fL, true); } @Test public void testAddNameDiffOnSignedWordDataUpperBit1PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new SignedWordDataType(), new byte[] { - (byte) 0xad, (byte) 0xad }, 0xffffffffffffadadL, true); + runTestAddNameDiffPickIndicated("0x1002d24", new SignedWordDataType(), + new byte[] { (byte) 0xad, (byte) 0xad }, 0xffffffffffffadadL, true); } @Test public void testAddNameDiffOnSignedQWordDataUpperBit0PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new SignedQWordDataType(), new byte[] { - (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, - (byte) 0x5f, (byte) 0x5f }, 0x5f5f5f5f5f5f5f5fL, true); + runTestAddNameDiffPickIndicated( + "0x1002d24", new SignedQWordDataType(), new byte[] { (byte) 0x5f, (byte) 0x5f, + (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f }, + 0x5f5f5f5f5f5f5f5fL, true); } @Test public void testAddNameDiffOnSignedQWordDataUpperBit1PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new SignedQWordDataType(), new byte[] { - (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, - (byte) 0xad, (byte) 0xad }, 0xadadadadadadadadL, true); + runTestAddNameDiffPickIndicated( + "0x1002d24", new SignedQWordDataType(), new byte[] { (byte) 0xad, (byte) 0xad, + (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad }, + 0xadadadadadadadadL, true); } @Test public void testAddNameDiffOnSignedInt5DataUpperBit0PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new Integer5DataType(), new byte[] { - (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f }, 0x5f5f5f5f5fL, true); + runTestAddNameDiffPickIndicated("0x1002d24", new Integer5DataType(), + new byte[] { (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f }, + 0x5f5f5f5f5fL, true); } @Test public void testAddNameDiffOnSignedInt5DataUpperBit1PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new Integer5DataType(), new byte[] { - (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad }, 0xffffffadadadadadL, - true); + runTestAddNameDiffPickIndicated("0x1002d24", new Integer5DataType(), + new byte[] { (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad }, + 0xffffffadadadadadL, true); } @Test @@ -409,43 +413,48 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { @Test public void testAddNameDiffOnSignedInt7DataUpperBit0PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new Integer7DataType(), new byte[] { - (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, - (byte) 0x5f }, 0x5f5f5f5f5f5f5fL, true); + runTestAddNameDiffPickIndicated("0x1002d24", new Integer7DataType(), + new byte[] { (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, + (byte) 0x5f, (byte) 0x5f }, + 0x5f5f5f5f5f5f5fL, true); } @Test public void testAddNameDiffOnSignedInt7DataUpperBit1PickMy() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new Integer7DataType(), new byte[] { - (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, - (byte) 0xad }, 0xffadadadadadadadL, true); + runTestAddNameDiffPickIndicated("0x1002d24", new Integer7DataType(), + new byte[] { (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, + (byte) 0xad, (byte) 0xad }, + 0xffadadadadadadadL, true); } @Test public void testAddNameDiffOnSignedWordDataUpperBit0PickLatest() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new SignedWordDataType(), new byte[] { - (byte) 0x5f, (byte) 0x5f }, 0x5f5fL, false); + runTestAddNameDiffPickIndicated("0x1002d24", new SignedWordDataType(), + new byte[] { (byte) 0x5f, (byte) 0x5f }, 0x5f5fL, false); } @Test public void testAddNameDiffOnSignedQWordDataUpperBit0PickLatest() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new SignedQWordDataType(), new byte[] { - (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, - (byte) 0x5f, (byte) 0x5f }, 0x5f5f5f5f5f5f5f5fL, false); + runTestAddNameDiffPickIndicated( + "0x1002d24", new SignedQWordDataType(), new byte[] { (byte) 0x5f, (byte) 0x5f, + (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f, (byte) 0x5f }, + 0x5f5f5f5f5f5f5f5fL, false); } @Test public void testAddNameDiffOnSignedQWordDataUpperBit1PickLatest() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new SignedQWordDataType(), new byte[] { - (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, - (byte) 0xad, (byte) 0xad }, 0xadadadadadadadadL, false); + runTestAddNameDiffPickIndicated( + "0x1002d24", new SignedQWordDataType(), new byte[] { (byte) 0xad, (byte) 0xad, + (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad }, + 0xadadadadadadadadL, false); } @Test public void testAddNameDiffOnSignedInt5DataUpperBit1PickLatest() throws Exception { - runTestAddNameDiffPickIndicated("0x1002d24", new Integer5DataType(), new byte[] { - (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, - (byte) 0xad, (byte) 0xad }, 0xffffffadadadadadL, false); + runTestAddNameDiffPickIndicated( + "0x1002d24", new Integer5DataType(), new byte[] { (byte) 0xad, (byte) 0xad, (byte) 0xad, + (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad, (byte) 0xad }, + 0xffffffadadadadadL, false); } @Test @@ -476,10 +485,9 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { try { Listing listing = program.getListing(); Address startAddr = addr(program, "0x1002d20"); - program.getMemory().setBytes( - startAddr, - new byte[] { (byte) 0x8d, (byte) 0x04, (byte) 0x8d, (byte) 0x0, (byte) 0x0, - (byte) 0x0, (byte) 0x0 }); //LEA EAX,[0x0 + ECX*0x4] + program.getMemory() + .setBytes(startAddr, new byte[] { (byte) 0x8d, (byte) 0x04, (byte) 0x8d, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0 }); //LEA EAX,[0x0 + ECX*0x4] createInstruction(program, startAddr); Instruction instruction = listing.getInstructionAt(startAddr); Assert.assertTrue(instruction != null); @@ -491,7 +499,7 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { } finally { program.endTransaction(txId, commit); - } + } } @Override @@ -533,7 +541,7 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { } finally { program.endTransaction(txId, commit); - } + } } }); } @@ -571,19 +579,19 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { setupAddNameDiffOnSubOperand(); executeMerge(ASK_USER); + chooseEquate("0x1002d20", 1, KEEP_MY); // 0x4 Order seems to have been switched chooseEquate("0x1002d20", 1, KEEP_MY); // 0x0 - chooseEquate("0x1002d20", 1, KEEP_MY); // 0x4 waitForMergeCompletion(); EquateTable equateTab = resultProgram.getEquateTable(); List equates = equateTab.getEquates(addr("0x1002d20"), 1); assertEquals(2, equates.size()); Equate eq = equates.get(0); - assertEquals("ZERO", eq.getName()); - assertEquals(0L, eq.getValue()); - eq = equates.get(1); assertEquals("QUAD", eq.getName()); assertEquals(4L, eq.getValue()); + eq = equates.get(1); + assertEquals("ZERO", eq.getName()); + assertEquals(0L, eq.getValue()); } @Test @@ -595,33 +603,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { setupAddNameDiffOnSubOperand(); executeMerge(ASK_USER); - chooseEquate("0x1002d20", 1, KEEP_LATEST); // 0x0 - chooseEquate("0x1002d20", 1, KEEP_MY); // 0x4 - waitForMergeCompletion(); - - EquateTable equateTab = resultProgram.getEquateTable(); - List equates = equateTab.getEquates(addr("0x1002d20"), 1); - assertEquals(2, equates.size()); - Equate eq; - eq = equates.get(0); - assertEquals("NADA", eq.getName()); - assertEquals(0L, eq.getValue()); - eq = equates.get(1); - assertEquals("QUAD", eq.getName()); - assertEquals(4L, eq.getValue()); - } - - @Test - public void testAddNameDiffOnSubOperandPickMyLatest() throws Exception { - // 0x1002d20 LEA EAX,[0x0 + ECX*0x4] - // - // LATEST 0x0=NADA 0x4=FOUR - // MY 0x0=ZERO 0x4=QUAD - setupAddNameDiffOnSubOperand(); - - executeMerge(ASK_USER); - chooseEquate("0x1002d20", 1, KEEP_MY); // 0x0 chooseEquate("0x1002d20", 1, KEEP_LATEST); // 0x4 + chooseEquate("0x1002d20", 1, KEEP_MY); // 0x0 waitForMergeCompletion(); EquateTable equateTab = resultProgram.getEquateTable(); @@ -637,7 +620,32 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { } @Test - public void testAddSameNameDiffValue() throws Exception { + public void testAddNameDiffOnSubOperandPickMyLatest() throws Exception { + // 0x1002d20 LEA EAX,[0x0 + ECX*0x4] + // + // LATEST 0x0=NADA 0x4=FOUR + // MY 0x0=ZERO 0x4=QUAD + setupAddNameDiffOnSubOperand(); + + executeMerge(ASK_USER); + chooseEquate("0x1002d20", 1, KEEP_MY); // 0x4 + chooseEquate("0x1002d20", 1, KEEP_LATEST); // 0x0 + waitForMergeCompletion(); + + EquateTable equateTab = resultProgram.getEquateTable(); + List equates = equateTab.getEquates(addr("0x1002d20"), 1); + assertEquals(2, equates.size()); + Equate eq; + eq = equates.get(0); + assertEquals("NADA", eq.getName()); + assertEquals(0L, eq.getValue()); + eq = equates.get(1); + assertEquals("QUAD", eq.getName()); + assertEquals(4L, eq.getValue()); + } + + @Test + public void testAddSameNameDiffValue() throws Exception { mtf.initialize("NotepadMergeListingTest", new ProgramModifierListener() { /* (non-Javadoc) @@ -703,8 +711,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { assertEquals(1L, eq.getValue()); } -@Test - public void testAddSameNameDiffValueWithResolve() throws Exception { + @Test + public void testAddSameNameDiffValueWithResolve() throws Exception { mtf.initialize("NotepadMergeListingTest", new ProgramModifierListener() { /* (non-Javadoc) @@ -808,8 +816,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { }); } -@Test - public void testChangeEquateUseForAllPickLatest() throws Exception { + @Test + public void testChangeEquateUseForAllPickLatest() throws Exception { setupUseForAll(); executeMerge(ASK_USER); @@ -832,8 +840,8 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest { assertEquals(1L, eq.getValue()); } -@Test - public void testChangeEquateUseForAllPickMy() throws Exception { + @Test + public void testChangeEquateUseForAllPickMy() throws Exception { setupUseForAll(); executeMerge(ASK_USER); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/calltree/CallTreePluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/calltree/CallTreePluginTest.java index f90100563b..a1e3d67af5 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/calltree/CallTreePluginTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/calltree/CallTreePluginTest.java @@ -421,7 +421,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { // more incoming calls. // - myWaitForTree(incomingTree, provider); + waitForTree(incomingTree); GTreeNode rootNode = getRootNode(incomingTree); List children = rootNode.getChildren(); assertTrue( @@ -430,7 +430,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { GTreeNode child0 = children.get(0); incomingTree.expandPath(child0); - myWaitForTree(incomingTree, provider); + waitForTree(incomingTree); List grandChildren = child0.getChildren(); assertTrue("Incoming tree child does not have callers as expected for child: " + child0, @@ -441,7 +441,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { public void testOutgoingCalls() { setProviderFunction("0x5000"); - myWaitForTree(outgoingTree, provider); + waitForTree(outgoingTree); GTreeNode rootNode = getRootNode(outgoingTree); List children = rootNode.getChildren(); assertTrue( @@ -450,7 +450,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { GTreeNode child1 = children.get(1); outgoingTree.expandPath(child1); - myWaitForTree(outgoingTree, provider); + waitForTree(outgoingTree); List grandChildren = child1.getChildren(); assertTrue("Outgoing tree child does not have callers as expected for child: " + child1, @@ -461,7 +461,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { public void testGoToFromNode() { setProviderFunction("0x5000"); - myWaitForTree(outgoingTree, provider); + waitForTree(outgoingTree); GTreeNode rootNode = getRootNode(outgoingTree); List children = rootNode.getChildren(); assertTrue( @@ -472,7 +472,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { GTreeNode child1 = children.get(1);// skip the first child--it is an external function outgoingTree.setSelectedNode(child1); - myWaitForTree(outgoingTree, provider); + waitForTree(outgoingTree); ActionContext actionContext = new ActionContext(provider, outgoingTree); DockingActionIf goToAction = getAction("Go To Destination"); @@ -502,7 +502,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { ProgramSelection currentSelection = codeBrowserPlugin.getCurrentSelection(); assertTrue(currentSelection.isEmpty()); - myWaitForTree(outgoingTree, provider); + waitForTree(outgoingTree); GTreeNode rootNode = getRootNode(outgoingTree); List children = rootNode.getChildren(); assertTrue( @@ -587,7 +587,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { performAction(filterDuplicatesAction, true); } - myWaitForTree(outgoingTree, provider); + waitForTree(outgoingTree); GTreeNode rootNode = getRootNode(outgoingTree); List children = rootNode.getChildren(); assertTrue( @@ -598,6 +598,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { // no duplicates boolean shouldHaveDuplicates = false; Map nameCountMap = createNameCountMap(rootNode); + System.out.println("nameCountMap: before: = " + nameCountMap); assertDuplicateChildStatus(nameCountMap, shouldHaveDuplicates); performAction(filterDuplicatesAction, true);// deselect @@ -607,6 +608,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { rootNode = getRootNode(outgoingTree); nameCountMap = createNameCountMap(rootNode); shouldHaveDuplicates = true; + System.out.println("nameCountMap: after: = " + nameCountMap); assertDuplicateChildStatus(nameCountMap, shouldHaveDuplicates); } @@ -627,7 +629,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { performAction(navigateAction, true); } - myWaitForTree(outgoingTree, provider); + waitForTree(outgoingTree); GTreeNode rootNode = getRootNode(outgoingTree); List children = rootNode.getChildren(); assertTrue( @@ -697,7 +699,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { setProviderFunction(addrString); - myWaitForTree(incomingTree, provider); + waitForTree(incomingTree); GTreeNode rootNode = getRootNode(incomingTree); List children = rootNode.getChildren(); assertTrue("Incoming tree does not have callers as expected for function: " + addrString, @@ -712,7 +714,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { // setProviderFunction("0x5000"); - myWaitForTree(incomingTree, provider); + waitForTree(incomingTree); GTreeNode rootNode = getRootNode(incomingTree); List children = rootNode.getChildren(); assertTrue( @@ -743,7 +745,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { public void testRenamingIncomingRootFunction() { setProviderFunction("0x5000"); - myWaitForTree(incomingTree, provider); + waitForTree(incomingTree); GTreeNode rootNode = getRootNode(incomingTree); List children = rootNode.getChildren(); assertTrue( @@ -804,7 +806,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { } private GTreeNode getRootNode(final GTree tree, boolean filtered) { - myWaitForTree(tree, provider); + waitForTree(tree); final AtomicReference ref = new AtomicReference<>(); runSwing(() -> ref.set(filtered ? tree.getViewRoot() : tree.getModelRoot())); return ref.get(); @@ -874,7 +876,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { private void setOutgoingFilter(final String text) { runSwing(() -> provider.setOutgoingFilter(text)); - myWaitForTree(outgoingTree, provider); + waitForTree(outgoingTree); } private void setProviderFunction(String address) { @@ -1040,7 +1042,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { private void setIncomingFilter(final String text) { runSwing(() -> provider.setIncomingFilter(text)); - myWaitForTree(incomingTree, provider); + waitForTree(incomingTree); } private void setDepth(final int depth) { @@ -1114,32 +1116,6 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest { return action; } - private void myWaitForTree(GTree gTree, CallTreeProvider treeProvider) { - waitForSwing(); - - boolean didWait = false; - while (gTree.isBusy()) { - didWait = true; - try { - Thread.sleep(50); - } - catch (Exception e) { - // who cares? - } - } - - waitForSwing(); - if (didWait) { - // The logic here is that if we ever had to wait for the tree, then some other events - // may have been buffered while we were allowing the work to happen. Just to be sure - // that there are no buffered actions, lets try to wait again. If things are really - // settled down, then the extra call to wait should not have any effect. This 'try - // again' approach is an effort to catch update calls that can be schedule by actions - // from the Swing thread, which the test thread does not handle flawlessly. - myWaitForTree(gTree, treeProvider); - } - } - /** * Shows and returns a provider for the specified address. */ diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/GoToPluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/GoToPluginTest.java index 52d02a27fa..e21b10d24b 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/GoToPluginTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/GoToPluginTest.java @@ -772,7 +772,7 @@ public class GoToPluginTest extends AbstractGhidraHeadedIntegrationTest { private void setOptionToAllowNavigationToOtherOpenPrograms() throws Exception { runSwing(() -> { ToolOptions options = tool.getOptions("Navigation"); - options.setBoolean("'Go To' in current program only", false); + options.setBoolean("'Go To' in Current Program Only", false); }); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/script/AbstractGhidraScriptMgrPluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/script/AbstractGhidraScriptMgrPluginTest.java index 5879379c90..c10751dd25 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/script/AbstractGhidraScriptMgrPluginTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/script/AbstractGhidraScriptMgrPluginTest.java @@ -1072,13 +1072,13 @@ public abstract class AbstractGhidraScriptMgrPluginTest protected void assertSaveButtonEnabled() { waitForSwing(); DockingActionIf saveAction = getAction(plugin, "Save Script"); - assertTrue(saveAction.isEnabled()); + assertTrue(saveAction.isEnabledForContext(editor.getActionContext(null))); } protected void assertSaveButtonDisabled() { waitForSwing(); DockingActionIf saveAction = getAction(plugin, "Save Script"); - assertFalse(saveAction.isEnabled()); + assertFalse(saveAction.isEnabledForContext(editor.getActionContext(null))); assertEditorHasNoChanges(); } diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/symbol/SymbolDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/symbol/SymbolDB.java index 88ca23bc6c..73bfbb8689 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/symbol/SymbolDB.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/symbol/SymbolDB.java @@ -662,7 +662,7 @@ public abstract class SymbolDB extends DatabaseObject implements Symbol { } Symbol s = (Symbol) obj; - if (getID() == s.getID()) { + if (hasSameId(s)) { return true; } @@ -682,6 +682,13 @@ public abstract class SymbolDB extends DatabaseObject implements Symbol { return SystemUtilities.isEqual(myParent, otherParent); } + private boolean hasSameId(Symbol s) { + if (getID() == s.getID()) { + return getProgram() == s.getProgram(); + } + return false; + } + @Override public int hashCode() { return (int) key;