Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-06-12 19:15:48 +0000
committerAlexander Kurtakov2014-07-28 08:20:43 +0000
commit754beff64a40d6ae465cbaee19f7107a77bcc2b7 (patch)
tree33c45124c67c7e4b0bb0f21ffa477e7f4922faef /systemtap
parent789298c66263ddb219c26785ddf0e3c9bcc45131 (diff)
downloadorg.eclipse.linuxtools-754beff64a40d6ae465cbaee19f7107a77bcc2b7.tar.gz
org.eclipse.linuxtools-754beff64a40d6ae465cbaee19f7107a77bcc2b7.tar.xz
org.eclipse.linuxtools-754beff64a40d6ae465cbaee19f7107a77bcc2b7.zip
Man: Add support for remote manpages.
Allow for fetching manpages of executables from a remote machine. Also add Linuxtools support for launching remote processes to make this possible. Change-Id: I69b840b2a15d6268ff5d1a42642ff0176646c354 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/29064 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'systemtap')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java57
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java7
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java28
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java4
5 files changed, 42 insertions, 58 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java
index 80536bb279..22587105f2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java
@@ -13,22 +13,17 @@ package org.eclipse.linuxtools.systemtap.structures.process;
import java.io.OutputStream;
+import org.eclipse.linuxtools.tools.launch.core.factory.LinuxtoolsProcessFactory;
+
import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
/**
- * The {@link SystemtapProcessFactory} is responsible for creating process
- * objects.
- * When executing systemtap operations you must always use this factory so that
- * mock objects can be provided during testing.
+ * @deprecated Use {@link LinuxtoolsProcessFactory} instead.
*/
+@Deprecated
public class SystemtapProcessFactory {
- private static final int DEFAULT_PORT = 22;
-
/**
* Runs stap with the given arguments on the given host using the given
* credentials.
@@ -42,7 +37,7 @@ public class SystemtapProcessFactory {
public static Channel execRemote(String[] args,
OutputStream out, OutputStream err, String user, String host,
String password) throws JSchException {
- return execRemote(args, out, err, user, host, password, DEFAULT_PORT, null);
+ return LinuxtoolsProcessFactory.execRemote(args, out, err, user, host, password);
}
/**
@@ -61,32 +56,7 @@ public class SystemtapProcessFactory {
public static Channel execRemote(String[] args, OutputStream out,
OutputStream err, String user, String host, String password, int port, String[] envp)
throws JSchException {
- JSch jsch = new JSch();
- Session session = jsch.getSession(user, host, port);
- session.setPassword(password);
- java.util.Properties config = new java.util.Properties();
- config.put("StrictHostKeyChecking", "no"); //$NON-NLS-1$//$NON-NLS-2$
- session.setConfig(config);
- session.connect();
-
- StringBuilder command = new StringBuilder();
- if (envp != null) {
- for (String var : envp) {
- command.append(String.format("export %s; ", var)); //$NON-NLS-1$
- }
- }
- for (int i = 0; i < args.length; i++) {
- command.append(args[i] + ' ');
- }
-
- ChannelExec channel = (ChannelExec) session.openChannel("exec"); //$NON-NLS-1$
- channel.setCommand(command.toString());
- channel.setInputStream(null, true);
- channel.setOutputStream(out, true);
- channel.setExtOutputStream(err, true);
- channel.connect();
-
- return channel;
+ return LinuxtoolsProcessFactory.execRemote(args, out, err, user, host, password, port, envp);
}
/**
@@ -102,7 +72,7 @@ public class SystemtapProcessFactory {
public static Channel execRemoteAndWait(String[] args,
OutputStream out, OutputStream err, String user, String host,
String password) throws JSchException {
- return execRemote(args, out, err, user, host, password, DEFAULT_PORT, null);
+ return LinuxtoolsProcessFactory.execRemoteAndWait(args, out, err, user, host, password);
}
/**
@@ -121,17 +91,6 @@ public class SystemtapProcessFactory {
public static Channel execRemoteAndWait(String[] args, OutputStream out,
OutputStream err, String user, String host, String password, int port, String[] envp)
throws JSchException {
- Channel channel = execRemote(args, out, err, user, host, password, port, envp);
-
- while (!channel.isClosed()) {
- try {
- Thread.sleep(250);
- } catch (InterruptedException e) {
- // Thread was interrupted just return.
- return channel;
- }
- }
-
- return channel;
+ return LinuxtoolsProcessFactory.execRemoteAndWait(args, out, err, user, host, password, port, envp);
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java
index a8994f4550..0c5ed7636f 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java
@@ -16,11 +16,11 @@ import java.io.IOException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog;
-import org.eclipse.linuxtools.systemtap.structures.process.SystemtapProcessFactory;
import org.eclipse.linuxtools.systemtap.structures.runnable.Command;
import org.eclipse.linuxtools.systemtap.structures.runnable.StreamGobbler;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.RemoteScriptOptions;
+import org.eclipse.linuxtools.tools.launch.core.factory.LinuxtoolsProcessFactory;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSchException;
@@ -43,7 +43,7 @@ public class ScpExec extends Command {
@Override
protected IStatus init() {
try {
- channel = SystemtapProcessFactory.execRemote(
+ channel = LinuxtoolsProcessFactory.execRemote(
cmd, System.out, System.err,
remoteOptions.userName, remoteOptions.hostName, remoteOptions.password, remoteOptions.port,
envVars);
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
index b7b5638db8..80ef43c8a8 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
@@ -367,7 +367,12 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
return true;
}
- return c != '.' && Pattern.matches("\\W", Character.toString(c)); //$NON-NLS-1$
+ switch (c) {
+ case '.':
+ case '$':
+ return false;
+ }
+ return Pattern.matches("\\W", Character.toString(c)); //$NON-NLS-1$
}
public void waitForInitialization() {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java
index 22bb5a8cf8..d95115a9aa 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java
@@ -13,15 +13,24 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
import java.util.HashMap;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
import org.eclipse.linuxtools.man.parser.ManPage;
+import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
+import org.eclipse.linuxtools.systemtap.ui.consolelog.preferences.ConsoleLogPreferenceConstants;
public class ManpageCacher {
private static final String SPLITTER = "::"; //$NON-NLS-1$
- private static final String NO_MAN_ENTRY = "No manual entry for"; //$NON-NLS-1$
+ private static final String NO_MAN_ENTRY = "No manual entry for "; //$NON-NLS-1$
private static HashMap<String, String> pages = new HashMap<>();
public static boolean isEmptyDocumentation(String documentation) {
- return documentation != null && documentation.startsWith(ManpageCacher.NO_MAN_ENTRY);
+ return documentation != null && documentation.startsWith(NO_MAN_ENTRY);
+ }
+
+ private static String makeEmptyDocumentation(String element) {
+ return NO_MAN_ENTRY + element;
}
public static synchronized void clear() {
@@ -41,14 +50,25 @@ public class ManpageCacher {
getDocumentation(TapsetItemType.PROBE, elements[0]);
documentation = pages.get(fullElement);
if (documentation == null) {
- documentation = ManpageCacher.NO_MAN_ENTRY + " " + fullElement; //$NON-NLS-1$
+ documentation = makeEmptyDocumentation(fullElement);
pages.put(fullElement, documentation);
}
return documentation;
}
// Otherwise, get the documentation for the requested element.
- documentation = (new ManPage(fullElement)).getStrippedTextPage().toString();
+ IPreferenceStore p = IDEPlugin.getDefault().getPreferenceStore();
+ ManPage manpage = null;
+ if (!p.getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES)) {
+ manpage = new ManPage(fullElement);
+ } else {
+ p = ConsoleLogPlugin.getDefault().getPreferenceStore();
+ String user = p.getString(ConsoleLogPreferenceConstants.SCP_USER);
+ String host = p.getString(ConsoleLogPreferenceConstants.HOST_NAME);
+ String password = p.getString(ConsoleLogPreferenceConstants.SCP_PASSWORD);
+ manpage = new ManPage(fullElement, user, host, password);
+ }
+ documentation = manpage.getStrippedTextPage().toString();
pages.put(fullElement, documentation);
// If the requested element is a probe and a documentation page was
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
index 52ffe37f49..59b73dbeab 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
@@ -23,10 +23,10 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.StringOutputStream;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.EnvironmentVariablesPreferencePage;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
-import org.eclipse.linuxtools.systemtap.structures.process.SystemtapProcessFactory;
import org.eclipse.linuxtools.systemtap.structures.runnable.StringStreamGobbler;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.linuxtools.systemtap.ui.consolelog.preferences.ConsoleLogPreferenceConstants;
+import org.eclipse.linuxtools.tools.launch.core.factory.LinuxtoolsProcessFactory;
import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
@@ -173,7 +173,7 @@ public abstract class TapsetParser extends Job {
String password = p.getString(ConsoleLogPreferenceConstants.SCP_PASSWORD);
int port = p.getInt(ConsoleLogPreferenceConstants.PORT_NUMBER);
- Channel channel = SystemtapProcessFactory.execRemoteAndWait(args, str, strErr, user, host, password,
+ Channel channel = LinuxtoolsProcessFactory.execRemoteAndWait(args, str, strErr, user, host, password,
port, EnvironmentVariablesPreferencePage.getEnvironmentVariables());
if (channel == null) {
displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);

Back to the top