GT-3212 - Function Graph - fixed exception when a function's entry point

vertex was not correctly marked as such
This commit is contained in:
dragonmacher 2019-10-03 11:28:17 -04:00
parent bb27721a1f
commit cf905d6fe9
3 changed files with 14 additions and 6 deletions

View file

@ -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) {

View file

@ -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);

View file

@ -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 {
@Override
public 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