Search in sources :

Example 1 with BreakpointManagerListener

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

the class BreakpointManager method setBreakpointsStatus.

private void setBreakpointsStatus(final Set<BreakpointAddress> addresses, final BreakpointStatus newStatus, final BreakpointStorage storage) {
    if (storage.getBreakPointsByAddress(addresses).isEmpty()) {
        return;
    }
    final Map<Breakpoint, BreakpointStatus> breakpointToStatus = Maps.newHashMap();
    for (final BreakpointAddress breakpointAddress : addresses) {
        breakpointToStatus.put(storage.get(breakpointAddress), storage.getBreakpointStatus(breakpointAddress));
        storage.setBreakpointStatus(breakpointAddress, newStatus);
    }
    for (final BreakpointManagerListener listener : listeners) {
        try {
            listener.breakpointsStatusChanged(breakpointToStatus, newStatus);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : BreakpointStatus(com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus) BreakpointManagerListener(com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.BreakpointManagerListener)

Example 2 with BreakpointManagerListener

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

the class BreakpointManager method addBreakpoints.

/**
   * Adds a list of breakpoints to the breakpoint manager.
   *
   * @param addresses Addresses of the breakpoints to add.
   * @param status Initial status of the new breakpoints.
   */
private void addBreakpoints(final Set<BreakpointAddress> addresses, final BreakpointStatus status, final BreakpointStorage storage, final BreakpointType type) {
    Preconditions.checkNotNull(addresses, "IE00718: addresses argument can not be null");
    Preconditions.checkNotNull(status, "IE00719: status argument can not be null");
    Preconditions.checkNotNull(storage, "IE00720: storage argument can not be null");
    Preconditions.checkNotNull(type, "IE00721: type argument can not be null");
    if (addresses.size() == 0) {
        return;
    }
    final List<Breakpoint> breakpoints = new ArrayList<>();
    for (final BreakpointAddress address : addresses) {
        final Breakpoint breakpoint = new Breakpoint(type, address);
        storage.add(breakpoint, status);
        breakpoints.add(breakpoint);
    }
    for (final BreakpointManagerListener listener : listeners) {
        try {
            listener.breakpointsAdded(breakpoints);
        } catch (final Exception e) {
            CUtilityFunctions.logException(e);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) BreakpointManagerListener(com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.BreakpointManagerListener)

Example 3 with BreakpointManagerListener

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

the class BreakpointManager method removeBreakpoints.

/**
   * Remove the given set of breakpoints.
   *
   * @param breakpointAddressSet The breakpoints to be removed.
   */
private void removeBreakpoints(final Set<BreakpointAddress> breakpointAddressSet, final BreakpointStorage storage) {
    if (breakpointAddressSet.size() != 0) {
        final Set<Breakpoint> breakpoints = storage.getBreakPointsByAddress(breakpointAddressSet);
        storage.removeBreakpoints(breakpointAddressSet);
        for (final BreakpointManagerListener listener : listeners) {
            try {
                listener.breakpointsRemoved(breakpoints);
            } catch (final Exception e) {
                // This should never happen. Breakpoint listeners are not allowed
                // to throw. Nevertheless, if we don't catch unexpected exceptions,
                // it is possible that we forget to release the semaphore.
                CUtilityFunctions.logException(e);
            }
        }
    }
}
Also used : BreakpointManagerListener(com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.BreakpointManagerListener)

Example 4 with BreakpointManagerListener

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

the class BreakpointManager method setBreakpointCondition.

public void setBreakpointCondition(final int breakpointIndex, final String formula) {
    Preconditions.checkNotNull(formula, "Error: formula argument can not be null.");
    final Breakpoint breakpoint = getBreakpoint(BreakpointType.REGULAR, breakpointIndex);
    final Set<Breakpoint> conditinalBreakPoints = Sets.newHashSet();
    Condition condition = null;
    try {
        condition = BreakpointConditionParser.evaluate(formula);
    } catch (final InvalidFormulaException exception) {
        CUtilityFunctions.logException(exception);
    }
    breakpoint.setCondition(condition);
    conditinalBreakPoints.add(breakpoint);
    for (final BreakpointManagerListener listener : listeners) {
        try {
            listener.breakpointsConditionChanged(conditinalBreakPoints);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : Condition(com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.Condition) BreakpointManagerListener(com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.BreakpointManagerListener)

Aggregations

BreakpointManagerListener (com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.BreakpointManagerListener)4 BreakpointStatus (com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus)1 Condition (com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.Condition)1 ArrayList (java.util.ArrayList)1