Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
authorEd Swartz <ed.swartz@nokia.com>
Wed, 21 Apr 2010 15:10:34 -0500
changeset 1260 f3b387a17eb7
parent 1259 2a211a55b277
child 1264 076ad3096576
Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
debuggercdi/com.nokia.cdt.debug.common/META-INF/MANIFEST.MF
debuggercdi/com.nokia.cdt.debug.common/plugin.xml
debuggercdi/com.nokia.cdt.debug.common/schema/launchDelegateConnectionExtension.exsd
debuggercdi/com.nokia.cdt.debug.common/src/com/nokia/cdt/debug/common/internal/api/ILaunchDelegateConnectionExtension.java
debuggercdi/com.nokia.cdt.debug.cw.symbian/META-INF/MANIFEST.MF
debuggercdi/com.nokia.cdt.debug.launch/plugin.xml
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AttachLaunchDelegate.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/NokiaAbstractLaunchDelegate.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/TRKLaunchDelegate.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/TRKConnectionWizardPage.java
--- a/debuggercdi/com.nokia.cdt.debug.common/META-INF/MANIFEST.MF	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.common/META-INF/MANIFEST.MF	Wed Apr 21 15:10:34 2010 -0500
@@ -1,6 +1,6 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
-Bundle-Name: Carbide Common CDT Plugin
+Bundle-Name: Carbide Common CDT Debug Plugin
 Bundle-SymbolicName: com.nokia.cdt.debug.common;singleton:=true
 Bundle-Version: 1.0.0.qualifier
 Bundle-Activator: com.nokia.cdt.debug.common.CarbideCommonDebuggerPlugin
@@ -10,8 +10,10 @@
  org.eclipse.cdt.debug.core;bundle-version="7.0.0",
  org.eclipse.debug.core;bundle-version="3.6.0",
  com.nokia.carbide.cdt.builder;bundle-version="2.0.0",
- org.eclipse.cdt.debug.edc
+ org.eclipse.cdt.debug.edc,
+ com.nokia.carbide.remoteConnections;bundle-version="1.4.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
-Export-Package: com.nokia.cdt.debug.common.internal.source.lookup, 
- com.nokia.cdt.debug.common.internal.executables
+Export-Package: com.nokia.cdt.debug.common.internal.api,
+ com.nokia.cdt.debug.common.internal.executables,
+ com.nokia.cdt.debug.common.internal.source.lookup
--- a/debuggercdi/com.nokia.cdt.debug.common/plugin.xml	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.common/plugin.xml	Wed Apr 21 15:10:34 2010 -0500
@@ -37,4 +37,6 @@
       <provider class="com.nokia.cdt.debug.common.internal.executables.SymbianSourceFileRemappingFactory"/>
    </extension>
 
+   <extension-point id="launchDelegateConnectionExtension" name="Launch Delegate Connection Extension" schema="schema/launchDelegateConnectionExtension.exsd"/>
+
 </plugin>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debuggercdi/com.nokia.cdt.debug.common/schema/launchDelegateConnectionExtension.exsd	Wed Apr 21 15:10:34 2010 -0500
