Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 361934 | Differences between
and this patch

Collapse All | Expand All

(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml (+9 lines)
Added Link Here
475
         </enablement>
475
         </enablement>
476
      </toggleTargetFactory>
476
      </toggleTargetFactory>
477
   </extension>
477
   </extension>
478
   <extension
479
         point="org.eclipse.debug.core.statusHandlers">
480
      <statusHandler
481
            class="org.eclipse.cdt.dsf.gdb.internal.ui.GdbStatusHandler"
482
            code="20001"
483
            id="org.eclipse.cdt.dsf.gdb.ui.statusHandler"
484
            plugin="org.eclipse.cdt.dsf.gdb">
485
      </statusHandler>
486
   </extension>
478
</plugin>
487
</plugin>
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbStatusHandler.java (+66 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.gdb.internal.ui;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.debug.core.IStatusHandler;
17
import org.eclipse.jface.dialogs.MessageDialog;
18
import org.eclipse.swt.widgets.Display;
19
import org.eclipse.swt.widgets.Shell;
20
21
public class GdbStatusHandler implements IStatusHandler {
22
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
25
	 */
26
	@Override
27
	public Object handleStatus( final IStatus status, Object source ) throws CoreException {
28
		Runnable runnable = null;
29
		if ( status.getSeverity() == IStatus.ERROR ) {
30
			runnable = new Runnable() {
31
				
32
				@Override
33
				public void run() {
34
					Shell parent = GdbUIPlugin.getActiveWorkbenchShell();
35
					if ( parent != null )
36
						MessageDialog.openError( parent, Messages.GdbStatusHandler_Error, status.getMessage() );
37
				}
38
			};
39
		}
40
		else if ( status.getSeverity() == IStatus.WARNING ) {
41
			runnable = new Runnable() {
42
				
43
				@Override
44
				public void run() {
45
					Shell parent = GdbUIPlugin.getActiveWorkbenchShell();
46
					if ( parent != null )
47
						MessageDialog.openWarning( parent, Messages.GdbStatusHandler_Warning, status.getMessage() );
48
				}
49
			};
50
		}
51
		else if ( status.getSeverity() == IStatus.INFO ) {
52
			runnable = new Runnable() {
53
				
54
				@Override
55
				public void run() {
56
					Shell parent = GdbUIPlugin.getActiveWorkbenchShell();
57
					if ( parent != null )
58
						MessageDialog.openInformation( parent, Messages.GdbStatusHandler_Information, status.getMessage() );
59
				}
60
			};
61
		}
62
		if ( runnable != null )
63
			Display.getDefault().asyncExec( runnable );
64
		return null;
65
	}
66
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java (+31 lines)
Lines 22-27 Link Here
22
import org.eclipse.debug.core.ILaunch;
22
import org.eclipse.debug.core.ILaunch;
23
import org.eclipse.jface.dialogs.ErrorDialog;
23
import org.eclipse.jface.dialogs.ErrorDialog;
24
import org.eclipse.jface.preference.IPreferenceStore;
24
import org.eclipse.jface.preference.IPreferenceStore;
25
import org.eclipse.jface.resource.ImageDescriptor;
26
import org.eclipse.jface.resource.ImageRegistry;
27
import org.eclipse.swt.graphics.Image;
25
import org.eclipse.swt.widgets.Shell;
28
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.ui.IWorkbenchPage;
29
import org.eclipse.ui.IWorkbenchPage;
27
import org.eclipse.ui.IWorkbenchWindow;
30
import org.eclipse.ui.IWorkbenchWindow;
Lines 227-230 Link Here
227
		}
230
		}
228
	}
231
	}
229
232
233
    /* (non-Javadoc)
234
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
235
	 */
236
	@Override
237
	protected void initializeImageRegistry( ImageRegistry reg ) {
238
		super.initializeImageRegistry( reg );
239
		declareImages( reg );
240
	}
241
242
	/**
243
     * Returns an image descriptor for the image file at the given
244
     * plug-in relative path
245
     *
246
     * @param path the path
247
     * @return the image descriptor
248
     */
249
    public static ImageDescriptor getImageDescriptor(String path) {
250
        return imageDescriptorFromPlugin(PLUGIN_ID, path);
251
    }
252
253
    public static Image getImage( String key ) {
254
    	return getDefault().getImageRegistry().get( key );
255
    }
256
257
    private void declareImages( ImageRegistry reg ) {
258
    	reg.put( IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS, 
259
    			getImageDescriptor( "icons/full/wizban/advtosettings_wiz.png" ) ); //$NON-NLS-1$
260
    }
