[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] CDT 1.2 serial line speed patch
|
Hello,
Please find attached a CDT 1.2 patch that enables setting of
serial line speed in the launch configuration when debugging remote targets.
The summary of changes is as follows:
1. IGDBServerMILaunchConfigurationConstants.java
New attribute definition DEV_SPEED.
2. GDBServerDebuggerPage.java
Add a new Combo that helps select a reasonable line speed, and storing
the selected value as a configuration attribute.
3. GDBServerDebugger.java
Extracts serial speed value and passes it to createCSession().
4. MIPlugin.java
Sends remotebaud command prior to sending target attach.
Thanks,
Ashish.
--- ./merge/latest/GDBServerDebugger.java 2003-11-04 10:38:41.000000000 -0500
+++ ./merge/outbound/GDBServerDebugger.java 2003-11-04 10:26:01.000000000 -0500
@@ -55,15 +55,19 @@
String gdb = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
File cwd = exe.getProject().getLocation().toFile();
String remote;
+ String remoteSpeed = null;
+ String []args=null;
if (config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false)) {
remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid");
remote += ":";
remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid");
+ args = new String[] {"remote", remote};
} else {
remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid");
+ remoteSpeed = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid");
+ args = new String[] {"remote", remote, "remotebaud", remoteSpeed};
}
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
- String[] args = new String[] {"remote", remote};
Session session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), 0, args, cwd, gdbinit);
initializeLibraries(config, session);
return session;
--- ./merge/latest/IGDBServerMILaunchConfigurationConstants.java 2003-11-04 10:38:41.000000000 -0500
+++ ./merge/outbound/IGDBServerMILaunchConfigurationConstants.java 2003-11-04 10:26:01.000000000 -0500
@@ -21,4 +21,5 @@
public static final String ATTR_HOST = MIPlugin.getUniqueIdentifier() + ".HOST"; //$NON-NLS-1$
public static final String ATTR_PORT = MIPlugin.getUniqueIdentifier() + ".PORT"; //$NON-NLS-1$
public static final String ATTR_DEV = MIPlugin.getUniqueIdentifier() + ".DEV"; //$NON-NLS-1$
+ public static final String ATTR_DEV_SPEED = MIPlugin.getUniqueIdentifier() + ".DEV_SPEED"; //$NON-NLS-1$
}
--- ./merge/latest/MIPlugin.java 2003-11-04 10:38:41.000000000 -0500
+++ ./merge/outbound/MIPlugin.java 2003-11-04 10:33:29.000000000 -0500
@@ -18,6 +18,7 @@
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MITargetAttach;
import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
+import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
@@ -212,8 +213,11 @@
if (gdbinit == null || gdbinit.length() == 0) {
gdbinit = GDBINIT;
}
+ String speed = null;
String[] args;
+
+
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1"};
} else {
@@ -228,7 +232,25 @@
throw e;
}
CommandFactory factory = session.getCommandFactory();
+
if (targetParams != null && targetParams.length > 0) {
+
+ if (targetParams.length == 4 ) {
+ // Extract serial line settings from the targetParams array.
+
+ String [] speedParams = new String[] {targetParams[2], targetParams[3] };
+ MIGDBSet setSpeed = factory.createMIGDBSet(speedParams);
+ // Set serial line parameters
+ session.postCommand(setSpeed);
+ MIInfo info = setSpeed.getMIInfo();
+ if (info == null) {
+ throw new MIException ("No answer");
+ }
+ // Rebuild the targetParams array with just the target selection command.
+ targetParams = new String [] {targetParams[0], targetParams[1] };
+
+ }
+
MITargetSelect target = factory.createMITargetSelect(targetParams);
session.postCommand(target);
MIInfo info = target.getMIInfo();
@@ -266,7 +288,7 @@
}
public void debugLog(String message) {
- if (getDefault().isDebugging()) {
+ if (getDefault().isDebugging()) { //
// Time stamp
message = MessageFormat.format( "[{0}] {1}", new Object[] { new Long( System.currentTimeMillis() ), message } );
// This is to verbose for a log file, better use the console.
--- ./merge/latest/GDBServerDebuggerPage.java 2003-11-04 10:38:41.000000000 -0500
+++ ./merge/outbound/GDBServerDebuggerPage.java 2003-11-04 10:26:01.000000000 -0500
@@ -25,6 +25,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -37,6 +38,7 @@
protected Text fHostText;
protected Text fHostPort;
protected Text fAsyncDev;
+ protected Combo fAsyncDevSpeedCombo;
private Button fAutoSoLibButton;
public void createControl(Composite parent) {
@@ -83,6 +85,7 @@
fAsyncButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fAsyncDev.setEnabled(fAsyncButton.getSelection());
+ fAsyncDevSpeedCombo.setEnabled(fAsyncButton.getSelection());
updateLaunchConfigurationDialog();
}
});
@@ -112,6 +115,8 @@
}
});
+
+
Label asyncDevLabel= new Label(comp, SWT.NONE);
asyncDevLabel.setText("Serial device:");
@@ -124,6 +129,26 @@
}
});
+ 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);
fAsyncButton.setSelection(false);
fHostText.setEnabled(true);
@@ -131,7 +156,7 @@
fAsyncDev.setEnabled(false);
fHostPort.setEnabled(true);
fHostText.setEnabled(true);
- fAsyncDev.setEnabled(false);
+ fAsyncDevSpeedCombo.setEnabled(false);
createVerticalSpacer(comp, 2);
@@ -212,6 +237,14 @@
if (attr == null) {
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 @@
setMessage(null);
}
} else {
- valid = fAsyncDev.getText().length() != 0;
+ valid = ((fAsyncDev.getText().length() != 0) && (fAsyncDevSpeedCombo.getSelectionIndex()!=-1)) ;
if (!valid) {
- setErrorMessage("If Async is selected, device must be specified");
+ setErrorMessage("If Async is selected, device and speed must be specified");
setMessage(null);
}
}
@@ -253,6 +286,7 @@
String hostText = "";
String hostPort = "";
String asyncDev = "/dev/ttyS0";
+ String asyncDevSpeed = "115200";
boolean autosolib = false;
try {
debuggerCommand = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
@@ -264,6 +298,7 @@
hostText = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "");
hostPort = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "");
asyncDev = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "");
+ asyncDevSpeed = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "");
} catch (CoreException e) {
}
fDebuggerCommandText.setText(debuggerCommand);
@@ -272,9 +307,11 @@
fHostText.setText(hostText);
fHostPort.setText(hostPort);
fAsyncDev.setText(asyncDev);
+ fAsyncDevSpeedCombo.select(fAsyncDevSpeedCombo.indexOf(asyncDevSpeed));
fHostText.setEnabled(isTcp);
fHostPort.setEnabled(isTcp);
fAsyncDev.setEnabled(!isTcp);
+ fAsyncDevSpeedCombo.setEnabled(!isTcp);
fAutoSoLibButton.setSelection(autosolib);
}
@@ -283,6 +320,7 @@
String hostText = fHostText.getText();
String hostPort = fHostPort.getText();
String asyncDev = fAsyncDev.getText();
+ String asyncDevSpeed = fAsyncDevSpeedCombo.getItem(fAsyncDevSpeedCombo.getSelectionIndex());
debuggerCommand.trim();
hostText.trim();
hostPort.trim();
@@ -293,6 +331,7 @@
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, hostText);
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, hostPort);
configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, asyncDev);
+ configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, asyncDevSpeed);
}
public String getName() {