Search in sources :

Example 6 with CDebugPerspectiveModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel in project binnavi by google.

the class CFollowInDumpMenu method addFollowInDumpMenu.

/**
   * Adds the menu that follow in dump menu for the clicked instruction.
   *
   * @param menu The code node menu that is extended.
   * @param model The graph model that provides information about the graph.
   * @param node The node whose menu is created.
   * @param clickedObject The object that was clicked.
   * @param y The y-coordinate of the click.
   */
public static void addFollowInDumpMenu(final JPopupMenu menu, final CGraphModel model, final NaviNode node, final Object clickedObject, final double y) {
    Preconditions.checkNotNull(menu, "IE02371: menu argument can not be null");
    Preconditions.checkNotNull(model, "IE02372: model argument can not be null");
    Preconditions.checkNotNull(node, "IE02373: node argument can not be null");
    final int line = node.positionToRow(y);
    if (line == -1) {
        return;
    }
    final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
    final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(codeNode, line);
    if (instruction != null) {
        final IDebugger debugger = CGraphDebugger.getDebugger(model.getDebuggerProvider(), instruction);
        if ((debugger != null) && (clickedObject instanceof COperandTreeNode)) {
            final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
            if (activeThread != null) {
                final CDebugPerspectiveModel viewModel = (CDebugPerspectiveModel) model.getGraphPanel().getViewModel().getModel(PerspectiveType.DebugPerspective);
                final COperandTreeNode treeNode = (COperandTreeNode) clickedObject;
                final boolean added = addFollowInDumpMenu(menu, viewModel, debugger, activeThread, instruction.getModule(), treeNode);
                if (added) {
                    menu.addSeparator();
                }
            }
        }
    }
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 7 with CDebugPerspectiveModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel in project binnavi by google.

the class CModulesPanelTest method testLifeCycle.

@Test
public void testLifeCycle() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final CDebugPerspectiveModel model = new CDebugPerspectiveModel(new MockGraphModel());
    model.setActiveDebugger(debugger);
    final CModulesPanel panel = new CModulesPanel(model);
    panel.dispose();
    final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "synchronizer"), "listeners"), "m_listeners");
    final LinkedHashSet<?> processListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
    // The debugger only has one internal memory synchronizer
    assertEquals(1, debuggerListeners.size());
    // The process manager only has one thread state synchronizer
    assertEquals(1, processListeners.size());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) AbstractDebugger(com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) Test(org.junit.Test)

Example 8 with CDebugPerspectiveModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel in project binnavi by google.

the class CThreadInformationPanelTest method test2.

/**
   * This test makes sure that going from no debugger to a debugger to no debugger works fine.
   */
@Test
public void test2() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // CGraphModelFactory.get(database,
    final IGraphModel graphModel = new MockGraphModel();
    // viewContainer);
    final CDebugPerspectiveModel model = CDebugPerspectiveModelFactory.get(graphModel);
    final CThreadInformationPanel panel = new CThreadInformationPanel(model);
    final IDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread);
    final LinkedHashSet<?> perspectiveListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(model, "m_listeners"), "m_listeners");
    final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
    final LinkedHashSet<?> threadListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(thread, "listeners"), "m_listeners");
    assertEquals(1, perspectiveListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(1, threadListeners.size());
    model.setActiveDebugger(debugger);
    assertEquals(2, threadListeners.size());
    assertEquals(2, debuggerListeners.size());
    model.setActiveDebugger(null);
    assertEquals(1, threadListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(1, perspectiveListeners.size());
    panel.dispose();
    assertEquals(1, threadListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(0, perspectiveListeners.size());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) AbstractDebugger(com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Test(org.junit.Test)

Example 9 with CDebugPerspectiveModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel in project binnavi by google.

the class CMemoryViewerSynchronizerTest method setUp.

@Before
public void setUp() {
    final IGraphModel graphModel = new MockGraphModel();
    m_model = new CDebugPerspectiveModel(graphModel);
    final CMemoryProvider provider = new CMemoryProvider();
    m_hexView.setData(provider);
    m_synchronizer = new CMemoryViewerSynchronizer(m_hexView, provider, m_model);
    m_debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    m_model.setActiveDebugger(m_debugger);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) Before(org.junit.Before)

Aggregations

CDebugPerspectiveModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel)9 MockGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel)8 Test (org.junit.Test)7 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)6 IGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel)6 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)6 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)5 AbstractDebugger (com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger)4 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)4 LinkedHashSet (java.util.LinkedHashSet)4 JHexView (com.google.security.zynamics.zylib.gui.JHexPanel.JHexView)2 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)1 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)1 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)1 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)1 COperandTreeNode (com.google.security.zynamics.binnavi.disassembly.COperandTreeNode)1 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)1 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1