# HG changeset patch # User Ed Swartz # Date 1271795761 18000 # Node ID 0e45b6356eac45a899d7f3bfff34dfafd53a74f1 # Parent 174c8b7f4dff5e528677dfd34928f3d85b17ee7a Initial pass getting PlatSim connections to work in App/Sys TRK configurations. Add extension for TRK launch delegate for PlatSim-specific behavior. diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.cw.symbian/META-INF/MANIFEST.MF --- a/debuggercdi/com.nokia.cdt.debug.cw.symbian/META-INF/MANIFEST.MF Tue Apr 20 14:10:08 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.cw.symbian/META-INF/MANIFEST.MF Tue Apr 20 15:36:01 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, diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/plugin.xml --- a/debuggercdi/com.nokia.cdt.debug.launch/plugin.xml Tue Apr 20 14:10:08 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/plugin.xml Tue Apr 20 15:36:01 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"> @@ -237,20 +237,20 @@ @@ -316,11 +316,11 @@ @@ -464,5 +464,6 @@ - + + diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/schema/launchDelegateConnectionExtension.exsd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/schema/launchDelegateConnectionExtension.exsd Tue Apr 20 15:36:01 2010 -0500 @@ -0,0 +1,107 @@ + + + + + + + + + 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. + + + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This class implements behavior that is called after the remote connection is selected and after the session terminates. + + + + + + + + + + + + + + + 2.6 + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + See com.nokia.cdt.internal.debug.launch.ILaunchWizardExtension + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java Tue Apr 20 14:10:08 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java Tue Apr 20 15:36:01 2010 -0500 @@ -68,7 +68,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 matches = new ArrayList(); for (int i = 0; i < configs.length; i++) { diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AttachLaunchDelegate.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AttachLaunchDelegate.java Tue Apr 20 14:10:08 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AttachLaunchDelegate.java Tue Apr 20 15:36:01 2010 -0500 @@ -170,7 +170,7 @@ } } } - hookSessionEnded(); + hookSessionEnded(launch); } else if (mode.equals(ILaunchManager.RUN_MODE)) { // run mode not supported for attach } diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ILaunchDelegateConnectionExtension.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ILaunchDelegateConnectionExtension.java Tue Apr 20 15:36:01 2010 -0500 @@ -0,0 +1,67 @@ +/* +* 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.internal.debug.launch; + +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; + +/** + * 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 = LaunchPlugin.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; + +} diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java Tue Apr 20 14:10:08 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java Tue Apr 20 15:36:01 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$ } /** diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java Tue Apr 20 14:10:08 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java Tue Apr 20 15:36:01 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; }; diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/TRKLaunchDelegate.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/TRKLaunchDelegate.java Tue Apr 20 14:10:08 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/TRKLaunchDelegate.java Tue Apr 20 15:36:01 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; @@ -67,13 +70,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 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 +89,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 +105,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 +168,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 +199,7 @@ } } } - hookSessionEnded(); + hookSessionEnded(launch); } else if (mode.equals(ILaunchManager.RUN_MODE)) { // Run the program. @@ -215,7 +221,7 @@ arguments, null, getEnvironmentAsProperty(config), - monitor, + new SubProgressMonitor(monitor, 8), project, "", //$NON-NLS-1$ false /* run instead of debug */); @@ -233,7 +239,13 @@ display.syncExec(new Runnable() { public void run() { - connection.useConnection(false); + try { + invokeConnectionSpecificShutdown(launch, new NullProgressMonitor()); + } catch (CoreException e) { + LaunchPlugin.log(e); + } finally { + connection.useConnection(false); + } MessageDialog.openInformation( CUIPlugin.getActiveWorkbenchShell(), LaunchMessages.getString("CarbideCPPLaunchDelegate.DebuggerName"), //$NON-NLS-1$ @@ -242,6 +254,8 @@ } }); } + + invokeConnectionSpecificPostLaunch(launch, new SubProgressMonitor(monitor, 5)); } catch (CWException e) { connection.useConnection(false); unhookConnectionStatus(); @@ -259,12 +273,66 @@ } // end of synchronized. } - protected void hookSessionEnded() { + /** Create the extensions every session, in case they hold state. */ + protected List getLaunchDelegateConnectionExtensions() { + if (connectionExtensions == null) { + connectionExtensions = new ArrayList(); + 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 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 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 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(); + } } }); } diff -r 174c8b7f4dff -r 0e45b6356eac debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/TRKConnectionWizardPage.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/TRKConnectionWizardPage.java Tue Apr 20 14:10:08 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/TRKConnectionWizardPage.java Tue Apr 20 15:36:01 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); }