Search in sources :

Example 1 with COptionsDialog

use of com.google.security.zynamics.binnavi.Gui.Debug.OptionsDialog.COptionsDialog in project binnavi by google.

the class CDebuggerFunctions method showDebuggerOptionsDialogAlways.

/**
   * Shows the debugger options dialog.
   *
   * @param parent Parent window of the dialog.
   * @param target Provides the debugger target.
   * @param debugger The debugger whose options are shown in the dialog.
   */
public static void showDebuggerOptionsDialogAlways(final JFrame parent, final DebugTargetSettings target, final IDebugger debugger) {
    Preconditions.checkNotNull(parent, "IE01559: Parent argument can not be null");
    Preconditions.checkNotNull(target, "IE01560: Target argument can not be null");
    Preconditions.checkNotNull(debugger, "IE01561: Debugger argument can not be null");
    final TargetInformation targetInformation = debugger.getProcessManager().getTargetInformation();
    if (targetInformation == null) {
        CMessageBox.showInformation(parent, "Debugger information can not be shown before the debugger is active.");
        return;
    }
    DebuggerOptions options = targetInformation.getDebuggerOptions();
    if (options == null) {
        CMessageBox.showInformation(parent, "Debugger information can not be shown before the debugger is active.");
        return;
    }
    if (!debugger.isConnected()) {
        CMessageBox.showInformation(parent, "Debugger information can not be shown since the debugger is not currently connected.");
        return;
    }
    try {
        options.setExceptions(new ArrayList<DebuggerException>(mergeExceptionsSettings(target, options.getExceptions(), debugger.getId())));
    } catch (final CouldntLoadDataException exception) {
        CUtilityFunctions.logException(exception);
        final String message = "Exception settings could not be loaded.";
        final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not load the exception settings from the database."), new String[] { "Communication error while contacting the database" }, new String[] { "BinNavi is unable to show the debugger options dialog until the problem is resolved." + " The default debugger options will be used during this session." });
        NaviErrorDialog.show(parent, message, description, exception);
    }
    final DebuggerEventSettings eventSettings = readDebuggerEventSettings(parent, debugger, target);
    final COptionsDialog dlg = new COptionsDialog(parent, options, eventSettings);
    dlg.setVisible(true);
    options = dlg.getDebuggerOptions();
    try {
        writeDebuggerExceptionSettings(options, target, debugger.getId());
        writeDebuggerEventSettings(debugger, target, dlg.getDebuggerEventSettings());
    } catch (final CouldntSaveDataException exception) {
        CUtilityFunctions.logException(exception);
        CUtilityFunctions.logException(exception);
        final String message = "Exception settings could not be written.";
        final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not write the debugger options to the database."), new String[] { "Communication error while contacting the database" }, new String[] { "BinNavi is unable to store the debugger options in the database.", "Nevertheless, the debugger options will be sent to the debugger." });
        NaviErrorDialog.show(parent, message, description, exception);
    }
    sendExceptionSettings(parent, debugger, options.getExceptions());
    sendDebuggerEventSettings(parent, debugger, target);
}
Also used : DebuggerEventSettings(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerEventSettings) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) COptionsDialog(com.google.security.zynamics.binnavi.Gui.Debug.OptionsDialog.COptionsDialog)

Aggregations

CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)1 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)1 COptionsDialog (com.google.security.zynamics.binnavi.Gui.Debug.OptionsDialog.COptionsDialog)1 DebuggerEventSettings (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerEventSettings)1 DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)1 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)1 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)1