Search in sources :

Example 26 with IDebugger

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

the class CBreakpointTableHelpers method findBreakpoint.

/**
 * Given a row of the breakpoint table, this function calculates to what breakpoint manager the
 * breakpoint of that row belongs to and what index the breakpoint has within the breakpoint
 * manager.
 *
 * @param debuggerProvider The debuggers that are used to fill the breakpoint table.
 * @param row A row of the breakpoint table.
 *
 * @return A pair that contains the breakpoint manager and the breakpoint index of the breakpoint
 *         identified by the given row.
 *
 * @throws IllegalArgumentException Thrown if the debugger provider argument is null or the row
 *         argument is out of bounds.
 */
public static Pair<IDebugger, Integer> findBreakpoint(final BackEndDebuggerProvider debuggerProvider, final int row) {
    Preconditions.checkNotNull(debuggerProvider, "IE01336: Debugger provider argument can't be null");
    Preconditions.checkArgument(row >= 0, "IE01337: Row arguments can not be negative");
    int breakpoints = 0;
    for (final IDebugger debugger : debuggerProvider.getDebuggers()) {
        if ((row >= breakpoints) && (row < breakpoints + debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR))) {
            return new Pair<IDebugger, Integer>(debugger, row - breakpoints);
        } else {
            breakpoints += debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR);
        }
    }
    throw new IllegalArgumentException("IE01338: Invalid row number");
}
Also used : IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 27 with IDebugger

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

the class CBreakpointFunctions method allDisabled.

/**
 * Tests whether all breakpoints set in the specified rows are disabled.
 *
 * @param debuggerProvider Provides the debuggers where breakpoints can be set.
 * @param rows Rows that identify the breakpoints.
 *
 * @return True, if all selected breakpoints are disabled. False, otherwise.
 */
public static boolean allDisabled(final BackEndDebuggerProvider debuggerProvider, final int[] rows) {
    checkArguments(debuggerProvider, rows);
    for (final int row : rows) {
        final Pair<IDebugger, Integer> breakpoint = CBreakpointTableHelpers.findBreakpoint(debuggerProvider, row);
        final BreakpointManager manager = breakpoint.first().getBreakpointManager();
        final int breakpointIndex = breakpoint.second();
        if (manager.getBreakpointStatus(BreakpointType.REGULAR, breakpointIndex) != BreakpointStatus.BREAKPOINT_DISABLED) {
            return false;
        }
    }
    return true;
}
Also used : BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 28 with IDebugger

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

the class CStepIntoHotkeyAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
    final TargetProcessThread currentThread = debugger == null ? null : debugger.getProcessManager().getActiveThread();
    if (currentThread != null && debugger != null) {
        CDebuggerFunctions.stepInto(m_parent, debugger);
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 29 with IDebugger

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

the class CProjectContainer method updateProjectDebuggers.

/**
 * Rebuilds the active debuggers from information from the address spaces.
 */
private void updateProjectDebuggers() {
    for (final INaviAddressSpace addressSpace : m_project.getContent().getAddressSpaces()) {
        final IDebugger debugger = addressSpace.getConfiguration().getDebugger();
        if (debugger != null) {
            m_activeDebuggers.put(addressSpace, debugger);
            m_debuggerProvider.addDebugger(debugger);
        }
    }
}
Also used : IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 30 with IDebugger

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

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