Skip to content

Commit

Permalink
feat: Improved timeout err msg
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmaaa committed Mar 7, 2024
1 parent 21c0573 commit 3f9e179
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@
import org.eclipse.embedcdt.debug.gdbjtag.core.DebugUtils;
import org.eclipse.embedcdt.debug.gdbjtag.core.dsf.AbstractGnuMcuLaunchConfigurationDelegate;
import org.eclipse.embedcdt.debug.gdbjtag.core.dsf.GnuMcuServerServicesLaunchSequence;
import org.eclipse.swt.widgets.Display;

import com.espressif.idf.debug.gdbjtag.openocd.Activator;
import com.espressif.idf.debug.gdbjtag.openocd.Configuration;
import com.espressif.idf.debug.gdbjtag.openocd.ui.Messages;
import com.espressif.idf.debug.gdbjtag.openocd.ui.ServerTimeoutErrorDialog;

/**
* This class is referred in the plugin.xml as an "org.eclipse.debug.core.launchDelegates" extension point.
Expand Down Expand Up @@ -446,8 +448,22 @@ else if (sessionType == SessionType.CORE)
}
catch (ExecutionException e1)
{
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED,
"Error in services launch sequence", e1.getCause())); //$NON-NLS-1$
if (e1.getMessage().contains("Starting OpenOCD timed out."))
{
Display.getDefault().asyncExec(() -> {
ServerTimeoutErrorDialog.openError(Display.getDefault().getActiveShell());

});
// Throwing exception with OK status to terminate launch sequence
throw new DebugException(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED,
"Error in services launch sequence", e1.getCause())); //$NON-NLS-1$
}
else
{
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED,
"Error in services launch sequence", e1.getCause())); //$NON-NLS-1$
}

}
catch (CancellationException e1)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.debug.gdbjtag.openocd.ui;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.PreferencesUtil;

public class ServerTimeoutErrorDialog extends MessageDialog
{

private static final String ESPRESSIF_PREFERENCES_MAINPAGE_ID = "com.espressif.idf.ui.preferences.mainpage"; //$NON-NLS-1$

public ServerTimeoutErrorDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
int dialogImageType, int defaultIndex, String[] dialogButtonLabels)
{
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, defaultIndex,
dialogButtonLabels);
}

public static boolean open(int kind, Shell parent, String title, String message, int style)
{
ServerTimeoutErrorDialog dialog = new ServerTimeoutErrorDialog(parent, title, null, message, kind, 0,
new String[] { IDialogConstants.OK_LABEL });
style &= SWT.SHEET;

Check warning on line 35 in bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/ServerTimeoutErrorDialog.java

View workflow job for this annotation

GitHub Actions / spotbugs

DLS_DEAD_LOCAL_STORE

Dead store to style in com.espressif.idf.debug.gdbjtag.openocd.ui.ServerTimeoutErrorDialog.open(int, Shell, String, String, int)
Raw output
This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used.

Note that Sun's javac compiler often generates dead stores for final local variables. Because SpotBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.
return dialog.open() == 0;
}

public static void openError(Shell parent)
{
open(ERROR, parent, Messages.getString("ServerTimeoutErrorDialog.title"), //$NON-NLS-1$
Messages.getString("ServerTimeoutErrorDialog.message"), SWT.NONE); //$NON-NLS-1$
}

@Override
protected Control createCustomArea(Composite parent)
{
Link link = new Link(parent, SWT.WRAP);
link.setText(Messages.getString("ServerTimeoutErrorDialog.customAreaMessage")); //$NON-NLS-1$
link.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
PreferencesUtil
.createPreferenceDialogOn(parent.getShell(), ESPRESSIF_PREFERENCES_MAINPAGE_ID, null, null)
.open();
}
});
;
return link;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,9 @@ TabMain_Launch_Config=Launch Configuration:


## Console Messages ##
OpenOCDConsole_ErrorGuideMessage=Please refer to the troubleshooting guide below to identify the problem.
OpenOCDConsole_ErrorGuideMessage=Please refer to the troubleshooting guide below to identify the problem.

## Timeout Exception Dialog ##
ServerTimeoutErrorDialog.customAreaMessage=To increase timeout time visit <a>the Espressif Preference Page</a>.
ServerTimeoutErrorDialog.message=Starting OpenOCD timed out. Try to increase the `GDB server launch timeout`
ServerTimeoutErrorDialog.title=Problem Occured

0 comments on commit 3f9e179

Please sign in to comment.