Search in sources :

Example 1 with TracePoint

use of com.google.security.zynamics.binnavi.API.disassembly.TracePoint in project binnavi by google.

the class TraceLoggerTest method testHits.

@Test
public void testHits() throws CouldntSaveDataException, DebugExceptionWrapper {
    m_mockDebugger.connect();
    final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100)), new TracePoint(m_mockModule, new Address(0x100))));
    m_mockDebugger.connection.m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 0, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x1100), new byte[0], true, false)))))));
    m_logger.stop();
    assertEquals("Name", trace.getName());
    assertEquals("Description", trace.getDescription());
    assertEquals(1, trace.getEvents().size());
    assertEquals(0x100, trace.getEvents().get(0).getAddress().toLong());
    assertEquals("TraceLogger [Debugger 'Mock' : Mock Module]", m_logger.toString());
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) EchoBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply) TracePoint(com.google.security.zynamics.binnavi.API.disassembly.TracePoint) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) Test(org.junit.Test)

Example 2 with TracePoint

use of com.google.security.zynamics.binnavi.API.disassembly.TracePoint in project binnavi by google.

the class TraceLoggerTest method testHitsProject.

@Test
public void testHitsProject() throws CouldntSaveDataException, DebugExceptionWrapper {
    m_mockDebugger.connect();
    final Trace trace = m_projectLogger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
    m_mockDebugger.connection.m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 0, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x1100), new byte[0], true, false)))))));
    m_projectLogger.stop();
    assertEquals("Name", trace.getName());
    assertEquals("Description", trace.getDescription());
    assertEquals(1, trace.getEvents().size());
    assertEquals(0x100, trace.getEvents().get(0).getAddress().toLong());
    assertEquals("TraceLogger [Debugger 'Mock' : Mock Project]", m_projectLogger.toString());
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) EchoBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply) TracePoint(com.google.security.zynamics.binnavi.API.disassembly.TracePoint) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) Test(org.junit.Test)

Example 3 with TracePoint

use of com.google.security.zynamics.binnavi.API.disassembly.TracePoint in project binnavi by google.

the class TraceLogger method start.

// / Starts trace logging.
/**
   * Starts trace logging with this logger.
   *
   * @param name The name of the new trace.
   * @param description The description of the new trace.
   * @param addresses List of addresses where echo breakpoints should be set.
   *
   * @return The created event trace.
   *
   * @throws CouldntSaveDataException Thrown if the event trace could not be written to the
   *         database.
   */
public Trace start(final String name, final String description, final List<TracePoint> addresses) throws CouldntSaveDataException {
    Preconditions.checkArgument(debugger.isConnected(), "Error: Debugger must be connected");
    Preconditions.checkArgument(logger == null, "Error: Addresses argument can not be null");
    Preconditions.checkNotNull(addresses, "Error: Addresses argument can not be null");
    for (final TracePoint address : addresses) {
        Preconditions.checkNotNull(address, "Error: Addresses list contains null-elements");
    }
    try {
        final TraceList trace = createTrace(name, description);
        logger = createLogger();
        logger.start(trace, convertAddresses(addresses), 3);
        return ObjectFinders.getObject(trace, getTraces());
    } catch (final com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException e) {
        throw new CouldntSaveDataException(e);
    }
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.API.disassembly.CouldntSaveDataException) TracePoint(com.google.security.zynamics.binnavi.API.disassembly.TracePoint) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Example 4 with TracePoint

use of com.google.security.zynamics.binnavi.API.disassembly.TracePoint in project binnavi by google.

the class TraceLoggerTest method testEmptyHits.

@Test
public void testEmptyHits() throws CouldntSaveDataException, DebugExceptionWrapper {
    m_mockDebugger.connect();
    final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
    m_logger.stop();
    assertEquals("Name", trace.getName());
    assertEquals("Description", trace.getDescription());
    assertTrue(trace.getEvents().isEmpty());
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) TracePoint(com.google.security.zynamics.binnavi.API.disassembly.TracePoint) Test(org.junit.Test)

Example 5 with TracePoint

use of com.google.security.zynamics.binnavi.API.disassembly.TracePoint in project binnavi by google.

the class TraceLoggerTest method testStartErrors.

@Test
public void testStartErrors() throws CouldntSaveDataException, DebugExceptionWrapper {
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
        fail();
    } catch (final IllegalArgumentException exception) {
    }
    m_mockDebugger.connect();
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start(null, "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", null, Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", "Description", null);
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, null)));
        fail();
    } catch (final NullPointerException exception) {
    }
    @SuppressWarnings("unused") final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
    try {
        m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
        fail();
    } catch (final IllegalArgumentException exception) {
    }
    m_logger.stop();
    try {
        m_logger.stop();
        fail();
    } catch (final NullPointerException exception) {
    }
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) TracePoint(com.google.security.zynamics.binnavi.API.disassembly.TracePoint) Test(org.junit.Test)

Aggregations

TracePoint (com.google.security.zynamics.binnavi.API.disassembly.TracePoint)5 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)4 Trace (com.google.security.zynamics.binnavi.API.disassembly.Trace)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 Test (org.junit.Test)4 EchoBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply)2 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)2 RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)2 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)2 CouldntSaveDataException (com.google.security.zynamics.binnavi.API.disassembly.CouldntSaveDataException)1 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)1