Search in sources :

Example 56 with BreakpointAddress

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

the class StepBreakpointSetSynchronizer method handleSuccess.

/**
   * When a stepping breakpoint was set in the target process, its state is set to ACTIVE in the
   * breakpoint manager.
   */
@Override
protected void handleSuccess(final StepBreakpointSetReply reply) {
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final Set<BreakpointAddress> addressesToActivate = new HashSet<BreakpointAddress>();
    final Set<BreakpointAddress> addressesToRemove = new HashSet<BreakpointAddress>();
    for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
        final RelocatedAddress address = resultPair.first();
        if (resultPair.second() == DebuggerErrorCodes.SUCCESS) {
            addressesToActivate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
        } else {
            addressesToRemove.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
        }
    }
    manager.setBreakpointStatus(addressesToActivate, BreakpointType.STEP, BreakpointStatus.BREAKPOINT_ACTIVE);
    manager.removeBreakpoints(BreakpointType.STEP, addressesToRemove);
}
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 57 with BreakpointAddress

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

the class BreakpointManagerTest method testSetBreakpoint.

@Test
public void testSetBreakpoint() {
    apiManager.addListener(mockListener);
    try {
        apiManager.setBreakpoint(null, null);
    } catch (final NullPointerException exception) {
    }
    apiManager.setBreakpoint(module, new Address(0x123));
    assertEquals("addedBreakpoint/123;", mockListener.events);
    try {
        apiManager.setBreakpoint(null, new Address(0x123));
    } catch (final NullPointerException exception) {
    }
    internalManager.addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(CommonTestObjects.MODULE, new UnrelocatedAddress(new CAddress(0x124)))));
    assertEquals("addedBreakpoint/123;addedBreakpoint/124;", mockListener.events);
    assertTrue(apiManager.hasBreakpoint(module, new Address(0x124)));
    apiManager.removeListener(mockListener);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 58 with BreakpointAddress

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

the class BreakpointManagerTest method testSetEchoBreakpoint.

@Test
public void testSetEchoBreakpoint() {
    apiManager.addListener(mockListener);
    try {
        apiManager.setEchoBreakpoint(null, null);
    } catch (final NullPointerException exception) {
    }
    apiManager.setEchoBreakpoint(module, new Address(0x123));
    assertEquals("addedEchoBreakpoint/123;", mockListener.events);
    try {
        apiManager.setEchoBreakpoint(null, new Address(0x123));
    } catch (final NullPointerException exception) {
    }
    internalManager.addBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(CommonTestObjects.MODULE, new UnrelocatedAddress(new CAddress(0x124)))));
    assertEquals("addedEchoBreakpoint/123;addedEchoBreakpoint/124;", mockListener.events);
    assertTrue(apiManager.hasEchoBreakpoint(module, new Address(0x124)));
    apiManager.removeListener(mockListener);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 59 with BreakpointAddress

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

the class BreakpointManagerTest method testRemoveEchoBreakpoint.

@Test
public void testRemoveEchoBreakpoint() {
    try {
        apiManager.removeEchoBreakpoint(null, null);
        fail();
    } catch (final NullPointerException exception) {
    }
    apiManager.setEchoBreakpoint(module, new Address(0x123));
    apiManager.setEchoBreakpoint(module, new Address(0x124));
    apiManager.addListener(mockListener);
    apiManager.removeEchoBreakpoint(module, new Address(0x123));
    internalManager.removeBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(CommonTestObjects.MODULE, new UnrelocatedAddress(new CAddress(0x124)))));
    assertEquals("removedEchoBreakpoint/123;removedEchoBreakpoint/124;", mockListener.events);
    assertEquals(0, apiManager.getBreakpoints().size());
    apiManager.removeListener(mockListener);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 60 with BreakpointAddress

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

the class CEventValueTableModelTest method foo.

@Test
public void foo() {
    final CEventValueTableModel model = new CEventValueTableModel();
    final INaviModule mockModule = new MockModule();
    final TraceEvent event = new TraceEvent(77, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x123))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 05, 06, 07 })));
    assertEquals(0, model.getRowCount());
    model.setEvent(event);
    assertEquals(1, model.getRowCount());
    assertEquals("eax", model.getValueAt(0, 0));
    assertEquals("00000123", model.getValueAt(0, 1));
    assertEquals("05 06 07", model.getValueAt(0, 2));
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) TraceRegister(com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CEventValueTableModel(com.google.security.zynamics.binnavi.Gui.Debug.EventLists.CEventValueTableModel) TraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.TraceEvent) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)87 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)60 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)49 Test (org.junit.Test)39 HashSet (java.util.HashSet)24 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)22 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)15 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)15 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)13 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)11 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)11 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)11 ArrayList (java.util.ArrayList)9 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)8 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)8 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)8 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)7 TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)7 ITraceEvent (com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)7