230
}
261
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/IGdbUIConstants.java (+28 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.gdb.internal.ui;
13
14
/**
15
 * @noimplement This interface is not intended to be implemented by clients.
16
 * 
17
 * @since 4.1
18
 */
19
public interface IGdbUIConstants {
20
21
	/**
22
	 * Plug-in identifier (value <code>"org.eclipse.cdt.dsf.gdb.ui"</code>).
23
	 */
24
	public static final String PLUGIN_ID = GdbUIPlugin.PLUGIN_ID; 
25
	
26
	/**  image identifier. */
27
	public static final String IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS = PLUGIN_ID + ".imageAdvancedTimeoutSettings"; //$NON-NLS-1$
28
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.java (+31 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.gdb.internal.ui;
13
14
import org.eclipse.osgi.util.NLS;
15
16
public class Messages extends NLS {
17
	private static final String BUNDLE_NAME = "org.eclipse.cdt.dsf.gdb.internal.ui.Messages"; //$NON-NLS-1$
18
19
	public static String GdbStatusHandler_Error;
20
21
	public static String GdbStatusHandler_Information;
22
23
	public static String GdbStatusHandler_Warning;
24
	static {
25
		// initialize resource bundle
26
		NLS.initializeMessages( BUNDLE_NAME, Messages.class );
27
	}
28
29
	private Messages() {
30
	}
31
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.properties (+3 lines)
Added Link Here
1
GdbStatusHandler_Error=Error
2
GdbStatusHandler_Information=Information
3
GdbStatusHandler_Warning=Warning
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java (-10 / +515 lines)
Lines 13-37 Link Here
13
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
13
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
14
14
15
import java.io.File;
15
import java.io.File;
16
import java.util.LinkedList;
17
import java.util.List;
18
import java.util.Map;
19
import java.util.Set;
16
20
21
import org.eclipse.cdt.dsf.debug.internal.ui.preferences.IntegerWithBooleanFieldEditor;
17
import org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor;
22
import org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor;
18
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
23
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
19
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
24
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
20
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages;
25
import org.eclipse.cdt.dsf.gdb.internal.ui.IGdbUIConstants;
26
import org.eclipse.cdt.dsf.gdb.service.command.CustomTimeoutsMap;
27
import org.eclipse.jface.dialogs.IDialogConstants;
28
import org.eclipse.jface.dialogs.TitleAreaDialog;
21
import org.eclipse.jface.preference.BooleanFieldEditor;
29
import org.eclipse.jface.preference.BooleanFieldEditor;
22
import org.eclipse.jface.preference.FieldEditorPreferencePage;
30
import org.eclipse.jface.preference.FieldEditorPreferencePage;
23
import org.eclipse.jface.preference.IPreferenceStore;
31
import org.eclipse.jface.preference.IPreferenceStore;
24
import org.eclipse.jface.preference.IntegerFieldEditor;
32
import org.eclipse.jface.preference.IntegerFieldEditor;
25
import org.eclipse.jface.preference.StringFieldEditor;
33
import org.eclipse.jface.preference.StringFieldEditor;
34
import org.eclipse.jface.resource.JFaceResources;
35
import org.eclipse.jface.util.PropertyChangeEvent;
36
import org.eclipse.jface.viewers.CellEditor;
37
import org.eclipse.jface.viewers.ColumnLabelProvider;
38
import org.eclipse.jface.viewers.ColumnViewer;
39
import org.eclipse.jface.viewers.DoubleClickEvent;
40
import org.eclipse.jface.viewers.EditingSupport;
41
import org.eclipse.jface.viewers.ICellEditorListener;
42
import org.eclipse.jface.viewers.ICellEditorValidator;
43
import org.eclipse.jface.viewers.IDoubleClickListener;
44
import org.eclipse.jface.viewers.ISelectionChangedListener;
45
import org.eclipse.jface.viewers.IStructuredContentProvider;
46
import org.eclipse.jface.viewers.IStructuredSelection;
47
import org.eclipse.jface.viewers.SelectionChangedEvent;
48
import org.eclipse.jface.viewers.StructuredSelection;
49
import org.eclipse.jface.viewers.TableViewer;
50
import org.eclipse.jface.viewers.TableViewerColumn;
51
import org.eclipse.jface.viewers.TextCellEditor;
52
import org.eclipse.jface.viewers.Viewer;
53
import org.eclipse.jface.window.Window;
26
import org.eclipse.swt.SWT;
54
import org.eclipse.swt.SWT;
55
import org.eclipse.swt.events.ControlAdapter;
56
import org.eclipse.swt.events.ControlEvent;
27
import org.eclipse.swt.events.SelectionAdapter;
57
import org.eclipse.swt.events.SelectionAdapter;
28
import org.eclipse.swt.events.SelectionEvent;
58
import org.eclipse.swt.events.SelectionEvent;
59
import org.eclipse.swt.graphics.Rectangle;
29
import org.eclipse.swt.layout.GridData;
60
import org.eclipse.swt.layout.GridData;
30
import org.eclipse.swt.layout.GridLayout;
61
import org.eclipse.swt.layout.GridLayout;
31
import org.eclipse.swt.widgets.Button;
62
import org.eclipse.swt.widgets.Button;
32
import org.eclipse.swt.widgets.Composite;
63
import org.eclipse.swt.widgets.Composite;
64
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.FileDialog;
65
import org.eclipse.swt.widgets.FileDialog;
34
import org.eclipse.swt.widgets.Group;
66
import org.eclipse.swt.widgets.Group;
67
import org.eclipse.swt.widgets.Shell;
68
import org.eclipse.swt.widgets.Table;
69
import org.eclipse.swt.widgets.TableColumn;
35
import org.eclipse.ui.IWorkbench;
70
import org.eclipse.ui.IWorkbench;
36
import org.eclipse.ui.IWorkbenchPreferencePage;
71
import org.eclipse.ui.IWorkbenchPreferencePage;
37
import org.eclipse.ui.PlatformUI;
72
import org.eclipse.ui.PlatformUI;
Lines 41-46 Link Here
41
 */
76
 */
42
@SuppressWarnings("restriction")
77
@SuppressWarnings("restriction")
43
public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
78
public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
79
	
44
	/**
80
	/**
45
	 * A vehicle in order to be able to register a selection listener with
81
	 * A vehicle in order to be able to register a selection listener with
46
	 * a {@link BooleanFieldEditor}.
82
	 * a {@link BooleanFieldEditor}.
Lines 58-68 Link Here
58
		}
94
		}
59
	}
95
	}
60
96
97
	class AdvancedTimeoutSettingsDialog extends TitleAreaDialog {
98
99
		class CommandTimeoutEntry {
100
			
101
			String fCommand;
102
			Integer fTimeout;
103
			
104
			CommandTimeoutEntry( String command, Integer timeout ) {
105
				fCommand = command;
106
				fTimeout = timeout;
107
			}
108
		}
109
110
		class CellEditorListener implements ICellEditorListener {
111
			
112
			CellEditor fEditor;
113
			
114
			public CellEditorListener( CellEditor editor ) {
115
				super();
116
				fEditor = editor;
117
			}
118
119
			@Override
120
			public void editorValueChanged( boolean oldValidState, boolean newValidState ) {
121
				if ( newValidState ) {
122
					setErrorMessage( null );
123
				}
124
				else {
125
					setErrorMessage( fEditor.getErrorMessage() );
126
				}
127
				updateDialogButtons();
128
			}
129
			
130
			@Override
131
			public void cancelEditor() {
132
			}
133
			
134
			@Override
135
			public void applyEditorValue() {
136
				validate();
137
				updateDialogButtons();
138
			}
139
		};
140
		
141
		abstract class AbstractEditingSupport extends EditingSupport {
142
143
			public AbstractEditingSupport( ColumnViewer viewer ) {
144
				super( viewer );
145
			}
146
147
			@Override
148
			protected void setValue( Object element, Object value ) {
149
				if ( element instanceof CommandTimeoutEntry && value instanceof String ) {
150
					if ( processValue( (CommandTimeoutEntry)element, (String)value ) ) {
151
						fViewer.refresh( element );
152
						validate();
153
						updateDialogButtons();
154
					}
155
				}
156
			}
157
			
158
			@Override
159
			protected Object getValue( Object element ) {
160
				if ( element instanceof CommandTimeoutEntry ) {
161
					return doGetValue( (CommandTimeoutEntry)element );
162
				}
163
				return null;
164
			}
165
			
166
			@Override
167
			protected CellEditor getCellEditor( Object element ) {
168
				final CellEditor editor = new TextCellEditor( (Composite)getViewer().getControl() );
169
				editor.setValidator( getValidator() );
170
				editor.addListener( new CellEditorListener( editor ) );
171
				return editor;
172
			}
173
			
174
			@Override
175
			protected boolean canEdit( Object element ) {
176
				return ( element instanceof CommandTimeoutEntry );
177
			}
178
			
179
			abstract boolean processValue( CommandTimeoutEntry entry, String value );
180
181
			abstract Object doGetValue( CommandTimeoutEntry entry );
182
183
			abstract ICellEditorValidator getValidator();
184
		};
185
186
		private TableViewer fViewer;
187
		private Button fAddButton;
188
		private Button fDeleteButton;
189
		
190
		private List<CommandTimeoutEntry> fEntries;
191
		
192
		final private ICellEditorValidator fCommandValidator = new ICellEditorValidator() {
193
			
194
			@Override
195
			public String isValid( Object value ) {
196
				if ( value instanceof String && ((String)value).trim().length() == 0 ) {
197
					return MessagesForPreferences.GdbDebugPreferencePage_Command_field_can_not_be_empty;
198
				}
199
				return null;
200
			}
201
		};
202
203
		final private ICellEditorValidator fTimeoutValidator = new ICellEditorValidator() {
204
			
205
			@Override
206
			public String isValid( Object value ) {
207
				if ( value instanceof String ) {
208
					try {
209
						int intValue = Integer.decode( (String)value ).intValue();
210
						if ( intValue < 0 )
211
							return MessagesForPreferences.GdbDebugPreferencePage_Timeout_value_can_not_be_negative;
212
					}
213
					catch( NumberFormatException e ) {
214
						return MessagesForPreferences.GdbDebugPreferencePage_Invalid_timeout_value;
215
					}
216
				}
217
				return null;
218
			}
219
		};
220
221
		AdvancedTimeoutSettingsDialog( Shell parentShell, Set<Map.Entry<String, Integer>> entries ) {
222
			super( parentShell );
223
			setShellStyle(getShellStyle() | SWT.RESIZE);
224
			fEntries = new LinkedList<CommandTimeoutEntry>();
225
			for ( Map.Entry<String, Integer> entry : entries ) {
226
				fEntries.add( new CommandTimeoutEntry( entry.getKey(), entry.getValue() ) );
227
			}
228
		}
229
230
		/* (non-Javadoc)
231
		 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
232
		 */
233
		@Override
234
		protected Control createDialogArea( Composite parent ) {
235
			getShell().setText( MessagesForPreferences.GdbDebugPreferencePage_Anvanced_Timeout_Settings ); 
236
			setTitle( MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_title ); 
237
			setTitleImage( GdbUIPlugin.getImage( IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS ) );
238
			setMessage( MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_message );
239
240
			Composite control = (Composite)super.createDialogArea( parent );
241
			Composite comp = new Composite( control, SWT.NONE );
242
			GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
243
			comp.setLayout( new GridLayout( 2, false ) );
244
			comp.setLayoutData( gd );
245
			
246
			fViewer = new TableViewer( comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
247
			final Table table = fViewer.getTable();
248
			gd = new GridData( SWT.FILL, SWT.FILL, true, true );
249
			table.setLayoutData( gd );
250
251
			fViewer.addDoubleClickListener( new IDoubleClickListener() {
252
				@Override
253
				public void doubleClick( DoubleClickEvent event ) {
254
					okPressed();
255
				}
256
			} );
257
258
			fViewer.addSelectionChangedListener( new ISelectionChangedListener() {
259
				
260
				@Override
261
				public void selectionChanged( SelectionChangedEvent event ) {
262
					updateDialogButtons();
263
				}
264
			} );
265
266
			Composite btnComp = new Composite( comp, SWT.NONE );
267
			btnComp.setLayout( new GridLayout() );
268
			btnComp.setLayoutData( new GridData( SWT.RIGHT, SWT.TOP, false, false ) );
269
			
270
			fAddButton = new Button( btnComp, SWT.PUSH );
271
			fAddButton.setText( MessagesForPreferences.GdbDebugPreferencePage_Add_button );
272
			fAddButton.setFont( JFaceResources.getDialogFont() );
273
			setButtonLayoutData( fAddButton );
274
			fAddButton.addSelectionListener( new SelectionAdapter() {
275
276
				@Override
277
				public void widgetSelected( SelectionEvent e ) {
278
					addNewEntry();
279
				}
280
			} );
281
			
282
			fDeleteButton = new Button( btnComp, SWT.PUSH );
283
			fDeleteButton.setText( MessagesForPreferences.GdbDebugPreferencePage_Delete_button );
284
			fDeleteButton.setFont( JFaceResources.getDialogFont() );
285
			setButtonLayoutData( fDeleteButton );
286
			fDeleteButton.addSelectionListener( new SelectionAdapter() {
287
288
				@Override
289
				public void widgetSelected( SelectionEvent e ) {
290
					deleteEntries();
291
				}
292
			} );
293
294
			table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
295
			table.setHeaderVisible( true );
296
			table.setLinesVisible( true );
297
			
298
			TableViewerColumn commandColumn = new TableViewerColumn( fViewer, SWT.LEFT );
299
			commandColumn.getColumn().setText( MessagesForPreferences.GdbDebugPreferencePage_Command_column_name );
300
			commandColumn.setLabelProvider( createCommandLabelProvider() );
301
			commandColumn.setEditingSupport( createCommandEditingSupport( fViewer ) );
302
303
			TableViewerColumn timeoutColumn = new TableViewerColumn( fViewer, SWT.LEFT );
304
			timeoutColumn.getColumn().setText( MessagesForPreferences.GdbDebugPreferencePage_Timeout_column_name );
305
			timeoutColumn.setLabelProvider( createTimeoutLabelProvider() );
306
			timeoutColumn.setEditingSupport( createTimeoutEditingSupport( fViewer ) );
307
308
			fViewer.setContentProvider( createCustomTimeoutsContentProvider() );
309
			
310
			table.addControlListener( new ControlAdapter() {
311
				
312
				@Override
313
				public void controlResized( ControlEvent e ) {
314
					Rectangle area = table.getClientArea();
315
					if ( area.width > 0 ) {
316
						TableColumn[] cols = table.getColumns();
317
						cols[0].setWidth( area.width * 50 / 100 );
318
						cols[1].setWidth( area.width * 50 / 100 );
319
						table.removeControlListener( this );
320
					}
321
				}
322
			} );
323
324
			fViewer.setInput( fEntries );
325
326
			updateDialogButtons();
327
328
			return control;
329
		}
330
331
		void updateDialogButtons() {
332
			if ( fViewer != null && fDeleteButton != null ) {
333
				fDeleteButton.setEnabled( !fViewer.getSelection().isEmpty() );
334
			}
335
			Button okButton = getButton( IDialogConstants.OK_ID );
336
			if ( okButton != null )
337
				okButton.setEnabled( getErrorMessage() == null );
338
		}
339
340
		void addNewEntry() {
341
			CommandTimeoutEntry newEntry = new CommandTimeoutEntry( "", Integer.valueOf( 0 ) ); //$NON-NLS-1$
342
			fEntries.add( newEntry );
343
			fViewer.refresh();
344
			fViewer.setSelection( new StructuredSelection( newEntry ) );
345
			validateEntry( newEntry );
346
			updateDialogButtons();
347
			fViewer.editElement( newEntry, 0 );
348
		}
349
350
		void deleteEntries() {
351
			IStructuredSelection sel = (IStructuredSelection)fViewer.getSelection();
352
			if ( !sel.isEmpty() )
353
				fEntries.removeAll( sel.toList() );
354
			fViewer.refresh();
355
			validate();
356
			updateDialogButtons();
357
		}
358
359
		CustomTimeoutsMap getResult() {
360
			CustomTimeoutsMap map = new CustomTimeoutsMap();
361
			for ( CommandTimeoutEntry entry : fEntries ) {
362
				map.put( entry.fCommand, entry.fTimeout );
363
			}
364
			return map;
365
		}
366
367
		void validate() {
368
			for ( CommandTimeoutEntry entry : fEntries ) {
369
				validateEntry( entry );
370
			}
371
		}
372
373
		void validateEntry( CommandTimeoutEntry entry ) {
374
			String errorMessage = fCommandValidator.isValid( entry.fCommand );
375
			setErrorMessage( ( errorMessage != null ) ? 
376
					errorMessage : fTimeoutValidator.isValid( entry.fTimeout.toString() ) );
377
		}
378
379
		IStructuredContentProvider createCustomTimeoutsContentProvider() {
380
			return new IStructuredContentProvider() {
381
				
382
				@Override
383
				public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
384
				}
385
				
386
				@Override
387
				public void dispose() {
388
				}
389
				
390
				@Override
391
				public Object[] getElements( Object inputElement ) {
392
					if ( inputElement instanceof List<?> ) {
393
						@SuppressWarnings( "unchecked" )
394
						List<CommandTimeoutEntry> list = (List<CommandTimeoutEntry>)inputElement;
395
						return list.toArray( new Object[list.size()] );
396
					}
397
					return null;
398
				}
399
			};
400
		}
401
402
		ColumnLabelProvider createCommandLabelProvider() {
403
			return new ColumnLabelProvider() {
404
405
				/* (non-Javadoc)
406
				 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
407
				 */
408
				@Override
409
				public String getText( Object element ) {
410
					if ( element instanceof CommandTimeoutEntry ) {
411
						return ((CommandTimeoutEntry)element).fCommand;
412
					}
413
					return super.getText( element );
414
				}
415
			};
416
		}
417
418
		ColumnLabelProvider createTimeoutLabelProvider() {
419
			return new ColumnLabelProvider() {
420
421
				/* (non-Javadoc)
422
				 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
423
				 */
424
				@Override
425
				public String getText( Object element ) {
426
					if ( element instanceof CommandTimeoutEntry ) {
427
						return ((CommandTimeoutEntry)element).fTimeout.toString();
428
					}
429
					return super.getText( element );
430
				}
431
			};
432
		}
433
434
		EditingSupport createCommandEditingSupport( ColumnViewer viewer ) {
435
			return new AbstractEditingSupport( viewer ) {
436
				
437
				@Override
438
				boolean processValue( CommandTimeoutEntry entry, String value ) {
439
					entry.fCommand = value;
440
					return true;
441
				}
442
443
				@Override
444
				Object doGetValue( CommandTimeoutEntry entry ) {
445
					return entry.fCommand;
446
				}
447
448
				@Override
449
				ICellEditorValidator getValidator() {
450
					return fCommandValidator;
451
				}
452
			};
453
		}
454
455
		EditingSupport createTimeoutEditingSupport( ColumnViewer viewer ) {
456
			return new AbstractEditingSupport( viewer ) {
457
458
				@Override
459
				boolean processValue( CommandTimeoutEntry entry, String value ) {
460
					try {
461
						entry.fTimeout = Integer.decode( value );
462
						return true;
463
					}
464
					catch( NumberFormatException e ) {
465
						// Shouldn't happen, validator takes care of this case.
466
					}
467
					return false;
468
				}
469
470
				@Override
471
				Object doGetValue( CommandTimeoutEntry entry ) {
472
					return entry.fTimeout.toString();
473
				}
474
475
				@Override
476
				ICellEditorValidator getValidator() {
477
					return fTimeoutValidator;
478
				}
479
			};
480
		}
481
	}
482
483
	private IntegerWithBooleanFieldEditor fCommandTimeoutField;
484
	private Button fTimeoutAdvancedButton;
485
486
	private CustomTimeoutsMap fCustomTimeouts;
487
	
61
	public GdbDebugPreferencePage() {
488
	public GdbDebugPreferencePage() {
62
		super(FLAT);
489
		super(FLAT);
63
		IPreferenceStore store= GdbUIPlugin.getDefault().getPreferenceStore();
490
		IPreferenceStore store= GdbUIPlugin.getDefault().getPreferenceStore();
64
		setPreferenceStore(store);
491
		setPreferenceStore(store);
65
		setDescription(MessagesForPreferences.GdbDebugPreferencePage_description);
492
		setDescription(MessagesForPreferences.GdbDebugPreferencePage_description);
493
		fCustomTimeouts = new CustomTimeoutsMap();
66
	}
494
	}
67
495
68
    @Override
496
    @Override
Lines 70-77 Link Here
70
	}
498
	}
71
499
72
	@Override
500
	@Override
501
	protected void initialize() {
502
		super.initialize();
503
		initializeCustomTimeouts();
504
	}
505
506
	@Override
73
	public void createControl(Composite parent) {
507
	public void createControl(Composite parent) {
74
		super.createControl(parent);
508
		super.createControl(parent);
509
		updateTimeoutButtons();
75
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
510
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
76
				GdbUIPlugin.PLUGIN_ID + ".dsfgdb_preference_page"); //$NON-NLS-1$
511
				GdbUIPlugin.PLUGIN_ID + ".dsfgdb_preference_page"); //$NON-NLS-1$
77
	}
