Search in sources :

Example 1 with ITraceEvent

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

the class CEventTableModel method getValueAt.

@Override
public Object getValueAt(final int row, final int col) {
    final ITraceEvent debugEvent = getEvents().get(row);
    final BreakpointAddress address = debugEvent.getOffset();
    switch(col) {
        case INDEX_COLUMN:
            return row + 1;
        case THREAD_COLUMN:
            return Long.valueOf(debugEvent.getThreadId());
        case MODULE_COLUMN:
            return address.getModule() == null ? "-" : address.getModule().getConfiguration().getName();
        case ADDRESS_COLUMN:
            {
                if (address.getModule() == null) {
                    return address.getAddress().getAddress().toHexString();
                } else {
                    final INaviFunction function = address.getModule().isLoaded() ? address.getModule().getContent().getFunctionContainer().getFunction(address.getAddress().getAddress()) : null;
                    if (function == null) {
                        return address.getAddress().getAddress().toHexString();
                    } else {
                        return function.getName();
                    }
                }
            }
        default:
            throw new IllegalStateException("IE01121: Unknown column");
    }
}
Also used : BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 2 with ITraceEvent

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

the class CTraceFilterExpression method evaluate.

@Override
public boolean evaluate(final CTraceEventWrapper element) {
    final ITraceEvent event = element.unwrap();
    final INaviModule currentModule = event.getOffset().getModule();
    String functionName = "";
    String moduleName = "";
    if (currentModule != null) {
        final INaviFunction function = currentModule.isLoaded() ? currentModule.getContent().getFunctionContainer().getFunction(event.getOffset().getAddress().getAddress()) : null;
        if (function != null) {
            functionName = function.getName();
        }
        moduleName = currentModule.getConfiguration().getName();
    }
    return String.valueOf(event.getThreadId()).contains(m_text) || event.getOffset().getAddress().getAddress().toHexString().contains(m_text) || moduleName.contains(m_text) || functionName.contains(m_text);
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 3 with ITraceEvent

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

the class CEventTableMenu method addOpenFunction.

/**
   * Adds a menu item to open the selected trace.
   *
   * @param parent Parent window of the menu.
   * @param traces The selected traces.
   */
private void addOpenFunction(final Window parent, final List<ITraceEvent> traces) {
    if (traces.size() == 1) {
        final ITraceEvent trace = traces.get(0);
        final INaviModule module = trace.getOffset().getModule();
        if (module.isLoaded()) {
            final INaviFunction function = module.getContent().getFunctionContainer().getFunction(trace.getOffset().getAddress().getAddress());
            if (function != null) {
                final IViewContainer container = graphModel.getViewContainer();
                final INaviView view = container.getView(function);
                if (view != null) {
                    add(new JMenuItem(CActionProxy.proxy(new COpenInLastWindowAction(parent, container, new INaviView[] { view }))));
                    addSeparator();
                }
            }
        }
    }
}
Also used : IViewContainer(com.google.security.zynamics.binnavi.disassembly.views.IViewContainer) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) COpenInLastWindowAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Views.Component.Actions.COpenInLastWindowAction) JMenuItem(javax.swing.JMenuItem) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 4 with ITraceEvent

use of com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent 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 5 with ITraceEvent

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

the class CEventTableModelTest method testSimple.

/**
   * General test whether the model is working as expected.
   *
   * @throws RecognitionException
   */
@Test
public void testSimple() throws RecognitionException {
    final INaviModule mockModule = new MockModule();
    final INaviModule mockModule2 = new MockModule(true);
    final INaviModule mockModule3 = new MockModule();
    final CEventTableModel model = new CEventTableModel();
    final TraceList list = new TraceList(1, "", "", new MockSqlProvider());
    list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x123))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 05 }))));
    list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule2, new UnrelocatedAddress(new CAddress(0x124))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 06 }))));
    list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule3, new UnrelocatedAddress(new CAddress(0x125))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 07, 05 }))));
    assertEquals(0, model.getRowCount());
    model.setEventList(list);
    assertEquals(3, model.getRowCount());
    final IFilter<ITraceEvent> filter = new CTraceFilterCreator().createFilter("mem == 05");
    model.setFilter(filter);
    assertEquals(2, model.getRowCount());
    assertEquals(2, model.getEvents().size());
    assertEquals(0x123, model.getEvents().get(0).getOffset().getAddress().getAddress().toLong());
    assertEquals(0x125, model.getEvents().get(1).getOffset().getAddress().getAddress().toLong());
    model.setFilter(null);
    assertEquals(3, model.getRowCount());
    for (int i = 0; i < model.getRowCount(); i++) {
        for (int j = 0; j < model.getColumnCount(); j++) {
            model.getValueAt(i, j);
        }
    }
}
Also used : CTraceFilterCreator(com.google.security.zynamics.binnavi.Gui.Debug.EventLists.CTraceFilterCreator) CEventTableModel(com.google.security.zynamics.binnavi.Gui.Debug.EventLists.CEventTableModel) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) 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) TraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.TraceEvent) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent) Test(org.junit.Test)

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