Ghidra is a software reverse engineering (SRE) framework
Tests - fixed CallNodes to correctly allow duplicates
dragonmacher063358fc277a
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/CallNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/CallNode.javaindex 55db539d2f..a52185d5d4 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/CallNode.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/CallNode.java@@ -48,11 +48,13 @@ public abstract class CallNode extends GTreeSlowLoadingNode {/*** Returns a location that represents the caller of the callee.+ * @return the location*/public abstract ProgramLocation getLocation();/*** Returns the address that for the caller of the callee.+ * @return the address*/public abstract Address getSourceAddress();@@ -83,34 +85,23 @@ public abstract class CallNode extends GTreeSlowLoadingNode {}/**- * Signals that this node should not override the equals method to treat all nodes with the- * same name as the same. When the user wants to see duplicates, each node should rely on- * Java's default notion of equality; otherwise, the JTree goes out to lunch.+ * True allows this node to contains children with the same name+ *+ * @param allowDuplicates true to allow duplicate nodes*/protected void setAllowsDuplicates(boolean allowDuplicates) {this.allowDuplicates = allowDuplicates;}- @Override- public boolean equals(Object other) {+ protected void addNode(List<GTreeNode> nodes, GTreeNode node) {if (allowDuplicates) {- return super.equals(other);- }-- if (other == this) {- return true;+ nodes.add(node);+ return;}- if (other == null) {- return false;+ if (!nodes.contains(node)) {+ nodes.add(node);}-- if (!getClass().equals(other.getClass())) {- return false;- }-- CallNode otherCallNode = (CallNode) other;- return getName().equals(otherCallNode.getName());}protected class CallNodeComparator implements Comparator<GTreeNode> {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/IncomingCallNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/IncomingCallNode.javaindex 28df828fbd..f8b27381ce 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/IncomingCallNode.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/IncomingCallNode.java@@ -91,13 +91,13 @@ public class IncomingCallNode extends CallNode {for (Address fromAddress : addresses) {monitor.checkCanceled();Function callerFunction = functionManager.getFunctionContaining(fromAddress);- if (callerFunction != null) {- IncomingCallNode node = new IncomingCallNode(program, callerFunction, fromAddress,- filterDuplicates, filterDepth);- if (!nodes.contains(node)) {- nodes.add(node);- }+ if (callerFunction == null) {+ continue;}++ IncomingCallNode node = new IncomingCallNode(program, callerFunction, fromAddress,+ filterDuplicates, filterDepth);+ addNode(nodes, node);}Collections.sort(nodes, new CallNodeComparator());diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/OutgoingCallNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/OutgoingCallNode.javaindex bef2055104..080c3bd2b0 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/OutgoingCallNode.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/calltree/OutgoingCallNode.java@@ -148,12 +148,6 @@ public abstract class OutgoingCallNode extends CallNode {return calledFunction.isExternal();}- private void addNode(List<GTreeNode> nodes, GTreeNode node) {- if (!nodes.contains(node)) {- nodes.add(node);- }- }-private boolean isCallReference(Reference reference) {RefType type = reference.getReferenceType();if (type.isCall()) {