Search in sources :

Example 1 with DebuggerSynchronizer

use of com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer in project binnavi by google.

the class BreakpointLifecycleTest method setUp.

@Before
public void setUp() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    m_debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    m_debugger.setAddressTranslator(CommonTestObjects.MODULE, mockFileBase, mockImageBase.getAddress());
    m_breakpointManager = m_debugger.getBreakpointManager();
    m_synchronizer = new DebuggerSynchronizer(m_debugger);
    m_synchronizer.addListener(m_listener);
    // assign the synchronizer to the internally used one by the debugger so we can test the
    // synchronizer itself
    // as well as the combination of synchronizer and debugger
    final Field synchronizerField = AbstractDebugger.class.getDeclaredField("synchronizer");
    synchronizerField.setAccessible(true);
    synchronizerField.set(m_debugger, m_synchronizer);
}
Also used : DebuggerSynchronizer(com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer) Field(java.lang.reflect.Field) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) Before(org.junit.Before)

Example 2 with DebuggerSynchronizer

use of com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer in project binnavi by google.

the class CBreakpointSynchronizerTest method setUp.

@Before
public void setUp() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    m_debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
    m_debugger.setAddressTranslator(mockModule, mockFileBase, mockImageBase.getAddress());
    m_breakpointManager = m_debugger.getBreakpointManager();
    m_synchronizer = new DebuggerSynchronizer(m_debugger);
    m_synchronizer.addListener(m_listener);
    // assign the synchronizer to the internally used one by the debugger so we can test the
    // synchronizer itself
    // as well as the combination of synchronizer and debugger
    final Field synchronizerField = AbstractDebugger.class.getDeclaredField("synchronizer");
    synchronizerField.setAccessible(true);
    synchronizerField.set(m_debugger, m_synchronizer);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) DebuggerSynchronizer(com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer) Field(java.lang.reflect.Field) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) Before(org.junit.Before)

Example 3 with DebuggerSynchronizer

use of com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer in project binnavi by google.

the class CHistoryStringBuilderTest method setUp.

@Before
public void setUp() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    m_debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
    m_debugger.setAddressTranslator(mockModule, mockFileBase, mockImageBase.getAddress());
    m_breakpointManager = m_debugger.getBreakpointManager();
    m_synchronizer = new DebuggerSynchronizer(m_debugger);
    m_synchronizer.addListener(m_listener);
    // assign the synchronizer to the internally used one by the debugger so we can test the
    // synchronizer itself
    // as well as the combination of synchronizer and debugger
    final Field synchronizerField = AbstractDebugger.class.getDeclaredField("synchronizer");
    synchronizerField.setAccessible(true);
    synchronizerField.set(m_debugger, m_synchronizer);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) DebuggerSynchronizer(com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer) Field(java.lang.reflect.Field) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) Before(org.junit.Before)

Example 4 with DebuggerSynchronizer

use of com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer in project binnavi by google.

the class CTraceLoggerTest method testHitEchoBreakpoint.

@Test
public void testHitEchoBreakpoint() throws DebugExceptionWrapper, MessageParserException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // Scenario: All echo breakpoints are hit
    final ITraceListProvider provider = new MockTraceListProvider();
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(module));
    final MockModule module = new MockModule();
    debugger.setAddressTranslator(module, new CAddress(0), new CAddress(0x1000));
    debugger.connect();
    final TraceLogger logger = new TraceLogger(provider, debugger);
    final MockTraceLoggerListener listener = new MockTraceLoggerListener();
    logger.addListener(listener);
    final MockSqlProvider sqlProvider = new MockSqlProvider();
    final TraceList trace = new TraceList(1, "Foo", "Bar", sqlProvider);
    final Set<BreakpointAddress> addresses = new HashSet<BreakpointAddress>();
    addresses.add(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0x100))));
    addresses.add(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0x200))));
    logger.start(trace, addresses, 3);
    final DebuggerSynchronizer m_synchronizer = (DebuggerSynchronizer) ReflectionHelpers.getField(AbstractDebugger.class, debugger, "synchronizer");
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1100))));
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1200))));
    assertEquals(2, trace.getEventCount());
    assertEquals("++", listener.events);
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1100))));
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1200))));
    assertEquals(4, trace.getEventCount());
    assertEquals("++", listener.events);
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1100))));
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1200))));
    assertEquals(6, trace.getEventCount());
    assertEquals("++--!", listener.events);
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1100))));
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1200))));
    assertEquals(6, trace.getEventCount());
    assertEquals("++--!", listener.events);
    logger.stop();
    assertEquals(6, trace.getEventCount());
    assertEquals("++--!", listener.events);
    logger.start(trace, addresses, 1);
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1100))));
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(new RelocatedAddress(new CAddress(0x1200))));
    logger.stop();
    assertEquals(8, trace.getEventCount());
    debugger.close();
}
Also used : DebuggerSynchronizer(com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer) ITraceListProvider(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceListProvider) TraceLogger(com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) 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) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) AbstractDebugger(com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with DebuggerSynchronizer

use of com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer in project binnavi by google.

the class CDebuggerSynchronizerTest method setUp.

@Before
public void setUp() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    mockDebugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    mockDebugger.setAddressTranslator(CommonTestObjects.MODULE, new CAddress(0), new CAddress(0x1000));
    breakpointManager = mockDebugger.getBreakpointManager();
    debuggerSynchronizer = new DebuggerSynchronizer(mockDebugger);
    debuggerSynchronizer.addListener(listener);
    // assign the synchronizer to the internally used one by the debugger so we can test the
    // synchronizer itself
    // as well as the combination of synchronizer and debugger
    final Field synchronizerField = AbstractDebugger.class.getDeclaredField("synchronizer");
    synchronizerField.setAccessible(true);
    synchronizerField.set(mockDebugger, debuggerSynchronizer);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) DebuggerSynchronizer(com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer) Field(java.lang.reflect.Field) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Before(org.junit.Before)

Aggregations

ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)5 DebuggerSynchronizer (com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer)5 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)4 Field (java.lang.reflect.Field)4 Before (org.junit.Before)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 AbstractDebugger (com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger)1 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)1 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)1 TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)1 ITraceListProvider (com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceListProvider)1 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)1 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)1 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1