512
	}
Lines 91-134 Link Here
91
526
92
		final StringFieldEditor stringFieldEditorCommand = new StringFieldEditor(
527
		final StringFieldEditor stringFieldEditorCommand = new StringFieldEditor(
93
				IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
528
				IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
94
				LaunchUIMessages.getString("GDBDebuggerPage.gdb_debugger"), //$NON-NLS-1$
529
				"GDB debugger:", //$NON-NLS-1$
95
				group1);
530
				group1);
96
531
97
		stringFieldEditorCommand.fillIntoGrid(group1, 2);
532
		stringFieldEditorCommand.fillIntoGrid(group1, 2);
98
		addField(stringFieldEditorCommand);
533
		addField(stringFieldEditorCommand);
99
		Button browsebutton = new Button(group1, SWT.PUSH);
534
		Button browsebutton = new Button(group1, SWT.PUSH);
100
		browsebutton.setText(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse")); //$NON-NLS-1$
535
		browsebutton.setText("&Browse..."); //$NON-NLS-1$
101
		browsebutton.addSelectionListener(new SelectionAdapter() {
536
		browsebutton.addSelectionListener(new SelectionAdapter() {
102
			@Override
537
			@Override
103
			public void widgetSelected(SelectionEvent e) {
538
			public void widgetSelected(SelectionEvent e) {
104
				handleBrowseButtonSelected(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse_dlg_title"),  //$NON-NLS-1$
539
				handleBrowseButtonSelected("GDB Debugger",  //$NON-NLS-1$
105
						stringFieldEditorCommand);
540
						stringFieldEditorCommand);
106
			}
541
			}
107
		});
542
		});
543
		setButtonLayoutData( browsebutton );
108
544
109
		final StringFieldEditor stringFieldEditorGdbInit = new StringFieldEditor(
545
		final StringFieldEditor stringFieldEditorGdbInit = new StringFieldEditor(
110
				IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT,
546
				IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT,
111
				LaunchUIMessages.getString("GDBDebuggerPage.gdb_command_file"), //$NON-NLS-1$
547
				"GDB command file:", //$NON-NLS-1$
112
				group1);
548
				group1);
113
549
114
		stringFieldEditorGdbInit.fillIntoGrid(group1, 2);
550
		stringFieldEditorGdbInit.fillIntoGrid(group1, 2);
115
		addField(stringFieldEditorGdbInit);
551
		addField(stringFieldEditorGdbInit);
116
		browsebutton = new Button(group1, SWT.PUSH);
552
		browsebutton = new Button(group1, SWT.PUSH);
117
		browsebutton.setText(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse")); //$NON-NLS-1$
553
		browsebutton.setText("&Browse..."); //$NON-NLS-1$
118
		browsebutton.addSelectionListener(new SelectionAdapter() {
554
		browsebutton.addSelectionListener(new SelectionAdapter() {
119
			@Override
555
			@Override
120
			public void widgetSelected(SelectionEvent e) {
556
			public void widgetSelected(SelectionEvent e) {
121
				handleBrowseButtonSelected(LaunchUIMessages.getString("GDBDebuggerPage.gdb_cmdfile_dlg_title"), //$NON-NLS-1$
557
				handleBrowseButtonSelected("GDB Command File", //$NON-NLS-1$
122
						stringFieldEditorGdbInit);
558
						stringFieldEditorGdbInit);
123
			}
559
			}
124
		});
560
		});
561
		setButtonLayoutData( browsebutton );
125
562
126
		final StringWithBooleanFieldEditor enableStopAtMain = new StringWithBooleanFieldEditor(
563
		final StringWithBooleanFieldEditor enableStopAtMain = new StringWithBooleanFieldEditor(
127
				IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN,
564
				IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN,
128
				IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
565
				IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
129
				LaunchUIMessages.getString("CDebuggerTab.Stop_at_main_on_startup"), //$NON-NLS-1$
566
				"Stop on startup at:", //$NON-NLS-1$
130
				group1);
567
				group1);
131
		enableStopAtMain.fillIntoGrid(group1, 2);
568
		enableStopAtMain.fillIntoGrid(group1, 3);
132
		addField(enableStopAtMain);
569
		addField(enableStopAtMain);
133
570
134
//		final StringFieldEditor stopAtMainSymbol = new StringFieldEditor(
571
//		final StringFieldEditor stopAtMainSymbol = new StringFieldEditor(
Lines 145-153 Link Here
145
//			}
582
//			}
146
//		});
583
//		});
147
584
585
		fCommandTimeoutField = new IntegerWithBooleanFieldEditor( 
586
				IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, 
587
				IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, 
588
				MessagesForPreferences.GdbDebugPreferencePage_Command_timeout,
589
				group1);
590
		fCommandTimeoutField.setValidRange(0, Integer.MAX_VALUE);
591
		fCommandTimeoutField.fillIntoGrid(group1, 2);
592
		addField(fCommandTimeoutField);
593
		
594
		fTimeoutAdvancedButton = new Button(group1, SWT.PUSH);
595
		fTimeoutAdvancedButton.setText(MessagesForPreferences.GdbDebugPreferencePage_Advanced_button);
596
		fTimeoutAdvancedButton.addSelectionListener(new SelectionAdapter() {
597
			@Override
598
			public void widgetSelected(SelectionEvent e) {
599
				handleAdvancedButtonSelected(
600
						"GDB Debugger");  //$NON-NLS-1$
601
			}
602
		});
603
		setButtonLayoutData( fTimeoutAdvancedButton );
604
148
		final ListenableBooleanFieldEditor enableNonStop= new ListenableBooleanFieldEditor(
605
		final ListenableBooleanFieldEditor enableNonStop= new ListenableBooleanFieldEditor(
149
				IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP,
606
				IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP,
150
				LaunchUIMessages.getString("GDBDebuggerPage.nonstop_mode"), //$NON-NLS-1$
607
				"Non-stop mode (Note: Requires non-stop GDB)", //$NON-NLS-1$
151
				SWT.NONE, group1);
608
				SWT.NONE, group1);
152
		enableNonStop.fillIntoGrid(group1, 3);
609
		enableNonStop.fillIntoGrid(group1, 3);
153
		addField(enableNonStop);
610
		addField(enableNonStop);
Lines 286-293 Link Here
286
		stringFieldEditor.setStringValue(res);
743
		stringFieldEditor.setStringValue(res);
287
	}
744
	}
288
745
746
	private void handleAdvancedButtonSelected(String dialogTitle) {
747
		AdvancedTimeoutSettingsDialog dialog = 
748
			new AdvancedTimeoutSettingsDialog( getShell(), fCustomTimeouts.entrySet() );
749
		if ( dialog.open() == Window.OK ) {
750
			fCustomTimeouts = dialog.getResult();
751
		}
752
	}
753
289
	@Override
754
	@Override
290
	protected void adjustGridLayout() {
755
	protected void adjustGridLayout() {
291
		// do nothing
756
		// do nothing
292
	}
757
	}
758
759
	@Override
760
	public void propertyChange( PropertyChangeEvent event ) {
761
		if ( event.getSource().equals( fCommandTimeoutField ) && event.getNewValue() instanceof Boolean ) {
762
			fTimeoutAdvancedButton.setEnabled( ((Boolean)event.getNewValue()).booleanValue() );
763
		}
764
		super.propertyChange( event );
765
	}
766
767
	@Override
768
	protected void performDefaults() {
769
		IPreferenceStore store = getPreferenceStore();
770
		if ( store != null ) {
771
			String memento = store.getDefaultString( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS );
772
			fCustomTimeouts.initializeFromMemento( memento );
773
		}
774
		super.performDefaults();
775
		updateTimeoutButtons();
776
	}
777
778
	/* (non-Javadoc)
779
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
780
	 */
781
	@Override
782
	public boolean performOk() {
783
		getPreferenceStore().setValue( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS, fCustomTimeouts.getMemento() );
784
		return super.performOk();
785
	}
786
787
	private void updateTimeoutButtons() {
788
		fTimeoutAdvancedButton.setEnabled( fCommandTimeoutField.getBooleanValue() );
789
	}
790
791
	private void initializeCustomTimeouts() {
792
		IPreferenceStore store = getPreferenceStore();
793
		if ( store != null ) {
794
			String memento = store.getString( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS );
795
			fCustomTimeouts.initializeFromMemento( memento );
796
		}
797
	}
293
}
798
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java (+12 lines)
Lines 17-22 Link Here
17
 * Preference strings.
17
 * Preference strings.
18
 */
18
 */
