Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2013-12-03 14:44:50 -0500
committerJeff Johnston2013-12-03 15:53:08 -0500
commit97d561cdc947ee8a7ff325fb7b99fb2f0ee5d061 (patch)
treecfec92175f7aee2bfc859c7b0ab0af8b40585292
parentb22b69aa6928a79167cbd3ff35b5a68b44a54105 (diff)
downloadorg.eclipse.linuxtools-97d561cdc947ee8a7ff325fb7b99fb2f0ee5d061.tar.gz
org.eclipse.linuxtools-97d561cdc947ee8a7ff325fb7b99fb2f0ee5d061.tar.xz
org.eclipse.linuxtools-97d561cdc947ee8a7ff325fb7b99fb2f0ee5d061.zip
Add Linux Tools path support for SystemTap
- Add additional Command constructor that takes a project as input - Change RunScriptHandler to calculate the project, if possible - Add an additional ScriptConsole.runLocally method which takes project as input and uses RuntimeProcessFactory so that Linux Tools path will be used Change-Id: I6aa0cf1ead4dda393fecb2236491aa0b6dd912cd Reviewed-on: https://git.eclipse.org/r/19267 Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> IP-Clean: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.structures/META-INF/MANIFEST.MF2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.structures/pom.xml2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java26
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/pom.xml2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java27
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptHandler.java21
7 files changed, 67 insertions, 15 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.structures/META-INF/MANIFEST.MF b/systemtap/org.eclipse.linuxtools.systemtap.structures/META-INF/MANIFEST.MF
index c730b73dfd..0750b4f4f1 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.structures/META-INF/MANIFEST.MF
+++ b/systemtap/org.eclipse.linuxtools.systemtap.structures/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.linuxtools.systemtap.structures;singleton:=true
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Vendor: %bundleProvider
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.linuxtools.systemtap.structures,
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.structures/pom.xml b/systemtap/org.eclipse.linuxtools.systemtap.structures/pom.xml
index b4c55249c7..90ba5b7615 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.structures/pom.xml
+++ b/systemtap/org.eclipse.linuxtools.systemtap.structures/pom.xml
@@ -18,7 +18,7 @@
</parent>
<artifactId>org.eclipse.linuxtools.systemtap.structures</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools Structures Plug-in</name>
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java
index e38891c8b5..d1bb69c87a 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java
@@ -17,13 +17,14 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.linuxtools.internal.systemtap.structures.StructuresPlugin;
import org.eclipse.linuxtools.systemtap.structures.LoggingStreamDaemon;
import org.eclipse.linuxtools.systemtap.structures.listeners.IGobblerListener;
-import org.eclipse.linuxtools.systemtap.structures.process.SystemtapProcessFactory;
+import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
@@ -62,7 +63,11 @@ public class Command implements Runnable {
private String[] cmd;
private String[] envVars;
protected Process process;
- private LoggingStreamDaemon logger;
+ /**
+ * @since 2.1
+ */
+ protected IProject project = null;
+ private final LoggingStreamDaemon logger;
public static final int ERROR_STREAM = 0;
public static final int INPUT_STREAM = 1;
@@ -77,6 +82,20 @@ public class Command implements Runnable {
* @since 2.0
*/
public Command(String[] cmd, String[] envVars) {
+ this(cmd, envVars, null);
+ }
+
+ /**
+ * Spawns the new thread that this class will run in. From the Runnable
+ * interface spawning the new thread automatically calls the run() method.
+ * This must be called by the implementing class in order to start the
+ * StreamGobbler.
+ * @param cmd The entire command to run
+ * @param envVars List of all environment variables to use
+ * @param project The project this script belongs to or null
+ * @since 2.1
+ */
+ public Command(String[] cmd, String[] envVars, IProject project) {
if (cmd != null) {
this.cmd = Arrays.copyOf(cmd, cmd.length);
}
@@ -84,6 +103,7 @@ public class Command implements Runnable {
if (envVars != null) {
this.envVars = Arrays.copyOf(envVars, envVars.length);
}
+ this.project = project;
logger = new LoggingStreamDaemon();
addInputStreamListener(logger);
}
@@ -112,7 +132,7 @@ public class Command implements Runnable {
*/
protected IStatus init() {
try {
- process = SystemtapProcessFactory.exec(cmd, envVars);
+ process = RuntimeProcessFactory.getFactory().exec(cmd, envVars, project);
if (process == null){
return new Status(IStatus.ERROR, StructuresPlugin.PLUGIN_ID, Messages.Command_failedToRunSystemtap);
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF
index 1a7f81c7b6..67876f68f6 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.linuxtools.systemtap.ui.consolelog;singleton:=true
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Activator: org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin
Bundle-Vendor: %bundleProvider
Bundle-Localization: plugin
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/pom.xml b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/pom.xml
index aabf938004..2aa87649a3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/pom.xml
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/pom.xml
@@ -17,7 +17,7 @@
</parent>
<artifactId>org.eclipse.linuxtools.systemtap.ui.consolelog</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools SystemTap ConsoleLog Plug-in</name>
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java
index 2bd6c51a83..3a1dfd2710 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java
@@ -15,6 +15,7 @@ import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -81,7 +82,7 @@ public class ScriptConsole extends IOConsole {
public void runningStateChanged(boolean running);
}
- private LinkedList<ScriptConsoleObserver> activeConsoleObservers
+ private final LinkedList<ScriptConsoleObserver> activeConsoleObservers
= new LinkedList<ScriptConsoleObserver>();
/**
@@ -209,8 +210,8 @@ public class ScriptConsole extends IOConsole {
cmd = new ScpExec(command);
this.stopCommand = new Runnable() {
- private Command stopcmd = cmd;
- private String stopString = getStopString();
+ private final Command stopcmd = cmd;
+ private final String stopString = getStopString();
@Override
public void run() {
@@ -241,21 +242,35 @@ public class ScriptConsole extends IOConsole {
* @since 2.0
*/
public void runLocally(String[] command, String[] envVars, IErrorParser errorParser) {
+ runLocally(command, envVars, errorParser, null);
+ }
+
+ /**
+ * Runs the provided command in this ScriptConsole instance on the current
+ * host.
+ * @param command The command and arguments to run.
+ * @param envVars The environment variables to use while running
+ * @param errorParser The parser to handle error messages generated by the command
+ * @param project The project that command belongs to or null
+ * @since 2.1
+ */
+ public void runLocally(String[] command, String[] envVars, IErrorParser errorParser, IProject project) {
// Don't start a new command if one is already waiting to be started.
if (onCmdStartThread != null && onCmdStartThread.isAlive()) {
return;
}
- cmd = new Command(command, envVars);
+ cmd = new Command(command, envVars, project);
+ final IProject proj = project;
this.stopCommand = new Runnable() {
- private Command stopcmd = cmd;
+ private final Command stopcmd = cmd;
String stopString = getStopString();
@Override
public void run() {
try {
do {
- RuntimeProcessFactory.getFactory().exec(stopString, null, null);
+ RuntimeProcessFactory.getFactory().exec(stopString, null, proj);
synchronized (stopcmd) {
stopcmd.wait(RETRY_STOP_TIME);
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptHandler.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptHandler.java
index 3d7b8f81eb..9db6ab0edf 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptHandler.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptHandler.java
@@ -14,6 +14,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.net.URI;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
@@ -23,6 +24,10 @@ import java.util.regex.Pattern;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -77,7 +82,8 @@ public class RunScriptHandler extends AbstractHandler {
private String tmpfileName = null;
private String serverfileName = null;
private IPath path;
- private List<String> cmdList;
+ private IProject project;
+ private final List<String> cmdList;
public RunScriptHandler(){
@@ -89,6 +95,17 @@ public class RunScriptHandler extends AbstractHandler {
*/
public void setPath(IPath path){
this.path = path;
+ URI uri = URIUtil.toURI(path);
+ IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri);
+ if (files.length > 0)
+ this.project = files[0].getProject();
+ }
+
+ /**
+ * @since 2.1
+ */
+ public IProject getProject() {
+ return project;
}
/**
@@ -178,7 +195,7 @@ public class RunScriptHandler extends AbstractHandler {
console.run(script, envVars, new StapErrorParser());
} else {
console = ScriptConsole.getInstance(fileName);
- console.runLocally(script, envVars, new StapErrorParser());
+ console.runLocally(script, envVars, new StapErrorParser(), getProject());
}
scriptConsoleInitialized(console);
}

Back to the top