GP-256 - Graphing - fixed AST graph exceptions

This commit is contained in:
dragonmacher 2020-10-28 17:52:12 -04:00
parent 7764f965be
commit edc8efdbf6
7 changed files with 51 additions and 31 deletions

View file

@ -106,7 +106,7 @@ public class BlockGraphTask extends Task {
private CodeBlockModel blockModel;
private AddressSetView selection;
private ProgramLocation location;
private GraphDisplayProvider graphService;
private GraphDisplayProvider graphProvider;
private boolean reuseGraph;
private boolean appendGraph;
private PluginTool tool;
@ -116,7 +116,7 @@ public class BlockGraphTask extends Task {
public BlockGraphTask(String actionName, boolean graphEntryPointNexus, boolean showCode,
boolean reuseGraph, boolean appendGraph, PluginTool tool, ProgramSelection selection,
ProgramLocation location, CodeBlockModel blockModel,
GraphDisplayProvider graphService) {
GraphDisplayProvider graphProvider) {
super("Graph Program", true, false, true);
this.actionName = actionName;
@ -127,7 +127,7 @@ public class BlockGraphTask extends Task {
this.appendGraph = appendGraph;
this.tool = tool;
this.blockModel = blockModel;
this.graphService = graphService;
this.graphProvider = graphProvider;
this.colorizingService = tool.getService(ColorizingService.class);
this.selection = selection;
this.location = location;
@ -142,7 +142,7 @@ public class BlockGraphTask extends Task {
AttributedGraph graph = createGraph();
monitor.setMessage("Generating Graph...");
try {
GraphDisplay display = graphService.getGraphDisplay(reuseGraph, monitor);
GraphDisplay display = graphProvider.getGraphDisplay(reuseGraph, monitor);
BlockModelGraphDisplayListener listener =
new BlockModelGraphDisplayListener(tool, blockModel, display);
display.setGraphDisplayListener(listener);

View file

@ -30,6 +30,10 @@ import ghidra.program.model.mem.MemoryAccessException;
import ghidra.test.*;
public class AbstractBlockGraphTest extends AbstractGhidraHeadedIntegrationTest {
protected static final String CALLER_FUNCTION_ADDRESS = "01002200";
protected static final String SIMPLE_FUNCTION_ADDRESS = "01002239";
protected PluginTool tool;
protected ProgramDB program;
protected TestEnv env;
@ -37,10 +41,6 @@ public class AbstractBlockGraphTest extends AbstractGhidraHeadedIntegrationTest
private ToyProgramBuilder builder;
protected CodeBrowserPlugin codeBrowser;
protected Address addr(long addr) {
return builder.getAddress(addr);
}
@Before
public void setUp() throws Exception {
@ -50,7 +50,6 @@ public class AbstractBlockGraphTest extends AbstractGhidraHeadedIntegrationTest
tool = env.getTool();
initializeTool();
}
@After
@ -80,14 +79,15 @@ public class AbstractBlockGraphTest extends AbstractGhidraHeadedIntegrationTest
builder = new ToyProgramBuilder("sample", true);
builder.createMemory("caller", "0x01002200", 8);
builder.createMemory("simple", "0x01002239", 8);
builder.createMemory("not_graphed", "0x01002300", 8);
buildCallerFunction(builder);
buildSimpleFunction(builder);
buildCallerFunction();
buildSimpleFunction();
program = builder.getProgram();
}
private void buildCallerFunction(ToyProgramBuilder builder) throws MemoryAccessException {
private void buildCallerFunction() throws MemoryAccessException {
// just a function that calls another
builder.addBytesNOP("0x01002200", 1);
builder.addBytesCall("0x01002201", "0x01002239");// jump to C
@ -98,7 +98,7 @@ public class AbstractBlockGraphTest extends AbstractGhidraHeadedIntegrationTest
builder.createLabel("0x01002200", "entry");// function label
}
private void buildSimpleFunction(ToyProgramBuilder builder) throws MemoryAccessException {
private void buildSimpleFunction() throws MemoryAccessException {
// just a function to render in the graph so that we can clear out settings/cache
// 01002239
@ -128,4 +128,12 @@ public class AbstractBlockGraphTest extends AbstractGhidraHeadedIntegrationTest
builder.createLabel("0x01002239", "simple");// function label
}
protected Address addr(long addr) {
return builder.getAddress(addr);
}
protected Address addr(String addressString) {
return builder.addr(addressString);
}
}