19
class MessagesForPreferences extends NLS {
19
class MessagesForPreferences extends NLS {
20
	public static String GdbDebugPreferencePage_Add_button;
21
	public static String GdbDebugPreferencePage_Advanced_button;
22
	public static String GdbDebugPreferencePage_Advanced_timeout_dialog_message;
23
	public static String GdbDebugPreferencePage_Advanced_timeout_dialog_title;
24
	public static String GdbDebugPreferencePage_Anvanced_Timeout_Settings;
20
	public static String GdbDebugPreferencePage_description;
25
	public static String GdbDebugPreferencePage_description;
21
	public static String GdbDebugPreferencePage_traces_label;
26
	public static String GdbDebugPreferencePage_traces_label;
22
	public static String GdbDebugPreferencePage_enableTraces_label;
27
	public static String GdbDebugPreferencePage_enableTraces_label;
Lines 24-29 Link Here
24
	public static String GdbDebugPreferencePage_maxGdbTraces_label;
29
	public static String GdbDebugPreferencePage_maxGdbTraces_label;
25
	public static String GdbDebugPreferencePage_termination_label;
30
	public static String GdbDebugPreferencePage_termination_label;
26
	public static String GdbDebugPreferencePage_autoTerminateGdb_label;
31
	public static String GdbDebugPreferencePage_autoTerminateGdb_label;
32
	public static String GdbDebugPreferencePage_Command_column_name;
33
	public static String GdbDebugPreferencePage_Command_field_can_not_be_empty;
34
	public static String GdbDebugPreferencePage_Command_timeout;
27
	public static String GdbDebugPreferencePage_hover_label;
35
	public static String GdbDebugPreferencePage_hover_label;
28
	public static String GdbDebugPreferencePage_useInspectorHover_label;
36
	public static String GdbDebugPreferencePage_useInspectorHover_label;
29
	/** @since 2.2 */
37
	/** @since 2.2 */
Lines 36-41 Link Here
36
	public static String GdbDebugPreferencePage_initialChildCountLimitForCollections_label;
44
	public static String GdbDebugPreferencePage_initialChildCountLimitForCollections_label;
37
	/** @since 2.2 */
45
	/** @since 2.2 */
38
	public static String GdbDebugPreferencePage_defaults_label;
46
	public static String GdbDebugPreferencePage_defaults_label;
47
	public static String GdbDebugPreferencePage_Delete_button;
48
	public static String GdbDebugPreferencePage_Invalid_timeout_value;
49
	public static String GdbDebugPreferencePage_Timeout_column_name;
50
	public static String GdbDebugPreferencePage_Timeout_value_can_not_be_negative;
39
	static {
51
	static {
40
		// initialize resource bundle
52
		// initialize resource bundle
41
		NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class);
53
		NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class);
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties (+13 lines)
Lines 10-15 Link Here
10
#   Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
10
#   Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
11
###############################################################################
11
###############################################################################
12
12
13
GdbDebugPreferencePage_Add_button=Add
13
GdbDebugPreferencePage_description=General settings for GDB Debugging
14
GdbDebugPreferencePage_description=General settings for GDB Debugging
14
15
15
GdbDebugPreferencePage_traces_label=Traces
16
GdbDebugPreferencePage_traces_label=Traces
Lines 17-22 Link Here
17
GdbDebugPreferencePage_maxGdbTraces_label=Limit GDB traces output (number of characters):
18
GdbDebugPreferencePage_maxGdbTraces_label=Limit GDB traces output (number of characters):
18
GdbDebugPreferencePage_termination_label=Termination
19
GdbDebugPreferencePage_termination_label=Termination
19
GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
20
GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
21
GdbDebugPreferencePage_Command_column_name=GDB/MI Command
22
GdbDebugPreferencePage_Command_field_can_not_be_empty='Command' field can not be empty
23
GdbDebugPreferencePage_Command_timeout=Command timeout (ms):
20
24
21
GdbDebugPreferencePage_hover_label=Debug Text Hover
25
GdbDebugPreferencePage_hover_label=Debug Text Hover
22
GdbDebugPreferencePage_useInspectorHover_label=Use enhanced debug hover
26
GdbDebugPreferencePage_useInspectorHover_label=Use enhanced debug hover
Lines 27-29 Link Here
27
GdbDebugPreferencePage_initialChildCountLimitForCollections_label=For collections, initially limit child count to
31
GdbDebugPreferencePage_initialChildCountLimitForCollections_label=For collections, initially limit child count to
28
32
29
GdbDebugPreferencePage_defaults_label=Debug Configurations Defaults
33
GdbDebugPreferencePage_defaults_label=Debug Configurations Defaults
34
GdbDebugPreferencePage_Delete_button=Delete
35
GdbDebugPreferencePage_Invalid_timeout_value=Invalid timeout value
36
GdbDebugPreferencePage_Timeout_column_name=Timeout(ms)
37
GdbDebugPreferencePage_Timeout_value_can_not_be_negative=Timeout value can not be negative
38
39
GdbDebugPreferencePage_Advanced_button=&Advanced...
40
GdbDebugPreferencePage_Advanced_timeout_dialog_message=Specify commands and corresponding timeout values, '0' for 'no timeout'.\nThe default value will be used for all commands that are not mentioned here.
41
GdbDebugPreferencePage_Advanced_timeout_dialog_title=Add/delete/modify custom timeouts for GDB/MI commands
42
GdbDebugPreferencePage_Anvanced_Timeout_Settings=Advanced Timeout Settings
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/.options (+1 lines)
Line 1 Link Here
1
org.eclipse.cdt.dsf.gdb/debug = false
1
org.eclipse.cdt.dsf.gdb/debug = false
2
org.eclipse.cdt.dsf.gdb/debug/timeouts = false
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugConstants.java (-2 / +6 lines)
Lines 16-22 Link Here
16
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
16
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
17
17
18
18
19
20
/**
19
/**
21
 * @noimplement This interface is not intended to be implemented by clients.
20
 * @noimplement This interface is not intended to be implemented by clients.
22
 * @since 4.0
21
 * @since 4.0
Lines 24-29 Link Here
24
public interface IGdbDebugConstants {
23
public interface IGdbDebugConstants {
25
	
24
	
26
    public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
25
    public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
26
27
	/**
28
	 * Status code for which a UI handler is registered.
29
	 * @since 4.1
30
	 */
31
	public static final int STATUS_HANDLER_CODE = 20001;
27
32
28
    /**
33
    /**
29
     * Attribute key to be added to the IProcess associated with an IMIContainerDMContext.
34
     * Attribute key to be added to the IProcess associated with an IMIContainerDMContext.
Lines 54-59 Link Here
54
     */
59
     */
55
    public static final String GDB_PROCESS_CREATION_VALUE = PREFIX + "gdbProcess"; //$NON-NLS-1$
60
    public static final String GDB_PROCESS_CREATION_VALUE = PREFIX + "gdbProcess"; //$NON-NLS-1$
56
    
61
    
57
58
}
62
}
59
63
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java (+24 lines)
Lines 87-92 Link Here
87
	public static final String PREF_DEFAULT_NON_STOP = "defaultNonStop"; //$NON-NLS-1$
87
	public static final String PREF_DEFAULT_NON_STOP = "defaultNonStop"; //$NON-NLS-1$
88
88
89
	/**
89
	/**
90
	 * The value is an boolean specifying whether the timeout is used for GDB commands.
91
	 * @since 4.1
92
	 */
93
	public static final String PREF_COMMAND_TIMEOUT = "commandTimeout"; //$NON-NLS-1$
94
95
	/**
96
	 * The value is an integer specifying the timeout value (milliseconds) for GDB commands.
97
	 * @since 4.1
98
	 */
99
	public static final String PREF_COMMAND_TIMEOUT_VALUE = "commandTimeoutValue"; //$NON-NLS-1$
100
101
	/**
102
	 * The value is a string specifying the list of GDB/MI commands with custom timeout values.
103
	 * @since 4.1
104
	 */
105
	public static final String PREF_COMMAND_CUSTOM_TIMEOUTS = "commandTimeoutSpecials"; //$NON-NLS-1$
106
107
	/**
108
	 * Default default value for <code>PREF_COMMAND_TIMEOUT</code>;
109
	 * @since 4.1
110
	 */
111
	public static final int COMMAND_TIMEOUT_VALUE_DEFAULT = 10000;
112
113
	/**
90
     * Help prefixes.
114
     * Help prefixes.
91
     */
115
     */
92
    public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
116
    public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java (+2 lines)
Lines 38-42 Link Here
38
		node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT);
38
		node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT);
39
		node.put(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
39
		node.put(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
40
		node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
40
		node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
41
		node.putBoolean(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, false);
42
		node.putInt(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT);
41
	}
43
	}
