diff options
Diffstat (limited to 'debug/org.eclipse.cdt.debug.core/src/org')
6 files changed, 560 insertions, 560 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java index 217c6dced4f..b3909f12d61 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java @@ -1,88 +1,88 @@ -/*******************************************************************************
- * Copyright (c) 2017 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.core.launch;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.internal.core.Messages;
-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.core.variables.IStringVariableManager;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-
-/**
- * Delegate for Generic Launches over the Generic Launch Target. Can be
- * overriden to support launch customization for similar targets.
- *
- * @since 8.3
- */
-public class CoreBuildGenericLaunchConfigDelegate extends CoreBuildLaunchConfigDelegate {
-
- public static final String TYPE_ID = "org.eclipse.cdt.debug.core.genericLaunchConfigType"; //$NON-NLS-1$
-
- @Override
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
- throws CoreException {
- IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
-
- String location = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_LOCATION, ""); //$NON-NLS-1$
- if (location.isEmpty()) {
- launch.addProcess(new NullProcess(launch, Messages.CoreBuildGenericLaunchConfigDelegate_NoAction));
- return;
- } else {
- String substLocation = varManager.performStringSubstitution(location);
- if (substLocation.isEmpty()) {
- throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
- String.format(Messages.CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed, location)));
- }
- location = substLocation;
- }
-
- if (!new File(location).canExecute()) {
- throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
- String.format(Messages.CoreBuildGenericLaunchConfigDelegate_CommandNotValid, location)));
- }
-
- List<String> commands = new ArrayList<>();
- commands.add(location);
-
- String arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
- if (!arguments.isEmpty()) {
- commands.addAll(Arrays.asList(varManager.performStringSubstitution(arguments).split(" "))); //$NON-NLS-1$
- }
-
- String workingDirectory = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- ""); //$NON-NLS-1$
- File workingDir;
- if (workingDirectory.isEmpty()) {
- workingDir = new File(getProject(configuration).getLocationURI());
- } else {
- workingDir = new File(varManager.performStringSubstitution(workingDirectory));
- if (!workingDir.isDirectory()) {
- throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
- String.format(Messages.CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists, location)));
- }
- }
-
- String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
-
- Process p = DebugPlugin.exec(commands.toArray(new String[0]), workingDir, envp);
- DebugPlugin.newProcess(launch, p, String.join(" ", commands)); //$NON-NLS-1$
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2017 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.core.launch; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.internal.core.Messages; +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.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; + +/** + * Delegate for Generic Launches over the Generic Launch Target. Can be + * overriden to support launch customization for similar targets. + * + * @since 8.3 + */ +public class CoreBuildGenericLaunchConfigDelegate extends CoreBuildLaunchConfigDelegate { + + public static final String TYPE_ID = "org.eclipse.cdt.debug.core.genericLaunchConfigType"; //$NON-NLS-1$ + + @Override + public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) + throws CoreException { + IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager(); + + String location = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_LOCATION, ""); //$NON-NLS-1$ + if (location.isEmpty()) { + launch.addProcess(new NullProcess(launch, Messages.CoreBuildGenericLaunchConfigDelegate_NoAction)); + return; + } else { + String substLocation = varManager.performStringSubstitution(location); + if (substLocation.isEmpty()) { + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + String.format(Messages.CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed, location))); + } + location = substLocation; + } + + if (!new File(location).canExecute()) { + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + String.format(Messages.CoreBuildGenericLaunchConfigDelegate_CommandNotValid, location))); + } + + List<String> commands = new ArrayList<>(); + commands.add(location); + + String arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$ + if (!arguments.isEmpty()) { + commands.addAll(Arrays.asList(varManager.performStringSubstitution(arguments).split(" "))); //$NON-NLS-1$ + } + + String workingDirectory = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, + ""); //$NON-NLS-1$ + File workingDir; + if (workingDirectory.isEmpty()) { + workingDir = new File(getProject(configuration).getLocationURI()); + } else { + workingDir = new File(varManager.performStringSubstitution(workingDirectory)); + if (!workingDir.isDirectory()) { + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + String.format(Messages.CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists, location))); + } + } + + String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration); + + Process p = DebugPlugin.exec(commands.toArray(new String[0]), workingDir, envp); + DebugPlugin.newProcess(launch, p, String.join(" ", commands)); //$NON-NLS-1$ + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java index 7cc54a1260b..24439e69d5d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java @@ -1,165 +1,165 @@ -package org.eclipse.cdt.debug.core.launch;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-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;
-
-/**
- * Core launch configuration provider used by generic target types.
- *
- * @since 8.3
- */
-public class CoreBuildGenericLaunchConfigProvider extends AbstractLaunchConfigProvider {
-
- private static final String ATTR_OS = CDebugCorePlugin.PLUGIN_ID + ".target_os"; //$NON-NLS-1$
- private static final String ATTR_ARCH = CDebugCorePlugin.PLUGIN_ID + ".target_arch"; //$NON-NLS-1$
- private static final String EMPTY = ""; //$NON-NLS-1$
-
- private Map<IProject, Map<String, ILaunchConfiguration>> configs = new HashMap<>();
-
- @Override
- public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
- return target.getTypeId().equals(GenericTargetTypeProvider.TYPE_ID);
- }
-
- @Override
- public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
- throws CoreException {
- return DebugPlugin.getDefault().getLaunchManager()
- .getLaunchConfigurationType(CoreBuildGenericLaunchConfigDelegate.TYPE_ID);
- }
-
- @Override
- public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
- throws CoreException {
- ILaunchConfiguration config = null;
- IProject project = descriptor.getAdapter(IProject.class);
- if (project != null) {
- Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
- if (projectConfigs == null) {
- projectConfigs = new HashMap<>();
- configs.put(project, projectConfigs);
- }
-
- String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
- String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
- String targetConfig = os + '.' + arch;
- config = projectConfigs.get(targetConfig);
- if (config == null) {
- config = createLaunchConfiguration(descriptor, target);
- }
- }
- return config;
- }
-
- @Override
- protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
- ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
- super.populateLaunchConfiguration(descriptor, target, workingCopy);
-
- // Set the project
- IProject project = descriptor.getAdapter(IProject.class);
- workingCopy.setMappedResources(new IResource[] { project });
-
- // set the OS and ARCH
- String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
- workingCopy.setAttribute(ATTR_OS, os);
-
- String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
- workingCopy.setAttribute(ATTR_ARCH, arch);
- }
-
- @Override
- public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
- // TODO make sure it's the correct type
- if (ownsLaunchConfiguration(configuration)) {
- IProject project = configuration.getMappedResources()[0].getProject();
- Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
- if (projectConfigs == null) {
- projectConfigs = new HashMap<>();
- configs.put(project, projectConfigs);
- }
-
- String os = configuration.getAttribute(ATTR_OS, EMPTY);
- String arch = configuration.getAttribute(ATTR_ARCH, EMPTY);
- String targetConfig = os + '.' + arch;
- projectConfigs.put(targetConfig, configuration);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
- for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) {
- Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue();
- for (Entry<String, ILaunchConfiguration> entry : projectConfigs.entrySet()) {
- if (configuration.equals(entry.getValue())) {
- projectConfigs.remove(entry.getKey());
- if (projectConfigs.isEmpty()) {
- configs.remove(projectEntry.getKey());
- }
- return true;
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException {
- // nothing to do
- return false;
- }
-
- @Override
- public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException {
- IProject project = descriptor.getAdapter(IProject.class);
- if (project != null) {
- Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
- if (projectConfigs != null) {
- for (ILaunchConfiguration config : projectConfigs.values()) {
- config.delete();
- }
- }
- }
- }
-
- @Override
- public void launchTargetRemoved(ILaunchTarget target) throws CoreException {
- // Any other targets have the same OS and ARCH?
- String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
- String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
-
- ILaunchTargetManager targetManager = CDebugCorePlugin.getService(ILaunchTargetManager.class);
- for (ILaunchTarget t : targetManager.getLaunchTargets()) {
- if (!target.equals(t) && os.equals(t.getAttribute(ILaunchTarget.ATTR_OS, EMPTY))
- && arch.equals(t.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY))) {
- // Yup, nothing to do then
- return;
- }
- }
-
- for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) {
- Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue();
- ILaunchConfiguration config = projectConfigs.get(os);
- if (config != null) {
- config.delete();
- }
- }
- }
-
-}
+package org.eclipse.cdt.debug.core.launch; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +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; + +/** + * Core launch configuration provider used by generic target types. + * + * @since 8.3 + */ +public class CoreBuildGenericLaunchConfigProvider extends AbstractLaunchConfigProvider { + + private static final String ATTR_OS = CDebugCorePlugin.PLUGIN_ID + ".target_os"; //$NON-NLS-1$ + private static final String ATTR_ARCH = CDebugCorePlugin.PLUGIN_ID + ".target_arch"; //$NON-NLS-1$ + private static final String EMPTY = ""; //$NON-NLS-1$ + + private Map<IProject, Map<String, ILaunchConfiguration>> configs = new HashMap<>(); + + @Override + public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { + return target.getTypeId().equals(GenericTargetTypeProvider.TYPE_ID); + } + + @Override + public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) + throws CoreException { + return DebugPlugin.getDefault().getLaunchManager() + .getLaunchConfigurationType(CoreBuildGenericLaunchConfigDelegate.TYPE_ID); + } + + @Override + public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) + throws CoreException { + ILaunchConfiguration config = null; + IProject project = descriptor.getAdapter(IProject.class); + if (project != null) { + Map<String, ILaunchConfiguration> projectConfigs = configs.get(project); + if (projectConfigs == null) { + projectConfigs = new HashMap<>(); + configs.put(project, projectConfigs); + } + + String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY); + String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY); + String targetConfig = os + '.' + arch; + config = projectConfigs.get(targetConfig); + if (config == null) { + config = createLaunchConfiguration(descriptor, target); + } + } + return config; + } + + @Override + protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target, + ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { + super.populateLaunchConfiguration(descriptor, target, workingCopy); + + // Set the project + IProject project = descriptor.getAdapter(IProject.class); + workingCopy.setMappedResources(new IResource[] { project }); + + // set the OS and ARCH + String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY); + workingCopy.setAttribute(ATTR_OS, os); + + String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY); + workingCopy.setAttribute(ATTR_ARCH, arch); + } + + @Override + public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException { + // TODO make sure it's the correct type + if (ownsLaunchConfiguration(configuration)) { + IProject project = configuration.getMappedResources()[0].getProject(); + Map<String, ILaunchConfiguration> projectConfigs = configs.get(project); + if (projectConfigs == null) { + projectConfigs = new HashMap<>(); + configs.put(project, projectConfigs); + } + + String os = configuration.getAttribute(ATTR_OS, EMPTY); + String arch = configuration.getAttribute(ATTR_ARCH, EMPTY); + String targetConfig = os + '.' + arch; + projectConfigs.put(targetConfig, configuration); + return true; + } + return false; + } + + @Override + public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException { + for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) { + Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue(); + for (Entry<String, ILaunchConfiguration> entry : projectConfigs.entrySet()) { + if (configuration.equals(entry.getValue())) { + projectConfigs.remove(entry.getKey()); + if (projectConfigs.isEmpty()) { + configs.remove(projectEntry.getKey()); + } + return true; + } + } + } + return false; + } + + @Override + public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException { + // nothing to do + return false; + } + + @Override + public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException { + IProject project = descriptor.getAdapter(IProject.class); + if (project != null) { + Map<String, ILaunchConfiguration> projectConfigs = configs.get(project); + if (projectConfigs != null) { + for (ILaunchConfiguration config : projectConfigs.values()) { + config.delete(); + } + } + } + } + + @Override + public void launchTargetRemoved(ILaunchTarget target) throws CoreException { + // Any other targets have the same OS and ARCH? + String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY); + String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY); + + ILaunchTargetManager targetManager = CDebugCorePlugin.getService(ILaunchTargetManager.class); + for (ILaunchTarget t : targetManager.getLaunchTargets()) { + if (!target.equals(t) && os.equals(t.getAttribute(ILaunchTarget.ATTR_OS, EMPTY)) + && arch.equals(t.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY))) { + // Yup, nothing to do then + return; + } + } + + for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) { + Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue(); + ILaunchConfiguration config = projectConfigs.get(os); + if (config != null) { + config.delete(); + } + } + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java index ca62c059340..bab959fbcd3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java @@ -1,107 +1,107 @@ -/*******************************************************************************
- * Copyright (c) 2017 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.core.launch;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.debug.core.model.IStreamsProxy;
-
-/**
- * A simple process that only spits out a message then terminates.
- *
- * @since 8.3
- */
-public class NullProcess extends PlatformObject implements IProcess {
-
- private final String message;
- private final ILaunch launch;
-
- public NullProcess(ILaunch launch, String message) {
- this.launch = launch;
- this.message = message;
- }
-
- @Override
- public boolean canTerminate() {
- return true;
- }
-
- @Override
- public boolean isTerminated() {
- return true;
- }
-
- @Override
- public void terminate() throws DebugException {
- }
-
- @Override
- public String getLabel() {
- return launch.getLaunchConfiguration().getName();
- }
-
- @Override
- public ILaunch getLaunch() {
- return launch;
- }
-
- @Override
- public IStreamsProxy getStreamsProxy() {
- return new IStreamsProxy() {
- @Override
- public void write(String input) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public IStreamMonitor getOutputStreamMonitor() {
- return new IStreamMonitor() {
- @Override
- public void removeListener(IStreamListener listener) {
- }
-
- @Override
- public String getContents() {
- return message;
- }
-
- @Override
- public void addListener(IStreamListener listener) {
- }
- };
- }
-
- @Override
- public IStreamMonitor getErrorStreamMonitor() {
- return null;
- }
- };
- }
-
- @Override
- public void setAttribute(String key, String value) {
- }
-
- @Override
- public String getAttribute(String key) {
- return null;
- }
-
- @Override
- public int getExitValue() throws DebugException {
- return 0;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2017 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.core.launch; + +import java.io.IOException; + +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.IStreamListener; +import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.core.model.IStreamMonitor; +import org.eclipse.debug.core.model.IStreamsProxy; + +/** + * A simple process that only spits out a message then terminates. + * + * @since 8.3 + */ +public class NullProcess extends PlatformObject implements IProcess { + + private final String message; + private final ILaunch launch; + + public NullProcess(ILaunch launch, String message) { + this.launch = launch; + this.message = message; + } + + @Override + public boolean canTerminate() { + return true; + } + + @Override + public boolean isTerminated() { + return true; + } + + @Override + public void terminate() throws DebugException { + } + + @Override + public String getLabel() { + return launch.getLaunchConfiguration().getName(); + } + + @Override + public ILaunch getLaunch() { + return launch; + } + + @Override + public IStreamsProxy getStreamsProxy() { + return new IStreamsProxy() { + @Override + public void write(String input) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public IStreamMonitor getOutputStreamMonitor() { + return new IStreamMonitor() { + @Override + public void removeListener(IStreamListener listener) { + } + + @Override + public String getContents() { + return message; + } + + @Override + public void addListener(IStreamListener listener) { + } + }; + } + + @Override + public IStreamMonitor getErrorStreamMonitor() { + return null; + } + }; + } + + @Override + public void setAttribute(String key, String value) { + } + + @Override + public String getAttribute(String key) { + return null; + } + + @Override + public int getExitValue() throws DebugException { + return 0; + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Messages.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Messages.java index 7de4c1786fe..e72f4cb2ee7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Messages.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Messages.java @@ -1,25 +1,25 @@ -/*******************************************************************************
- * Copyright (c) 2017 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;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.messages"; //$NON-NLS-1$
- public static String CoreBuildGenericLaunchConfigDelegate_CommandNotValid;
- public static String CoreBuildGenericLaunchConfigDelegate_NoAction;
- public static String CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed;
- public static String CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
+/******************************************************************************* + * Copyright (c) 2017 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; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.messages"; //$NON-NLS-1$ + public static String CoreBuildGenericLaunchConfigDelegate_CommandNotValid; + public static String CoreBuildGenericLaunchConfigDelegate_NoAction; + public static String CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed; + public static String CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java index 6d9037fef4d..995eb38c6f9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java @@ -1,164 +1,164 @@ -/*******************************************************************************
- * Copyright (c) 2015 Freescale Semiconductors 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
- *
- * Contributors:
- * Dan Ungureanu (Freescale Semiconductors) - Initial implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.internal.core.breakpoints;
-
-import java.util.Map;
-
-import org.eclipse.cdt.debug.core.model.ICBreakpoint;
-import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
-import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.IBreakpointImportParticipant;
-
-/**
- * Initial implementation covering matching breakpoints at import for all platform C/C++ breakpoints
- */
-public class CBreakpointImportParticipant implements IBreakpointImportParticipant {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.debug.core.model.IBreakpointImportParticipant#matches(java
- * .util.Map, org.eclipse.debug.core.model.IBreakpoint)
- */
- public boolean matches(Map<String, Object> attributes, IBreakpoint breakpoint)
- throws CoreException {
- if (attributes == null || breakpoint == null) {
- return false;
- }
- String type = (String) attributes.get("type"); //$NON-NLS-1$
- if (type == null) {
- return false;
- }
- if (!breakpoint.getMarker().getType().equals(type)) {
- return false;
- }
- if (breakpoint instanceof AbstractLineBreakpoint) {
- return matchesLineBreakpoint(attributes,
- (AbstractLineBreakpoint) breakpoint);
- }
- if (breakpoint instanceof AbstractTracepoint) {
- return matchesTracepoint(attributes,
- (AbstractTracepoint) breakpoint);
- }
- if (breakpoint instanceof CEventBreakpoint) {
- return matchesEventBreakpoint(attributes, (CEventBreakpoint) breakpoint);
- }
- if (breakpoint instanceof CWatchpoint) {
- return matchesWatchpoint(attributes, (CWatchpoint) breakpoint);
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.core.model.IBreakpointImportParticipant#verify(org.eclipse.debug.core.model.IBreakpoint)
- */
- @Override
- public void verify(IBreakpoint breakpoint) throws CoreException {}
-
-
- /**
- * Compares two attributes in a <code>null</code> safe way
- *
- * @param attr1
- * the first attribute
- * @param attr2
- * the second attribute
- * @return true if the attributes are equal, false otherwise. If both
- * attributes are <code>null</code> they are considered to be equal
- */
- private boolean attributesEqual(Object attr1, Object attr2) {
- if (attr1 == null) {
- return attr2 == null;
- }
- return attr1.equals(attr2);
- }
-
- /**
- * Returns if the given map of attributes matches the given breakpoint
- * Works for any breakpoint class that extends AbstractLineBreakpoint
- *
- * @param attributes
- * @param breakpoint
- * @return true if the attributes match the breakpoint's attributes, false
- * otherwise
- * @throws CoreException
- */
- private boolean matchesLineBreakpoint(Map<String, Object> attributes, AbstractLineBreakpoint breakpoint)
- throws CoreException {
- Integer line = (Integer) attributes.get(IMarker.LINE_NUMBER);
- int lineNumber = (line == null ? -1 : line.intValue());
- return breakpoint.getLineNumber() == lineNumber
- && attributesEqual(breakpoint.getType(), attributes.get(CBreakpoint.TYPE))
- && attributesEqual(breakpoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE))
- && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS))
- && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION));
- }
-
- /**
- * Returns if the given map of attributes matches the given tracepoint
- * Works for any breakpoint class that extends AbstractTracepoint
- *
- * @param attributes
- * @param tracepoint
- * @return true if the attributes match the tracepoint's attributes, false
- * otherwise
- * @throws CoreException
- */
- private boolean matchesTracepoint(Map<String, Object> attributes, AbstractTracepoint tracepoint)
- throws CoreException {
- Integer line = (Integer) attributes.get(IMarker.LINE_NUMBER);
- int lineNumber = (line == null ? -1 : line.intValue());
- return tracepoint.getLineNumber() == lineNumber
- && attributesEqual(tracepoint.getType(), attributes.get(CBreakpoint.TYPE))
- && attributesEqual(tracepoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE))
- && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS))
- && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION));
- }
-
- /**
- * Returns if the given map of attributes matches the given event breakpoint
- *
- * @param attributes
- * @param breakpoint
- * @return true if the attributes match the event breakpoint's attributes, false
- * otherwise
- * @throws CoreException
- */
- private boolean matchesEventBreakpoint(Map<String, Object> attributes, CEventBreakpoint breakpoint)
- throws CoreException {
- return breakpoint.getEventArgument().equals(
- attributes.get(ICEventBreakpoint.EVENT_ARG))
- && attributesEqual(breakpoint.getEventType(),
- attributes.get(ICEventBreakpoint.EVENT_TYPE_ID));
- }
-
- /**
- * Returns if the given map of attributes matches the given watchpoint
- *
- * @param attributes
- * @param breakpoint
- * @return true if the attributes match the watchpoint's attributes, false
- * otherwise
- * @throws CoreException
- */
- private boolean matchesWatchpoint(Map<String, Object> attributes, CWatchpoint watchpoint)
- throws CoreException {
- return watchpoint.getExpression().equals(
- attributes.get(CWatchpoint.EXPRESSION))
- && attributesEqual(watchpoint.getType(),
- attributes.get(CBreakpoint.TYPE));
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2015 Freescale Semiconductors 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 + * + * Contributors: + * Dan Ungureanu (Freescale Semiconductors) - Initial implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.core.breakpoints; + +import java.util.Map; + +import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.core.model.ICEventBreakpoint; +import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.core.model.IBreakpointImportParticipant; + +/** + * Initial implementation covering matching breakpoints at import for all platform C/C++ breakpoints + */ +public class CBreakpointImportParticipant implements IBreakpointImportParticipant { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.debug.core.model.IBreakpointImportParticipant#matches(java + * .util.Map, org.eclipse.debug.core.model.IBreakpoint) + */ + public boolean matches(Map<String, Object> attributes, IBreakpoint breakpoint) + throws CoreException { + if (attributes == null || breakpoint == null) { + return false; + } + String type = (String) attributes.get("type"); //$NON-NLS-1$ + if (type == null) { + return false; + } + if (!breakpoint.getMarker().getType().equals(type)) { + return false; + } + if (breakpoint instanceof AbstractLineBreakpoint) { + return matchesLineBreakpoint(attributes, + (AbstractLineBreakpoint) breakpoint); + } + if (breakpoint instanceof AbstractTracepoint) { + return matchesTracepoint(attributes, + (AbstractTracepoint) breakpoint); + } + if (breakpoint instanceof CEventBreakpoint) { + return matchesEventBreakpoint(attributes, (CEventBreakpoint) breakpoint); + } + if (breakpoint instanceof CWatchpoint) { + return matchesWatchpoint(attributes, (CWatchpoint) breakpoint); + } + return false; + } + + /* + * (non-Javadoc) + * @see org.eclipse.debug.core.model.IBreakpointImportParticipant#verify(org.eclipse.debug.core.model.IBreakpoint) + */ + @Override + public void verify(IBreakpoint breakpoint) throws CoreException {} + + + /** + * Compares two attributes in a <code>null</code> safe way + * + * @param attr1 + * the first attribute + * @param attr2 + * the second attribute + * @return true if the attributes are equal, false otherwise. If both + * attributes are <code>null</code> they are considered to be equal + */ + private boolean attributesEqual(Object attr1, Object attr2) { + if (attr1 == null) { + return attr2 == null; + } + return attr1.equals(attr2); + } + + /** + * Returns if the given map of attributes matches the given breakpoint + * Works for any breakpoint class that extends AbstractLineBreakpoint + * + * @param attributes + * @param breakpoint + * @return true if the attributes match the breakpoint's attributes, false + * otherwise + * @throws CoreException + */ + private boolean matchesLineBreakpoint(Map<String, Object> attributes, AbstractLineBreakpoint breakpoint) + throws CoreException { + Integer line = (Integer) attributes.get(IMarker.LINE_NUMBER); + int lineNumber = (line == null ? -1 : line.intValue()); + return breakpoint.getLineNumber() == lineNumber + && attributesEqual(breakpoint.getType(), attributes.get(CBreakpoint.TYPE)) + && attributesEqual(breakpoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE)) + && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS)) + && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION)); + } + + /** + * Returns if the given map of attributes matches the given tracepoint + * Works for any breakpoint class that extends AbstractTracepoint + * + * @param attributes + * @param tracepoint + * @return true if the attributes match the tracepoint's attributes, false + * otherwise + * @throws CoreException + */ + private boolean matchesTracepoint(Map<String, Object> attributes, AbstractTracepoint tracepoint) + throws CoreException { + Integer line = (Integer) attributes.get(IMarker.LINE_NUMBER); + int lineNumber = (line == null ? -1 : line.intValue()); + return tracepoint.getLineNumber() == lineNumber + && attributesEqual(tracepoint.getType(), attributes.get(CBreakpoint.TYPE)) + && attributesEqual(tracepoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE)) + && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS)) + && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION)); + } + + /** + * Returns if the given map of attributes matches the given event breakpoint + * + * @param attributes + * @param breakpoint + * @return true if the attributes match the event breakpoint's attributes, false + * otherwise + * @throws CoreException + */ + private boolean matchesEventBreakpoint(Map<String, Object> attributes, CEventBreakpoint breakpoint) + throws CoreException { + return breakpoint.getEventArgument().equals( + attributes.get(ICEventBreakpoint.EVENT_ARG)) + && attributesEqual(breakpoint.getEventType(), + attributes.get(ICEventBreakpoint.EVENT_TYPE_ID)); + } + + /** + * Returns if the given map of attributes matches the given watchpoint + * + * @param attributes + * @param breakpoint + * @return true if the attributes match the watchpoint's attributes, false + * otherwise + * @throws CoreException + */ + private boolean matchesWatchpoint(Map<String, Object> attributes, CWatchpoint watchpoint) + throws CoreException { + return watchpoint.getExpression().equals( + attributes.get(CWatchpoint.EXPRESSION)) + && attributesEqual(watchpoint.getType(), + attributes.get(CBreakpoint.TYPE)); + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/messages.properties b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/messages.properties index c00aff78954..387004aeef9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/messages.properties +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/messages.properties @@ -1,11 +1,11 @@ -###############################################################################
-# Copyright (c) 2003, 2010 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
-###############################################################################
-CoreBuildGenericLaunchConfigDelegate_CommandNotValid=Not a valid command "%s"
-CoreBuildGenericLaunchConfigDelegate_NoAction=No action specified. Skipping.
-CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed=Variable substitution failed "%s"
-CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists=Working directory %s does not exist
+############################################################################### +# Copyright (c) 2003, 2010 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 +############################################################################### +CoreBuildGenericLaunchConfigDelegate_CommandNotValid=Not a valid command "%s" +CoreBuildGenericLaunchConfigDelegate_NoAction=No action specified. Skipping. +CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed=Variable substitution failed "%s" +CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists=Working directory %s does not exist |