aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2018-05-22 18:29:35 -0400
committerJeff Johnston2018-05-29 15:20:00 -0400
commitda57b8881279310261a67159992135d140ca8c20 (patch)
treee42d7bcaf8d126cde837d7ab4a9bd68df2616d9d
parent8bc138b9db3e727c9183a82828e6660a02a17092 (diff)
downloadorg.eclipse.linuxtools-da57b8881279310261a67159992135d140ca8c20.tar.gz
org.eclipse.linuxtools-da57b8881279310261a67159992135d140ca8c20.tar.xz
org.eclipse.linuxtools-da57b8881279310261a67159992135d140ca8c20.zip
Bug 494296 - GCov plugin handling of linked resources
- modify STSymbolManager and add 3 new methods: (1) findFileFromPath to find linked resource (2) getProjectFromFile to resolve project from file (3) findOneAndOnlyBinary to find binary which can be linked - replace all occurences of getFileForLocation by STSymbolManager.sharedInstance.findFileFromPath Change-Id: I551452e969552e4b5cea7cc2fc5fc0ba46d0063f Reviewed-on: https://git.eclipse.org/r/123109 Tested-by: CI Bot Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java17
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java9
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java13
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovViewer.java4
-rw-r--r--profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java7
-rw-r--r--profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java148
-rw-r--r--profiling/org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF1
-rw-r--r--profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java5
8 files changed, 186 insertions, 18 deletions
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java
index d7e3159ca5..66ec9eb345 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/action/OpenGCAction.java
@@ -17,7 +17,6 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
-
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary;
@@ -26,7 +25,6 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -114,7 +112,9 @@ public class OpenGCAction implements IEditorLauncher {
}
String defaultBinary = defaultMapping.get(file.toOSString());
if (defaultBinary == null || defaultBinary.isEmpty() || !exists(defaultBinary)) {
- defaultBinary = getDefaultBinary(file);
+ //FIXME EK-LINUXTOOLS: defaultBinary = getDefaultBinary(file);
+ defaultBinary =
+ STSymbolManager.sharedInstance.findOneAndOnlyBinary(file).getLocation().toOSString();
}
OpenGCDialog d = new OpenGCDialog(shell, defaultBinary, file);
@@ -128,8 +128,12 @@ public class OpenGCAction implements IEditorLauncher {
t.start();
}
- private void displayCoverage(IPath file, String binaryPath, File gcda, boolean isCompleteCoverageResultWanted) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file).getProject();
+ private void displayCoverage(IPath file, String binaryPath, File gcda, boolean isCompleteCoverageResultWanted)
+ {
+ //FIXME EK-LINUXTOOLS: IProject project = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file).getProject();
+ IProject project = STSymbolManager.sharedInstance.getProjectFromFile(file);
+ //FIXME EK-LINUXTOOLS: Need check for null and correct action
+
GcovAnnotationModelTracker.getInstance().addProject(project, new Path(binaryPath));
PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
GcovAnnotationModelTracker.getInstance().annotateAllCEditors();
@@ -172,7 +176,8 @@ public class OpenGCAction implements IEditorLauncher {
}
private String getDefaultBinary(IPath file) {
- IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file);
+ //FIXME EK-LINUXTOOLS: IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file);
+ IFile c = STSymbolManager.sharedInstance.findFileFromPath(file);
if (c != null) {
IProject project = c.getProject();
if (project != null && project.exists()) {
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java
index c43bfd915e..5faea1aad1 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/CovManager.java
@@ -74,7 +74,9 @@ public class CovManager implements Serializable {
private long nbrPgmRuns = 0;
// for view
private CovRootTreeElement rootNode;
- private final IProject project;
+ //FIXME EK-LINUXTOOLS: private final IProject project;
+ //FIXME EK-LINUXTOOLS: Need project for finding local STRINGS etc. Can't be final
+ private IProject project;
/**
* Constructor
@@ -91,8 +93,11 @@ public class CovManager implements Serializable {
* Constructor
* @param binaryPath
*/
- public CovManager(String binaryPath) {
+ public CovManager(String binaryPath)
+ {
this(binaryPath, null);
+ //FIXME EK-LINUXTOOLS: Need project for finding local STRINGS etc.
+ this.project = STSymbolManager.sharedInstance.getProjectFromFile(new Path(binaryPath));;
}
/**
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
index 492030f65b..dde12a56e4 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
@@ -20,11 +20,13 @@ import java.util.Date;
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
@@ -34,6 +36,7 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
import org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView;
import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
import org.eclipse.linuxtools.dataviewers.abstractviewers.TreeColumnViewerFilter;
@@ -144,8 +147,9 @@ public class CovView extends AbstractSTDataView {
public static void displayCovDetailedResult(String binaryPath, String gcda) {
try {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile binary = root.getFileForLocation(new Path(binaryPath));
+ //FIXME EK-LINUXTOOLS: IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ //FIXME EK-LINUXTOOLS: IFile binary = root.getFileForLocation(new Path(binaryPath));
+ IFile binary = STSymbolManager.sharedInstance.findFileFromPath(new Path(binaryPath));
IProject project = null;
if (binary != null) {
project = binary.getProject();
@@ -169,8 +173,9 @@ public class CovView extends AbstractSTDataView {
public static void displayCovResults(String binaryPath, String gcda) {
try {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile binary = root.getFileForLocation(new Path(binaryPath));
+ //FIXME EK-LINUXTOOLS: IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ //FIXME EK-LINUXTOOLS: IFile binary = root.getFileForLocation(new Path(binaryPath));
+ IFile binary = STSymbolManager.sharedInstance.findFileFromPath(new Path(binaryPath));
IProject project = null;
if (binary != null) {
project = binary.getProject();
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovViewer.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovViewer.java
index 27162b06f4..0a4e541ab5 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovViewer.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovViewer.java
@@ -22,6 +22,7 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTreeViewer;
import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
import org.eclipse.linuxtools.internal.gcov.model.CovFileTreeElement;
@@ -96,7 +97,8 @@ public class CovViewer extends AbstractSTTreeViewer {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
String binaryLoc = cvm.getBinaryPath();
IPath binaryPath = new Path(binaryLoc);
- IFile binary = root.getFileForLocation(binaryPath);
+ //FIXME EK-LINUXTOOLS: IFile binary = root.getFileForLocation(binaryPath);
+ IFile binary = STSymbolManager.sharedInstance.findFileFromPath(binaryPath);
IProject project = null;
if (binary != null) {
project = binary.getProject();
diff --git a/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java b/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java
index 452e3425d7..15c41a46f8 100644
--- a/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java
+++ b/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java
@@ -45,6 +45,7 @@ import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
import org.eclipse.linuxtools.internal.Activator;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -74,7 +75,8 @@ public final class STLink2SourceSupport {
*/
private static boolean openSourceFileAtLocation(IPath binaryLoc, IPath sourceLoc, int lineNumber) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile binary = root.getFileForLocation(binaryLoc);
+ //FIXME EK-LINUXTOOLS: IFile binary = root.getFileForLocation(binaryLoc);
+ IFile binary = STSymbolManager.sharedInstance.findFileFromPath(binaryLoc);
IProject project = null;
if (binary != null) {
project = binary.getProject();
@@ -257,7 +259,8 @@ public final class STLink2SourceSupport {
private static IFile getFileForPathImpl(IPath path, IProject project) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
if (path.isAbsolute()) {
- return root.getFileForLocation(path);
+ //FIXME EK-LINUXTOOLS: return root.getFileForLocation(path);
+ return STSymbolManager.sharedInstance.findFileFromPath(path);
}
if (project != null && project.exists()) {
diff --git a/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java b/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java
index 19d4e0c5c4..205287157a 100644
--- a/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java
+++ b/profiling/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java
@@ -15,6 +15,7 @@
package org.eclipse.linuxtools.binutils.utils;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
@@ -36,9 +37,11 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.utils.Addr2line;
import org.eclipse.cdt.utils.CPPFilt;
+import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -381,7 +384,8 @@ public class STSymbolManager {
* @return a IBinaryObject
*/
private IBinaryObject getBinaryObject(IPath path, IBinaryParser defaultparser) {
- IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ //FIXME EK-LINUXTOOLS: IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ IFile c = findFileFromPath(path);
List<IBinaryParser> parsers;
if (c != null) {
IBinaryObject object = getAlreadyExistingBinaryObject(c);
@@ -428,6 +432,148 @@ public class STSymbolManager {
return ret;
}
+ //FIXME EK-LINUXTOOLS: Search workspace for one binary
+ /**
+ * Searches workspace and tries to find one-and-only binary which could have
+ * created GCOV files.
+ * 1. Look in the project where .gcda or .gcna file are registered
+ * 2. Search workspace and list all binaries
+ * 3. If there is only one binary found then return it
+ *
+ * @param file
+ * @return Binary path or null
+ * @since 6.0
+ */
+ public IResource findOneAndOnlyBinary(IPath file)
+ {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource project;
+ IResource binary = null;
+
+ project = STSymbolManager.sharedInstance.getProjectFromFile(file);
+ if (project != null && project.exists())
+ {
+ ICProject cproject = (ICProject)CoreModel.getDefault().create(project);
+ if (cproject != null)
+ {
+ try
+ {
+ IBinary[] bs = cproject.getBinaryContainer().getBinaries();
+ if (bs.length == 1)
+ {
+ binary = bs[0].getResource();
+ }
+ }
+ catch (CModelException e)
+ {
+ String message =
+ "Error getting binaries for [" + cproject.toString() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ CCorePlugin.log(message, e);
+ }
+ }
+ }
+
+ if (binary == null)
+ {
+ /*
+ * Apparently we did not find one binary in the project
+ * where GCOV files are located.
+ * Search workspace in hopes that there will be only one binary there
+ */
+ ArrayList<IResource> binaries = new ArrayList<>();
+ IProject projects[] = root.getProjects();
+ for (IProject prj : projects)
+ {
+ ICProject cproject = CoreModel.getDefault().create(prj);
+ if (cproject != null)
+ {
+ try
+ {
+ IBinary[] bs = cproject.getBinaryContainer().getBinaries();
+ if (bs.length == 1)
+ {
+ /*
+ * Validate binary. Not tested
+ */
+ IBinaryObject binObj =
+ STSymbolManager.sharedInstance.getBinaryObject(bs[0].getPath());
+ if (binObj != null)
+ {
+ binaries.add(bs[0].getResource());
+ }
+ }
+ }
+ catch (CModelException e)
+ {
+ String message =
+ "Error getting binaries for [" + cproject.toString() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ CCorePlugin.log(message, e);
+ }
+ }
+
+ }
+
+ if (binaries.size() == 1)
+ {
+ binary = binaries.get(0);
+ }
+ }
+
+ return (binary);
+ }
+
+ //FIXME EK-LINUXTOOLS: New method to get location for linked binary resource
+ /**
+ * @param file
+ * @return
+ * @since 6.0
+ */
+ public IFile findFileFromPath(IPath file)
+ {
+ // can't use a null or empty path below
+ if (file == null || file.isEmpty()) {
+ return null;
+ }
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ /*
+ * Find resource to which this GCOV file maps to in workspace
+ */
+ IFile files[] = root.findFilesForLocationURI(URIUtil.toURI(file));
+ if ((files.length == 0) || (files.length > 1))
+ {
+ /*
+ * Nothing found or more than one GCOV output file
+ * Let user decide what to use as binary
+ */
+ return (null);
+ }
+ return files[0];
+ }
+
+ //FIXME EK-LINUXTOOLS: IProject file resolution for linked resources
+ /**
+ * @param file
+ * @return
+ * @since 6.0
+ */
+ public IProject getProjectFromFile(IPath file)
+ {
+ IFile ifile = findFileFromPath(file);
+ if (ifile == null)
+ {
+ /*
+ * Nothing found or more than one GCOV output file
+ * Let upstream processing handle this exception
+ */
+ return (null);
+ }
+ /*
+ * Find project this resource belongs to
+ */
+ return (ifile.getProject());
+ }
+
/**
* Validate the binary file. In particular, verify that this binary file can be decoded.
* @param o
diff --git a/profiling/org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF
index 32d460c6a0..96ebfa0bb5 100644
--- a/profiling/org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF
+++ b/profiling/org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Bundle-Vendor: %bundleProvider
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.ui,
+ org.eclipse.linuxtools.binutils,
org.eclipse.ui.ide
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.linuxtools.dataviewers,
diff --git a/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java b/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java
index c3fb81c6f4..71da36403c 100644
--- a/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java
+++ b/profiling/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -35,6 +34,7 @@ import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
import org.eclipse.linuxtools.dataviewers.STDataViewersActivator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Item;
@@ -374,7 +374,8 @@ public class STDataViewersCSVExporter {
// end monitoring
monitor.done();
- IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(getFilePath()));
+ //FIXME EK-LINUXTOOLS: IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(getFilePath()));
+ IFile c = STSymbolManager.sharedInstance.findFileFromPath(new Path(getFilePath()));
if (c != null) {
try {
c.refreshLocal(1, new NullProgressMonitor());