Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-patch] CDT 1.2 serial line speed patch

> 
> 
> 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.

(4) is rejected.  You are implying that args[3] args[4] must be of a certain
value.  Currently the helper function in the MIPlugin.java is use by a
variety of other users.  Something like this is incorrect.  Your propose
code been move to GDBServerDebugger.java. (see patch)

Thanks.

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.185
diff -u -r1.185 ChangeLog
--- ChangeLog	29 Oct 2003 17:35:48 -0000	1.185
+++ ChangeLog	6 Nov 2003 20:53:33 -0000
@@ -1,3 +1,21 @@
+2003-11-06 Alain Magloire
+
+	* src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java:
+	Small fix for the defferred breakpoint support.
+
+2003-11-06 Alain Magloire
+	
+	Patch from Ashish Karkare:
+	A CDT 1.2 patch that enables setting of
+	serial line speed in the launch configuration when debugging remote targets.
+ 
+	* src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java
+    New attribute definition DEV_SPEED.
+ 
+	* src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java
+    Extracts  serial speed value and passes it to createCSession().
+  
+
 2003-10-29 Alain Magloire
 
 	Deal with PR 45533
Index: src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java,v
retrieving revision 1.4
diff -u -r1.4 GDBServerDebugger.java
--- src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java	11 Sep 2003 17:44:35 -0000	1.4
+++ src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java	6 Nov 2003 20:53:33 -0000
@@ -22,9 +22,14 @@
 import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager;
 import org.eclipse.cdt.debug.mi.core.cdi.Session;
 import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
+import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
+import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
+import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Preferences;
 import org.eclipse.debug.core.ILaunchConfiguration;
 
 public class GDBServerDebugger implements ICDebugger {
@@ -54,17 +59,40 @@
 		try {
 			String gdb = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
 			File cwd = exe.getProject().getLocation().toFile();
-			String remote;
+			String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
+			Session session = null;
 			if (config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false)) {
-				remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid");
+				String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid");
 				remote += ":";
 				remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid");
+				String[] args = new String[] {"remote", remote};
+				session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), 0, args, cwd, gdbinit);
 			} else {
-				remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid");
+				MIPlugin plugin = MIPlugin.getDefault();
+				Preferences prefs = plugin.getPluginPreferences();
+				int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
+
+				String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid");
+				String remoteBaud = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid");
+				session = (Session)MIPlugin.getDefault().createCSession(gdb, (File)null, cwd, gdbinit);
+				MISession miSession = session.getMISession();
+				CommandFactory factory = miSession.getCommandFactory();
+				MIGDBSet setRemoteBaud = factory.createMIGDBSet(new String[]{"remotebaud", remoteBaud});
+				// Set serial line parameters
+				miSession.postCommand(setRemoteBaud, launchTimeout);
+				MIInfo info = setRemoteBaud.getMIInfo();
+				if (info == null) {
+					session.terminate();
+					throw new MIException ("Can not set Baud");
+				}
+				MITargetSelect select = factory.createMITargetSelect(new String[] {"remote", remote});
+				miSession.postCommand(select, launchTimeout);
+				select.getMIInfo();
+				if (info == null) {
+					session.terminate();
+					throw new MIException ("No answer");
+				}
 			}
-			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;
 		} catch (IOException e) {
Index: src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java,v
retrieving revision 1.1
diff -u -r1.1 IGDBServerMILaunchConfigurationConstants.java
--- src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java	6 Apr 2003 01:07:15 -0000	1.1
+++ src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java	6 Nov 2003 20:53:33 -0000
@@ -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$
 }
Index: src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java,v
retrieving revision 1.41
diff -u -r1.41 EventManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java	18 Oct 2003 01:22:27 -0000	1.41
+++ src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java	6 Nov 2003 20:53:33 -0000
@@ -351,7 +351,6 @@
 				}
 				// A new Libraries loaded, try to set the breakpoints.
 				if (eventList.size() > 0) {
-					boolean breakpointSet = false;
 					ICDIBreakpointManager manager = session.getBreakpointManager();
 					if (manager instanceof BreakpointManager) {
 						BreakpointManager bpMgr = (BreakpointManager)manager;
@@ -458,7 +457,7 @@
 					} catch (MIException e) {
 					}
 				}
-				if (miLevel > 0) {
+				if (miLevel >= 0) {
 					MIStackSelectFrame selectFrame = factory.createMIStackSelectFrame(miLevel);
 					MIExecFinish finish = factory.createMIExecFinish();
 					try {

Back to the top