diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/wizban/advtosettings_wiz.png b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/wizban/advtosettings_wiz.png
new file mode 100755
index 00000000000..7229ca07fd3
Binary files /dev/null and b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/wizban/advtosettings_wiz.png differ
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
index 9e68fbd126c..62f27c7673e 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
@@ -475,4 +475,13 @@
+
+
+
+
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbStatusHandler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbStatusHandler.java
new file mode 100644
index 00000000000..3bbd6396570
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbStatusHandler.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.dsf.gdb.internal.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class GdbStatusHandler implements IStatusHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
+ */
+ @Override
+ public Object handleStatus( final IStatus status, Object source ) throws CoreException {
+ Runnable runnable = null;
+ if ( status.getSeverity() == IStatus.ERROR ) {
+ runnable = new Runnable() {
+
+ @Override
+ public void run() {
+ Shell parent = GdbUIPlugin.getActiveWorkbenchShell();
+ if ( parent != null )
+ MessageDialog.openError( parent, Messages.GdbStatusHandler_Error, status.getMessage() );
+ }
+ };
+ }
+ else if ( status.getSeverity() == IStatus.WARNING ) {
+ runnable = new Runnable() {
+
+ @Override
+ public void run() {
+ Shell parent = GdbUIPlugin.getActiveWorkbenchShell();
+ if ( parent != null )
+ MessageDialog.openWarning( parent, Messages.GdbStatusHandler_Warning, status.getMessage() );
+ }
+ };
+ }
+ else if ( status.getSeverity() == IStatus.INFO ) {
+ runnable = new Runnable() {
+
+ @Override
+ public void run() {
+ Shell parent = GdbUIPlugin.getActiveWorkbenchShell();
+ if ( parent != null )
+ MessageDialog.openInformation( parent, Messages.GdbStatusHandler_Information, status.getMessage() );
+ }
+ };
+ }
+ if ( runnable != null )
+ Display.getDefault().asyncExec( runnable );
+ return null;
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java
index 2aedaeb95b0..3e9ed2919f2 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java
@@ -22,6 +22,9 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -227,4 +230,32 @@ public class GdbUIPlugin extends AbstractUIPlugin {
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
+ */
+ @Override
+ protected void initializeImageRegistry( ImageRegistry reg ) {
+ super.initializeImageRegistry( reg );
+ declareImages( reg );
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ public static Image getImage( String key ) {
+ return getDefault().getImageRegistry().get( key );
+ }
+
+ private void declareImages( ImageRegistry reg ) {
+ reg.put( IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS,
+ getImageDescriptor( "icons/full/wizban/advtosettings_wiz.png" ) ); //$NON-NLS-1$
+ }
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/IGdbUIConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/IGdbUIConstants.java
new file mode 100644
index 00000000000..3a10e92f305
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/IGdbUIConstants.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.dsf.gdb.internal.ui;
+
+/**
+ * @noimplement This interface is not intended to be implemented by clients.
+ *
+ * @since 4.1
+ */
+public interface IGdbUIConstants {
+
+ /**
+ * Plug-in identifier (value "org.eclipse.cdt.dsf.gdb.ui"
).
+ */
+ public static final String PLUGIN_ID = GdbUIPlugin.PLUGIN_ID;
+
+ /** image identifier. */
+ public static final String IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS = PLUGIN_ID + ".imageAdvancedTimeoutSettings"; //$NON-NLS-1$
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.java
new file mode 100644
index 00000000000..1b8f0f53bd2
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.dsf.gdb.internal.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ public static String GdbStatusHandler_Error;
+
+ public static String GdbStatusHandler_Information;
+
+ public static String GdbStatusHandler_Warning;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages( Messages.class.getName(), Messages.class );
+ }
+
+ private Messages() {
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.properties
new file mode 100644
index 00000000000..765b50e87aa
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.properties
@@ -0,0 +1,14 @@
+#######################################################################################
+# Copyright (c) 2012 Mentor Graphics and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Mentor Graphics - Initial API and implementation
+#######################################################################################
+
+GdbStatusHandler_Error=Error
+GdbStatusHandler_Information=Information
+GdbStatusHandler_Warning=Warning
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 7277956d3f1..e6d688d2b56 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
@@ -13,25 +13,62 @@
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.cdt.dsf.debug.internal.ui.preferences.IntegerWithBooleanFieldEditor;
import org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
-import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages;
+import org.eclipse.cdt.dsf.gdb.internal.ui.IGdbUIConstants;
+import org.eclipse.cdt.dsf.gdb.service.command.CustomTimeoutsMap;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ICellEditorListener;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
@@ -41,6 +78,7 @@ import org.eclipse.ui.PlatformUI;
*/
@SuppressWarnings("restriction")
public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
/**
* A vehicle in order to be able to register a selection listener with
* a {@link BooleanFieldEditor}.
@@ -58,20 +96,428 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
}
}
+ class AdvancedTimeoutSettingsDialog extends TitleAreaDialog {
+
+ class CommandTimeoutEntry {
+
+ String fCommand;
+ Integer fTimeout;
+
+ CommandTimeoutEntry( String command, Integer timeout ) {
+ fCommand = command;
+ fTimeout = timeout;
+ }
+ }
+
+ class CellEditorListener implements ICellEditorListener {
+
+ CellEditor fEditor;
+
+ public CellEditorListener( CellEditor editor ) {
+ super();
+ fEditor = editor;
+ }
+
+ @Override
+ public void editorValueChanged( boolean oldValidState, boolean newValidState ) {
+ if ( newValidState ) {
+ setErrorMessage( null );
+ }
+ else {
+ setErrorMessage( fEditor.getErrorMessage() );
+ }
+ updateDialogButtons();
+ }
+
+ @Override
+ public void cancelEditor() {
+ }
+
+ @Override
+ public void applyEditorValue() {
+ validate();
+ updateDialogButtons();
+ }
+ };
+
+ abstract class AbstractEditingSupport extends EditingSupport {
+
+ public AbstractEditingSupport( ColumnViewer viewer ) {
+ super( viewer );
+ }
+
+ @Override
+ protected void setValue( Object element, Object value ) {
+ if ( element instanceof CommandTimeoutEntry && value instanceof String ) {
+ if ( processValue( (CommandTimeoutEntry)element, (String)value ) ) {
+ fViewer.refresh( element );
+ validate();
+ updateDialogButtons();
+ }
+ }
+ }
+
+ @Override
+ protected Object getValue( Object element ) {
+ if ( element instanceof CommandTimeoutEntry ) {
+ return doGetValue( (CommandTimeoutEntry)element );
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor( Object element ) {
+ final CellEditor editor = new TextCellEditor( (Composite)getViewer().getControl() );
+ editor.setValidator( getValidator() );
+ editor.addListener( new CellEditorListener( editor ) );
+ return editor;
+ }
+
+ @Override
+ protected boolean canEdit( Object element ) {
+ return ( element instanceof CommandTimeoutEntry );
+ }
+
+ abstract boolean processValue( CommandTimeoutEntry entry, String value );
+
+ abstract Object doGetValue( CommandTimeoutEntry entry );
+
+ abstract ICellEditorValidator getValidator();
+ };
+
+ private TableViewer fViewer;
+ private Button fAddButton;
+ private Button fDeleteButton;
+
+ private List fEntries;
+
+ final private ICellEditorValidator fCommandValidator = new ICellEditorValidator() {
+
+ @Override
+ public String isValid( Object value ) {
+ if ( value instanceof String && ((String)value).trim().length() == 0 ) {
+ return MessagesForPreferences.GdbDebugPreferencePage_Command_field_can_not_be_empty;
+ }
+ return null;
+ }
+ };
+
+ final private ICellEditorValidator fTimeoutValidator = new ICellEditorValidator() {
+
+ @Override
+ public String isValid( Object value ) {
+ if ( value instanceof String ) {
+ try {
+ int intValue = Integer.decode( (String)value ).intValue();
+ if ( intValue < 0 )
+ return MessagesForPreferences.GdbDebugPreferencePage_Timeout_value_can_not_be_negative;
+ }
+ catch( NumberFormatException e ) {
+ return MessagesForPreferences.GdbDebugPreferencePage_Invalid_timeout_value;
+ }
+ }
+ return null;
+ }
+ };
+
+ AdvancedTimeoutSettingsDialog( Shell parentShell, Set> entries ) {
+ super( parentShell );
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ fEntries = new LinkedList();
+ for ( Map.Entry entry : entries ) {
+ fEntries.add( new CommandTimeoutEntry( entry.getKey(), entry.getValue() ) );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea( Composite parent ) {
+ getShell().setText( MessagesForPreferences.GdbDebugPreferencePage_Advanced_Timeout_Settings );
+ setTitle( MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_title );
+ setTitleImage( GdbUIPlugin.getImage( IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS ) );
+ setMessage( MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_message );
+
+ Composite control = (Composite)super.createDialogArea( parent );
+ Composite comp = new Composite( control, SWT.NONE );
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ GridLayout layout = new GridLayout( 2, false );
+ layout.marginLeft = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
+ comp.setLayout( layout );
+ comp.setLayoutData( gd );
+
+ fViewer = new TableViewer( comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
+ final Table table = fViewer.getTable();
+ gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
+ table.setLayoutData( gd );
+
+ ControlDecoration decoration = new ControlDecoration( table, SWT.TOP | SWT.LEFT, control );
+ decoration.setImage(
+ FieldDecorationRegistry.getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_INFORMATION ).getImage() );
+ decoration.setDescriptionText(
+ MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip );
+ fViewer.addDoubleClickListener( new IDoubleClickListener() {
+ @Override
+ public void doubleClick( DoubleClickEvent event ) {
+ okPressed();
+ }
+ } );
+
+ fViewer.addSelectionChangedListener( new ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged( SelectionChangedEvent event ) {
+ updateDialogButtons();
+ }
+ } );
+
+ Composite btnComp = new Composite( comp, SWT.NONE );
+ btnComp.setLayout( new GridLayout() );
+ btnComp.setLayoutData( new GridData( SWT.RIGHT, SWT.TOP, false, false ) );
+
+ fAddButton = new Button( btnComp, SWT.PUSH );
+ fAddButton.setText( MessagesForPreferences.GdbDebugPreferencePage_Add_button );
+ fAddButton.setFont( JFaceResources.getDialogFont() );
+ setButtonLayoutData( fAddButton );
+ fAddButton.addSelectionListener( new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ addNewEntry();
+ }
+ } );
+
+ fDeleteButton = new Button( btnComp, SWT.PUSH );
+ fDeleteButton.setText( MessagesForPreferences.GdbDebugPreferencePage_Delete_button );
+ fDeleteButton.setFont( JFaceResources.getDialogFont() );
+ setButtonLayoutData( fDeleteButton );
+ fDeleteButton.addSelectionListener( new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ deleteEntries();
+ }
+ } );
+
+ table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ table.setHeaderVisible( true );
+ table.setLinesVisible( true );
+
+ TableViewerColumn commandColumn = new TableViewerColumn( fViewer, SWT.LEFT );
+ commandColumn.getColumn().setText( MessagesForPreferences.GdbDebugPreferencePage_Command_column_name );
+ commandColumn.setLabelProvider( createCommandLabelProvider() );
+ commandColumn.setEditingSupport( createCommandEditingSupport( fViewer ) );
+
+ TableViewerColumn timeoutColumn = new TableViewerColumn( fViewer, SWT.LEFT );
+ timeoutColumn.getColumn().setText( MessagesForPreferences.GdbDebugPreferencePage_Timeout_column_name );
+ timeoutColumn.setLabelProvider( createTimeoutLabelProvider() );
+ timeoutColumn.setEditingSupport( createTimeoutEditingSupport( fViewer ) );
+
+ fViewer.setContentProvider( createCustomTimeoutsContentProvider() );
+
+ table.addControlListener( new ControlAdapter() {
+
+ @Override
+ public void controlResized( ControlEvent e ) {
+ Rectangle area = table.getClientArea();
+ if ( area.width > 0 ) {
+ TableColumn[] cols = table.getColumns();
+ cols[0].setWidth( area.width * 50 / 100 );
+ cols[1].setWidth( area.width * 50 / 100 );
+ table.removeControlListener( this );
+ }
+ }
+ } );
+
+ fViewer.setInput( fEntries );
+
+ updateDialogButtons();
+
+ return control;
+ }
+
+ void updateDialogButtons() {
+ if ( fViewer != null && fDeleteButton != null ) {
+ fDeleteButton.setEnabled( !fViewer.getSelection().isEmpty() );
+ }
+ Button okButton = getButton( IDialogConstants.OK_ID );
+ if ( okButton != null )
+ okButton.setEnabled( getErrorMessage() == null );
+ }
+
+ void addNewEntry() {
+ CommandTimeoutEntry newEntry = new CommandTimeoutEntry( "", Integer.valueOf( 0 ) ); //$NON-NLS-1$
+ fEntries.add( newEntry );
+ fViewer.refresh();
+ fViewer.setSelection( new StructuredSelection( newEntry ) );
+ validateEntry( newEntry );
+ updateDialogButtons();
+ fViewer.editElement( newEntry, 0 );
+ }
+
+ void deleteEntries() {
+ IStructuredSelection sel = (IStructuredSelection)fViewer.getSelection();
+ if ( !sel.isEmpty() )
+ fEntries.removeAll( sel.toList() );
+ fViewer.refresh();
+ validate();
+ updateDialogButtons();
+ }
+
+ CustomTimeoutsMap getResult() {
+ CustomTimeoutsMap map = new CustomTimeoutsMap();
+ for ( CommandTimeoutEntry entry : fEntries ) {
+ map.put( entry.fCommand, entry.fTimeout );
+ }
+ return map;
+ }
+
+ void validate() {
+ for ( CommandTimeoutEntry entry : fEntries ) {
+ validateEntry( entry );
+ }
+ }
+
+ void validateEntry( CommandTimeoutEntry entry ) {
+ String errorMessage = fCommandValidator.isValid( entry.fCommand );
+ setErrorMessage( ( errorMessage != null ) ?
+ errorMessage : fTimeoutValidator.isValid( entry.fTimeout.toString() ) );
+ }
+
+ IStructuredContentProvider createCustomTimeoutsContentProvider() {
+ return new IStructuredContentProvider() {
+
+ @Override
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public Object[] getElements( Object inputElement ) {
+ if ( inputElement instanceof List> ) {
+ @SuppressWarnings( "unchecked" )
+ List list = (List)inputElement;
+ return list.toArray( new Object[list.size()] );
+ }
+ return null;
+ }
+ };
+ }
+
+ ColumnLabelProvider createCommandLabelProvider() {
+ return new ColumnLabelProvider() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( Object element ) {
+ if ( element instanceof CommandTimeoutEntry ) {
+ return ((CommandTimeoutEntry)element).fCommand;
+ }
+ return super.getText( element );
+ }
+ };
+ }
+
+ ColumnLabelProvider createTimeoutLabelProvider() {
+ return new ColumnLabelProvider() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( Object element ) {
+ if ( element instanceof CommandTimeoutEntry ) {
+ return ((CommandTimeoutEntry)element).fTimeout.toString();
+ }
+ return super.getText( element );
+ }
+ };
+ }
+
+ EditingSupport createCommandEditingSupport( ColumnViewer viewer ) {
+ return new AbstractEditingSupport( viewer ) {
+
+ @Override
+ boolean processValue( CommandTimeoutEntry entry, String value ) {
+ entry.fCommand = value;
+ return true;
+ }
+
+ @Override
+ Object doGetValue( CommandTimeoutEntry entry ) {
+ return entry.fCommand;
+ }
+
+ @Override
+ ICellEditorValidator getValidator() {
+ return fCommandValidator;
+ }
+ };
+ }
+
+ EditingSupport createTimeoutEditingSupport( ColumnViewer viewer ) {
+ return new AbstractEditingSupport( viewer ) {
+
+ @Override
+ boolean processValue( CommandTimeoutEntry entry, String value ) {
+ try {
+ entry.fTimeout = Integer.decode( value );
+ return true;
+ }
+ catch( NumberFormatException e ) {
+ // Shouldn't happen, validator takes care of this case.
+ }
+ return false;
+ }
+
+ @Override
+ Object doGetValue( CommandTimeoutEntry entry ) {
+ return entry.fTimeout.toString();
+ }
+
+ @Override
+ ICellEditorValidator getValidator() {
+ return fTimeoutValidator;
+ }
+ };
+ }
+ }
+
+ private IntegerWithBooleanFieldEditor fCommandTimeoutField;
+ private Button fTimeoutAdvancedButton;
+
+ private CustomTimeoutsMap fCustomTimeouts;
+
public GdbDebugPreferencePage() {
super(FLAT);
IPreferenceStore store= GdbUIPlugin.getDefault().getPreferenceStore();
setPreferenceStore(store);
setDescription(MessagesForPreferences.GdbDebugPreferencePage_description);
+ fCustomTimeouts = new CustomTimeoutsMap();
}
@Override
public void init(IWorkbench workbench) {
}
+ @Override
+ protected void initialize() {
+ super.initialize();
+ initializeCustomTimeouts();
+ }
+
@Override
public void createControl(Composite parent) {
super.createControl(parent);
+ updateTimeoutButtons();
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
GdbUIPlugin.PLUGIN_ID + ".dsfgdb_preference_page"); //$NON-NLS-1$
}
@@ -91,44 +537,46 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
final StringFieldEditor stringFieldEditorCommand = new StringFieldEditor(
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
- LaunchUIMessages.getString("GDBDebuggerPage.gdb_debugger"), //$NON-NLS-1$
+ "GDB debugger:", //$NON-NLS-1$
group1);
stringFieldEditorCommand.fillIntoGrid(group1, 2);
addField(stringFieldEditorCommand);
Button browsebutton = new Button(group1, SWT.PUSH);
- browsebutton.setText(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse")); //$NON-NLS-1$
+ browsebutton.setText("&Browse..."); //$NON-NLS-1$
browsebutton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- handleBrowseButtonSelected(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse_dlg_title"), //$NON-NLS-1$
+ handleBrowseButtonSelected("GDB Debugger", //$NON-NLS-1$
stringFieldEditorCommand);
}
});
+ setButtonLayoutData( browsebutton );
final StringFieldEditor stringFieldEditorGdbInit = new StringFieldEditor(
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT,
- LaunchUIMessages.getString("GDBDebuggerPage.gdb_command_file"), //$NON-NLS-1$
+ "GDB command file:", //$NON-NLS-1$
group1);
stringFieldEditorGdbInit.fillIntoGrid(group1, 2);
addField(stringFieldEditorGdbInit);
browsebutton = new Button(group1, SWT.PUSH);
- browsebutton.setText(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse")); //$NON-NLS-1$
+ browsebutton.setText("&Browse..."); //$NON-NLS-1$
browsebutton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- handleBrowseButtonSelected(LaunchUIMessages.getString("GDBDebuggerPage.gdb_cmdfile_dlg_title"), //$NON-NLS-1$
+ handleBrowseButtonSelected("GDB Command File", //$NON-NLS-1$
stringFieldEditorGdbInit);
}
});
+ setButtonLayoutData( browsebutton );
final StringWithBooleanFieldEditor enableStopAtMain = new StringWithBooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN,
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
- LaunchUIMessages.getString("CDebuggerTab.Stop_at_main_on_startup"), //$NON-NLS-1$
+ "Stop on startup at:", //$NON-NLS-1$
group1);
- enableStopAtMain.fillIntoGrid(group1, 2);
+ enableStopAtMain.fillIntoGrid(group1, 3);
addField(enableStopAtMain);
// final StringFieldEditor stopAtMainSymbol = new StringFieldEditor(
@@ -145,9 +593,29 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
// }
// });
+ fCommandTimeoutField = new IntegerWithBooleanFieldEditor(
+ IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT,
+ IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE,
+ MessagesForPreferences.GdbDebugPreferencePage_Command_timeout,
+ group1);
+ fCommandTimeoutField.setValidRange(0, Integer.MAX_VALUE);
+ fCommandTimeoutField.fillIntoGrid(group1, 2);
+ addField(fCommandTimeoutField);
+
+ fTimeoutAdvancedButton = new Button(group1, SWT.PUSH);
+ fTimeoutAdvancedButton.setText(MessagesForPreferences.GdbDebugPreferencePage_Advanced_button);
+ fTimeoutAdvancedButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleAdvancedButtonSelected(
+ "GDB Debugger"); //$NON-NLS-1$
+ }
+ });
+ setButtonLayoutData( fTimeoutAdvancedButton );
+
final ListenableBooleanFieldEditor enableNonStop= new ListenableBooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP,
- LaunchUIMessages.getString("GDBDebuggerPage.nonstop_mode"), //$NON-NLS-1$
+ "Non-stop mode (Note: Requires non-stop GDB)", //$NON-NLS-1$
SWT.NONE, group1);
enableNonStop.fillIntoGrid(group1, 3);
addField(enableNonStop);
@@ -286,8 +754,56 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
stringFieldEditor.setStringValue(res);
}
+ private void handleAdvancedButtonSelected(String dialogTitle) {
+ AdvancedTimeoutSettingsDialog dialog =
+ new AdvancedTimeoutSettingsDialog( getShell(), fCustomTimeouts.entrySet() );
+ if ( dialog.open() == Window.OK ) {
+ fCustomTimeouts = dialog.getResult();
+ }
+ }
+
@Override
protected void adjustGridLayout() {
// do nothing
}
+
+ @Override
+ public void propertyChange( PropertyChangeEvent event ) {
+ if ( event.getSource().equals( fCommandTimeoutField ) && event.getNewValue() instanceof Boolean ) {
+ fTimeoutAdvancedButton.setEnabled( ((Boolean)event.getNewValue()).booleanValue() );
+ }
+ super.propertyChange( event );
+ }
+
+ @Override
+ protected void performDefaults() {
+ IPreferenceStore store = getPreferenceStore();
+ if ( store != null ) {
+ String memento = store.getDefaultString( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS );
+ fCustomTimeouts.initializeFromMemento( memento );
+ }
+ super.performDefaults();
+ updateTimeoutButtons();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ getPreferenceStore().setValue( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS, fCustomTimeouts.getMemento() );
+ return super.performOk();
+ }
+
+ private void updateTimeoutButtons() {
+ fTimeoutAdvancedButton.setEnabled( fCommandTimeoutField.getBooleanValue() );
+ }
+
+ private void initializeCustomTimeouts() {
+ IPreferenceStore store = getPreferenceStore();
+ if ( store != null ) {
+ String memento = store.getString( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS );
+ fCustomTimeouts.initializeFromMemento( memento );
+ }
+ }
}
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 43f30999338..752701a87b2 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
@@ -17,6 +17,12 @@ import org.eclipse.osgi.util.NLS;
* Preference strings.
*/
class MessagesForPreferences extends NLS {
+ public static String GdbDebugPreferencePage_Add_button;
+ public static String GdbDebugPreferencePage_Advanced_button;
+ public static String GdbDebugPreferencePage_Advanced_timeout_dialog_message;
+ public static String GdbDebugPreferencePage_Advanced_timeout_dialog_title;
+ public static String GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip;
+ public static String GdbDebugPreferencePage_Advanced_Timeout_Settings;
public static String GdbDebugPreferencePage_description;
public static String GdbDebugPreferencePage_traces_label;
public static String GdbDebugPreferencePage_enableTraces_label;
@@ -24,6 +30,9 @@ class MessagesForPreferences extends NLS {
public static String GdbDebugPreferencePage_maxGdbTraces_label;
public static String GdbDebugPreferencePage_termination_label;
public static String GdbDebugPreferencePage_autoTerminateGdb_label;
+ public static String GdbDebugPreferencePage_Command_column_name;
+ public static String GdbDebugPreferencePage_Command_field_can_not_be_empty;
+ public static String GdbDebugPreferencePage_Command_timeout;
public static String GdbDebugPreferencePage_hover_label;
public static String GdbDebugPreferencePage_useInspectorHover_label;
/** @since 2.2 */
@@ -36,6 +45,10 @@ class MessagesForPreferences extends NLS {
public static String GdbDebugPreferencePage_initialChildCountLimitForCollections_label;
/** @since 2.2 */
public static String GdbDebugPreferencePage_defaults_label;
+ public static String GdbDebugPreferencePage_Delete_button;
+ public static String GdbDebugPreferencePage_Invalid_timeout_value;
+ public static String GdbDebugPreferencePage_Timeout_column_name;
+ public static String GdbDebugPreferencePage_Timeout_value_can_not_be_negative;
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 849a567443a..954149f1345 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
@@ -10,6 +10,7 @@
# Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
###############################################################################
+GdbDebugPreferencePage_Add_button=Add
GdbDebugPreferencePage_description=General settings for GDB Debugging
GdbDebugPreferencePage_traces_label=Traces
@@ -17,6 +18,9 @@ GdbDebugPreferencePage_enableTraces_label=Enable GDB traces
GdbDebugPreferencePage_maxGdbTraces_label=Limit GDB traces output (number of characters):
GdbDebugPreferencePage_termination_label=Termination
GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
+GdbDebugPreferencePage_Command_column_name=GDB/MI Command
+GdbDebugPreferencePage_Command_field_can_not_be_empty='Command' field can not be empty
+GdbDebugPreferencePage_Command_timeout=Command timeout (ms):
GdbDebugPreferencePage_hover_label=Debug Text Hover
GdbDebugPreferencePage_useInspectorHover_label=Use enhanced debug hover
@@ -27,3 +31,13 @@ GdbDebugPreferencePage_enablePrettyPrinting_label2=(requires python-enabled GDB)
GdbDebugPreferencePage_initialChildCountLimitForCollections_label=For collections, initially limit child count to
GdbDebugPreferencePage_defaults_label=Debug Configurations Defaults
+GdbDebugPreferencePage_Delete_button=Delete
+GdbDebugPreferencePage_Invalid_timeout_value=Invalid timeout value
+GdbDebugPreferencePage_Timeout_column_name=Timeout(ms)
+GdbDebugPreferencePage_Timeout_value_can_not_be_negative=Timeout value can not be negative
+
+GdbDebugPreferencePage_Advanced_button=&Advanced...
+GdbDebugPreferencePage_Advanced_timeout_dialog_message=Specify commands and corresponding timeout values.
+GdbDebugPreferencePage_Advanced_timeout_dialog_title=Add/delete/modify custom timeouts for GDB/MI commands
+GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip=Specify commands and corresponding timeout values, use zero for "no timeout".\nMI commands must start with hyphen ('-'). For example, '-target-select'.\nThe default value will be used for all commands that are not mentioned here.
+GdbDebugPreferencePage_Advanced_Timeout_Settings=Advanced Timeout Settings
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/.options b/dsf-gdb/org.eclipse.cdt.dsf.gdb/.options
index 28eeb8b6aa9..b9256aedc6e 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/.options
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/.options
@@ -1 +1,2 @@
org.eclipse.cdt.dsf.gdb/debug = false
+org.eclipse.cdt.dsf.gdb/debug/timeouts = false
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java
index f50d84f1021..a56582932cf 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java
@@ -16,7 +16,6 @@ import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
-
/**
* @noimplement This interface is not intended to be implemented by clients.
* @since 4.0
@@ -25,6 +24,12 @@ public interface IGdbDebugConstants {
public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+ /**
+ * Status code for which a UI handler is registered.
+ * @since 4.1
+ */
+ public static final int STATUS_HANDLER_CODE = 20001;
+
/**
* Attribute key to be added to the IProcess associated with an IMIContainerDMContext.
* The value should be the groupId as returned by {@link IMIContainerDMContext#getGroupId()}
@@ -54,6 +59,5 @@ public interface IGdbDebugConstants {
*/
public static final String GDB_PROCESS_CREATION_VALUE = PREFIX + "gdbProcess"; //$NON-NLS-1$
-
}
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 acc62431fc4..8a77e886b18 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
@@ -19,6 +19,11 @@ import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
* @since 2.0
*/
public interface IGdbDebugPreferenceConstants {
+
+ /**
+ * Help prefixes.
+ */
+ public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
/**
* Boolean preference whether to enable GDB traces. Default is true
.
@@ -87,8 +92,27 @@ public interface IGdbDebugPreferenceConstants {
public static final String PREF_DEFAULT_NON_STOP = "defaultNonStop"; //$NON-NLS-1$
/**
- * Help prefixes.
- */
- public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+ * The value is an boolean specifying whether the timeout is used for GDB commands.
+ * @since 4.1
+ */
+ public static final String PREF_COMMAND_TIMEOUT = PREFIX + "commandTimeout"; //$NON-NLS-1$
+
+ /**
+ * The value is an integer specifying the timeout value (milliseconds) for GDB commands.
+ * @since 4.1
+ */
+ public static final String PREF_COMMAND_TIMEOUT_VALUE = PREFIX + "commandTimeoutValue"; //$NON-NLS-1$
+
+ /**
+ * The value is a string specifying the list of GDB/MI commands with custom timeout values.
+ * @since 4.1
+ */
+ public static final String PREF_COMMAND_CUSTOM_TIMEOUTS = PREFIX + "commandCustomTimeouts"; //$NON-NLS-1$
+
+ /**
+ * Default default value for PREF_COMMAND_TIMEOUT
;
+ * @since 4.1
+ */
+ public static final int COMMAND_TIMEOUT_VALUE_DEFAULT = 10000;
}
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 e9403f12ba9..92d0a08d776 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
@@ -38,5 +38,7 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer {
node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT);
node.put(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
+ node.putBoolean(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, false);
+ node.putInt(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT);
}
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/Messages.java
new file mode 100644
index 00000000000..ee19d3c3678
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/Messages.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.dsf.gdb.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ public static String CustomTimeoutsMap_Error_initializing_custom_timeouts;
+
+ public static String CustomTimeoutsMap_Invalid_custom_timeout_data;
+
+ public static String CustomTimeoutsMap_Invalid_custom_timeout_value;
+
+ public static String GDBControl_Session_is_terminated;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages( Messages.class.getName(), Messages.class );
+ }
+
+ private Messages() {
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/Messages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/Messages.properties
new file mode 100644
index 00000000000..9a4e8c3dbbe
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/Messages.properties
@@ -0,0 +1,15 @@
+#######################################################################################
+# Copyright (c) 2011 Mentor Graphics and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Mentor Graphics - Initial API and implementation
+#######################################################################################
+
+CustomTimeoutsMap_Error_initializing_custom_timeouts=Error initializing custom timeouts
+CustomTimeoutsMap_Invalid_custom_timeout_data=Invalid custom timeout data.
+CustomTimeoutsMap_Invalid_custom_timeout_value=Invalid custom timeout value for '%s'.
+GDBControl_Session_is_terminated=Session is terminated.\nReason: %s
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/CustomTimeoutsMap.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/CustomTimeoutsMap.java
new file mode 100644
index 00000000000..503ec1a48c1
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/CustomTimeoutsMap.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.dsf.gdb.service.command;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.dsf.gdb.internal.Messages;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * @since 4.1
+ */
+public class CustomTimeoutsMap extends HashMap {
+
+ public CustomTimeoutsMap() {
+ super();
+ }
+
+ public CustomTimeoutsMap( CustomTimeoutsMap map ) {
+ super( map );
+ }
+
+ private static final long serialVersionUID = -8281280275781904870L;
+
+ public String getMemento() {
+ StringBuilder sb = new StringBuilder();
+ for ( Map.Entry entry : entrySet() ) {
+ sb.append( entry.getKey() );
+ sb.append( ',' );
+ sb.append( entry.getValue().intValue() );
+ sb.append( ';' );
+ }
+ return sb.toString();
+ }
+
+ public void initializeFromMemento( String memento ) {
+ clear();
+ StringTokenizer st = new StringTokenizer( memento, ";" ); //$NON-NLS-1$
+ MultiStatus ms = new MultiStatus( GdbPlugin.PLUGIN_ID, 0, Messages.CustomTimeoutsMap_Error_initializing_custom_timeouts, null );
+ while( st.hasMoreTokens() ) {
+ String token = st.nextToken();
+ String[] tokenParts = token.split( "," ); //$NON-NLS-1$
+ if ( tokenParts.length == 2 && tokenParts[0].length() > 0 && tokenParts[1].length() > 0 ) {
+ try {
+ put( tokenParts[0], Integer.valueOf( tokenParts[1] ) );
+ }
+ catch( NumberFormatException e ) {
+ ms.add( new Status(
+ IStatus.ERROR,
+ GdbPlugin.PLUGIN_ID,
+ String.format( Messages.CustomTimeoutsMap_Invalid_custom_timeout_value, tokenParts[0] ) ) );
+ }
+ }
+ else {
+ ms.add( new Status(
+ IStatus.ERROR,
+ GdbPlugin.PLUGIN_ID,
+ Messages.CustomTimeoutsMap_Invalid_custom_timeout_data ) );
+ }
+ }
+ if ( !ms.isOK() ) {
+ GdbPlugin.getDefault().getLog().log( ms );
+ }
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
index dd4b956a7b5..dbd6dc9cac3 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
@@ -30,6 +30,7 @@ import java.util.Properties;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
@@ -43,10 +44,14 @@ import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
+import org.eclipse.cdt.dsf.debug.service.command.ICommandToken;
+import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.dsf.gdb.internal.Messages;
import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses;
+import org.eclipse.cdt.dsf.gdb.service.command.GdbCommandTimeoutManager.ICommandTimeoutListener;
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
import org.eclipse.cdt.dsf.mi.service.IMIBackend.BackendStateChangedEvent;
import org.eclipse.cdt.dsf.mi.service.IMIBackend2;
@@ -69,8 +74,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.IStatusHandler;
import org.osgi.framework.BundleContext;
/**
@@ -82,6 +89,8 @@ import org.osgi.framework.BundleContext;
*/
public class GDBControl extends AbstractMIControl implements IGDBControl {
+ private static final int STATUS_CODE_COMMAND_TIMED_OUT = 20100;
+
/**
* Event indicating that the back end process has started.
*/
@@ -104,6 +113,20 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
}
}
+ private class TimeoutListener implements ICommandTimeoutListener {
+
+ @Override
+ public void commandTimedOut(final ICommandToken token) {
+ getExecutor().execute(new DsfRunnable() {
+
+ @Override
+ public void run() {
+ GDBControl.this.commandTimedOut(token);
+ }
+ });
+ }
+ }
+
private GDBControlDMContext fControlDmc;
private IGDBBackend fMIBackend;
@@ -112,6 +135,10 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
private IEventProcessor fCLICommandProcessor;
private AbstractCLIProcess fCLIProcess;
+ private GdbCommandTimeoutManager fCommandTimeoutManager;
+
+ private ICommandTimeoutListener fTimeoutListener = new TimeoutListener();
+
/**
* GDBControl is only used for GDB earlier that 7.0. Although -list-features
* is available in 6.8, it does not report anything we care about, so
@@ -120,6 +147,14 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
private final List fFeatures = new ArrayList();
private Sequence fInitializationSequence;
+
+ /**
+ * Indicator to distinguish whether this service is initialized.
+ * fInitializationSequence
can not be used for this
+ * purpose because there is a period of time when the service is already
+ * initializing but the initialization sequence has not created yet.
+ */
+ private boolean fInitialized = false;
private boolean fTerminated;
@@ -308,6 +343,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
@Override
protected void handleCompleted() {
fInitializationSequence = null;
+ fInitialized = true;
if (!isCanceled()) {
// Only set the status if the user has not cancelled the operation already.
rm.setStatus(getStatus());
@@ -440,6 +476,33 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
}
}
+ /**
+ * @since 4.1
+ */
+ protected class CommandTimeoutStep extends InitializationShutdownStep {
+ CommandTimeoutStep( Direction direction ) {
+ super( direction );
+ }
+
+ @Override
+ public void initialize( final RequestMonitor requestMonitor ) {
+ fCommandTimeoutManager = createCommandTimeoutManager( GDBControl.this );
+ if (fCommandTimeoutManager != null) {
+ fCommandTimeoutManager.addCommandTimeoutListener(fTimeoutListener);
+ }
+ requestMonitor.done();
+ }
+
+ @Override
+ protected void shutdown( RequestMonitor requestMonitor ) {
+ if ( fCommandTimeoutManager != null ) {
+ fCommandTimeoutManager.removeCommandTimeoutListener(fTimeoutListener);
+ fCommandTimeoutManager.dispose();
+ }
+ requestMonitor.done();
+ }
+ }
+
protected class RegisterStep extends InitializationShutdownStep {
RegisterStep(Direction direction) { super(direction); }
@Override
@@ -493,6 +556,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
final Sequence.Step[] initializeSteps = new Sequence.Step[] {
new CommandMonitoringStep(InitializationShutdownStep.Direction.INITIALIZING),
new CommandProcessorsStep(InitializationShutdownStep.Direction.INITIALIZING),
+ new CommandTimeoutStep(InitializationShutdownStep.Direction.INITIALIZING),
new RegisterStep(InitializationShutdownStep.Direction.INITIALIZING),
};
@@ -507,6 +571,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
protected Sequence getShutdownSequence(RequestMonitor requestMonitor) {
final Sequence.Step[] shutdownSteps = new Sequence.Step[] {
new RegisterStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
+ new CommandTimeoutStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
new CommandProcessorsStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
new CommandMonitoringStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
};
@@ -536,4 +601,63 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
fFeatures.clear();
fFeatures.addAll(features);
}
+
+ /**
+ * @since 4.1
+ */
+ protected GdbCommandTimeoutManager createCommandTimeoutManager(ICommandControl commandControl) {
+ GdbCommandTimeoutManager manager = new GdbCommandTimeoutManager(commandControl);
+ manager.initialize();
+ return manager;
+ }
+
+ /**
+ * @since 4.1
+ */
+ @ConfinedToDsfExecutor("this.getExecutor()")
+ protected void commandTimedOut(ICommandToken token) {
+ String commandText = token.getCommand().toString();
+ if (commandText.endsWith("\n")) //$NON-NLS-1$
+ commandText = commandText.substring(0, commandText.length() - 1);
+ final String errorMessage = String.format("Command '%s' is timed out", commandText); //$NON-NLS-1$
+ commandFailed(token, STATUS_CODE_COMMAND_TIMED_OUT, errorMessage);
+
+ // If the timeout occurs while the launch sequence is running
+ // the error will be reported by the launcher's error reporting mechanism.
+ // We need to show the error message only when the session is initialized.
+ if (isInitialized()) {
+ // The session is terminated if a command is timed out.
+ terminate(new RequestMonitor(getExecutor(), null) {
+
+ @Override
+ protected void handleErrorOrWarning() {
+ GdbPlugin.getDefault().getLog().log(getStatus());
+ super.handleErrorOrWarning();
+ };
+ } );
+
+ IStatus status = new Status(
+ IStatus.ERROR,
+ GdbPlugin.PLUGIN_ID,
+ IGdbDebugConstants.STATUS_HANDLER_CODE,
+ String.format( Messages.GDBControl_Session_is_terminated, errorMessage ),
+ null);
+ IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(status);
+ if (statusHandler != null) {
+ try {
+ statusHandler.handleStatus(status, null);
+ }
+ catch(CoreException e) {
+ GdbPlugin.getDefault().getLog().log(e.getStatus());
+ }
+ }
+ }
+ }
+
+ /**
+ * @since 4.1
+ */
+ protected boolean isInitialized() {
+ return fInitialized;
+ }
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
index 3a780424602..55f4aa15860 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
@@ -147,6 +147,7 @@ public class GDBControl_7_0 extends GDBControl {
final Sequence.Step[] initializeSteps = new Sequence.Step[] {
new GDBControl.CommandMonitoringStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
new GDBControl.CommandProcessorsStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
+ new CommandTimeoutStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
new ListFeaturesStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
new GDBControl.RegisterStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
};
@@ -161,6 +162,7 @@ public class GDBControl_7_0 extends GDBControl {
final Sequence.Step[] shutdownSteps = new Sequence.Step[] {
new GDBControl.RegisterStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
new ListFeaturesStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
+ new CommandTimeoutStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
new GDBControl.CommandProcessorsStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
new GDBControl.CommandMonitoringStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
};
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GdbCommandTimeoutManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GdbCommandTimeoutManager.java
new file mode 100644
index 00000000000..133865c1a95
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GdbCommandTimeoutManager.java
@@ -0,0 +1,443 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.dsf.gdb.service.command;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.eclipse.cdt.dsf.debug.service.command.ICommand;
+import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
+import org.eclipse.cdt.dsf.debug.service.command.ICommandListener;
+import org.eclipse.cdt.dsf.debug.service.command.ICommandResult;
+import org.eclipse.cdt.dsf.debug.service.command.ICommandToken;
+import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.dsf.mi.service.command.AbstractMIControl;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+/**
+ * The command timeout manager registers itself as a command listener and monitors
+ * the command execution time. The goal of this implementation is to gracefully
+ * handle disruptions in the communication between Eclipse and GDB.
+ *
+ * The algorithm used by this class is based on the assumption that the command
+ * execution in GDB is sequential even though DSF can send up to 3 commands at
+ * a time to GDB (see {@link AbstractMIControl}).
+ *
+ * @since 4.1
+ */
+public class GdbCommandTimeoutManager implements ICommandListener, IPreferenceChangeListener {
+
+ public interface ICommandTimeoutListener {
+
+ void commandTimedOut( ICommandToken token );
+ }
+
+ public final static boolean DEBUG = "true".equals( Platform.getDebugOption( "org.eclipse.cdt.dsf.gdb/debug/timeouts" ) ); //$NON-NLS-1$//$NON-NLS-2$
+
+ private class QueueEntry {
+ private long fTimestamp;
+ private ICommandToken fCommandToken;
+
+ private QueueEntry( long timestamp, ICommandToken commandToken ) {
+ super();
+ fTimestamp = timestamp;
+ fCommandToken = commandToken;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if ( obj instanceof QueueEntry ) {
+ return fCommandToken.equals( ((QueueEntry)obj).fCommandToken );
+ }
+ return false;
+ }
+ }
+
+ private enum TimerThreadState {
+ INITIALIZING,
+ RUNNING,
+ HALTED,
+ SHUTDOWN
+ }
+
+ private class TimerThread extends Thread {
+
+ private BlockingQueue fQueue;
+ private int fWaitTimeout = IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT;
+ private TimerThreadState fState = TimerThreadState.INITIALIZING;
+
+ TimerThread( BlockingQueue queue, int timeout ) {
+ super();
+ setName( "GDB Command Timer Thread" ); //$NON-NLS-1$
+ fQueue = queue;
+ setWaitTimout( timeout );
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Thread#run()
+ */
+ @Override
+ public void run() {
+ setTimerThreadState( ( getWaitTimeout() > 0 ) ?
+ TimerThreadState.RUNNING : TimerThreadState.HALTED );
+ doRun();
+ }
+
+ private void doRun() {
+ while ( getTimerThreadState() != TimerThreadState.SHUTDOWN ) {
+ if ( getTimerThreadState() == TimerThreadState.HALTED ) {
+ halted();
+ }
+ else {
+ running();
+ }
+ }
+ }
+
+ private void halted() {
+ fQueue.clear();
+ try {
+ synchronized( TimerThread.this ) {
+ wait();
+ }
+ }
+ catch( InterruptedException e ) {
+ }
+ }
+
+ private void running() {
+ try {
+ while( getTimerThreadState() == TimerThreadState.RUNNING ) {
+ // Use the minimum of all timeout values > 0 as the wait timeout.
+ long timeout = getWaitTimeout();
+ QueueEntry entry = fQueue.peek();
+ if ( entry != null ) {
+ // Calculate the time elapsed since the execution of this command started
+ // and compare it with the command's timeout value.
+ // If the elapsed time is greater or equal than the timeout value the command
+ // is marked as timed out. Otherwise, schedule the next check when the timeout
+ // expires.
+ long commandTimeout = getTimeoutForCommand( entry.fCommandToken.getCommand() );
+
+ if ( DEBUG ) {
+ String commandText = entry.fCommandToken.getCommand().toString();
+ if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
+ commandText = commandText.substring( 0, commandText.length() - 1 );
+ printDebugMessage( String.format( "Processing command '%s', command timeout is %d", //$NON-NLS-1$
+ commandText, Long.valueOf( commandTimeout ) ) );
+ }
+
+ long currentTime = System.currentTimeMillis();
+ long elapsedTime = currentTime - entry.fTimestamp;
+ if ( commandTimeout <= elapsedTime ) {
+ processTimedOutCommand( entry.fCommandToken );
+ fQueue.remove( entry );
+ // Reset the timestamp of the next command in the queue because
+ // regardless how long the command has been in the queue GDB will
+ // start executing it only when the execution of the previous command
+ // is completed.
+ QueueEntry nextEntry = fQueue.peek();
+ if ( nextEntry != null ) {
+ setTimeStamp( currentTime, nextEntry );
+ }
+ }
+ else {
+ // Adjust the wait timeout because the time remaining for
+ // the current command to expire may be less than the current wait timeout.
+ timeout = Math.min( timeout, commandTimeout - elapsedTime );
+
+ if ( DEBUG ) {
+ String commandText = entry.fCommandToken.getCommand().toString();
+ if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
+ commandText = commandText.substring( 0, commandText.length() - 1 );
+ printDebugMessage( String.format( "Setting timeout %d for command '%s'", Long.valueOf( timeout ), commandText ) ); //$NON-NLS-1$
+ }
+ }
+ }
+ synchronized( TimerThread.this ) {
+ wait( timeout );
+ }
+ }
+ }
+ catch( InterruptedException e ) {
+ }
+ }
+
+ private void shutdown() {
+ setTimerThreadState( TimerThreadState.SHUTDOWN );
+ }
+
+ private synchronized void setWaitTimout( int waitTimeout ) {
+ fWaitTimeout = waitTimeout;
+ if ( DEBUG )
+ printDebugMessage( String.format( "Wait timeout is set to %d", Integer.valueOf( fWaitTimeout ) ) ); //$NON-NLS-1$
+ }
+
+ private synchronized int getWaitTimeout() {
+ return fWaitTimeout;
+ }
+
+ private synchronized void setTimerThreadState( TimerThreadState state ) {
+ fState = state;
+ interrupt();
+ }
+
+ private synchronized TimerThreadState getTimerThreadState() {
+ return fState;
+ }
+ }
+
+ private static final String TIMEOUT_TRACE_IDENTIFIER = "[TMO]"; //$NON-NLS-1$
+
+ private ICommandControl fCommandControl;
+ private boolean fTimeoutEnabled = false;
+ private int fTimeout = 0;
+ private TimerThread fTimerThread;
+ private BlockingQueue fCommandQueue = new LinkedBlockingQueue();
+ private CustomTimeoutsMap fCustomTimeouts = new CustomTimeoutsMap();
+
+ private ListenerList fListeners;
+
+ public GdbCommandTimeoutManager( ICommandControl commandControl ) {
+ fCommandControl = commandControl;
+ fListeners = new ListenerList();
+ }
+
+ public void initialize() {
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
+
+ fTimeoutEnabled = Platform.getPreferencesService().getBoolean(
+ GdbPlugin.PLUGIN_ID,
+ IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT,
+ false,
+ null );
+
+ fTimeout = Platform.getPreferencesService().getInt(
+ GdbPlugin.PLUGIN_ID,
+ IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE,
+ IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT,
+ null );
+
+ fCustomTimeouts.initializeFromMemento( Platform.getPreferencesService().getString(
+ GdbPlugin.PLUGIN_ID,
+ IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS,
+ "", //$NON-NLS-1$
+ null ) );
+
+ node.addPreferenceChangeListener( this );
+
+ fCommandControl.addCommandListener( this );
+
+ fTimerThread = new TimerThread( fCommandQueue, calculateWaitTimeout() );
+ fTimerThread.start();
+ }
+
+ public void dispose() {
+ fTimerThread.shutdown();
+ fListeners.clear();
+ InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID ).removePreferenceChangeListener( this );
+ fCommandControl.removeCommandListener( this );
+ fCommandQueue.clear();
+ fCustomTimeouts.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.command.ICommandListener#commandQueued(org.eclipse.cdt.dsf.debug.service.command.ICommandToken)
+ */
+ @Override
+ public void commandQueued( ICommandToken token ) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.command.ICommandListener#commandSent(org.eclipse.cdt.dsf.debug.service.command.ICommandToken)
+ */
+ @Override
+ public void commandSent( ICommandToken token ) {
+ if ( !isTimeoutEnabled() )
+ return;
+ int commandTimeout = getTimeoutForCommand( token.getCommand() );
+ if ( DEBUG ) {
+ String commandText = token.getCommand().toString();
+ if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
+ commandText = commandText.substring( 0, commandText.length() - 1 );
+ printDebugMessage( String.format( "Command '%s' sent, timeout = %d", commandText, Integer.valueOf( commandTimeout ) ) ); //$NON-NLS-1$
+ }
+ if ( commandTimeout == 0 )
+ // Skip commands with no timeout
+ return;
+ try {
+ fCommandQueue.put( new QueueEntry( System.currentTimeMillis(), token ) );
+ }
+ catch( InterruptedException e ) {
+ // ignore
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.command.ICommandListener#commandRemoved(org.eclipse.cdt.dsf.debug.service.command.ICommandToken)
+ */
+ @Override
+ public void commandRemoved( ICommandToken token ) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.command.ICommandListener#commandDone(org.eclipse.cdt.dsf.debug.service.command.ICommandToken, org.eclipse.cdt.dsf.debug.service.command.ICommandResult)
+ */
+ @Override
+ public void commandDone( ICommandToken token, ICommandResult result ) {
+ if ( !isTimeoutEnabled() )
+ return;
+ fCommandQueue.remove( new QueueEntry( 0, token ) );
+ if ( DEBUG ) {
+ String commandText = token.getCommand().toString();
+ if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
+ commandText = commandText.substring( 0, commandText.length() - 1 );
+ printDebugMessage( String.format( "Command '%s' is done", commandText ) ); //$NON-NLS-1$
+ }
+ // Reset the timestamp of the next command in the queue because
+ // regardless how long it has been in the queue GDB will start
+ // executing it only when the execution of the previous command
+ // is completed.
+ QueueEntry nextEntry = fCommandQueue.peek();
+ if ( nextEntry != null ) {
+ setTimeStamp( System.currentTimeMillis(), nextEntry );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
+ */
+ @Override
+ public void preferenceChange( PreferenceChangeEvent event ) {
+ String property = event.getKey();
+ if ( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT.equals( property ) ) {
+ // The new value is null when the timeout support is disabled.
+ if ( event.getNewValue() == null || !event.getNewValue().equals( event.getOldValue() ) ) {
+ fTimeoutEnabled = ( event.getNewValue() != null ) ?
+ Boolean.parseBoolean( event.getNewValue().toString() ) : Boolean.FALSE;
+ updateWaitTimeout();
+ fTimerThread.setTimerThreadState( ( fTimerThread.getWaitTimeout() > 0 ) ?
+ TimerThreadState.RUNNING : TimerThreadState.HALTED );
+ }
+ }
+ else if ( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE.equals( property ) ) {
+ if ( event.getNewValue() == null || !event.getNewValue().equals( event.getOldValue() ) ) {
+ try {
+ fTimeout = ( event.getNewValue() != null ) ?
+ Integer.parseInt( event.getNewValue().toString() ) :
+ IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT;
+ updateWaitTimeout();
+ fTimerThread.setTimerThreadState( ( fTimerThread.getWaitTimeout() > 0 ) ?
+ TimerThreadState.RUNNING : TimerThreadState.HALTED );
+ }
+ catch( NumberFormatException e ) {
+ GdbPlugin.getDefault().getLog().log( new Status( IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Invlaid timeout value" ) ); //$NON-NLS-1$
+ }
+ }
+ }
+ else if ( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS.equals( property ) ) {
+ if ( event.getNewValue() instanceof String ) {
+ fCustomTimeouts.initializeFromMemento( (String)event.getNewValue() );
+ }
+ else if ( event.getNewValue() == null ) {
+ fCustomTimeouts.clear();
+ }
+ updateWaitTimeout();
+ fTimerThread.setTimerThreadState( ( fTimerThread.getWaitTimeout() > 0 ) ?
+ TimerThreadState.RUNNING : TimerThreadState.HALTED );
+ }
+ }
+
+ protected int getTimeoutForCommand( ICommand extends ICommandResult> command ) {
+ if ( !(command instanceof MICommand>) )
+ return 0;
+ @SuppressWarnings( "unchecked" )
+ Integer timeout = fCustomTimeouts.get( ((MICommand extends MIInfo>)command).getOperation() );
+ return ( timeout != null ) ? timeout.intValue() : fTimeout;
+ }
+
+ protected void processTimedOutCommand( ICommandToken token ) {
+ if ( DEBUG ) {
+ String commandText = token.getCommand().toString();
+ if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
+ commandText = commandText.substring( 0, commandText.length() - 1 );
+ printDebugMessage( String.format( "Command '%s' is timed out", commandText ) ); //$NON-NLS-1$
+ }
+ for ( Object l : fListeners.getListeners() ) {
+ ((ICommandTimeoutListener)l).commandTimedOut( token );
+ }
+ }
+
+ public void addCommandTimeoutListener( ICommandTimeoutListener listener ) {
+ fListeners.add( listener );
+ }
+
+ public void removeCommandTimeoutListener( ICommandTimeoutListener listener ) {
+ fListeners.remove( listener );
+ }
+
+ private void updateWaitTimeout() {
+ fTimerThread.setWaitTimout( calculateWaitTimeout() );
+ }
+
+ private boolean isTimeoutEnabled() {
+ return fTimeoutEnabled;
+ }
+
+ private void printDebugMessage( String message ) {
+ System.out.println( String.format( "%s %s %s", GdbPlugin.getDebugTime(), TIMEOUT_TRACE_IDENTIFIER, message ) ); //$NON-NLS-1$
+ }
+
+ private int calculateWaitTimeout() {
+ int waitTimeout = 0;
+ if ( isTimeoutEnabled() ) {
+ waitTimeout = fTimeout;
+ int minCustomTimeout = Integer.MAX_VALUE;
+ for ( Integer t : fCustomTimeouts.values() ) {
+ if ( t.intValue() > 0 ) {
+ minCustomTimeout = Math.min( minCustomTimeout, t.intValue() );
+ }
+ }
+ if ( minCustomTimeout > 0 ) {
+ waitTimeout = ( waitTimeout == 0 ) ?
+ minCustomTimeout : Math.min( waitTimeout, minCustomTimeout );
+ }
+ }
+ return waitTimeout;
+ }
+
+ private void setTimeStamp( long currentTime, QueueEntry nextEntry ) {
+ if ( nextEntry != null ) {
+ nextEntry.fTimestamp = currentTime;
+
+ if ( DEBUG ) {
+ String commandText = nextEntry.fCommandToken.getCommand().toString();
+ if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
+ commandText = commandText.substring( 0, commandText.length() - 1 );
+ printDebugMessage( String.format( "Setting the timestamp for command '%s' to %d", commandText, Long.valueOf( currentTime ) ) ); //$NON-NLS-1$
+ }
+ }
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java
index eb2e702a877..6277fbb97ad 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java
@@ -29,6 +29,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
+import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
@@ -874,6 +875,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
}
void processMIOutput(String line) {
+
MIParser.RecordType recordType = fMiParser.getRecordType(line);
if (recordType == MIParser.RecordType.ResultRecord) {
@@ -885,6 +887,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
* some form of asynchronous notification. Or perhaps general IO.
*/
int id = rr.getToken();
+
final CommandHandle commandHandle = fRxCommands.remove(id);
if (commandHandle != null) {
@@ -1098,4 +1101,46 @@ public abstract class AbstractMIControl extends AbstractDsfService
fCurrentStackLevel = -1;
}
+ /**
+ * @since 4.1
+ */
+ @ConfinedToDsfExecutor("this.getExecutor()")
+ protected void commandFailed(ICommandToken token, int statusCode, String errorMessage) {
+ if ( !(token instanceof CommandHandle && token.getCommand() instanceof MICommand>) )
+ return;
+ final CommandHandle commandHandle = (CommandHandle)token;
+ Integer tokenId = commandHandle.getTokenId();
+
+ // If the timeout value is too small a command can be timed out but still processed by RxThread.
+ // To avoid processing it twice we need to remove it from the command list.
+ CommandHandle h = fRxCommands.remove(tokenId);
+ if (h == null)
+ // Command has already been processed by RxThread.
+ return;
+
+ MIConst value = new MIConst();
+ value.setCString(errorMessage);
+ MIResult result = new MIResult();
+ result.setVariable("msg"); //$NON-NLS-1$
+ result.setMIValue(value);
+ MIResultRecord resultRecord = new MIResultRecord();
+ resultRecord.setToken(tokenId.intValue());
+ resultRecord.setResultClass(MIResultRecord.ERROR);
+ resultRecord.setMIResults(new MIResult[] { result });
+ MIOutput miOutput = new MIOutput(resultRecord, new MIOOBRecord[0]);
+
+ final MIInfo info = commandHandle.getCommand().getResult(miOutput);
+ DataRequestMonitor rm = commandHandle.getRequestMonitor();
+
+ if ( rm != null ) {
+ rm.setData(info);
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, statusCode, errorMessage, null));
+ rm.done();
+
+ /*
+ * Now tell the generic listeners about it.
+ */
+ processCommandDone(commandHandle, info);
+ }
+ }
}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java
index 797e4882983..7d20fe9db2c 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java
@@ -91,6 +91,10 @@ public class BaseTestCase {
launchAttributes.put(key, value);
}
+ public static void removeLaunchAttribute(String key) {
+ launchAttributes.remove(key);
+ }
+
public static void setGlobalLaunchAttribute(String key, Object value) {
globalLaunchAttributes.put(key, value);
}
@@ -206,7 +210,8 @@ public class BaseTestCase {
.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
// First check if we should launch gdbserver in the case of a remote session
- launchGdbServer();
+ if (reallyLaunchGDBServer())
+ launchGdbServer();
ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType lcType = launchMgr.getLaunchConfigurationType("org.eclipse.cdt.tests.dsf.gdb.TestLaunch");
@@ -332,4 +337,14 @@ public class BaseTestCase {
BaseTestCase.setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : ""));
BaseTestCase.setLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : ""));
}
+
+ /**
+ * In some tests we need to start a gdbserver session without starting gdbserver.
+ * This method allows super classes of this class control the launch of gdbserver.
+ *
+ * @return whether gdbserver should be started
+ */
+ protected boolean reallyLaunchGDBServer() {
+ return true;
+ }
}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AllTests.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AllTests.java
index 6f0319c88cf..5b00c8877b2 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AllTests.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AllTests.java
@@ -38,6 +38,7 @@ import org.junit.runners.Suite;
LaunchConfigurationAndRestartTest.class,
OperationsWhileTargetIsRunningTest.class,
PostMortemCoreTest.class,
+ CommandTimeoutTest.class,
Suite_Sessionless_Tests.class,
/* Add your suite class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandTimeoutTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandTimeoutTest.java
new file mode 100644
index 00000000000..065d6924c15
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandTimeoutTest.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests;
+
+import junit.framework.Assert;
+
+import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.debug.core.DebugException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest extends BaseTestCase {
+
+ private static boolean fgTimeoutEnabled = false;
+ private static int fgTimeout = IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT;
+
+ @BeforeClass
+ public static void beforeClassMethod() {
+ // Save the original values of the timeout-related preferences
+ fgTimeoutEnabled = Platform.getPreferencesService().getBoolean(
+ GdbPlugin.PLUGIN_ID,
+ IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT,
+ false,
+ null );
+ fgTimeout = Platform.getPreferencesService().getInt(
+ GdbPlugin.PLUGIN_ID,
+ IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE,
+ IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT,
+ null );
+ }
+
+ @Before
+ @Override
+ public void baseBeforeMethod() throws Exception {
+ }
+
+ @After
+ @Override
+ public void baseAfterMethod() throws Exception {
+ // Restore the timeout preferences
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
+ node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, fgTimeoutEnabled );
+ node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, fgTimeout );
+ }
+
+ @Override
+ protected boolean reallyLaunchGDBServer() {
+ return false;
+ }
+
+ /**
+ * Enables the timeout support and sets the timeout value to minimal - 1.
+ * Launch is expected to timeout on the first gdb command.
+ */
+ @Test
+ public void firstCommandTimedOut() {
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
+ node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, true );
+ node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, 1 );
+
+ try {
+ performLaunchAndTerminate();
+ Assert.fail( "Launch is expected to fail" );
+ }
+ catch( Exception e ) {
+ processException( e );
+ }
+ }
+
+ /**
+ * Tries to connect to gdbserver without starting it.
+ * Launch is expected to timeout on "target-remote" command.
+ */
+ @Test
+ public void remoteConnectionTimedOut() {
+ if ( !isRemoteSession() )
+ return;
+
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
+ node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, true );
+ node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, 1000 );
+
+ try {
+ performLaunchAndTerminate();
+ Assert.fail( "Launch is expected to fail" );
+ }
+ catch( Exception e ) {
+ processException( e );
+ }
+ }
+
+ private void performLaunchAndTerminate() throws Exception {
+ super.baseBeforeMethod();
+ super.baseAfterMethod();
+ }
+
+ /**
+ * Checks whether the given exception is an instance of {@link CoreException}
+ * with the status code 20100 which indicates that a gdb command has been timed out.
+ */
+ private void processException( Exception e ) {
+ if ( e instanceof DebugException ) {
+ Throwable t = getExceptionCause( e );
+ Assert.assertTrue(
+ "Unexpected exception",
+ t instanceof CoreException && ((CoreException)t).getStatus().getCode() == 20100 );
+ }
+ else {
+ Assert.fail( "Unexpected exception type" );
+ }
+ }
+
+ private Throwable getExceptionCause(Throwable e) {
+ Throwable current = e;
+ while ( current instanceof CoreException ) {
+ Throwable t = ((CoreException)current).getCause();
+ if ( t == null )
+ break;
+ current = t;
+ }
+ return current;
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/CommandTimeoutTest_6_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/CommandTimeoutTest_6_6.java
new file mode 100644
index 00000000000..2f087862af3
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/CommandTimeoutTest_6_6.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
+
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
+import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest_6_6 extends CommandTimeoutTest {
+ @BeforeClass
+ public static void beforeClassMethod_6_6() {
+ setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java
index 987092d6b6b..f83b1204c91 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java
@@ -38,7 +38,8 @@ import org.junit.runners.Suite;
LaunchConfigurationAndRestartTest_6_6.class,
OperationsWhileTargetIsRunningTest_6_6.class,
PostMortemCoreTest_6_6.class,
- Suite_Sessionless_Tests.class
+ Suite_Sessionless_Tests.class,
+ CommandTimeoutTest_6_6.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java
index 19d259a4ff0..648d1c45677 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java
@@ -37,7 +37,8 @@ import org.junit.runners.Suite;
MIDisassemblyTest_6_6.class,
GDBProcessesTest_6_6.class,
OperationsWhileTargetIsRunningTest_6_6.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_6_6.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/CommandTimeoutTest_6_7.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/CommandTimeoutTest_6_7.java
new file mode 100644
index 00000000000..1ab85b63073
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/CommandTimeoutTest_6_7.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7;
+
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
+import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest_6_7 extends CommandTimeoutTest {
+ @BeforeClass
+ public static void beforeClassMethod_6_7() {
+ setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_7);
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java
index 3a58408147a..5b3bde605a5 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java
@@ -38,7 +38,8 @@ import org.junit.runners.Suite;
LaunchConfigurationAndRestartTest_6_7.class,
OperationsWhileTargetIsRunningTest_6_7.class,
PostMortemCoreTest_6_7.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_6_7.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java
index 504ca779574..9e5a278a1fe 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java
@@ -37,7 +37,8 @@ import org.junit.runners.Suite;
MIDisassemblyTest_6_7.class,
GDBProcessesTest_6_7.class,
OperationsWhileTargetIsRunningTest_6_7.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_6_7.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/CommandTimeoutTest_6_8.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/CommandTimeoutTest_6_8.java
new file mode 100644
index 00000000000..f8e57790df0
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/CommandTimeoutTest_6_8.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8;
+
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
+import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest_6_8 extends CommandTimeoutTest {
+ @BeforeClass
+ public static void beforeClassMethod_6_8() {
+ setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_8);
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java
index 6b2b75c984a..61f22592880 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java
@@ -38,7 +38,8 @@ import org.junit.runners.Suite;
LaunchConfigurationAndRestartTest_6_8.class,
OperationsWhileTargetIsRunningTest_6_8.class,
PostMortemCoreTest_6_8.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_6_8.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java
index 286ad3e06dc..b059d858228 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java
@@ -37,7 +37,8 @@ import org.junit.runners.Suite;
MIDisassemblyTest_6_8.class,
GDBProcessesTest_6_8.class,
OperationsWhileTargetIsRunningTest_6_8.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_6_8.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/CommandTimeoutTest_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/CommandTimeoutTest_7_0.java
new file mode 100644
index 00000000000..eb8c7759e0a
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/CommandTimeoutTest_7_0.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0;
+
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
+import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest_7_0 extends CommandTimeoutTest {
+ @BeforeClass
+ public static void beforeClassMethod_7_0() {
+ setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_0);
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java
index 176b45b84f4..68d0e6843f1 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
OperationsWhileTargetIsRunningTest_7_0.class,
OperationsWhileTargetIsRunningNonStopTest_7_0.class,
PostMortemCoreTest_7_0.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_0.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java
index 3869ccee90d..d267a011a74 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
GDBProcessesTest_7_0.class,
OperationsWhileTargetIsRunningTest_7_0.class,
OperationsWhileTargetIsRunningNonStopTest_7_0.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_0.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/CommandTimeoutTest_7_1.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/CommandTimeoutTest_7_1.java
new file mode 100644
index 00000000000..b3de8a12d57
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/CommandTimeoutTest_7_1.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1;
+
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
+import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest_7_1 extends CommandTimeoutTest {
+ @BeforeClass
+ public static void beforeClassMethod_7_1() {
+ setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_1);
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java
index c8717d34335..75b9b161c61 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
OperationsWhileTargetIsRunningTest_7_1.class,
OperationsWhileTargetIsRunningNonStopTest_7_1.class,
PostMortemCoreTest_7_1.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_1.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java
index ac73aa23356..980446d4e95 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
GDBProcessesTest_7_1.class,
OperationsWhileTargetIsRunningTest_7_1.class,
OperationsWhileTargetIsRunningNonStopTest_7_1.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_1.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/CommandTimeoutTest_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/CommandTimeoutTest_7_2.java
new file mode 100644
index 00000000000..6a88bcc8eea
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/CommandTimeoutTest_7_2.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2;
+
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
+import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest_7_2 extends CommandTimeoutTest {
+ @BeforeClass
+ public static void beforeClassMethod_7_2() {
+ setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java
index 45deeaa2853..800fe29a252 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
OperationsWhileTargetIsRunningTest_7_2.class,
OperationsWhileTargetIsRunningNonStopTest_7_2.class,
PostMortemCoreTest_7_2.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_2.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java
index 48269bfc10b..32f2a1e7b89 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
GDBProcessesTest_7_2.class,
OperationsWhileTargetIsRunningTest_7_2.class,
OperationsWhileTargetIsRunningNonStopTest_7_2.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_2.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/CommandTimeoutTest_7_3.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/CommandTimeoutTest_7_3.java
new file mode 100644
index 00000000000..624916380dc
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/CommandTimeoutTest_7_3.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3;
+
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
+import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest_7_3 extends CommandTimeoutTest {
+ @BeforeClass
+ public static void beforeClassMethod_7_3() {
+ setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_3);
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java
index 66843ec2753..65e39402046 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
OperationsWhileTargetIsRunningTest_7_3.class,
OperationsWhileTargetIsRunningNonStopTest_7_3.class,
PostMortemCoreTest_7_3.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_3.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java
index 5baac54dcf3..63e9e39e29a 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
GDBProcessesTest_7_3.class,
OperationsWhileTargetIsRunningTest_7_3.class,
OperationsWhileTargetIsRunningNonStopTest_7_3.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_3.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/CommandTimeoutTest_7_4.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/CommandTimeoutTest_7_4.java
new file mode 100644
index 00000000000..3974aa66159
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/CommandTimeoutTest_7_4.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Mentor Graphics and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mentor Graphics - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
+
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
+import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class CommandTimeoutTest_7_4 extends CommandTimeoutTest {
+ @BeforeClass
+ public static void beforeClassMethod_7_4() {
+ setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_4);
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java
index 7f84cf16bb1..d2c7ea43ec1 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java
@@ -40,7 +40,8 @@ import org.junit.runners.Suite;
OperationsWhileTargetIsRunningTest_7_4.class,
OperationsWhileTargetIsRunningNonStopTest_7_4.class,
PostMortemCoreTest_7_4.class,
- Suite_Sessionless_Tests.class
+ CommandTimeoutTest_7_4.class,
+ Suite_Sessionless_Tests.class,
/* Add your test class here */
})
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_Remote_7_4.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_Remote_7_4.java
index ce61ef09780..f76a836d040 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_Remote_7_4.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_Remote_7_4.java
@@ -40,6 +40,7 @@ import org.junit.runners.Suite;
GDBProcessesTest_7_4.class,
OperationsWhileTargetIsRunningTest_7_4.class,
OperationsWhileTargetIsRunningNonStopTest_7_4.class,
+ CommandTimeoutTest_7_4.class,
Suite_Sessionless_Tests.class
/* Add your test class here */
})