Search in sources :

Example 1 with BreakpointStatus

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus 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 BreakpointStatus

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

the class CBreakpointStatusRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(final JTable table, final Object object, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
    super.setHorizontalAlignment(CENTER);
    final BreakpointStatus breakpointStatus = (BreakpointStatus) object;
    setForeground(Color.BLACK);
    setBackground(BreakpointManager.getBreakpointColor(breakpointStatus));
    setText(getText(breakpointStatus));
    // Create a small border effect for the status cells
    setBorder(BorderFactory.createMatteBorder(2, 5, 2, 5, isSelected ? table.getSelectionBackground() : table.getBackground()));
    return this;
}
Also used : BreakpointStatus(com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus)

Example 3 with BreakpointStatus

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

the class CGraphDebugger method removeBreakpoints.

/**
   * Removes a breakpoint from a breakpoint manager.
   *
   * @param addresses The address of the breakpoint to remove.
   * @param manager The breakpoint manager from where the breakpoint is removed.
   */
public static void removeBreakpoints(final Set<BreakpointAddress> addresses, final BreakpointManager manager) {
    Preconditions.checkNotNull(manager, "IE01708: Manager argument can not be null");
    Preconditions.checkNotNull(addresses, "IE01709: Address argument can not be null");
    final Set<BreakpointAddress> addressesToRemoveFromManager = new HashSet<BreakpointAddress>();
    final Set<BreakpointAddress> addressesToRemoveFromDebugger = new HashSet<BreakpointAddress>();
    for (final BreakpointAddress address : addresses) {
        final BreakpointStatus status = manager.getBreakpointStatus(address, BreakpointType.REGULAR);
        if ((status == BreakpointStatus.BREAKPOINT_DISABLED) || (status == BreakpointStatus.BREAKPOINT_INACTIVE)) {
            addressesToRemoveFromManager.add(address);
        }
        if (status != BreakpointStatus.BREAKPOINT_DELETING) {
            addressesToRemoveFromDebugger.add(address);
        }
    }
    if (addressesToRemoveFromManager.size() != 0) {
        manager.removeBreakpoints(BreakpointType.REGULAR, addressesToRemoveFromManager);
    }
    if (addressesToRemoveFromDebugger.size() != 0) {
        manager.setBreakpointStatus(addressesToRemoveFromDebugger, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DELETING);
    }
}
Also used : BreakpointStatus(com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) HashSet(java.util.HashSet)

Example 4 with BreakpointStatus

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

the class BreakpointManager method removeBreakpoint.

// ! Removes a regular breakpoint.
/**
   * Removes a regular breakpoint from a given address.
   *
   * @param module The module the breakpoint is tied to. This argument can be null.
   * @param address The address of the breakpoint.
   */
public void removeBreakpoint(final Module module, final Address address) {
    Preconditions.checkNotNull(address, "Error: Address argument can not be null");
    final BreakpointStatus currentStatus = com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus.BREAKPOINT_DELETING;
    final BreakpointAddress breakpointAddress = new BreakpointAddress(module == null ? null : module.getNative(), new UnrelocatedAddress(new CAddress(address.toLong())));
    breakpointManager.setBreakpointStatus(Sets.newHashSet(breakpointAddress), BreakpointType.REGULAR, currentStatus);
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointStatus(com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 5 with BreakpointStatus

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

the class CAddressLabel method paint.

@Override
public void paint(final Graphics graphics) {
    CLoadProgressPainter.paint(view, graphics, getWidth(), getHeight(), getBackground());
    if (view.isStared()) {
        graphics.drawImage(starImage, 0, 0, getHeight() - 2, getHeight() - 2, table);
    }
    final UnrelocatedAddress fileAddress = new UnrelocatedAddress(function.getAddress());
    if (CGraphDebugger.hasBreakpoint(debugger.getBreakpointManager(), function.getModule(), fileAddress)) {
        final BreakpointStatus breakpointStatus = CGraphDebugger.getBreakpointStatus(debugger.getBreakpointManager(), function.getModule(), fileAddress);
        final CBreakpointImage img = new CBreakpointImage(getBackground(), BreakpointManager.getBreakpointColor(breakpointStatus));
        final int x = getWidth() - img.getWidth() - 2;
        final int y = (getHeight() / 2) - (img.getHeight() / 2);
        ((Graphics2D) graphics).drawImage(img, null, x, y);
    }
    final boolean isOpen = CWindowManager.instance().isOpen(view);
    graphics.setColor(Color.BLACK);
    graphics.setFont(isOpen ? normalBoldFont : normalFont);
    graphics.drawString(function.getAddress().toHexString(), view.isStared() ? getHeight() : 0, 12);
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointStatus(com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus) Graphics2D(java.awt.Graphics2D)

Aggregations

BreakpointStatus (com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus)5 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)2 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)2 BreakpointManagerListener (com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.BreakpointManagerListener)1 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)1 Graphics2D (java.awt.Graphics2D)1 HashSet (java.util.HashSet)1