Search in sources :

Example 1 with TraceLogger

use of com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger in project binnavi by google.

the class CTraceLoggerTest method testOverwrittenEchoBreakpoint.

@Test
public void testOverwrittenEchoBreakpoint() throws DebugExceptionWrapper {
    // Scenario: Echo breakpoint of the trace is overwritten by a regular breakpoint
    final ITraceListProvider provider = new MockTraceListProvider();
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(module));
    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, 1);
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0x100)))));
    assertEquals("++-", listener.events);
    logger.stop();
    assertEquals("++--!", listener.events);
    // Start the trace mode again to make sure all resources were cleaned
    // up in the previous run.
    logger.start(trace, addresses, 1);
    logger.stop();
    debugger.close();
}
Also used : ITraceListProvider(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceListProvider) TraceLogger(com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger) 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) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) 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 2 with TraceLogger

use of com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger in project binnavi by google.

the class CTraceLoggerTest method testTargetClosed.

@Test
public void testTargetClosed() throws DebugExceptionWrapper {
    final ITraceListProvider provider = new MockTraceListProvider();
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(module));
    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))));
    logger.start(trace, addresses, 1);
    debugger.getProcessManager().setAttached(false);
    assertEquals("+!", listener.events);
    logger.stop();
    // assertEquals(0, debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.ECHO));
    // Start the trace mode again to make sure all resources were cleaned
    // up in the previous run.
    logger.start(trace, addresses, 1);
    logger.stop();
    debugger.close();
}
Also used : ITraceListProvider(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceListProvider) TraceLogger(com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger) 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) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) 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 3 with TraceLogger

use of com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger in project binnavi by google.

the class CDebugPerspectiveModel method setActiveDebugger.

/**
   * Sets the active debugger.
   *
   * @param debugger The new debugger.
   */
public void setActiveDebugger(final IDebugger debugger) {
    if (m_activeDebugger == debugger) {
        return;
    }
    if ((debugger != null) && !m_eventLoggerMap.containsKey(debugger)) {
        m_notifierMap.put(debugger, new CDebugEventNotifier(m_model.getParent(), debugger, m_model.getDebuggerProvider().getDebugTarget(), m_model.getViewContainer()));
        m_eventLoggerMap.put(debugger, new TraceLogger(m_model.getViewContainer().getTraceProvider(), debugger));
    }
    final IDebugger oldDebugger = m_activeDebugger;
    m_activeDebugger = debugger;
    for (final IDebugPerspectiveModelListener listener : m_listeners) {
        // ESCA-JAVA0166: Calling a listener
        try {
            listener.changedActiveDebugger(oldDebugger, m_activeDebugger);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : TraceLogger(com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger) CDebugEventNotifier(com.google.security.zynamics.binnavi.Gui.Debug.Notifier.CDebugEventNotifier) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 4 with TraceLogger

use of com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger in project binnavi by google.

the class CTraceLoggerTest method testAllBreakpointsBlocked.

@Test
public void testAllBreakpointsBlocked() throws DebugExceptionWrapper {
    // Scenario: All given addresses are already blocked by regular breakpoints
    final ITraceListProvider provider = new MockTraceListProvider();
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(module));
    debugger.setAddressTranslator(module, new CAddress(0), new CAddress(0x1000));
    debugger.connect();
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0x100)))));
    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))));
    logger.start(trace, addresses, 1);
    logger.stop();
    assertEquals("", listener.events);
    // Start the trace mode again to make sure all resources were cleaned
    // up in the previous run.
    logger.start(trace, addresses, 1);
    logger.stop();
    debugger.close();
}
Also used : ITraceListProvider(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceListProvider) TraceLogger(com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger) 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) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) 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 TraceLogger

use of com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger 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)

Aggregations

TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)8 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)7 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)7 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)7 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)7 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)7 ITraceListProvider (com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceListProvider)7 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)7 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)7 HashSet (java.util.HashSet)7 Test (org.junit.Test)7 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)2 CDebugEventNotifier (com.google.security.zynamics.binnavi.Gui.Debug.Notifier.CDebugEventNotifier)1 AbstractDebugger (com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger)1 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)1 DebuggerSynchronizer (com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer)1 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)1 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)1