debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/TRKLaunchDelegate.java
author dadubrow
Thu, 20 May 2010 13:54:19 -0500
changeset 1378 9a387b0094c7
parent 1260 f3b387a17eb7
permissions -rw-r--r--
move p2 policy code to component definition in com.nokia.carbide.cpp product plugin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     1
/*
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     3
* All rights reserved.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     8
*
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    11
*
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    12
* Contributors:
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    13
*
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    14
* Description: 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    15
*
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    16
*/
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    17
package com.nokia.cdt.internal.debug.launch;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    18
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    19
import java.io.File;
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    20
import java.util.ArrayList;
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    21
import java.util.List;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    22
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    23
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    24
import org.eclipse.cdt.core.model.ICProject;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    25
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    26
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    27
import org.eclipse.cdt.debug.core.cdi.ICDISession;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    28
import org.eclipse.cdt.ui.CUIPlugin;
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    29
import org.eclipse.core.runtime.CoreException;
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    30
import org.eclipse.core.runtime.IConfigurationElement;
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    31
import org.eclipse.core.runtime.IPath;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    32
import org.eclipse.core.runtime.IProgressMonitor;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    33
import org.eclipse.core.runtime.IStatus;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    34
import org.eclipse.core.runtime.NullProgressMonitor;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    35
import org.eclipse.core.runtime.Path;
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    36
import org.eclipse.core.runtime.Platform;
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    37
import org.eclipse.core.runtime.Status;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    38
import org.eclipse.core.runtime.SubProgressMonitor;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    39
import org.eclipse.debug.core.DebugException;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    40
import org.eclipse.debug.core.ILaunch;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    41
import org.eclipse.debug.core.ILaunchConfiguration;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    42
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    43
import org.eclipse.debug.core.ILaunchManager;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    44
import org.eclipse.jface.dialogs.MessageDialog;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    45
import org.eclipse.swt.widgets.Display;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    46
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    47
import com.freescale.cdt.debug.cw.CWException;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    48
import com.freescale.cdt.debug.cw.core.RemoteConnectionsTRKHelper;
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    49
import com.freescale.cdt.debug.cw.core.cdi.ISessionListener;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    50
import com.freescale.cdt.debug.cw.core.cdi.Session;
94
d74b720418db Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
tzelaw
parents: 0
diff changeset
    51
