Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-debug-dev] CDT embedded targets patch

In the past I've mutilated CDT to support my embedded targets. 

However, as the CDT code has evolved, the changes have become more
benign to the point where it just might be possible to formulate a
palatable patch.

Are we there yet?

In the attached patch, I've introduced a new launch mode "idle". This is
the default mode in which GDB is launched, i.e. it is not attached to a
running process or a target, but simply waiting for further instructions
from the user.

The really cool thing with idle, is that the user can manually type in
the commands in the GDB console to attach to the target. Automating the
connection/launching of the target at the cost of making manual entry of
the commands more difficult or less obvious is a Bad Idea for embedded
targets.


'nuff said.


I intend to update my web-page with a binary build of the patch RSN:

http://www.zylin.com/opensource.html


-- 
Øyvind Harboe
http://www.zylin.com

Index: src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java,v
retrieving revision 1.8
diff -u -r1.8 ICDTLaunchConfigurationConstants.java
--- src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java	25 Jun 2004 14:47:07 -0000	1.8
+++ src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java	26 Jul 2004 08:32:02 -0000
@@ -115,6 +115,14 @@
 
 	/**
 	 * Launch configuration attribute value. The key is ATTR_DEBUGGER_START_MODE.
+	 * Startup debugger in idle mode. I.e. not attached, running or connected.
+	 * Typically used for embedded targets where connection to target happens manually.
+	 */
+	public static String DEBUGGER_MODE_IDLE = "idle"; //$NON-NLS-1$
+
+	
+	/**
+	 * Launch configuration attribute value. The key is ATTR_DEBUGGER_START_MODE.
 	 * Startup debugger and attach to running process.
 	 */
 	public static String DEBUGGER_MODE_ATTACH = "attach"; //$NON-NLS-1$
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/plugin.properties,v
retrieving revision 1.7
diff -u -r1.7 plugin.properties
--- plugin.properties	25 Jun 2004 14:46:48 -0000	1.7
+++ plugin.properties	26 Jul 2004 08:32:14 -0000
@@ -14,3 +14,4 @@
 GDBDebugger.name=GDB Debugger
 CygwinGDBDebugger.name=Cygwin GDB Debugger
 GDBServer.name=GDB Server
+NonNativeGDB.name=Non-native GDB
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/plugin.xml,v
retrieving revision 1.24
diff -u -r1.24 plugin.xml
--- plugin.xml	15 Jul 2004 15:54:13 -0000	1.24
+++ plugin.xml	26 Jul 2004 08:32:14 -0000
@@ -47,6 +47,14 @@
             class="org.eclipse.cdt.debug.mi.core.GDBServerDebugger"
             id="org.eclipse.cdt.debug.mi.core.GDBServerCDebugger">
       </debugger>
+      <debugger
+            platform="*"
+			cpu="*"
+            name="%NonNativeGDB.name"
+            modes="idle"
+            class="org.eclipse.cdt.debug.mi.core.GDBDebugger"
+            id="org.eclipse.cdt.debug.mi.core.CDebugger">
+      </debugger>
    </extension>
 
 </plugin>
