Search in sources :

Example 6 with BreakpointManager

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

the class StepBreakpointHitSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final StepBreakpointHitReply reply) {
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final ProcessManager processManager = getDebugger().getProcessManager();
    RelocatedAddress breakpointAddress = null;
    final RegisterValues registerValues = reply.getRegisterValues();
    final long tid = reply.getThreadId();
    for (final ThreadRegisters threadRegisters : registerValues) {
        if (tid == threadRegisters.getTid()) {
            for (final RegisterValue registerValue : threadRegisters) {
                if (registerValue.isPc()) {
                    breakpointAddress = new RelocatedAddress(new CAddress(registerValue.getValue()));
                    break;
                }
            }
        }
    }
    manager.clearBreakpointsPassive(BreakpointType.STEP);
    try {
        final TargetProcessThread thread = processManager.getThread(tid);
        for (final ThreadRegisters threadRegisters : registerValues) {
            if (tid == threadRegisters.getTid()) {
                // Update the thread with the new register values.
                thread.setRegisterValues(threadRegisters.getRegisters());
            }
        }
        processManager.setActiveThread(thread);
        thread.setCurrentAddress(breakpointAddress);
    } catch (final MaybeNullException exception) {
        // Apparently there is no thread with the specified TID.
        // This is not necessarily an error because the thread might have
        // been closed while this handler was active.
        // Nevertheless this should be logged.
        NaviLogger.info("Error: Process manager could not get thread. Exception %s", exception);
        return;
    }
}
Also used : RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 7 with BreakpointManager

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

the class EchoBreakpointHitSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final EchoBreakpointHitReply reply) {
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final long tid = reply.getThreadId();
    for (final ThreadRegisters threadRegisters : reply.getRegisterValues()) {
        if (tid == threadRegisters.getTid()) {
            for (final RegisterValue registerValue : threadRegisters) {
                if (registerValue.isPc()) {
                    final RelocatedAddress address = new RelocatedAddress(new CAddress(registerValue.getValue()));
                    manager.setBreakpointStatus(Sets.newHashSet(DebuggerHelpers.getBreakpointAddress(getDebugger(), address)), BreakpointType.ECHO, BreakpointStatus.BREAKPOINT_HIT);
                    break;
                }
            }
        }
    }
}
Also used : RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 8 with BreakpointManager

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

the class CBreakpointTable method showPopupMenu.

/**
 * Displays the popup menu at the location specified by the click event.
 *
 * @param event The click event.
 */
private void showPopupMenu(final MouseEvent event) {
    final int row = rowAtPoint(event.getPoint());
    final int column = columnAtPoint(event.getPoint());
    int[] rows = getSelectedRows();
    if ((rows.length == 0) || (rows.length == 1)) {
        changeSelection(row, column, false, false);
        rows = getSelectedRows();
    }
    final JPopupMenu menu = new JPopupMenu();
    menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteAction(m_debuggerProvider, rows))));
    if (CBreakpointFunctions.allDisabled(m_debuggerProvider, rows)) {
        menu.add(new JMenuItem(CActionProxy.proxy(new CEnableAction(m_debuggerProvider, rows))));
    } else if (CBreakpointFunctions.allNotDisabled(m_debuggerProvider, rows)) {
        menu.add(new JMenuItem(CActionProxy.proxy(new CDisableAction(m_debuggerProvider, rows))));
    }
    if (rows.length == 1) {
        menu.addSeparator();
        final Pair<IDebugger, Integer> breakpoint = CBreakpointTableHelpers.findBreakpoint(m_debuggerProvider, rows[0]);
        final BreakpointManager manager = breakpoint.first().getBreakpointManager();
        final int breakpointIndex = breakpoint.second();
        final BreakpointAddress address = manager.getBreakpoint(BreakpointType.REGULAR, breakpointIndex).getAddress();
        menu.add(new JMenuItem(CActionProxy.proxy(new CZoomBreakpointAction(SwingUtilities.windowForComponent(this), m_graph, m_viewContainer, address))));
    }
    menu.show(event.getComponent(), event.getX(), event.getY());
}
Also used : CZoomBreakpointAction(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.Actions.CZoomBreakpointAction) CDeleteAction(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.Actions.CDeleteAction) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) JPopupMenu(javax.swing.JPopupMenu) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) CDisableAction(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.Actions.CDisableAction) JMenuItem(javax.swing.JMenuItem) CEnableAction(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.Actions.CEnableAction) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)

Example 9 with BreakpointManager

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

the class CBreakpointTableModel method getBreakpointAddress.

/**
 * Determines the address of the breakpoint shown in a given row.
 *
 * @param row The row where the breakpoint is shown.
 *
 * @return The address of the breakpoint shown in the given row.
 */
private IAddress getBreakpointAddress(final int row) {
    final Pair<IDebugger, Integer> breakpoint = CBreakpointTableHelpers.findBreakpoint(m_debuggerProvider, row);
    final BreakpointManager manager = breakpoint.first().getBreakpointManager();
    final int breakpointIndex = breakpoint.second();
    return manager.getBreakpoint(BreakpointType.REGULAR, breakpointIndex).getAddress().getAddress().getAddress();
}
Also used : BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 10 with BreakpointManager

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

the class CBreakpointTableModel method getBreakpointCondition.

/**
 * Returns the breakpoint condition for the breakpoint in the given row.
 *
 * @param row Row index of the breakpoint.
 *
 * @return Formula string of the breakpoint condition.
 */
private String getBreakpointCondition(final int row) {
    final Pair<IDebugger, Integer> breakpoint = CBreakpointTableHelpers.findBreakpoint(m_debuggerProvider, row);
    final BreakpointManager manager = breakpoint.first().getBreakpointManager();
    final int breakpointIndex = breakpoint.second();
    final Condition condition = manager.getBreakpoint(BreakpointType.REGULAR, breakpointIndex).getCondition();
    return condition == null ? "" : condition.toString();
}
Also used : Condition(com.google.security.zynamics.binnavi.debug.models.breakpoints.interfaces.Condition) 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