GP-3250 changed default call graph action to always use "Isolated Entry"

block model
This commit is contained in:
ghidragon 2023-03-23 15:35:00 -04:00
parent acb07dd535
commit a48d7f8b50
2 changed files with 81 additions and 79 deletions

View file

@ -141,13 +141,13 @@ public class BlockGraphTask extends Task {
java.util.function.Function<AttributedVertex, Address> addressFunction) { java.util.function.Function<AttributedVertex, Address> addressFunction) {
display.addAction(new ActionBuilder("Rename Symbol", "Block Graph") display.addAction(new ActionBuilder("Rename Symbol", "Block Graph")
.popupMenuPath("Rename Symbol") .popupMenuPath("Rename Symbol")
.withContext(VertexGraphActionContext.class) .withContext(VertexGraphActionContext.class)
.helpLocation(new HelpLocation("ProgramGraphPlugin", "Rename_Symbol")) .helpLocation(new HelpLocation("ProgramGraphPlugin", "Rename_Symbol"))
// only enable action when vertex corresponds to an address // only enable action when vertex corresponds to an address
.enabledWhen(c -> addressFunction.apply(c.getClickedVertex()) != null) .enabledWhen(c -> addressFunction.apply(c.getClickedVertex()) != null)
.onAction(c -> updateVertexName(addressFunction, c)) .onAction(c -> updateVertexName(addressFunction, c))
.build()); .build());
} }
private void updateVertexName( private void updateVertexName(
@ -231,16 +231,18 @@ public class BlockGraphTask extends Task {
AddressSet set = new AddressSet(); AddressSet set = new AddressSet();
set.add(function.getBody()); set.add(function.getBody());
try { try {
CodeBlock block = blockModel.getCodeBlockAt(function.getEntryPoint(), taskMonitor); for (CodeBlock block : blockModel.getCodeBlocksContaining(function.getEntryPoint(),
CodeBlockReferenceIterator it = blockModel.getDestinations(block, taskMonitor); taskMonitor)) {
while (it.hasNext()) { CodeBlockReferenceIterator it = blockModel.getDestinations(block, taskMonitor);
CodeBlockReference next = it.next(); while (it.hasNext()) {
set.add(next.getDestinationBlock()); CodeBlockReference next = it.next();
} set.add(next.getDestinationBlock());
it = blockModel.getSources(block, taskMonitor); }
while (it.hasNext()) { it = blockModel.getSources(block, taskMonitor);
CodeBlockReference next = it.next(); while (it.hasNext()) {
set.add(next.getSourceBlock()); CodeBlockReference next = it.next();
set.add(next.getSourceBlock());
}
} }
} }
catch (CancelledException e) { catch (CancelledException e) {

View file

@ -73,7 +73,7 @@ public class ProgramGraphPlugin extends ProgramPlugin
implements OptionsChangeListener, BlockModelServiceListener, GraphDisplayBrokerListener { implements OptionsChangeListener, BlockModelServiceListener, GraphDisplayBrokerListener {
private static final String PLUGIN_NAME = "Program Graph"; private static final String PLUGIN_NAME = "Program Graph";
private static final String DEFAULT_BLOCK_MODEL_FOR_CALL_GRAPH = "Isolated Entry";
private static final String OPTIONS_PREFIX = PLUGIN_NAME + Options.DELIMITER; private static final String OPTIONS_PREFIX = PLUGIN_NAME + Options.DELIMITER;
private static final String MAX_CODE_LINES_DISPLAYED = private static final String MAX_CODE_LINES_DISPLAYED =
OPTIONS_PREFIX + "Max Code Lines Displayed"; OPTIONS_PREFIX + "Max Code Lines Displayed";
@ -189,79 +189,79 @@ public class ProgramGraphPlugin extends ProgramPlugin
private void createActions() { private void createActions() {
new ActionBuilder("Graph Block Flow", getName()) new ActionBuilder("Graph Block Flow", getName())
.menuPath(MENU_GRAPH, "&Block Flow") .menuPath(MENU_GRAPH, "&Block Flow")
.menuGroup(MENU_GRAPH, "A") .menuGroup(MENU_GRAPH, "A")
.onAction(c -> graphBlockFlow()) .onAction(c -> graphBlockFlow())
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
new ActionBuilder("Graph Code Flow", getName()) new ActionBuilder("Graph Code Flow", getName())
.menuPath(MENU_GRAPH, "C&ode Flow") .menuPath(MENU_GRAPH, "C&ode Flow")
.menuGroup(MENU_GRAPH, "B") .menuGroup(MENU_GRAPH, "B")
.onAction(c -> graphCodeFlow()) .onAction(c -> graphCodeFlow())
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
new ActionBuilder("Graph Calls Using Default Model", getName()) new ActionBuilder("Graph Calls Using Default Model", getName())
.menuPath(MENU_GRAPH, "&Calls") .menuPath(MENU_GRAPH, "&Calls")
.menuGroup(MENU_GRAPH, "C") .menuGroup(MENU_GRAPH, "C")
.onAction(c -> graphSubroutines()) .onAction(c -> createDefaultCallGraph())
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
tool.setMenuGroup(new String[] { MENU_GRAPH, "Data" }, "Graph", "Data"); tool.setMenuGroup(new String[] { MENU_GRAPH, "Data" }, "Graph", "Data");
HelpLocation helpLoc = new HelpLocation(getName(), "Data_Reference_Graph"); HelpLocation helpLoc = new HelpLocation(getName(), "Data_Reference_Graph");
new ActionBuilder("Graph To/From Data References", getName()) new ActionBuilder("Graph To/From Data References", getName())
.menuPath(MENU_GRAPH, "Data", "To/From &References") .menuPath(MENU_GRAPH, "Data", "To/From &References")
.menuGroup(MENU_GRAPH, "Data") .menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc) .helpLocation(helpLoc)
.onAction(c -> graphDataReferences()) .onAction(c -> graphDataReferences())
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
new ActionBuilder("Graph To Data References", getName()) new ActionBuilder("Graph To Data References", getName())
.menuPath(MENU_GRAPH, "Data", "&To References") .menuPath(MENU_GRAPH, "Data", "&To References")
.menuGroup(MENU_GRAPH, "Data") .menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc) .helpLocation(helpLoc)
.onAction(c -> graphToDataReferences()) .onAction(c -> graphToDataReferences())
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
new ActionBuilder("Graph From Data References", getName()) new ActionBuilder("Graph From Data References", getName())
.menuPath(MENU_GRAPH, "Data", "&From References") .menuPath(MENU_GRAPH, "Data", "&From References")
.menuGroup(MENU_GRAPH, "Data") .menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc) .helpLocation(helpLoc)
.onAction(c -> graphFromDataReferences()) .onAction(c -> graphFromDataReferences())
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
reuseGraphAction = reuseGraphAction =
new ToggleActionBuilder("Reuse Graph", getName()) new ToggleActionBuilder("Reuse Graph", getName())
.menuPath(MENU_GRAPH, "Reuse Graph") .menuPath(MENU_GRAPH, "Reuse Graph")
.menuGroup("Graph Options") .menuGroup("Graph Options")
.selected(reuseGraph) .selected(reuseGraph)
.onAction(c -> reuseGraph = reuseGraphAction.isSelected()) .onAction(c -> reuseGraph = reuseGraphAction.isSelected())
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
appendGraphAction = appendGraphAction =
new ToggleActionBuilder("Append Graph", getName()) new ToggleActionBuilder("Append Graph", getName())
.menuPath(MENU_GRAPH, "Append Graph") .menuPath(MENU_GRAPH, "Append Graph")
.menuGroup("Graph Options")
.selected(false)
.onAction(c -> updateAppendAndReuseGraph())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
forceLocationVisibleAction = new ToggleActionBuilder("Show Location in Graph", getName())
.menuPath(MENU_GRAPH, "Show Location")
.description("Tell the graph to pan/scale as need to keep location changes visible")
.menuGroup("Graph Options") .menuGroup("Graph Options")
.onAction(c -> toggleForceLocationVisible()) .selected(false)
.onAction(c -> updateAppendAndReuseGraph())
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
forceLocationVisibleAction = new ToggleActionBuilder("Show Location in Graph", getName())
.menuPath(MENU_GRAPH, "Show Location")
.description("Tell the graph to pan/scale as need to keep location changes visible")
.menuGroup("Graph Options")
.onAction(c -> toggleForceLocationVisible())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
updateSubroutineActions(); updateSubroutineActions();
} }
@ -309,12 +309,12 @@ public class ProgramGraphPlugin extends ProgramPlugin
private DockingAction buildGraphActionWithModel(String blockModelName, HelpLocation helpLoc) { private DockingAction buildGraphActionWithModel(String blockModelName, HelpLocation helpLoc) {
return new ActionBuilder("Graph Calls using " + blockModelName, getName()) return new ActionBuilder("Graph Calls using " + blockModelName, getName())
.menuPath(MENU_GRAPH, "Calls Using Model", blockModelName) .menuPath(MENU_GRAPH, "Calls Using Model", blockModelName)
.menuGroup(MENU_GRAPH, "C") .menuGroup(MENU_GRAPH, "C")
.helpLocation(helpLoc) .helpLocation(helpLoc)
.onAction(c -> graphSubroutinesUsing(blockModelName)) .onAction(c -> createCallGraphUsing(blockModelName))
.enabledWhen(this::canGraph) .enabledWhen(this::canGraph)
.buildAndInstall(tool); .buildAndInstall(tool);
} }
private void graphBlockFlow() { private void graphBlockFlow() {
@ -325,11 +325,11 @@ public class ProgramGraphPlugin extends ProgramPlugin
graph(new CodeFlowGraphType(), blockModelService.getActiveBlockModelName()); graph(new CodeFlowGraphType(), blockModelService.getActiveBlockModelName());
} }
private void graphSubroutines() { private void createDefaultCallGraph() {
graph(new CallGraphType(), blockModelService.getActiveSubroutineModelName()); createCallGraphUsing(DEFAULT_BLOCK_MODEL_FOR_CALL_GRAPH);
} }
private void graphSubroutinesUsing(String modelName) { private void createCallGraphUsing(String modelName) {
graph(new CallGraphType(), modelName); graph(new CallGraphType(), modelName);
} }
@ -351,8 +351,8 @@ public class ProgramGraphPlugin extends ProgramPlugin
blockModelService.getNewModelByName(modelName, currentProgram, true); blockModelService.getNewModelByName(modelName, currentProgram, true);
BlockGraphTask task = BlockGraphTask task =
new BlockGraphTask(graphType, graphEntryPointNexus, new BlockGraphTask(graphType, graphEntryPointNexus,
reuseGraph, appendToGraph, tool, currentSelection, currentLocation, model, reuseGraph, appendToGraph, tool, currentSelection, currentLocation, model,
defaultGraphService); defaultGraphService);
task.setCodeLimitPerBlock(codeLimitPerBlock); task.setCodeLimitPerBlock(codeLimitPerBlock);
new TaskLauncher(task, tool.getToolFrame()); new TaskLauncher(task, tool.getToolFrame());
} }