import com.freescale.cdt.debug.cw.core.cdi.model.Target;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    52
import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    53
import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    54
import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    55
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    56
import com.nokia.carbide.remoteconnections.interfaces.IConnection;
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    57
import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    58
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    59
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatusChangedListener;
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    60
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    61
import com.nokia.cdt.debug.common.internal.api.ILaunchDelegateConnectionExtension;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    62
import com.nokia.cdt.debug.cw.symbian.SettingsData;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    63
import com.nokia.cdt.debug.cw.symbian.SymbianPlugin;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    64
import com.nokia.cdt.internal.debug.launch.ui.PartialUpgradeAlertDialog;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    65
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    66
import cwdbg.PreferenceConstants;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    67
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    68
public class TRKLaunchDelegate extends NokiaAbstractLaunchDelegate {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    69
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    70
	private static final String DONT_ASK_ABOUT_PARTIAL_UPGRADE_OPTION = "DONT_ASK_ABOUT_PARTIAL_UPGRADE_OPTION"; //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    71
	private static final int LARGE_SIS_THRESHOLD = 250 * 1024; // 250K
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    72
	
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    73
	protected Session cwDebugSession;
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    74
	protected IConnection connection;
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
    75
	private IConnectionStatusChangedListener connectionStatusChangedListener;
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    76
	private List<ILaunchDelegateConnectionExtension> connectionExtensions;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    77
	
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    78
	public void launch(
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    79
			ILaunchConfiguration 	config, 
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    80
			final String 					mode, 
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    81
			final ILaunch 				launch, 
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    82
			IProgressMonitor monitor) throws CoreException 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    83
	{
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    84
	// See comment at definition of the "mutex" for why this "synchronized".		
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    85
	synchronized(Session.sessionStartStopMutex()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    86
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    87
		cwDebugSession = null;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    88
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    89
		if (monitor == null) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    90
            monitor = new NullProgressMonitor();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    91
        }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    92
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
    93
        monitor.beginTask(LaunchMessages.getString("LocalRunLaunchDelegate.Launching_Local_C_Application"), 30); //$NON-NLS-1$
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    94
        // check for cancellation
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    95
        if (monitor.isCanceled()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    96
            return;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    97
        }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    98
		
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    99
        if (!RemoteConnectionsTRKHelper.configUsesConnectionAttribute(config)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   100
        	config = RemoteConnectionsTRKHelper.attemptUpdateLaunchConfiguration(config.getWorkingCopy());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   101
        }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   102
        
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   103
        connection = RemoteConnectionsTRKHelper.ensureConnectionFromConfig(config);
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   104
		if (connection == null) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   105
			IStatus status = new Status(Status.ERROR, LaunchPlugin.PLUGIN_ID, 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   106
				LaunchMessages.getString("TRKLaunchDelegate.NoConnectionErrorMsg")); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   107
			throw new DebugException(status);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   108
		}
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   109
		
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   110
		invokeConnectionSpecificSetup(launch, new SubProgressMonitor(monitor, 5));
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   111
		
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   112
		connection.useConnection(true);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   113
        try {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   114
        	addBeingLaunched(config); // indicating the LC is being launched
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   115
        	
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   116
            monitor.worked(1);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   117
            IPath exePath = verifyProgramPath(config);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   118
            ICProject project = verifyCProject(config);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   119
            IBinaryObject exeFile = verifyBinary(project, exePath);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   120
            String arguments[] = getProgramArgumentsArray(config);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   121
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   122
            // See comment for this method for more.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   123
            SettingsData.setInternalPreferences(config, SettingsData.LaunchConfig_AppTRK);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   124
            
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   125
            // set the partial upgrade pref value
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   126
            ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   127
            workingCopy.setAttribute(PreferenceConstants.J_PN_PUSisFileHostPath, ""); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   128
            
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   129
            String sisHostPath = config.getAttribute(PreferenceConstants.J_PN_SisFileHostPath, ""); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   130
            if (sisHostPath.length() > 0) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   131
            	// app trk launch - see if there's a partial upgrade sis file
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   132
            	IPath sisPath = new Path(sisHostPath);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   133
            	String buildConfigName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   134
				if (buildConfigName.length() > 0) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   135
			        ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project.getProject());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   136
			        if (cpi != null) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   137
			        	for (ICarbideBuildConfiguration buildConfig : cpi.getBuildConfigurations()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   138
			        		if (buildConfig.getDisplayString().equals(buildConfigName)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   139
								IPath puSisPath = CarbideCPPBuilder.getPartialUpgradeSisPath(buildConfig, sisPath);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   140
								if (puSisPath != null && puSisPath.toFile().exists()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   141
									workingCopy.setAttribute(PreferenceConstants.J_PN_PUSisFileHostPath, puSisPath.toOSString());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   142
								}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   143
								break;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   144
			        		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   145
			        	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   146
			        }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   147
				}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   148
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   149
            
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   150
            // save the changes
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   151
            workingCopy.doSave();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   152
                        
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   153
            // set the default source locator if required
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   154
            setDefaultSourceLocator(launch, config);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   155
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   156
            if (mode.equals(ILaunchManager.DEBUG_MODE)) {
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   157
        		hookConnectionStatus();
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   158
               // debug mode
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   159
                ICDebugConfiguration debugConfig = getDebugConfig(config);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   160
                ICDISession dsession = null;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   161
                String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   162
                        ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   163
                if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   164
                    dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile,
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   165
                            new SubProgressMonitor(monitor, 8));
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   166
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   167
					assert(dsession instanceof Session);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   168
					cwDebugSession = (Session)dsession;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   169
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   170
					doAdditionalSessionSetup(cwDebugSession);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   171
					
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   172
					IPath[] otherExecutables = getOtherExecutables(project, exePath, config, new SubProgressMonitor(monitor, 1));					
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   173
					{
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   174
						try {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   175
							monitor.worked(1);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   176
							
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   177
							// if enabled in the prefs, show the console view(s)
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   178
							if (config.getAttribute(PreferenceConstants.J_PN_ViewUnframedData, false)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   179
								SymbianPlugin.getDefault().openUnframedDataConsole(true);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   180
							}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   181
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   182
							if (config.getAttribute(PreferenceConstants.J_PN_ViewCommMessages, false)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   183
								SymbianPlugin.getDefault().openTRKCommLogConsole(true);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   184
							}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   185
							
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   186
							config = synchronizeWithProjectAccessPaths(project, config);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   187
							
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   188
							File wd = getWorkingDirectory(config);
94
d74b720418db Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
tzelaw
parents: 0
diff changeset
   189
							Target target = cwDebugSession.launchExecutable(launch, config, exeFile, otherExecutables, arguments, wd, getEnvironmentAsProperty(config), monitor, project, getTargetLabel(exeFile.getName()), true);
d74b720418db Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
tzelaw
parents: 0
diff changeset
   190
							ATFLaunchSupport.saveDebugTargetFromLaunchDelegate(target.getCoreModelTarget());
d74b720418db Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
tzelaw
parents: 0
diff changeset
   191
							
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   192
						} catch (CoreException e) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   193
							Session session = (Session)dsession;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   194
							session.cleanupAfterLaunchFailure();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   195
							throw e;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   196
						} catch (Exception e) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   197
							Session session = (Session)dsession;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   198
							session.debuggingStopped(null);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   199
							this.abort(e.getLocalizedMessage(), null, 0);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   200
						}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   201
					}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   202
                }
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   203
                hookSessionEnded(launch);
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   204
            }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   205
            else if (mode.equals(ILaunchManager.RUN_MODE)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   206
                // Run the program.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   207
            	// Connect to DE, download and launch the program, close debug session.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   208
                ICDebugConfiguration debugConfig = getDebugConfig(config);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   209
                ICDISession dsession = null;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   210
                
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   211
                // Set up communication with DE.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   212
                dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile,
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   213
                            new SubProgressMonitor(monitor, 8));
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   214
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   215
                // Launch the program through the DE.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   216
                cwDebugSession = (Session)dsession;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   217
				cwDebugSession.launchExecutable(
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   218
										launch, 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   219
										config, 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   220
										exeFile, 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   221
										new IPath[0], 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   222
										arguments, 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   223
										null, 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   224
										getEnvironmentAsProperty(config), 
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   225
										new SubProgressMonitor(monitor, 8), 
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   226
										project, 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   227
										"",  //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   228
										false  /* run instead of debug */);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   229
				
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   230
				// The above call would throw exception on error. So it must have succeeded 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   231
				// if control gets here. Show success message in a dialog.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   232
	    		//
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   233
	    		// get the name of the executable that's launched instead of, say, the DLL name if
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   234
	    		// exeFile is a DLL.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   235
	    		final String exeLaunched = config.getAttribute(PreferenceConstants.J_PN_RemoteProcessToLaunch, exeFile.toString());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   236
				Display display = Display.getCurrent();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   237
				if (display == null) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   238
					display = Display.getDefault();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   239
				}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   240
				
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   241
				display.syncExec(new Runnable() {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   242
					public void run() {
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   243
						shutdownConnection(launch);
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   244
						MessageDialog.openInformation(
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   245
							CUIPlugin.getActiveWorkbenchShell(),
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   246
							LaunchMessages.getString("CarbideCPPLaunchDelegate.DebuggerName"),  //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   247
							LaunchMessages.getString("TRKLaunchDelegate.runSucceed") + //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   248
						           "\n\t\"" + exeLaunched + "\""); //$NON-NLS-1$ //$NON-NLS-2$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   249
					}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   250
				});
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   251
            }
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   252
            
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   253
            invokeConnectionSpecificPostLaunch(launch, new SubProgressMonitor(monitor, 5));
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   254
        } catch (CWException e) {
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   255
        	shutdownConnection(launch);
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   256
       		unhookConnectionStatus();
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   257
        	if (! monitor.isCanceled()) // don't throw on user cancellation
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   258
        		e.printStackTrace();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   259
		} catch (CoreException e) {
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   260
			shutdownConnection(launch);
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   261
			unhookConnectionStatus();
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   262
        	if (! monitor.isCanceled()) // don't throw on user cancellation
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   263
        		throw e;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   264
		} finally {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   265
            monitor.done();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   266
            removeBeingLaunched(config);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   267
        }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   268
	} // end of synchronized.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   269
	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   270
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   271
	protected void shutdownConnection(ILaunch launch) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   272
		try {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   273
			invokeConnectionSpecificShutdown(launch, new NullProgressMonitor());
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   274
		} catch (CoreException e) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   275
			LaunchPlugin.log(e);
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   276
		} finally {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   277
			connection.useConnection(false);
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   278
		}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   279
	}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   280
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   281
	/** Create the extensions every session, in case they hold state. */
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   282
	protected List<ILaunchDelegateConnectionExtension> getLaunchDelegateConnectionExtensions() {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   283
		if (connectionExtensions == null) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   284
			connectionExtensions = new ArrayList<ILaunchDelegateConnectionExtension>();
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   285
			IConfigurationElement[] elements =
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   286
				Platform.getExtensionRegistry().getConfigurationElementsFor(ILaunchDelegateConnectionExtension.ID);
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   287
			for (IConfigurationElement element : elements) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   288
				try {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   289
					connectionExtensions.add((ILaunchDelegateConnectionExtension) element.createExecutableExtension("class"));
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   290
				} catch (CoreException e) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   291
					LaunchPlugin.log(e);
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   292
				}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   293
			}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   294
		}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   295
		return connectionExtensions;
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   296
	}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   297
	
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   298
	protected void invokeConnectionSpecificSetup(ILaunch launch,
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   299
			IProgressMonitor monitor) throws CoreException {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   300
		List<ILaunchDelegateConnectionExtension> extensions = getLaunchDelegateConnectionExtensions();
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   301
		monitor.beginTask("", extensions.size());
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   302
		for (ILaunchDelegateConnectionExtension extension : extensions) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   303
			extension.initializeConnection(launch, connection, new SubProgressMonitor(monitor, 1));
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   304
		}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   305
		monitor.done();
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   306
	}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   307
	
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   308
	protected void invokeConnectionSpecificPostLaunch(ILaunch launch,
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   309
			IProgressMonitor monitor) throws CoreException {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   310
		List<ILaunchDelegateConnectionExtension> extensions = getLaunchDelegateConnectionExtensions();
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   311
		monitor.beginTask("", extensions.size());
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   312
		for (ILaunchDelegateConnectionExtension extension : extensions) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   313
			extension.launchStarted(launch, connection, new SubProgressMonitor(monitor, 1));
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   314
		}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   315
		monitor.done();
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   316
	}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   317
	
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   318
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   319
	protected void invokeConnectionSpecificShutdown(
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   320
			ILaunch launch, IProgressMonitor monitor) throws CoreException {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   321
		List<ILaunchDelegateConnectionExtension> extensions = getLaunchDelegateConnectionExtensions();
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   322
		monitor.beginTask("", extensions.size());
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   323
		for (ILaunchDelegateConnectionExtension extension : extensions) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   324
			extension.terminateConnection(launch, connection, new SubProgressMonitor(monitor, 1));
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   325
		}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   326
		monitor.done();
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   327
	}
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   328
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   329
	protected void hookSessionEnded(final ILaunch launch) {
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   330
		if (cwDebugSession != null) {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   331
			cwDebugSession.addListener(new ISessionListener() {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   332
				public void sessionEnded() {
1260
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   333
					try {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   334
						invokeConnectionSpecificShutdown(launch, new NullProgressMonitor());
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   335
					} catch (CoreException e) {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   336
						LaunchPlugin.log(e);
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   337
					} finally {
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   338
						connection.useConnection(false);
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   339
						unhookConnectionStatus();
f3b387a17eb7 Merge PlatSim changes from 2.x, but move ILaunchDelegateConnectionExtension into com.nokia.cdt.debug.common so EDC can use it
Ed Swartz <ed.swartz@nokia.com>
parents: 772
diff changeset
   340
					}
772
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   341
				}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   342
			});
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   343
		}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   344
	}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   345
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   346
	protected void hookConnectionStatus() {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   347
		if (connection instanceof IConnection2) {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   348
			connectionStatusChangedListener = new IConnectionStatusChangedListener() {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   349
				public void statusChanged(IConnectionStatus status) {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   350
					if (status.getEConnectionStatus().equals(EConnectionStatus.IN_USE_DISCONNECTED)) {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   351
						try {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   352
							cwDebugSession.getLaunch().terminate();
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   353
						} catch (Exception e) {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   354
							LaunchPlugin.log(e);
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   355
						}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   356
					}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   357
				}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   358
			};
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   359
			((IConnection2) connection).addStatusChangedListener(connectionStatusChangedListener);
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   360
		}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   361
	}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   362
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   363
	protected void unhookConnectionStatus() {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   364
		if (connection instanceof IConnection2 && connectionStatusChangedListener != null) {
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   365
			((IConnection2) connection).removeStatusChangedListener(connectionStatusChangedListener);
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   366
		}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   367
	}
