Search in sources :

Example 16 with TraceList

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);
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) Test(org.junit.Test)

Example 17 with TraceList

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;
}
Also used : TraceRegister(com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) ArrayList(java.util.ArrayList) List(java.util.List) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 18 with TraceList

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());
}
Also used : TraceEventType(com.google.security.zynamics.binnavi.debug.models.trace.TraceEventType) ArrayList(java.util.ArrayList) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) TraceRegister(com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent) TraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.TraceEvent) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 19 with TraceList

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());
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 20 with TraceList

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));
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)

Aggregations

TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)46 Test (org.junit.Test)26 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)14 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)11 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)10 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)10 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)10 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)9 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)7 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)7 TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)7 ITraceListProvider (com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceListProvider)7 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)6 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)6 Trace (com.google.security.zynamics.binnavi.API.disassembly.Trace)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)5 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)5 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)4