42
}
44
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/Messages.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.gdb.internal;
13
14
import org.eclipse.osgi.util.NLS;
15
16
public class Messages extends NLS {
17
	private static final String BUNDLE_NAME = "org.eclipse.cdt.dsf.gdb.internal.Messages"; //$NON-NLS-1$
18
19
	public static String CustomTimeoutsMap_Error_initializing_custom_timeouts;
20
21
	public static String CustomTimeoutsMap_Invalid_custom_timeout_data;
22
23
	public static String CustomTimeoutsMap_Invalid_custom_timeout_value;
24
25
	public static String GDBControl_Session_is_terminated;
26
	static {
27
		// initialize resource bundle
28
		NLS.initializeMessages( BUNDLE_NAME, Messages.class );
29
	}
30
31
	private Messages() {
32
	}
33
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/Messages.properties (+15 lines)
Added Link Here
1
#######################################################################################
2
# Copyright (c) 2011 Mentor Graphics and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
# Mentor Graphics - Initial API and implementation
10
#######################################################################################
11
12
CustomTimeoutsMap_Error_initializing_custom_timeouts=Error initializing custom timeouts
13
CustomTimeoutsMap_Invalid_custom_timeout_data=Invalid custom timeout data.
14
CustomTimeoutsMap_Invalid_custom_timeout_value=Invalid custom timeout value for '%s'.
15
GDBControl_Session_is_terminated=Session is terminated.\nReason: %s
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/CustomTimeoutsMap.java (+79 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.gdb.service.command;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
import java.util.StringTokenizer;
17
18
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
19
import org.eclipse.cdt.dsf.gdb.internal.Messages;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.MultiStatus;
22
import org.eclipse.core.runtime.Status;
23
24
/**
25
 * @since 4.1
26
 */
27
public class CustomTimeoutsMap extends HashMap<String, Integer> {
28
29
	public CustomTimeoutsMap() {
30
		super();
31
	}
32
33
	public CustomTimeoutsMap( CustomTimeoutsMap map ) {
34
		super( map );
35
	}
36
37
	private static final long serialVersionUID = -8281280275781904870L;
38
39
	public String getMemento() {
40
		StringBuilder sb = new StringBuilder();
41
		for ( Map.Entry<String, Integer> entry : entrySet() ) {
42
			sb.append( entry.getKey() );
43
			sb.append( ',' );
44
			sb.append( entry.getValue().intValue() );
45
			sb.append( ';' );
46
		}
47
		return sb.toString();
48
	}
49
	
50
	public void initializeFromMemento( String memento ) {
51
		clear();
52
		StringTokenizer st = new StringTokenizer( memento, ";" ); //$NON-NLS-1$
53
		MultiStatus ms = new MultiStatus( GdbPlugin.PLUGIN_ID, 0, Messages.CustomTimeoutsMap_Error_initializing_custom_timeouts, null );
54
		while( st.hasMoreTokens() ) {
55
			String token = st.nextToken();
56
			String[] tokenParts = token.split( "," ); //$NON-NLS-1$
57
			if ( tokenParts.length == 2 && tokenParts[0].length() > 0 && tokenParts[0].length() > 0 ) {
58
				try {
59
					put( tokenParts[0], Integer.valueOf( tokenParts[1] ) );
60
				}
61
				catch( NumberFormatException e ) {
62
					ms.add( new Status(
63
							IStatus.ERROR, 
64
							GdbPlugin.PLUGIN_ID, 
65
							String.format( Messages.CustomTimeoutsMap_Invalid_custom_timeout_value, tokenParts[0] ) ) );
66
				}
67
			}
68
			else {
69
				ms.add( new Status(
70
						IStatus.ERROR, 
71
						GdbPlugin.PLUGIN_ID, 
72
						Messages.CustomTimeoutsMap_Invalid_custom_timeout_data ) );
73
			}
74
		}
75
		if ( !ms.isOK() ) {
76
			GdbPlugin.getDefault().getLog().log( ms );
77
		}
78
	}
79
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java (+105 lines)
Lines 43-52 Link Here
43
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
43
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
44
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
44
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
45
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
45
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
46
import org.eclipse.cdt.dsf.debug.service.command.ICommandToken;
47
import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants;
46
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
48
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
49
import org.eclipse.cdt.dsf.gdb.internal.Messages;
47
import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence;
50
import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence;
48
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
51
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
49
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses;
52
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses;
53
import org.eclipse.cdt.dsf.gdb.service.command.GdbCommandTimeoutManager.ICommandTimeoutListener;
50
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
54
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
51
import org.eclipse.cdt.dsf.mi.service.IMIBackend.BackendStateChangedEvent;
55
import org.eclipse.cdt.dsf.mi.service.IMIBackend.BackendStateChangedEvent;
52
import org.eclipse.cdt.dsf.mi.service.IMIBackend2;
56
import org.eclipse.cdt.dsf.mi.service.IMIBackend2;
Lines 69-76 Link Here
69
import org.eclipse.core.runtime.IStatus;
73
import org.eclipse.core.runtime.IStatus;
70
import org.eclipse.core.runtime.NullProgressMonitor;
74
import org.eclipse.core.runtime.NullProgressMonitor;
71
import org.eclipse.core.runtime.Status;
75
import org.eclipse.core.runtime.Status;
76
import org.eclipse.debug.core.DebugPlugin;
72
import org.eclipse.debug.core.ILaunch;
77
import org.eclipse.debug.core.ILaunch;
73
import org.eclipse.debug.core.ILaunchConfiguration;
78
import org.eclipse.debug.core.ILaunchConfiguration;
79
import org.eclipse.debug.core.IStatusHandler;
74
import org.osgi.framework.BundleContext;
80
import org.osgi.framework.BundleContext;
75
81
76
/**
82
/**
Lines 81-86 Link Here
81
 * - inferior process status tracking.<br>
87
 * - inferior process status tracking.<br>
82
 */
88
 */
83
public class GDBControl extends AbstractMIControl implements IGDBControl {
89
public class GDBControl extends AbstractMIControl implements IGDBControl {
90
91
	private static final int STATUS_CODE_COMMAND_TIMED_OUT = 20100;
84
92
85
    /**
93
    /**
86
     * Event indicating that the back end process has started.
94
     * Event indicating that the back end process has started.
Lines 104-109 Link Here
104
        }
112
        }
105
    }
113
    }
106
114
115
	private class TimeoutListener implements ICommandTimeoutListener {
116
117
		@Override
118
		public void commandTimedOut( ICommandToken token ) {
119
			GDBControl.this.commandTimedOut(token);
120
		}		
121
	}
122
107
    private GDBControlDMContext fControlDmc;
123
    private GDBControlDMContext fControlDmc;
108
124
109
    private IGDBBackend fMIBackend;
125
    private IGDBBackend fMIBackend;
Lines 111-116 Link Here
111
    private IEventProcessor fMIEventProcessor;
127
    private IEventProcessor fMIEventProcessor;
112
    private IEventProcessor fCLICommandProcessor;
128
    private IEventProcessor fCLICommandProcessor;
113
    private AbstractCLIProcess fCLIProcess;
129
    private AbstractCLIProcess fCLIProcess;
130
131
    private GdbCommandTimeoutManager fCommandTimeoutManager;
132
133
    private ICommandTimeoutListener fTimeoutListener = new TimeoutListener();
114
134
115
    /**
135
    /**
116
     * GDBControl is only used for GDB earlier that 7.0. Although -list-features
136
     * GDBControl is only used for GDB earlier that 7.0. Although -list-features
Lines 120-125 Link Here
120
	private final List<String> fFeatures = new ArrayList<String>();
140
	private final List<String> fFeatures = new ArrayList<String>();
121
141
122
	private Sequence fInitializationSequence;
142
	private Sequence fInitializationSequence;
143
	
144
	private boolean fInitialized = false;
123
145
124
    private boolean fTerminated;
146
    private boolean fTerminated;
125
147
Lines 308-313 Link Here
308
			@Override
330
			@Override
309
			protected void handleCompleted() {
331
			protected void handleCompleted() {
310
				fInitializationSequence = null;
332
				fInitializationSequence = null;
333
				fInitialized = true;
311
				if (!isCanceled()) {
334
				if (!isCanceled()) {
312
					// Only set the status if the user has not cancelled the operation already.
335
					// Only set the status if the user has not cancelled the operation already.
313
					rm.setStatus(getStatus());
336
					rm.setStatus(getStatus());
Lines 440-445 Link Here
440
        }
463
        }
441
    }
464
    }
442
    
465
    
466
    /**
467
	 * @since 4.1
468
	 */
469
    protected class CommandTimeoutStep extends InitializationShutdownStep {
470
		CommandTimeoutStep( Direction direction ) {
471
			super( direction );
472
		}
473
474
		@Override
475
		public void initialize( final RequestMonitor requestMonitor ) {
476
			fCommandTimeoutManager = createCommandTimeoutManager( GDBControl.this );
477
			if (fCommandTimeoutManager != null) {
478
				fCommandTimeoutManager.addCommandTimeoutListener(fTimeoutListener);
479
			}
480
			requestMonitor.done();
481
		}
482
483
		@Override
484
		protected void shutdown( RequestMonitor requestMonitor ) {
485
			if ( fCommandTimeoutManager != null ) {
486
				fCommandTimeoutManager.removeCommandTimeoutListener(fTimeoutListener);
487
				fCommandTimeoutManager.dispose();
488
			}
489
			requestMonitor.done();
490
		}
491
	}
492
443
    protected class RegisterStep extends InitializationShutdownStep {
493
    protected class RegisterStep extends InitializationShutdownStep {
444
        RegisterStep(Direction direction) { super(direction); }
494
        RegisterStep(Direction direction) { super(direction); }
445
        @Override
495
        @Override
Lines 493-498 Link Here
493
        final Sequence.Step[] initializeSteps = new Sequence.Step[] {
543
        final Sequence.Step[] initializeSteps = new Sequence.Step[] {
494
                new CommandMonitoringStep(InitializationShutdownStep.Direction.INITIALIZING),
544
                new CommandMonitoringStep(InitializationShutdownStep.Direction.INITIALIZING),
495
                new CommandProcessorsStep(InitializationShutdownStep.Direction.INITIALIZING),
545
                new CommandProcessorsStep(InitializationShutdownStep.Direction.INITIALIZING),
546
                new CommandTimeoutStep(InitializationShutdownStep.Direction.INITIALIZING),
496
                new RegisterStep(InitializationShutdownStep.Direction.INITIALIZING),
547
                new RegisterStep(InitializationShutdownStep.Direction.INITIALIZING),
497
            };
548
            };
498
549
Lines 507-512 Link Here
507
	protected Sequence getShutdownSequence(RequestMonitor requestMonitor) {
558
	protected Sequence getShutdownSequence(RequestMonitor requestMonitor) {
508
        final Sequence.Step[] shutdownSteps = new Sequence.Step[] {
559
        final Sequence.Step[] shutdownSteps = new Sequence.Step[] {
509
                new RegisterStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
560
                new RegisterStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
561
                new CommandTimeoutStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
510
                new CommandProcessorsStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
562
                new CommandProcessorsStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
511
                new CommandMonitoringStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
563
                new CommandMonitoringStep(InitializationShutdownStep.Direction.SHUTTING_DOWN),
512
            };
564
            };
Lines 536-539 Link Here
536
		fFeatures.clear();
588
		fFeatures.clear();
537
		fFeatures.addAll(features);
589
		fFeatures.addAll(features);
538
	}
590
	}
591
	
592
	/**
593
	 * @since 4.1
594
	 */
595
	protected GdbCommandTimeoutManager createCommandTimeoutManager(IGDBControl commandControl) {
596
		GdbCommandTimeoutManager manager = new GdbCommandTimeoutManager(commandControl);
597
		manager.initialize();
598
		return manager;
599
	}
600
601
	void commandTimedOut(ICommandToken token) {
602
		String commandText = token.getCommand().toString();
603
		if (commandText.endsWith("\n")) //$NON-NLS-1$
604
			commandText = commandText.substring(0, commandText.length() - 1);
605
		final String errorMessage = String.format("Command '%s' is timed out", commandText); //$NON-NLS-1$
606
		commandFailed(token, STATUS_CODE_COMMAND_TIMED_OUT, errorMessage);
607
		
608
		// If the timeout occurs while the launch sequence is running 
609
		// the error will be reported by the launcher's error reporting mechanism.
610
		// We need to show the error message only when the session is initialized.
611
		if (fInitializationSequence == null && fInitialized) {
612
			getExecutor().execute(new DsfRunnable() {
613
			
614
				@Override
615
				public void run() {
616
					terminate(new RequestMonitor(getExecutor(), null) {
617
						
618
						@Override
619
						protected void handleErrorOrWarning() {
620
							GdbPlugin.getDefault().getLog().log(getStatus());
621
							super.handleErrorOrWarning();
622
						};
623
					} );
624
	
625
					IStatus status = new Status( 
626
							IStatus.ERROR, 
627
							GdbPlugin.PLUGIN_ID, 
628
							IGdbDebugConstants.STATUS_HANDLER_CODE, 
629
							String.format( Messages.GDBControl_Session_is_terminated, errorMessage ), 
630
							null);
631
					IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(status);
632
					if (statusHandler != null) {
633
						try {
634
							statusHandler.handleStatus(status, null);
635
						}
636
						catch(CoreException e) {
637
							GdbPlugin.getDefault().getLog().log(e.getStatus());
638
						}
639
					}
640
				}
641
			} );
642
		}	
643
	}
539
}
644
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java (+2 lines)
Lines 147-152 Link Here
147
        final Sequence.Step[] initializeSteps = new Sequence.Step[] {
147
        final Sequence.Step[] initializeSteps = new Sequence.Step[] {
148
                new GDBControl.CommandMonitoringStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
148
                new GDBControl.CommandMonitoringStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
149
                new GDBControl.CommandProcessorsStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
149
                new GDBControl.CommandProcessorsStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
150
                new CommandTimeoutStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
150
                new ListFeaturesStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
151
                new ListFeaturesStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
151
                new GDBControl.RegisterStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
152
                new GDBControl.RegisterStep(GDBControl.InitializationShutdownStep.Direction.INITIALIZING),
152
            };
153
            };
Lines 161-166 Link Here
161
        final Sequence.Step[] shutdownSteps = new Sequence.Step[] {
162
        final Sequence.Step[] shutdownSteps = new Sequence.Step[] {
162
                new GDBControl.RegisterStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
163
                new GDBControl.RegisterStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
163
                new ListFeaturesStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
164
                new ListFeaturesStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
165
                new CommandTimeoutStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
164
                new GDBControl.CommandProcessorsStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
166
                new GDBControl.CommandProcessorsStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
165
                new GDBControl.CommandMonitoringStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
167
                new GDBControl.CommandMonitoringStep(GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN),
166
            };
168
            };
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GdbCommandTimeoutManager.java (+447 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.gdb.service.command;
13
14
import java.util.concurrent.BlockingQueue;
15
import java.util.concurrent.LinkedBlockingQueue;
16
17
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
18
import org.eclipse.cdt.dsf.debug.service.command.ICommandListener;
19
import org.eclipse.cdt.dsf.debug.service.command.ICommandResult;
20
import org.eclipse.cdt.dsf.debug.service.command.ICommandToken;
21
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
22
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
23
import org.eclipse.cdt.dsf.mi.service.command.AbstractMIControl;
24
import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand;
25
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
26
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.ListenerList;
28
import org.eclipse.core.runtime.Platform;
29
import org.eclipse.core.runtime.Status;
30
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
31
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
32
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
33
import org.eclipse.core.runtime.preferences.InstanceScope;
34
35
/**
36
 * The command timeout manager registers itself as a command listener and monitors 
37
 * the command execution time. The goal of this implementation is to gracefully 
38
 * handle disruptions in the communication between Eclipse and GDB. 
39
 * 
40
 * The algorithm used by this class is based on the assumption that the command 
41
 * execution in GDB is sequential even though DSF can send up to 3 commands at 
42
 * a time to GDB (see {@link AbstractMIControl}).
43
 *  
44
 * @since 4.1
45
 */
46
public class GdbCommandTimeoutManager implements ICommandListener, IPreferenceChangeListener {
47
48
	public interface ICommandTimeoutListener {
49
		
50
		void commandTimedOut( ICommandToken token );
51
	}
52
53
	public final static boolean DEBUG = "true".equals( Platform.getDebugOption( "org.eclipse.cdt.dsf.gdb/debug/timeouts" ) ); //$NON-NLS-1$//$NON-NLS-2$
54
	
55
	class QueueEntry {
56
		long fTimestamp;
57
		ICommandToken fCommandToken;
58
		
59
		QueueEntry( long timestamp, ICommandToken commandToken ) {
60
			super();
61
			fTimestamp = timestamp;
62
			fCommandToken = commandToken;
63
		}
64
65
		/* (non-Javadoc)
66
		 * @see java.lang.Object#equals(java.lang.Object)
67
		 */
68
		@Override
69
		public boolean equals( Object obj ) {
70
			if ( obj instanceof QueueEntry ) {
71
				return fCommandToken.equals( ((QueueEntry)obj).fCommandToken );
72
			}
73
			return false;
74
		}
75
	}
76
77
	enum TimerThreadState {
78
		INITIALIZING,
79
		RUNNING,
80
		HALTED,
81
		SHUTDOWN
82
	}
83
84
	class TimerThread extends Thread {
85
86
		private BlockingQueue<QueueEntry> fQueue;
87
		private int fWaitTimeout = IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT;
88
		private TimerThreadState fState = TimerThreadState.INITIALIZING;
89
90
		TimerThread( BlockingQueue<QueueEntry> queue, int timeout ) {
91
			super();
92
			fQueue = queue;
93
			setWaitTimout( timeout );
94
		}
95
96
		/* (non-Javadoc)
97
		 * @see java.lang.Thread#run()
98
		 */
99
		@Override
100
		public void run() {
101
			setState( ( getWaitTimeout() > 0 ) ? 
102
					TimerThreadState.RUNNING : TimerThreadState.HALTED );
103
			doRun();
104
		}
105
106
		private void doRun() {
107
			if ( fState == TimerThreadState.HALTED ) {
108
				halted();
109
			}
110
			else {
111
				running();
112
			}
113
		}
114
115
		private void halted() {
116
			try {
117
				synchronized( TimerThread.this ) {
118
					wait();
119
				}
120
			}
121
			catch( InterruptedException e ) {
122
				doRun();
123
			}
124
		}
125
126
		private void running() {
127
			try {
128
				while( fState == TimerThreadState.RUNNING ) {
129
					long timeout = getWaitTimeout();
130
					QueueEntry entry = fQueue.peek();
131
					if ( entry != null ) {
132
						// Calculate the time elapsed since the execution of this command started 
133
						// and compare it with the command's timeout value.
134
						// If the elapsed time is greater or equal than the timeout value the command 
135
						// is marked as timed out. Otherwise, schedule the next check when the timeout 
136
						// expires.
137
						long commandTimeout = getTimeoutForCommand( entry.fCommandToken.getCommand() );
138
						
139
						if ( DEBUG ) {
140
							String commandText = entry.fCommandToken.getCommand().toString();
141
							if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
142
								commandText = commandText.substring( 0, commandText.length() - 1 );
143
							printDebugMessage( String.format( "Processing command '%s', command timeout is %d", //$NON-NLS-1$ 
144
									commandText, Long.valueOf( commandTimeout ) ) );
145
						}
146
147
						long currentTime = System.currentTimeMillis();
148
						long elapsedTime = currentTime - entry.fTimestamp;
149
						if ( commandTimeout <= elapsedTime ) {
150
							processTimedOutCommand( entry.fCommandToken );
151
							fQueue.remove( entry );
152
							// Reset the timestamp of the next command in the queue because 
153
							// regardless how long the command has been in the queue GDB will 
154
							// start executing it only when the previous command is . 
155
							QueueEntry nextEntry = fQueue.peek();
156
							if ( nextEntry != null ) {
157
								setTimeStamp( currentTime, nextEntry );
158
							}
159
						}
160
						else {
161
							timeout = Math.min( timeout, commandTimeout - elapsedTime );
162
						
163
							if ( DEBUG ) {
164
								String commandText = entry.fCommandToken.getCommand().toString();
165
								if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
166
									commandText = commandText.substring( 0, commandText.length() - 1 );
167
								printDebugMessage( String.format( "Setting timeout %d for command '%s'", Long.valueOf( timeout ), commandText ) ); //$NON-NLS-1$
168
							}
169
						}
170
					}
171
					synchronized( TimerThread.this ) {
172
						wait( timeout );
173
					}
174
					if ( isInterrupted() ) {
175
						doRun();
176
					}
177
				}
178
			}
179
			catch( InterruptedException e ) {
180
				doRun();
181
			}
182
		}
183
184
		void shutdown() {
185
			setState( TimerThreadState.SHUTDOWN );
186
			interrupt();
187
		}
188
		
189
		void haltProcessing() {
190
			setState( TimerThreadState.HALTED );
191
			interrupt();
192
		}
193
		
194
		void resumeProcessing() {
195
			setState( TimerThreadState.RUNNING );
196
			interrupt();
197
		}
198
		
199
		void setWaitTimout( int waitTimeout ) {
200
			fWaitTimeout = waitTimeout;
201
			if ( DEBUG )
202
				printDebugMessage( String.format( "Wait timeout is set to %d", Integer.valueOf( fWaitTimeout ) ) ); //$NON-NLS-1$
203
		}
204
		
205
		int getWaitTimeout() {
206
			return fWaitTimeout;
207
		}
208
		
209
		void setState( TimerThreadState state ) {
210
			fState = state;
211
		}
212
	}
213
214
	private static final String TIMEOUT_TRACE_IDENTIFIER = "[TMO]"; //$NON-NLS-1$
215
216
	private IGDBControl fCommandControl;
217
	private boolean fTimeoutEnabled = false;
218
	private int fTimeout = 0;
219
	private TimerThread fTimerThread;
220
	private BlockingQueue<QueueEntry> fCommandQueue = new LinkedBlockingQueue<QueueEntry>();
221
	private CustomTimeoutsMap fCustomTimeouts = new CustomTimeoutsMap();
222
223
	private ListenerList fListeners;
224
	
225
	public GdbCommandTimeoutManager( IGDBControl commandControl ) {
226
		fCommandControl = commandControl;
227
		fListeners = new ListenerList();
228
	}
229
230
	public void initialize() {
231
		IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
232
233
		fTimeoutEnabled = Platform.getPreferencesService().getBoolean( 
234
				GdbPlugin.PLUGIN_ID,
235
				IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, 
236
				false,
237
				null );
238
239
		fTimeout = Platform.getPreferencesService().getInt( 
240
				GdbPlugin.PLUGIN_ID,
241
				IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, 
242
				IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT,
243
				null );
244
		
245
		fCustomTimeouts.initializeFromMemento( Platform.getPreferencesService().getString( 
246
				GdbPlugin.PLUGIN_ID,
247
				IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS, 
248
				"", //$NON-NLS-1$
249
				null ) );
250
		
251
		node.addPreferenceChangeListener( this );
252
		
253
		fCommandControl.addCommandListener( this );
254
		
255
		fTimerThread = new TimerThread( fCommandQueue, calculateWaitTimeout() );
256
		fTimerThread.start();
257
	}
258
259
	public void dispose() {
260
		fTimerThread.shutdown();
261
		fListeners.clear();
262
		InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID ).removePreferenceChangeListener( this );
263
		fCommandControl.removeCommandListener( this );
264
		fCommandQueue.clear();
265
		fCustomTimeouts.clear();
266
	}
267
268
	/* (non-Javadoc)
269
	 * @see org.eclipse.cdt.dsf.debug.service.command.ICommandListener#commandQueued(org.eclipse.cdt.dsf.debug.service.command.ICommandToken)
270
	 */
271
	@Override
272
	public void commandQueued( ICommandToken token ) {
273
	}
274
275
	/* (non-Javadoc)
276
	 * @see org.eclipse.cdt.dsf.debug.service.command.ICommandListener#commandSent(org.eclipse.cdt.dsf.debug.service.command.ICommandToken)
277
	 */
278
	@Override
279
	public void commandSent( ICommandToken token ) {
280
		if ( !isTimeoutEnabled() )
281
			return;
282
		int commandTimeout = getTimeoutForCommand( token.getCommand() );
283
		if ( DEBUG ) {
284
			String commandText = token.getCommand().toString();
285
			if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
286
				commandText = commandText.substring( 0, commandText.length() - 1 );
287
			printDebugMessage( String.format( "Command '%s' sent, timeout = %d", commandText, Integer.valueOf( commandTimeout ) ) ); //$NON-NLS-1$
288
		}
289
		if ( commandTimeout == 0 )
290
			// Skip commands with no timeout 
291
			return;
292
		try {
293
			fCommandQueue.put( new QueueEntry( System.currentTimeMillis(), token ) );
294
		}
295
		catch( InterruptedException e ) {
296
			// ignore
297
		}
298
	}
299
300
	/* (non-Javadoc)
301
	 * @see org.eclipse.cdt.dsf.debug.service.command.ICommandListener#commandRemoved(org.eclipse.cdt.dsf.debug.service.command.ICommandToken)
302
	 */
303
	@Override
304
	public void commandRemoved( ICommandToken token ) {
305
		if ( !isTimeoutEnabled() )
306
			return;
307
		removeCommand( token, false );
308
	}
309
310
	/* (non-Javadoc)
311
	 * @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)
312
	 */
313
	@Override
314
	public void commandDone( ICommandToken token, ICommandResult result ) {
315
		if ( !isTimeoutEnabled() )
316
			return;
317
		removeCommand( token, true );
318
	}
319
320
	/* (non-Javadoc)
321
	 * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
322
	 */
323
	@Override
324
	public void preferenceChange( PreferenceChangeEvent event ) {
325
		String property = event.getKey();
326
		if ( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT.equals( property ) ) {
327
			if ( event.getNewValue() == null || !event.getNewValue().equals( event.getOldValue() ) ) {
328
				fTimeoutEnabled = Boolean.parseBoolean( event.getNewValue().toString() );
329
				updateWaitTimeout();
330
				fTimerThread.setState( ( fTimerThread.getWaitTimeout() > 0 ) ? 
331
						TimerThreadState.RUNNING : TimerThreadState.HALTED );
332
				fTimerThread.interrupt();
333
			}
334
		}
335
		else if ( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE.equals( property ) ) {
336
			if ( !event.getNewValue().equals( event.getOldValue() ) ) {
337
				try {
338
					fTimeout = Integer.parseInt( event.getNewValue().toString() );
339
					updateWaitTimeout();
340
					fTimerThread.setState( ( fTimerThread.getWaitTimeout() > 0 ) ? 
341
							TimerThreadState.RUNNING : TimerThreadState.HALTED );
342
					fTimerThread.interrupt();
343
				}
344
				catch( NumberFormatException e ) {
345
					GdbPlugin.getDefault().getLog().log( new Status( IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Invlaid timeout value" ) ); //$NON-NLS-1$
346
				}
347
			}
348
		}
349
		else if ( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS.equals( property ) ) {
350
			if ( event.getNewValue() instanceof String ) {
351
				fCustomTimeouts.initializeFromMemento( (String)event.getNewValue() );
352
			}
353
			else if ( event.getNewValue() == null ) {
354
				fCustomTimeouts.clear();
355
			}
356
			updateWaitTimeout();
357
			fTimerThread.setState( ( fTimerThread.getWaitTimeout() > 0 ) ? 
358
					TimerThreadState.RUNNING : TimerThreadState.HALTED );
359
			fTimerThread.interrupt();
360
		}
361
	}
362
363
	protected int getTimeoutForCommand( ICommand<? extends ICommandResult> command ) {
364
		if ( !(command instanceof MICommand<?>) )
365
			return 0;
366
		@SuppressWarnings( "unchecked" )
367
		Integer timeout = fCustomTimeouts.get( ((MICommand<? extends MIInfo>)command).getOperation() );
368
		return ( timeout != null ) ? timeout.intValue() : fTimeout;
369
	}
370
371
	protected void processTimedOutCommand( ICommandToken token ) {
372
		if ( DEBUG ) {
373
			String commandText = token.getCommand().toString();
374
			if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
375
				commandText = commandText.substring( 0, commandText.length() - 1 );
376
			printDebugMessage( String.format( "Command '%s' is timed out", commandText ) ); //$NON-NLS-1$
377
		}
378
		for ( Object l : fListeners.getListeners() ) {
379
			((ICommandTimeoutListener)l).commandTimedOut( token );
380
		}
381
	}
382
383
	public void addCommandTimeoutListener( ICommandTimeoutListener listener ) {
384
		fListeners.add( listener );
385
	}
386
387
	public void removeCommandTimeoutListener( ICommandTimeoutListener listener ) {
388
		fListeners.remove( listener );
389
	}
390
	
391
	private void updateWaitTimeout() {
392
		fTimerThread.setWaitTimout( calculateWaitTimeout() );
393
	}
394
395
	private boolean isTimeoutEnabled() {
396
		return fTimeoutEnabled;
397
	}
398
399
	private void printDebugMessage( String message ) {
400
		System.out.println( String.format( "%s %s  %s", GdbPlugin.getDebugTime(), TIMEOUT_TRACE_IDENTIFIER, message ) ); //$NON-NLS-1$		
401
	}
402
403
	private int calculateWaitTimeout() {
404
		int waitTimeout = 0;
405
		if ( isTimeoutEnabled() ) {
406
			waitTimeout = fTimeout;
407
			for ( Integer t : fCustomTimeouts.values() ) {
408
				if ( t.intValue() > 0 ) {
409
					waitTimeout = Math.min( waitTimeout, t.intValue() );
410
				}
411
			}
412
		}
413
		return waitTimeout;
414
	}
415
416
	private void removeCommand( ICommandToken token, boolean done ) {
417
		fCommandQueue.remove( new QueueEntry( 0, token ) );
418
		if ( DEBUG ) {
419
			String commandText = token.getCommand().toString();
420
			if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
421
				commandText = commandText.substring( 0, commandText.length() - 1 );
422
			String message = ( done ) ? 
423
					String.format( "Command '%s' is done", commandText ) : //$NON-NLS-1$
424
					String.format( "Command '%s' removed", commandText ); //$NON-NLS-1$
425
			printDebugMessage( message );
426
		}
427
		// Reset the timestamp of the next command in the queue because 
428
		// regardless how long it has been in the queue GDB started executing 
429
		QueueEntry nextEntry = fCommandQueue.peek();
430
		if ( nextEntry != null ) {
431
			setTimeStamp( System.currentTimeMillis(), nextEntry );
432
		}
433
	}
434
435
	private void setTimeStamp( long currentTime, QueueEntry nextEntry ) {
436
		if ( nextEntry != null ) {
437
			nextEntry.fTimestamp = currentTime;
438
			
439
			if ( DEBUG ) {
440
				String commandText = nextEntry.fCommandToken.getCommand().toString();
441
				if ( commandText.endsWith( "\n" ) ) //$NON-NLS-1$
442
					commandText = commandText.substring( 0, commandText.length() - 1 );
443
				printDebugMessage( String.format( "Setting the timestamp for command '%s' to %d", commandText, Long.valueOf( currentTime ) ) ); //$NON-NLS-1$
444
			}
445
		}
446
	}
447
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java (-1 / +69 lines)
Lines 874-879 Link Here
874
        }
874
        }
875
875
876
        void processMIOutput(String line) {
876
        void processMIOutput(String line) {
877
877
            MIParser.RecordType recordType = fMiParser.getRecordType(line);
878
            MIParser.RecordType recordType = fMiParser.getRecordType(line);
878
            
879
            
879
            if (recordType == MIParser.RecordType.ResultRecord) {
880
            if (recordType == MIParser.RecordType.ResultRecord) {
Lines 885-891 Link Here
885
            	 *  some form of asynchronous notification. Or perhaps general IO.
886
            	 *  some form of asynchronous notification. Or perhaps general IO.
886
            	 */
887
            	 */
887
                int id = rr.getToken();
888
                int id = rr.getToken();
888
                final CommandHandle commandHandle = fRxCommands.remove(id);
889
                
890
                final CommandHandle commandHandle; 
891
                synchronized(fRxCommands) {
892
					commandHandle = fRxCommands.remove(id);
893
				}
894
                
889
895
890
                if (commandHandle != null) {
896
                if (commandHandle != null) {
891
                    final MIOutput response = new MIOutput(
897
                    final MIOutput response = new MIOutput(
Lines 1098-1101 Link Here
1098
    	fCurrentStackLevel = -1; 
1104
    	fCurrentStackLevel = -1; 
1099
    }
1105
    }
1100
1106
1107
    /**
1108
	 * @since 4.1
1109
	 */
1110
    protected void commandFailed(ICommandToken token, int statusCode, String errorMessage) {
1111
    	if ( !(token instanceof CommandHandle && token.getCommand() instanceof MICommand<?>) )
1112
    		return;
1113
		final CommandHandle commandHandle = (CommandHandle)token;
1114
		Integer tokenId = commandHandle.getTokenId();
1115
1116
		// If the timeout value is too small a command can be timed out but still processed by RxThread.
1117
		// To avoid processing it twice we need to remove it from the command list.
1118
		synchronized(fRxCommands) {
1119
			CommandHandle h = fRxCommands.remove(tokenId);
1120
			if (h == null)
1121
				// Command has already been processed by RxThread.
1122
				return;
1123
		}
1124
		
1125
		MIConst value = new MIConst();
1126
		value.setCString(errorMessage);
1127
		MIResult result = new MIResult();
1128
		result.setVariable("msg"); //$NON-NLS-1$
1129
		result.setMIValue(value);
1130
		MIResultRecord resultRecord = new MIResultRecord();
1131
		resultRecord.setToken(tokenId.intValue());
1132
		resultRecord.setResultClass(MIResultRecord.ERROR);
1133
		resultRecord.setMIResults(new MIResult[] { result });
1134
		MIOutput miOutput = new MIOutput(resultRecord, new MIOOBRecord[0]);
1135
1136
		final MIInfo info = commandHandle.getCommand().getResult(miOutput);
1137
		DataRequestMonitor<MIInfo> rm = commandHandle.getRequestMonitor();
1138
		
1139
		if ( rm != null ) {
1140
			rm.setData(info);			
1141
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, statusCode, errorMessage, null)); 
1142
			
1143
			/*
1144
			 *  We need to complete the command on the DSF thread for data security.
1145
			 */
1146
			getExecutor().execute(new DsfRunnable() {
1147
                @Override
1148
				public void run() {
1149
                	/*
1150
                	 *  Complete the specific command.
1151
                	 */
1152
                    if (commandHandle.getRequestMonitor() != null) {
1153
                        commandHandle.getRequestMonitor().done();
1154
                    }
1155
                    
1156
                    /*
1157
                     *  Now tell the generic listeners about it.
1158
                     */
1159
                    processCommandDone(commandHandle, info);
1160
                }
1161
1162
                @Override
1163
                public String toString() {
1164
                    return "MI command output received for: " + commandHandle.getCommand(); //$NON-NLS-1$
1165
                }
1166
            });
1167
		}
1168
    }
1101
}
1169
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java (-1 / +16 lines)
Lines 91-96 Link Here
91
    	launchAttributes.put(key, value);
91
    	launchAttributes.put(key, value);
92
    }
92
    }
93
93
94
    public static void removeLaunchAttribute(String key) { 
95
    	launchAttributes.remove(key);
96
    }
97
94
    public static void setGlobalLaunchAttribute(String key, Object value) {
98
    public static void setGlobalLaunchAttribute(String key, Object value) {
95
    	globalLaunchAttributes.put(key, value);
99
    	globalLaunchAttributes.put(key, value);
96
    }
100
    }
Lines 206-212 Link Here
206
	                                               .equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
210
	                                               .equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
207
 		
211
 		
208
 		// First check if we should launch gdbserver in the case of a remote session
212
 		// First check if we should launch gdbserver in the case of a remote session
209
		launchGdbServer();
213
 		if (reallyLaunchGDBServer())
214
 			launchGdbServer();
210
		
215
		
211
 		ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager();
216
 		ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager();
212
 		ILaunchConfigurationType lcType = launchMgr.getLaunchConfigurationType("org.eclipse.cdt.tests.dsf.gdb.TestLaunch");
217
 		ILaunchConfigurationType lcType = launchMgr.getLaunchConfigurationType("org.eclipse.cdt.tests.dsf.gdb.TestLaunch");
Lines 332-335 Link Here
332
 		BaseTestCase.setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : ""));
337
 		BaseTestCase.setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : ""));
333
 		BaseTestCase.setLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : ""));
338
 		BaseTestCase.setLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : ""));
