Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-05-12 20:29:49 +0000
committerAlexander Kurtakov2014-05-15 12:33:23 +0000
commit12a16448f7323d5914863c08e5544850eaa5877f (patch)
tree64b2abdd8b1771fdc4d8ed7b2b4c916a4ffab21c /systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse
parent1ced4e4ad3e1bf8f2d352e90c6ea0f06a2967547 (diff)
downloadorg.eclipse.linuxtools-12a16448f7323d5914863c08e5544850eaa5877f.tar.gz
org.eclipse.linuxtools-12a16448f7323d5914863c08e5544850eaa5877f.tar.xz
org.eclipse.linuxtools-12a16448f7323d5914863c08e5544850eaa5877f.zip
Systemtap: Improvements to remote operations.
-Resolve EBZ #433422. -Apply environment variables passed to remote runs. -Restore option to specify port number for remote operations. -Improve some error dialogs relating to failed remote connections/runs. -Cleanup, syntax standardization, and removal of unused modules/preferences. Change-Id: I6f18afaa97efb3f4196261dff51b55454b6e3ee1 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/26406 Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java6
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java7
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java130
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties6
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java12
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java132
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties2
9 files changed, 208 insertions, 91 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java
index fad891dbbc..bf9eeea4c0 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java
@@ -97,8 +97,12 @@ public class IDEPlugin extends AbstractUIPlugin {
if (path == null) {
path = ""; //$NON-NLS-1$
}
+ int port = p.getInt(ConsoleLogPreferenceConstants.PORT_NUMBER);
+ if (port == 0) {
+ port = p.getDefaultInt(ConsoleLogPreferenceConstants.PORT_NUMBER);
+ }
try {
- return new URI("ssh", user, host, -1, path, null, null); //$NON-NLS-1$
+ return new URI("ssh", user, host, port, path, null, null); //$NON-NLS-1$
} catch (URISyntaxException uri) {
return null;
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java
index ca6b379793..e154788ef8 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java
@@ -74,6 +74,8 @@ public class Messages extends NLS {
public static String SystemTapScriptLaunchConfigurationTab_password;
public static String SystemTapScriptLaunchConfigurationTab_user;
public static String SystemTapScriptLaunchConfigurationTab_host;
+ public static String SystemTapScriptLaunchConfigurationTab_useDefaultPort;
+ public static String SystemTapScriptLaunchConfigurationTab_port;
public static String SystemTapScriptLaunchConfigurationTab_runLocally;
public static String SystemTapScriptLaunchConfigurationTab_hostname;
public static String SystemTapScriptLaunchConfigurationTab_general;
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
index c3eb692257..03b9130e81 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
@@ -44,7 +44,8 @@ import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.RemoteScriptOpt
public class SystemTapScriptLaunchConfigurationDelegate extends
LaunchConfigurationDelegate {
- private static String LOCALHOST = "localhost"; //$NON-NLS-1$
+ static final String LOCALHOST = "localhost"; //$NON-NLS-1$
+ static final int DEFAULT_PORT = 22;
static final String CONFIGURATION_TYPE = "org.eclipse.linuxtools.systemtap.ui.ide.SystemTapLaunchConfigurationType"; //$NON-NLS-1$
private IProject[] scriptProject;
@@ -139,7 +140,9 @@ public class SystemTapScriptLaunchConfigurationDelegate extends
configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USER_NAME_ATTR, ""), //$NON-NLS-1$
configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USER_PASS_ATTR, ""), //$NON-NLS-1$
configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.LOCAL_HOST_ATTR, true) ? LOCALHOST :
- configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.HOST_NAME_ATTR, LOCALHOST)));
+ configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.HOST_NAME_ATTR, LOCALHOST),
+ configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USE_DEFAULT_PORT_ATTR, true) ? DEFAULT_PORT :
+ configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.PORT_ATTR, DEFAULT_PORT)));
String value = configuration.getAttribute(IDEPreferenceConstants.STAP_CMD_OPTION[IDEPreferenceConstants.KEY], ""); //$NON-NLS-1$
if (!value.isEmpty()) {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java
index 8c612f2a88..e57aefe74a 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java
@@ -32,6 +32,8 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -56,19 +58,42 @@ public class SystemTapScriptLaunchConfigurationTab extends
static final String USER_PASS_ATTR = "userPassword"; //$NON-NLS-1$
static final String LOCAL_HOST_ATTR = "executeOnLocalHost"; //$NON-NLS-1$
static final String HOST_NAME_ATTR = "hostName"; //$NON-NLS-1$
+ static final String PORT_ATTR = "port"; //$NON-NLS-1$
+ static final String USE_DEFAULT_PORT_ATTR = "useDefaultPort"; //$NON-NLS-1$
private Text scriptPathText;
private Button currentUserCheckButton;
private Text userNameText;
+ private Label userNameLabel;
private Text userPasswordText;
+ private Label userPasswordLabel;
private Button localHostCheckButton;
private Group hostSettingsGroup;
private Text hostNameText;
- private Label userNameLabel;
- private Label userPasswordLabel;
- private Label hostNamelabel;
+ private Label hostNameLabel;
+ private Text portText;
+ private Label portLabel;
+ private Button portCheckButton;
private FileDialog fileDialog;
+ SelectionListener checkListener = new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ update();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ update();
+ }
+
+ private void update() {
+ updateLaunchConfigurationDialog();
+ }
+
+ };
+
/**
* @return The path of the chosen script the Run Configuration will be applied to,
* or <code>null</code> if no file exists at the given path.
@@ -81,7 +106,7 @@ public class SystemTapScriptLaunchConfigurationTab extends
@Override
public void createControl(Composite parent) {
- this.fileDialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
+ fileDialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
fileDialog.setText(Messages.SystemTapScriptLaunchConfigurationTab_selectScript);
fileDialog.setFilterPath(Platform.getLocation().toOSString());
@@ -98,7 +123,7 @@ public class SystemTapScriptLaunchConfigurationTab extends
layout = new GridLayout();
layout.numColumns = 2;
scriptSettingsGroup.setLayout(layout);
- this.scriptPathText = new Text(scriptSettingsGroup, SWT.SINGLE | SWT.BORDER);
+ scriptPathText = new Text(scriptSettingsGroup, SWT.SINGLE | SWT.BORDER);
scriptPathText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scriptPathText.addModifyListener(new ModifyListener() {
@Override
@@ -133,44 +158,27 @@ public class SystemTapScriptLaunchConfigurationTab extends
layout.numColumns = 2;
userSettingsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- this.currentUserCheckButton = new Button(userSettingsGroup, SWT.CHECK);
+ currentUserCheckButton = new Button(userSettingsGroup, SWT.CHECK);
currentUserCheckButton.setText(Messages.SystemTapScriptLaunchConfigurationTab_currentUser);
currentUserCheckButton.setSelection(true);
gridData = new GridData();
gridData.horizontalSpan = 2;
currentUserCheckButton.setLayoutData(gridData);
+ currentUserCheckButton.addSelectionListener(checkListener);
- this.userNameLabel = new Label(userSettingsGroup, SWT.NONE);
+ userNameLabel = new Label(userSettingsGroup, SWT.NONE);
userNameLabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_username);
- this.userNameText = new Text(userSettingsGroup, SWT.SINGLE | SWT.BORDER);
+ userNameText = new Text(userSettingsGroup, SWT.SINGLE | SWT.BORDER);
userNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- this.userPasswordLabel = new Label(userSettingsGroup, SWT.NONE);
+ userPasswordLabel = new Label(userSettingsGroup, SWT.NONE);
userPasswordLabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_password);
- this.userPasswordText = new Text(userSettingsGroup, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
+ userPasswordText = new Text(userSettingsGroup, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
userPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
userSettingsGroup.setLayoutData( new GridData(SWT.FILL, SWT.FILL, true, false));
userSettingsGroup.setText(Messages.SystemTapScriptLaunchConfigurationTab_user);
- currentUserCheckButton.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- update();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- update();
- }
-
- private void update() {
- boolean enable = !currentUserCheckButton.getSelection();
- setUserGroupEnablement(enable);
- updateLaunchConfigurationDialog();
- }
- });
-
userNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
@@ -193,32 +201,51 @@ public class SystemTapScriptLaunchConfigurationTab extends
hostSettingsGroup.setLayout(layout);
layout.numColumns = 2;
- this.localHostCheckButton = new Button(hostSettingsGroup, SWT.CHECK);
+ localHostCheckButton = new Button(hostSettingsGroup, SWT.CHECK);
localHostCheckButton.setText(Messages.SystemTapScriptLaunchConfigurationTab_runLocally);
gridData = new GridData();
gridData.horizontalSpan = 2;
- this.hostNamelabel = new Label(hostSettingsGroup, SWT.NONE);
- hostNamelabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_hostname);
- this.hostNameText = new Text(hostSettingsGroup, SWT.SINGLE | SWT.BORDER);
+ hostNameLabel = new Label(hostSettingsGroup, SWT.NONE);
+ hostNameLabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_hostname);
+ hostNameText = new Text(hostSettingsGroup, SWT.SINGLE | SWT.BORDER);
hostNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
localHostCheckButton.setLayoutData(gridData);
- localHostCheckButton.addSelectionListener(new SelectionListener() {
+ localHostCheckButton.addSelectionListener(checkListener);
+ hostNameText.addModifyListener(new ModifyListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
- update();
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
}
+ });
+ portCheckButton = new Button(hostSettingsGroup, SWT.CHECK);
+ portCheckButton.setText(Messages.SystemTapScriptLaunchConfigurationTab_useDefaultPort);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ portCheckButton.setLayoutData(gridData);
+ portCheckButton.addSelectionListener(checkListener);
+
+ portLabel = new Label(hostSettingsGroup, SWT.NONE);
+ portLabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_port);
+ portText = new Text(hostSettingsGroup, SWT.SINGLE | SWT.BORDER);
+ portText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ portText.setTextLimit(5);
+ portText.addVerifyListener(new VerifyListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {
- update();
- }
-
- private void update() {
- updateLaunchConfigurationDialog();
+ public void verifyText(VerifyEvent e) {
+ if (e.keyCode == SWT.BS) {
+ return;
+ }
+ for (int i = 0, n = e.text.length(); i < n; i++) {
+ if (!Character.isDigit(e.text.charAt(i))) {
+ e.doit = false;
+ return;
+ }
+ }
}
});
- hostNameText.addModifyListener(new ModifyListener() {
+ portText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateLaunchConfigurationDialog();
@@ -237,18 +264,26 @@ public class SystemTapScriptLaunchConfigurationTab extends
}
private void setHostGroupEnablement(boolean enable) {
- hostNamelabel.setEnabled(enable);
hostNameText.setEnabled(enable);
+ hostNameLabel.setEnabled(enable);
+ portCheckButton.setEnabled(enable);
+
+ boolean portEnabled = enable && !portCheckButton.getSelection();
+ portText.setEnabled(portEnabled);
+ portLabel.setEnabled(portEnabled);
}
@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(SCRIPT_PATH_ATTR, this.getSelectedScriptPath());
+ configuration.setAttribute(SCRIPT_PATH_ATTR, getSelectedScriptPath());
configuration.setAttribute(CURRENT_USER_ATTR, true);
configuration.setAttribute(USER_NAME_ATTR, ""); //$NON-NLS-1$
configuration.setAttribute(USER_PASS_ATTR, ""); //$NON-NLS-1$
configuration.setAttribute(LOCAL_HOST_ATTR, true);
configuration.setAttribute(HOST_NAME_ATTR, ""); //$NON-NLS-1$
+ configuration.setAttribute(PORT_ATTR,
+ SystemTapScriptLaunchConfigurationDelegate.DEFAULT_PORT);
+ configuration.setAttribute(USE_DEFAULT_PORT_ATTR, true);
}
@Override
@@ -260,6 +295,9 @@ public class SystemTapScriptLaunchConfigurationTab extends
this.userPasswordText.setText(configuration.getAttribute(USER_PASS_ATTR, "")); //$NON-NLS-1$
this.localHostCheckButton.setSelection(configuration.getAttribute(LOCAL_HOST_ATTR, true));
this.hostNameText.setText(configuration.getAttribute(HOST_NAME_ATTR, "")); //$NON-NLS-1$
+ this.portText.setText(Integer.toString(configuration.getAttribute(PORT_ATTR,
+ SystemTapScriptLaunchConfigurationDelegate.DEFAULT_PORT)));
+ this.portCheckButton.setSelection(configuration.getAttribute(USE_DEFAULT_PORT_ATTR, true));
} catch (CoreException e) {
ExceptionErrorDialog.openError(Messages.SystemTapScriptLaunchConfigurationTab_errorInitializingTab, e);
}
@@ -274,6 +312,10 @@ public class SystemTapScriptLaunchConfigurationTab extends
configuration.setAttribute(LOCAL_HOST_ATTR, this.localHostCheckButton.getSelection());
configuration.setAttribute(HOST_NAME_ATTR, this.hostNameText.getText());
+ configuration.setAttribute(USE_DEFAULT_PORT_ATTR, portCheckButton.getSelection());
+ String portString = this.portText.getText();
+ configuration.setAttribute(PORT_ATTR, !portString.isEmpty() ? Integer.valueOf(portString) : 0);
+
boolean enable = !currentUserCheckButton.getSelection();
setUserGroupEnablement(enable);
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties
index 7333366dd4..c24a7b7c1d 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties
@@ -65,13 +65,15 @@ SystemTapScriptGraphOptionsTab_generateFromPrintsEmpty=No valid printf statement
SystemTapScriptLaunchConfigurationTab_script=Systemtap Script:
SystemTapScriptLaunchConfigurationTab_browse=Browse...
-SystemTapScriptLaunchConfigurationTab_currentUser=Execute script as current user.
+SystemTapScriptLaunchConfigurationTab_currentUser=Execute script as current user
SystemTapScriptLaunchConfigurationTab_username=User Name:
SystemTapScriptLaunchConfigurationTab_password=Password:
SystemTapScriptLaunchConfigurationTab_user=User:
SystemTapScriptLaunchConfigurationTab_host=Host:
-SystemTapScriptLaunchConfigurationTab_runLocally=Run script on localhost.
+SystemTapScriptLaunchConfigurationTab_runLocally=Run script on localhost
SystemTapScriptLaunchConfigurationTab_hostname=Host Name:
+SystemTapScriptLaunchConfigurationTab_useDefaultPort=Use default port
+SystemTapScriptLaunchConfigurationTab_port=Port:
SystemTapScriptLaunchConfigurationTab_general=General
SystemTapScriptLaunchConfigurationTab_tabName=Systemtap
SystemTapScriptLaunchConfigurationTab_selectScript=Select Systemtap Script
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
index 8dd1c6f218..e24af415b0 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
@@ -23,6 +23,8 @@ public class Messages extends NLS {
public static String TapsetParser_CannotRunStapMessage;
public static String TapsetParser_CannotRunStapTitle;
public static String TapsetParser_ErrorRunningSystemtap;
+ public static String TapsetParser_RemoteCredentialErrorTitle;
+ public static String TapsetParser_RemoteCredentialErrorMessage;
public static String SharedParser_NoOutput;
static {
// initialize resource bundle
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
index 77e446c6bb..833722a394 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
@@ -29,6 +29,7 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.PreferenceCo
import org.eclipse.linuxtools.man.parser.ManPage;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener;
+import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -141,6 +142,7 @@ public final class TapsetLibrary {
private static void init() {
IPreferenceStore preferenceStore = IDEPlugin.getDefault().getPreferenceStore();
preferenceStore.addPropertyChangeListener(propertyChangeListener);
+ ConsoleLogPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(credentialChangeListener);
functionParser.addListener(functionCompletionListener);
probeParser.addListener(probeCompletionListener);
@@ -158,7 +160,8 @@ public final class TapsetLibrary {
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
if (property.equals(IDEPreferenceConstants.P_TAPSETS)
- || property.equals(PreferenceConstants.P_ENV.SYSTEMTAP_TAPSET.toPrefKey())) {
+ || property.equals(PreferenceConstants.P_ENV.SYSTEMTAP_TAPSET.toPrefKey())
+ || property.equals(IDEPreferenceConstants.P_REMOTE_PROBES)) {
runStapParser();
} else if (property.equals(IDEPreferenceConstants.P_STORED_TREE)) {
if (event.getNewValue().equals(false)) {
@@ -173,6 +176,13 @@ public final class TapsetLibrary {
}
};
+ private static final IPropertyChangeListener credentialChangeListener = new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ runStapParser();
+ }
+ };
+
private static class ParseCompletionListener implements IUpdateListener {
TreeTapsetParser parser;
public ParseCompletionListener(TreeTapsetParser parser) {
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 62812afb8b..b25dcbf081 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
@@ -13,6 +13,7 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
import java.io.File;
import java.io.IOException;
+import java.net.ConnectException;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -31,9 +32,13 @@ 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.RuntimeProcessFactory;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSchException;
@@ -52,6 +57,7 @@ import com.jcraft.jsch.JSchException;
public abstract class TapsetParser extends Job {
private static AtomicBoolean displayingError = new AtomicBoolean(false);
+ private static AtomicBoolean displayingCredentialDialog = new AtomicBoolean(false);
private ArrayList<IUpdateListener> listeners = new ArrayList<>();
private boolean cancelRequested = false;
@@ -135,6 +141,7 @@ public abstract class TapsetParser extends Job {
.getString(IDEPreferenceConstants.P_TAPSETS).split(File.pathSeparator);
boolean noTapsets = tapsets[0].trim().isEmpty();
boolean noOptions = options[0].trim().isEmpty();
+ final boolean remote = IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES);
int size = probe != null ? 2 : 1;
if (!noTapsets) {
@@ -147,7 +154,8 @@ public abstract class TapsetParser extends Job {
args = new String[size];
args[0] = "stap"; //$NON-NLS-1$
if (probe != null) {
- args[size-1] = probe;
+ // Workaround for the fact that remote & local execution methods use string args differently
+ args[size - 1] = !remote ? probe : '\'' + probe + '\'';
}
//Add extra tapset directories
@@ -158,53 +166,18 @@ public abstract class TapsetParser extends Job {
}
}
if (!noOptions) {
- for (int i = 0, s = noTapsets ? 1 : 1 + tapsets.length*2; i<options.length; i++) {
+ for (int i = 0, s = noTapsets ? 1 : 1 + tapsets.length*2; i < options.length; i++) {
args[s + i] = options[i];
}
}
try {
- if (IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES)) {
- StringOutputStream str = new StringOutputStream();
- StringOutputStream strErr = new StringOutputStream();
-
- IPreferenceStore 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);
-
- Channel channel = SystemtapProcessFactory.execRemoteAndWait(args, str, strErr, user, host, password);
- if (channel == null) {
- displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);
- }
-
- return (!getErrors ? str : strErr).toString();
+ if (!remote) {
+ return runLocalStap(args, getErrors);
} else {
- Process process = RuntimeProcessFactory.getFactory().exec(
- args, EnvironmentVariablesPreferencePage.getEnvironmentVariables(), null);
- if (process == null) {
- displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);
- return null;
- }
-
- StringStreamGobbler gobbler = new StringStreamGobbler(process.getInputStream());
- StringStreamGobbler egobbler = null;
- gobbler.start();
- if (getErrors) {
- egobbler = new StringStreamGobbler(process.getErrorStream());
- egobbler.start();
- }
- process.waitFor();
- gobbler.stop();
- if (egobbler == null) {
- return gobbler.getOutput().toString();
- } else {
- egobbler.stop();
- return egobbler.getOutput().toString();
- }
+ return runRemoteStapAttempt(args, getErrors);
}
-
- } catch (JSchException|IOException e) {
+ } catch (IOException e) {
displayError(Messages.TapsetParser_ErrorRunningSystemtap, e.getMessage());
} catch (InterruptedException e) {
// Interrupted; exit.
@@ -213,6 +186,83 @@ public abstract class TapsetParser extends Job {
return null;
}
+ private String runLocalStap(String[] args, boolean getErrors) throws IOException, InterruptedException {
+ Process process = RuntimeProcessFactory.getFactory().exec(
+ args, EnvironmentVariablesPreferencePage.getEnvironmentVariables(), null);
+ if (process == null) {
+ displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);
+ return null;
+ }
+
+ StringStreamGobbler gobbler = new StringStreamGobbler(process.getInputStream());
+ StringStreamGobbler egobbler = null;
+ gobbler.start();
+ if (getErrors) {
+ egobbler = new StringStreamGobbler(process.getErrorStream());
+ egobbler.start();
+ }
+ process.waitFor();
+ gobbler.stop();
+ if (egobbler == null) {
+ return gobbler.getOutput().toString();
+ } else {
+ egobbler.stop();
+ return egobbler.getOutput().toString();
+ }
+ }
+
+ private String runRemoteStapAttempt(String[] args, boolean getErrors) {
+ int attemptsLeft = 3;
+ while (true) {
+ try {
+ return runRemoteStap(args, getErrors);
+ } catch (JSchException e) {
+ if (!(e.getCause() instanceof ConnectException) || --attemptsLeft == 0) {
+ askIfEditCredentials();
+ return null;
+ }
+ }
+ }
+ }
+
+ private String runRemoteStap(String[] args, boolean getErrors) throws JSchException {
+ StringOutputStream str = new StringOutputStream();
+ StringOutputStream strErr = new StringOutputStream();
+
+ IPreferenceStore 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);
+ int port = p.getInt(ConsoleLogPreferenceConstants.PORT_NUMBER);
+
+ Channel channel = SystemtapProcessFactory.execRemoteAndWait(args, str, strErr, user, host, password,
+ port, EnvironmentVariablesPreferencePage.getEnvironmentVariables());
+ if (channel == null) {
+ displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);
+ }
+
+ return (!getErrors ? str : strErr).toString();
+ }
+
+ private void askIfEditCredentials() {
+ if (displayingCredentialDialog.compareAndSet(false, true)) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ dialog.setText(Messages.TapsetParser_RemoteCredentialErrorTitle);
+ dialog.setMessage(Messages.TapsetParser_RemoteCredentialErrorMessage);
+ if (dialog.open() == SWT.YES) {
+ String pageID = "org.eclipse.linuxtools.systemtap.prefs.consoleLog"; //$NON-NLS-1$
+ PreferencesUtil.createPreferenceDialogOn(shell, pageID, new String[]{pageID}, null).open();
+ }
+ displayingCredentialDialog.set(false);
+ }
+ });
+ }
+ }
+
private void displayError(final String title, final String error) {
if (displayingError.compareAndSet(false, true)) {
Display.getDefault().asyncExec(new Runnable() {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
index 1b53522a4b..dbe41099f2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
@@ -15,4 +15,6 @@ ProbeParser_aliasProbes=Probe Aliases
TapsetParser_CannotRunStapMessage=Make sure SystemTap is installed.
TapsetParser_CannotRunStapTitle=Cannot Run SystemTap
TapsetParser_ErrorRunningSystemtap=Error Running SystemTap
+TapsetParser_RemoteCredentialErrorTitle=Remote Login Error
+TapsetParser_RemoteCredentialErrorMessage=Unable to login to the remote host for loading tapset contents. Edit the login credentials now?
SharedParser_NoOutput=No stap output was generated \ No newline at end of file

Back to the top