@@ -0,0 +1,107 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.nokia.cdt.debug.launch" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="com.nokia.cdt.debug.launch" id="launchDelegateExtension" name="Launch Delegate Extension"/>
+      </appInfo>
+      <documentation>
+         This extension allows customizing the startup and shutdown behavior of a launch for a specific remote connection type associated with the launch.
+
+Every extension is called for each launch.  Use the provided ILaunchConfiguration and IConnection arguments to filter for your purposes.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+         <documentation>
+            This extension allows for connection-specific launch behavior.  Launch delegates that use connections will typically only check for TRK and then launch.  You can add additional behavior to validate other things as well as clean up.
+         </documentation>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="delegate"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="delegate">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  This class implements behavior that is called after the remote connection is selected and after the session terminates.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn=":com.nokia.cdt.internal.debug.launch.ILaunchDelegateConnectionExtension"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         2.6
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiinfo"/>
+      </appInfo>
+      <documentation>
+         See com.nokia.cdt.internal.debug.launch.ILaunchWizardExtension
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debuggercdi/com.nokia.cdt.debug.common/src/com/nokia/cdt/debug/common/internal/api/ILaunchDelegateConnectionExtension.java	Wed Apr 21 15:10:34 2010 -0500
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+package com.nokia.cdt.debug.common.internal.api;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+
+import com.nokia.carbide.remoteconnections.interfaces.IConnection;
+import com.nokia.cdt.debug.common.CarbideCommonDebuggerPlugin;
+
+/**
+ * This extension augments a launch delegate's behavior.  Every extension is called for
+ * every connection-based launch; ignore the call if the connection is not relevant
+ * for your needs. 
+ * 
+ * Note: the extension instance is created once for each session.
+ */
+public interface ILaunchDelegateConnectionExtension {
+	String ID = CarbideCommonDebuggerPlugin.PLUGIN_ID + ".launchDelegateConnectionExtension"; //$NON-NLS-1$
+	
+	/** 
+	 * Initialize a connection for a run or debug launch after it has been selected (either it was
+	 * static or was selected by the user; you cannot influence the connection selector).
+	 * This is called before the connection is marked "in use".
+	 * @param launch
+	 * @param connection
+	 * @param monitor
+	 * @throws CoreException if the extension determines some problem with the
+	 * connection for this configuration
+	 */
+	void initializeConnection(ILaunch launch, IConnection connection, IProgressMonitor monitor) throws CoreException;
+
+	/**
+	 * Handle any work when the launch has started successfully.
+	 * @param launch
+	 * @param connection
+	 * @param monitor 
+	 * @throws CoreException
+	 */
+	void launchStarted(ILaunch launch, IConnection connection, IProgressMonitor monitor) throws CoreException; 
+	
+	/**
+	 * Terminate a connection for a launch after a session has completed.  This
+	 * is called before the connection is marked "not in use".
+	 * @param launch
+	 * @param connection
+	 * @param monitor
+	 * @throws CoreException if the extension encounters a failure terminating the connection
+	 */
+	void terminateConnection(ILaunch launch, IConnection connection, IProgressMonitor monitor) throws CoreException;
+
+}
--- a/debuggercdi/com.nokia.cdt.debug.cw.symbian/META-INF/MANIFEST.MF	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.cw.symbian/META-INF/MANIFEST.MF	Wed Apr 21 15:10:34 2010 -0500
@@ -34,7 +34,9 @@
    com.nokia.carbide.automation.utils,
    com.nokia.carbide.cpp.debug.crashdebugger,
    com.nokia.cdt.debug.cw.symbian.tests,
-   com.nokia.cdt.debug.launch",
+   com.nokia.cdt.debug.launch,
+   com.nokia.cdt.debug.launch.platSim,
+   com.nokia.cdt.debug.launch.platSim.stopMode",
  com.nokia.cdt.debug.cw.symbian.binaryparser;
   x-friends:="com.nokia.carbide.automation.smoke.test,
    com.nokia.carbide.automation.utils,
--- a/debuggercdi/com.nokia.cdt.debug.launch/plugin.xml	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/plugin.xml	Wed Apr 21 15:10:34 2010 -0500
@@ -179,7 +179,7 @@
             class="com.nokia.cdt.internal.debug.launch.PhoneLaunchShortcut"
             icon="icons/launch_config_file_16x16.png"
             id="com.nokia.cdt.debug.launch.symbianCPPShortcut.phone"
-            label="Symbian OS Phone Launch"
+            label="Symbian OS Phone or Simulator Launch"
             modes="run, debug">
          <contextualLaunch>
             <enablement>
@@ -237,20 +237,20 @@
                </with>
             </enablement>
             <contextLabel
-                  label="Run Symbian OS Application on Phone"
+                  label="Run Symbian OS Application on Phone or Simulator"
                   mode="run">
             </contextLabel>
             <contextLabel
-                  label="Debug Symbian OS Application on Phone"
+                  label="Debug Symbian OS Application on Phone or Simulator"
                   mode="debug">
             </contextLabel>
          </contextualLaunch>
          <description
-               description="Debugs on a phone using System TRK or Application TRK"
+               description="Debugs on a phone or simulator using System TRK or Application TRK"
                mode="debug">
          </description>
          <description
-               description="Runs on a phone using System TRK or Application TRK"
+               description="Runs on a phone or simulator using System TRK or Application TRK"
                mode="run">
          </description>
       </shortcut>
@@ -316,11 +316,11 @@
                </with>
             </enablement>
             <contextLabel
-                  label="Run Symbian OS Application on Reference Board"
+                  label="Run Symbian OS System on Reference Board"
                   mode="run">
             </contextLabel>
             <contextLabel
