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();
}
}
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);
}
}
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);
}
}
}
Aggregations