Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'debug/org.eclipse.cdt.debug.core')
-rw-r--r--debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF5
-rw-r--r--debug/org.eclipse.cdt.debug.core/plugin.properties2
-rw-r--r--debug/org.eclipse.cdt.debug.core/plugin.xml22
-rw-r--r--debug/org.eclipse.cdt.debug.core/pom.xml2
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java14
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLaunchDescriptorType.java35
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalLaunchConfigProvider.java109
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalRunLaunchDelegate.java126
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildProjectLaunchDescriptor.java48
9 files changed, 358 insertions, 5 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF
index 759817ce73..d2ca74a2f4 100644
--- a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF
+++ b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
-Bundle-Version: 8.0.0.qualifier
+Bundle-Version: 8.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -41,7 +41,8 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.0.0,7.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.variables;bundle-version="3.2.0",
- org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)"
+ org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.launchbar.core;bundle-version="2.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.ibm.icu.text
diff --git a/debug/org.eclipse.cdt.debug.core/plugin.properties b/debug/org.eclipse.cdt.debug.core/plugin.properties
index 5143875d06..13fc4ebc6e 100644
--- a/debug/org.eclipse.cdt.debug.core/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.core/plugin.properties
@@ -24,6 +24,8 @@ AttachLaunch.name=C/C++ Attach to Application
PostMortemLaunch.name=C/C++ Postmortem Debugger
RemoteApplicationLaunch.name=C/C++ Remote Application
+localApplicationLaunch.name=C/C++ Local Application (auto)
+
CDebugger.name=C/C++ Development Tools Core Debugger Extension
BreakpointAction.name=Breakpoint Action Extension
SupportedSourceContainerTypes.name=C/C++ Supported Source Container Types Extension
diff --git a/debug/org.eclipse.cdt.debug.core/plugin.xml b/debug/org.eclipse.cdt.debug.core/plugin.xml
index bbbb4c5a6a..65b5feba7f 100644
--- a/debug/org.eclipse.cdt.debug.core/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.core/plugin.xml
@@ -461,4 +461,26 @@
type="org.eclipse.cdt.debug.core.cFunctionTracepointMarker">
</importParticipant>
</extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.eclipse.cdt.debug.internal.core.launch.CoreBuildLocalRunLaunchDelegate"
+ id="org.eclipse.cdt.debug.core.localLaunchConfigurationType"
+ modes="run"
+ name="%localApplicationLaunch.name">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.launchbar.core.launchBarContributions">
+ <descriptorType
+ class="org.eclipse.cdt.debug.internal.core.launch.CoreBuildLaunchDescriptorType"
+ id="org.eclipse.cdt.debug.core.coreBuildDescriptorType"
+ priority="20">
+ </descriptorType>
+ <configProvider
+ class="org.eclipse.cdt.debug.internal.core.launch.CoreBuildLocalLaunchConfigProvider"
+ descriptorType="org.eclipse.cdt.debug.core.coreBuildDescriptorType"
+ priority="10">
+ </configProvider>
+ </extension>
</plugin>
diff --git a/debug/org.eclipse.cdt.debug.core/pom.xml b/debug/org.eclipse.cdt.debug.core/pom.xml
index 7bd571ce05..5a22c4af33 100644
--- a/debug/org.eclipse.cdt.debug.core/pom.xml
+++ b/debug/org.eclipse.cdt.debug.core/pom.xml
@@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.debug.core</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
index 177b245c5d..78fd598077 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
@@ -46,6 +46,7 @@ import org.eclipse.debug.core.ILaunchDelegate;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* The plugin class for C/C++ debug core.
@@ -239,6 +240,15 @@ public class CDebugCorePlugin extends Plugin {
super.stop(context);
}
+ /**
+ * @since 8.1
+ */
+ public static <T> T getService(Class<T> service) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference<T> ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
+
private void createCommandAdapterFactory() {
IAdapterManager manager= Platform.getAdapterManager();
CCommandAdapterFactory actionFactory = new CCommandAdapterFactory();
@@ -319,7 +329,7 @@ public class CDebugCorePlugin extends Plugin {
// Set the default launch delegates as early as possible, and do it only once (Bug 312997)
ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager();
- HashSet<String> debugSet = new HashSet<String>();
+ HashSet<String> debugSet = new HashSet<>();
debugSet.add(ILaunchManager.DEBUG_MODE);
ILaunchConfigurationType localCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP);
@@ -378,7 +388,7 @@ public class CDebugCorePlugin extends Plugin {
} catch (CoreException e) {
}
- HashSet<String> runSet = new HashSet<String>();
+ HashSet<String> runSet = new HashSet<>();
runSet.add(ILaunchManager.RUN_MODE);
try {
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLaunchDescriptorType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLaunchDescriptorType.java
new file mode 100644
index 0000000000..661a6e3c89
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLaunchDescriptorType.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2016 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.core.launch;
+
+import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.launchbar.core.ILaunchDescriptor;
+import org.eclipse.launchbar.core.ILaunchDescriptorType;
+import org.eclipse.launchbar.core.internal.Activator;
+
+/**
+ * The launch descriptor type for launch objects built with the Core Build System.
+ */
+public class CoreBuildLaunchDescriptorType implements ILaunchDescriptorType {
+
+ @Override
+ public ILaunchDescriptor getDescriptor(Object launchObject) throws CoreException {
+ if (launchObject instanceof IProject) {
+ // Make sure it's a new style build
+ IProject project = (IProject) launchObject;
+ if (Activator.getService(ICBuildConfigurationManager.class).supports(project)) {
+ return new CoreBuildProjectLaunchDescriptor(this, project);
+ }
+ }
+ // TODO IBinary
+ return null;
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalLaunchConfigProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalLaunchConfigProvider.java
new file mode 100644
index 0000000000..609bfa3e34
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalLaunchConfigProvider.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2016 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.core.launch;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.launchbar.core.AbstractLaunchConfigProvider;
+import org.eclipse.launchbar.core.ILaunchDescriptor;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
+import org.eclipse.launchbar.core.target.ILaunchTargetManager;
+
+public class CoreBuildLocalLaunchConfigProvider extends AbstractLaunchConfigProvider {
+
+ private static final String TYPE_ID = "org.eclipse.cdt.debug.core.localLaunchConfigurationType"; //$NON-NLS-1$
+
+ private Map<IProject, ILaunchConfiguration> configs = new HashMap<>();
+
+ @Override
+ public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
+ return ILaunchTargetManager.localLaunchTargetTypeId.equals(target.getTypeId());
+ }
+
+ @Override
+ public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
+ throws CoreException {
+ return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(TYPE_ID);
+ }
+
+ @Override
+ public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
+ throws CoreException {
+ ILaunchConfiguration config = null;
+ IProject project = descriptor.getAdapter(IProject.class);
+ if (project != null) {
+ config = configs.get(project);
+ if (config == null) {
+ config = createLaunchConfiguration(descriptor, target);
+ // launch config added will get called below to add it to the
+ // configs map
+ }
+ }
+ return config;
+ }
+
+ @Override
+ protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
+ ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
+ super.populateLaunchConfiguration(descriptor, target, workingCopy);
+
+ // Set the project and the connection
+ IProject project = descriptor.getAdapter(IProject.class);
+ workingCopy.setMappedResources(new IResource[] { project });
+ }
+
+ @Override
+ public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
+ if (ownsLaunchConfiguration(configuration)) {
+ IProject project = configuration.getMappedResources()[0].getProject();
+ configs.put(project, configuration);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
+ for (Entry<IProject, ILaunchConfiguration> entry : configs.entrySet()) {
+ if (configuration.equals(entry.getValue())) {
+ configs.remove(entry.getKey());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException {
+ // TODO not sure I care
+ return false;
+ }
+
+ @Override
+ public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException {
+ IProject project = descriptor.getAdapter(IProject.class);
+ if (project != null) {
+ configs.remove(project);
+ }
+ }
+
+ @Override
+ public void launchTargetRemoved(ILaunchTarget target) throws CoreException {
+ // nothing to do since the Local connection can't be removed
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalRunLaunchDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalRunLaunchDelegate.java
new file mode 100644
index 0000000000..e26692aa13
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalRunLaunchDelegate.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2016 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.core.launch;
+
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.build.IToolChainManager;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.utils.Platform;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
+import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
+import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate;
+
+public class CoreBuildLocalRunLaunchDelegate extends LaunchConfigurationTargetedDelegate {
+
+ public static final String TYPE_ID = "org.eclipse.cdt.cmake.core.launchConfigurationType"; //$NON-NLS-1$
+
+ private ICBuildConfigurationManager configManager = CDebugCorePlugin.getService(ICBuildConfigurationManager.class);
+ private IToolChainManager tcManager = CDebugCorePlugin.getService(IToolChainManager.class);
+
+ private IProject getProject(ILaunchConfiguration configuration) throws CoreException {
+ return configuration.getMappedResources()[0].getProject();
+ }
+
+ @Override
+ public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
+ IProgressMonitor monitor) throws CoreException {
+ // Set active build config based on toolchain for target
+ Map<String, String> properties = new HashMap<>();
+ properties.put(IToolChain.ATTR_OS, Platform.getOS());
+ properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
+ // TODO should really use real architecture of platform, not what Eclipse is using.
+ // Also on 64-bit platforms, try 32-bit if toolchains not found
+ Collection<IToolChain> tcs = tcManager.getToolChainsMatching(properties);
+ if (!tcs.isEmpty()) {
+ IToolChain toolChain = tcs.iterator().next();
+
+ IProject project = getProject(configuration);
+ ICBuildConfiguration config = configManager.getBuildConfiguration(project, toolChain, "run", monitor); //$NON-NLS-1$
+
+ if (config != null) {
+ IProjectDescription desc = project.getDescription();
+ desc.setActiveBuildConfig(config.getBuildConfiguration().getName());
+ project.setDescription(desc, monitor);
+ }
+ }
+
+ // proceed with the build
+ return superBuildForLaunch(configuration, mode, monitor);
+ }
+
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+ IProject project = getProject(configuration);
+ ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget();
+
+ ICBuildConfiguration buildConfig = getBuildConfiguration(project, mode, target, monitor);
+ IBinary[] binaries = buildConfig.getBuildOutput();
+ IBinary exeFile = null;
+ for (IBinary binary : binaries) {
+ if (binary.isExecutable()) {
+ exeFile = binary;
+ break;
+ }
+ }
+ if (exeFile == null) {
+ throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, "No binaries"));
+ }
+
+ try {
+ ProcessBuilder builder = new ProcessBuilder(Paths.get(exeFile.getLocationURI()).toString());
+ buildConfig.setBuildEnvironment(builder.environment());
+ Process process = builder.start();
+ DebugPlugin.newProcess(launch, process, exeFile.getPath().lastSegment());
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, "Error launching", e));
+ }
+ }
+
+ @Override
+ protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
+ // 1. Extract project from configuration
+ // TODO dependencies too.
+ IProject project = getProject(configuration);
+ return new IProject[] { project };
+ }
+
+ private ICBuildConfiguration getBuildConfiguration(IProject project, String mode, ILaunchTarget target,
+ IProgressMonitor monitor) throws CoreException {
+ // Set active build config based on toolchain for target
+ Map<String, String> properties = new HashMap<>();
+ properties.put(IToolChain.ATTR_OS, Platform.getOS());
+ properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
+ Collection<IToolChain> tcs = tcManager.getToolChainsMatching(properties);
+ if (!tcs.isEmpty()) {
+ IToolChain toolChain = tcs.iterator().next();
+ return configManager.getBuildConfiguration(project, toolChain, "run", monitor); //$NON-NLS-1$
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildProjectLaunchDescriptor.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildProjectLaunchDescriptor.java
new file mode 100644
index 0000000000..bfb4a223d9
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildProjectLaunchDescriptor.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2016 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.core.launch;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.launchbar.core.ILaunchDescriptor;
+import org.eclipse.launchbar.core.ILaunchDescriptorType;
+
+/**
+ * A launch descriptor representing a project built with the new Core Build system.
+ */
+public class CoreBuildProjectLaunchDescriptor extends PlatformObject implements ILaunchDescriptor {
+
+ private final IProject project;
+ private final CoreBuildLaunchDescriptorType type;
+
+ public CoreBuildProjectLaunchDescriptor(CoreBuildLaunchDescriptorType type, IProject project) {
+ this.type = type;
+ this.project = project;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
+ if (IProject.class.equals(adapter)) {
+ return (T) project;
+ } else {
+ return super.getAdapter(adapter);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return project.getName();
+ }
+
+ @Override
+ public ILaunchDescriptorType getType() {
+ return type;
+ }
+
+}

Back to the top