-                  label="Debug Symbian OS Application on Reference Board"
+                  label="Debug Symbian OS System on Reference Board"
                   mode="debug">
             </contextLabel>
          </contextualLaunch>
@@ -464,5 +464,5 @@
 
    <extension-point id="launchWizardExtension" name="Launch Wizard Page" schema="schema/launchWizardExtension.exsd"/>
    <extension-point id="launchCategoryExtension" name="Launch Category" schema="schema/launchCategoryExtension.exsd"/>
-
+
 </plugin>
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java	Wed Apr 21 15:10:34 2010 -0500
@@ -70,7 +70,7 @@
 
 		// launch an existing config if one exists
 		ILaunchConfiguration[] configs = getLaunchConfigurations(selection);
-		if (configs.length > 0) {
+		if (configs != null && configs.length > 0) {
 			// find all the ones that support the mode and shortcut (#11013)
 			List<ILaunchConfiguration> matches = new ArrayList<ILaunchConfiguration>();
 			for (int i = 0; i < configs.length; i++) {
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AttachLaunchDelegate.java	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AttachLaunchDelegate.java	Wed Apr 21 15:10:34 2010 -0500
@@ -170,7 +170,7 @@
 							}
 						}
 					}
-	    			hookSessionEnded();
+	    			hookSessionEnded(launch);
 				} else if (mode.equals(ILaunchManager.RUN_MODE)) {
 					// run mode not supported for attach
 				}
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java	Wed Apr 21 15:10:34 2010 -0500
@@ -99,11 +99,16 @@
 
 	public static final String EMULATION_LAUNCH_TYPE = "com.nokia.cdt.debug.launch.emulationLaunch"; //$NON-NLS-1$
 	public static final String PROXY_LAUNCH_TYPE = "com.nokia.cdt.debug.launch.proxyLaunch"; //$NON-NLS-1$
+	
+	public static final String REMOTE_CONNECTIONS_TRK_SERVICE = "com.nokia.carbide.trk.support.service.TRKService"; //$NON-NLS-1$
+	public static final String REMOTE_CONNECTIONS_TRACING_SERVICE = "com.nokia.carbide.trk.support.service.TracingService"; //$NON-NLS-1$
 
 	// Preference constants
 	public static final String Use_New_Project_Assist = "com.nokia.cdt.debug.launch.Use_New_Project_Assist"; //$NON-NLS-1$
 
 	
+
+	
 	/**
 	 * The constructor.
 	 */