c3301e21f173 terminate the debug session when connection becomes disconnected
dadubrow
parents: 728
diff changeset
   368
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   369
	@Override
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   370
	public boolean buildForLaunch(final ILaunchConfiguration configuration,
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   371
			String mode, IProgressMonitor monitor) throws CoreException {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   372
		// for app trk, check to see if we need to ask the user if they want to enable
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   373
		// partial upgrade builds
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   374
        String sisHostPath = configuration.getAttribute(PreferenceConstants.J_PN_SisFileHostPath, ""); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   375
        if (sisHostPath.length() > 0) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   376
        	// app trk launch - see if the partial upgrade option is enabled
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   377
        	IPath sisPath = new Path(sisHostPath);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   378
        	String buildConfigName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   379
			if (buildConfigName.length() > 0) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   380
	            final ICProject project = verifyCProject(configuration);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   381
		        ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project.getProject());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   382
		        if (cpi != null) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   383
		        	for (ICarbideBuildConfiguration buildConfig : cpi.getBuildConfigurations()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   384
		        		if (buildConfig.getDisplayString().equals(buildConfigName)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   385
							if (null == CarbideCPPBuilder.getPartialUpgradeSisPath(buildConfig, sisPath)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   386
								if (!configuration.getAttribute(DONT_ASK_ABOUT_PARTIAL_UPGRADE_OPTION, false)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   387
									// get the size of the sis file if it exists
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   388
									File sisFile = sisPath.toFile();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   389
									if (sisFile.exists() && sisFile.length() > LARGE_SIS_THRESHOLD) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   390
										// it's larger than the threshold so present dialog.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   391
										
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   392
										Display.getDefault().syncExec(new Runnable() {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   393
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   394
											public void run() {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   395
												PartialUpgradeAlertDialog dlg = new PartialUpgradeAlertDialog(CUIPlugin.getActiveWorkbenchShell(), project.getProject());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   396
												dlg.open();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   397
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   398
												// if they check the option then remember it
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   399
												if (dlg.dontAskAgain()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   400
										            try {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   401
										            	ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   402
														workingCopy.setAttribute(DONT_ASK_ABOUT_PARTIAL_UPGRADE_OPTION, true);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   403
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   404
														// save the changes
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   405
											            workingCopy.doSave();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   406
													} catch (CoreException e) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   407
														e.printStackTrace();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   408
														LaunchPlugin.log(e);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   409
													}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   410
												}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   411
											}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   412
										});
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   413
									}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   414
								}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   415
							}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   416
							break;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   417
		        		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   418
		        	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   419
		        }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   420
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   421
		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   422
		
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   423
		
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   424
		return super.buildForLaunch(configuration, mode, monitor);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   425
	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   426
}