Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2013-11-27 16:30:23 -0500
committerAndrew Ferrazzutti2013-12-02 15:28:12 -0500
commitf130cacb2e3c98e89ec8570d31d8840eadb7937f (patch)
tree3abae57a52b45d0a826d2fd25322b35e89b2631f
parent154026ee2a278c8491d6b78a017182426192f15f (diff)
downloadorg.eclipse.linuxtools-f130cacb2e3c98e89ec8570d31d8840eadb7937f.tar.gz
org.eclipse.linuxtools-f130cacb2e3c98e89ec8570d31d8840eadb7937f.tar.xz
org.eclipse.linuxtools-f130cacb2e3c98e89ec8570d31d8840eadb7937f.zip
Systemtap: forbid invalid Run Config paths.
If the path entered in the "Systemtap Script" textbox of the Run Configuration menu does not point to an existing .stp file, the configuration won't be runnable. Change-Id: Ic943931ddfcd0ae10a930b04f34cc537708b305d Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/19018 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com> Reviewed-on: https://git.eclipse.org/r/19156 Tested-by: Hudson CI
-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/SystemTapScriptLaunchConfigurationTab.java30
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties2
3 files changed, 34 insertions, 0 deletions
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 2a1a9dba72..8805beaf50 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_runWithChart;
public static String SystemTapScriptLaunchShortcut_couldNotFindConfig;
public static String SystemTapScriptLaunchShortcut_couldNotLaunchScript;
+ public static String SystemTapScriptLaunchConfigurationTab_couldNotFindFile;
+ public static String SystemTapScriptLaunchConfigurationTab_fileNotStp;
public static String SystemTapScriptOptionsTab_0;
public static String SystemTapScriptOptionsTab_1;
public static String SystemTapScriptOptionsTab_2;
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 7914859e53..bf14fa39c6 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
@@ -11,9 +11,12 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher;
+import java.text.MessageFormat;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -65,6 +68,15 @@ public class SystemTapScriptLaunchConfigurationTab extends
private Label hostNamelabel;
private FileDialog fileDialog;
+ /**
+ * @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.
+ */
+ IPath getScriptPath() {
+ IPath scriptPath = new Path(scriptPathText.getText());
+ return scriptPath.toFile().exists() ? scriptPath : null;
+ }
+
@Override
public void createControl(Composite parent) {
@@ -268,6 +280,24 @@ public class SystemTapScriptLaunchConfigurationTab extends
}
@Override
+ public boolean isValid(ILaunchConfiguration launchConfig) {
+ setErrorMessage(null);
+
+ IPath scriptPath = getScriptPath();
+ if (scriptPath == null) {
+ setErrorMessage(MessageFormat.format(Messages.SystemTapScriptLaunchConfigurationTab_couldNotFindFile, scriptPathText.getText()));
+ return false;
+ }
+ String extension = scriptPath.getFileExtension();
+ if (extension == null || !extension.equals("stp")) { //$NON-NLS-1$
+ setErrorMessage(Messages.SystemTapScriptLaunchConfigurationTab_fileNotStp);
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
public String getName() {
return Messages.SystemTapScriptLaunchConfigurationTab_9;
}
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 5e0f2fa38b..448a9a9e25 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
@@ -72,6 +72,8 @@ SystemTapScriptLaunchConfigurationTab_11=Select Systemtap Script
SystemTapScriptLaunchConfigurationTab_errorInitializingTab=Could not initialize tab
SystemTapScriptLaunchConfigurationTab_options=Options:
SystemTapScriptLaunchConfigurationTab_runWithChart=Run the script with a chart.
+SystemTapScriptLaunchConfigurationTab_couldNotFindFile=No Systemtap script exists with the path {0}.
+SystemTapScriptLaunchConfigurationTab_fileNotStp=Must provide a path to a valid Systemtap script (with extension ".stp").
SystemTapScriptLaunchShortcut_couldNotFindConfig=Could Not Find configuration
SystemTapScriptLaunchShortcut_couldNotLaunchScript=Could Not Launch Script
SystemTapScriptOptionsTab_0=Select target executable.

Back to the top