334
 	}
339
 	}
340
341
 	/**
342
 	 * In some tests we need to start a gdbserver session without starting gdbserver. 
343
 	 * This method allows super classes of this class control the launch of gdbserver.
344
 	 * 
345
 	 * @return whether gdbserver should be started
346
 	 */
347
 	protected boolean reallyLaunchGDBServer() {
348
 		return true;
349
 	}
335
}
350
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AllTests.java (+1 lines)
Lines 38-43 Link Here
38
	LaunchConfigurationAndRestartTest.class,
38
	LaunchConfigurationAndRestartTest.class,
39
	OperationsWhileTargetIsRunningTest.class,
39
	OperationsWhileTargetIsRunningTest.class,
40
	PostMortemCoreTest.class,
40
	PostMortemCoreTest.class,
41
	CommandTimeoutTest.class,
41
	Suite_Sessionless_Tests.class,
42
	Suite_Sessionless_Tests.class,
42
	/* Add your suite class here */
43
	/* Add your suite class here */
43
})
44
})
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandTimeoutTest.java (+140 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests;
13
14
import junit.framework.Assert;
15
16
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
17
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
18
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
22
import org.eclipse.core.runtime.preferences.InstanceScope;
23
import org.eclipse.debug.core.DebugException;
24
import org.junit.After;
25
import org.junit.Before;
26
import org.junit.BeforeClass;
27
import org.junit.Test;
28
29
public class CommandTimeoutTest extends BaseTestCase {
30
31
	private static boolean fgTimeoutEnabled = false;
32
	private static int fgTimeout = IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT;
33
	
34
    @BeforeClass
35
    public static void beforeClassMethod() {
36
		// Save the original values of the timeout-related preferences
37
		fgTimeoutEnabled = Platform.getPreferencesService().getBoolean( 
38
				GdbPlugin.PLUGIN_ID, 
39
				IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, 
40
				false, 
41
				null );		
42
		fgTimeout = Platform.getPreferencesService().getInt( 
43
				GdbPlugin.PLUGIN_ID,
44
				IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, 
45
				IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT,
46
				null );		
47
    }
48
49
    @Before
50
	@Override
51
	public void baseBeforeMethod() throws Exception {
52
	}
53
54
	@After
55
	@Override
56
	public void baseAfterMethod() throws Exception {
57
		// Restore the timeout preferences
58
		IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
59
		node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, fgTimeoutEnabled );
60
		node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, fgTimeout );
61
	}
62
63
	@Override
64
	protected boolean reallyLaunchGDBServer() {
65
		return false;
66
	}
67
68
	/**
69
	 * Enables the timeout support and sets the timeout value to minimal - 1.
70
	 * Launch is expected to timeout on the first gdb command.
71
	 */
72
	@Test
73
	public void firstCommandTimedOut() {
74
		IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
75
		node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, true );
76
		node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, 1 );
77
78
		try {
79
			performLaunchAndTerminate();
80
			Assert.fail( "Launch is expected to fail" );
81
		}
82
		catch( Exception e ) {
83
			processException( e );
84
		}
85
	}
86
87
	/**
88
	 * Tries to connect to gdbserver without starting it.
89
	 * Launch is expected to timeout on "target-remote" command.
90
	 */
91
	@Test
92
	public void remoteConnectionTimedOut() {
93
		if ( !isRemoteSession() )
94
			return;
95
96
		IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
97
		node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, true );
98
		node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, 1000 );
99
100
		try {
101
			performLaunchAndTerminate();
102
			Assert.fail( "Launch is expected to fail" );
103
		}
104
		catch( Exception e ) {
105
			processException( e );
106
		}
107
	}
108
109
	private void performLaunchAndTerminate() throws Exception {
110
		super.baseBeforeMethod();
111
		super.baseAfterMethod();
112
	}
113
114
	/**
115
	 * Checks whether the given exception is an instance of {@link CoreException} 
116
	 * with the status code 20100 which indicates that a gdb command has been timed out.
117
	 */
118
	private void processException( Exception e ) {
119
		if ( e instanceof DebugException ) {
120
			Throwable t = getExceptionCause( e );
121
			Assert.assertTrue(
122
				"Unexpected exception",
123
				t instanceof CoreException && ((CoreException)t).getStatus().getCode() == 20100 );
124
		}
125
		else {
126
			Assert.fail( "Unexpected exception type" );
127
		}
128
	}
129
130
	private Throwable getExceptionCause(Throwable e) {
131
		Throwable current = e;
132
		while ( current instanceof CoreException ) {
133
			Throwable t = ((CoreException)current).getCause();
134
			if ( t == null )
135
				break;
136
			current = t;
137
		}
138
		return current;
139
	}
140
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/CommandTimeoutTest_6_6.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
13
14
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
17
import org.junit.BeforeClass;
18
import org.junit.runner.RunWith;
19
20
@RunWith(BackgroundRunner.class)
21
public class CommandTimeoutTest_6_6 extends CommandTimeoutTest {
22
	@BeforeClass
23
    public static void beforeClassMethod_6_6() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
25
	}
26
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java (-1 / +2 lines)
Lines 38-44 Link Here
38
	LaunchConfigurationAndRestartTest_6_6.class,
38
	LaunchConfigurationAndRestartTest_6_6.class,
39
	OperationsWhileTargetIsRunningTest_6_6.class,
39
	OperationsWhileTargetIsRunningTest_6_6.class,
40
	PostMortemCoreTest_6_6.class,
40
	PostMortemCoreTest_6_6.class,
41
	Suite_Sessionless_Tests.class	
41
	Suite_Sessionless_Tests.class,
42
	CommandTimeoutTest_6_6.class,
42
	/* Add your test class here */
43
	/* Add your test class here */
43
})
44
})
44
45
(-)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 (-1 / +2 lines)
Lines 37-43 Link Here
37
	MIDisassemblyTest_6_6.class,
37
	MIDisassemblyTest_6_6.class,
38
	GDBProcessesTest_6_6.class,
38
	GDBProcessesTest_6_6.class,
39
	OperationsWhileTargetIsRunningTest_6_6.class,
39
	OperationsWhileTargetIsRunningTest_6_6.class,
40
	Suite_Sessionless_Tests.class
40
	CommandTimeoutTest_6_6.class,
41
	Suite_Sessionless_Tests.class,
41
	/* Add your test class here */
42
	/* Add your test class here */
42
})
43
})
43
44
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/CommandTimeoutTest_6_7.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7;
13
14
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
17
import org.junit.BeforeClass;
18
import org.junit.runner.RunWith;
19
20
@RunWith(BackgroundRunner.class)
21
public class CommandTimeoutTest_6_7 extends CommandTimeoutTest {
22
	@BeforeClass
23
    public static void beforeClassMethod_6_7() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_7);		
25
	}
26
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java (-1 / +2 lines)
Lines 38-44 Link Here
38
	LaunchConfigurationAndRestartTest_6_7.class,
38
	LaunchConfigurationAndRestartTest_6_7.class,
39
	OperationsWhileTargetIsRunningTest_6_7.class,
39
	OperationsWhileTargetIsRunningTest_6_7.class,
40
	PostMortemCoreTest_6_7.class,
40
	PostMortemCoreTest_6_7.class,
41
	Suite_Sessionless_Tests.class	
41
	CommandTimeoutTest_6_7.class,
42
	Suite_Sessionless_Tests.class,
42
	/* Add your test class here */
43
	/* Add your test class here */
43
})
44
})
44
45
(-)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 (-1 / +2 lines)
Lines 37-43 Link Here
37
	MIDisassemblyTest_6_7.class,
37
	MIDisassemblyTest_6_7.class,
38
	GDBProcessesTest_6_7.class,
38
	GDBProcessesTest_6_7.class,
39
	OperationsWhileTargetIsRunningTest_6_7.class,
39
	OperationsWhileTargetIsRunningTest_6_7.class,
40
	Suite_Sessionless_Tests.class	
40
	CommandTimeoutTest_6_7.class,
41
	Suite_Sessionless_Tests.class,	
41
	/* Add your test class here */
42
	/* Add your test class here */
42
})
43
})
43
44
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/CommandTimeoutTest_6_8.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8;
13
14
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
17
import org.junit.BeforeClass;
18
import org.junit.runner.RunWith;
19
20
@RunWith(BackgroundRunner.class)
21
public class CommandTimeoutTest_6_8 extends CommandTimeoutTest {
22
	@BeforeClass
23
    public static void beforeClassMethod_6_8() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_8);		
25
	}
26
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java (-1 / +2 lines)
Lines 38-44 Link Here
38
	LaunchConfigurationAndRestartTest_6_8.class,
38
	LaunchConfigurationAndRestartTest_6_8.class,
39
	OperationsWhileTargetIsRunningTest_6_8.class,
39
	OperationsWhileTargetIsRunningTest_6_8.class,
40
	PostMortemCoreTest_6_8.class,
40
	PostMortemCoreTest_6_8.class,
41
	Suite_Sessionless_Tests.class
41
	CommandTimeoutTest_6_8.class,
42
	Suite_Sessionless_Tests.class,
42
	/* Add your test class here */
43
	/* Add your test class here */
43
})
44
})
44
45
(-)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 (-1 / +2 lines)
Lines 37-43 Link Here
37
	MIDisassemblyTest_6_8.class,
37
	MIDisassemblyTest_6_8.class,
38
	GDBProcessesTest_6_8.class,
38
	GDBProcessesTest_6_8.class,
39
	OperationsWhileTargetIsRunningTest_6_8.class,
39
	OperationsWhileTargetIsRunningTest_6_8.class,
40
	Suite_Sessionless_Tests.class	
40
	CommandTimeoutTest_6_8.class,
41
	Suite_Sessionless_Tests.class,	
41
	/* Add your test class here */
42
	/* Add your test class here */
42
})
43
})
43
44
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/CommandTimeoutTest_7_0.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0;
13
14
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
17
import org.junit.BeforeClass;
18
import org.junit.runner.RunWith;
19
20
@RunWith(BackgroundRunner.class)
21
public class CommandTimeoutTest_7_0 extends CommandTimeoutTest {
22
	@BeforeClass
23
    public static void beforeClassMethod_7_0() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_0);		
25
	}
26
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java (-1 / +2 lines)
Lines 40-46 Link Here
40
	OperationsWhileTargetIsRunningTest_7_0.class,
40
	OperationsWhileTargetIsRunningTest_7_0.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_0.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_0.class,
42
	PostMortemCoreTest_7_0.class,
42
	PostMortemCoreTest_7_0.class,
43
	Suite_Sessionless_Tests.class	
43
	CommandTimeoutTest_7_0.class,
44
	Suite_Sessionless_Tests.class,	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)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 (-1 / +2 lines)
Lines 40-46 Link Here
40
	GDBProcessesTest_7_0.class,
40
	GDBProcessesTest_7_0.class,
41
	OperationsWhileTargetIsRunningTest_7_0.class,
41
	OperationsWhileTargetIsRunningTest_7_0.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_0.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_0.class,
43
	Suite_Sessionless_Tests.class	
43
	CommandTimeoutTest_7_0.class,
44
	Suite_Sessionless_Tests.class,	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/CommandTimeoutTest_7_1.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1;
13
14
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
17
import org.junit.BeforeClass;
18
import org.junit.runner.RunWith;
19
20
@RunWith(BackgroundRunner.class)
21
public class CommandTimeoutTest_7_1 extends CommandTimeoutTest {
22
	@BeforeClass
23
    public static void beforeClassMethod_7_1() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_1);		
25
	}
26
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java (-1 / +2 lines)
Lines 40-46 Link Here
40
	OperationsWhileTargetIsRunningTest_7_1.class,
40
	OperationsWhileTargetIsRunningTest_7_1.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_1.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_1.class,
42
	PostMortemCoreTest_7_1.class,
42
	PostMortemCoreTest_7_1.class,
43
	Suite_Sessionless_Tests.class
43
	CommandTimeoutTest_7_1.class,
44
	Suite_Sessionless_Tests.class,
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)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 (-1 / +2 lines)
Lines 40-46 Link Here
40
	GDBProcessesTest_7_1.class,
40
	GDBProcessesTest_7_1.class,
41
	OperationsWhileTargetIsRunningTest_7_1.class,
41
	OperationsWhileTargetIsRunningTest_7_1.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_1.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_1.class,
43
	Suite_Sessionless_Tests.class	
43
	CommandTimeoutTest_7_1.class,
44
	Suite_Sessionless_Tests.class,	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/CommandTimeoutTest_7_2.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2;
13
14
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
17
import org.junit.BeforeClass;
18
import org.junit.runner.RunWith;
19
20
@RunWith(BackgroundRunner.class)
21
public class CommandTimeoutTest_7_2 extends CommandTimeoutTest {
22
	@BeforeClass
23
    public static void beforeClassMethod_7_2() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);		
25
	}
26
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java (-1 / +2 lines)
Lines 40-46 Link Here
40
	OperationsWhileTargetIsRunningTest_7_2.class,
40
	OperationsWhileTargetIsRunningTest_7_2.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_2.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_2.class,
42
	PostMortemCoreTest_7_2.class,
42
	PostMortemCoreTest_7_2.class,
43
	Suite_Sessionless_Tests.class	
43
	CommandTimeoutTest_7_2.class,
44
	Suite_Sessionless_Tests.class,	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)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 (-1 / +2 lines)
Lines 40-46 Link Here
40
	GDBProcessesTest_7_2.class,
40
	GDBProcessesTest_7_2.class,
41
	OperationsWhileTargetIsRunningTest_7_2.class,
41
	OperationsWhileTargetIsRunningTest_7_2.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_2.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_2.class,
43
	Suite_Sessionless_Tests.class	
43
	CommandTimeoutTest_7_2.class,
44
	Suite_Sessionless_Tests.class,	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/CommandTimeoutTest_7_3.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3;
13
14
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
17
import org.junit.BeforeClass;
18
import org.junit.runner.RunWith;
19
20
@RunWith(BackgroundRunner.class)
21
public class CommandTimeoutTest_7_3 extends CommandTimeoutTest {
22
	@BeforeClass
23
    public static void beforeClassMethod_7_3() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_3);		
25
	}
26
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java (-1 / +2 lines)
Lines 40-46 Link Here
40
	OperationsWhileTargetIsRunningTest_7_3.class,
40
	OperationsWhileTargetIsRunningTest_7_3.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_3.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_3.class,
42
	PostMortemCoreTest_7_3.class,
42
	PostMortemCoreTest_7_3.class,
43
	Suite_Sessionless_Tests.class	
43
	CommandTimeoutTest_7_3.class,
44
	Suite_Sessionless_Tests.class,	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)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 (-1 / +2 lines)
Lines 40-46 Link Here
40
	GDBProcessesTest_7_3.class,
40
	GDBProcessesTest_7_3.class,
41
	OperationsWhileTargetIsRunningTest_7_3.class,
41
	OperationsWhileTargetIsRunningTest_7_3.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_3.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_3.class,
43
	Suite_Sessionless_Tests.class	
43
	CommandTimeoutTest_7_3.class,
44
	Suite_Sessionless_Tests.class,	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/CommandTimeoutTest_7_4.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
13
14
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
17
import org.junit.BeforeClass;
18
import org.junit.runner.RunWith;
19
20
@RunWith(BackgroundRunner.class)
21
public class CommandTimeoutTest_7_4 extends CommandTimeoutTest {
22
	@BeforeClass
23
    public static void beforeClassMethod_7_4() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_4);		
25
	}
26
}
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java (-1 / +2 lines)
Lines 40-46 Link Here
40
	OperationsWhileTargetIsRunningTest_7_4.class,
40
	OperationsWhileTargetIsRunningTest_7_4.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_4.class,
41
	OperationsWhileTargetIsRunningNonStopTest_7_4.class,
42
	PostMortemCoreTest_7_4.class,
42
	PostMortemCoreTest_7_4.class,
43
	Suite_Sessionless_Tests.class	
43
	CommandTimeoutTest_7_4.class,
44
	Suite_Sessionless_Tests.class,	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})
46
47
(-)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 (+1 lines)
Lines 40-45 Link Here
40
	GDBProcessesTest_7_4.class,
40
	GDBProcessesTest_7_4.class,
41
	OperationsWhileTargetIsRunningTest_7_4.class,
41
	OperationsWhileTargetIsRunningTest_7_4.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_4.class,
42
	OperationsWhileTargetIsRunningNonStopTest_7_4.class,
43
	CommandTimeoutTest_7_4.class,
43
	Suite_Sessionless_Tests.class	
44
	Suite_Sessionless_Tests.class	
44
	/* Add your test class here */
45
	/* Add your test class here */
45
})
46
})

Return to bug 361934