Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/gcov
diff options
context:
space:
mode:
authorOtavio Pontes2011-10-05 16:50:15 +0000
committerOtavio Pontes2011-11-09 18:59:01 +0000
commitdd38d8163d294834c08fd6630c1e67dedd28ff90 (patch)
tree192455b8b857080293c70bc07891c83d27bad61a /gcov
parent2900e65d8e0ff29a64d68b7c44d04503d7e6ec08 (diff)
downloadorg.eclipse.linuxtools-dd38d8163d294834c08fd6630c1e67dedd28ff90.tar.gz
org.eclipse.linuxtools-dd38d8163d294834c08fd6630c1e67dedd28ff90.tar.xz
org.eclipse.linuxtools-dd38d8163d294834c08fd6630c1e67dedd28ff90.zip
Gprof/gcov: Using the lt Process Factories to run commands (bug #353056)
The Process Factories from linuxtools use a project property to get a PATH environment variable to be used to run commands.
Diffstat (limited to 'gcov')
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/parser/CovManager.java17
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java16
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/view/CovView.java19
3 files changed, 35 insertions, 17 deletions
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/parser/CovManager.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/parser/CovManager.java
index a13288974b..bf516f7d2d 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/parser/CovManager.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/parser/CovManager.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
@@ -45,7 +46,6 @@ import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
-
/**
* @author Xavier Raynaud <xavier.raynaud@st.com>
*
@@ -66,17 +66,26 @@ public class CovManager implements Serializable {
private long nbrPgmRuns = 0;
// for view
private CovRootTreeElement rootNode;
+ private IProject project;
/**
* Constructor
* @param binaryPath
+ * @param project the project that will be used to get the path to run commands
*/
- public CovManager(String binaryPath) {
+ public CovManager(String binaryPath, IProject project) {
this.binaryPath = binaryPath;
+ this.project = project;
}
+ /**
+ * Constructor
+ * @param binaryPath
+ */
+ public CovManager(String binaryPath) {
+ this(binaryPath, null);
+ }
-
/**
* parse coverage files, execute resolve graph algorithm, process counts for functions,
* lines and folders.
@@ -227,7 +236,7 @@ public class CovManager implements Serializable {
for (GcnoFunction fnctn : src.getFnctns()) {
String name = fnctn.getName();
- name = STSymbolManager.sharedInstance.demangle(binaryObject, name);
+ name = STSymbolManager.sharedInstance.demangle(binaryObject, name, project);;
srcTreeElem.addChild(new CovFunctionTreeElement(
srcTreeElem, name, fnctn.getSrcFile(), fnctn
.getFirstLineNmbr(), fnctn.getCvrge()
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java
index c47cf07d92..ae21182799 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java
@@ -15,6 +15,8 @@ import java.io.IOException;
import java.util.WeakHashMap;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.binutils.utils.STNMFactory;
import org.eclipse.linuxtools.binutils.utils.STNMSymbolsHandler;
@@ -31,32 +33,32 @@ public class STGcovProgramChecker implements STNMSymbolsHandler {
this.timestamp = timestamp;
}
- private static STGcovProgramChecker getProgramChecker(IBinaryObject object) throws IOException {
+ private static STGcovProgramChecker getProgramChecker(IBinaryObject object, IProject project) throws IOException {
File program = object.getPath().toFile();
STGcovProgramChecker pg = map.get(program);
if (pg == null) {
pg = new STGcovProgramChecker(program.lastModified());
- STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg);
+ STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg, project);
map.put(program, pg);
} else {
long fileTime = program.lastModified();
if (fileTime > pg.timestamp) {
pg.timestamp = fileTime;
pg.gcovFound = false;
- STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg);
+ STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg, project);
}
}
return pg;
}
- public static boolean isGCovCompatible(String s) throws IOException {
+ public static boolean isGCovCompatible(String s, IProject project) throws IOException {
IBinaryObject object = STSymbolManager.sharedInstance.getBinaryObject(new Path(s));
if (object == null) return false;
- return isGCovCompatible(object);
+ return isGCovCompatible(object, project);
}
- public static boolean isGCovCompatible(IBinaryObject object) throws IOException {
- STGcovProgramChecker pg = getProgramChecker(object);
+ public static boolean isGCovCompatible(IBinaryObject object, IProject project) throws IOException {
+ STGcovProgramChecker pg = getProgramChecker(object, project);
return pg.gcovFound;
}
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/view/CovView.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/view/CovView.java
index 1e62bc2571..93006f5bcb 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/view/CovView.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/gcov/view/CovView.java
@@ -141,8 +141,13 @@ public class CovView extends AbstractSTDataView {
public static void displayCovDetailedResult(String binaryPath, String gcdaFile) {
try {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile binary = root.getFileForLocation(new Path(binaryPath));
+ IProject project = null;
+ if (binary != null) project = binary.getProject();
+
// parse and process coverage data
- CovManager cvrgeMnger = new CovManager(binaryPath);
+ CovManager cvrgeMnger = new CovManager(binaryPath, project);
List<String> gcdaPaths = new LinkedList<String>();
gcdaPaths.add(gcdaFile);
cvrgeMnger.processCovFiles(gcdaPaths, gcdaFile);
@@ -150,10 +155,6 @@ public class CovView extends AbstractSTDataView {
cvrgeMnger.fillGcovView();
for (SourceFile sf : cvrgeMnger.getSourceMap().values()) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile binary = root.getFileForLocation(new Path(binaryPath));
- IProject project = null;
- if (binary != null) project = binary.getProject();
OpenSourceFileAction.sharedInstance.openAnnotatedSourceFile(project,
binary, sf, 0);
}
@@ -176,8 +177,14 @@ public class CovView extends AbstractSTDataView {
public static CovView displayCovResults(String binaryPath, String gcda) {
try {
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile binary = root.getFileForLocation(new Path(binaryPath));
+ IProject project = null;
+ if (binary != null) project = binary.getProject();
+
// parse and process coverage data
- CovManager cvrgeMnger = new CovManager(binaryPath);
+ CovManager cvrgeMnger = new CovManager(binaryPath, project);
List<String> gcdaPaths = cvrgeMnger.getGCDALocations();
cvrgeMnger.processCovFiles(gcdaPaths, gcda);
// generate model for view

Back to the top