use of com.google.security.zynamics.zylib.types.common.IterationMode in project binnavi by google.
the class InternalNodeCallBack method zoomToAddress.
/**
* Zooms to the first occurrence of an address in a graph.
*
* @param graph The graph where the zoom operation takes place.
* @param address The address to zoom to.
*/
public static void zoomToAddress(final ZyGraph graph, final IAddress address) {
graph.iterate(new INodeCallback<NaviNode>() {
@Override
public IterationMode next(final NaviNode node) {
if (node.getRawNode() instanceof INaviCodeNode) {
final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
for (final INaviInstruction instruction : codeNode.getInstructions()) {
if (instruction.getAddress().equals(address)) {
uncollapseParents(codeNode);
graph.showNode(node, true);
ZoomFunctions.zoomToNode(graph, node);
return IterationMode.STOP;
}
}
} else if (node.getRawNode() instanceof INaviFunctionNode) {
final INaviFunctionNode functionNode = (INaviFunctionNode) node.getRawNode();
if (functionNode.getFunction().getAddress().equals(address)) {
uncollapseParents(functionNode);
graph.showNode(node, true);
ZoomFunctions.zoomToNode(graph, node);
return IterationMode.STOP;
}
}
return IterationMode.CONTINUE;
}
});
}
use of com.google.security.zynamics.zylib.types.common.IterationMode in project binnavi by google.
the class CDebuggerPainter method updateDebuggerHighlighting.
/**
* Updates the program counter highlighting in a whole graph.
*
* @param graph The graph where the highlighting is updated.
* @param address The address of the program counter to be highlighted.
* @param module The module in which the address is located.
*/
public static void updateDebuggerHighlighting(final ZyGraph graph, final UnrelocatedAddress address, final INaviModule module) {
Preconditions.checkNotNull(graph, "IE02187: Graph argument can not be null");
Preconditions.checkNotNull(address, "IE02188: Address argument can not be null");
graph.iterate(new INodeCallback<NaviNode>() {
@Override
public IterationMode next(final NaviNode node) {
final INaviViewNode rawNode = node.getRawNode();
if (rawNode instanceof ICodeNode) {
final INaviCodeNode codeNode = (INaviCodeNode) rawNode;
try {
if (module.equals(codeNode.getParentFunction().getModule())) {
updateDebuggerHighlighting(graph, address, node, codeNode);
}
} catch (final MaybeNullException exception) {
CUtilityFunctions.logException(exception);
}
} else if (rawNode instanceof INaviFunctionNode) {
final INaviFunctionNode functionNode = (INaviFunctionNode) rawNode;
if (module.equals(functionNode.getFunction().getModule())) {
updateDebuggerHighlighting(address, node, functionNode);
}
}
return IterationMode.CONTINUE;
}
});
ZyZoomHelpers.zoomToAddress(graph, address.getAddress(), module, false);
}
use of com.google.security.zynamics.zylib.types.common.IterationMode in project binnavi by google.
the class CStepEndHelper method getEndAddresses.
/**
* Returns the addresses of all final instructions of a graph.
*
* @param graph The graph whose final addresses are returned.
*
* @return The final addresses of the graph.
*/
public static Set<BreakpointAddress> getEndAddresses(final ZyGraph graph) {
final Set<BreakpointAddress> instructions = new HashSet<BreakpointAddress>();
graph.iterate(new INodeCallback<NaviNode>() {
@Override
public IterationMode next(final NaviNode node) {
if ((node.getRawNode() instanceof INaviCodeNode) && node.getChildren().isEmpty()) {
final INaviCodeNode cnode = (INaviCodeNode) node.getRawNode();
final INaviInstruction lastInstruction = Iterables.getLast(cnode.getInstructions());
instructions.add(new BreakpointAddress(lastInstruction.getModule(), new UnrelocatedAddress(lastInstruction.getAddress())));
}
return IterationMode.CONTINUE;
}
});
return instructions;
}
Aggregations