From 68c67b20a4878e49419c3e75b2069d1dc1091a43 Mon Sep 17 00:00:00 2001 From: Umair Sair Date: Mon, 27 Sep 2021 22:58:16 +0500 Subject: [PATCH] Bug 576291 - Add preference for suspend timeout - Adding preference in GDB preference page Change-Id: Ic179ddd4f15eb02f8de479ca095cc2ec19818c6b Signed-off-by: Umair Sair --- .../META-INF/MANIFEST.MF | 2 +- .../ui/preferences/GdbDebugPreferencePage.java | 7 +++++++ .../ui/preferences/MessagesForPreferences.java | 2 ++ .../MessagesForPreferences.properties | 2 ++ .../.settings/.api_filters | 17 +++++++++++++++++ .../META-INF/MANIFEST.MF | 2 +- .../dsf/gdb/IGdbDebugPreferenceConstants.java | 14 ++++++++++++++ .../gdb/internal/GdbPreferenceInitializer.java | 2 ++ .../eclipse/cdt/dsf/gdb/service/GDBBackend.java | 16 +++++++++------- .../dsf/gdb/service/GDBRunControl_7_0_NS.java | 10 +++++----- .../cdt/dsf/gdb/service/GDBRunControl_7_12.java | 10 +++++----- 11 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/.settings/.api_filters diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF index c7ec91cf9b5..bb1175f48fb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.ui;singleton:=true -Bundle-Version: 2.7.200.qualifier +Bundle-Version: 2.7.300.qualifier Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java index 0eb6abd767b..28aed42482a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java @@ -630,6 +630,13 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements group2.setLayout(groupLayout); group2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + final IntegerFieldEditor suspendTimeout = new IntegerFieldEditor( + IGdbDebugPreferenceConstants.PREF_SUSPEND_TIMEOUT_VALUE, + MessagesForPreferences.GdbDebugPreferencePage_suspendTimeout_label, group2); + suspendTimeout.setValidRange(5, Integer.MAX_VALUE); + suspendTimeout.fillIntoGrid(group2, 3); + addField(suspendTimeout); + BooleanFieldEditor boolField = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, MessagesForPreferences.GdbDebugPreferencePage_autoTerminateGdb_label, group2); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java index aae5e188437..40ec2ffe99d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java @@ -83,6 +83,8 @@ class MessagesForPreferences extends NLS { public static String GdbDebugPreferencePage_remoteTimeout_label; public static String GdbDebugPreferencePage_remoteTimeout_tooltip; + public static String GdbDebugPreferencePage_suspendTimeout_label; + static { // initialize resource bundle NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties index 803818bf147..8f63e159308 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties @@ -73,3 +73,5 @@ GdbConsolePreferencePage_BufferLines = Console buffer lines: GdbDebugPreferencePage_remoteTimeout_label=Remote timeout (seconds): GdbDebugPreferencePage_remoteTimeout_tooltip=Default timeout for the remote target to respond. If unchecked, uses GDB default value. See GDB's help for "set remotetimeout num". + +GdbDebugPreferencePage_suspendTimeout_label=Suspend timeout (seconds): \ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/.settings/.api_filters b/dsf-gdb/org.eclipse.cdt.dsf.gdb/.settings/.api_filters new file mode 100644 index 00000000000..7ea951e228a --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/.settings/.api_filters @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF index 815fabed77f..29e7d2fcf2f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true -Bundle-Version: 6.4.200.qualifier +Bundle-Version: 6.5.0.qualifier Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java index b000efa2f82..acc672f5ba9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java @@ -247,4 +247,18 @@ public interface IGdbDebugPreferenceConstants { * @since 5.5 */ public static final String PREF_DEFAULT_REMOTE_TIMEOUT_VALUE = "defaultRemoteTimeoutValue"; //$NON-NLS-1$ + + /** + * The value of suspend timeout + * + * @since 6.5 + */ + public static final String PREF_SUSPEND_TIMEOUT_VALUE = "suspendTimeoutValue"; //$NON-NLS-1$ + + /** + * Default value of {@link #PREF_SUSPEND_TIMEOUT_VALUE} + * + * @since 6.5 + */ + public static final int SUSPEND_TIMEOUT_VALUE_DEFAULT = 10; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java index 8056d779697..d2ae06c4822 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java @@ -71,5 +71,7 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer { IGDBLaunchConfigurationConstants.DEBUGGER_REMOTE_TIMEOUT_ENABLED_DEFAULT); node.put(IGdbDebugPreferenceConstants.PREF_DEFAULT_REMOTE_TIMEOUT_VALUE, IGDBLaunchConfigurationConstants.DEBUGGER_REMOTE_TIMEOUT_VALUE_DEFAULT); + node.putInt(IGdbDebugPreferenceConstants.PREF_SUSPEND_TIMEOUT_VALUE, + IGdbDebugPreferenceConstants.SUSPEND_TIMEOUT_VALUE_DEFAULT); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java index 2cbd4b38842..344358655fb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java @@ -37,6 +37,7 @@ import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; @@ -55,6 +56,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.DebugException; @@ -818,17 +820,15 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend, IMIBa * backend, and the current job will indicate this in the request monitor. * * The specified timeout is used to indicate how many milliseconds this job - * should wait for. INTERRUPT_TIMEOUT_DEFAULT indicates to use the default - * of 5 seconds. The default is also use if the timeout value is 0 or + * should wait for. Default timeout is provided by preference + * {@code IGdbDebugPreferenceConstants.PREF_SUSPEND_TIMEOUT_VALUE}. + * The default is also used if the timeout value is 0 or * negative. * * @since 3.0 */ protected class MonitorInterruptJob extends Job { - // Bug 310274. Until we have a preference to configure timeouts, - // we need a large enough default timeout to accommodate slow - // remote sessions. - private final static int TIMEOUT_DEFAULT_VALUE = 5000; + private final RequestMonitor fRequestMonitor; public MonitorInterruptJob(int timeout, RequestMonitor rm) { @@ -837,7 +837,9 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend, IMIBa fRequestMonitor = rm; if (timeout == INTERRUPT_TIMEOUT_DEFAULT || timeout <= 0) { - timeout = TIMEOUT_DEFAULT_VALUE; // default of 5 seconds + timeout = 1000 * Platform.getPreferencesService().getInt(GdbPlugin.PLUGIN_ID, + IGdbDebugPreferenceConstants.PREF_SUSPEND_TIMEOUT_VALUE, + IGdbDebugPreferenceConstants.SUSPEND_TIMEOUT_VALUE_DEFAULT, null); } schedule(timeout); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java index 72dd8b38dcc..7d529843175 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java @@ -67,6 +67,7 @@ import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommand; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent; +import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.internal.service.command.events.MITracepointSelectedEvent; import org.eclipse.cdt.dsf.gdb.internal.service.control.StepIntoSelectionActiveOperation; @@ -109,6 +110,7 @@ import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.DebugException; @@ -636,10 +638,6 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService * @since 4.5 */ protected class MonitorSuspendJob extends Job { - // Bug 310274. Until we have a preference to configure timeouts, - // we need a large enough default timeout to accommodate slow - // remote sessions. - private final static int TIMEOUT_DEFAULT_VALUE = 5000; private final RequestMonitor fRequestMonitor; private final IMIExecutionDMContext fThread; @@ -651,7 +649,9 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService fRequestMonitor = rm; if (timeout <= 0) { - timeout = TIMEOUT_DEFAULT_VALUE; // default of 5 seconds + timeout = 1000 * Platform.getPreferencesService().getInt(GdbPlugin.PLUGIN_ID, + IGdbDebugPreferenceConstants.PREF_SUSPEND_TIMEOUT_VALUE, + IGdbDebugPreferenceConstants.SUSPEND_TIMEOUT_VALUE_DEFAULT, null); } // Register to listen for the stopped event diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_12.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_12.java index ac548b6d92e..dd722427847 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_12.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_12.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; +import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; @@ -37,6 +38,7 @@ import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; @@ -301,10 +303,6 @@ public class GDBRunControl_7_12 extends GDBRunControl_7_10 { } protected class MonitorSuspendJob extends Job { - // Bug 310274. Until we have a preference to configure timeouts, - // we need a large enough default timeout to accommodate slow - // remote sessions. - private final static int TIMEOUT_DEFAULT_VALUE = 5000; private final RequestMonitor fRequestMonitor; @@ -314,7 +312,9 @@ public class GDBRunControl_7_12 extends GDBRunControl_7_10 { fRequestMonitor = rm; if (timeout <= 0) { - timeout = TIMEOUT_DEFAULT_VALUE; // default of 5 seconds + timeout = 1000 * Platform.getPreferencesService().getInt(GdbPlugin.PLUGIN_ID, + IGdbDebugPreferenceConstants.PREF_SUSPEND_TIMEOUT_VALUE, + IGdbDebugPreferenceConstants.SUSPEND_TIMEOUT_VALUE_DEFAULT, null); } // Register to listen for the stopped event