Search in sources :

Example 6 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 7 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 8 with ITraceEvent

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

the class CRegisterFilterExpression method evaluate.

@Override
public boolean evaluate(final CTraceEventWrapper element) {
    final ITraceEvent trace = element.unwrap();
    boolean returnValue = false;
    for (final TraceRegister register : trace.getRegisterValues()) {
        if ("any".equalsIgnoreCase(m_register) || register.getName().equalsIgnoreCase(m_register)) {
            returnValue |= evaluateExpression(m_predicate, register, m_value);
        }
    }
    return returnValue;
}
Also used : TraceRegister(com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 9 with ITraceEvent

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

the class CTraceCombinationFunctions method createCombinedTrace.

/**
   * Fills a combined trace from the events of multiple input traces.
   *
   * @param newTrace The trace to fill.
   * @param traces The input events.
   * @param addresses The addresses of the events to put into the combined trace.
   */
private static void createCombinedTrace(final TraceList newTrace, final List<TraceList> traces, final Set<BreakpointAddress> addresses) {
    final Set<BreakpointAddress> visitedAddresses = new LinkedHashSet<BreakpointAddress>();
    for (final TraceList trace : traces) {
        for (final ITraceEvent event : trace) {
            final BreakpointAddress address = event.getOffset();
            if (!addresses.contains(address)) {
                continue;
            }
            if (visitedAddresses.contains(address)) {
                continue;
            }
            visitedAddresses.add(address);
            newTrace.addEvent(event);
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) 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)

Example 10 with ITraceEvent

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

the class CTraceFunctions method setBreakpoints.

/**
   * Sets breakpoints on trace events.
   *
   * @param model Provides the active debugger.
   * @param events Events on which breakpoints are set.
   */
public static void setBreakpoints(final CDebugPerspectiveModel model, final List<ITraceEvent> events) {
    final IDebugger debugger = model.getCurrentSelectedDebugger();
    if (debugger == null) {
        return;
    }
    final List<INaviModule> modules = debugger.getModules();
    final Set<BreakpointAddress> addresses = new HashSet<BreakpointAddress>();
    for (final ITraceEvent event : events) {
        final BreakpointAddress address = event.getOffset();
        if ((address.getModule() == null) || (modules.contains(address.getModule()) && !debugger.getBreakpointManager().hasBreakpoint(BreakpointType.REGULAR, address))) {
            addresses.add(address);
        }
    }
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, addresses);
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) HashSet(java.util.HashSet) 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