Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2011-09-26 18:56:27 +0000
committerRoland Grunberg2011-09-26 18:56:27 +0000
commitf71494378039c6c7733a2f1a876679568a40846e (patch)
tree250697522721000f8cd4a82bdfb50dac7c8e07eb /oprofile/org.eclipse.linuxtools.oprofile.ui/src/org
parent1108874337c2864f426e189b55d33dba99510ed7 (diff)
downloadorg.eclipse.linuxtools-f71494378039c6c7733a2f1a876679568a40846e.tar.gz
org.eclipse.linuxtools-f71494378039c6c7733a2f1a876679568a40846e.tar.xz
org.eclipse.linuxtools-f71494378039c6c7733a2f1a876679568a40846e.zip
Use opreport information for linking to source code.
When opxml was in use, the source locations for various samples and symbols was unreliable. This resulted in using the CDT Indexer for this functionality. We can now rely on opreport for file/line data of samples and symbols.
Diffstat (limited to 'oprofile/org.eclipse.linuxtools.oprofile.ui/src/org')
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSample.java4
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java8
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewDoubleClickListener.java67
3 files changed, 14 insertions, 65 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSample.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSample.java
index 389ab2f7d4..c4786ae1a9 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSample.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSample.java
@@ -38,6 +38,10 @@ public class UiModelSample implements IUiModelElement {
return _sample.getLine();
}
+ public String getFile(){
+ return _sample.getFilePath();
+ }
+
public double getCountPercentage() {
return (double)_sample.getCount() / (double)_totalCount;
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java
index a4dae3bfbe..2dd4497f22 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java
@@ -59,20 +59,24 @@ public class UiModelSymbol implements IUiModelElement {
String percentage = OprofileUiPlugin.getPercentageString(countPercentage);
//a hack to get `basename` type functionality
- String fileName = (new File(_symbol.getFile())).getName();
+ String fileName = (new File(_symbol.getFilePath())).getName();
// String fileName = _symbol.getFile();
return percentage + " " + OprofileUiMessages.getString("uimodel.percentage.in") + _symbol.getName() + (fileName.length() == 0 ? "" : " [" + fileName + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
public String getFileName() {
- return _symbol.getFile();
+ return _symbol.getFilePath();
}
public String getFunctionName(){
return _symbol.getName();
}
+ public int getLineNumber(){
+ return _symbol.getLine();
+ }
+
/** IUiModelElement functions **/
public String getLabelText() {
return toString();
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewDoubleClickListener.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewDoubleClickListener.java
index f8180fdaa0..ada6505059 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewDoubleClickListener.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/view/OprofileViewDoubleClickListener.java
@@ -10,11 +10,6 @@
*******************************************************************************/
package org.eclipse.linuxtools.oprofile.ui.view;
-import java.util.HashMap;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -45,7 +40,6 @@ public class OprofileViewDoubleClickListener implements IDoubleClickListener {
TreeViewer tv = (TreeViewer) event.getSource();
TreeSelection tsl = (TreeSelection) tv.getSelection();
IUiModelElement element = (IUiModelElement) tsl.getFirstElement();
- ICProject project;
try {
if (element instanceof UiModelEvent) {
@@ -58,60 +52,10 @@ public class OprofileViewDoubleClickListener implements IDoubleClickListener {
} else if (element instanceof UiModelSymbol) {
final UiModelSymbol symbol = (UiModelSymbol) element;
- final String imageLabel = symbol.getParent().getLabelText();
final String fileName = symbol.getFileName();
- String functionName = symbol.getFunctionName();
- int numOfArgs = -1;
- HashMap<String, int[]> map;
-
- // hard coded to match "XY.PQ% in /some/arbitrary/path/to/binary"
- String absPath = imageLabel.substring(imageLabel.indexOf(" in ") + 4);
- project = ProfileUIUtils.findCProjectWithAbsolutePath(absPath);
- if (project == null) {
- return;
- }
-
- // detect function with arguments and narrow search accordingly
- if (functionName.matches(".*\\(.*\\)")) {
- int start = functionName.indexOf('(');
- if (functionName.contains(",")) {
- int end = functionName.indexOf(')');
- numOfArgs = functionName.substring(start, end).split(",").length;
- } else {
- numOfArgs = 1;
- }
- functionName = functionName.substring(0, start);
- }else{
- numOfArgs = 0;
- }
-
- if (fileName.length() > 0 && functionName.length() > 0) {
- // this should almost ALWAYS be the case
- // try and go to the function in the file
- map = ProfileUIUtils.findFunctionsInProject(project,functionName, numOfArgs, fileName, true);
-
- // if function still can't be found, go to first line in the file
- if (map.isEmpty()) {
- ProfileUIUtils.openEditorAndSelect(fileName, 1);
- } else {
- for (Entry<String, int []> ent : map.entrySet()) {
- ProfileUIUtils.openEditorAndSelect(ent.getKey(), ent.getValue()[0], ent.getValue()[1]);
- }
- }
-
- } else if (functionName.length() > 0) {
- // can this ever happen ?
- // try to find the file name that has this function
- map = ProfileUIUtils.findFunctionsInProject(project, functionName, numOfArgs, null, true);
-
- for (Entry<String, int []> ent : map.entrySet()) {
- ProfileUIUtils.openEditorAndSelect(ent.getKey(), ent.getValue()[0], ent.getValue()[1]);
- }
- } else if (fileName.length() > 0) {
- // can this ever happen ?
- // jump to 1st line in the file
- ProfileUIUtils.openEditorAndSelect(fileName, 1);
- }
+ int line = symbol.getLineNumber();
+
+ ProfileUIUtils.openEditorAndSelect(fileName, line);
} else if (element instanceof UiModelSample) {
// jump to line number in the appropriate file
@@ -119,16 +63,13 @@ public class OprofileViewDoubleClickListener implements IDoubleClickListener {
int line = sample.getLine();
// get file name from the parent sample
- final UiModelSymbol symbol = ((UiModelSymbol) sample.getParent());
- final String fileName = symbol.getFileName();
+ final String fileName = sample.getFile();
ProfileUIUtils.openEditorAndSelect(fileName, line);
}
} catch (BadLocationException e1) {
e1.printStackTrace();
} catch (PartInitException e2) {
e2.printStackTrace();
- } catch (CoreException e3) {
- e3.printStackTrace();
}
}

Back to the top