@@ -596,7 +601,7 @@
 	
 	public static IService getTRKService() {
 		return RemoteConnectionsActivator.getConnectionTypeProvider().
-					findServiceByID("com.nokia.carbide.trk.support.service.TRKService"); //$NON-NLS-1$
+					findServiceByID(REMOTE_CONNECTIONS_TRK_SERVICE); //$NON-NLS-1$
 	}
 	
 	/**
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/NokiaAbstractLaunchDelegate.java	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/NokiaAbstractLaunchDelegate.java	Wed Apr 21 15:10:34 2010 -0500
@@ -37,6 +37,7 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.core.runtime.jobs.IJobManager;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.debug.core.ILaunchConfiguration;
@@ -155,7 +156,7 @@
 			// If a debug session is already running for the given launch
 			// configuration, don't allow user to start another session.
 			//
-			if (Session.preLaunchCheckForExistingTarget(configuration)) {
+			if (Session.preLaunchCheckForExistingTarget(configuration, new SubProgressMonitor(monitor, 0))) {
 				// Pop up a dialog telling user.
 				String cfgName = configuration.getName();
 				showMessage(LaunchMessages.getString("CarbideCPPLaunchDelegate.DebuggerName"), //$NON-NLS-1$
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java	Wed Apr 21 15:10:34 2010 -0500
@@ -22,8 +22,6 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.debug.core.ILaunchConfiguration;
 
-import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
-import com.nokia.carbide.remoteconnections.interfaces.IConnectionTypeProvider;
 import com.nokia.carbide.remoteconnections.interfaces.IService;
 import com.nokia.cdt.debug.cw.symbian.SettingsData;
 import com.nokia.cdt.internal.debug.launch.LaunchPlugin.ILaunchCreationWizardFactory;
@@ -47,8 +45,7 @@
 		LaunchPlugin.getDefault().launchProject(project, executable, defaultMMP, mode, 
 																new ILaunchCreationWizardFactory() {
 					public ILaunchCreationWizard createLaunchCreationWizard(LaunchOptions launchOptions) throws Exception {
-						IConnectionTypeProvider provider = RemoteConnectionsActivator.getConnectionTypeProvider();
-						IService trkService = provider.findServiceByID("com.nokia.carbide.trk.support.service.TRKService"); //$NON-NLS-1$
+						IService trkService = LaunchPlugin.getTRKService();
 						LaunchWizard launchWizard = new LaunchWizard(launchOptions, trkService);
 						return launchWizard;
 					};
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/TRKLaunchDelegate.java	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/TRKLaunchDelegate.java	Wed Apr 21 15:10:34 2010 -0500
@@ -17,20 +17,23 @@
 package com.nokia.cdt.internal.debug.launch;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.ICDebugConfiguration;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
 import org.eclipse.cdt.debug.core.cdi.ICDISession;
 import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.debug.core.DebugException;
@@ -55,6 +58,7 @@
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatusChangedListener;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
+import com.nokia.cdt.debug.common.internal.api.ILaunchDelegateConnectionExtension;
 import com.nokia.cdt.debug.cw.symbian.SettingsData;
 import com.nokia.cdt.debug.cw.symbian.SymbianPlugin;
 import com.nokia.cdt.internal.debug.launch.ui.PartialUpgradeAlertDialog;
@@ -67,13 +71,14 @@
 	private static final int LARGE_SIS_THRESHOLD = 250 * 1024; // 250K
 	
 	protected Session cwDebugSession;
-	private IConnection connection;
+	protected IConnection connection;
 	private IConnectionStatusChangedListener connectionStatusChangedListener;
+	private List<ILaunchDelegateConnectionExtension> connectionExtensions;
 	
 	public void launch(
 			ILaunchConfiguration 	config, 
-			String 					mode, 
-			ILaunch 				launch, 
+			final String 					mode, 
+			final ILaunch 				launch, 
 			IProgressMonitor monitor) throws CoreException 
 	{
 	// See comment at definition of the "mutex" for why this "synchronized".		
@@ -85,7 +90,7 @@
             monitor = new NullProgressMonitor();
         }
 
-        monitor.beginTask(LaunchMessages.getString("LocalRunLaunchDelegate.Launching_Local_C_Application"), 10); //$NON-NLS-1$
+        monitor.beginTask(LaunchMessages.getString("LocalRunLaunchDelegate.Launching_Local_C_Application"), 30); //$NON-NLS-1$
         // check for cancellation
         if (monitor.isCanceled()) {
             return;
@@ -101,8 +106,10 @@
 				LaunchMessages.getString("TRKLaunchDelegate.NoConnectionErrorMsg")); //$NON-NLS-1$
 			throw new DebugException(status);
 		}
+		
+		invokeConnectionSpecificSetup(launch, new SubProgressMonitor(monitor, 5));
+		
 		connection.useConnection(true);
-		
         try {
         	addBeingLaunched(config); // indicating the LC is being launched
         	
@@ -162,7 +169,7 @@
 
 					doAdditionalSessionSetup(cwDebugSession);
 					
-					IPath[] otherExecutables = getOtherExecutables(project, exePath, config, monitor);					
+					IPath[] otherExecutables = getOtherExecutables(project, exePath, config, new SubProgressMonitor(monitor, 1));					
 					{
 						try {
 							monitor.worked(1);
@@ -193,7 +200,7 @@
 						}
 					}
                 }
-                hookSessionEnded();
+                hookSessionEnded(launch);
             }
             else if (mode.equals(ILaunchManager.RUN_MODE)) {
                 // Run the program.
@@ -215,7 +222,7 @@
 										arguments, 
 										null, 
 										getEnvironmentAsProperty(config), 
-										monitor, 
+										new SubProgressMonitor(monitor, 8), 
 										project, 
 										"",  //$NON-NLS-1$
 										false  /* run instead of debug */);
@@ -233,7 +240,7 @@
 				
 				display.syncExec(new Runnable() {
 					public void run() {
-						connection.useConnection(false);
+						shutdownConnection(launch);
 						MessageDialog.openInformation(
 							CUIPlugin.getActiveWorkbenchShell(),
 							LaunchMessages.getString("CarbideCPPLaunchDelegate.DebuggerName"),  //$NON-NLS-1$
@@ -242,13 +249,15 @@
 					}
 				});
             }
