Search in sources :

Example 11 with ITraceEvent

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

the class PostgreSQLTraceFunctions method saveEventValues.

/**
   * Saves the event values of a trace.
   *
   * @param connection Connection to the database.
   * @param trace Trace whose event values are saved.
   *
   * @throws CouldntSaveDataException Thrown if the data could not be saved.
   */
public static void saveEventValues(final CConnection connection, final TraceList trace) throws CouldntSaveDataException {
    Preconditions.checkNotNull(connection, "IE02412: connection argument can not be null");
    Preconditions.checkNotNull(trace, "IE02413: trace argument can not be null");
    final String query = "INSERT INTO " + CTableNames.TRACE_EVENT_VALUES_TABLE + "(trace_id, position, register_name, register_value, memory_value) VALUES " + "(?, ?, ?, ?, ?)";
    try {
        final PreparedStatement preparedStatement = connection.getConnection().prepareStatement(query);
        int position = 0;
        for (final ITraceEvent traceEvent : trace) {
            for (final TraceRegister register : traceEvent.getRegisterValues()) {
                preparedStatement.setInt(1, trace.getId());
                preparedStatement.setInt(2, position);
                preparedStatement.setString(3, register.getName());
                preparedStatement.setLong(4, register.getValue().toLong());
                preparedStatement.setBytes(5, register.getMemory());
                preparedStatement.addBatch();
            }
            ++position;
        }
        preparedStatement.executeBatch();
        preparedStatement.close();
    } catch (final SQLException exception) {
        throw new CouldntSaveDataException(exception);
    }
}
Also used : SQLException(java.sql.SQLException) TraceRegister(com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) PreparedStatement(java.sql.PreparedStatement) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 12 with ITraceEvent

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

the class PostgreSQLTraceFunctions method saveEvents.

/**
   * Saves the events of a trace.
   *
   * @param connection Connection to the database.
   * @param trace The trace whose events are saved.
   *
   * @throws CouldntSaveDataException Thrown if the events could not be saved.
   */
private static void saveEvents(final CConnection connection, final TraceList trace) throws CouldntSaveDataException {
    final String queryPrefix = "INSERT INTO " + CTableNames.TRACE_EVENT_TABLE + "(trace_id, position, tid, module_id, address, type) VALUES";
    final StringBuilder stringBuilder = new StringBuilder(queryPrefix);
    int position = 0;
    for (final ITraceEvent traceEvent : trace) {
        final String moduleString = traceEvent.getOffset().getModule() == null ? "null" : String.valueOf(traceEvent.getOffset().getModule().getConfiguration().getId());
        stringBuilder.append(String.format(Locale.ENGLISH, "(%d, %d, %d, %s, %s, %d)", trace.getId(), position, traceEvent.getThreadId(), moduleString, traceEvent.getOffset().getAddress().getAddress().toBigInteger().toString(), 1));
        ++position;
        if (trace.getEventCount() > position) {
            stringBuilder.append(", ");
        }
    }
    try {
        final PreparedStatement prep = connection.getConnection().prepareStatement(stringBuilder.toString());
        try {
            prep.execute();
        } catch (final SQLException exception) {
            throw new CouldntSaveDataException(exception);
        } finally {
            prep.close();
        }
    } catch (final SQLException exception) {
        throw new CouldntSaveDataException(exception);
    }
}
Also used : SQLException(java.sql.SQLException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) PreparedStatement(java.sql.PreparedStatement) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 13 with ITraceEvent

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

the class CTracesNodeComponent method showRelevantViews.

/**
   * Shows the views that belong to a trace in the table in the lower half of the component.
   *
   * @param trace The trace list.
   *
   * @throws CouldntLoadDataException
   */
private void showRelevantViews(final TraceList trace) throws CouldntLoadDataException {
    final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
    for (final ITraceEvent traceEvent : trace) {
        addresses.add(traceEvent.getOffset().getAddress());
    }
    final List<INaviView> views = m_container.getViewsWithAddresses(addresses, false);
    if (m_container instanceof CProjectContainer) {
        for (final INaviModule module : m_container.getModules()) {
            if (module.isLoaded()) {
                views.addAll(module.getViewsWithAddresses(addresses, false));
            }
        }
    }
    m_model.setViews(views);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CProjectContainer(com.google.security.zynamics.binnavi.disassembly.CProjectContainer) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Aggregations

ITraceEvent (com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)13 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)8 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)7 TraceRegister (com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister)6 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)5 TraceEvent (com.google.security.zynamics.binnavi.debug.models.trace.TraceEvent)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 Test (org.junit.Test)4 CTraceFilterCreator (com.google.security.zynamics.binnavi.Gui.Debug.EventLists.CTraceFilterCreator)3 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)3 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)3 ArrayList (java.util.ArrayList)3 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)2 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)2 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 CEventTableModel (com.google.security.zynamics.binnavi.Gui.Debug.EventLists.CEventTableModel)1 COpenInLastWindowAction (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Views.Component.Actions.COpenInLastWindowAction)1