From 3f9e17985c6a5116f89dd918c13b69605eadf07f Mon Sep 17 00:00:00 2001 From: Denys Almazov Date: Thu, 7 Mar 2024 09:48:12 +0200 Subject: [PATCH] feat: Improved timeout err msg --- .../dsf/LaunchConfigurationDelegate.java | 20 +++++- .../openocd/ui/ServerTimeoutErrorDialog.java | 63 +++++++++++++++++++ .../gdbjtag/openocd/ui/messages.properties | 7 ++- 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/ServerTimeoutErrorDialog.java diff --git a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java index 33fcc1c5a..1d5093bb8 100644 --- a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java +++ b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java @@ -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. @@ -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) { diff --git a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/ServerTimeoutErrorDialog.java b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/ServerTimeoutErrorDialog.java new file mode 100644 index 000000000..bb02326e4 --- /dev/null +++ b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/ServerTimeoutErrorDialog.java @@ -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; + 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; + } +} diff --git a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/messages.properties b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/messages.properties index 8795d8592..2b313114b 100644 --- a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/messages.properties +++ b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/messages.properties @@ -410,4 +410,9 @@ TabMain_Launch_Config=Launch Configuration: ## Console Messages ## -OpenOCDConsole_ErrorGuideMessage=Please refer to the troubleshooting guide below to identify the problem. \ No newline at end of file +OpenOCDConsole_ErrorGuideMessage=Please refer to the troubleshooting guide below to identify the problem. + +## Timeout Exception Dialog ## +ServerTimeoutErrorDialog.customAreaMessage=To increase timeout time visit the Espressif Preference Page. +ServerTimeoutErrorDialog.message=Starting OpenOCD timed out. Try to increase the `GDB server launch timeout` +ServerTimeoutErrorDialog.title=Problem Occured \ No newline at end of file