From 55a0d30355f89f288b2d51597dc2b829f5ec6b37 Mon Sep 17 00:00:00 2001 From: Ken Ryall Date: Tue, 4 Nov 2008 21:39:26 +0000 Subject: [PATCH] Improvements to the Executables manager including work for bug 253778. --- .../debug/core/executables/Executable.java | 13 +++++++-- .../core/executables/ExecutablesManager.java | 20 +++++++++---- .../executables/ISourceFileRemapping.java | 2 +- .../StandardExecutableImporter.java | 28 ++++++++++++++++--- .../StandardSourceFileRemapping.java | 2 +- 5 files changed, 52 insertions(+), 13 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java index 5df9ac5fae3..f1b3ae55aeb 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java @@ -71,6 +71,15 @@ public class Executable extends PlatformObject { return true; } + public boolean equals(Object arg0) { + if (arg0 instanceof Executable) + { + Executable exe = (Executable)arg0; + return exe.getPath().equals(this.getPath()); + } + return super.equals(arg0); + } + private IPath path; private IProject project; private String name; @@ -143,7 +152,7 @@ public class Executable extends PlatformObject { String filename = symReaderSources[i]; String orgPath = filename; - filename = ExecutablesManager.getExecutablesManager().remapSourceFile(filename); + filename = ExecutablesManager.getExecutablesManager().remapSourceFile(this, filename); // Sometimes the path in the symbolics will have a // different @@ -222,7 +231,7 @@ public class Executable extends PlatformObject { public String getOriginalLocation(ITranslationUnit tu) { String orgLocation = remappedPaths.get(tu); if (orgLocation == null) - orgLocation = tu.getPath().toOSString(); + orgLocation = tu.getLocation().toOSString(); return orgLocation; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java index a8f9ae26b32..8483f3c2dc9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java @@ -170,14 +170,18 @@ public class ExecutablesManager extends PlatformObject { DebugPlugin.log( e ); } } - Collection exes = executables.values(); - return exes.toArray(new Executable[exes.size()]); + + synchronized (executables) + { + Collection exes = executables.values(); + return exes.toArray(new Executable[exes.size()]); + } } - public String remapSourceFile(String filePath) { + public String remapSourceFile(Executable executable, String filePath) { synchronized (sourceFileRemappings) { for (ISourceFileRemapping remapping : sourceFileRemappings) { - String remappedPath = remapping.remapSourceFile(filePath); + String remappedPath = remapping.remapSourceFile(executable, filePath); if (!remappedPath.equals(filePath)) return remappedPath; } @@ -245,7 +249,9 @@ public class ExecutablesManager extends PlatformObject { } public boolean executableExists(IPath exePath) { - return executables.containsKey(exePath.toOSString()); + synchronized (executables) { + return executables.containsKey(exePath.toOSString()); + } } public String[] getSourceFiles(final Executable executable, @@ -320,4 +326,8 @@ public class ExecutablesManager extends PlatformObject { return result; } + public void setRefreshNeeded(boolean refresh) { + refreshNeeded = true; + } + } \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemapping.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemapping.java index 85948e3b61a..ff0a0d60f74 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemapping.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemapping.java @@ -19,6 +19,6 @@ package org.eclipse.cdt.debug.core.executables; */ public interface ISourceFileRemapping { - String remapSourceFile(String filePath); + String remapSourceFile(Executable executable, String filePath); } \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java index bf6b1ed7f8f..88129a6db93 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.core.filesystem.EFS; @@ -39,7 +40,9 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.*; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.core.runtime.content.IContentTypeManager; +import org.eclipse.core.runtime.content.IContentTypeSettings; import org.eclipse.debug.core.DebugPlugin; public class StandardExecutableImporter implements IExecutableImporter { @@ -96,7 +99,12 @@ public class StandardExecutableImporter implements IExecutableImporter { store = store.getChild(newProjectHandle.getName()); for (String deleteName : ignoreList) { IFileStore projFile = store.getChild(deleteName); - projFile.delete(EFS.NONE, null); + projFile.delete(EFS.NONE, new NullProgressMonitor()); + } + IFileStore[] children = store.childStores(EFS.NONE, new NullProgressMonitor()); + for (IFileStore fileStore : children) { + if (fileStore.fetchInfo().isDirectory()) + fileStore.delete(EFS.NONE, new NullProgressMonitor()); } exeProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, null, DEBUG_PROJECT_ID); } catch (OperationCanceledException e) { @@ -224,8 +232,20 @@ public class StandardExecutableImporter implements IExecutableImporter { // Make sure the project has this parser ICProjectDescription pd = CCorePlugin.getDefault().getProjectDescription(exeProject); try { - pd.getDefaultSettingConfiguration().create(CCorePlugin.BINARY_PARSER_UNIQ_ID, parserID); - CCorePlugin.getDefault().setProjectDescription(exeProject, pd, true, new NullProgressMonitor()); + boolean existsAlready = false; + ICConfigExtensionReference[] parsers = pd.getDefaultSettingConfiguration().get(CCorePlugin.BINARY_PARSER_UNIQ_ID); + for (ICConfigExtensionReference configExtensionReference : parsers) { + if (configExtensionReference.getID().equals(parserID)) + { + existsAlready = true; + break; + } + } + if (!existsAlready) + { + pd.getDefaultSettingConfiguration().create(CCorePlugin.BINARY_PARSER_UNIQ_ID, parserID); + CCorePlugin.getDefault().setProjectDescription(exeProject, pd, true, new NullProgressMonitor()); + } } catch (CoreException e) { } return true; diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardSourceFileRemapping.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardSourceFileRemapping.java index 001dd717dde..1afcea46431 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardSourceFileRemapping.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardSourceFileRemapping.java @@ -23,7 +23,7 @@ import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; public class StandardSourceFileRemapping implements ISourceFileRemapping { - public String remapSourceFile(String filePath) { + public String remapSourceFile(Executable executable, String filePath) { try { Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().findSourceElements(filePath);