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();
}
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();
}
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);
}
}
}
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();
}
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();
}
Aggregations