mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-3212 - Function Graph - fixed exception when a function's entry point
vertex was not correctly marked as such
This commit is contained in:
parent
bb27721a1f
commit
cf905d6fe9
3 changed files with 14 additions and 6 deletions
|
@ -479,7 +479,7 @@ public class FunctionGraph extends GroupingVisualGraph<FGVertex, FGEdge> {
|
||||||
HashSet<FGVertex> result = new LinkedHashSet<>();
|
HashSet<FGVertex> result = new LinkedHashSet<>();
|
||||||
for (FGVertex vertex : getVertices()) {
|
for (FGVertex vertex : getVertices()) {
|
||||||
FGVertexType vertexType = vertex.getVertexType();
|
FGVertexType vertexType = vertex.getVertexType();
|
||||||
if (vertexType.isEntry()) {
|
if (vertex.isEntry()) {
|
||||||
result.add(vertex);
|
result.add(vertex);
|
||||||
}
|
}
|
||||||
else if (vertexType == FGVertexType.GROUP) {
|
else if (vertexType == FGVertexType.GROUP) {
|
||||||
|
@ -495,7 +495,7 @@ public class FunctionGraph extends GroupingVisualGraph<FGVertex, FGEdge> {
|
||||||
Set<FGVertex> groupVertices = vertex.getVertices();
|
Set<FGVertex> groupVertices = vertex.getVertices();
|
||||||
for (FGVertex groupedVertex : groupVertices) {
|
for (FGVertex groupedVertex : groupVertices) {
|
||||||
FGVertexType vertexType = groupedVertex.getVertexType();
|
FGVertexType vertexType = groupedVertex.getVertexType();
|
||||||
if (vertexType.isEntry()) {
|
if (vertex.isEntry()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (vertexType == FGVertexType.GROUP) {
|
else if (vertexType == FGVertexType.GROUP) {
|
||||||
|
|
|
@ -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.FGVertex;
|
||||||
import ghidra.app.plugin.core.functiongraph.graph.vertex.ListingFunctionGraphVertex;
|
import ghidra.app.plugin.core.functiongraph.graph.vertex.ListingFunctionGraphVertex;
|
||||||
import ghidra.app.plugin.core.functiongraph.mvc.*;
|
import ghidra.app.plugin.core.functiongraph.mvc.*;
|
||||||
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.address.AddressSetView;
|
import ghidra.program.model.address.AddressSetView;
|
||||||
import ghidra.program.model.block.*;
|
import ghidra.program.model.block.*;
|
||||||
import ghidra.program.model.listing.Function;
|
import ghidra.program.model.listing.Function;
|
||||||
|
@ -131,6 +132,7 @@ public class FunctionGraphFactory {
|
||||||
*
|
*
|
||||||
* @param function the function to graph
|
* @param function the function to graph
|
||||||
* @param controller the controller needed by the function graph
|
* @param controller the controller needed by the function graph
|
||||||
|
* @param program the function's program
|
||||||
* @param monitor the task monitor
|
* @param monitor the task monitor
|
||||||
* @return the new graph
|
* @return the new graph
|
||||||
* @throws CancelledException if the task is cancelled via the monitor
|
* @throws CancelledException if the task is cancelled via the monitor
|
||||||
|
@ -313,6 +315,10 @@ public class FunctionGraphFactory {
|
||||||
|
|
||||||
FlowType flowType = codeBlock.getFlowType();
|
FlowType flowType = codeBlock.getFlowType();
|
||||||
boolean isEntry = isEntry(codeBlock);
|
boolean isEntry = isEntry(codeBlock);
|
||||||
|
Address cbStart = codeBlock.getFirstStartAddress();
|
||||||
|
if (cbStart.equals(function.getEntryPoint())) {
|
||||||
|
isEntry = true;
|
||||||
|
}
|
||||||
|
|
||||||
FGVertex vertex =
|
FGVertex vertex =
|
||||||
new ListingFunctionGraphVertex(controller, codeBlock, flowType, isEntry);
|
new ListingFunctionGraphVertex(controller, codeBlock, flowType, isEntry);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public abstract class AbstractFunctionGraphVertex implements FGVertex {
|
||||||
this.location = new Point2D.Double();
|
this.location = new Point2D.Double();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy constructor */
|
/* Copy constructor */
|
||||||
AbstractFunctionGraphVertex(FGController controller, AbstractFunctionGraphVertex vertex) {
|
AbstractFunctionGraphVertex(FGController controller, AbstractFunctionGraphVertex vertex) {
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
this.program = vertex.program;
|
this.program = vertex.program;
|
||||||
|
@ -154,8 +154,8 @@ public abstract class AbstractFunctionGraphVertex implements FGVertex {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsProgramLocation(ProgramLocation location) {
|
public boolean containsProgramLocation(ProgramLocation pl) {
|
||||||
return addressSet.contains(location.getAddress());
|
return addressSet.contains(pl.getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -210,7 +210,9 @@ public abstract class AbstractFunctionGraphVertex implements FGVertex {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEntry() {
|
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
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue