1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 06:55:23 +02:00

Fix for PR 45533: MIException while creating MISession can leave an orphan gdb process.

This commit is contained in:
Mikhail Khodjaiants 2003-11-19 21:47:53 +00:00
parent ff03b9fc87
commit 21f66ca19b
6 changed files with 111 additions and 52 deletions

View file

@ -1,3 +1,15 @@
2003-11-19 Mikhail Khodjaiants
Fix for PR 45533: MIException while creating MISession can leave an orphan gdb process.
* src/org/eclipse/cdt/debug/mi/core/MIPlugin.java: removed the 'getAdjustedTimeout' method.
2003-11-19 Mikhail Khodjaiants
Fix for PR 45533: MIException while creating MISession can leave an orphan gdb process.
* src/org/eclipse/cdt/debug/mi/core/MIPlugin.java: initialization of preferences by default values.
* src/org/eclipse/cdt/debug/mi/core/MISession.java: removed the duplicate constant for the default
launch timeout value.
2003-11-13 Mikhail Khodjaiants 2003-11-13 Mikhail Khodjaiants
* src/org/eclipse/cdt/debug/mi/core/output/MIFrame.java * src/org/eclipse/cdt/debug/mi/core/output/MIFrame.java

View file

@ -289,27 +289,6 @@ public class MIPlugin extends Plugin {
} }
} }
/**
* Retrieve the session timeout.
*
* Allow at least one second per megabyte as a minimum on the timeout
* (note one second is an arbitrary choice based on swapping performance).
* This is required for loading the symbols from very large programs.
*/
private int getAdjustedTimeout(File program) {
Preferences prefs = plugin.getPluginPreferences();
int timeout = prefs.getInt(IMIConstants.PREF_REQUEST_TIMEOUT); //milliseconds
if(program != null && program.exists()) {
long programSize = program.length();
int minimumTimeout = (int)(programSize / 1000L);
if(timeout < minimumTimeout) {
//debugLog("Adjusting timeout from " + timeout + "ms to " + minimumTimeout + "ms");
timeout = minimumTimeout;
}
}
return timeout;
}
/** /**
* Do some basic synchronisation, gdb make take some time to load * Do some basic synchronisation, gdb make take some time to load
* for whatever reasons. * for whatever reasons.
@ -348,9 +327,6 @@ public class MIPlugin extends Plugin {
MIPlugin plugin = getDefault(); MIPlugin plugin = getDefault();
Preferences prefs = plugin.getPluginPreferences(); Preferences prefs = plugin.getPluginPreferences();
int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT); int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
if (launchTimeout <= 0) {
launchTimeout = getAdjustedTimeout(program);
}
while (syncStartup.isAlive()) { while (syncStartup.isAlive()) {
try { try {
pgdb.wait(launchTimeout); pgdb.wait(launchTimeout);
@ -378,7 +354,8 @@ public class MIPlugin extends Plugin {
* @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPrefrences() * @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPrefrences()
*/ */
protected void initializeDefaultPluginPreferences() { protected void initializeDefaultPluginPreferences() {
getPluginPreferences().setDefault(IMIConstants.PREF_REQUEST_TIMEOUT, MISession.REQUEST_TIMEOUT); getPluginPreferences().setDefault(IMIConstants.PREF_REQUEST_TIMEOUT, IMIConstants.DEF_REQUEST_TIMEOUT);
getPluginPreferences().setDefault(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, IMIConstants.DEF_REQUEST_LAUNCH_TIMEOUT);
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -44,11 +44,6 @@ public class MISession extends Observable {
*/ */
public final static int CORE = 2; public final static int CORE = 2;
/**
* Default wait() period for an answer after a query, 10 seconds.
*/
public static long REQUEST_TIMEOUT = 10000; // 10 * 1000 (~ 10 secs);
boolean terminated; boolean terminated;
// hold the type of the session(post-mortem, attach etc ..) // hold the type of the session(post-mortem, attach etc ..)

View file

@ -1,3 +1,16 @@
2003-11-19 Mikhail Khodjaiants
Fix for PR 45533: MIException while creating MISession can leave an orphan gdb process.
* src/org/eclipse/cdt/debug/mi/internal/ui/preferences/MIPreferencePage.java:
added a text field for the launch timeout.
2003-11-06 Alain Magloire
Patch from Ashish Karkare(TimeSys)
*src/org/eclipse/cdt/debug/mi/internal/ui/GDBServerDebuggerPage.java
Add a new Combo that helps select a reasonable line speed, and storing
the selected value as a configuration attribute.
2003-09-29 Mikhail Khodjaiants 2003-09-29 Mikhail Khodjaiants
Improved the layout of the 'Shared Libraries' component. Improved the layout of the 'Shared Libraries' component.
* SolibSearchPathBlock.java * SolibSearchPathBlock.java

View file

@ -25,6 +25,7 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
@ -37,6 +38,7 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
protected Text fHostText; protected Text fHostText;
protected Text fHostPort; protected Text fHostPort;
protected Text fAsyncDev; protected Text fAsyncDev;
protected Combo fAsyncDevSpeedCombo;
private Button fAutoSoLibButton; private Button fAutoSoLibButton;
public void createControl(Composite parent) { public void createControl(Composite parent) {
@ -83,6 +85,7 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
fAsyncButton.addSelectionListener(new SelectionAdapter() { fAsyncButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
fAsyncDev.setEnabled(fAsyncButton.getSelection()); fAsyncDev.setEnabled(fAsyncButton.getSelection());
fAsyncDevSpeedCombo.setEnabled(fAsyncButton.getSelection());
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
@ -112,6 +115,8 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
} }
}); });
Label asyncDevLabel= new Label(comp, SWT.NONE); Label asyncDevLabel= new Label(comp, SWT.NONE);
asyncDevLabel.setText("Serial device:"); asyncDevLabel.setText("Serial device:");
@ -124,6 +129,26 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
} }
}); });
Label asyncDevSpeedLabel= new Label(comp, SWT.NONE);
asyncDevSpeedLabel.setText("Serial speed:");
fAsyncDevSpeedCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
String choices [] = {"9600", "19200","38400", "57600", "115200"};
fAsyncDevSpeedCombo.setItems(choices);
fAsyncDevSpeedCombo.select(choices.length-1);
gd = new GridData(GridData.FILL_HORIZONTAL);
fAsyncDevSpeedCombo.setLayoutData(gd);
fAsyncDevSpeedCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
updateLaunchConfigurationDialog();
}
});
fTCPButton.setSelection(true); fTCPButton.setSelection(true);
fAsyncButton.setSelection(false); fAsyncButton.setSelection(false);
fHostText.setEnabled(true); fHostText.setEnabled(true);
@ -131,7 +156,7 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
fAsyncDev.setEnabled(false); fAsyncDev.setEnabled(false);
fHostPort.setEnabled(true); fHostPort.setEnabled(true);
fHostText.setEnabled(true); fHostText.setEnabled(true);
fAsyncDev.setEnabled(false); fAsyncDevSpeedCombo.setEnabled(false);
createVerticalSpacer(comp, 2); createVerticalSpacer(comp, 2);
@ -212,6 +237,14 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
if (attr == null) { if (attr == null) {
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "/dev/ttyS0"); configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "/dev/ttyS0");
} }
attr = null;
try {
attr = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, (String) null);
} catch (CoreException e) {
}
if (attr == null) {
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "115200");
}
} }
/** /**
@ -236,9 +269,9 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
setMessage(null); setMessage(null);
} }
} else { } else {
valid = fAsyncDev.getText().length() != 0; valid = ((fAsyncDev.getText().length() != 0) && (fAsyncDevSpeedCombo.getSelectionIndex()!=-1)) ;
if (!valid) { if (!valid) {
setErrorMessage("If Async is selected, device must be specified"); setErrorMessage("If Async is selected, device and speed must be specified");
setMessage(null); setMessage(null);
} }
} }
@ -253,6 +286,7 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
String hostText = ""; String hostText = "";
String hostPort = ""; String hostPort = "";
String asyncDev = "/dev/ttyS0"; String asyncDev = "/dev/ttyS0";
String asyncDevSpeed = "115200";
boolean autosolib = false; boolean autosolib = false;
try { try {
debuggerCommand = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); debuggerCommand = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
@ -264,6 +298,7 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
hostText = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, ""); hostText = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "");
hostPort = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, ""); hostPort = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "");
asyncDev = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, ""); asyncDev = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "");
asyncDevSpeed = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "");
} catch (CoreException e) { } catch (CoreException e) {
} }
fDebuggerCommandText.setText(debuggerCommand); fDebuggerCommandText.setText(debuggerCommand);
@ -272,9 +307,11 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
fHostText.setText(hostText); fHostText.setText(hostText);
fHostPort.setText(hostPort); fHostPort.setText(hostPort);
fAsyncDev.setText(asyncDev); fAsyncDev.setText(asyncDev);
fAsyncDevSpeedCombo.select(fAsyncDevSpeedCombo.indexOf(asyncDevSpeed));
fHostText.setEnabled(isTcp); fHostText.setEnabled(isTcp);
fHostPort.setEnabled(isTcp); fHostPort.setEnabled(isTcp);
fAsyncDev.setEnabled(!isTcp); fAsyncDev.setEnabled(!isTcp);
fAsyncDevSpeedCombo.setEnabled(!isTcp);
fAutoSoLibButton.setSelection(autosolib); fAutoSoLibButton.setSelection(autosolib);
} }
@ -283,6 +320,7 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
String hostText = fHostText.getText(); String hostText = fHostText.getText();
String hostPort = fHostPort.getText(); String hostPort = fHostPort.getText();
String asyncDev = fAsyncDev.getText(); String asyncDev = fAsyncDev.getText();
String asyncDevSpeed = fAsyncDevSpeedCombo.getItem(fAsyncDevSpeedCombo.getSelectionIndex());
debuggerCommand.trim(); debuggerCommand.trim();
hostText.trim(); hostText.trim();
hostPort.trim(); hostPort.trim();
@ -293,6 +331,7 @@ public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab {
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, hostText); configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, hostText);
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, hostPort); configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, hostPort);
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, asyncDev); configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, asyncDev);
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, asyncDevSpeed);
} }
public String getName() { public String getName() {

View file

@ -36,8 +36,11 @@ import org.eclipse.ui.help.WorkbenchHelp;
*/ */
public class MIPreferencePage extends PreferencePage implements IWorkbenchPreferencePage public class MIPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
{ {
// Timeout preference widgets // Debugger timeout preference widgets
IntegerFieldEditor fTimeoutText; IntegerFieldEditor fDebugTimeoutText;
// Launch timeout preference widgets
IntegerFieldEditor fLaunchTimeoutText;
/** /**
* Constructor for MIPreferencePage. * Constructor for MIPreferencePage.
@ -95,7 +98,8 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer
*/ */
private void setValues() private void setValues()
{ {
fTimeoutText.setStringValue( new Integer( MIPlugin.getDefault().getPluginPreferences().getInt( IMIConstants.PREF_REQUEST_TIMEOUT ) ).toString() ); fDebugTimeoutText.setStringValue( new Integer( MIPlugin.getDefault().getPluginPreferences().getInt( IMIConstants.PREF_REQUEST_TIMEOUT ) ).toString() );
fLaunchTimeoutText.setStringValue( new Integer( MIPlugin.getDefault().getPluginPreferences().getInt( IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT ) ).toString() );
} }
/** /**
@ -121,7 +125,8 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer
private void setDefaultValues() private void setDefaultValues()
{ {
fTimeoutText.setStringValue( new Integer( IMIConstants.DEF_REQUEST_TIMEOUT ).toString() ); fDebugTimeoutText.setStringValue( new Integer( IMIConstants.DEF_REQUEST_TIMEOUT ).toString() );
fLaunchTimeoutText.setStringValue( new Integer( IMIConstants.DEF_REQUEST_LAUNCH_TIMEOUT ).toString() );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -150,25 +155,25 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer
data.horizontalSpan = 2; data.horizontalSpan = 2;
spacingComposite.setLayoutData( data ); spacingComposite.setLayoutData( data );
fTimeoutText = new IntegerFieldEditor( IMIConstants.PREF_REQUEST_TIMEOUT, "Debugger &timeout (ms):", spacingComposite ); fDebugTimeoutText = createTimeoutField( IMIConstants.PREF_REQUEST_TIMEOUT, "&Debugger timeout (ms):", spacingComposite );
data = new GridData(); fDebugTimeoutText.setPropertyChangeListener(
data.widthHint = convertWidthInCharsToPixels( 10 );
fTimeoutText.getTextControl( spacingComposite ).setLayoutData( data );
fTimeoutText.setPreferenceStore( MIUIPlugin.getDefault().getPreferenceStore() );
fTimeoutText.setPreferencePage( this );
fTimeoutText.setValidateStrategy( StringFieldEditor.VALIDATE_ON_KEY_STROKE );
fTimeoutText.setValidRange( IMIConstants.MIN_REQUEST_TIMEOUT, IMIConstants.MAX_REQUEST_TIMEOUT );
String minValue = Integer.toString( IMIConstants.MIN_REQUEST_TIMEOUT );
String maxValue = Integer.toString( IMIConstants.MAX_REQUEST_TIMEOUT );
fTimeoutText.setErrorMessage( MessageFormat.format( "The valid value range is [{0},{1}].", new String[]{ minValue, maxValue } ) );
fTimeoutText.load();
fTimeoutText.setPropertyChangeListener(
new IPropertyChangeListener() new IPropertyChangeListener()
{ {
public void propertyChange( PropertyChangeEvent event ) public void propertyChange( PropertyChangeEvent event )
{ {
if ( event.getProperty().equals( FieldEditor.IS_VALID ) ) if ( event.getProperty().equals( FieldEditor.IS_VALID ) )
setValid( fTimeoutText.isValid() ); setValid( fDebugTimeoutText.isValid() );
}
} );
fLaunchTimeoutText = createTimeoutField( IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, "&Launch &timeout (ms):", spacingComposite );
fLaunchTimeoutText.setPropertyChangeListener(
new IPropertyChangeListener()
{
public void propertyChange( PropertyChangeEvent event )
{
if ( event.getProperty().equals( FieldEditor.IS_VALID ) )
setValid( fLaunchTimeoutText.isValid() );
} }
} ); } );
} }
@ -179,6 +184,24 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer
*/ */
private void storeValues() private void storeValues()
{ {
MIPlugin.getDefault().getPluginPreferences().setValue( IMIConstants.PREF_REQUEST_TIMEOUT, fTimeoutText.getIntValue() ); MIPlugin.getDefault().getPluginPreferences().setValue( IMIConstants.PREF_REQUEST_TIMEOUT, fDebugTimeoutText.getIntValue() );
MIPlugin.getDefault().getPluginPreferences().setValue( IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, fLaunchTimeoutText.getIntValue() );
}
private IntegerFieldEditor createTimeoutField( String preference, String label, Composite parent )
{
IntegerFieldEditor toText = new IntegerFieldEditor( preference, label, parent );
GridData data = new GridData();
data.widthHint = convertWidthInCharsToPixels( 10 );
toText.getTextControl( parent ).setLayoutData( data );
toText.setPreferenceStore( MIUIPlugin.getDefault().getPreferenceStore() );
toText.setPreferencePage( this );
toText.setValidateStrategy( StringFieldEditor.VALIDATE_ON_KEY_STROKE );
toText.setValidRange( IMIConstants.MIN_REQUEST_TIMEOUT, IMIConstants.MAX_REQUEST_TIMEOUT );
String minValue = Integer.toString( IMIConstants.MIN_REQUEST_TIMEOUT );
String maxValue = Integer.toString( IMIConstants.MAX_REQUEST_TIMEOUT );
toText.setErrorMessage( MessageFormat.format( "The valid value range is [{0},{1}].", new String[]{ minValue, maxValue } ) );
toText.load();
return toText;
} }
} }