Search in sources :

Example 6 with ViewNode

use of com.google.security.zynamics.binnavi.API.disassembly.ViewNode in project binnavi by google.

the class VisualCoverage method updatePreviousNode.

/**
   * Updates the color of the previously hit node depending on its hit count.
   */
private void updatePreviousNode() {
    if ((previousNodeAddress == null) || !myBreakpoints.contains(previousNodeAddress)) {
        return;
    }
    final ViewNode node = nodeMap.get(previousNodeAddress);
    final int count = breakpointCounter.get(previousNodeAddress);
    if (count < 5) {
        node.setColor(COLOR_FEW_HITS);
    } else if (count < 10) {
        node.setColor(COLOR_SEVERAL_HITS);
    } else {
        node.setColor(COLOR_MANY_HITS);
        // After a breakpoint was hit 10 times we remove it so we do not
        // hit it again.
        final BreakpointManager breakpointManager = debugger.getBreakpointManager();
        if (breakpointManager.hasBreakpoint(null, previousNodeAddress)) {
            breakpointManager.removeBreakpoint(null, previousNodeAddress);
            myBreakpoints.remove(previousNodeAddress);
        }
    }
    try {
        java.lang.Thread.sleep(100);
    } catch (final InterruptedException e) {
        // restore the interrupted status of the thread.
        // http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
        java.lang.Thread.currentThread().interrupt();
    }
}
Also used : ViewNode(com.google.security.zynamics.binnavi.API.disassembly.ViewNode) BreakpointManager(com.google.security.zynamics.binnavi.API.debug.BreakpointManager)

Example 7 with ViewNode

use of com.google.security.zynamics.binnavi.API.disassembly.ViewNode in project binnavi by google.

the class PathFinder method deleteNodesNotOnPath.

/**
   * Deletes all nodes that are not on the path.
   *
   * @param view View from which the nodes are deleted.
   * @param startNode Start node of the path.
   * @param targetNode Target node of the path.
   */
private static void deleteNodesNotOnPath(final View view, final ViewNode startNode, final ViewNode targetNode) {
    final Set<ViewNode> succs = GraphAlgorithms.getSuccessors(startNode);
    final Set<ViewNode> preds = GraphAlgorithms.getPredecessors(targetNode);
    final HashSet<ViewNode> combined = new HashSet<ViewNode>(succs);
    combined.retainAll(preds);
    combined.add(startNode);
    combined.add(targetNode);
    final List<ViewNode> nodesToDelete = new ArrayList<ViewNode>();
    for (final ViewNode node : view.getGraph().getNodes()) {
        if (!combined.contains(node)) {
            nodesToDelete.add(node);
        }
    }
    for (final ViewNode node : nodesToDelete) {
        view.deleteNode(node);
    }
}
Also used : ArrayList(java.util.ArrayList) ViewNode(com.google.security.zynamics.binnavi.API.disassembly.ViewNode) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 8 with ViewNode

use of com.google.security.zynamics.binnavi.API.disassembly.ViewNode in project binnavi by google.

the class PathFinder method findEntryExitNodes.

/**
   * Finds the entry nodes and exit nodes of all functions that lie on the path. This is necessary
   * for function inlining.
   *
   * @param passedFunctions All functions that lie on the path.
   * @param nodeMap Maps between the basic blocks of the functions and their corresponding code
   *        nodes.
   * @param functionMap Keeps track to what function a view node belongs to.
   * @param entryNodes Keeps track of the entry nodes of all functions.
   * @param exitNodes Keeps track of the exit nodes of all functions.
   */
private static void findEntryExitNodes(final Collection<FunctionBlock> passedFunctions, final Map<BasicBlock, ViewNode> nodeMap, final Map<ViewNode, Function> functionMap, final Map<Function, ViewNode> entryNodes, final ArrayListMultimap<Function, ViewNode> exitNodes) {
    // actually do have basic blocks.
    for (final FunctionBlock functionBlock : passedFunctions) {
        final Function function = functionBlock.getFunction();
        if (function.getType() != FunctionType.Import) {
            entryNodes.put(function, nodeMap.get(findEntryNode(function)));
            for (final BasicBlock block : findExitNode(function.getGraph())) {
                exitNodes.put(function, nodeMap.get(block));
            }
        }
    }
    // Afterwards we find the entry and exit nodes of the imported functions.
    for (final Map.Entry<ViewNode, Function> p : functionMap.entrySet()) {
        final Function function = p.getValue();
        if (function.getType() == FunctionType.Import) {
            final ViewNode node = p.getKey();
            entryNodes.put(function, node);
            exitNodes.put(function, node);
        }
    }
}
Also used : Function(com.google.security.zynamics.binnavi.API.disassembly.Function) BasicBlock(com.google.security.zynamics.binnavi.API.disassembly.BasicBlock) ViewNode(com.google.security.zynamics.binnavi.API.disassembly.ViewNode) HashMap(java.util.HashMap) Map(java.util.Map) FunctionBlock(com.google.security.zynamics.binnavi.API.disassembly.FunctionBlock)

Aggregations

ViewNode (com.google.security.zynamics.binnavi.API.disassembly.ViewNode)8 Function (com.google.security.zynamics.binnavi.API.disassembly.Function)4 BasicBlock (com.google.security.zynamics.binnavi.API.disassembly.BasicBlock)3 CodeNode (com.google.security.zynamics.binnavi.API.disassembly.CodeNode)3 FunctionBlock (com.google.security.zynamics.binnavi.API.disassembly.FunctionBlock)3 ViewEdge (com.google.security.zynamics.binnavi.API.disassembly.ViewEdge)3 Instruction (com.google.security.zynamics.binnavi.API.disassembly.Instruction)2 View (com.google.security.zynamics.binnavi.API.disassembly.View)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 BreakpointManager (com.google.security.zynamics.binnavi.API.debug.BreakpointManager)1 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)1 CouldntSaveDataException (com.google.security.zynamics.binnavi.API.disassembly.CouldntSaveDataException)1 FunctionNode (com.google.security.zynamics.binnavi.API.disassembly.FunctionNode)1 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)1 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)1 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)1 IInstruction (com.google.security.zynamics.zylib.disassembly.IInstruction)1