mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-2848: Refactor DependencyGraph with Deterministic version
This commit is contained in:
parent
dace9682fb
commit
fa558af9c2
11 changed files with 744 additions and 343 deletions
|
@ -27,7 +27,7 @@ import ghidra.program.model.*;
|
|||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.symbol.ReferenceManager;
|
||||
import ghidra.util.graph.DependencyGraph;
|
||||
import ghidra.util.graph.AbstractDependencyGraph;
|
||||
|
||||
public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
node(3, 4);
|
||||
|
||||
AcyclicCallGraphBuilder builder = new AcyclicCallGraphBuilder(program, functions, false);
|
||||
DependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
AbstractDependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
|
||||
Assert.assertEquals(4, graph.size());
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
node(2,3);
|
||||
|
||||
AcyclicCallGraphBuilder builder = new AcyclicCallGraphBuilder(program,functions,false);
|
||||
DependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
AbstractDependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
|
||||
Assert.assertEquals(3, graph.size());
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
node(3, 1);
|
||||
|
||||
AcyclicCallGraphBuilder builder = new AcyclicCallGraphBuilder(program, functions, false);
|
||||
DependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
AbstractDependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
|
||||
Assert.assertEquals(3, graph.size());
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
node(2, 2);
|
||||
|
||||
AcyclicCallGraphBuilder builder = new AcyclicCallGraphBuilder(program, functions, false);
|
||||
DependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
AbstractDependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
|
||||
Assert.assertEquals(3, graph.size());
|
||||
|
||||
|
@ -168,7 +168,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
node(3, 1);
|
||||
|
||||
AcyclicCallGraphBuilder builder = new AcyclicCallGraphBuilder(program, functions, false);
|
||||
DependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
AbstractDependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
|
||||
Assert.assertEquals(3, graph.size());
|
||||
|
||||
|
@ -197,7 +197,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
thunkNode(17, 18, false);
|
||||
|
||||
AcyclicCallGraphBuilder builder = new AcyclicCallGraphBuilder(program, functions, false);
|
||||
DependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
AbstractDependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
|
||||
Assert.assertEquals(18, graph.size());
|
||||
|
||||
|
@ -241,7 +241,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
thunkNode(17, 18, false);
|
||||
|
||||
AcyclicCallGraphBuilder builder = new AcyclicCallGraphBuilder(program, functions, true);
|
||||
DependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
AbstractDependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
|
||||
Assert.assertEquals(8, graph.size());
|
||||
|
||||
|
@ -265,7 +265,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
|
||||
thunkNode(5, 3, true); // Thunk node hits recursion from different point
|
||||
AcyclicCallGraphBuilder builder = new AcyclicCallGraphBuilder(program, functions, true);
|
||||
DependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
AbstractDependencyGraph<Address> graph = builder.getDependencyGraph(DUMMY_MONITOR);
|
||||
|
||||
Assert.assertEquals(4, graph.size());
|
||||
assertDependents(graph, 2, 1);
|
||||
|
@ -274,7 +274,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
|
|||
Assert.assertFalse(graph.hasCycles());
|
||||
}
|
||||
|
||||
private void assertDependents(DependencyGraph<Address> graph, int fromID, int... toIDs) {
|
||||
private void assertDependents(AbstractDependencyGraph<Address> graph, int fromID, int... toIDs) {
|
||||
Set<Address> expectedSet = new HashSet<Address>();
|
||||
for (int toAddr : toIDs) {
|
||||
expectedSet.add(functionAddress(toAddr));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue