mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GT-0 fixed miscellaneous tests failing
This commit is contained in:
parent
0109c9e8d8
commit
20f5f53778
6 changed files with 140 additions and 146 deletions
|
@ -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;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package ghidra.app.merge.listing;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<Equate> 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<Equate> 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();
|
||||
|
@ -636,6 +619,31 @@ public class EquateMergeManager1Test extends AbstractListingMergeManagerTest {
|
|||
assertEquals(0L, 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); // 0x4
|
||||
chooseEquate("0x1002d20", 1, KEEP_LATEST); // 0x0
|
||||
waitForMergeCompletion();
|
||||
|
||||
EquateTable equateTab = resultProgram.getEquateTable();
|
||||
List<Equate> 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() {
|
||||
|
|
|
@ -421,7 +421,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
// more incoming calls.
|
||||
//
|
||||
|
||||
myWaitForTree(incomingTree, provider);
|
||||
waitForTree(incomingTree);
|
||||
GTreeNode rootNode = getRootNode(incomingTree);
|
||||
List<GTreeNode> 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<GTreeNode> 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<GTreeNode> 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<GTreeNode> 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<GTreeNode> 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<GTreeNode> 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<GTreeNode> children = rootNode.getChildren();
|
||||
assertTrue(
|
||||
|
@ -598,6 +598,7 @@ public class CallTreePluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
// no duplicates
|
||||
boolean shouldHaveDuplicates = false;
|
||||
Map<String, Integer> 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<GTreeNode> 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<GTreeNode> 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<GTreeNode> 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<GTreeNode> 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<GTreeNode> 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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue