Search in sources :

Example 11 with Breakpoint

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

the class CBreakpointFunctionsTest method test4DisableBreakpoints.

@Test
public void test4DisableBreakpoints() {
    final INaviModule mockModule = new MockModule();
    final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0)))));
    final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0))));
    @SuppressWarnings("unused") final CAddress address = new CAddress(0);
    final BaseNode root = new BaseNode();
    final BreakpointCondition bpCondition = new BreakpointCondition("foo", root);
    breakPoint.setCondition(bpCondition);
    breakPoint.setDescription("purzel");
    debuggerProvider.addDebugger(debugger);
    @SuppressWarnings("unused") final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
    final int[] rows = { 0 };
    final int[] rows2 = { 1 };
    assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
    try {
        CBreakpointRemoveFunctions.disableBreakpoints(debuggerProvider, rows2);
    } catch (final IllegalArgumentException e) {
    }
    CBreakpointRemoveFunctions.disableBreakpoints(debuggerProvider, rows);
    assertTrue(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
}
Also used : Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) BaseNode(com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode) CBreakpointTableModel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointCondition(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Test(org.junit.Test)

Example 12 with Breakpoint

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

the class CBreakpointFunctionsTest method test3disableAll.

@Test
public void test3disableAll() {
    final INaviModule mockModule = new MockModule();
    final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0)))));
    final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0))));
    @SuppressWarnings("unused") final CAddress address = new CAddress(0);
    final BaseNode root = new BaseNode();
    final BreakpointCondition bpCondition = new BreakpointCondition("foo", root);
    breakPoint.setCondition(bpCondition);
    breakPoint.setDescription("purzel");
    debuggerProvider.addDebugger(debugger);
    @SuppressWarnings("unused") final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
    final int[] rows = { 0 };
    assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
    CBreakpointRemoveFunctions.disableAll(debuggerProvider);
    assertTrue(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
}
Also used : Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) BaseNode(com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode) CBreakpointTableModel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointCondition(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Test(org.junit.Test)

Example 13 with Breakpoint

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

the class CBreakpointFunctionsTest method test5enableFunctions.

@Test
public void test5enableFunctions() {
    final INaviModule mockModule = new MockModule();
    final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0)))));
    final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0))));
    @SuppressWarnings("unused") final CAddress address = new CAddress(0);
    final BaseNode root = new BaseNode();
    final BreakpointCondition bpCondition = new BreakpointCondition("foo", root);
    breakPoint.setCondition(bpCondition);
    breakPoint.setDescription("purzel");
    debuggerProvider.addDebugger(debugger);
    @SuppressWarnings("unused") final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
    final int[] rows = { 0 };
    assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
    CBreakpointRemoveFunctions.disableAll(debuggerProvider);
    assertTrue(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
    CBreakpointSetFunctions.enableAll(debuggerProvider);
    assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
    CBreakpointRemoveFunctions.disableAll(debuggerProvider);
    assertTrue(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
    CBreakpointSetFunctions.enableBreakpoints(debuggerProvider, rows);
    assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
}
Also used : Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) BaseNode(com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode) CBreakpointTableModel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointCondition(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Test(org.junit.Test)

Example 14 with Breakpoint

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

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

the class CDebugBreakpointTest method testRegularBreakpoint.

/**
   * Tests whether all getter and setter methods work properly for regular breakpoints.
   */
@Test
public void testRegularBreakpoint() {
    final Breakpoint bp = new Breakpoint(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_123);
    // Test whether the constructor worked properly.
    assertEquals(BreakpointType.REGULAR, bp.getType());
    assertEquals(null, bp.getDescription());
    assertEquals(BigInteger.valueOf(0x123), bp.getAddress().getAddress().getAddress().toBigInteger());
    assertEquals(BreakpointType.REGULAR, bp.getType());
    assertEquals(null, bp.getDescription());
    assertEquals(BigInteger.valueOf(0x123), bp.getAddress().getAddress().getAddress().toBigInteger());
    assertEquals(BreakpointType.REGULAR, bp.getType());
    assertEquals(null, bp.getDescription());
    assertEquals(BigInteger.valueOf(0x123), bp.getAddress().getAddress().getAddress().toBigInteger());
    // Test the comment setter method.
    bp.setDescription("foo");
    assertEquals(BreakpointType.REGULAR, bp.getType());
    assertEquals("foo", bp.getDescription());
    assertEquals(BigInteger.valueOf(0x123), bp.getAddress().getAddress().getAddress().toBigInteger());
}
Also used : Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) Test(org.junit.Test)

Aggregations

Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)21 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)14 Test (org.junit.Test)12 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)11 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)11 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)10 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)10 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)10 BreakpointCondition (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition)8 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)8 BaseNode (com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode)8 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)8 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)7 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)7 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)6 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)5 HashSet (java.util.HashSet)5 Pair (com.google.security.zynamics.zylib.general.Pair)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)2 MockFunction (com.google.security.zynamics.binnavi.disassembly.MockFunction)2