Search in sources :

Example 41 with TraceList

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

the class CTraceFunctions method deleteTrace.

/**
   * Deletes a number of traces from a given event list provider.
   *
   * @param parent Parent window used for dialogs.
   * @param listProvider The event list provider that manages the event lists.
   * @param traces Indices of the traces to be deleted.
   */
public static void deleteTrace(final Window parent, final ITraceListProvider listProvider, final int[] traces) {
    Preconditions.checkNotNull(parent, "IE01381: Parent argument can not be null");
    Preconditions.checkNotNull(listProvider, "IE01382: List provider argument can't be null");
    Preconditions.checkNotNull(traces, "IE01383: Traces argument can't be null");
    // At first we get the trace list objects that correspond
    // to the indices passed in the traces parameter.
    //
    // We can not delete the event lists directly or we'd have to keep
    // track of changing indices because deleting event lists from
    // the manager changes the internal event list indices.
    final List<TraceList> traceObjects = new ArrayList<TraceList>();
    for (final int trace : traces) {
        traceObjects.add(listProvider.getList(trace));
    }
    if (CMessageBox.showYesNoQuestion(parent, String.format("Do you really want to delete the following traces from the database?\n\n%s", CNameListGenerators.getNameList(traceObjects))) == JOptionPane.YES_OPTION) {
        for (final TraceList trace : traceObjects) {
            new Thread() {

                @Override
                public void run() {
                    final CDefaultProgressOperation operation = new CDefaultProgressOperation("", true, false);
                    operation.getProgressPanel().setMaximum(1);
                    operation.getProgressPanel().setText("Deleting trace" + ": " + trace.getName());
                    try {
                        listProvider.removeList(trace);
                        operation.getProgressPanel().next();
                    } catch (final CouldntDeleteException e) {
                        CUtilityFunctions.logException(e);
                        final String innerMessage = "E00075: " + "Could not delete trace list";
                        final String innerDescription = CUtilityFunctions.createDescription(String.format("The trace list '%s' could not be deleted.", trace.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The trace list was not deleted. You could try to delete the list again once the connection problem was resolved." });
                        NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
                    } finally {
                        operation.stop();
                    }
                }
            }.start();
        }
    }
}
Also used : CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) ArrayList(java.util.ArrayList) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Example 42 with TraceList

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

the class CNameListGenerators method getNameList.

/**
   * Generates a name list from the names of the given traces.
   * 
   * @param traces The traces that provide the names.
   * 
   * @return The generated name list.
   */
public static String getNameList(final List<TraceList> traces) {
    int count = 0;
    final StringBuilder list = new StringBuilder();
    for (final TraceList trace : traces) {
        list.append("- ");
        list.append(trace.getName());
        list.append('\n');
        count++;
        if ((count == MAX_LIST_LENGTH) && (traces.size() != MAX_LIST_LENGTH)) {
            list.append("\n... ");
            list.append(String.format("%d others ...", traces.size() - count));
            break;
        }
    }
    return list.toString();
}
Also used : TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Example 43 with TraceList

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

the class CTraceFunctions method showStartTraceProgressWindow.

/**
   * Shows a progress dialog and sets all the echo breakpoints necessary for the next trace.
   *
   * @param parent Parent window used for dialogs.
   * @param addresses List of addresses where echo breakpoints are set.
   * @param logger The trace logger used to log the events.
   * @param maximumHits Maximum number of hits before echo breakpoints are cleared.
   */
private static void showStartTraceProgressWindow(final JFrame parent, final Set<BreakpointAddress> addresses, final TraceLogger logger, final int maximumHits) {
    // Create the new event list where the events of the current trace
    // mode are logged to.
    final TraceList trace = createTrace(parent, logger);
    // Create the object that updates the progress bar
    // on each successfully set echo breakpoint.
    final CStartTraceListener bpl = new CStartTraceListener(logger, trace, addresses, maximumHits);
    // Show the progress dialog.
    CProgressDialog.showEndless(parent, "Setting echo breakpoints", bpl);
}
Also used : TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Example 44 with TraceList

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

the class CTraceFunctions method startTrace.

/**
   * Starts trace mode for a given graph.
   *
   * @param parent Parent window used for dialogs.
   * @param debugger Debugger that sets the breakpoints.
   * @param graph Graph for which trace mode is activated.
   * @param logger The trace logger used to log the events.
   */
public static void startTrace(final JFrame parent, final IDebugger debugger, final ZyGraph graph, final TraceLogger logger) {
    checkArguments(parent, debugger, logger);
    Preconditions.checkNotNull(graph, "IE01569: Graph argument can not be null");
    if (!debugger.isConnected()) {
        return;
    }
    if (logger.hasEchoBreakpoints()) {
        final TraceList trace = createTrace(parent, logger);
        if (trace == null) {
            return;
        }
        final TraceList oldTrace = logger.switchTargetList(trace);
        saveTrace(oldTrace);
    } else {
        final int bps = countEchoBreakpoints(debugger.getBreakpointManager(), graph);
        if (bps == 0) {
            CMessageBox.showError(parent, "All nodes of the graph are already covered by another active trace");
        } else {
            final CTraceOptionsDialog dlg = CTraceOptionsDialog.show(parent);
            if (!dlg.wasCancelled()) {
                final int maximumHits = dlg.getMaximumHits();
                if (maximumHits == 0) {
                    return;
                }
                final EchoBreakpointCollector ebc = new EchoBreakpointCollector(debugger.getBreakpointManager());
                graph.iterate(new NodeBreakpointDecider(ebc));
                showStartTraceProgressWindow(parent, ebc.getBreakpoints(), logger, maximumHits);
            }
        }
    }
}
Also used : TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) EchoBreakpointCollector(com.google.security.zynamics.binnavi.debug.helpers.EchoBreakpointCollector) CTraceOptionsDialog(com.google.security.zynamics.binnavi.Gui.Debug.TraceOptionsDialog.CTraceOptionsDialog) NodeBreakpointDecider(com.google.security.zynamics.binnavi.debug.helpers.NodeBreakpointDecider)

Example 45 with TraceList

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

the class CProjectContent method createTrace.

/**
   * Creates a new trace with the given name in the project. The new trace is immediately saved to
   * the database.
   * 
   * This function is guaranteed to be exception-safe. If an exception is thrown while saving the
   * trace to the database, the project object remains unchanged.
   * 
   * @param name The name of the new trace.
   * @param description The description of the new trace.
   * 
   * @return The new trace that was created in the project.
   * 
   * @throws CouldntSaveDataException Thrown if the trace could not be saved to the database.
   */
public TraceList createTrace(final String name, final String description) throws CouldntSaveDataException {
    Preconditions.checkNotNull(name, "IE00242: Name argument can't be null");
    Preconditions.checkNotNull(description, "IE00246: Description argument can't be null");
    final TraceList trace = m_provider.createTrace(m_project, name, description);
    m_traces.add(trace);
    for (final IProjectListener listener : m_listeners) {
        try {
            listener.addedTrace(m_project, trace);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    m_project.getConfiguration().updateModificationDate();
    return trace;
}
Also used : TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

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