use of com.google.security.zynamics.binnavi.debug.models.trace.TraceList in project binnavi by google.
the class TraceTest method testSetDescription.
@Test
public void testSetDescription() throws CouldntSaveDataException {
final Trace trace = new Trace(new TraceList(1, "Name", "Description", new MockSqlProvider()));
final MockTraceListener listener = new MockTraceListener();
trace.addListener(listener);
trace.setDescription("D1");
assertEquals("D1", trace.getDescription());
assertEquals("changedDescription;", listener.events);
trace.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.debug.models.trace.TraceList in project binnavi by google.
the class PostgreSQLTracesLoader method loadTraceEventValues.
/**
* Loads the event values of a trace from the database.
*
* @param connection Connection to the database.
* @param traceList The trace to load.
*
* @return The event values.
*
* @throws SQLException Thrown if the values could not be loaded.
*/
private static List<List<TraceRegister>> loadTraceEventValues(final CConnection connection, final TraceList traceList) throws SQLException {
final List<List<TraceRegister>> values = new ArrayList<>();
final String query = "select position, register_name, register_value, memory_value from " + CTableNames.TRACE_EVENT_VALUES_TABLE + " where trace_id = " + traceList.getId() + " order by position asc";
final ResultSet resultSet = connection.executeQuery(query, true);
int currentPosition = -1;
try {
List<TraceRegister> registers = new ArrayList<TraceRegister>();
while (resultSet.next()) {
final int position = resultSet.getInt("position");
if (position != currentPosition) {
if (!registers.isEmpty()) {
values.add(Lists.newArrayList(registers));
registers = new FilledList<TraceRegister>();
}
currentPosition = position;
}
final String name = PostgreSQLHelpers.readString(resultSet, "register_name");
final long value = resultSet.getLong("register_value");
final byte[] memory = resultSet.getBytes("memory_value");
registers.add(new TraceRegister(name, new CAddress(value), memory));
}
if (!registers.isEmpty()) {
values.add(Lists.newArrayList(registers));
}
} finally {
resultSet.close();
}
return values;
}
use of com.google.security.zynamics.binnavi.debug.models.trace.TraceList in project binnavi by google.
the class PostgreSQLProviderTest method testTraceFunctionsSave1.
@Test
public void testTraceFunctionsSave1() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
final INaviProject project = getProvider().createProject("SOME_PROJECT");
getProvider().createTrace(project, "SOME_TRACE", "SOME_TRACE_DESCRIPTION");
project.load();
final TraceList trace = project.getContent().getTraces().get(0);
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final long tid = 0x1L;
final UnrelocatedAddress address2 = new UnrelocatedAddress(new CAddress(0x1234));
final BreakpointAddress address = new BreakpointAddress(module, address2);
final TraceEventType type = TraceEventType.ECHO_BREAKPOINT;
final List<TraceRegister> values = new ArrayList<>();
final ITraceEvent event = new TraceEvent(tid, address, type, values);
trace.addEvent(event);
trace.setDescription("burzelbarf");
PostgreSQLTraceFunctions.save((AbstractSQLProvider) getProvider(), trace);
project.close();
INaviProject project2 = null;
for (final INaviProject cProject : getProvider().loadProjects()) {
if (cProject.getConfiguration().getId() == project.getConfiguration().getId()) {
project2 = cProject;
}
}
getProvider().createTrace(project2, "SOME_TRACE_2", "SOME_TRACE_DESCRIPTION_2");
project2.load();
final TraceList trace2 = project2.getContent().getTraces().get(0);
assertEquals("burzelbarf", trace2.getDescription());
}
use of com.google.security.zynamics.binnavi.debug.models.trace.TraceList in project binnavi by google.
the class PostgreSQLProviderTestSetup method testCreateTraceModule4.
@Test
public void testCreateTraceModule4() throws CouldntSaveDataException, CouldntLoadDataException {
final INaviModule module = getProvider().loadModules().get(0);
final TraceList trace = getProvider().createTrace(module, "Trace Name", "Trace Description");
assertEquals("Trace Name", trace.getName());
assertEquals("Trace Description", trace.getDescription());
assertEquals(0, trace.getEventCount());
}
use of com.google.security.zynamics.binnavi.debug.models.trace.TraceList in project binnavi by google.
the class Project method convertData.
/**
* Converts the internal project data to API project data.
*/
private void convertData() {
m_debuggerTemplates = new FilledList<DebuggerTemplate>();
final List<DebuggerTemplate> apiTemplates = m_database.getDebuggerTemplateManager().getDebuggerTemplates();
for (final com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate debuggerTemplate : m_project.getConfiguration().getDebuggers()) {
m_debuggerTemplates.add(ObjectFinders.getObject(debuggerTemplate, apiTemplates));
}
m_traces = new FilledList<Trace>();
for (final TraceList trace : m_project.getContent().getTraces()) {
m_traces.add(new Trace(trace));
}
m_addressSpaces = new FilledList<AddressSpace>();
for (final INaviAddressSpace addressSpace : m_project.getContent().getAddressSpaces()) {
m_addressSpaces.add(new AddressSpace(m_database, this, addressSpace));
}
m_views = new FilledList<View>();
for (final INaviView view : m_project.getContent().getViews()) {
m_views.add(new View(this, view, m_nodeTagManager, m_viewTagManager));
}
}
Aggregations