Index: cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java,v
retrieving revision 1.5
diff -u -r1.5 Target.java
--- cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java	9 Jul 2004 17:54:39 -0000	1.5
+++ cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java	26 Jul 2004 08:32:15 -0000
@@ -335,18 +335,20 @@
 	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#restart()
 	 */
 	public void restart() throws CDIException {
-		MISession mi = session.getMISession();
-		CommandFactory factory = mi.getCommandFactory();
-		MIExecRun run = factory.createMIExecRun(new String[0]);
-		lastExecutionCommand = run;
-		try {
-			mi.postCommand(run);
-			MIInfo info = run.getMIInfo();
-			if (info == null) {
-				throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
+		if (false) {
+			MISession mi = session.getMISession();
+			CommandFactory factory = mi.getCommandFactory();
+			MIExecRun run = factory.createMIExecRun(new String[0]);
+			lastExecutionCommand = run;
+			try {
+				mi.postCommand(run);
+				MIInfo info = run.getMIInfo();
+				if (info == null) {
+					throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
+				}
+			} catch (MIException e) {
+				throw new MI2CDIException(e);
 			}
-		} catch (MIException e) {
-			throw new MI2CDIException(e);
 		}
 	}
 
Index: src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java,v
retrieving revision 1.26
diff -u -r1.26 CApplicationLaunchShortcut.java
--- src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java	14 Jul 2004 15:44:22 -0000	1.26
+++ src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java	26 Jul 2004 08:32:29 -0000
@@ -119,7 +119,8 @@
 			String os = Platform.getOS();
 			for (int i = 0; i < debugConfigs.length; i++) {
 				String platform = debugConfigs[i].getPlatform();
-				if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
+				if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)||
+						debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_IDLE)) {
 					if (platform.equals("*") || platform.equals(os)) { //$NON-NLS-1$
 						if (debugConfigs[i].supportsCPU(programCPU)) 
 							debugList.add(debugConfigs[i]);
Index: src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java,v
retrieving revision 1.35
diff -u -r1.35 LocalCLaunchConfigurationDelegate.java
--- src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java	21 Jul 2004 20:06:41 -0000	1.35
+++ src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java	26 Jul 2004 08:32:29 -0000
@@ -85,7 +85,8 @@
 					config.getAttribute(
 						ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
 						ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
-				if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
+				if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)||
+						debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_IDLE)) {
 					dsession = debugConfig.getDebugger().createLaunchSession(config, exeFile);
 					ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
 					opt.setArguments(getProgramArgumentsArray(config));
Index: src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties,v
retrieving revision 1.8
diff -u -r1.8 LaunchUIPluginResources.properties
--- src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties	15 Jul 2004 02:38:03 -0000	1.8
+++ src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties	26 Jul 2004 08:32:29 -0000
@@ -89,6 +89,7 @@
 
 CDebuggerTab.Run_program_in_debugger=Run program in debugger.
 CDebuggerTab.Attach_to_running_process=Attach to running process.
+CDebuggerTab.Idle_Debugger=Idle debugger.
 CDebuggerTab.Stop_at_main_on_startup=Stop at main() on startup.
 CDebuggerTab.Automatically_track_values_of_variables=Automatically track the values of variables.
 CDebuggerTab.Debugger_Options=Debugger Options
Index: src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java,v
retrieving revision 1.33
diff -u -r1.33 CDebuggerTab.java
--- src/org/eclipse/cdt/launch/ui/CDebuggerTab.java	15 Jul 2004 02:38:03 -0000	1.33
+++ src/org/eclipse/cdt/launch/ui/CDebuggerTab.java	26 Jul 2004 08:32:30 -0000
@@ -42,6 +42,7 @@
 	protected Combo fDCombo;
 	protected Button fStopInMain;
 	protected Button fAttachButton;
+	protected Button fIdleButton;
 	protected Button fRunButton;
 	protected Button fVarBookKeeping;
 
@@ -96,6 +97,13 @@
 				updateLaunchConfigurationDialog();
 			}
 		});
+		fIdleButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Idle_Debugger")); //$NON-NLS-1$
+		fIdleButton.addSelectionListener(new SelectionAdapter() {
+
+			public void widgetSelected(SelectionEvent e) {
+				updateLaunchConfigurationDialog();
+			}
+		});
 
 		Composite optionComp = new Composite(comp, SWT.NONE);
 		layout = new GridLayout(2, false);
@@ -158,6 +166,7 @@
 		int selndx = -1;
 		for (int i = 0; i < debugConfigs.length; i++) {
 			if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
+					|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_IDLE)
 					|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
 				String debuggerPlatform = debugConfigs[i].getPlatform();
 				if (debuggerPlatform.equalsIgnoreCase(configPlatform)
@@ -198,6 +207,8 @@
 			fRunButton.setSelection(false);
 			fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
 			fAttachButton.setSelection(false);
+			fIdleButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_IDLE));
+			fIdleButton.setSelection(false);
 			try {
 				String mode = getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
 						ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
@@ -205,6 +216,8 @@
 					fRunButton.setSelection(true);
 				} else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH) && fAttachButton.isEnabled()) {
 					fAttachButton.setSelection(true);
+				} else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_IDLE) && fIdleButton.isEnabled()) {
+					fIdleButton.setSelection(true);
 				}
 				if (fRunButton.getSelection() == true) {
 					fStopInMain.setEnabled(true);
@@ -241,12 +254,19 @@
 			loadDebuggerComboBox(config, id);
 			String mode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
 					ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
-			if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
+			if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)||
+					mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_IDLE)) {
 				fRunButton.setSelection(true);
 				fAttachButton.setSelection(false);
+				fIdleButton.setSelection(false);
 			} else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
 				fAttachButton.setSelection(true);
 				fRunButton.setSelection(false);
+				fIdleButton.setSelection(false);
+			} else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_IDLE)) {
+				fAttachButton.setSelection(false);
+				fRunButton.setSelection(false);
+				fIdleButton.setSelection(true);
 			}
 			if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, DEFAULT_STOP_AT_MAIN) == true) {
 				fStopInMain.setSelection(true);
@@ -268,6 +288,9 @@
 			if (fAttachButton.getSelection() == true) {
 				config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
 						ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
+			} else if (fIdleButton.getSelection() == true) {
+				config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+						ICDTLaunchConfigurationConstants.DEBUGGER_MODE_IDLE);
 			} else {
 				config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
 				config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
@@ -284,7 +307,7 @@
 		if (super.isValid(config) == false) {
 			return false;
 		}
-		if (!fRunButton.getSelection() && !fAttachButton.getSelection()) {
+		if (!fRunButton.getSelection() && !fAttachButton.getSelection() && !fIdleButton.getSelection()) {
 			setErrorMessage(LaunchUIPlugin.getResourceString("CDebuggerTab.Select_Debug_mode")); //$NON-NLS-1$
 			return false;
 		}

Back to the top