+            
+            invokeConnectionSpecificPostLaunch(launch, new SubProgressMonitor(monitor, 5));
         } catch (CWException e) {
-       		connection.useConnection(false);
+        	shutdownConnection(launch);
        		unhookConnectionStatus();
         	if (! monitor.isCanceled()) // don't throw on user cancellation
         		e.printStackTrace();
 		} catch (CoreException e) {
-			connection.useConnection(false);
+			shutdownConnection(launch);
 			unhookConnectionStatus();
         	if (! monitor.isCanceled()) // don't throw on user cancellation
         		throw e;
@@ -259,12 +268,76 @@
 	} // end of synchronized.
 	}
 
-	protected void hookSessionEnded() {
+	protected void shutdownConnection(ILaunch launch) {
+		try {
+			invokeConnectionSpecificShutdown(launch, new NullProgressMonitor());
+		} catch (CoreException e) {
+			LaunchPlugin.log(e);
+		} finally {
+			connection.useConnection(false);
+		}
+	}
+
+	/** Create the extensions every session, in case they hold state. */
+	protected List<ILaunchDelegateConnectionExtension> getLaunchDelegateConnectionExtensions() {
+		if (connectionExtensions == null) {
+			connectionExtensions = new ArrayList<ILaunchDelegateConnectionExtension>();
+			IConfigurationElement[] elements =
+				Platform.getExtensionRegistry().getConfigurationElementsFor(ILaunchDelegateConnectionExtension.ID);
+			for (IConfigurationElement element : elements) {
+				try {
+					connectionExtensions.add((ILaunchDelegateConnectionExtension) element.createExecutableExtension("class"));
+				} catch (CoreException e) {
+					LaunchPlugin.log(e);
+				}
+			}
+		}
+		return connectionExtensions;
+	}
+	
+	protected void invokeConnectionSpecificSetup(ILaunch launch,
+			IProgressMonitor monitor) throws CoreException {
+		List<ILaunchDelegateConnectionExtension> extensions = getLaunchDelegateConnectionExtensions();
+		monitor.beginTask("", extensions.size());
+		for (ILaunchDelegateConnectionExtension extension : extensions) {
+			extension.initializeConnection(launch, connection, new SubProgressMonitor(monitor, 1));
+		}
+		monitor.done();
+	}
+	
+	protected void invokeConnectionSpecificPostLaunch(ILaunch launch,
+			IProgressMonitor monitor) throws CoreException {
+		List<ILaunchDelegateConnectionExtension> extensions = getLaunchDelegateConnectionExtensions();
+		monitor.beginTask("", extensions.size());
+		for (ILaunchDelegateConnectionExtension extension : extensions) {
+			extension.launchStarted(launch, connection, new SubProgressMonitor(monitor, 1));
+		}
+		monitor.done();
+	}
+	
+
+	protected void invokeConnectionSpecificShutdown(
+			ILaunch launch, IProgressMonitor monitor) throws CoreException {
+		List<ILaunchDelegateConnectionExtension> extensions = getLaunchDelegateConnectionExtensions();
+		monitor.beginTask("", extensions.size());
+		for (ILaunchDelegateConnectionExtension extension : extensions) {
+			extension.terminateConnection(launch, connection, new SubProgressMonitor(monitor, 1));
+		}
+		monitor.done();
+	}
+
+	protected void hookSessionEnded(final ILaunch launch) {
 		if (cwDebugSession != null) {
 			cwDebugSession.addListener(new ISessionListener() {
 				public void sessionEnded() {
-					connection.useConnection(false);
-					unhookConnectionStatus();
+					try {
+						invokeConnectionSpecificShutdown(launch, new NullProgressMonitor());
+					} catch (CoreException e) {
+						LaunchPlugin.log(e);
+					} finally {
+						connection.useConnection(false);
+						unhookConnectionStatus();
+					}
 				}
 			});
 		}
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/TRKConnectionWizardPage.java	Wed Apr 21 14:58:14 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/TRKConnectionWizardPage.java	Wed Apr 21 15:10:34 2010 -0500
@@ -72,7 +72,7 @@
         validatePage();
     }
     
-    void updateConfiguration(ILaunchConfigurationWorkingCopy config) {
+    public void updateConfiguration(ILaunchConfigurationWorkingCopy config) {
 		if (connectionId != null) {
 			config.setAttribute(RemoteConnectionsTRKHelper.CONNECTION_ATTRIBUTE, connectionId);
 		}