# HG changeset patch # User Ed Swartz # Date 1271880634 18000 # Node ID f3b387a17eb70888fcd45c7374696eebda9fd993 # Parent 2a211a55b277ee40ec128dc892ab85036df7b037 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it diff -r 2a211a55b277 -r f3b387a17eb7 debuggercdi/com.nokia.cdt.debug.common/META-INF/MANIFEST.MF --- 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 diff -r 2a211a55b277 -r f3b387a17eb7 debuggercdi/com.nokia.cdt.debug.common/plugin.xml --- 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 @@ + + diff -r 2a211a55b277 -r f3b387a17eb7 debuggercdi/com.nokia.cdt.debug.common/schema/launchDelegateConnectionExtension.exsd --- /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 @@ + + + + + + + + + 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 2a211a55b277 -r f3b387a17eb7 debuggercdi/com.nokia.cdt.debug.common/src/com/nokia/cdt/debug/common/internal/api/ILaunchDelegateConnectionExtension.java --- /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; + +} diff -r 2a211a55b277 -r f3b387a17eb7 debuggercdi/com.nokia.cdt.debug.cw.symbian/META-INF/MANIFEST.MF --- 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, diff -r 2a211a55b277 -r f3b387a17eb7 debuggercdi/com.nokia.cdt.debug.launch/plugin.xml --- 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"> @@ -237,20 +237,20 @@ @@ -316,11 +316,11 @@ @@ -464,5 +464,5 @@ - + diff -r 2a211a55b277 -r f3b387a17eb7 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 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 matches = new ArrayList(); for (int i = 0; i < configs.length; i++) { diff -r 2a211a55b277 -r f3b387a17eb7 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 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 } diff -r 2a211a55b277 -r f3b387a17eb7 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 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$ } /** diff -r 2a211a55b277 -r f3b387a17eb7 debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/NokiaAbstractLaunchDelegate.java --- 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$ diff -r 2a211a55b277 -r f3b387a17eb7 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 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; }; diff -r 2a211a55b277 -r f3b387a17eb7 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 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 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 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 2a211a55b277 -r f3b387a17eb7 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 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); }