Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorJohn Cortell2011-04-12 12:35:04 -0400
committerJohn Cortell2011-04-12 12:35:04 -0400
commit69e391fbe1449dd23c395e3021ab222e51637d28 (patch)
treedfa2b5f135ccce69c70abb16bbc6add896760a48 /debug
parent706f09f8858ce7817b081f2b282a1b2d08a00f3e (diff)
downloadorg.eclipse.cdt-69e391fbe1449dd23c395e3021ab222e51637d28.tar.gz
org.eclipse.cdt-69e391fbe1449dd23c395e3021ab222e51637d28.tar.xz
org.eclipse.cdt-69e391fbe1449dd23c395e3021ab222e51637d28.zip
Bug 342096 - Executables view shows binaries for all build configurations instead of just the active ones
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java3
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java46
2 files changed, 44 insertions, 5 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java
index c9b0c58d7e..9a5baedd30 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java
@@ -36,7 +36,8 @@ public interface IProjectExecutablesProvider {
List<String> getProjectNatures();
/**
- * Get the list of executables for the given project
+ * Get the list of executables for the active configuration of the given
+ * project
* @param project the project to get the executables for
* @param monitor progress monitor
* @return the list of executables (which may be empty)
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java
index 8280f5f9aa..52903c09f8 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java
@@ -12,15 +12,19 @@
package org.eclipse.cdt.debug.core.executables;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.internal.core.model.CModelManager;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -52,9 +56,42 @@ public class StandardExecutableProvider implements IProjectExecutablesProvider {
ICProject cproject = CModelManager.getDefault().create(project);
try {
- IBinary[] binaries = cproject.getBinaryContainer().getBinaries();
+ // Start out by getting all binaries in all build configurations. If
+ // we can't filter based on the active configuration, we'll use this
+ // complete list
+ IBinary[] allBinaries = cproject.getBinaryContainer().getBinaries();
+ if (allBinaries.length == 0) {
+ return executables; // save ourselves a lot of pointless busy work
+ }
+
+ // Get the output directories of the active build configuration then
+ // go through the list of all binaries and pick only the ones that
+ // are in these output directories
+ List<IBinary> binaries = null;
+ ICProjectDescription projDesc = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ if (projDesc != null) {
+ ICConfigurationDescription cfg = projDesc.getActiveConfiguration();
+ if (cfg != null) {
+ binaries = new ArrayList<IBinary>(allBinaries.length);
+ ICOutputEntry[] cfgOutDirs = cfg.getBuildSetting().getOutputDirectories();
+ for (IBinary allBinary : allBinaries) {
+ for (ICOutputEntry outdir : cfgOutDirs) {
+ if (outdir.getFullPath().isPrefixOf(allBinary.getPath())) {
+ binaries.add(allBinary);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // If we weren't able to filter on the active configuration,
+ // consider binaries from all configurations
+ if (binaries == null) {
+ binaries = Arrays.asList(allBinaries);
+ }
- SubMonitor progress = SubMonitor.convert(monitor, binaries.length);
+ SubMonitor progress = SubMonitor.convert(monitor, binaries.size());
for (IBinary binary : binaries) {
if (progress.isCanceled()) {
@@ -78,7 +115,8 @@ public class StandardExecutableProvider implements IProjectExecutablesProvider {
progress.worked(1);
}
- } catch (CModelException e) {
+ } catch (CoreException e) {
+ CDebugCorePlugin.log(e);
}
return executables;

Back to the top