mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-3101 - Function Graph - fixed exception when hovering on the root
node when it has incoming edges
This commit is contained in:
parent
cf47a2ee57
commit
f4a7def733
4 changed files with 74 additions and 1 deletions
|
@ -50,6 +50,7 @@ public class FGPrimaryViewer extends GraphViewer<FGVertex, FGEdge> {
|
||||||
|
|
||||||
return new VisualGraphPathHighlighter<>(getVisualGraph(), listener) {
|
return new VisualGraphPathHighlighter<>(getVisualGraph(), listener) {
|
||||||
|
|
||||||
|
@Override
|
||||||
protected GDirectedGraph<FGVertex, FGEdge> getDominanceGraph(
|
protected GDirectedGraph<FGVertex, FGEdge> getDominanceGraph(
|
||||||
VisualGraph<FGVertex, FGEdge> graph, boolean forward) {
|
VisualGraph<FGVertex, FGEdge> graph, boolean forward) {
|
||||||
|
|
||||||
|
|
|
@ -604,7 +604,7 @@ public class FunctionGraph extends GroupingVisualGraph<FGVertex, FGEdge> {
|
||||||
for (FGVertex entry : entries) {
|
for (FGVertex entry : entries) {
|
||||||
AbstractFunctionGraphVertex abstractVertex = (AbstractFunctionGraphVertex) entry;
|
AbstractFunctionGraphVertex abstractVertex = (AbstractFunctionGraphVertex) entry;
|
||||||
FGController controller = abstractVertex.getController();
|
FGController controller = abstractVertex.getController();
|
||||||
ListingFunctionGraphVertex newEntry = new ListingFunctionGraphVertex(controller,
|
ListingFunctionGraphVertex newEntry = new DummyListingFGVertex(controller,
|
||||||
abstractVertex.getAddresses(), RefType.UNCONDITIONAL_JUMP, true);
|
abstractVertex.getAddresses(), RefType.UNCONDITIONAL_JUMP, true);
|
||||||
newEntry.setVertexType(FGVertexType.ENTRY);
|
newEntry.setVertexType(FGVertexType.ENTRY);
|
||||||
FGVertex groupVertex = getVertexForAddress(entry.getVertexAddress());
|
FGVertex groupVertex = getVertexForAddress(entry.getVertexAddress());
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package ghidra.app.plugin.core.functiongraph.graph.vertex;
|
||||||
|
|
||||||
|
import ghidra.app.plugin.core.functiongraph.mvc.FGController;
|
||||||
|
import ghidra.program.model.address.AddressSetView;
|
||||||
|
import ghidra.program.model.symbol.FlowType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A vertex that is used as a temporary placeholder for graph algorithms that require a
|
||||||
|
* particular structure, such as having a source or sink
|
||||||
|
*/
|
||||||
|
public class DummyListingFGVertex extends ListingFunctionGraphVertex {
|
||||||
|
|
||||||
|
public DummyListingFGVertex(FGController controller, AddressSetView addressSet,
|
||||||
|
FlowType flowType, boolean isEntry) {
|
||||||
|
super(controller, addressSet, flowType, isEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Dummy " + super.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return this == obj;
|
||||||
|
}
|
||||||
|
}
|
|
@ -447,6 +447,36 @@ public class FunctionGraphGroupVertices2Test extends AbstractFunctionGraphTest {
|
||||||
assertHovered(edges);
|
assertHovered(edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFindForwardScopedFlow_WithoutGroup_IncomingEdgeToRoot() {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Test the case that an ungrouped graph does not throw an exception if the root node
|
||||||
|
// is hovered when it has incoming edges.
|
||||||
|
//
|
||||||
|
|
||||||
|
create12345GraphWithTransaction();
|
||||||
|
|
||||||
|
FGVertex entry = vertex("100415a");
|
||||||
|
FGVertex v2 = vertex("1004178");
|
||||||
|
|
||||||
|
FunctionGraph graph = getFunctionGraph();
|
||||||
|
FGEdgeImpl edge = new FGEdgeImpl(v2, entry, RefType.UNCONDITIONAL_JUMP, graph.getOptions());
|
||||||
|
graph.addEdge(edge);
|
||||||
|
|
||||||
|
FGComponent graphComponent = getGraphComponent();
|
||||||
|
VisualGraphPathHighlighter<FGVertex, FGEdge> pathHighlighter =
|
||||||
|
graphComponent.getPathHighlighter();
|
||||||
|
pathHighlighter.setHoveredVertex(entry);
|
||||||
|
waitForPathHighligter();
|
||||||
|
|
||||||
|
Collection<FGEdge> edges = graph.getEdges();
|
||||||
|
assertHovered(edges);
|
||||||
|
|
||||||
|
pathHighlighter.setHoveredVertex(null);
|
||||||
|
assertHovered(Collections.emptySet());
|
||||||
|
}
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
// Private Methods
|
// Private Methods
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue