Ghidra is a software reverse engineering (SRE) framework
GT-3212 - Function Graph - fixed exception when a function's entry point vertex was not correctly marked as such
dragonmachercf905d6fe928
diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraph.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraph.javaindex f54adb0b36..bf32398794 100644--- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraph.java+++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraph.java@@ -479,7 +479,7 @@ public class FunctionGraph extends GroupingVisualGraph<FGVertex, FGEdge> {HashSet<FGVertex> result = new LinkedHashSet<>();for (FGVertex vertex : getVertices()) {FGVertexType vertexType = vertex.getVertexType();- if (vertexType.isEntry()) {+ if (vertex.isEntry()) {result.add(vertex);}else if (vertexType == FGVertexType.GROUP) {@@ -495,7 +495,7 @@ public class FunctionGraph extends GroupingVisualGraph<FGVertex, FGEdge> {Set<FGVertex> groupVertices = vertex.getVertices();for (FGVertex groupedVertex : groupVertices) {FGVertexType vertexType = groupedVertex.getVertexType();- if (vertexType.isEntry()) {+ if (vertex.isEntry()) {return true;}else if (vertexType == FGVertexType.GROUP) {diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraphFactory.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraphFactory.javaindex 463ae3be01..8147120f83 100644--- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraphFactory.java+++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraphFactory.java@@ -27,6 +27,7 @@ import ghidra.app.plugin.core.functiongraph.graph.layout.*;import ghidra.app.plugin.core.functiongraph.graph.vertex.FGVertex;import ghidra.app.plugin.core.functiongraph.graph.vertex.ListingFunctionGraphVertex;import ghidra.app.plugin.core.functiongraph.mvc.*;+import ghidra.program.model.address.Address;import ghidra.program.model.address.AddressSetView;import ghidra.program.model.block.*;import ghidra.program.model.listing.Function;@@ -131,6 +132,7 @@ public class FunctionGraphFactory {** @param function the function to graph* @param controller the controller needed by the function graph+ * @param program the function's program* @param monitor the task monitor* @return the new graph* @throws CancelledException if the task is cancelled via the monitor@@ -313,6 +315,10 @@ public class FunctionGraphFactory {FlowType flowType = codeBlock.getFlowType();boolean isEntry = isEntry(codeBlock);+ Address cbStart = codeBlock.getFirstStartAddress();+ if (cbStart.equals(function.getEntryPoint())) {+ isEntry = true;+ }FGVertex vertex =new ListingFunctionGraphVertex(controller, codeBlock, flowType, isEntry);diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/vertex/AbstractFunctionGraphVertex.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/vertex/AbstractFunctionGraphVertex.javaindex ea63219c88..409ad5b4dc 100644--- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/vertex/AbstractFunctionGraphVertex.java+++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/vertex/AbstractFunctionGraphVertex.java@@ -74,7 +74,7 @@ public abstract class AbstractFunctionGraphVertex implements FGVertex {this.location = new Point2D.Double();}- /** Copy constructor */+ /* Copy constructor */AbstractFunctionGraphVertex(FGController controller, AbstractFunctionGraphVertex vertex) {this.controller = controller;this.program = vertex.program;@@ -154,8 +154,8 @@ public abstract class AbstractFunctionGraphVertex implements FGVertex {}@Override- public boolean containsProgramLocation(ProgramLocation location) {- return addressSet.contains(location.getAddress());+ public boolean containsProgramLocation(ProgramLocation pl) {+ return addressSet.contains(pl.getAddress());}@Override@@ -210,7 +210,9 @@ public abstract class AbstractFunctionGraphVertex implements FGVertex {@Overridepublic boolean isEntry() {- return isEntry;+ // note: not sure if we need the second check; this check will catch any case where+ // the vertex was manually marked as an entry+ return isEntry || (vertexType != null && vertexType.isEntry());}@Override