Search in sources :

Example 26 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CSelectionHistoryTest method testUndo.

@Test
public void testUndo() throws FileReadException, LoadCancelledException {
    ConfigManager.instance().read();
    final ZyGraph graph = CGraphBuilder.buildGraph(new MockView());
    final CSelectionHistory history = new CSelectionHistory(graph, 4);
    final CSelectionSnapshot snapshot1 = new CSelectionSnapshot(new ArrayList<NaviNode>());
    final CSelectionSnapshot snapshot2 = new CSelectionSnapshot(new ArrayList<NaviNode>());
    final CSelectionSnapshot snapshot3 = new CSelectionSnapshot(new ArrayList<NaviNode>());
    final CSelectionSnapshot snapshot4 = new CSelectionSnapshot(new ArrayList<NaviNode>());
    history.addSnapshot(snapshot1);
    history.addSnapshot(snapshot2);
    history.addSnapshot(snapshot3);
    history.addSnapshot(snapshot4);
    // First Undo
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
    assertEquals(snapshot3, history.getUndoSnapshot(true));
    // Second Undo
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
    assertEquals(snapshot2, history.getUndoSnapshot(true));
    // Third Undo
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
    assertEquals(snapshot1, history.getUndoSnapshot(true));
    // Fourth Undo (Fail) + First Redo
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
    assertEquals(snapshot1, history.getUndoSnapshot(true));
    assertEquals(snapshot2, history.getUndoSnapshot(false));
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
    // Second Redo
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
    assertEquals(snapshot3, history.getUndoSnapshot(false));
    // Third Redo
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
    assertEquals(snapshot4, history.getUndoSnapshot(false));
    // Fourth Redo (Fail) + Last Undo
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
    assertEquals(snapshot4, history.getUndoSnapshot(false));
    assertEquals(snapshot3, history.getUndoSnapshot(true));
    assertTrue(history.canUndo());
    assertTrue(history.canRedo());
}
Also used : MockView(com.google.security.zynamics.binnavi.disassembly.MockView) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Test(org.junit.Test)

Example 27 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CNaviNodeFactory method get.

public static NaviNode get() {
    final Graph2D graph = new Graph2D();
    final CTextNode node = CTextNodeFactory.get();
    final ZyLabelContent content = ZyTextNodeBuilder.buildContent(node);
    final IZyNodeRealizer realizer = new ZyNormalNodeRealizer<NaviNode>(content);
    return new NaviNode(graph.createNode(), realizer, node);
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) Graph2D(y.view.Graph2D)

Example 28 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CVariableHighlighterTest method test1Simple.

@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final ZyGraph graph = ZyGraphFactory.generateTestGraph();
    final List<INaviInstruction> mockInstructions = new ArrayList<INaviInstruction>();
    final CCodeNode node = graph.getRawView().getBasicBlocks().get(0);
    final NaviNode naviNode = graph.getNode(node);
    mockInstructions.add(Iterables.get(node.getInstructions(), 0));
    final BackEndDebuggerProvider provider = new MockDebuggerProvider();
    @SuppressWarnings("unused") final CCodeNodeUpdater updater = new CCodeNodeUpdater(graph, naviNode, node, provider);
    assertFalse(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.VARIABLE_LAYER));
    CVariableHighlighter.highlightInstructions(graph, mockInstructions);
    assertTrue(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.VARIABLE_LAYER));
}
Also used : ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) CCodeNodeUpdater(com.google.security.zynamics.binnavi.ZyGraph.Updaters.CodeNodes.CCodeNodeUpdater) ArrayList(java.util.ArrayList) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) BackEndDebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.BackEndDebuggerProvider) MockDebuggerProvider(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Example 29 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CTaggedGraphNodeNodeTest method test1Simple.

@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final ZyGraph graph = ZyGraphFactory.generateTestGraph();
    final CCodeNode node = graph.getRawView().getBasicBlocks().get(0);
    final NaviNode naviNode = graph.getNode(node);
    @SuppressWarnings("unused") final CTaggedGraphNodeNode taggedNode = new CTaggedGraphNodeNode(graph, naviNode);
}
Also used : ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Test(org.junit.Test)

Example 30 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode 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;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) IterationMode(com.google.security.zynamics.zylib.types.common.IterationMode) HashSet(java.util.HashSet) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Aggregations

NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)60 Test (org.junit.Test)29 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)19 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)11 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)9 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)9 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)8 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)7 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)6 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)6 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)6 SearchResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult)5 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)5 ArrayList (java.util.ArrayList)5 Node (y.base.Node)5 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)4 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)4 CTextNode (com.google.security.zynamics.binnavi.disassembly.CTextNode)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 Edge (y.base.Edge)4