Search in sources :

Example 1 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CTraceCombinationFunctions method differenceTraces.

/**
   * Creates a new trace that contains exactly those events that appear in the first trace but not
   * in the second trace.
   *
   * @param parent Parent window used for dialogs.
   * @param provider Creates the new trace.
   * @param trace1 The first input trace.
   * @param trace2 The second input trace.
   */
public static void differenceTraces(final JFrame parent, final ITraceListProvider provider, final TraceList trace1, final TraceList trace2) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
                operation.getProgressPanel().setMaximum(3);
                operation.getProgressPanel().setText(String.format("Creating trace difference between '%s' and '%s'", trace1.getName(), trace2.getName()));
                final TraceList newTrace = provider.createTrace("Combined Trace", String.format("%s - %s", trace1.getName(), trace2.getName()));
                operation.getProgressPanel().next();
                createCombinedTrace(newTrace, Lists.newArrayList(trace1, trace2), getDifferenceAddresses(trace1, trace2));
                operation.getProgressPanel().next();
                newTrace.save();
                operation.getProgressPanel().next();
                operation.stop();
            } catch (final CouldntSaveDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00191: " + "Could not combine debug traces";
                final String innerDescription = CUtilityFunctions.createDescription("The selected traces could not be combined into a larger trace.", new String[] { "There was a problem with the database connection." }, new String[] { "The trace list was not created. You could try to combine the lists again once the connection problem was resolved." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Example 2 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CTraceCombinationFunctions method intersectTraces.

/**
   * Creates a new trace that contains those events that appear in all of the input traces.
   *
   * @param parent Parent window used for dialogs.
   * @param provider Creates the new trace.
   * @param traces The input traces.
   */
public static void intersectTraces(final JFrame parent, final ITraceListProvider provider, final List<TraceList> traces) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
                operation.getProgressPanel().setMaximum(3);
                operation.getProgressPanel().setText("Combining traces");
                final TraceList newTrace = provider.createTrace("Combined Trace", "");
                operation.next();
                createCombinedTrace(newTrace, traces, getIntersectedAddresses(traces));
                operation.next();
                newTrace.save();
                operation.next();
                operation.stop();
            } catch (final CouldntSaveDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00196: " + "Could not combine debug traces";
                final String innerDescription = CUtilityFunctions.createDescription("The selected traces could not be combined into a larger trace.", new String[] { "There was a problem with the database connection." }, new String[] { "The trace list was not created. You could try to combine the lists again once the connection problem was resolved." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Example 3 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class ZyGraph method saveAs.

/**
   * Creates a copy of the current native view and transfers the copied native view into the graph
   * object. That means that the graph object changes its underlying raw view when this function is
   * called.
   *
   * @param container The view container where the view is copied to.
   * @param name The new name of the raw view.
   * @param description The new description of the raw view.
   *
   * @return The new raw view.
   *
   * @throws CouldntSaveDataException Thrown if the view could not be saved.
   */
public INaviView saveAs(final IViewContainer container, final String name, final String description) throws CouldntSaveDataException {
    Preconditions.checkNotNull(container, "IE00871: Container argument can not be null");
    Preconditions.checkNotNull(name, "IE00872: Name argument can not be null");
    Preconditions.checkNotNull(description, "IE00899: Description argument can not be null");
    final INaviView oldView = m_rawView;
    final INaviView newView = container.createView(name, description);
    CViewInserter.insertView(oldView, newView);
    final List<INaviViewNode> oldNodes = oldView.getGraph().getNodes();
    final List<INaviViewNode> newNodes = newView.getGraph().getNodes();
    for (int i = 0; i < oldNodes.size(); i++) {
        final INaviViewNode newNode = newNodes.get(i);
        final NaviNode oldNode = getMappings().getNode(oldNodes.get(i));
        getMappings().setNode(newNode, oldNode);
        oldNode.setRawNode(newNode);
        for (final INaviGraphListener listener : m_listeners) {
            try {
                listener.changedModel(this, oldNode);
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
            }
        }
    }
    final List<INaviEdge> oldEdges = oldView.getGraph().getEdges();
    final List<INaviEdge> newEdges = newView.getGraph().getEdges();
    for (int i = 0; i < oldEdges.size(); i++) {
        final INaviEdge newEdge = newEdges.get(i);
        final NaviEdge oldEdge = getMappings().getEdge(oldEdges.get(i));
        assert oldEdge != null;
        getMappings().setEdge(newEdge, oldEdge);
        final ZyEdgeRealizer<NaviEdge> realizer = oldEdge.getRealizer();
        realizer.setUpdater(new CEdgeUpdater(newEdge));
        oldEdge.setRawEdge(newEdge);
    }
    removeListeners();
    newView.save();
    CSettingsFunctions.saveSettings(newView, getView(), m_settings);
    m_rawView = newView;
    initializeListeners();
    m_synchronizer.reset();
    for (final INaviGraphListener listener : m_listeners) {
        // ESCA-JAVA0166: Catch Exception here because we are calling a listener function.
        try {
            listener.changedView(oldView, newView);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    oldView.close();
    return m_rawView;
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CEdgeUpdater(com.google.security.zynamics.binnavi.ZyGraph.Updaters.CEdgeUpdater) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviGraphListener(com.google.security.zynamics.binnavi.ZyGraph.INaviGraphListener) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge)

Example 4 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CModuleOverviewPanel method saveFileBase.

/**
   * Saves the module file base to the database.
   */
private void saveFileBase() {
    try {
        final CAddress fileBase = new CAddress(Convert.hexStringToLong(m_debuggerPanel.getFileBase()));
        m_module.getConfiguration().setFileBase(new CAddress(fileBase));
    } catch (final CouldntSaveDataException e) {
        CUtilityFunctions.logException(e);
        final String message = "E00165: " + "Could not change the module file base";
        final String description = CUtilityFunctions.createDescription("The new module file base could not be saved to the database.", new String[] { "There was a problem with the connection to the database while the module file base was saved" }, new String[] { "The module file base was not saved. Please try to find out what went wrong with the database connection and try to save the module file base again." });
        NaviErrorDialog.show(SwingUtilities.getWindowAncestor(this), message, description, e);
    }
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 5 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CTagSortingHandler method drop.

@Override
public void drop(final DNDTree target, final DefaultMutableTreeNode parentNode, final DefaultMutableTreeNode draggedNode) {
    final ITagManager tagManager = ((CTagNode) parentNode).getTagManager();
    final TreeNode<CTag> parentNodeNode = ((CTagNode) parentNode).getObject();
    final TreeNode<CTag> draggedNodeNode = ((CTagNode) draggedNode).getObject();
    try {
        tagManager.moveTag(parentNodeNode, draggedNodeNode);
        CNodeExpander.expandNode(target, parentNodeNode);
    } catch (final CouldntSaveDataException e) {
        // TODO: Improve this
        CUtilityFunctions.logException(e);
    }
}
Also used : ITagManager(com.google.security.zynamics.binnavi.Tagging.ITagManager) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Tag.CTagNode)

Aggregations

CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)133 SQLException (java.sql.SQLException)71 PreparedStatement (java.sql.PreparedStatement)38 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)35 CallableStatement (java.sql.CallableStatement)20 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)17 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)13 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)10 CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)10 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)9 ArrayList (java.util.ArrayList)9 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)8 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)8 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)8 BigInteger (java.math.BigInteger)8 Connection (java.sql.Connection)8 ResultSet (java.sql.ResultSet)8 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)7 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)6 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)5