Search in sources :

Example 21 with BreakpointManager

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.

the class EchoBreakpointSetSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final EchoBreakpointSetReply reply) {
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final Set<BreakpointAddress> addressesToActivate = new HashSet<>();
    final Set<BreakpointAddress> addressesToRemove = new HashSet<>();
    for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
        final RelocatedAddress address = resultPair.first();
        if (resultPair.second() == 0) {
            addressesToActivate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
        } else {
            addressesToRemove.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
        }
    }
    manager.setBreakpointStatus(addressesToActivate, BreakpointType.ECHO, BreakpointStatus.BREAKPOINT_ACTIVE);
    manager.removeBreakpointsPassive(BreakpointType.ECHO, addressesToRemove);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) HashSet(java.util.HashSet)

Example 22 with BreakpointManager

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.

the class StepBreakpointSetSynchronizer method handleSuccess.

/**
 * When a stepping breakpoint was set in the target process, its state is set to ACTIVE in the
 * breakpoint manager.
 */
@Override
protected void handleSuccess(final StepBreakpointSetReply reply) {
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final Set<BreakpointAddress> addressesToActivate = new HashSet<BreakpointAddress>();
    final Set<BreakpointAddress> addressesToRemove = new HashSet<BreakpointAddress>();
    for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
        final RelocatedAddress address = resultPair.first();
        if (resultPair.second() == DebuggerErrorCodes.SUCCESS) {
            addressesToActivate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
        } else {
            addressesToRemove.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
        }
    }
    manager.setBreakpointStatus(addressesToActivate, BreakpointType.STEP, BreakpointStatus.BREAKPOINT_ACTIVE);
    manager.removeBreakpoints(BreakpointType.STEP, addressesToRemove);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) HashSet(java.util.HashSet)

Example 23 with BreakpointManager

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.

the class ReplySynchronizer method updateHitBreakpoints.

/**
 * Updates the hit state of breakpoints.
 *
 * @param address The current value of the program counter which is used to determine the state of
 *        breakpoints.
 */
protected void updateHitBreakpoints(final BreakpointAddress address) {
    Preconditions.checkNotNull(address, "IE01048: Address argument can not be null");
    final BreakpointManager manager = debugger.getBreakpointManager();
    for (final Breakpoint breakpoint : manager.getBreakpoints(BreakpointType.REGULAR)) {
        final boolean isAddressSame = address.equals(breakpoint.getAddress());
        if ((manager.getBreakpointStatus(breakpoint.getAddress(), BreakpointType.REGULAR) == BreakpointStatus.BREAKPOINT_HIT) && !isAddressSame) {
            // Activate the previously hit breakpoint
            manager.setBreakpointStatus(Sets.newHashSet(breakpoint.getAddress()), BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE);
            break;
        } else if (isAddressSame) {
            // Hit the currently hit breakpoint
            try {
                manager.setBreakpointStatus(Sets.newHashSet(breakpoint.getAddress()), BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_HIT);
            } catch (final IllegalArgumentException exception) {
                // Not one of our breakpoints.
                return;
            }
        }
    }
}
Also used : Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)

Example 24 with BreakpointManager

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.

the class CBreakpointFunctions method allNotDisabled.

/**
 * Tests whether not 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 not all selected breakpoints are disabled. False, otherwise.
 */
public static boolean allNotDisabled(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 25 with BreakpointManager

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.

the class CBreakpointSetFunctions method enableBreakpoints.

/**
 * Enables all breakpoints that are identified by the rows argument.
 *
 * @param debuggerProvider Provides the debuggers where breakpoints can be set.
 * @param rows Rows that identify the breakpoints.
 */
public static void enableBreakpoints(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();
        manager.setBreakpointStatus(BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ENABLED, breakpointIndex);
    }
}
Also used : BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Aggregations

BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)32 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)16 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)11 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)9 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)7 HashSet (java.util.HashSet)7 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)3 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)3 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)2 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)2 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)2 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)2 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)2 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)2 Pair (com.google.security.zynamics.zylib.general.Pair)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)1 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1