Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2014-04-24 22:31:02 +0000
committerJeff Johnston2014-04-24 22:31:02 +0000
commit6d1f46500b56302ed19f5d5f3d4648ff8029a050 (patch)
tree4cffee6252090d4d5e41f2d101d4e28b456449f6
parent009784803d82708f7a0543452cf69bbc78f2231d (diff)
downloadorg.eclipse.cdt-6d1f46500b56302ed19f5d5f3d4648ff8029a050.tar.gz
org.eclipse.cdt-6d1f46500b56302ed19f5d5f3d4648ff8029a050.tar.xz
org.eclipse.cdt-6d1f46500b56302ed19f5d5f3d4648ff8029a050.zip
Clean up Standalone Debugger behaviourGDBStandalone
- when starting an attached executable, no longer remove any executable launch - don't save the memento for an attached launch - when starting the debugger and no binary is specified after cancelling the executable dialog, issue a warning that there is nothing for the debugger to debug instead of an error - fix NPE when no executable or anything else is specified Change-Id: I35246977989d6f15402c10a3ea9130562fd390ba
-rw-r--r--debug/org.eclipse.cdt.debug.application/.gitignore15
-rw-r--r--debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java4
-rw-r--r--debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/messages.properties2
-rw-r--r--debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java287
4 files changed, 137 insertions, 171 deletions
diff --git a/debug/org.eclipse.cdt.debug.application/.gitignore b/debug/org.eclipse.cdt.debug.application/.gitignore
index adbf3cdb9a7..548434be930 100644
--- a/debug/org.eclipse.cdt.debug.application/.gitignore
+++ b/debug/org.eclipse.cdt.debug.application/.gitignore
@@ -149,3 +149,18 @@
/bin
/bin
/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java
index 67dfca9084a..0c94e45ea69 100644
--- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java
+++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java
@@ -239,7 +239,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
config = DebugAttachedExecutable.createLaunchConfig(monitor, buildLog);
} else if (corefile != null && corefile.length() > 0) {
config = DebugCoreFile.createLaunchConfig(monitor, buildLog, executable, corefile);
- } else if (executable.length() > 0) {
+ } else if (executable != null && executable.length() > 0) {
config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments);
} else {
// No executable specified, look for last launch
@@ -257,7 +257,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
oldBuildLog = config.getAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION, ""); //$NON-NLS-1$
}
final NewExecutableInfo info = new NewExecutableInfo("", "", "", ""); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
- final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0,
+ final IStatus errorStatus = new Status(IStatus.WARNING, Activator.PLUGIN_ID, 0,
Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist, null);
final String executablePath = oldExecutable;
final String executableArgs = oldArguments;
diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/messages.properties b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/messages.properties
index 67d1ba6eaf9..67b099d83ea 100644
--- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/messages.properties
+++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/messages.properties
@@ -28,7 +28,7 @@ DebuggerInitializingProblem=Problem occurred in start-up
GdbDebugNewExecutableCommand_Arguments=Arguments:
GdbDebugNewExecutableCommand_Binary=Binary:
-GdbDebugNewExecutableCommand_Binary_file_does_not_exist=Binary file does not exist
+GdbDebugNewExecutableCommand_Binary_file_does_not_exist=Debugger will start up with no input
GdbDebugNewExecutableCommand_Binary_must_be_specified=Binary must be specified
GdbDebugNewExecutableCommand_Binary_on_host=Binary on host:
GdbDebugNewExecutableCommand_Binary_on_target=Binary on target:
diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java
index d895311521b..32582bbe892 100644
--- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java
+++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java
@@ -12,30 +12,23 @@ package org.eclipse.cdt.internal.debug.application;
import java.io.File;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.debug.application.Messages;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.executables.Executable;
-import org.eclipse.cdt.debug.core.executables.ExecutablesManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.QualifiedName;
@@ -50,7 +43,7 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
public class DebugAttachedExecutable {
-
+
private static final String GCC_BUILTIN_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"; //$NON-NLS-1$
private static final String GCC_COMPILE_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.debug.application.DwarfLanguageSettingsProvider"; //$NON-NLS-1$
private static final String GCC_BUILD_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$
@@ -61,16 +54,24 @@ public class DebugAttachedExecutable {
public DebugAttachedExecutable() {
}
-
+
public static ILaunchManager getLaunchManager() {
return DebugPlugin.getDefault().getLaunchManager();
}
-
+
+ // Create a new project that doesn't already exist. Use the base project name and add
+ // a numerical suffix as needed.
private static IProject createCProjectForExecutable(String projectName) throws OperationCanceledException, CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject newProjectHandle = workspace.getRoot().getProject(projectName);
+ int projectSuffix = 2;
+ while (newProjectHandle.exists()){
+ newProjectHandle = workspace.getRoot().getProject(projectName + projectSuffix);
+ projectSuffix++;
+ }
+
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
description.setLocation(null);
@@ -79,7 +80,7 @@ public class DebugAttachedExecutable {
return newProject;
}
-
+
/**
* Import given executable into the Executables project then create a launch configuration.
*
@@ -92,174 +93,124 @@ public class DebugAttachedExecutable {
*/
public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor,
String buildLog)
- throws CoreException, InterruptedException {
+ throws CoreException, InterruptedException {
ILaunchConfiguration config = null;
String defaultProjectName = "Executables"; //$NON-NLS-1$
- ICProject cProject = CoreModel.getDefault().getCModel()
- .getCProject(defaultProjectName);
-
- // if a valid executable is specified, remove any executables already loaded in workspace
- if (cProject.exists()) {
- monitor.subTask(Messages.RemoveOldExecutable);
- IProject proj = cProject.getProject();
- Collection<Executable> elist = ExecutablesManager.getExecutablesManager().getExecutablesForProject(proj);
- Executable[] executables = new Executable[elist.size()];
- elist.toArray(executables);
- @SuppressWarnings("unused")
- IStatus rc = ExecutablesManager.getExecutablesManager().removeExecutables(executables, new NullProgressMonitor());
- // Remove all old members of the Executables project from the last run
- IResource[] resources = proj.members();
- for (IResource resource : resources) {
- resource.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT|IResource.FORCE, new NullProgressMonitor());
- }
- monitor.worked(1);
- // Find last launch if one exists
- String memento = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH));
-// System.out.println("memento is " + memento);
- if (memento != null) {
- ILaunchConfiguration lastConfiguration = getLaunchManager().getLaunchConfiguration(memento);
- try {
- lastConfiguration.getType();
- if (lastConfiguration.exists())
- lastConfiguration.delete();
- } catch (CoreException e) {
- // do nothing
- }
- }
-
- // Delete project because we have deleted .cproject and settings files
- // by this point so just create a new Executables C project to use for
- // importing the new executable.
- proj.delete(true, new NullProgressMonitor());
- monitor.worked(1);
- }
-
- // Executables project doesn't already exist, create it
- createCProjectForExecutable(defaultProjectName);
-
+ // Create a new Executablesnn project
+ IProject project = createCProjectForExecutable(defaultProjectName);
+
monitor.worked(3);
- // either get default project or create it
- cProject = CoreModel.getDefault().getCModel()
- .getCProject(defaultProjectName);
- if (cProject.exists()) {
- File buildLogFile = null;
- final IProject project = cProject.getProject();
-
- final ICProjectDescriptionManager projDescManager = CCorePlugin
- .getDefault().getProjectDescriptionManager();
-
- ICProjectDescription projectDescription = projDescManager
- .getProjectDescription(project,
- ICProjectDescriptionManager.GET_WRITABLE);
-
- monitor.subTask(Messages.SetLanguageProviders);
- final ICConfigurationDescription ccd = projectDescription
- .getActiveConfiguration();
- String[] langProviderIds = ((ILanguageSettingsProvidersKeeper) ccd)
- .getDefaultLanguageSettingsProvidersIds();
- boolean found = false;
- for (int i = 0; i < langProviderIds.length; ++i) {
- if (langProviderIds[i].equals(GCC_BUILTIN_PROVIDER_ID)) {
- found = true;
- break;
- }
- }
- // Look for the GCC builtin LanguageSettingsProvider id. If it isn't already
- // there, add it.
- if (!found) {
- langProviderIds = Arrays.copyOf(langProviderIds,
- langProviderIds.length + 1);
- langProviderIds[langProviderIds.length - 1] = GCC_BUILTIN_PROVIDER_ID;
+ File buildLogFile = null;
+
+ final ICProjectDescriptionManager projDescManager = CCorePlugin
+ .getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription projectDescription = projDescManager
+ .getProjectDescription(project,
+ ICProjectDescriptionManager.GET_WRITABLE);
+
+ monitor.subTask(Messages.SetLanguageProviders);
+ final ICConfigurationDescription ccd = projectDescription
+ .getActiveConfiguration();
+ String[] langProviderIds = ((ILanguageSettingsProvidersKeeper) ccd)
+ .getDefaultLanguageSettingsProvidersIds();
+ boolean found = false;
+ for (int i = 0; i < langProviderIds.length; ++i) {
+ if (langProviderIds[i].equals(GCC_BUILTIN_PROVIDER_ID)) {
+ found = true;
+ break;
}
- found = false;
- for (int i = 0; i < langProviderIds.length; ++i) {
- if (langProviderIds[i].equals(GCC_COMPILE_OPTIONS_PROVIDER_ID)) {
- found = true;
- break;
- }
- }
- // Look for our macro parser provider id. If it isn't added already, do so now.
- if (!found) {
- langProviderIds = Arrays.copyOf(langProviderIds,
- langProviderIds.length + 1);
- langProviderIds[langProviderIds.length - 1] = GCC_COMPILE_OPTIONS_PROVIDER_ID;
+ }
+ // Look for the GCC builtin LanguageSettingsProvider id. If it isn't already
+ // there, add it.
+ if (!found) {
+ langProviderIds = Arrays.copyOf(langProviderIds,
+ langProviderIds.length + 1);
+ langProviderIds[langProviderIds.length - 1] = GCC_BUILTIN_PROVIDER_ID;
+ }
+ found = false;
+ for (int i = 0; i < langProviderIds.length; ++i) {
+ if (langProviderIds[i].equals(GCC_COMPILE_OPTIONS_PROVIDER_ID)) {
+ found = true;
+ break;
}
+ }
+ // Look for our macro parser provider id. If it isn't added already, do so now.
+ if (!found) {
+ langProviderIds = Arrays.copyOf(langProviderIds,
+ langProviderIds.length + 1);
+ langProviderIds[langProviderIds.length - 1] = GCC_COMPILE_OPTIONS_PROVIDER_ID;
+ }
- if (buildLog != null) {
- File f = new File(buildLog);
- if (f.exists()) {
- buildLogFile = f;
- found = false;
- for (int i = 0; i < langProviderIds.length; ++i) {
- if (langProviderIds[i].equals(GCC_BUILD_OPTIONS_PROVIDER_ID)) {
- found = true;
- break;
- }
- }
- // Look for our macro parser provider id. If it isn't added already, do so now.
- if (!found) {
- langProviderIds = Arrays.copyOf(langProviderIds,
- langProviderIds.length + 1);
- langProviderIds[langProviderIds.length - 1] = GCC_BUILD_OPTIONS_PROVIDER_ID;
+ if (buildLog != null) {
+ File f = new File(buildLog);
+ if (f.exists()) {
+ buildLogFile = f;
+ found = false;
+ for (int i = 0; i < langProviderIds.length; ++i) {
+ if (langProviderIds[i].equals(GCC_BUILD_OPTIONS_PROVIDER_ID)) {
+ found = true;
+ break;
}
}
+ // Look for our macro parser provider id. If it isn't added already, do so now.
+ if (!found) {
+ langProviderIds = Arrays.copyOf(langProviderIds,
+ langProviderIds.length + 1);
+ langProviderIds[langProviderIds.length - 1] = GCC_BUILD_OPTIONS_PROVIDER_ID;
+ }
}
+ }
- // System.out.println("creating language settings providers");
- // Create all the LanguageSettingsProviders
- List<ILanguageSettingsProvider> providers = LanguageSettingsManager
- .createLanguageSettingsProviders(langProviderIds);
-
- // Update the providers for the configuration.
- ((ILanguageSettingsProvidersKeeper) ccd)
- .setLanguageSettingProviders(providers);
-
- monitor.worked(1);
-
- // System.out.println("before setProjectDescription");
-
- // Update the project description.
- projDescManager.setProjectDescription(project,
- projectDescription);
-
- // System.out.println("after setProjectDescription");
-
- // Serialize the language settings for the project now in case we don't run a
- // language settings provider which will do this in shutdown.
- ICProjectDescription projDescReadOnly = projDescManager
- .getProjectDescription(project,
- false);
- LanguageSettingsManager.serializeLanguageSettings(projDescReadOnly);
-
- monitor.worked(1);
-
- if (buildLogFile != null)
- // We need to parse the build log to get compile options. We need to lock the
- // workspace when we do this so we don't have multiple copies of GCCBuildOptionsParser
- // LanguageSettingsProvider and we end up filling in the wrong one.
- project.getWorkspace().run(new BuildOptionsParser(project, buildLogFile),
- ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
-
- // System.out.println("about to close all editors");
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- if (workbenchWindow != null) {
- final IWorkbenchPage activePage = workbenchWindow.getActivePage();
- if (activePage != null)
- activePage.closeAllEditors(false);
- }
+ // System.out.println("creating language settings providers");
+ // Create all the LanguageSettingsProviders
+ List<ILanguageSettingsProvider> providers = LanguageSettingsManager
+ .createLanguageSettingsProviders(langProviderIds);
+
+ // Update the providers for the configuration.
+ ((ILanguageSettingsProvidersKeeper) ccd)
+ .setLanguageSettingProviders(providers);
+
+ monitor.worked(1);
+
+ // System.out.println("before setProjectDescription");
+
+ // Update the project description.
+ projDescManager.setProjectDescription(project,
+ projectDescription);
+
+ // System.out.println("after setProjectDescription");
+
+ // Serialize the language settings for the project now in case we don't run a
+ // language settings provider which will do this in shutdown.
+ ICProjectDescription projDescReadOnly = projDescManager
+ .getProjectDescription(project,
+ false);
+ LanguageSettingsManager.serializeLanguageSettings(projDescReadOnly);
+
+ monitor.worked(1);
+
+ if (buildLogFile != null)
+ // We need to parse the build log to get compile options. We need to lock the
+ // workspace when we do this so we don't have multiple copies of GCCBuildOptionsParser
+ // LanguageSettingsProvider and we end up filling in the wrong one.
+ project.getWorkspace().run(new BuildOptionsParser(project, buildLogFile),
+ ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
+
+ // System.out.println("about to close all editors");
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null) {
+ final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ if (workbenchWindow != null) {
+ final IWorkbenchPage activePage = workbenchWindow.getActivePage();
+ if (activePage != null)
+ activePage.closeAllEditors(false);
}
- // System.out.println("about to create launch configuration");
- config = createConfiguration(true);
- String memento = config.getMemento();
- ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH), memento);
- monitor.worked(1);
- } else {
- System.out.println("Import job failed");
- return null;
}
+ // System.out.println("about to create launch configuration");
+ config = createConfiguration(true);
+ monitor.worked(1);
return config;
}
@@ -267,9 +218,9 @@ public class DebugAttachedExecutable {
return getLaunchManager().getLaunchConfigurationType(
"org.eclipse.cdt.launch.attachLaunchType"); //$NON-NLS-1$
}
-
+
protected static ILaunchConfiguration createConfiguration(boolean save) {
-// System.out.println("creating launch configuration");
+ // System.out.println("creating launch configuration");
ILaunchConfiguration config = null;
try {
ILaunchConfigurationType configType = getLaunchConfigType();

Back to the top