Search in sources :

Example 1 with ICodeNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode 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);
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) ICodeNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) IterationMode(com.google.security.zynamics.zylib.types.common.IterationMode)

Example 2 with ICodeNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode in project binnavi by google.

the class TooltipGenerator method generateProximityNodeRealizer.

private static <NodeType extends ZyGraphNode<?>> String generateProximityNodeRealizer(final AbstractZyGraph<NodeType, ?> graph, final ZyProximityNode<?> node) {
    final Set<String> strings = new LinkedHashSet<String>();
    final List<? extends Object> nodes = node.isIncoming() ? ((IGraphNode<?>) node.getRawNode().getAttachedNode()).getChildren() : ((IGraphNode<?>) node.getRawNode().getAttachedNode()).getParents();
    boolean cutoff = false;
    int counter = 0;
    final int invisibleNodesCount = CollectionHelpers.countIf(nodes, new ICollectionFilter<Object>() {

        @Override
        public boolean qualifies(final Object item) {
            return !((IViewNode<?>) item).isVisible();
        }
    });
    for (final Object child : nodes) {
        final IViewNode<?> childNode = (IViewNode<?>) child;
        if (childNode.isVisible()) {
            continue;
        }
        final IZyNodeRealizer realizer = (IZyNodeRealizer) graph.getGraph().getRealizer(graph.getYNode(child));
        final ZyLabelContent content = realizer.getNodeContent();
        if (child instanceof IFunctionNode<?, ?>) {
            final IFunctionNode<?, ?> fnode = (IFunctionNode<?, ?>) child;
            strings.add("F: " + fnode.getFunction().getName());
        } else if (child instanceof ICodeNode<?, ?, ?>) {
            final ICodeNode<?, ?, ?> cnode = (ICodeNode<?, ?, ?>) child;
            strings.add("B: " + cnode.getAddress().toHexString());
        } else {
            if (content.getLineCount() > 0) {
                strings.add(content.getLineContent(0).getText());
            }
        }
        ++counter;
        if (strings.size() == 25) {
            cutoff = counter != invisibleNodesCount;
            break;
        }
    }
    if (cutoff) {
        strings.add("...");
    }
    return HtmlGenerator.getHtml(strings, GuiHelper.getMonospaceFont(), false);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ICodeNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode) IFunctionNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IFunctionNode) IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)

Example 3 with ICodeNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode in project binnavi by google.

the class CDebuggerPainter method updateSingleNodeDebuggerHighlighting.

/**
 * Updates the debugger highlighting for a single node
 *
 * @param graph The graph in which the node is located
 * @param address The address of the breakpoint
 * @param node The node in which the breakpoint is located.
 */
public static void updateSingleNodeDebuggerHighlighting(final ZyGraph graph, final UnrelocatedAddress address, final NaviNode node) {
    Preconditions.checkNotNull(graph, "IE01192: Graph argument can not be null");
    Preconditions.checkNotNull(address, "IE01216: Address argument can not be null");
    final INaviViewNode rawNode = node.getRawNode();
    if (rawNode instanceof ICodeNode) {
        final INaviCodeNode codeNode = (INaviCodeNode) rawNode;
        updateDebuggerHighlighting(graph, address, node, codeNode);
    } else if (rawNode instanceof INaviFunctionNode) {
        final INaviFunctionNode functionNode = (INaviFunctionNode) rawNode;
        updateDebuggerHighlighting(address, node, functionNode);
    }
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) ICodeNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)

Aggregations

ICodeNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)2 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)2 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)2 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)1 IFunctionNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IFunctionNode)1 IViewNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode)1 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)1 IterationMode (com.google.security.zynamics.zylib.types.common.IterationMode)1 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)1 LinkedHashSet (java.util.LinkedHashSet)1