aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Medeiros Teixeira2012-06-21 16:29:31 (EDT)
committerOtavio Pontes2012-06-28 16:49:48 (EDT)
commitf3508856a3aee69b119dcdae382e3552853aa9f8 (patch)
tree9b7f7c3c1c8fa6621362fb151c1da806a4388f9f
parent3903e014fb839396e1e180e14a636a0cc617c07d (diff)
downloadorg.eclipse.linuxtools-f3508856a3aee69b119dcdae382e3552853aa9f8.zip
org.eclipse.linuxtools-f3508856a3aee69b119dcdae382e3552853aa9f8.tar.gz
org.eclipse.linuxtools-f3508856a3aee69b119dcdae382e3552853aa9f8.tar.bz2
Oprofile: Added support for remote targets with Oprofile
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestInfoPreParse.java19
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF9
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/build.properties3
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/plugin.xml13
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/schema/org.eclipse.linuxtools.oprofile.core.OpcontrolProvider.exsd109
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java7
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java27
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java32
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java140
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpControlErrorHandler.java23
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java104
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/checkevent/CheckEventAdapter.java16
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java62
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/META-INF/MANIFEST.MF3
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java16
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java224
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java37
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java48
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java80
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.classpath7
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.gitignore5
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.project34
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/META-INF/MANIFEST.MF26
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/about.html28
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/build.properties11
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/event_tab.gifbin0 -> 617 bytes
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/global_tab.gifbin0 -> 362 bytes
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/profile_run.pngbin0 -> 604 bytes
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/plugin.properties21
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/plugin.xml49
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/pom.xml36
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/core/linux/RemoteLinuxOpcontrolProvider.java115
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/configuration/OprofileRemoteEventConfigTab.java45
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/configuration/OprofileRemoteLaunchConfigurationTabGroup.java16
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/launching/OprofileRemoteLaunchConfigurationDelegate.java57
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF4
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewLogReaderAction.java32
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java18
38 files changed, 1221 insertions, 255 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestInfoPreParse.java b/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestInfoPreParse.java
index 0fc8a4c..7b98425 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestInfoPreParse.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestInfoPreParse.java
@@ -1,9 +1,8 @@
package org.eclipse.linuxtools.oprofile.core.tests;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -13,7 +12,11 @@ import javax.xml.parsers.ParserConfigurationException;
import junit.framework.TestCase;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.info.InfoAdapter;
import org.osgi.framework.FrameworkUtil;
@@ -41,18 +44,18 @@ public class TestInfoPreParse extends TestCase {
@Override
protected void setUp() {
- File file = null;
+ IFileStore fileStore = null;
String absFilePath = null;
Path filePath = new Path(REL_PATH_TO_INFO_PRE_PARSE_RAW);
URL fileURL = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), filePath, null);
try {
absFilePath = FileLocator.toFileURL(fileURL).getFile();
- file = new File (absFilePath);
+ fileStore = EFS.getLocalFileSystem().getStore(new Path(absFilePath));
} catch (IOException e) {
fail("Failed to convert the resource file's path.");
}
- InfoAdapter ia = new InfoAdapter(file);
+ InfoAdapter ia = new InfoAdapter(fileStore);
ia.process();
Document actualDocument = ia.getDocument();
Element actualRoot = (Element) actualDocument.getElementsByTagName(InfoAdapter.INFO).item(0);
@@ -62,8 +65,8 @@ public class TestInfoPreParse extends TestCase {
Element expectedRoot = null;
try {
absFilePath = FileLocator.toFileURL(fileURL).getFile();
- file = new File (absFilePath);
- FileInputStream inp = new FileInputStream(file);
+ fileStore = EFS.getLocalFileSystem().getStore(new Path(absFilePath));
+ InputStream inp = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
builder = factory.newDocumentBuilder();
@@ -78,6 +81,8 @@ public class TestInfoPreParse extends TestCase {
fail("Failed to parse the XML.");
} catch (ParserConfigurationException e) {
fail("Failed to create a document builder.");
+ } catch (CoreException e) {
+ fail("Failed to open output stream");
}
rootList = new Element [] {expectedRoot, actualRoot};
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF b/oprofile/org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF
index 8559f00..c2a35ac 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/META-INF/MANIFEST.MF
@@ -7,7 +7,11 @@ Bundle-Activator: org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlug
Bundle-Vendor: %bundleProvider
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
org.eclipse.ui;bundle-version="3.4.0",
- org.eclipse.linuxtools.tools.launch.core
+ org.eclipse.linuxtools.tools.launch.core,
+ org.eclipse.linuxtools.profiling.launch;bundle-version="0.9.0",
+ org.eclipse.cdt.core;bundle-version="5.3.0",
+ org.eclipse.core.filesystem;bundle-version="1.3.100",
+ org.eclipse.jface.text;bundle-version="3.7.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: oprofile-core.jar
Bundle-ActivationPolicy: lazy
@@ -22,4 +26,5 @@ Export-Package: org.eclipse.linuxtools.internal.oprofile.core,
org.eclipse.linuxtools.internal.oprofile.core.opxml.sessions
Bundle-Localization: plugin
Eclipse-BundleShape: dir
-Import-Package: org.eclipse.core.resources
+Import-Package: org.eclipse.core.resources,
+ org.eclipse.ui
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/build.properties b/oprofile/org.eclipse.linuxtools.oprofile.core/build.properties
index 6180272..32c8e62 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/build.properties
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/build.properties
@@ -4,7 +4,8 @@ bin.includes = META-INF/,\
about.html,\
README,\
natives/,\
- op_error_key
+ op_error_key,\
+ plugin.xml
src.includes = README,\
about.html,\
natives/
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/plugin.xml b/oprofile/org.eclipse.linuxtools.oprofile.core/plugin.xml
new file mode 100644
index 0000000..6386692
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="org.eclipse.linuxtools.oprofile.core.OpcontrolProvider" name="Opcontrol Provider" schema="schema/org.eclipse.linuxtools.oprofile.core.OpcontrolProvider.exsd"/>
+ <extension
+ point="org.eclipse.linuxtools.oprofile.core.OpcontrolProvider">
+ <opcontrolProvider
+ class="org.eclipse.linuxtools.internal.oprofile.core.linux.LinuxOpcontrolProvider"
+ scheme="file">
+ </opcontrolProvider>
+ </extension>
+
+</plugin>
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/schema/org.eclipse.linuxtools.oprofile.core.OpcontrolProvider.exsd b/oprofile/org.eclipse.linuxtools.oprofile.core/schema/org.eclipse.linuxtools.oprofile.core.OpcontrolProvider.exsd
new file mode 100644
index 0000000..01ea37e
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/schema/org.eclipse.linuxtools.oprofile.core.OpcontrolProvider.exsd
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.linuxtools.oprofile.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.linuxtools.oprofile.core" id="org.eclipse.linuxtools.oprofile.core.OpcontrolProvider" name="Opcontrol Provider"/>
+ </appinfo>
+ <documentation>
+ This extension point allows providing classes that encapsulate running opcontrol in different platforms.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="opcontrolProvider"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="opcontrolProvider">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="scheme" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java
index 2d3e7c2..fc0ceea 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.core;
+import org.eclipse.core.resources.IProject;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonEvent;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions;
@@ -90,4 +91,10 @@ public interface IOpcontrolProvider {
public void deleteSession (String sessionName, String sessionEvent) throws OpcontrolException;
public boolean status() throws OpcontrolException;
+
+ /**
+ * @since 1.1
+ */
+ public boolean hasPermissions(IProject project) throws OpcontrolException;
+
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java
index fa6f3c7..ac9b83b 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java
@@ -12,17 +12,20 @@
package org.eclipse.linuxtools.internal.oprofile.core;
-import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpInfo;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.checkevent.CheckEventsProcessor;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
/**
@@ -74,9 +77,16 @@ public class Oprofile
// succesfully call into the oprofile wrapper library without causing it to print out
// a lot of warnings).
private static boolean isKernelModuleLoaded() {
+ IRemoteFileProxy proxy = null;
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
for (int i = 0; i < OPROFILE_CPU_TYPE_FILES.length; ++i) {
- File f = new File(OPROFILE_CPU_TYPE_FILES[i]);
- if (f.exists())
+ IFileStore f = proxy.getResource(OPROFILE_CPU_TYPE_FILES[i]);
+ if (f.fetchInfo().exists())
return true;
}
@@ -231,15 +241,12 @@ public class Oprofile
* @since 1.1
*/
public static void updateInfo(){
- try {
- if (!OprofileCorePlugin.getDefault().getOpcontrolProvider().status()){
- OprofileCorePlugin.getDefault().getOpcontrolProvider().initModule();
+ if (!isKernelModuleLoaded()){
+ initializeOprofile();
}
+ if(isKernelModuleLoaded()){
info = OpInfo.getInfo();
- } catch (OpcontrolException e) {
- e.printStackTrace();
}
-
}
// Oprofile class has a static initializer and the code inside it needs to know which project
@@ -251,8 +258,6 @@ public class Oprofile
public static class OprofileProject {
private static IProject project;
- // Reloads oprofile modules by calling 'opcontrol --deinit' and
- // 'opcontrol --init'
public static void setProject(IProject project) {
OprofileProject.project = project;
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java
index 705a0ba..4a8996c 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java
@@ -17,13 +17,16 @@ import java.net.URL;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.linuxtools.internal.oprofile.core.linux.LinuxOpcontrolProvider;
import org.eclipse.linuxtools.internal.oprofile.core.linux.LinuxOpxmlProvider;
import org.eclipse.swt.widgets.Display;
import org.osgi.framework.Bundle;
@@ -121,7 +124,32 @@ public class OprofileCorePlugin extends Plugin {
//
// return _opcontrol;
- return new LinuxOpcontrolProvider();
+ IOpcontrolProvider opcontrolProvider = null;
+
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extPoint = registry.getExtensionPoint("org.eclipse.linuxtools.oprofile.core.OpcontrolProvider"); //$NON-NLS-1$
+ if (extPoint != null) {
+ IExtension[] extensions = extPoint.getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configElements = extension.getConfigurationElements();
+ if (configElements.length != 0) {
+ try {
+ String scheme = configElements[0].getAttribute("scheme");
+ if(Oprofile.OprofileProject.getProject().getLocationURI().getScheme().equals(scheme)){
+ opcontrolProvider = (IOpcontrolProvider) configElements[0].createExecutableExtension("class");//$NON-NLS-1$
+ }
+ } catch (CoreException ce) {
+ ce.printStackTrace();
+ }
+ }
+ }
+ }
+ // If there was a problem finding opcontrol, throw an exception
+ if(opcontrolProvider == null) {
+ throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolProvider", null));
+ }
+
+ return opcontrolProvider;
}
public static IStatus createErrorStatus(String errorClassString, Exception e) {
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java
index 7a6d9c5..31d55c1 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java
@@ -39,10 +39,12 @@ import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathPropert
public class LinuxOpcontrolProvider implements IOpcontrolProvider {
private static final String OPCONTROL_EXECUTABLE = "opcontrol";
+ private static final int SUDO_TIMEOUT = 2000;
+
// Location of opcontrol security wrapper
private static final String OPCONTROL_REL_PATH = "natives/linux/scripts/" + OPCONTROL_EXECUTABLE; //$NON-NLS-1$
- private final String opcontrolProgram;
+ private static boolean isInstalled;
// Initialize the Oprofile kernel module and oprofilefs
private static final String OPD_INIT_MODULE = "--init"; //$NON-NLS-1$
@@ -98,8 +100,7 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider {
private String verbosity = ""; //$NON-NLS-1$
- public LinuxOpcontrolProvider() throws OpcontrolException {
- opcontrolProgram = findOpcontrol();
+ public LinuxOpcontrolProvider() {
}
/**
@@ -255,13 +256,7 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider {
IProject project = Oprofile.OprofileProject.getProject();
- // If no linuxtools' toolchain is defined for this project, use the path for the
- // link created by the installation script
- if(project == null || LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){
- args.add(0, opcontrolProgram);
- } else{
- args.add(0, OPCONTROL_EXECUTABLE);
- }
+ args.add(0, findOpcontrol());
// Verbosity hack. If --start or --start-daemon, add verbosity, if set
String cmd = args.get(1);
@@ -277,17 +272,44 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider {
printOpcontrolCmd(cmdArray);
}
+ Process p = createOpcontrolProcess(cmdArray, project);
+ return checkOpcontrolProcess(p);
+
+ }
+
+ /**
+ * @param cmdArray
+ * @param project
+ * @return
+ * @throws OpcontrolException
+ * @since 1.1
+ */
+ protected Process createOpcontrolProcess(String[] cmdArray, IProject project) throws OpcontrolException {
Process p = null;
try {
- if(project == null || LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){
+
+ if (!LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){
+ p = RuntimeProcessFactory.getFactory().sudoExec(cmdArray, project);
+ } else if (isInstalled){
p = Runtime.getRuntime().exec(cmdArray);
} else{
- p = RuntimeProcessFactory.getFactory().sudoExec(cmdArray, project);
+ throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolProvider", null)); //$NON-NLS-1$
}
+
} catch (IOException ioe) {
throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolRun", ioe)); //$NON-NLS-1$
}
+ return p;
+ }
+
+ /**
+ * @since 1.1
+ * @param p
+ * @return
+ * @throws OpcontrolException
+ */
+ protected boolean checkOpcontrolProcess(Process p) throws OpcontrolException {
if (p != null) {
BufferedReader errout = new BufferedReader(new InputStreamReader(p.getErrorStream()));
BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream()));
@@ -341,21 +363,24 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider {
System.out.println(OprofileCorePlugin.DEBUG_PRINT_PREFIX + buf.toString());
}
- private static String findOpcontrol() throws OpcontrolException {
+ protected String findOpcontrol() {
IProject project = Oprofile.OprofileProject.getProject();
+ if (!LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){
+ return OPCONTROL_EXECUTABLE;
+ }
+
URL url = FileLocator.find(Platform.getBundle(OprofileCorePlugin
.getId()), new Path(OPCONTROL_REL_PATH), null);
if (url != null) {
try {
+ isInstalled = true;
return FileLocator.toFileURL(url).getPath();
} catch (IOException ignore) {
}
- // If no linuxtools' toolchain is defined for this project and oprofile is not
- // installed, throw exception
- } else if(project == null || LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){
- throw new OpcontrolException(OprofileCorePlugin.createErrorStatus(
- "opcontrolProvider", null)); //$NON-NLS-1$
+ } else {
+ isInstalled = false;
+ return OPCONTROL_EXECUTABLE;
}
return null;
@@ -413,4 +438,83 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider {
args.add(OPD_CALLGRAPH_DEPTH + options.getCallgraphDepth());
}
+
+ /**
+ * Checks if the user has permissions to execute opcontrol as root without providing password
+ * and if opcontrol exists in the indicated path
+ * @param project
+ * @return
+ * @throws OpcontrolException if opcontrol not installed
+ * @since 1.1
+ */
+ public boolean hasPermissions(IProject project) throws OpcontrolException {
+ String linuxtoolsPath = LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project);
+
+ try {
+ String opcontrolPath = null;
+ if(linuxtoolsPath.equals("")){
+ if(!isInstalled()){
+ throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolProvider", null));
+ } else{
+ return true;
+ }
+
+ } else if(linuxtoolsPath.endsWith("/")){
+ opcontrolPath = linuxtoolsPath + "opcontrol";
+ } else {
+ opcontrolPath = linuxtoolsPath + "/opcontrol";
+ }
+
+ // Check if user has sudo permissions without password by running sudo -l.
+ final Process p = RuntimeProcessFactory.getFactory().exec("sudo -l", project);
+ final StringBuffer buffer = new StringBuffer();
+
+ if(p == null){
+ return false;
+ }
+
+ Thread t = new Thread() {
+ @Override
+ public void run() {
+ try {
+ BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String s = null;
+ while ((s = input.readLine()) != null) {
+ buffer.append(s);
+ buffer.append('\n');
+ }
+ p.waitFor();
+ p.destroy();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ t.start();
+ t.join(SUDO_TIMEOUT);
+
+ String[] sudoLines = buffer.toString().split("\n");
+ for (String s : sudoLines) {
+ if(s.contains(opcontrolPath) && s.contains("NOPASSWD")){
+ return true;
+ }
+ }
+ System.out.println(buffer.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ private boolean isInstalled(){
+ findOpcontrol();
+ return isInstalled;
+ }
+
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpControlErrorHandler.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpControlErrorHandler.java
index 1eebd1a..8437d3a 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpControlErrorHandler.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpControlErrorHandler.java
@@ -11,16 +11,22 @@
package org.eclipse.linuxtools.internal.oprofile.core.linux;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.HashMap;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
import org.eclipse.linuxtools.internal.oprofile.core.OprofileProperties;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
import org.eclipse.osgi.util.NLS;
/**
@@ -47,6 +53,7 @@ public class OpControlErrorHandler {
public OpcontrolException handleError (String stdout, String stderr) {
String type = "";
String fullErr = "";
+ IRemoteFileProxy proxy = null;
// Figure out which stream has the error
// If both have errors, then stderr takes priority
@@ -65,8 +72,12 @@ public class OpControlErrorHandler {
// Read in the errors
try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ IFileStore fileStore = proxy.getResource(errorFilePath);
+ InputStream is = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
+
String line = "";
- BufferedReader buff = new BufferedReader(new FileReader(new File(errorFilePath)));
+ BufferedReader buff = new BufferedReader(new InputStreamReader(is));
// Populate the mapping
while ((line = buff.readLine()) != null){
@@ -76,10 +87,10 @@ public class OpControlErrorHandler {
buff.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
+ } catch (CoreException e) {
+ e.printStackTrace();
}
String error = null;
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java
index 768340a..4c2d77c 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java
@@ -11,18 +11,24 @@
package org.eclipse.linuxtools.internal.oprofile.core.opxml;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.HashMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.info.InfoAdapter;
+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.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -52,13 +58,28 @@ public class EventIdCache {
// name - the name of the event
// Element - the DOM node
private HashMap<String, Element> nameMap;
- private static EventIdCache single;
+
+ // Map containing the caches for remote machines
+ private static HashMap<String, EventIdCache> cacheMap;
public static EventIdCache getInstance(){
- if (single == null){
- single = new EventIdCache ();
+
+ if(cacheMap == null){
+ cacheMap = new HashMap<String, EventIdCache>();
+ }
+
+ IProject project = Oprofile.OprofileProject.getProject();
+ if(project != null){
+ EventIdCache eventIdCache = cacheMap.get(project.getLocationURI().getHost());
+ if(eventIdCache == null){
+ eventIdCache = new EventIdCache();
+ cacheMap.put(project.getLocationURI().getHost(), eventIdCache);
}
- return single;
+ return eventIdCache;
+ } else{
+ return null;
+ }
+
}
/**
@@ -66,30 +87,33 @@ public class EventIdCache {
* @return the DOM Element corresponding to the event tag
*/
public Element getElementWithName (String name) {
- if (single.nameMap == null){
- readXML();
- buildCache();
+ IProject project = Oprofile.OprofileProject.getProject();
+ EventIdCache eventIdCache = cacheMap.get(project.getLocationURI().getHost());
+ if (eventIdCache.nameMap == null){
+ readXML(eventIdCache);
+ buildCache(eventIdCache);
}
- return single.nameMap.get(name) != null ? (Element)single.nameMap.get(name) : null;
+ return eventIdCache.nameMap.get(name) != null ? (Element)eventIdCache.nameMap.get(name) : null;
+
}
/**
* Build the cache
*/
- private void buildCache() {
- single.nameMap = new HashMap<String, Element> ();
- NodeList eventList = single.eventRoot.getElementsByTagName(EVENT);
+ private void buildCache(EventIdCache eventId) {
+ eventId.nameMap = new HashMap<String, Element> ();
+ NodeList eventList = eventId.eventRoot.getElementsByTagName(EVENT);
for (int i = 0; i < eventList.getLength(); i++){
Element elem = (Element) eventList.item(i);
String eventName = elem.getAttribute(EVENT_NAME);
- single.nameMap.put(eventName, elem);
+ eventId.nameMap.put(eventName, elem);
}
}
/**
* Read the XML from ophelp
*/
- private void readXML() {
+ private void readXML(EventIdCache eventId) {
try {
Process p = RuntimeProcessFactory.getFactory().exec(OPHELP + " " + "-X", Oprofile.OprofileProject.getProject());
@@ -98,9 +122,9 @@ public class EventIdCache {
try {
builder = factory.newDocumentBuilder();
try {
- single.eventDoc = builder.parse(p.getInputStream());
- Element elem = (Element) single.eventDoc.getElementsByTagName(HELP_EVENTS).item(0);
- single.eventRoot = elem;
+ eventId.eventDoc = builder.parse(p.getInputStream());
+ Element elem = (Element) eventId.eventDoc.getElementsByTagName(HELP_EVENTS).item(0);
+ eventId.eventRoot = elem;
} catch (IOException e) {
} catch (SAXException e) {
}
@@ -123,21 +147,31 @@ public class EventIdCache {
* bitmask, or null if none could be found.
*/
public String getUnitMaskType(String name) {
- if (single.eventRoot == null){
- readXML();
- buildCache();
+ IProject project = Oprofile.OprofileProject.getProject();
+ EventIdCache eventIdCache = cacheMap.get(project.getLocationURI().getHost());
+
+ if (eventIdCache.eventRoot == null){
+ readXML(eventIdCache);
+ buildCache(eventIdCache);
}
- Element header = (Element)single.eventRoot.getElementsByTagName(HEADER).item(0);
+ Element header = (Element)eventIdCache.eventRoot.getElementsByTagName(HEADER).item(0);
double schemaVersion = 0;
- if (!single.eventRoot.getAttribute(SCHEMA).equals("")){
- schemaVersion = Double.parseDouble(single.eventRoot.getAttribute(SCHEMA));
+
+ if (!eventIdCache.eventRoot.getAttribute(SCHEMA).equals("")){
+ schemaVersion = Double.parseDouble(eventIdCache.eventRoot.getAttribute(SCHEMA));
}else{
schemaVersion = Double.parseDouble(header.getAttribute(SCHEMA));
}
String unitMaskType = null;
+ IRemoteFileProxy proxy = null;
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
// Schema Version > 1.0 has the unit mask type within the XML
if (schemaVersion > 1.0){
@@ -145,15 +179,17 @@ public class EventIdCache {
Element unitMaskTag = (Element) event.getElementsByTagName(InfoAdapter.UNIT_MASKS).item(0);
return unitMaskTag.getAttribute(CATEGORY);
}else{
- File file = new File(InfoAdapter.CPUTYPE);
+ IFileStore fileStore = proxy.getResource(InfoAdapter.CPUTYPE);
BufferedReader bi = null;
try {
- bi = new BufferedReader(new FileReader(file));
+ InputStream fileInputStream = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
+ bi = new BufferedReader(new InputStreamReader(fileInputStream));
String cpuType = bi.readLine();
- File opArchEvents = new File(InfoAdapter.OP_SHARE + cpuType + "/" + InfoAdapter.EVENTS); //$NON-NLS-1$
- File opArchUnitMasks = new File(InfoAdapter.OP_SHARE + cpuType + "/" + InfoAdapter.UNIT_MASKS); //$NON-NLS-1$
+ IFileStore opArchEvents = proxy.getResource(InfoAdapter.OP_SHARE + cpuType + "/" + InfoAdapter.EVENTS); //$NON-NLS-1$
+ IFileStore opArchUnitMasks = proxy.getResource(InfoAdapter.OP_SHARE + cpuType + "/" + InfoAdapter.UNIT_MASKS); //$NON-NLS-1$
- BufferedReader eventReader = new BufferedReader(new FileReader(opArchEvents));
+ InputStream inputStreamEvents = opArchEvents.openInputStream(EFS.NONE, new NullProgressMonitor());
+ BufferedReader eventReader = new BufferedReader(new InputStreamReader(inputStreamEvents));
String line;
while ((line = eventReader.readLine()) != null){
// find the line with the event name
@@ -164,8 +200,8 @@ public class EventIdCache {
String um = line.substring(start, end);
BufferedReader unitMaskReader = null;
try {
- unitMaskReader = new BufferedReader(new FileReader(
- opArchUnitMasks));
+ InputStream inputStreamMasks = opArchUnitMasks.openInputStream(EFS.NONE, new NullProgressMonitor());
+ unitMaskReader = new BufferedReader(new InputStreamReader(inputStreamMasks));
while ((line = unitMaskReader.readLine()) != null) {
if (line.contains("name:" + um + " ")) { //$NON-NLS-1$
start = line.indexOf("type:") + 5; //$NON-NLS-1$
@@ -182,10 +218,10 @@ public class EventIdCache {
}
}
eventReader.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
+ } catch (CoreException e) {
+ e.printStackTrace();
} finally {
if (bi != null) {
try {
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/checkevent/CheckEventAdapter.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/checkevent/CheckEventAdapter.java
index 58b7757..ea282a9 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/checkevent/CheckEventAdapter.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/checkevent/CheckEventAdapter.java
@@ -10,16 +10,20 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.core.opxml.checkevent;
-import java.io.File;
import java.util.TreeSet;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.AbstractDataAdapter;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.EventIdCache;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.info.InfoAdapter;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -133,8 +137,14 @@ public class CheckEventAdapter extends AbstractDataAdapter {
* hard-coded in a list. This method may not be entirely correct,
* although much simpler.
*/
- File file = new File(InfoAdapter.DEV_OPROFILE + cpuCounter);
- if (! file.exists()){
+ IRemoteFileProxy proxy = null;
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ IFileStore fileStore = proxy.getResource(InfoAdapter.DEV_OPROFILE + cpuCounter);
+ if (! fileStore.fetchInfo().exists()){
return false;
}
return true;
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java
index 65425b8..a79fed0 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java
@@ -11,25 +11,30 @@
package org.eclipse.linuxtools.internal.oprofile.core.opxml.info;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.AbstractDataAdapter;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.EventIdCache;
+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.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
/**
* This class takes the XML that is output from 'ophelp -X' for and uses that
@@ -85,6 +90,7 @@ public class InfoAdapter extends AbstractDataAdapter{
private Document newDoc; // the document we intend to build
private Element oldRoot; // the root of the document with data from ophelp
private Element newRoot; // the root of the document we intent to build
+ private static IRemoteFileProxy proxy;
private static boolean hasTimerSupport;
@@ -99,14 +105,16 @@ public class InfoAdapter extends AbstractDataAdapter{
createDOM(is);
}
} catch (IOException e) {
+ e.printStackTrace();
}
}
- public InfoAdapter(File resourceFile) {
+ public InfoAdapter(IFileStore resourceFile) {
+ InputStream inputStream = null;
try {
- FileInputStream fileInpStr = new FileInputStream(resourceFile);
- createDOM(fileInpStr);
- } catch (FileNotFoundException e) {
+ inputStream = resourceFile.openInputStream(EFS.NONE, new NullProgressMonitor());
+ createDOM(inputStream);
+ } catch (CoreException e) {
e.printStackTrace();
}
}
@@ -131,8 +139,10 @@ public class InfoAdapter extends AbstractDataAdapter{
newDoc = builder.newDocument();
newRoot = newDoc.createElement(INFO);
newDoc.appendChild(newRoot);
- } catch (IOException e) {
- } catch (SAXException e) {
+ } catch (Exception e) {
+ e.printStackTrace();
+ OpcontrolException opcontrolException = new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolRun", null)); //$NON-NLS-1$
+ OprofileCorePlugin.showErrorDialog("opcontrolProvider",opcontrolException);
}
} catch (ParserConfigurationException e1) {
e1.printStackTrace();
@@ -205,10 +215,13 @@ public class InfoAdapter extends AbstractDataAdapter{
* Set whether the cpu supports timer mode
*/
public static void checkTimerSupport() {
- File file = new File(CPUTYPE);
try {
- BufferedReader bi = new BufferedReader(new FileReader(file));
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ IFileStore fileStore = proxy.getResource(CPUTYPE);
+ if(fileStore.fetchInfo().exists()){
+ InputStream is = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
+ BufferedReader bi = new BufferedReader(new InputStreamReader(is));
String cpuType = bi.readLine();
bi.close();
if (cpuType.equals(TIMER)) {
@@ -216,11 +229,15 @@ public class InfoAdapter extends AbstractDataAdapter{
} else {
hasTimerSupport = false;
}
+
+ }
} catch (FileNotFoundException e) {
hasTimerSupport = true;
} catch (IOException e) {
hasTimerSupport = true;
e.printStackTrace();
+ } catch (CoreException e) {
+ e.printStackTrace();
}
}
@@ -230,13 +247,16 @@ public class InfoAdapter extends AbstractDataAdapter{
* @return the system's cpu frequency
*/
private int getCPUFrequency() {
- File file = new File(CPUINFO);
+
int val = 0;
BufferedReader bi = null;
try {
- bi = new BufferedReader(new FileReader(file));
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ IFileStore fileStore = proxy.getResource(CPUINFO);
+ if(fileStore.fetchInfo().exists()){
+ InputStream is = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
+ bi = new BufferedReader(new InputStreamReader(is));
String line;
-
while ((line = bi.readLine()) != null) {
int index = line.indexOf(':');
if (index != -1) {
@@ -263,10 +283,13 @@ public class InfoAdapter extends AbstractDataAdapter{
}
}
bi.close();
+ }
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
+ } catch (CoreException e) {
+ e.printStackTrace();
} finally {
if (null != bi) {
try {
@@ -289,10 +312,15 @@ public class InfoAdapter extends AbstractDataAdapter{
* hard-coded in a list. This method may not be entirely correct,
* although much simpler.
*/
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
final int MAXCPUS = Integer.MAX_VALUE;
for (int i = 0; i < MAXCPUS; i++){
- File file = new File (DEV_OPROFILE + i);
- if (!file.exists()){
+ IFileStore fileStore = proxy.getResource(DEV_OPROFILE + i);
+ if(!fileStore.fetchInfo().exists()){
return i;
}
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/META-INF/MANIFEST.MF b/oprofile/org.eclipse.linuxtools.oprofile.launch/META-INF/MANIFEST.MF
index 20d4ced..2b0090c 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/META-INF/MANIFEST.MF
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/META-INF/MANIFEST.MF
@@ -31,3 +31,6 @@ Import-Package: org.eclipse.cdt.core.model,
org.eclipse.linuxtools.internal.oprofile.ui.view,
org.eclipse.linuxtools.profiling.launch,
org.eclipse.ui
+Export-Package: org.eclipse.linuxtools.internal.oprofile.launch;x-friends:="org.eclipse.linuxtools.oprofile.remote.launch",
+ org.eclipse.linuxtools.internal.oprofile.launch.configuration;x-friends:="org.eclipse.linuxtools.oprofile.remote.launch",
+ org.eclipse.linuxtools.internal.oprofile.launch.launching;x-friends:="org.eclipse.linuxtools.oprofile.remote.launch"
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java
index a368d59..c44f0b3 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java
@@ -12,13 +12,15 @@
package org.eclipse.linuxtools.internal.oprofile.launch.configuration;
-import java.io.File;
-
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions;
import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
/**
* This class wraps OProfile's global launch options for the
@@ -38,11 +40,17 @@ public class LaunchOptions {
* @return whether the options are valid
*/
public boolean isValid() {
+ IRemoteFileProxy proxy = null;
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
// The only point of contention is whether the specified vmlinux *file* exists.
String fn = options.getKernelImageFile();
if (fn != null && fn.length() > 0) {
- File file = new File(options.getKernelImageFile());
- return (file.exists() && file.isFile());
+ IFileStore fileStore = proxy.getResource(options.getKernelImageFile());
+ return (fileStore.fetchInfo().exists() && !fileStore.fetchInfo().isDirectory());
}
return true;
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java
index 7581ebc..9066e7f 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java
@@ -24,6 +24,9 @@ package org.eclipse.linuxtools.internal.oprofile.launch.configuration;
import java.text.MessageFormat;
import java.util.ArrayList;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -37,6 +40,8 @@ import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider;
+import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent;
@@ -44,6 +49,7 @@ import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonEvent;
import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchMessages;
import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathProperty;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ModifyEvent;
@@ -55,6 +61,7 @@ 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.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
@@ -64,9 +71,12 @@ import org.eclipse.swt.widgets.Text;
* Thic class represents the event configuration tab of the launcher dialog.
*/
public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
+ private static final String EMPTY_STRING = "";
protected Button defaultEventCheck;
- protected OprofileCounter[] counters = OprofileCounter.getCounters(null);
+ protected OprofileCounter[] counters = null;
protected CounterSubTab[] counterSubTabs;
+ private Boolean hasPermissions = null;
+ private Composite top;
/**
* Essentially the constructor for this tab; creates the 'default event'
@@ -74,31 +84,25 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
* @param parent the parent composite
*/
public void createControl(Composite parent) {
- Composite top = new Composite(parent, SWT.NONE);
- setControl(top);
- top.setLayout(new GridLayout());
+ Composite top;
- if (getTimerMode()) {
- Label timerModeLabel = new Label(top, SWT.LEFT);
- timerModeLabel.setText(OprofileLaunchMessages.getString("tab.event.timermode.no.options")); //$NON-NLS-1$
+ if(parent.getChildren().length > 0){
+ top = (Composite) parent.getChildren()[0];
} else {
- createVerticalSpacer(top, 1);
-
- //default event checkbox
- defaultEventCheck = new Button(top, SWT.CHECK);
- defaultEventCheck.setText(OprofileLaunchMessages.getString("tab.event.defaultevent.button.text")); //$NON-NLS-1$
- defaultEventCheck.setLayoutData(new GridData());
- defaultEventCheck.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent se) {
- handleEnabledToggle();
+ top = new Composite(parent, SWT.NONE);
+ setControl(top);
+ top.setLayout(new GridLayout());
}
- });
-
- createVerticalSpacer(top, 1);
+ this.top = top;
+ }
+ /**
+ * @since 1.1
+ * @param top
+ */
+ private void createCounterTabs(Composite top){
//tabs for each of the counters
- OprofileCounter[] counters = OprofileCounter.getCounters(null);
+ counters = OprofileCounter.getCounters(null);
TabItem[] counterTabs = new TabItem[counters.length];
counterSubTabs = new CounterSubTab[counters.length];
@@ -115,6 +119,38 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
counterTabs[i].setControl(c);
counterTabs[i].setText(OprofileLaunchMessages.getString("tab.event.counterTab.counterText") + String.valueOf(i)); //$NON-NLS-1$
}
+ getTabFolderComposite();
+ }
+
+ /**
+ * Disposes all widgets and creates the timer mode Event tab
+ * @since 1.1
+ * @param top
+ */
+ private void createTimerModeTab(Composite top){
+ Control[] children = top.getChildren();
+ for (Control control : children) {
+ control.dispose();
+ }
+ counterSubTabs = null;
+ defaultEventCheck = null;
+
+ Label timerModeLabel = new Label(top, SWT.LEFT);
+ timerModeLabel.setText(OprofileLaunchMessages.getString("tab.event.timermode.no.options")); //$NON-NLS-1$
+ }
+
+ /**
+ * @since 1.1
+ */
+ private Composite getTabFolderComposite(){
+ if(counterSubTabs[0] == null){
+ return null;
+ } else {
+ Composite c = counterSubTabs[0].getTabTopContainer();
+ while(c != null && !(c instanceof TabFolder)){
+ c = c.getParent();
+ }
+ return c.getParent();
}
}
@@ -122,8 +158,66 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
* @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
*/
public void initializeFrom(ILaunchConfiguration config) {
- if (!getTimerMode()) {
+ this.hasPermissions = null;
+
+ IProject previousProject = Oprofile.OprofileProject.getProject();
+ IProject project = getProject(config);
+ Oprofile.OprofileProject.setProject(project);
+
try {
+ if(!hasPermissions(project)){
+ OpcontrolException e = new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolSudo", null));
+ OprofileCorePlugin.showErrorDialog("opcontrolProvider", e); //$NON-NLS-1$
+ createTimerModeTab(top);
+ return;
+ }
+ } catch (OpcontrolException e){
+ OprofileCorePlugin.showErrorDialog("opcontrolProvider", e);
+ createTimerModeTab(top);
+ return;
+ }
+ Oprofile.updateInfo();
+
+ String previousHost = null;
+ if(previousProject != null){
+ if(previousProject.getLocationURI() != null){
+ previousHost = previousProject.getLocationURI().getHost();
+ }
+ }
+
+ String host = project.getLocationURI().getHost();
+
+ // Create the counter tabs if host has changed or if they haven't been created yet
+ if(previousProject == null || previousHost != host || counters == null){
+ Control[] children = top.getChildren();
+
+ for (Control control : children) {
+ control.dispose();
+ }
+
+ if (getTimerMode()) {
+ Label timerModeLabel = new Label(top, SWT.LEFT);
+ timerModeLabel.setText(OprofileLaunchMessages.getString("tab.event.timermode.no.options")); //$NON-NLS-1$
+ } else {
+ createVerticalSpacer(top, 1);
+
+ //default event checkbox
+ defaultEventCheck = new Button(top, SWT.CHECK);
+ defaultEventCheck.setText(OprofileLaunchMessages.getString("tab.event.defaultevent.button.text")); //$NON-NLS-1$
+ defaultEventCheck.setLayoutData(new GridData());
+ defaultEventCheck.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent se) {
+ handleEnabledToggle();
+ }
+ });
+ createVerticalSpacer(top, 1);
+ createCounterTabs(top);
+ }
+
+ }
+
+ if(!getTimerMode()){
for (int i = 0; i < counters.length; i++) {
counters[i].loadConfiguration(config);
}
@@ -131,12 +225,10 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
for (CounterSubTab tab : counterSubTabs) {
tab.initializeTab(config);
}
-
+ try{
boolean enabledState = config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, true);
defaultEventCheck.setSelection(enabledState);
setEnabledState(!enabledState);
-
- updateLaunchConfigurationDialog();
} catch (CoreException e) {
e.printStackTrace();
}
@@ -148,6 +240,17 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
*/
@Override
public boolean isValid(ILaunchConfiguration config) {
+ IProject project = getProject(config);
+ Oprofile.OprofileProject.setProject(project);
+
+ try{
+ if(!hasPermissions(project)){
+ return false;
+ }
+ } catch(OpcontrolException e){
+ return false;
+ }
+
if (getTimerMode()) {
return true; //no options to check for validity
} else {
@@ -200,17 +303,23 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
* @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
*/
public void performApply(ILaunchConfigurationWorkingCopy config) {
+ IProject project = getProject(config);
+ try{
+ if(!hasPermissions(project)){
+ return;
+ }
if (getTimerMode()) {
config.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, true);
} else {
config.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, defaultEventCheck.getSelection());
-
for (CounterSubTab cst : counterSubTabs) {
cst.performApply(config);
}
}
- try {
config.doSave();
+ } catch(OpcontrolException e){
+ return;
+
} catch (CoreException e) {
e.printStackTrace();
}
@@ -222,6 +331,20 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
boolean useDefault = true;
+ IProject project = getProject(config);
+ Oprofile.OprofileProject.setProject(project);
+ if(project != null && !LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){
+ try{
+ if(!hasPermissions(project)){
+ return;
+ }
+ } catch(OpcontrolException e){
+ return;
+ }
+ }
+
+ counters = OprofileCounter.getCounters(config);
+
// When instantiated, the OprofileCounter will set defaults.
for (int i = 0; i < counters.length; i++) {
counters[i].saveConfiguration(config);
@@ -304,6 +427,42 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
}
/**
+ * Checks if user has permission to run remote opcontrol as root. Uses a local cache variable
+ * to avoid running costly calls repeatedly during creation of the view
+ * @param project
+ * @return
+ * @throws OpcontrolException
+ * @since 1.1
+ */
+ protected boolean hasPermissions(IProject project) throws OpcontrolException{
+ if (this.hasPermissions == null){
+ IOpcontrolProvider provider = OprofileCorePlugin.getDefault().getOpcontrolProvider();
+ this.hasPermissions = provider.hasPermissions(project);
+ }
+ return this.hasPermissions;
+ }
+
+ /**
+ *
+ * @param config
+ * @return
+ * @since 1.1
+ */
+ protected IProject getProject(ILaunchConfiguration config){
+ String name = null;
+ try {
+ name = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
+ } catch (CoreException e) {
+ return null;
+ }
+ if (name == null) {
+ return null;
+ }
+
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ }
+
+ /**
* A sub-tab of the OprofileEventConfigTab launch configuration tab.
* Essentially, it is a frontend to an OprofileCounter. This is an
* inner class because it requires methods from the parent tab (such as
@@ -322,7 +481,16 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
private OprofileCounter counter;
private ScrolledComposite scrolledTop;
- private Composite tabTopContainer;
+ protected Composite tabTopContainer;
+
+
+ public Composite getTabTopContainer() {
+ return tabTopContainer;
+ }
+
+ public void setTabTopContainer(Composite tabTopContainer) {
+ this.tabTopContainer = tabTopContainer;
+ }
/**
* Constructor for a subtab. Creates the layout and widgets for its content.
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java
index 0528fe9..99a9a54 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java
@@ -11,16 +11,19 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.launch.configuration;
-import java.io.File;
import java.text.MessageFormat;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions;
import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchMessages;
import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -51,6 +54,8 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab {
protected LaunchOptions options = null;
+ private IRemoteFileProxy proxy;
+
public String getName() {
return OprofileLaunchMessages.getString("tab.global.name"); //$NON-NLS-1$
}
@@ -229,8 +234,13 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab {
String filename = text.getText();
if (filename.length() > 0) {
- File file = new File(filename);
- if (!file.exists() || !file.isFile()) {
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ IFileStore fileStore = proxy.getResource(filename);
+ if (!fileStore.fetchInfo().exists() || fileStore.fetchInfo().isDirectory()){
String msg = OprofileLaunchMessages.getString("tab.global.kernelImage.kernel.nonexistent"); //$NON-NLS-1$
Object[] args = new Object[] { filename };
errorMessage = MessageFormat.format(msg, args);
@@ -251,19 +261,26 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab {
// Displays a file dialog to allow the user to select the kernel image file
private void showFileDialog(Shell shell) {
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
FileDialog d = new FileDialog(shell, SWT.OPEN);
- File kernel = new File(options.getKernelImageFile());
- if (!kernel.exists()) {
- kernel = new File("/boot"); //$NON-NLS-1$
- if (!kernel.exists())
- kernel = new File("/"); //$NON-NLS-1$
+ IFileStore kernel = proxy.getResource(options.getKernelImageFile());
+ if (!kernel.fetchInfo().exists()) {
+ kernel = proxy.getResource("/boot"); //$NON-NLS-1$
+
+ if (!kernel.fetchInfo().exists())
+ kernel = proxy.getResource("/"); //$NON-NLS-1$
}
d.setFileName(kernel.toString());
d.setText(OprofileLaunchMessages.getString("tab.global.selectKernelDialog.text")); //$NON-NLS-1$
String newKernel = d.open();
if (newKernel != null) {
- kernel = new File(newKernel);
- if (!kernel.exists()) {
+ kernel = proxy.getResource(newKernel);
+ if (!kernel.fetchInfo().exists()) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.RETRY | SWT.CANCEL);
mb.setMessage(OprofileLaunchMessages.getString("tab.global.selectKernelDialog.error.kernelDoesNotExist.text")); //$NON-NLS-1$
switch (mb.open()) {
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java
index a307834..7076b61 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java
@@ -14,20 +14,20 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.launch.launching;
-import java.io.File;
+import java.net.URI;
import java.util.ArrayList;
-import java.util.Arrays;
import org.eclipse.cdt.debug.core.CDebugUtils;
-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.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonEvent;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions;
@@ -36,20 +36,22 @@ import org.eclipse.linuxtools.internal.oprofile.launch.configuration.LaunchOptio
import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCounter;
import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin;
import org.eclipse.linuxtools.internal.oprofile.ui.view.OprofileView;
+import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
public abstract class AbstractOprofileLaunchConfigurationDelegate extends ProfileLaunchConfigurationDelegate {
-
protected ILaunchConfiguration config;
@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
this.config = config;
+ Oprofile.OprofileProject.setProject(getProject());
LaunchOptions options = new LaunchOptions(); //default options created in the constructor
options.loadConfiguration(config);
- IPath exePath = CDebugUtils.verifyProgramPath( config );
+ IPath exePath = getExePath(config);
options.setBinaryImage(exePath.toOSString());
//if daemonEvents null or zero size, the default event will be used
@@ -75,20 +77,16 @@ public abstract class AbstractOprofileLaunchConfigurationDelegate extends Profil
* originally in the CDT under LocalCDILaunchDelegate::RunLocalApplication
*/
//set up and launch the local c/c++ program
-
- File wd = getWorkingDirectory( config );
- if ( wd == null ) {
- wd = new File( System.getProperty( "user.home", "." ) ); //$NON-NLS-1$ //$NON-NLS-2$
- }
- String arguments[] = getProgramArgumentsArray( config );
- ArrayList<String> command = new ArrayList<String>( 1 + arguments.length );
- command.add( exePath.toOSString() );
- command.addAll( Arrays.asList( arguments ) );
- String[] commandArray = command.toArray( new String[command.size()] );
- boolean usePty = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
- Process process;
- process = execute( commandArray, getEnvironment( config ), wd, usePty );
- DebugPlugin.newProcess( launch, process, renderProcessLabel( commandArray[0] ) );
+ IRemoteCommandLauncher launcher = RemoteProxyManager.getInstance().getLauncher(Oprofile.OprofileProject.getProject());
+
+ URI workingDirURI = Oprofile.OprofileProject.getProject().getLocationURI();
+
+ IPath workingDirPath = new Path(workingDirURI.getPath());
+
+ String arguments[] = getProgramArgumentsArray( config );
+ Process process = launcher.execute(exePath, arguments, getEnvironment(config), workingDirPath, monitor);
+
+ DebugPlugin.newProcess( launch, process, renderProcessLabel( exePath.toOSString() ) );
postExec(options, daemonEvents, launch, process);
}
@@ -160,4 +158,16 @@ public abstract class AbstractOprofileLaunchConfigurationDelegate extends Profil
}
return null;
}
+ /**
+ *
+ * @param config
+ * @return
+ * @throws CoreException
+ * @since 1.1
+ */
+ protected IPath getExePath(ILaunchConfiguration config) throws CoreException{
+ IPath exePath = CDebugUtils.verifyProgramPath( config );
+
+ return exePath;
+ }
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java
index 65831e8..f50f00e 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java
@@ -10,10 +10,6 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.launch.launching;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
@@ -25,15 +21,11 @@ import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonEvent;
import org.eclipse.linuxtools.internal.oprofile.launch.configuration.LaunchOptions;
-import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathProperty;
import org.eclipse.swt.widgets.Display;
public class OprofileLaunchConfigurationDelegate extends AbstractOprofileLaunchConfigurationDelegate {
- private static final int SUDO_TIMEOUT = 5000;
- private static final String OPCONTROL_EXECUTABLE = "opcontrol";
-
@Override
protected boolean preExec(LaunchOptions options, OprofileDaemonEvent[] daemonEvents) {
//set up and launch the oprofile daemon
@@ -43,7 +35,7 @@ public class OprofileLaunchConfigurationDelegate extends AbstractOprofileLaunchC
//check if user has NOPASSWD sudo permission for opcontrol
//if the Linux Tools Path property was changed
if(project != null && !LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){
- if(!hasPermissions(project)){
+ if(!OprofileCorePlugin.getDefault().getOpcontrolProvider().hasPermissions(project)){
throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolSudo", null));
}
}
@@ -76,76 +68,6 @@ public class OprofileLaunchConfigurationDelegate extends AbstractOprofileLaunchC
return true;
}
-
- /**
- * Checks if the user has permissions to execute opcontrol as root without providing password
- * and if opcontrol exists in the indicated path
- * @param project
- * @return
- */
- public static boolean hasPermissions(IProject project) {
- String linuxtoolsPath = LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project);
-
- try {
- String opcontrolPath = null;
- if(linuxtoolsPath.equals("")){
- opcontrolPath = RuntimeProcessFactory.getFactory().whichCommand(OPCONTROL_EXECUTABLE, project);
- } else if(linuxtoolsPath.endsWith("/")){
- opcontrolPath = linuxtoolsPath + "opcontrol";
- } else {
- opcontrolPath = linuxtoolsPath + "/opcontrol";
- }
-
- if(opcontrolPath.equals("")){
- return false;
- }
-
- // Check if user has sudo permissions without password by running sudo -l.
- final Process p = RuntimeProcessFactory.getFactory().exec("sudo -l", project);
- final StringBuffer buffer = new StringBuffer();
-
- if(p == null){
- return false;
- }
-
- Thread t = new Thread() {
- @Override
- public void run() {
- try {
- BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
- String s = null;
- while ((s = input.readLine()) != null) {
- buffer.append(s);
- buffer.append('\n');
- }
- p.waitFor();
- p.destroy();
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- };
-
- t.start();
- t.join(SUDO_TIMEOUT);
-
- String[] sudoLines = buffer.toString().split("\n");
- for (String s : sudoLines) {
- if(s.contains(opcontrolPath) && s.contains("NOPASSWD")){
- return true;
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- return false;
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return false;
- }
-
@Override
protected void postExec(LaunchOptions options, OprofileDaemonEvent[] daemonEvents, ILaunch launch, Process process) {
//add a listener for termination of the launch
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.classpath b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.gitignore b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.gitignore
new file mode 100644
index 0000000..8d94ef8
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.gitignore
@@ -0,0 +1,5 @@
+bin
+@dot
+javaCompiler...args
+build.xml
+target
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.project b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.project
new file mode 100644
index 0000000..ac7d646
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.oprofile.remote.launch</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/META-INF/MANIFEST.MF b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..2bba32f
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.oprofile.remote.launch;singleton:=true
+Bundle-Version: 0.3.1.qualifier
+Bundle-Vendor: %bundleProvider
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
+ org.eclipse.ui;bundle-version="3.4.0",
+ org.eclipse.linuxtools.tools.launch.core
+Bundle-Activator: org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Import-Package: org.eclipse.cdt.launch,
+ org.eclipse.cdt.debug.core,
+ org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.linuxtools.internal.oprofile.core,
+ org.eclipse.linuxtools.internal.oprofile.core.daemon,
+ org.eclipse.linuxtools.internal.oprofile.core.linux,
+ org.eclipse.linuxtools.internal.oprofile.core.opxml.sessions,
+ org.eclipse.linuxtools.internal.oprofile.launch,
+ org.eclipse.linuxtools.internal.oprofile.launch.configuration,
+ org.eclipse.linuxtools.internal.oprofile.launch.launching,
+ org.eclipse.linuxtools.profiling.launch
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/about.html b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/about.html
new file mode 100644
index 0000000..28737f6
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/build.properties b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/build.properties
new file mode 100644
index 0000000..3e74bb9
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/build.properties
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ icons/,\
+ about.html
+src.includes = about.html,\
+ icons/
+individualSourceBundles=true
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/event_tab.gif b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/event_tab.gif
new file mode 100644
index 0000000..c91f254
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/event_tab.gif
Binary files differ
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/global_tab.gif b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/global_tab.gif
new file mode 100644
index 0000000..ec6cca4
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/global_tab.gif
Binary files differ
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/profile_run.png b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/profile_run.png
new file mode 100644
index 0000000..4f8488f
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/icons/profile_run.png
Binary files differ
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/plugin.properties b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/plugin.properties
new file mode 100644
index 0000000..655c55d
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/plugin.properties
@@ -0,0 +1,21 @@
+#*******************************************************************************
+# Copyright (c) 2008 Red Hat, Inc.
+# 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:
+# Red Hat, Inc. - initial API and implementation
+#*******************************************************************************
+bundleName=OProfile Remote Launch Plug-in (Incubation)
+bundleProvider=Eclipse Linux Tools
+
+pluginName=OProfile Remote Launch Support
+launchconfigurationtype.remote.label=Profile With OProfile (Remote)
+
+launchgroup.label=OProfile
+launchgroup.titile=Select a run configuration to profile with OProfile
+
+launchmode.label=Profile
+launchmode.launchaslabel=Profile As
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/plugin.xml b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/plugin.xml
new file mode 100644
index 0000000..575f5a1
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/plugin.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.eclipse.linuxtools.internal.oprofile.remote.launch.launching.OprofileRemoteLaunchConfigurationDelegate"
+ id="org.eclipse.linuxtools.oprofile.launch.oprofile.remote"
+ modes="profile"
+ name="%launchconfigurationtype.remote.label"
+ public="true"
+ sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
+ sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ configTypeID="org.eclipse.linuxtools.oprofile.launch.oprofile.remote"
+ icon="icons/profile_run.png"
+ id="org.eclipse.linuxtools.oprofile.launch.oprofileImage">
+ </launchConfigurationTypeImage>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ class="org.eclipse.linuxtools.internal.oprofile.remote.launch.configuration.OprofileRemoteLaunchConfigurationTabGroup"
+ id="org.eclipse.linuxtools.oprofile.launch.remoteLaunchConfigurationTabGroup"
+ type="org.eclipse.linuxtools.oprofile.launch.oprofile.remote">
+ </launchConfigurationTabGroup>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchShortcuts">
+ </extension>
+ <extension
+ point="org.eclipse.linuxtools.oprofile.core.OpcontrolProvider">
+ <opcontrolProvider
+ class="org.eclipse.linuxtools.internal.oprofile.remote.core.linux.RemoteLinuxOpcontrolProvider"
+ scheme="remotetools">
+ </opcontrolProvider>
+ </extension>
+ <extension
+ point="org.eclipse.linuxtools.oprofile.core.OpcontrolProvider">
+ <opcontrolProvider
+ class="org.eclipse.linuxtools.internal.oprofile.remote.core.linux.RemoteLinuxOpcontrolProvider"
+ scheme="rse">
+ </opcontrolProvider>
+ </extension>
+</plugin>
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/pom.xml b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/pom.xml
new file mode 100644
index 0000000..e543a97
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>linuxtools-oprofile-parent</artifactId>
+ <groupId>org.eclipse.linuxtools.oprofile</groupId>
+ <version>0.11.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.linuxtools.oprofile.launch.remote</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Linux Tools OProfile Remote Launch Plug-in</name>
+
+ <build>
+ <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 -->
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/core/linux/RemoteLinuxOpcontrolProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/core/linux/RemoteLinuxOpcontrolProvider.java
new file mode 100644
index 0000000..e7d9daa
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/core/linux/RemoteLinuxOpcontrolProvider.java
@@ -0,0 +1,115 @@
+package org.eclipse.linuxtools.internal.oprofile.remote.core.linux;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.internal.oprofile.core.linux.LinuxOpcontrolProvider;
+import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
+import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathProperty;
+
+/**
+ * A class which encapsulates running opcontrol.
+ * @since 1.1
+ */
+public class RemoteLinuxOpcontrolProvider extends LinuxOpcontrolProvider {
+
+ private static final String OPCONTROL_EXECUTABLE = "opcontrol";
+
+ private static final int SUDO_TIMEOUT = 5000;
+
+ public RemoteLinuxOpcontrolProvider() throws OpcontrolException {
+ }
+
+
+ protected Process createOpcontrolProcess(String[] cmdArray, IProject project) throws OpcontrolException {
+ Process p = null;
+ try {
+ p = RuntimeProcessFactory.getFactory().sudoExec(cmdArray, project);
+ } catch (IOException ioe) {
+ throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolRun", ioe)); //$NON-NLS-1$
+ }
+
+ return p;
+ }
+
+ protected String findOpcontrol(){
+ return OPCONTROL_EXECUTABLE;
+ }
+
+ public static boolean isInstalled(){
+ return true;
+ }
+
+ /**
+ * Checks if the user has permissions to execute opcontrol as root without providing password
+ * and if opcontrol exists in the indicated path
+ * @param project
+ * @return
+ */
+ public boolean hasPermissions(IProject project) {
+ String linuxtoolsPath = LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project);
+
+ try {
+ String opcontrolPath = null;
+ if(linuxtoolsPath.equals("")){
+ opcontrolPath = RuntimeProcessFactory.getFactory().whichCommand(OPCONTROL_EXECUTABLE, project);
+ } else if(linuxtoolsPath.endsWith("/")){
+ opcontrolPath = linuxtoolsPath + "opcontrol";
+ } else {
+ opcontrolPath = linuxtoolsPath + "/opcontrol";
+ }
+
+ if(opcontrolPath.equals("")){
+ return false;
+ }
+
+ // Check if user has sudo permissions without password by running sudo -l.
+ final Process p = RuntimeProcessFactory.getFactory().exec("sudo -l", project);
+ final StringBuffer buffer = new StringBuffer();
+
+ if(p == null){
+ return false;
+ }
+
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String s = null;
+ while ((s = input.readLine()) != null) {
+ buffer.append(s);
+ buffer.append('\n');
+ }
+ p.waitFor();
+ p.destroy();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ t.start();
+ t.join(SUDO_TIMEOUT);
+
+ String[] sudoLines = buffer.toString().split("\n");
+ for (String s : sudoLines) {
+ if(s.contains(opcontrolPath) && s.contains("NOPASSWD")){
+ return true;
+ }
+ }
+ System.out.println(buffer.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/configuration/OprofileRemoteEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/configuration/OprofileRemoteEventConfigTab.java
new file mode 100644
index 0000000..e15b19d
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/configuration/OprofileRemoteEventConfigTab.java
@@ -0,0 +1,45 @@
+package org.eclipse.linuxtools.internal.oprofile.remote.launch.configuration;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider;
+import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
+import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCounter;
+import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileEventConfigTab;
+import org.eclipse.swt.widgets.Button;
+
+
+/**
+ * Thic class represents the event configuration tab of the launcher dialog.
+ * @since 1.1
+ */
+public class OprofileRemoteEventConfigTab extends OprofileEventConfigTab {
+ protected Button defaultEventCheck;
+ protected OprofileCounter[] counters = null;
+ protected CounterSubTab[] counterSubTabs;
+ private Boolean hasPermissions = null;
+
+
+ public OprofileRemoteEventConfigTab(){
+ }
+
+ protected boolean hasPermissions(IProject project){
+ try{
+ if (this.hasPermissions == null){
+ IOpcontrolProvider provider = OprofileCorePlugin.getDefault().getOpcontrolProvider();
+ this.hasPermissions = provider.hasPermissions(project);
+ }
+ } catch(OpcontrolException e){
+ return false;
+ }
+ return this.hasPermissions;
+
+ }
+
+ public void initializeFrom(ILaunchConfiguration config) {
+ // Force re-check of permissions every time the view is initialized
+ this.hasPermissions = null;
+ super.initializeFrom(config);
+ }
+}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/configuration/OprofileRemoteLaunchConfigurationTabGroup.java b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/configuration/OprofileRemoteLaunchConfigurationTabGroup.java
new file mode 100644
index 0000000..8e4fecb
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/configuration/OprofileRemoteLaunchConfigurationTabGroup.java
@@ -0,0 +1,16 @@
+package org.eclipse.linuxtools.internal.oprofile.remote.launch.configuration;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileEventConfigTab;
+import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileSetupTab;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyProfileLaunchConfigurationTabGroup;
+
+/**
+ * @since 1.1
+ */
+public class OprofileRemoteLaunchConfigurationTabGroup extends RemoteProxyProfileLaunchConfigurationTabGroup {
+ @Override
+ public AbstractLaunchConfigurationTab[] getProfileTabs() {
+ return new AbstractLaunchConfigurationTab[] { new OprofileSetupTab(), new OprofileEventConfigTab() };
+ }
+}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/launching/OprofileRemoteLaunchConfigurationDelegate.java b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/launching/OprofileRemoteLaunchConfigurationDelegate.java
new file mode 100644
index 0000000..4848043
--- /dev/null
+++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/launch/launching/OprofileRemoteLaunchConfigurationDelegate.java
@@ -0,0 +1,57 @@
+package org.eclipse.linuxtools.internal.oprofile.remote.launch.launching;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.resources.IProject;
+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;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.internal.oprofile.launch.launching.OprofileLaunchConfigurationDelegate;
+import org.eclipse.linuxtools.profiling.launch.ProxyLaunchMessages;
+
+
+/**
+ * @since 1.1
+ */
+public class OprofileRemoteLaunchConfigurationDelegate extends OprofileLaunchConfigurationDelegate {
+ private final static String EMPTY_STRING = "";
+
+ @Override
+ protected IProject getProject() {
+ String name = null;
+ try {
+ name = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
+ } catch (CoreException e) {
+ return null;
+ }
+ if (name == null) {
+ return null;
+ }
+
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ }
+
+ @Override
+ protected IPath getExePath(ILaunchConfiguration config)
+ throws CoreException {
+ String pathString = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
+ URI uri;
+ try {
+ uri = new URI(pathString);
+ } catch (URISyntaxException e) {
+ throw new CoreException(new Status(IStatus.ERROR, OprofileCorePlugin.getId() ,
+ ProxyLaunchMessages.uri_of_executable_is_invalid));
+ }
+ IPath path = new Path(uri.getPath());
+
+ return path;
+ }
+
+}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF b/oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF
index 7665825..9fea4c3 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF
@@ -7,7 +7,9 @@ Bundle-Vendor: %bundleProvider
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
org.eclipse.ui;bundle-version="3.4.0",
- org.eclipse.ui.editors;bundle-version="3.4.0"
+ org.eclipse.ui.editors;bundle-version="3.4.0",
+ org.eclipse.linuxtools.profiling.launch;bundle-version="0.10.0",
+ org.eclipse.core.filesystem;bundle-version="1.3.100"
Bundle-Activator: org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewLogReaderAction.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewLogReaderAction.java
index 6a42a48..fad67e3 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewLogReaderAction.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewLogReaderAction.java
@@ -12,13 +12,17 @@
package org.eclipse.linuxtools.internal.oprofile.ui.view;
import java.io.BufferedReader;
-import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -26,6 +30,8 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiMessages;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -71,23 +77,28 @@ public class OprofileViewLogReaderAction extends Action {
class LogReader implements Runnable, IRunnableWithProgress {
private static long lastModified = -1;
private static String contents = null;
+ private IRemoteFileProxy proxy;
public void run() {
- File logFile = new File(Oprofile.getLogFile());
- long modified = logFile.lastModified();
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ IFileStore fileStore = proxy.getResource(Oprofile.getLogFile());
+ if(fileStore.fetchInfo().exists()){
+ long modified = fileStore.fetchInfo().getLastModified();
//only reread it if it has been modified since the last run
if (modified != lastModified) {
lastModified = modified;
contents = "";
-
- try {
- BufferedReader reader = new BufferedReader(new FileReader(logFile));
+ }
+ InputStream is = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
+ BufferedReader bi = new BufferedReader(new InputStreamReader(is));
String line;
- while ((line = reader.readLine()) != null) {
+ while ((line = bi.readLine()) != null){
contents += line + "\n"; //$NON-NLS-1$
}
- reader.close();
+ bi.close();
+ }
} catch (FileNotFoundException e) {
// The file doesn't exist or was erased. Try again next time.
contents = OprofileUiMessages.getString("oprofiled.logreader.error.fileNotFound"); //$NON-NLS-1$
@@ -95,7 +106,8 @@ class LogReader implements Runnable, IRunnableWithProgress {
// Error reading log. Try again next time.
lastModified = 0;
contents = OprofileUiMessages.getString("oprofiled.logreader.error.io"); //$NON-NLS-1$
- }
+ } catch (CoreException e) {
+ e.printStackTrace();
}
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java
index ec45ea6..6295fce 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java
@@ -11,9 +11,10 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.ui.view;
-import java.io.File;
import java.text.MessageFormat;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
@@ -28,12 +29,16 @@ import org.eclipse.linuxtools.internal.oprofile.ui.model.IUiModelElement;
import org.eclipse.linuxtools.internal.oprofile.ui.model.UiModelError;
import org.eclipse.linuxtools.internal.oprofile.ui.model.UiModelRoot;
import org.eclipse.linuxtools.internal.oprofile.ui.model.UiModelSession;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
/**
* Menu item to save the default session. Moved from a double-click in the view
* on the default session for consistency (since non-default sessions can't be saved).
*/
public class OprofileViewSaveDefaultSessionAction extends Action {
+ private IRemoteFileProxy proxy;
+
public OprofileViewSaveDefaultSessionAction() {
super(OprofileUiMessages.getString("view.actions.savedefaultsession.label")); //$NON-NLS-1$
}
@@ -113,8 +118,15 @@ public class OprofileViewSaveDefaultSessionAction extends Action {
}
// Must not already exist (opcontrol doesn't allow it)
- File file = new File(Oprofile.getDefaultSamplesDirectory(), newText);
- if (file.exists()) {
+
+ try {
+ proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ IFileStore fileStore = proxy.getResource(Oprofile.getDefaultSamplesDirectory() + newText);
+ if (fileStore.fetchInfo().exists()) {
String format = OprofileUiMessages.getString("savedialog.validator.exists"); //$NON-NLS-1$
Object[] fmtArgs = new Object[] { newText };
return MessageFormat.format(format, fmtArgs);