cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
author cawthron
Wed, 29 Jul 2009 14:30:25 -0500
changeset 37 c2bce6dd59e7
child 47 4c12a1ced0aa
permissions -rw-r--r--
add cdt_6_0_x
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     1
/*******************************************************************************
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2005, 2008 QNX Software Systems and others.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     3
 * All rights reserved. This program and the accompanying materials
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     4
 * are made available under the terms of the Eclipse Public License v1.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     5
 * which accompanies this distribution, and is available at
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     6
 * http://www.eclipse.org/legal/epl-v10.html
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     7
 *
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     8
 * Contributors:
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     9
 *     QNX Software Systems - initial API and implementation
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    10
 *     Andrew Ferguson (andrew.ferguson@arm.com) - bug 123997
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    11
 *     Ken Ryall (Nokia) - bug 178731
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    12
 *     Anton Leherbauer (Wind River Systems) - bug 224187
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    13
 *******************************************************************************/
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    14
package org.eclipse.cdt.launch;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    15
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    16
import java.io.File;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    17
import java.io.FileNotFoundException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    18
import java.util.ArrayList;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    19
import java.util.Arrays;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    20
import java.util.Date;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    21
import java.util.HashMap;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    22
import java.util.HashSet;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    23
import java.util.Iterator;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    24
import java.util.List;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    25
import java.util.Map;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    26
import java.util.Properties;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    27
import java.util.Map.Entry;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    28
import java.util.concurrent.atomic.AtomicBoolean;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    29
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    30
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    31
import org.eclipse.cdt.core.model.ICModelMarker;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    32
import org.eclipse.cdt.core.model.ICProject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    33
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    34
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    35
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    36
import org.eclipse.cdt.debug.core.CDebugUtils;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    37
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    38
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    39
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    40
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    41
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    42
import org.eclipse.cdt.ui.newui.CDTPropertyManager;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    43
import org.eclipse.core.resources.IContainer;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    44
import org.eclipse.core.resources.IFile;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    45
import org.eclipse.core.resources.IMarker;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    46
import org.eclipse.core.resources.IProject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    47
import org.eclipse.core.resources.IResource;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    48
import org.eclipse.core.resources.IWorkspace;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    49
import org.eclipse.core.resources.IncrementalProjectBuilder;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    50
import org.eclipse.core.resources.ResourcesPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    51
import org.eclipse.core.runtime.CoreException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    52
import org.eclipse.core.runtime.IPath;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    53
import org.eclipse.core.runtime.IProgressMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    54
import org.eclipse.core.runtime.IStatus;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    55
import org.eclipse.core.runtime.MultiStatus;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    56
import org.eclipse.core.runtime.NullProgressMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    57
import org.eclipse.core.runtime.Path;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    58
import org.eclipse.core.runtime.Status;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    59
import org.eclipse.core.runtime.SubProgressMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    60
import org.eclipse.core.runtime.jobs.Job;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    61
import org.eclipse.debug.core.DebugPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    62
import org.eclipse.debug.core.ILaunch;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    63
import org.eclipse.debug.core.ILaunchConfiguration;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    64
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    65
import org.eclipse.debug.core.ILaunchManager;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    66
import org.eclipse.debug.core.IStatusHandler;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    67
import org.eclipse.debug.core.Launch;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    68
import org.eclipse.debug.core.model.IPersistableSourceLocator;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    69
import org.eclipse.debug.core.model.IProcess;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    70
import org.eclipse.debug.core.model.ISourceLocator;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    71
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    72
import org.eclipse.debug.ui.RefreshTab;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    73
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    74
import com.ibm.icu.text.DateFormat;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    75
import com.ibm.icu.text.MessageFormat;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    76
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    77
abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegate {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    78
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    79
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    80
	 * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    81
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    82
    public class CLaunch extends Launch {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    83
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    84
        private final AtomicBoolean fRefreshDone;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    85
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    86
        public CLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    87
            super(launchConfiguration, mode, locator);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    88
            fRefreshDone = new AtomicBoolean(false);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    89
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    90
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    91
        public void refresh() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    92
            if (fRefreshDone.compareAndSet(false, true)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    93
                final ILaunchConfiguration config = getLaunchConfiguration();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    94
                try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    95
                    if (RefreshTab.getRefreshScope(config) != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    96
                        Job refreshJob = new Job("Refresh"){
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    97
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    98
                            /* (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    99
                             * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   100
                             */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   101
                            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   102
                            protected IStatus run(IProgressMonitor monitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   103
                                try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   104
                                    RefreshTab.refreshResources(config, monitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   105
                                } catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   106
                                    return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, e.getLocalizedMessage(), e);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   107
                                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   108
                                return Status.OK_STATUS;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   109
                            }};
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   110
                        refreshJob.setSystem(true);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   111
                        refreshJob.schedule();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   112
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   113
                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   114
                catch(CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   115
                    LaunchUIPlugin.log( e.getStatus() );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   116
                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   117
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   118
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   119
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   120
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   121
    /* (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   122
     * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   123
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   124
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   125
    public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   126
        return new CLaunch(configuration, mode, null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   127
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   128
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   129
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   130
	 * The project containing the programs file being launched
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   131
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   132
	private IProject project;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   133
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   134
	 * A list of prequisite projects ordered by their build order.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   135
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   136
	private List orderedProjects;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   137
	private String preLaunchBuildConfiguration;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   138
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   139
	abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   140
			throws CoreException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   141
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   142
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   143
	 * Returns the working directory specified by the given launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   144
	 * configuration, or <code>null</code> if none.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   145
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   146
	 * @deprecated Should use getWorkingDirectory()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   147
	 * @param configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   148
	 *            launch configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   149
	 * @return the working directory specified by the given launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   150
	 *         configuration, or <code>null</code> if none
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   151
	 * @exception CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   152
	 *                if unable to retrieve the attribute
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   153
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   154
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   155
	public File getWorkingDir(ILaunchConfiguration configuration) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   156
		return getWorkingDirectory(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   157
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   158
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   159
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   160
	 * Returns the working directory specified by the given launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   161
	 * configuration, or <code>null</code> if none.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   162
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   163
	 * @param configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   164
	 *            launch configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   165
	 * @return the working directory specified by the given launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   166
	 *         configuration, or <code>null</code> if none
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   167
	 * @exception CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   168
	 *                if unable to retrieve the attribute
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   169
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   170
	public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   171
		return verifyWorkingDirectory(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   172
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   173
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   174
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   175
	 * Expands and returns the working directory attribute of the given launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   176
	 * configuration. Returns <code>null</code> if a working directory is not
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   177
	 * specified. If specified, the working is verified to point to an existing
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   178
	 * directory in the local file system.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   179
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   180
	 * @param configuration launch configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   181
	 * @return an absolute path to a directory in the local file system, or
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   182
	 * <code>null</code> if unspecified
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   183
	 * @throws CoreException if unable to retrieve the associated launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   184
	 * configuration attribute, if unable to resolve any variables, or if the
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   185
	 * resolved location does not point to an existing directory in the local
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   186
	 * file system
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   187
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   188
	protected IPath getWorkingDirectoryPath(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   189
		String location = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   190
		if (location != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   191
			String expandedLocation = LaunchUtils.getStringVariableManager().performStringSubstitution(location);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   192
			if (expandedLocation.length() > 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   193
				return new Path(expandedLocation);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   194
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   195
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   196
		return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   197
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   198
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   199
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   200
	 * Throws a core exception with an error status object built from the given
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   201
	 * message, lower level exception, and error code.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   202
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   203
	 * @param message
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   204
	 *            the status message
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   205
	 * @param exception
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   206
	 *            lower level exception associated with the error, or
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   207
	 *            <code>null</code> if none
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   208
	 * @param code
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   209
	 *            error code
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   210
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   211
	protected void abort(String message, Throwable exception, int code) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   212
		IStatus status;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   213
		if (exception != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   214
			MultiStatus multiStatus = new MultiStatus(getPluginID(), code, message, exception);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   215
			multiStatus.add(new Status(IStatus.ERROR, getPluginID(), code, exception.getLocalizedMessage(), exception));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   216
			status= multiStatus;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   217
		} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   218
			status= new Status(IStatus.ERROR, getPluginID(), code, message, null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   219
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   220
		throw new CoreException(status);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   221
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   222
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   223
	protected void cancel(String message, int code) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   224
		throw new CoreException(new Status(IStatus.OK, getPluginID(), code, message, null));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   225
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   226
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   227
	abstract protected String getPluginID();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   228
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   229
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   230
     * @deprecated Use {@link org.eclipse.cdt.debug.core.CDebugUtils} instead.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   231
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   232
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   233
	public static ICProject getCProject(ILaunchConfiguration configuration) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   234
	    return CDebugUtils.getCProject(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   235
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   236
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   237
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   238
     * @deprecated Use {@link org.eclipse.cdt.debug.core.CDebugUtils} instead.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   239
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   240
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   241
	public static String getProjectName(ILaunchConfiguration configuration) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   242
        return CDebugUtils.getProjectName(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   243
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   244
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   245
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   246
     * @deprecated Use {@link org.eclipse.cdt.debug.core.CDebugUtils} instead.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   247
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   248
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   249
	public static String getProgramName(ILaunchConfiguration configuration) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   250
        return CDebugUtils.getProgramName(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   251
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   252
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   253
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   254
     * @deprecated Use {@link org.eclipse.cdt.debug.core.CDebugUtils} instead.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   255
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   256
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   257
	public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   258
        return CDebugUtils.getProgramPath(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   259
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   260
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   261
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   262
	 * @param launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   263
	 * @param config
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   264
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   265
	 * @deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   266
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   267
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   268
	protected void setSourceLocator(ILaunch launch, ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   269
		setDefaultSourceLocator(launch, config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   270
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   271
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   272
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   273
	 * Assigns a default source locator to the given launch if a source locator
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   274
	 * has not yet been assigned to it, and the associated launch configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   275
	 * does not specify a source locator.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   276
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   277
	 * @param launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   278
	 *            launch object
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   279
	 * @param configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   280
	 *            configuration being launched
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   281
	 * @exception CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   282
	 *                if unable to set the source locator
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   283
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   284
	protected void setDefaultSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   285
		//  set default source locator if none specified
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   286
		if (launch.getSourceLocator() == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   287
			IPersistableSourceLocator sourceLocator;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   288
			String id = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   289
			if (id == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   290
				ICProject cProject = CDebugUtils.getCProject(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   291
				if (cProject == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   292
					abort(LaunchMessages.getString("Launch.common.Project_does_not_exist"), null, //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   293
							ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   294
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   295
				sourceLocator = CDebugUIPlugin.createDefaultSourceLocator();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   296
				sourceLocator.initializeDefaults(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   297
			} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   298
				sourceLocator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(id);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   299
				String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   300
				if (memento == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   301
					sourceLocator.initializeDefaults(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   302
				} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   303
					sourceLocator.initializeFromMemento(memento);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   304
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   305
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   306
			launch.setSourceLocator(sourceLocator);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   307
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   308
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   309
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   310
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   311
	 * Returns the program arguments as a String.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   312
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   313
	 * @return the program arguments as a String
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   314
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   315
	public String getProgramArguments(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   316
		return LaunchUtils.getProgramArguments(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   317
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   318
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   319
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   320
	 * Returns the program arguments as an array of individual arguments.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   321
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   322
	 * @return the program arguments as an array of individual arguments
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   323
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   324
	public String[] getProgramArgumentsArray(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   325
		return LaunchUtils.getProgramArgumentsArray(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   326
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   327
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   328
	protected ICDebugConfiguration getDebugConfig(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   329
		ICDebugConfiguration dbgCfg = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   330
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   331
			dbgCfg = CDebugCorePlugin.getDefault().getDebugConfiguration(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   332
																			config.getAttribute(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   333
																								ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   334
																								"")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   335
		} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   336
			IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   337
					ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   338
					LaunchMessages.getString("AbstractCLaunchDelegate.Debugger_not_installed"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   339
					e);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   340
			IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   341
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   342
			if (handler != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   343
				Object result = handler.handleStatus(status, this);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   344
				if (result instanceof String) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   345
					// this could return the new debugger id to use?
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   346
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   347
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   348
			throw e;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   349
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   350
		return dbgCfg;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   351
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   352
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   353
	protected String renderTargetLabel(ICDebugConfiguration debugConfig) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   354
		String format = "{0} ({1})"; //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   355
		String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   356
		return MessageFormat.format(format, new String[]{debugConfig.getName(), timestamp});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   357
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   358
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   359
	protected String renderProcessLabel(String commandLine) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   360
		String format = "{0} ({1})"; //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   361
		String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   362
		return MessageFormat.format(format, new String[]{commandLine, timestamp});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   363
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   364
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   365
	// temporary fix for #66015
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   366
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   367
	 * @deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   368
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   369
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   370
	protected String renderDebuggerProcessLabel() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   371
		String format = "{0} ({1})"; //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   372
		String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   373
		return MessageFormat.format(format, new String[]{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   374
				LaunchMessages.getString("AbstractCLaunchDelegate.Debugger_Process"), timestamp}); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   375
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   376
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   377
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   378
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   379
	 * @param config
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   380
	 * @return
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   381
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   382
	 * @deprecated Use <code>verifyProgramFile</code> instead.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   383
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   384
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   385
	protected IFile getProgramFile(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   386
		ICProject cproject = verifyCProject(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   387
		String fileName = CDebugUtils.getProgramName(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   388
		if (fileName == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   389
			abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   390
					ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   391
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   392
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   393
		IFile programPath = ((IProject)cproject.getResource()).getFile(fileName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   394
		if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   395
			abort(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   396
					LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   397
					new FileNotFoundException(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   398
							LaunchMessages.getFormattedString(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   399
																"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.getLocation().toOSString())), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   400
					ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   401
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   402
		return programPath;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   403
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   404
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   405
	protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   406
		String name = CDebugUtils.getProjectName(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   407
		if (name == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   408
			abort(LaunchMessages.getString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   409
					ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   410
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   411
		ICProject cproject = CDebugUtils.getCProject(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   412
		if (cproject == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   413
			IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   414
			if (!proj.exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   415
				abort(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   416
						LaunchMessages.getFormattedString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   417
						ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   418
			} else if (!proj.isOpen()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   419
				abort(LaunchMessages.getFormattedString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   420
						ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   421
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   422
			abort(LaunchMessages.getString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   423
					ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   424
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   425
		return cproject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   426
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   427
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   428
	protected IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   429
		ICProject cproject = verifyCProject(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   430
		IPath programPath = CDebugUtils.getProgramPath(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   431
		if (programPath == null || programPath.isEmpty()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   432
			abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   433
					ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   434
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   435
		if (!programPath.isAbsolute()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   436
			IPath location = cproject.getProject().getLocation();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   437
			if (location != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   438
				programPath = location.append(programPath);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   439
				if (!programPath.toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   440
					// Try the old way, which is required to support linked resources.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   441
					IFile projFile = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   442
					try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   443
						projFile = project.getFile(CDebugUtils.getProgramPath(config));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   444
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   445
					catch (IllegalArgumentException exc) {}	// thrown if relative path that resolves to a root file (e.g., "..\somefile")
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   446
					if (projFile != null && projFile.exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   447
						programPath = projFile.getLocation();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   448
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   449
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   450
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   451
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   452
		if (!programPath.toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   453
			abort(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   454
					LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   455
					new FileNotFoundException(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   456
							LaunchMessages.getFormattedString(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   457
																"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.toOSString())), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   458
					ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   459
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   460
		return programPath;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   461
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   462
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   463
	protected IPath verifyProgramFile(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   464
		return getProgramFile(config).getLocation();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   465
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   466
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   467
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   468
	 * Verifies the working directory specified by the given launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   469
	 * configuration exists, and returns the working directory, or
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   470
	 * <code>null</code> if none is specified.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   471
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   472
	 * @param configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   473
	 *            launch configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   474
	 * @return the working directory specified by the given launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   475
	 *         configuration, or <code>null</code> if none
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   476
	 * @exception CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   477
	 *                if unable to retrieve the attribute
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   478
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   479
	public File verifyWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   480
		IPath path = getWorkingDirectoryPath(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   481
		if (path == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   482
			// default working dir is the project if this config has a project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   483
			ICProject cp = CDebugUtils.getCProject(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   484
			if (cp != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   485
				IProject p = cp.getProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   486
				return p.getLocation().toFile();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   487
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   488
		} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   489
			if (path.isAbsolute()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   490
				File dir = new File(path.toOSString());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   491
				if (dir.isDirectory()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   492
					return dir;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   493
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   494
				abort(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   495
						LaunchMessages.getString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   496
						new FileNotFoundException(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   497
								LaunchMessages.getFormattedString(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   498
																	"AbstractCLaunchDelegate.WORKINGDIRECTORY_PATH_not_found", path.toOSString())), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   499
						ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   500
			} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   501
				IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   502
				if (res instanceof IContainer && res.exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   503
					return res.getLocation().toFile();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   504
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   505
				abort(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   506
						LaunchMessages.getString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   507
						new FileNotFoundException(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   508
								LaunchMessages.getFormattedString(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   509
																	"AbstractCLaunchDelegate.WORKINGDIRECTORY_PATH_not_found", path.toOSString())), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   510
						ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   511
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   512
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   513
		return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   514
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   515
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   516
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   517
	 * Recursively creates a set of projects referenced by the current project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   518
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   519
	 * @param proj
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   520
	 *            The current project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   521
	 * @param referencedProjSet
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   522
	 *            A set of referenced projects
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   523
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   524
	 *             if an error occurs while getting referenced projects from the
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   525
	 *             current project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   526
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   527
	private void getReferencedProjectSet(IProject proj, HashSet referencedProjSet) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   528
		IProject[] projects = proj.getReferencedProjects();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   529
		for (int i = 0; i < projects.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   530
			IProject refProject = projects[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   531
			if (refProject.exists() && !referencedProjSet.contains(refProject)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   532
				referencedProjSet.add(refProject);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   533
				getReferencedProjectSet(refProject, referencedProjSet);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   534
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   535
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   536
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   537
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   538
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   539
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   540
	 * creates a list of project ordered by their build order from an unordered
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   541
	 * list of projects.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   542
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   543
	 * @param resourceCollection
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   544
	 *            The list of projects to sort.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   545
	 * @return A new list of projects, ordered by build order.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   546
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   547
	private List getBuildOrder(List resourceCollection) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   548
		String[] orderedNames = ResourcesPlugin.getWorkspace().getDescription().getBuildOrder();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   549
		if (orderedNames != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   550
			List orderedProjs = new ArrayList(resourceCollection.size());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   551
			//Projects may not be in the build order but should be built if
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   552
			// selected
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   553
			List unorderedProjects = new ArrayList(resourceCollection.size());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   554
			unorderedProjects.addAll(resourceCollection);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   555
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   556
			for (int i = 0; i < orderedNames.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   557
				String projectName = orderedNames[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   558
				for (int j = 0; j < resourceCollection.size(); j++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   559
					IProject proj = (IProject)resourceCollection.get(j);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   560
					if (proj.getName().equals(projectName)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   561
						orderedProjs.add(proj);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   562
						unorderedProjects.remove(proj);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   563
						break;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   564
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   565
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   566
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   567
			//Add anything not specified before we return
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   568
			orderedProjs.addAll(unorderedProjects);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   569
			return orderedProjs;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   570
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   571
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   572
		// Try the project prerequisite order then
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   573
		IProject[] projects = new IProject[resourceCollection.size()];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   574
		projects = (IProject[])resourceCollection.toArray(projects);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   575
		IWorkspace.ProjectOrder po = ResourcesPlugin.getWorkspace().computeProjectOrder(projects);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   576
		ArrayList orderedProjs = new ArrayList();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   577
		orderedProjs.addAll(Arrays.asList(po.projects));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   578
		return orderedProjs;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   579
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   580
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   581
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   582
	 * Builds the current project and all of it's prerequisite projects if
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   583
	 * necessary. Respects specified build order if any exists.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   584
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   585
	 * @param configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   586
	 *            the configuration being launched
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   587
	 * @param mode
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   588
	 *            the mode the configuration is being launched in
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   589
	 * @param monitor
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   590
	 *            progress monitor
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   591
	 * @return whether the debug platform should perform an incremental
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   592
	 *         workspace build before the launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   593
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   594
	 *             if an exception occurrs while building
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   595
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   596
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   597
	public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   598
		//This matches the old code, but I don't know that it is the right behaviour.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   599
		//We should be building the local project as well, not just the ordered projects
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   600
		if(orderedProjects == null) {		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   601
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   602
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   603
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   604
		if(monitor == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   605
			monitor = new NullProgressMonitor();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   606
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   607
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   608
		int scale = 1000;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   609
		int totalWork = (orderedProjects.size() + 1) * scale;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   610
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   611
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   612
			monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.building_projects"), totalWork); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   613
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   614
			for (Iterator i = orderedProjects.iterator(); i.hasNext();) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   615
				IProject proj = (IProject)i.next();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   616
				monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.building") + proj.getName()); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   617
				proj.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor, scale));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   618
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   619
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   620
			monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.building") + project.getName()); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   621
			setBuildConfiguration(configuration, project);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   622
			project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor, scale));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   623
		} finally {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   624
			monitor.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   625
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   626
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   627
		return false; 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   628
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   629
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   630
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   631
	 * Sets up a project for building by making sure the active configuration is the one used
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   632
	 * when the launch was created.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   633
	 * @param configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   634
	 * @param buildProject
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   635
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   636
	private void setBuildConfiguration(ILaunchConfiguration configuration, IProject buildProject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   637
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   638
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   639
			String buildConfigID = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   640
			ICProjectDescription projDes = CDTPropertyManager.getProjectDescription(buildProject);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   641
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   642
			if (buildConfigID.length() > 0 && projDes != null)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   643
			{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   644
				ICConfigurationDescription buildConfiguration = projDes.getConfigurationById(buildConfigID);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   645
				if (buildConfiguration != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   646
					preLaunchBuildConfiguration = projDes.getActiveConfiguration().getId();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   647
					buildConfiguration.setActive();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   648
					CDTPropertyManager.performOk(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   649
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   650
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   651
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   652
		} catch (CoreException e) {}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   653
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   654
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   655
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   656
	 * Searches for compile errors in the current project and any of its
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   657
	 * prerequisite projects. If any compile errors, give the user a chance to
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   658
	 * abort the launch and correct the errors.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   659
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   660
	 * @param configuration
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   661
	 * @param mode
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   662
	 * @param monitor
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   663
	 * @return whether the launch should proceed
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   664
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   665
	 *             if an exception occurs while checking for compile errors.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   666
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   667
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   668
	public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   669
		boolean continueLaunch = true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   670
		if(orderedProjects == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   671
			return continueLaunch;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   672
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   673
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   674
		if(monitor == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   675
			monitor = new NullProgressMonitor();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   676
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   677
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   678
		int scale = 1000;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   679
		int totalWork = (orderedProjects.size() + 1) * scale;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   680
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   681
			monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.searching_for_errors"), totalWork); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   682
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   683
			boolean compileErrorsInProjs = false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   684
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   685
			//check prerequisite projects for compile errors.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   686
			for (Iterator i = orderedProjects.iterator(); i.hasNext();) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   687
				IProject proj = (IProject)i.next();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   688
				monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.searching_for_errors_in" + proj.getName())); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   689
				monitor.worked(scale);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   690
				compileErrorsInProjs = existsErrors(proj);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   691
				if (compileErrorsInProjs) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   692
					break;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   693
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   694
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   695
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   696
			//check current project, if prerequite projects were ok
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   697
			if (!compileErrorsInProjs) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   698
				monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.searching_for_errors_in" + project.getName())); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   699
				monitor.worked(scale);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   700
				compileErrorsInProjs = existsErrors(project);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   701
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   702
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   703
			//if compile errors exist, ask the user before continuing.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   704
			if (compileErrorsInProjs) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   705
				IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   706
				if (prompter != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   707
					continueLaunch = ((Boolean)prompter.handleStatus(complileErrorPromptStatus, null)).booleanValue();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   708
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   709
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   710
		} finally {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   711
			monitor.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   712
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   713
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   714
		if (continueLaunch) // If no problems then restore the previous build configuration. Otherwise leave it so the user can fix the build issues.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   715
			resetBuildConfiguration(project);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   716
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   717
		return continueLaunch;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   718
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   719
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   720
	private void resetBuildConfiguration(IProject buildProject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   721
		// Restore the active configuration if it was changed for the launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   722
		if (preLaunchBuildConfiguration != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   723
			ICProjectDescription projDes = CDTPropertyManager.getProjectDescription(buildProject);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   724
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   725
			if (preLaunchBuildConfiguration.length() > 0 && projDes != null)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   726
			{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   727
				ICConfigurationDescription buildConfiguration = projDes.getConfigurationById(preLaunchBuildConfiguration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   728
				if (buildConfiguration != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   729
					buildConfiguration.setActive();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   730
					CDTPropertyManager.performOk(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   731
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   732
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   733
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   734
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   735
		preLaunchBuildConfiguration = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   736
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   737
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   738
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   739
	 * Searches for compile errors in the specified project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   740
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   741
	 * @param proj
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   742
	 *            The project to search
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   743
	 * @return true if compile errors exist, otherwise false
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   744
	 * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   745
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   746
	protected boolean existsErrors(IProject proj) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   747
		IMarker[] markers = proj.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   748
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   749
		if (markers.length > 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   750
			for (int j = 0; j < markers.length; j++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   751
				Object severityAttribute = markers[j].getAttribute(IMarker.SEVERITY);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   752
				if (severityAttribute != null && ((Integer) severityAttribute).intValue() == IMarker.SEVERITY_ERROR) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   753
					return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   754
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   755
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   756
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   757
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   758
		return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   759
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   760
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   761
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   762
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   763
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   764
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   765
	 *      java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   766
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   767
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   768
	public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   769
		if(monitor == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   770
			monitor = new NullProgressMonitor();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   771
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   772
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   773
		int scale = 1000;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   774
		int totalWork = 2 * scale;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   775
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   776
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   777
			monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.20"), totalWork); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   778
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   779
			// build project list
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   780
			orderedProjects = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   781
			ICProject cProject = CDebugUtils.getCProject(configuration);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   782
			if (cProject != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   783
				project = cProject.getProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   784
				HashSet projectSet = new HashSet();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   785
				getReferencedProjectSet(project, projectSet);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   786
				orderedProjects = getBuildOrder(new ArrayList(projectSet));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   787
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   788
			monitor.worked(scale);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   789
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   790
			// do generic launch checks
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   791
			return super.preLaunchCheck(configuration, mode, new SubProgressMonitor(monitor, scale));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   792
		} finally {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   793
			monitor.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   794
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   795
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   796
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   797
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   798
	 * @param project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   799
	 * @param exePath
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   800
	 * @return
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   801
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   802
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   803
	protected IBinaryObject verifyBinary(ICProject proj, IPath exePath) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   804
		Exception exception;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   805
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   806
			return LaunchUtils.getBinary(proj.getProject(), exePath);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   807
		} catch (ClassCastException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   808
			exception = e;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   809
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   810
		Status status = new Status(IStatus.ERROR,getPluginID(), 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   811
				ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_BINARY, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   812
				LaunchMessages.getString("AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable") + " " + exePath.toOSString(), //$NON-NLS-1$ 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   813
				exception); 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   814
		throw new CoreException(status);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   815
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   816
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   817
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   818
	 * @param config
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   819
	 * @return
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   820
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   821
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   822
	protected Properties getEnvironmentAsProperty(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   823
		String[] envp = getEnvironment(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   824
		Properties p = new Properties( );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   825
		for( int i = 0; i < envp.length; i++ ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   826
			int idx = envp[i].indexOf('=');
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   827
			if (idx != -1) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   828
				String key = envp[i].substring(0, idx);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   829
				String value = envp[i].substring(idx + 1);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   830
				p.setProperty(key, value);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   831
			} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   832
				p.setProperty(envp[i], ""); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   833
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   834
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   835
		return p;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   836
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   837
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   838
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   839
	 * Return the save environment variables in the configuration. The array
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   840
	 * does not include the default environment of the target. array[n] :
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   841
	 * name=value
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   842
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   843
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   844
	protected String[] getEnvironment(ILaunchConfiguration config) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   845
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   846
			// Migrate old env settings to new.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   847
			Map map = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   848
			ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   849
			if (map != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   850
				wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   851
				wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   852
				config = wc.doSave();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   853
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   854
			boolean append = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_INHERIT, true);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   855
			wc.setAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, append);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   856
		} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   857
		}		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   858
		String[] array = DebugPlugin.getDefault().getLaunchManager().getEnvironment(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   859
		if (array == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   860
			return new String[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   861
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   862
		return array;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   863
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   864
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   865
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   866
	 * Return the save environment variables in the configuration. The array
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   867
	 * does not include the default environment of the target. array[n] :
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   868
	 * name=value
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   869
	 * @deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   870
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   871
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   872
	protected String[] getEnvironmentArray(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   873
		Map env = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   874
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   875
			env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   876
		} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   877
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   878
		if (env == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   879
			return new String[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   880
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   881
		String[] array = new String[env.size()];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   882
		Iterator entries = env.entrySet().iterator();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   883
		Entry entry;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   884
		for (int i = 0; entries.hasNext() && i < array.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   885
			entry = (Entry)entries.next();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   886
			array[i] = ((String)entry.getKey()) + "=" + ((String)entry.getValue()); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   887
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   888
		return array;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   889
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   890
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   891
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   892
	 * Return the save environment variables of this configuration. The array
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   893
	 * does not include the default environment of the target.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   894
	 * @deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   895
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   896
	@Deprecated
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   897
	protected Properties getEnvironmentProperty(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   898
		Properties prop = new Properties();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   899
		Map env = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   900
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   901
			env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   902
		} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   903
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   904
		if (env == null)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   905
			return prop;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   906
		Iterator entries = env.entrySet().iterator();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   907
		Entry entry;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   908
		while (entries.hasNext()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   909
			entry = (Entry)entries.next();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   910
			prop.setProperty((String)entry.getKey(), (String)entry.getValue());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   911
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   912
		return prop;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   913
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   914
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   915
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   916
	 * Returns the default process attribute map for C/C++ processes.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   917
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   918
	 * @return default process attribute map for C/C++ processes
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   919
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   920
	protected Map getDefaultProcessMap() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   921
		Map map = new HashMap();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   922
		map.put( IProcess.ATTR_PROCESS_TYPE, ICDTLaunchConfigurationConstants.ID_PROGRAM_PROCESS_TYPE );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   923
		return map;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   924
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   925
}