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