aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Fraxino Araujo2012-06-19 15:20:36 (EDT)
committerDaniel Henrique Barboza2012-06-27 15:42:24 (EDT)
commit10b2ac23a9922c59f92b497d39c2d81653e0eff2 (patch)
tree75637dae9b9d25a15067c7ee6fececc591342b31
parent80855a1015205b0057856eae92d6b749cdaa9b0b (diff)
downloadorg.eclipse.linuxtools-10b2ac23a9922c59f92b497d39c2d81653e0eff2.zip
org.eclipse.linuxtools-10b2ac23a9922c59f92b497d39c2d81653e0eff2.tar.gz
org.eclipse.linuxtools-10b2ac23a9922c59f92b497d39c2d81653e0eff2.tar.bz2
Added support for remote perf using Linuxtools profiling package.
-rw-r--r--perf/org.eclipse.linuxtools.perf/META-INF/MANIFEST.MF2
-rw-r--r--perf/org.eclipse.linuxtools.perf/plugin.properties1
-rw-r--r--perf/org.eclipse.linuxtools.perf/plugin.xml39
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java264
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java2
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java13
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfEventsTab.java249
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfLaunchConfigDelegate.java229
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfLaunchConfigurationTabGroup.java24
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfOptionsTab.java60
10 files changed, 783 insertions, 100 deletions
diff --git a/perf/org.eclipse.linuxtools.perf/META-INF/MANIFEST.MF b/perf/org.eclipse.linuxtools.perf/META-INF/MANIFEST.MF
index f29ee7d..282f5f9 100644
--- a/perf/org.eclipse.linuxtools.perf/META-INF/MANIFEST.MF
+++ b/perf/org.eclipse.linuxtools.perf/META-INF/MANIFEST.MF
@@ -22,4 +22,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.ide
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.core.filesystem,
+ org.eclipse.linuxtools.tools.launch.core.factory
diff --git a/perf/org.eclipse.linuxtools.perf/plugin.properties b/perf/org.eclipse.linuxtools.perf/plugin.properties
index 0797b99..61e48e5 100644
--- a/perf/org.eclipse.linuxtools.perf/plugin.properties
+++ b/perf/org.eclipse.linuxtools.perf/plugin.properties
@@ -1,3 +1,4 @@
bundleName=Perf Plug-in
bundleProvider=Eclipse Linux Tools
launchConfigurationTabGroup.description.0 = Profile C/C++ Application Using Perf
+launchConfigurationTabGroup.description.1 = Profile C/C++ Application Using Remote Perf
diff --git a/perf/org.eclipse.linuxtools.perf/plugin.xml b/perf/org.eclipse.linuxtools.perf/plugin.xml
index 78c3d30..e735019 100644
--- a/perf/org.eclipse.linuxtools.perf/plugin.xml
+++ b/perf/org.eclipse.linuxtools.perf/plugin.xml
@@ -11,6 +11,14 @@
class="org.eclipse.linuxtools.internal.perf.ui.PerfProfileView"
id="org.eclipse.linuxtools.perf.ui.ProfileView">
</view>
+ <view
+ category="org.eclipse.linuxtools.profiling.ui"
+ class="org.eclipse.linuxtools.internal.perf.ui.PerfProfileView"
+ icon="icons/file.gif"
+ id="org.eclipse.linuxtools.perf.ui.RemoteProfileView"
+ name="Remote Perf Profile View"
+ restorable="true">
+ </view>
</extension>
<extension
point="org.eclipse.help.contexts">
@@ -76,6 +84,15 @@
sourceLocatorId="org.eclipse.cdt.launch.DefaultSourceLocator"
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer">
</launchConfigurationType>
+ <launchConfigurationType
+ delegate="org.eclipse.linuxtools.internal.perf.remote.launch.PerfLaunchConfigDelegate"
+ id="org.eclipse.linuxtools.perf.remote.launch.profile"
+ modes="profile"
+ name="Profile with Remote Perf"
+ public="true"
+ sourceLocatorId="org.eclipse.cdt.launch.DefaultSourceLocator"
+ sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer">
+ </launchConfigurationType>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
@@ -85,6 +102,12 @@
id="org.eclipse.linuxtools.perf.launch.launchConfigurationTabGroup"
type="org.eclipse.linuxtools.perf.launch.profile">
</launchConfigurationTabGroup>
+ <launchConfigurationTabGroup
+ class="org.eclipse.linuxtools.internal.perf.remote.launch.PerfLaunchConfigurationTabGroup"
+ description="%launchConfigurationTabGroup.description.1"
+ id="org.eclipse.linuxtools.perf.remote.launch.launchConfigurationTabGroup"
+ type="org.eclipse.linuxtools.perf.remote.launch.profile">
+ </launchConfigurationTabGroup>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTypeImages">
@@ -93,6 +116,11 @@
icon="icons/symbol.gif"
id="org.eclipse.linuxtools.perf.launch.perfImage">
</launchConfigurationTypeImage>
+ <launchConfigurationTypeImage
+ configTypeID="org.eclipse.linuxtools.perf.remote.launch.profile"
+ icon="icons/symbol.gif"
+ id="org.eclipse.linuxtools.perf.remote.launch.perfImage">
+ </launchConfigurationTypeImage>
</extension>
<extension
point="org.eclipse.ui.editors">
@@ -103,14 +131,5 @@
launcher="org.eclipse.linuxtools.internal.perf.launch.PerfOpenData"
name="Perf Viewer">
</editor>
- </extension>
- <extension
- point="org.eclipse.linuxtools.profiling.launch.launchProvider">
- <provider
- id="org.eclipse.linuxtools.perf.provider"
- shortcut="org.eclipse.linuxtools.internal.perf.launch.PerfLaunchShortcut"
- type="snapshot">
- </provider>
- </extension>
-
+ </extension>
</plugin>
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
index 63b33e0..2e8f7eb 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
@@ -15,13 +15,20 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.core.filesystem.IFileStore;
+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.IProgressMonitor;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.linuxtools.internal.perf.model.PMCommand;
@@ -30,6 +37,10 @@ import org.eclipse.linuxtools.internal.perf.model.PMEvent;
import org.eclipse.linuxtools.internal.perf.model.PMFile;
import org.eclipse.linuxtools.internal.perf.model.PMSymbol;
import org.eclipse.linuxtools.internal.perf.model.TreeParent;
+import org.eclipse.linuxtools.profiling.launch.ConfigUtils;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
+import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
@@ -39,7 +50,7 @@ public class PerfCore {
StringBuffer strBuf = new StringBuffer();
String line = null;
- try {
+ try {
while (( line = br.readLine()) != null){
strBuf.append(line + "\n");
}
@@ -50,28 +61,47 @@ public class PerfCore {
if (!str.trim().equals("")) {
if (print != null) {
print.println(blockTitle + ": \n" +str + "\n END OF " + blockTitle);
+ } else {
+ System.out.println(blockTitle + ": \n" +str + "\n END OF " + blockTitle);
}
}
return str;
}
private static HashMap<String,ArrayList<String>> eventList = null;
- public static HashMap<String,ArrayList<String>> getEventList() {
+ public static HashMap<String,ArrayList<String>> getEventList() {
+ return getEventList(null);
+ }
+ public static HashMap<String,ArrayList<String>> getEventList(ILaunchConfiguration config) {
//cache'ing
if (eventList == null) {
//if (PerfPlugin.DEBUG_ON) System.out.println("Event list cache empty, loading new event list.");
- eventList = loadEventList();
+ eventList = loadEventList(config);
}
return eventList;
}
- public static HashMap<String,ArrayList<String>> loadEventList() {
+ public static HashMap<String,ArrayList<String>> loadEventList(ILaunchConfiguration config) {
HashMap<String,ArrayList<String>> events = new HashMap<String,ArrayList<String>>();
- if (!PerfCore.checkPerfInPath())
- return events;
+ IProject project = null;
+ if (config==null) {
+ if (!PerfCore.checkPerfInPath()) {
+ return events;
+ }
+ } else {
+ ConfigUtils configUtils = new ConfigUtils(config);
+ try {
+ project = ConfigUtils.getProject(configUtils.getProjectName());
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+ if (!PerfCore.checkRemotePerfInPath(project)) {
+ return events;
+ }
+ }
Process p = null;
BufferedReader input = null;
try {
// Alternatively can try with -i flag
- p = Runtime.getRuntime().exec(new String[] {PerfPlugin.PERF_COMMAND, "list"}); //(char 1 as -t is a custom field seperator
+ p = RuntimeProcessFactory.getFactory().exec(new String[] {PerfPlugin.PERF_COMMAND, "list"}, project); //(char 1 as -t is a custom field seperator
/*
* Old versions of Perf will send events list to stderr instead of stdout
@@ -79,10 +109,10 @@ public class PerfCore {
*/
BufferedReader stdoutIn = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stderrIn = new BufferedReader(new InputStreamReader(p.getErrorStream()));
-
+
while (!stdoutIn.ready() && !stderrIn.ready()) continue;
input = stdoutIn.ready() ? stdoutIn : stderrIn;
-
+
} catch( IOException e ) {
e.printStackTrace();
}
@@ -126,23 +156,46 @@ public class PerfCore {
}
return events;
}
+
+
//Gets the current version of perf
- public static String getPerfVersion(String[] environ, File workingDir) {
- Process p = null;
+ public static String getPerfVersion(ILaunchConfiguration config, String[] environ, IPath workingDir) {
+ ConfigUtils configUtils = new ConfigUtils(config);
+ IProject project = null;
try {
- if (workingDir == null) {
- p = Runtime.getRuntime().exec(new String [] {PerfPlugin.PERF_COMMAND, "--version"});
- } else {
- p = Runtime.getRuntime().exec(new String [] {PerfPlugin.PERF_COMMAND, "--version"}, environ, workingDir); //runs with a specific working dir and environment.
- }
- } catch (IOException e) {
- e.printStackTrace();
+ project = ConfigUtils.getProject(configUtils.getProjectName());
+ } catch (CoreException e1) {
+ e1.printStackTrace();
}
+ Process p = null;
+ IRemoteFileProxy proxy = null;
+ IFileStore workingDirFileStore = null;
+
+ if (workingDir == null) {
+ try {
+ p = RuntimeProcessFactory.getFactory().exec(new String [] {PerfPlugin.PERF_COMMAND, "--version"}, project);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(new URI(workingDir.toOSString()));
+ workingDirFileStore = proxy.getResource(workingDir.toOSString());
+ p = RuntimeProcessFactory.getFactory().exec(new String [] {PerfPlugin.PERF_COMMAND, "--version"}, environ, workingDirFileStore, project);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
//p.waitFor();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
return spitStream(input, "Perf --version STDOUT", null);
}
-
+
public static boolean checkPerfInPath()
{
try
@@ -155,7 +208,26 @@ public class PerfCore {
}
return true;
}
-
+
+ public static boolean checkRemotePerfInPath(IProject project) {
+ try
+ {
+ RuntimeProcessFactory.getFactory().exec(new String [] {PerfPlugin.PERF_COMMAND, "--version"}, project);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ public String getRemoteProjectPath(String projectName) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(projectName);
+ return project.getName();
+ }
+
//Generates a perf record command string with the options set in the given config. (If null uses default).
public static String [] getRecordString(ILaunchConfiguration config) {
String [] base = new String [] {PerfPlugin.PERF_COMMAND, "record", "-f"};
@@ -173,7 +245,7 @@ public class PerfCore {
newCommand.add("-M");
List<String> selE = config.getAttribute(PerfPlugin.ATTR_SelectedEvents, PerfPlugin.ATTR_SelectedEvents_default);
if (!config.getAttribute(PerfPlugin.ATTR_DefaultEvent, PerfPlugin.ATTR_DefaultEvent_default)
- && selE != null) {
+ && selE != null) {
for(String e : selE) {
newCommand.add("-e");
newCommand.add(e);
@@ -196,7 +268,7 @@ public class PerfCore {
}
if (config.getAttribute(PerfPlugin.ATTR_ModuleSymbols, PerfPlugin.ATTR_ModuleSymbols_default))
base.add("-m");
-
+
/*
* danielhb, 12/14/2011 - some systems, like ubuntu and sles, does not have
* the -U option. The binary fails to execute in those systems when this
@@ -208,14 +280,14 @@ public class PerfCore {
/*
if (config.getAttribute(PerfPlugin.ATTR_HideUnresolvedSymbols, PerfPlugin.ATTR_HideUnresolvedSymbols_default))
base.add("-U");
- */
+ */
if (perfDataLoc != null) {
base.add("-i");
base.add(perfDataLoc);
}
} catch (CoreException e) { }
}
- return base.toArray( new String[base.size()] );
+ return (String[])base.toArray( new String[base.size()] );
}
public static String[] getAnnotateString(ILaunchConfiguration config, String dso, String symbol, String perfDataLoc, boolean OldPerfVersion) {
@@ -240,16 +312,28 @@ public class PerfCore {
}
} catch (CoreException e) { }
}
-
+
//(Annotate string per symbol)
//if (PerfPlugin.DEBUG_ON) System.out.println(Arrays.toString( (String[])base.toArray( new String[base.size()] ) ));
- return base.toArray( new String[base.size()] );
+ return (String[])base.toArray( new String[base.size()] );
}
//Runs Perf Record on the given binary and records into perf.data before calling Report() to feed in the results.
- public static void Record(String binaryPath) {
+ public static void Record(ILaunchConfiguration config, String binaryPath) {
+ ConfigUtils configUtils = new ConfigUtils(config);
+ IProject project = null;
+ try {
+ project = ConfigUtils.getProject(configUtils.getProjectName());
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
BufferedReader error = null;
+ Process perfRecord = null;
try {
- Process perfRecord = Runtime.getRuntime().exec(ArrayUtil.addAll(getRecordString(null), new String [] {binaryPath}));
+ if (project==null) {
+ perfRecord = Runtime.getRuntime().exec(ArrayUtil.addAll(getRecordString(null), new String [] {binaryPath}));
+ } else {
+ perfRecord = RuntimeProcessFactory.getFactory().exec(ArrayUtil.addAll(getRecordString(null), new String [] {binaryPath}), project);
+ }
error = new BufferedReader(new InputStreamReader(perfRecord.getErrorStream()));
perfRecord.waitFor();
spitStream(error,"Perf Record STDERR", null);
@@ -258,7 +342,7 @@ public class PerfCore {
} catch (InterruptedException e) {
e.printStackTrace();
}
- Report();
+ //Report();
}
public static void Report() {
Report(null,null,null,null,null,null);
@@ -266,22 +350,29 @@ public class PerfCore {
// Runs assuming perf.data has already been recorded, environ and workingDir can be set to null to use default
//perfDataLoc is optional - it is used to provide a pre-existing data file instead of something recorded from
//whatever project is being profiled. It is only used for junit tests atm.
- public static void Report(ILaunchConfiguration config, String[] environ, File workingDir, IProgressMonitor monitor, String perfDataLoc, PrintStream print) {
- TreeParent invisibleRoot = PerfPlugin.getDefault().getModelRoot();
+ public static void Report(ILaunchConfiguration config, String[] environ, IPath workingDir, IProgressMonitor monitor, String perfDataLoc, PrintStream print) {
+ ConfigUtils configUtils = new ConfigUtils(config);
+ IProject project = null;
+ try {
+ project = ConfigUtils.getProject(configUtils.getProjectName());
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+ TreeParent invisibleRoot = PerfPlugin.getDefault().getModelRoot();
if (invisibleRoot == null) {
invisibleRoot = new TreeParent("");
PerfPlugin.getDefault().setModelRoot(invisibleRoot);
} else {
invisibleRoot.clear();
}
-
+
boolean OldPerfVersion = false;
- if (getPerfVersion(environ, workingDir).contains("perf version 0.0.2.PERF")) {
+ if (getPerfVersion(config, environ, workingDir).contains("perf version 0.0.2.PERF")) {
OldPerfVersion = true;
if (print != null) { print.println("WARNING: You are running an older version of Perf, please update if you can. The plugin may produce unpredictable results."); }
}
-
-
+
+
BufferedReader input = null;
BufferedReader error = null;
Process p = null;
@@ -289,27 +380,28 @@ public class PerfCore {
if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
try {
- if (workingDir == null) {
- p = Runtime.getRuntime().exec(getReportString(config, perfDataLoc));
+ if (workingDir==null) {
+ p = RuntimeProcessFactory.getFactory().exec(getReportString(config, perfDataLoc), project);
} else {
- String perfDefaultDataLoc = workingDir + "/" + PerfPlugin.PERF_DEFAULT_DATA;
- p = Runtime.getRuntime().exec(getReportString(config, perfDefaultDataLoc));
- }
- //p.waitFor();
+ p = RuntimeProcessFactory.getFactory().exec(getReportString(config, workingDir.toOSString() + PerfPlugin.PERF_DEFAULT_DATA), project);
+ }
+
+ // p.waitFor();
input = new BufferedReader(new InputStreamReader(p.getInputStream()));
error = new BufferedReader(new InputStreamReader(p.getErrorStream()));
//spitting error stream moved to end of while loop, due to commenting of p.waitFor()
} catch( IOException e ) {
e.printStackTrace();
- /*} catch (InterruptedException e) {
+ /*} catch (InterruptedException e) {
e.printStackTrace();*/
- }
-
- PerfCore.parseReport(config, workingDir, monitor, perfDataLoc, print,
- invisibleRoot, OldPerfVersion, input, error);
-
+ }
+
+
+ PerfCore.parseRemoteReport(config, workingDir, monitor, perfDataLoc, print,
+ invisibleRoot, OldPerfVersion, input, error, project);
+
RefreshView();
- }
+ }
/**
* Parse and build a tree model from the report of a perf data file
@@ -324,9 +416,17 @@ public class PerfCore {
* @param error output stream to where all standard error is written to
*/
public static void parseReport(ILaunchConfiguration config,
- File workingDir, IProgressMonitor monitor, String perfDataLoc,
+ IPath workingDir, IProgressMonitor monitor, String perfDataLoc,
PrintStream print, TreeParent invisibleRoot,
boolean OldPerfVersion, BufferedReader input, BufferedReader error) {
+ PerfCore.parseRemoteReport(config, workingDir, monitor, perfDataLoc, print,
+ invisibleRoot, OldPerfVersion, input, error, null);
+ }
+
+ public static void parseRemoteReport(ILaunchConfiguration config,
+ IPath workingDir, IProgressMonitor monitor, String perfDataLoc,
+ PrintStream print, TreeParent invisibleRoot,
+ boolean OldPerfVersion, BufferedReader input, BufferedReader error, IProject project) {
if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
String line = null;
String items[];
@@ -356,7 +456,7 @@ public class PerfCore {
if (print != null) { print.println("WARNING: You are running an older version of Perf, please update if you can. The plugin may produce unpredictable results."); }
invisibleRoot.addChild(new PMEvent("WARNING: You are running an older version of Perf, the plugin may produce unpredictable results."));
}
- // contains profiled information
+ // contains profiled information
} else {
items = line.trim().split(""+(char)1); // using custom field separator. for default whitespace use " +"
if (items.length != 5) {
@@ -430,26 +530,27 @@ public class PerfCore {
for (TreeParent s : currentDso.getFile(PerfPlugin.STRINGS_UnfiledSymbols).getChildren()) {
if (!(s instanceof PMSymbol)) continue;
- if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
+ if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
currentSym = (PMSymbol)s;
- String[] annotateCmd;
- if (workingDir == null) {
- annotateCmd = getAnnotateString(config, currentDso.getName(), currentSym.getName().substring(4), perfDataLoc, OldPerfVersion);
- } else {
- String perfDefaultDataLoc = workingDir + "/" + PerfPlugin.PERF_DEFAULT_DATA;
- annotateCmd = getAnnotateString(config, currentDso.getName(), currentSym.getName().substring(4), perfDefaultDataLoc, OldPerfVersion);
- }
+ String[] annotateCmd;
+ if (workingDir == null) {
+ annotateCmd = getAnnotateString(config, currentDso.getName(), currentSym.getName().substring(4), perfDataLoc, OldPerfVersion);
+ } else {
+ String perfDefaultDataLoc = workingDir + "/" + PerfPlugin.PERF_DEFAULT_DATA;
+ annotateCmd = getAnnotateString(config, currentDso.getName(), currentSym.getName().substring(4), perfDefaultDataLoc, OldPerfVersion);
+ }
try {
- p = Runtime.getRuntime().exec(annotateCmd);
+ if(project==null) p = Runtime.getRuntime().exec(annotateCmd);
+ else p = RuntimeProcessFactory.getFactory().exec(annotateCmd, project);
input = new BufferedReader(new InputStreamReader(p.getInputStream()));
error = new BufferedReader(new InputStreamReader(p.getErrorStream()));
} catch (IOException e) {
e.printStackTrace();
}
-
+
PerfCore.parseAnnotation(monitor, input,
workingDir, currentDso, currentSym);
}
@@ -481,7 +582,7 @@ public class PerfCore {
* @param currentSym symbol
*/
public static void parseAnnotation(IProgressMonitor monitor,
- BufferedReader input, File workingDir, PMDso currentDso,
+ BufferedReader input, IPath workingDir, PMDso currentDso,
PMSymbol currentSym) {
if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
@@ -499,10 +600,10 @@ public class PerfCore {
dsoName = line.replace("Sorted summary for file ","");
blockStarted = false;
if ((workingDir != null) && (dsoName.startsWith("./"))) {
- if (workingDir.getAbsolutePath().endsWith("/")) {
- dsoName = workingDir.getAbsolutePath() + dsoName.substring(2); // path already ends with '/', so trim './'
+ if (workingDir.toOSString().endsWith("/")) {
+ dsoName = workingDir.toOSString() + dsoName.substring(2); // path already ends with '/', so trim './'
} else {
- dsoName = workingDir.getAbsolutePath() + dsoName.substring(1); // path doesn't have '/', so trim just the '.'
+ dsoName = workingDir.toOSString() + dsoName.substring(1); // path doesn't have '/', so trim just the '.'
}
}
currentDso.setPath(dsoName);
@@ -531,7 +632,7 @@ public class PerfCore {
if (currentSym.getParent().getName().equals(PerfPlugin.STRINGS_UnfiledSymbols)) {
currentSym.getParent().removeChild(currentSym);
currentDso.getFile(items[0]).addChild(currentSym);
- // Symbol has 2 (or more) parents
+ // Symbol has 2 (or more) parents
} else if (!((PMFile)currentSym.getParent()).getPath().equals(items[0])) {
currentSym.markConflict();
currentSym.getParent().removeChild(currentSym);
@@ -545,21 +646,20 @@ public class PerfCore {
}
}
- public static void RefreshView()
- {
- Display.getDefault().syncExec(new Runnable() {
- @Override
+ public static void RefreshView()
+ {
+ Display.getDefault().syncExec(new Runnable() {
public void run() {
- //Try to switch the active view to Perf.
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
- PerfPlugin.getDefault().getProfileView().refreshModel();
- } catch (NullPointerException e) {
- e.printStackTrace();
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- }
- });
- }
-}
+ //Try to switch the active view to Perf.
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
+ PerfPlugin.getDefault().getProfileView().refreshModel();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+} \ No newline at end of file
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java
index 93b1c48..2494278 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java
@@ -128,7 +128,6 @@ public class PerfPlugin extends AbstractUIPlugin {
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
- @Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
@@ -138,7 +137,6 @@ public class PerfPlugin extends AbstractUIPlugin {
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
- @Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java
index 9a9e3a3..308c54b 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java
@@ -22,6 +22,9 @@ package org.eclipse.linuxtools.internal.perf.launch;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
+
+import org.eclipse.ui.console.*;
+
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,6 +34,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -38,10 +42,6 @@ import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.linuxtools.internal.perf.PerfCore;
import org.eclipse.linuxtools.internal.perf.PerfPlugin;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleManager;
-import org.eclipse.ui.console.IOConsole;
public class PerfLaunchConfigDelegate extends ProfileLaunchConfigurationDelegate {
@@ -76,7 +76,7 @@ public class PerfLaunchConfigDelegate extends ProfileLaunchConfigurationDelegate
command.add( exePath.toOSString() ); // Add the path to the executable
//Compile string
command.addAll( Arrays.asList( arguments ) );
- String[] commandArray = command.toArray( new String[command.size()] );
+ String[] commandArray = (String[])command.toArray( new String[command.size()] );
boolean usePty = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
Process process;
@@ -135,7 +135,8 @@ public class PerfLaunchConfigDelegate extends ProfileLaunchConfigurationDelegate
}
//(Only for testing this line..) PerfCore.Report(config, null, null, null, "/home/thavidu/dev/eclipse-oprof2-workspace/org.eclipse.linuxtools.internal.perf.tests/resources/perf.data");
- PerfCore.Report(config, getEnvironment(config), wd, monitor, null, print);
+ IPath workingDir = Path.fromOSString(wd.toURI().getPath());
+ PerfCore.Report(config, getEnvironment(config), workingDir, monitor, null, print);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfEventsTab.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfEventsTab.java
new file mode 100644
index 0000000..45c34c8
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfEventsTab.java
@@ -0,0 +1,249 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
+ * (C) Copyright 2010 IBM Corp. 2010
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thavidu Ranatunga (IBM) - derived and modified from
+ * org.eclipse.linuxtools.oprofile.launch.configuration.OprofileEventConfigTab
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.remote.launch;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.linuxtools.internal.perf.PerfCore;
+import org.eclipse.linuxtools.internal.perf.PerfPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+public class PerfEventsTab extends org.eclipse.linuxtools.internal.perf.launch.PerfEventsTab {
+ private int rawTabIndex = 0;
+ private int bpTabIndex = 0;
+ private Composite top;
+
+ //Function adapted from org.eclipse.linuxtools.oprofile.launch.configuration.OprofileSetupTab.java
+ @Override
+ public void createControl(Composite parent) {
+ top = new Composite(parent, SWT.NONE);
+ setControl(top);
+ top.setLayout(new GridLayout());
+
+ createVerticalSpacer(top, 1);
+
+ //Default event checkbox
+ _chkDefaultEvent = new Button(top, SWT.CHECK);
+ _chkDefaultEvent.setText("Default Event"); //$NON-NLS-1$
+ _chkDefaultEvent.setLayoutData(new GridData());
+ _chkDefaultEvent.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent se) {
+ refreshDefaultEnabled();
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ createVerticalSpacer(top, 1);
+
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration config) {
+ //Maybe not the best place to load the event list but we'll see.
+ HashMap<String,ArrayList<String>> events = PerfCore.getEventList(config);
+
+ //tabs for each of the counters
+ //String[] tabNames = new String[]{"Hardware Event","Software Event","Hardware Cache Event","Tracepoint Event", "Raw hardware event descriptor","Hardware breakpoint"};
+ String[] tabNames = events.keySet().toArray(new String[events.keySet().size()]);
+ _eventTabItems = new TabItem[tabNames.length];
+ _eventTabLists = new Table[tabNames.length];
+
+ _tabFolder = new TabFolder(top, SWT.NONE);
+ _tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ //Initialize each tab.
+ for (int i = 0; i < tabNames.length; i++) {
+
+ _eventTabItems[i] = new TabItem(_tabFolder, SWT.NONE);
+ _eventTabItems[i].setText(tabNames[i]);
+
+ if (tabNames[i].equals(PerfPlugin.STRINGS_HWBREAKPOINTS) || tabNames[i].equals(PerfPlugin.STRINGS_RAWHWEvents)) {
+ //These are for the two special tabs for custom events.
+
+ //Composite to contain it all
+ Composite c = new Composite(_tabFolder, SWT.NONE);
+ c.setLayout(new GridLayout(2, false));
+
+ //A list to check off existing custom events (or show the new ones added)
+ Table eventList = new Table(c, SWT.CHECK | SWT.MULTI);
+ _eventTabLists[i] = eventList;
+ eventList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ eventList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent se) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ /* Snippet to insert static items
+ TableItem x = new TableItem(eventList, SWT.NONE);
+ x.setText("hello1");
+ x = new TableItem(eventList, SWT.NONE);
+ x.setText("hello2");*/
+
+ //Right side to enter new events and delete old ones
+ Composite right = new Composite(c, SWT.NONE);
+ right.setLayout(new GridLayout(2,false));
+ right.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true));
+
+ //for adding
+ Label l = new Label(right, SWT.NONE);
+ l.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,2,1));
+ Text t = new Text(right, SWT.SINGLE | SWT.BORDER);
+ t.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ if (tabNames[i].equals(PerfPlugin.STRINGS_HWBREAKPOINTS)) {
+ bpTabIndex = i;
+ _bpText = t;
+ l.setText("Please enter the hardware breakpoint in the form mem:<addr>[:access].");
+ }
+ if (tabNames[i].equals(PerfPlugin.STRINGS_RAWHWEvents)) {
+ rawTabIndex = i;
+ _rawText = t;
+ l.setText("Please enter the raw register encoding in the form rNNN.");
+ }
+
+ Button b = new Button(right, SWT.PUSH);
+ b.setText(" Add ");
+ b.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent se) {
+ int i = _tabFolder.getSelectionIndex();
+ if (rawTabIndex == i) {
+ new TableItem(_eventTabLists[i], SWT.NONE).setText(_rawText.getText());
+ } else if(bpTabIndex == i) {
+ new TableItem(_eventTabLists[i], SWT.NONE).setText(_bpText.getText());
+ }
+ updateLaunchConfigurationDialog();
+ }
+ });
+ l = new Label(right, SWT.NONE);
+ l.setForeground(new Color(right.getDisplay(), 100,100,100));
+ if (tabNames[i].equals(PerfPlugin.STRINGS_HWBREAKPOINTS)) {
+ l.setText("For example, .........");
+ }
+ if (tabNames[i].equals(PerfPlugin.STRINGS_RAWHWEvents)) {
+ l.setText("For example, r1a8");
+ }
+ l.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,2,1));
+
+ //spacer label.
+ l = new Label(right, SWT.NONE);
+ l.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true,2,1));
+
+ //for removing
+ b = new Button(right, SWT.PUSH);
+ b.setText("Remove Selected Events");
+ b.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false,2,1));
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent se) {
+ _eventTabLists[_tabFolder.getSelectionIndex()].remove(_eventTabLists[_tabFolder.getSelectionIndex()].getSelectionIndices());
+ updateLaunchConfigurationDialog();
+ }
+ });
+ l = new Label(right, SWT.NONE);
+ l.setForeground(new Color(right.getDisplay(), 100,100,100));
+ l.setText("Note: Select by highlighting, not by checking.");
+ l.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false,2,1));
+
+ _eventTabItems[i].setControl(c);
+ } else {
+ //This loads all the events 'perf list' gives into their respective tabs.
+ Table eventList = new Table(_tabFolder, SWT.CHECK);
+ _eventTabLists[i] = eventList;
+
+ ArrayList<String> evlist = events.get(tabNames[i]);
+ for (String e : evlist) {
+ TableItem x = new TableItem(eventList, SWT.NONE);
+ x.setText(e);
+ }
+
+ eventList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent se) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ _eventTabItems[i].setControl(eventList);
+ }
+ }
+ //if (PerfPlugin.DEBUG_ON) System.out.println("Initializing eventsTab from previous config.");
+ try {
+ //restore whether things are default event/enabled or not.
+ _chkDefaultEvent.setSelection(config.getAttribute(PerfPlugin.ATTR_DefaultEvent, PerfPlugin.ATTR_DefaultEvent_default));
+ refreshDefaultEnabled();
+
+ //restore custom hw breakpoints
+ List<String> hwbps = config.getAttribute(PerfPlugin.ATTR_HwBreakpointEvents, PerfPlugin.ATTR_HwBreakpointEvents_default);
+ if (hwbps != null) {
+ for (int i = 0; i < _eventTabLists.length; i++) {
+ if (_eventTabItems[i].getText().equals(PerfPlugin.STRINGS_HWBREAKPOINTS)) {
+ _eventTabLists[i].removeAll();
+ for (String e : hwbps) {
+ TableItem x = new TableItem(_eventTabLists[i], SWT.NONE);
+ x.setText(e);
+ }
+ }
+ }
+ }
+
+ //restore custom raw hw events
+ List<String> rawhe = config.getAttribute(PerfPlugin.ATTR_RawHwEvents, PerfPlugin.ATTR_RawHwEvents_default);
+ if (rawhe != null) {
+ for (int i = 0; i < _eventTabLists.length; i++) {
+ if (_eventTabItems[i].getText().equals(PerfPlugin.STRINGS_RAWHWEvents)) {
+ _eventTabLists[i].removeAll();
+ for (String e : rawhe) {
+ TableItem x = new TableItem(_eventTabLists[i], SWT.NONE);
+ x.setText(e);
+ }
+ }
+ }
+ }
+
+ //tick all the boxes that are checked (the events i mean)
+ //This is a little inefficient, I guess. TODO Check more efficiently?
+ List<String> selectedEvents = config.getAttribute(PerfPlugin.ATTR_SelectedEvents, PerfPlugin.ATTR_SelectedEvents_default);
+ if (selectedEvents != null) {
+ for(String s : selectedEvents) {
+ for (int i = 0; i < _eventTabLists.length; i++) {
+ for(TableItem x : _eventTabLists[i].getItems()) {
+ if (x.getText().equals(s))
+ x.setChecked(true);
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+
+}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfLaunchConfigDelegate.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfLaunchConfigDelegate.java
new file mode 100644
index 0000000..4f81cce
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfLaunchConfigDelegate.java
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008, 2009 Red Hat, Inc. and others
+ * (C) Copyright IBM Corp. 2010
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ * Keith Seitz <keiths@redhat.com> - setup code in launch the method, initially
+ * written in the now-defunct OprofileSession class
+ * QNX Software Systems and others - the section of code marked in the launch
+ * method, and the exec method
+ * Thavidu Ranatunga (IBM) - This code is based on the AbstractOprofileLauncher
+ * class code for the OProfile plugin. Part of that was originally adapted
+ * from code written by QNX Software Systems and others for the CDT
+ * LocalCDILaunchDelegate class.
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.remote.launch;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import org.eclipse.ui.console.*;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.linuxtools.internal.perf.PerfCore;
+import org.eclipse.linuxtools.internal.perf.PerfPlugin;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate;
+import org.eclipse.linuxtools.profiling.launch.ConfigUtils;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteConnection;
+import org.eclipse.linuxtools.profiling.launch.RemoteConnectionException;
+import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+
+public class PerfLaunchConfigDelegate extends ProfileLaunchConfigurationDelegate {
+
+ private ConfigUtils configUtils;
+ private static String OUTPUT_STR = "--output="; //$NON-NLS-1$
+
+ @Override
+ protected String getPluginID() {
+ return PerfPlugin.PLUGIN_ID;
+ }
+
+ @Override
+ public void launch(ILaunchConfiguration config, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ try {
+ this.configUtils = new ConfigUtils(config);
+ IProject project = ConfigUtils.getProject(configUtils.getProjectName());
+ // check if Perf exists in $PATH
+ if (! PerfCore.checkRemotePerfInPath(project))
+ {
+ IStatus status = new Status(IStatus.ERROR, PerfPlugin.PLUGIN_ID, "Error: Perf was not found on PATH"); //$NON-NLS-1$
+ throw new CoreException(status);
+ }
+
+ URI exeURI = new URI(configUtils.getExecutablePath());
+ String configWorkingDir = configUtils.getWorkingDirectory();
+ RemoteConnection exeRC = new RemoteConnection(exeURI);
+ monitor.worked(1);
+ String perfPathString = RuntimeProcessFactory.getFactory().whichCommand(PerfPlugin.PERF_COMMAND, project);
+ boolean copyExecutable = configUtils.getCopyExecutable();
+ if (copyExecutable) {
+ URI copyExeURI = new URI(configUtils.getCopyFromExecutablePath());
+ RemoteConnection copyExeRC = new RemoteConnection(copyExeURI);
+ IRemoteFileProxy copyExeRFP = copyExeRC.getRmtFileProxy();
+ IFileStore copyExeFS = copyExeRFP.getResource(copyExeURI.getPath());
+ IRemoteFileProxy exeRFP = exeRC.getRmtFileProxy();
+ IFileStore exeFS = exeRFP.getResource(exeURI.getPath());
+ IFileInfo exeFI = exeFS.fetchInfo();
+ if (exeFI.isDirectory()) {
+ // Assume the user wants to copy the file to the given directory, using
+ // the same filename as the "copy from" executable.
+ IPath copyExePath = Path.fromOSString(copyExeURI.getPath());
+ IPath newExePath = Path.fromOSString(exeURI.getPath()).append(copyExePath.lastSegment());
+ // update the exeURI with the new path.
+ exeURI = new URI(exeURI.getScheme(), exeURI.getAuthority(), newExePath.toString(), exeURI.getQuery(), exeURI.getFragment());
+ exeFS = exeRFP.getResource(exeURI.getPath());
+ }
+ copyExeFS.copy(exeFS, EFS.OVERWRITE | EFS.SHALLOW, new SubProgressMonitor(monitor, 1));
+ // Note: assume that we don't need to create a new exeRC since the
+ // scheme and authority remain the same between the original exeURI and the new one.
+ }
+ IPath remoteBinFile = Path.fromOSString(exeURI.getPath());
+ IFileStore workingDir;
+ if(configWorkingDir == null){
+ // If no working directory was provided, use the directory containing the
+ // the executable as the working directory.
+ IPath workingDirPath = (Path.fromPortableString(remoteBinFile.removeLastSegments(1).toOSString()));
+ IRemoteFileProxy workingDirRFP = exeRC.getRmtFileProxy();
+ workingDir = workingDirRFP.getResource(workingDirPath.toOSString());
+ } else {
+ URI workingDirURI = new URI(configUtils.getWorkingDirectory());
+ RemoteConnection workingDirRC = new RemoteConnection(workingDirURI);
+ IRemoteFileProxy workingDirRFP = workingDirRC.getRmtFileProxy();
+ workingDir = workingDirRFP.getResource(workingDirURI.getPath());
+ }
+
+ //Build the commandline string to run perf recording the given project
+ String arguments[] = getProgramArgumentsArray( config ); //Program args from launch config.
+ ArrayList<String> command = new ArrayList<String>( 4 + arguments.length );
+ command.addAll(Arrays.asList(PerfCore.getRecordString(config))); //Get the base commandline string (with flags/options based on config)
+ command.add( remoteBinFile.toOSString() ); // Add the path to the executable
+ command.set(0, perfPathString);
+ command.add(2,OUTPUT_STR + configWorkingDir + IPath.SEPARATOR + PerfPlugin.PERF_DEFAULT_DATA);
+ //Compile string
+ command.addAll( Arrays.asList( arguments ) );
+
+
+ //Spawn the process
+ String[] commandArray = command.toArray(new String[command.size()]);
+ Process pProxy = RuntimeProcessFactory.getFactory().exec(commandArray, getEnvironment(config), workingDir, project);
+ MessageConsole console = new MessageConsole("Perf Console", null); //$NON-NLS-1$
+ console.activate();
+ ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
+ MessageConsoleStream stream = console.newMessageStream();
+
+ if (pProxy != null) {
+ BufferedReader error = new BufferedReader(
+ new InputStreamReader(pProxy.getErrorStream()));
+ String err;
+ err = error.readLine();
+ while (err != null) {
+ stream.println(err);
+ err = error.readLine();
+ }
+ error.close();
+ }
+
+
+
+ /* This commented part is the basic method to run perf record without integrating into eclipse.
+ String binCall = exePath.toOSString();
+ for(String arg : arguments) {
+ binCall.concat(" " + arg);
+ }
+ PerfCore.Run(binCall);*/
+
+ pProxy.destroy();
+ PrintStream print = null;
+ if (config.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true)) {
+ //Get the console to output to.
+ //This may not be the best way to accomplish this but it shall do for now.
+ ConsolePlugin plugin = ConsolePlugin.getDefault();
+ IConsoleManager conMan = plugin.getConsoleManager();
+ IConsole[] existing = conMan.getConsoles();
+ IOConsole binaryOutCons = null;
+
+ //Find the console
+ for(IConsole x : existing) {
+ if (x.getName().contains(renderProcessLabel(commandArray[0]))) {
+ binaryOutCons = (IOConsole)x;
+ }
+ }
+ if ((binaryOutCons == null) && (existing.length != 0)) { //if can't be found get the most recent opened, this should probably never happen.
+ if (existing[existing.length - 1] instanceof IOConsole)
+ binaryOutCons = (IOConsole)existing[existing.length - 1];
+ }
+
+ //Get the printstream via the outputstream.
+ //Get ouput stream
+ OutputStream outputTo;
+ if (binaryOutCons != null) {
+ outputTo = binaryOutCons.newOutputStream();
+ } else { //This probably shouldn't ever happen...
+ outputTo = System.out;
+ }
+ //Get the printstream for that console
+ print = new PrintStream(outputTo);
+
+ for (int i = 0; i < command.size(); i++) {
+ print.print(command.get(i) + " ");
+ }
+
+ //Print Message
+ print.println();
+ print.println("Analysing recorded perf.data, please wait...");
+ //Possibly should pass this (the console reference) on to PerfCore.Report if theres anything we ever want to spit out to user.
+ }
+ PerfCore.Report(config, getEnvironment(config), Path.fromOSString(configWorkingDir + IPath.SEPARATOR), monitor, null, print);
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ }
+ // } catch (InterruptedException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ }
+
+ @Override
+ public String generateCommand(ILaunchConfiguration config) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfLaunchConfigurationTabGroup.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfLaunchConfigurationTabGroup.java
new file mode 100644
index 0000000..6bf4451
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfLaunchConfigurationTabGroup.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * (C) Copyright 2010 IBM Corp. 2010
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ * Thavidu Ranatunga (IBM) - derived from
+ * org.eclipse.linuxtools.oprofile.launch.configuration.OprofileLaunchConfigurationTabGroup
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.remote.launch;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyProfileLaunchConfigurationTabGroup;
+
+public class PerfLaunchConfigurationTabGroup extends RemoteProxyProfileLaunchConfigurationTabGroup {
+ @Override
+ public AbstractLaunchConfigurationTab[] getProfileTabs() {
+ return new AbstractLaunchConfigurationTab[] { new PerfOptionsTab(), new PerfEventsTab() };
+ }
+}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfOptionsTab.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfOptionsTab.java
new file mode 100644
index 0000000..397c7c7
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/remote/launch/PerfOptionsTab.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2004,2008 Red Hat, Inc.
+ * (C) Copyright 2010 IBM Corp. 2010
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Keith Seitz <keiths@redhat.com> - initial API and implementation
+ * Kent Sebastian <ksebasti@redhat.com> -
+ * Thavidu Ranatunga (IBM) - derived from
+ * org.eclipse.linuxtools.oprofile.launch.configuration.OprofileSetupTab
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.remote.launch;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.linuxtools.internal.perf.PerfCore;
+import org.eclipse.linuxtools.internal.perf.PerfPlugin;
+import org.eclipse.linuxtools.profiling.launch.ConfigUtils;
+
+public class PerfOptionsTab extends org.eclipse.linuxtools.internal.perf.launch.PerfOptionsTab {
+ @Override
+ public void initializeFrom(ILaunchConfiguration config) {
+
+ //if (PerfPlugin.DEBUG_ON) System.out.println("Initializing optionsTab from previous config.");
+ ConfigUtils configUtils = new ConfigUtils(config);
+ IProject project = null;
+ try {
+ project = ConfigUtils.getProject(configUtils.getProjectName());
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+ try {
+ System.out.println(project.getLocationURI());
+ if (! PerfCore.checkRemotePerfInPath(project))
+ {
+ IStatus status = new Status(IStatus.ERROR, PerfPlugin.PLUGIN_ID, "Error: Perf was not found on PATH"); //$NON-NLS-1$
+ ex = new CoreException(status);
+ }
+
+ _txtKernel_Location.setText(config.getAttribute(PerfPlugin.ATTR_Kernel_Location, PerfPlugin.ATTR_Kernel_Location_default));
+ _chkRecord_Realtime.setSelection(config.getAttribute(PerfPlugin.ATTR_Record_Realtime, PerfPlugin.ATTR_Record_Realtime_default));
+ _chkRecord_Verbose.setSelection(config.getAttribute(PerfPlugin.ATTR_Record_Verbose, PerfPlugin.ATTR_Record_Verbose_default));
+ _chkSourceLineNumbers.setSelection(config.getAttribute(PerfPlugin.ATTR_SourceLineNumbers, PerfPlugin.ATTR_SourceLineNumbers_default));
+ _chkKernel_SourceLineNumbers.setSelection(config.getAttribute(PerfPlugin.ATTR_Kernel_SourceLineNumbers, PerfPlugin.ATTR_Kernel_SourceLineNumbers_default));
+
+ _chkMultiplexEvents.setSelection(config.getAttribute(PerfPlugin.ATTR_Multiplex, PerfPlugin.ATTR_Multiplex_default));
+ _chkModuleSymbols.setSelection(config.getAttribute(PerfPlugin.ATTR_ModuleSymbols, PerfPlugin.ATTR_ModuleSymbols_default));
+ _chkHideUnresolvedSymbols.setSelection(config.getAttribute(PerfPlugin.ATTR_HideUnresolvedSymbols, PerfPlugin.ATTR_HideUnresolvedSymbols_default));
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file