Search in sources :

Example 16 with BreakpointManager

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager 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 17 with BreakpointManager

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

the class CGraphDebuggerTest method testRemoveBreakpoint.

@Test
public void testRemoveBreakpoint() {
    final BreakpointManager manager = new BreakpointManager();
    manager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_123_SET);
    manager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_456_SET);
    manager.setBreakpointStatus(BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE, 1);
    CGraphDebugger.removeBreakpoints(CommonTestObjects.BP_ADDRESS_123_SET, manager);
    CGraphDebugger.removeBreakpoints(CommonTestObjects.BP_ADDRESS_456_SET, manager);
    assertEquals(1, manager.getNumberOfBreakpoints(BreakpointType.REGULAR));
    assertEquals(0x123, manager.getBreakpoint(BreakpointType.REGULAR, 0).getAddress().getAddress().getAddress().toLong());
    assertEquals(BreakpointStatus.BREAKPOINT_DELETING, manager.getBreakpointStatus(BreakpointType.REGULAR, 1));
}
Also used : BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) Test(org.junit.Test)

Example 18 with BreakpointManager

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

the class CBreakpointManagerTest method setUp.

@Before
public void setUp() {
    m_manager = new BreakpointManager();
    m_manager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_123_SET);
    m_manager.addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x456)))));
    m_manager.addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x789)))));
    m_manager.addBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x111)))));
    m_manager.addBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x222)))));
    m_manager.addBreakpoints(BreakpointType.STEP, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x1000)))));
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Before(org.junit.Before)

Example 19 with BreakpointManager

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

the class BreakpointSetSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final BreakpointSetReply reply) {
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final Set<BreakpointAddress> addressesToActivate = new HashSet<>();
    final Set<BreakpointAddress> addressesToInvalidate = new HashSet<>();
    for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
        if (resultPair.second() == 0) {
            // If a breakpoint was successfully set in the target process, its status is
            // set to ACTIVE in the breakpoint manager.
            final BreakpointAddress breakpointAddress = DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first());
            if (manager.getBreakpointStatus(breakpointAddress, BreakpointType.REGULAR) != BreakpointStatus.BREAKPOINT_DISABLED) {
                addressesToActivate.add(breakpointAddress);
            }
        } else {
            // If a breakpoint could not be set in the target process, its status in the
            // breakpoint manager is set to INVALID. The real status of the breakpoint
            // is unknown though.
            addressesToInvalidate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first()));
        }
    }
    manager.setBreakpointStatus(addressesToInvalidate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_INVALID);
    manager.setBreakpointStatus(addressesToActivate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE);
}
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 20 with BreakpointManager

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

the class BreakpointRemovedSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final BreakpointsRemovedReply reply) {
    // If a breakpoint was removed from the target process, it can be removed
    // from the breakpoint manager too unless the breakpoint is set to disabled
    // there.
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final Set<BreakpointAddress> addressesToRemove = new HashSet<>();
    final Set<BreakpointAddress> addressesToInvalidate = new HashSet<>();
    for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
        if (resultPair.second() == 0) {
            final BreakpointAddress address = DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first());
            if (manager.getBreakpointStatus(address, BreakpointType.REGULAR) == BreakpointStatus.BREAKPOINT_DELETING) {
                addressesToRemove.add(address);
            }
        } else {
            addressesToInvalidate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first()));
        }
    }
    manager.removeBreakpointsPassive(BreakpointType.REGULAR, addressesToRemove);
    manager.setBreakpointStatus(addressesToInvalidate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_INVALID);
}
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)

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