Search in sources :

Example 31 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CMemoryViewerSynchronizerTest method testSwitchDebuggers.

@Test
public void testSwitchDebuggers() throws DebugExceptionWrapper {
    m_debugger.connect();
    m_debugger.getProcessManager().setAttached(true);
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)))));
    m_model.setActiveMemoryAddress(new CAddress(0x100), false);
    assertEquals(0x100, m_hexView.getCurrentOffset());
    assertEquals(0x100, m_hexView.getData().getDataLength());
    final IDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger2.connect();
    debugger2.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x10), new CAddress(0x50)))));
    m_model.setActiveDebugger(debugger2);
    assertEquals(0x10, m_hexView.getCurrentOffset());
    assertEquals(0x41, m_hexView.getData().getDataLength());
    m_debugger.getProcessManager().setAttached(false);
    m_synchronizer.dispose();
    debugger2.close();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 32 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CDebugPerspectiveModel method setActiveDebugger.

/**
 * Sets the active debugger.
 *
 * @param debugger The new debugger.
 */
public void setActiveDebugger(final IDebugger debugger) {
    if (m_activeDebugger == debugger) {
        return;
    }
    if ((debugger != null) && !m_eventLoggerMap.containsKey(debugger)) {
        m_notifierMap.put(debugger, new CDebugEventNotifier(m_model.getParent(), debugger, m_model.getDebuggerProvider().getDebugTarget(), m_model.getViewContainer()));
        m_eventLoggerMap.put(debugger, new TraceLogger(m_model.getViewContainer().getTraceProvider(), debugger));
    }
    final IDebugger oldDebugger = m_activeDebugger;
    m_activeDebugger = debugger;
    for (final IDebugPerspectiveModelListener listener : m_listeners) {
        // ESCA-JAVA0166: Calling a listener
        try {
            listener.changedActiveDebugger(oldDebugger, m_activeDebugger);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : TraceLogger(com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger) CDebugEventNotifier(com.google.security.zynamics.binnavi.Gui.Debug.Notifier.CDebugEventNotifier) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 33 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CGraphDebugger method toggleBreakpoint.

/**
 * Sets or removes a breakpoint at a given line of a code node.
 *
 * @param debuggerProvider Debugger provider that contains all possible debuggers for the code
 *        node.
 * @param codeNode The code node where the breakpoint is set.
 * @param row The code node row where the breakpoint is set.
 */
public static void toggleBreakpoint(final BackEndDebuggerProvider debuggerProvider, final INaviCodeNode codeNode, final int row) {
    Preconditions.checkNotNull(debuggerProvider, "IE01719: Debugger provider argument can not be null");
    Preconditions.checkNotNull(codeNode, "IE01720: Code node argument can not be null");
    final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(codeNode, row);
    if (instruction == null) {
        return;
    }
    final IDebugger debugger = getDebugger(debuggerProvider, instruction);
    if (debugger == null) {
        return;
    }
    toggleBreakpoint(debugger.getBreakpointManager(), instruction.getModule(), new UnrelocatedAddress(instruction.getAddress()));
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 34 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger 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 35 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CBookmarkTableModel method getBookmarkAddress.

/**
 * Finds the bookmark address of the bookmark that is displayed in a given row of the table.
 *
 * @param row The table row where the bookmark is displayed.
 *
 * @return The bookmark address of the bookmark in the given row.
 */
private String getBookmarkAddress(final int row) {
    final Triple<IDebugger, BookmarkManager, Integer> bookmarkTriple = CBookmarkTableHelpers.findBookmark(m_debuggerProvider, row);
    final BookmarkManager manager = bookmarkTriple.second();
    final int index = bookmarkTriple.third();
    return manager.getBookmark(index).getAddress().toHexString();
}
Also used : IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)

Aggregations

IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)62 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)16 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)16 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)6 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)6 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)6 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)6 Test (org.junit.Test)6 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)5 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)5 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)5 CDebugPerspectiveModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 BookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)4 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)4 Pair (com.google.security.zynamics.zylib.general.Pair)4 ArrayList (java.util.ArrayList)4 IGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel)3