Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Wagiaalla2013-06-07 15:37:42 +0000
committerRoland Grunberg2013-06-11 13:58:02 +0000
commitb810685ae4d5ff9bc508ed6fe30536f10431cdda (patch)
treea82162013b3a5a1033c8f8ef8dc2e1ddd1b9ca8e
parent51068e6f56feecd71bdcf73b19aa19884fb8dae0 (diff)
downloadorg.eclipse.linuxtools-b810685ae4d5ff9bc508ed6fe30536f10431cdda.tar.gz
org.eclipse.linuxtools-b810685ae4d5ff9bc508ed6fe30536f10431cdda.tar.xz
org.eclipse.linuxtools-b810685ae4d5ff9bc508ed6fe30536f10431cdda.zip
callgraph: make callgraph runnable with the current systemtap
- Move escaping of characters to the final stage of writing the launch script. - Use --runtime=dyninst to work around missing return probes. - Remove the use of probefunc() as it is not supported in dyninst mode. - Replace the use of -o with redirecting the output as dyninst does not support -o. - Update tests to expect the new command output format. - Save actions: Organize imports. Add braces. Remove trailing white space. This is a combination of two patches commited to master. Reviewed here: https://git.eclipse.org/r/13654 and here: https://git.eclipse.org/r/13711 Change-Id: Id6ecafc94b745ad4a84d7484b47bb4270a9fa6ae Reviewed-on: https://git.eclipse.org/r/13741 Tested-by: Hudson CI Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java29
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/ConfigurationTest.java10
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/SystemTapCommandGeneratorTest.java14
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/CallgraphLaunchPlugin.java1
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java12
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java1
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchConfigurationDelegate.java130
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java21
9 files changed, 117 insertions, 103 deletions
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java
index 96a25f96d0..cb33ddad85 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java
@@ -4,14 +4,14 @@
* 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 - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.callgraph.core;
public final class PluginConstants {
-
+
private static String PLUGIN_LOCATION = ""; //$NON-NLS-1$
public static final String CONFIGURATION_TYPE_ID = "org.eclipse.linuxtools.callgraph.launch.systemtapLaunch"; //$NON-NLS-1$
public static final String PARSER_CLASS = "org.eclipse.linuxtools.callgraph.core.parser"; //$NON-NLS-1$
@@ -23,21 +23,21 @@ public final class PluginConstants {
public static final String ATTR_CLASS = "class"; //$NON-NLS-1$
public static final String ATTR_REALTIME = "realtime"; //$NON-NLS-1$
public static final String VAL_TRUE = "true"; //$NON-NLS-1$
-
+
public static final String NEW_LINE = "\n"; //$NON-NLS-1$
public static final int MAX_ERRORS = 500; //Maximum number of errors to tolerate
public static int SYSTEMTAP_OPTIONS_TAB_HORIZONTAL_SPACING = 30;
public static String STAP_PATH = "stap"; //$NON-NLS-1$
-
+
public static final String DEFAULT_VIEW_ID = "org.eclipse.linuxtools.callgraph.core.staptextview"; //$NON-NLS-1$
public static final String DEFAULT_PARSER_ID = "org.eclipse.linuxtools.callgraph.core.systemtaptextparser"; //$NON-NLS-1$
private static String DEFAULT_OUTPUT = ""; //$NON-NLS-1$
private static String STAP_GRAPH_DEFAULT_IO_PATH = ""; //$NON-NLS-1$
-
+
/**
* Sets the absolute path of the Plugin folder and updates
* the PLUGIN_LOCATION.
- *
+ *
* @param loc
*/
public static void setPluginLocation(String loc) {
@@ -45,23 +45,28 @@ public final class PluginConstants {
}
public static String getPluginLocation() {
- if (PLUGIN_LOCATION.length() < 1)
+ if (PLUGIN_LOCATION.length() < 1) {
PluginConstants.setPluginLocation(CallgraphCorePlugin.getPluginLocation());
-
+ }
+
return PLUGIN_LOCATION;
}
public static String getDefaultOutput() {
- if (DEFAULT_OUTPUT.length() < 1)
+ if (DEFAULT_OUTPUT.length() < 1){
DEFAULT_OUTPUT = CallgraphCorePlugin.getDefault().getStateLocation().toString()+"/"; //$NON-NLS-1$
+ }
+
return DEFAULT_OUTPUT;
}
-
+
public static String getDefaultIOPath() {
if (STAP_GRAPH_DEFAULT_IO_PATH.length() < 1)
+ {
STAP_GRAPH_DEFAULT_IO_PATH = CallgraphCorePlugin.getDefault().getStateLocation().toString()+"/callgraph.out"; //$NON-NLS-1$
+ }
return STAP_GRAPH_DEFAULT_IO_PATH;
}
-
-
+
+
}
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java
index 235f5c79f6..b816618ce7 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java
@@ -38,7 +38,7 @@ public class SystemTapCommandGenerator {
binaryPath = binPath;
scriptPath = scrPath;
isGuru = false;
- arguments = arg;
+ arguments = "--runtime=dyninst " + arg; //$NON-NLS-1$
flags = opts;
binaryArguments = binArguments;
command = cmdTarget;
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/ConfigurationTest.java b/systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/ConfigurationTest.java
index a72b6ab9a2..64edeac1bf 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/ConfigurationTest.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/ConfigurationTest.java
@@ -33,9 +33,9 @@ public class ConfigurationTest extends AbstractStapTest{
String testCDirectives = "-DRandomjunk -DMoreJunk";
String testOutputPath = "/tmp/ThisFileDoesNothingDeleteIt";
- String testBinaryPath = "More random junk";
+ String testBinaryPath = "/path/to/binary";
String testScriptPath = "/tmp/NotAScriptFile.stp";
- String testArguments = "Nonexistent Arguments";
+ String testArguments = "/path/to/binary";
int testPid = 413;
int testBuffer = 100;
int testPass = 10;
@@ -86,9 +86,9 @@ public class ConfigurationTest extends AbstractStapTest{
assertEquals("stap -v -p" + testPass + " -k -g -P -u -w -b -t -s"
+ testBuffer + " -x" + testPid + " " + testCDirectives
- + " -F --skip-badvars --ignore-dwarf -q " + "-o "
- + testOutputPath + " -c '" + testBinaryPath + "' "
- + testScriptPath + " " + testArguments,
+ + " -F --skip-badvars --ignore-dwarf -q " + " -c '" + testBinaryPath
+ + "' " + testScriptPath + " --runtime=dyninst " + testArguments + " >& "
+ + testOutputPath,
del.generateCommand(config));
killStap();
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/SystemTapCommandGeneratorTest.java b/systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/SystemTapCommandGeneratorTest.java
index f2113afdd3..e9c671a3f6 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/SystemTapCommandGeneratorTest.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch.tests/src/org/eclipse/linuxtools/callgraph/launch/tests/SystemTapCommandGeneratorTest.java
@@ -4,7 +4,7 @@
* 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 - initial API and implementation
*******************************************************************************/
@@ -15,13 +15,13 @@ import java.io.File;
import org.eclipse.linuxtools.internal.callgraph.core.PluginConstants;
import org.eclipse.linuxtools.internal.callgraph.core.SystemTapCommandGenerator;
-public class SystemTapCommandGeneratorTest extends AbstractStapTest{
-
+public class SystemTapCommandGeneratorTest extends AbstractStapTest{
+
//HACK TO GET THE PATH TO THE TESTING PROJECT
File file = new File("");
private String location = file.getAbsolutePath() + "/";
SystemTapCommandGenerator stapgen = new SystemTapCommandGenerator();
-
+
public void testExecutionWithScriptAndBinaryAndArgument(){
String binaryFilePath = location + "factorial";
@@ -32,12 +32,12 @@ public class SystemTapCommandGeneratorTest extends AbstractStapTest{
binaryFilePath, "", true, true, binaryFilePath, "",
PluginConstants.STAP_PATH);
- assertEquals("stap -c '" + binaryFilePath + "' " + scriptPath + " "
+ assertEquals("stap -c '" + binaryFilePath + "' " + scriptPath + " --runtime=dyninst "
+ binaryFilePath, cmd);
killStap();
// END
}
-
+
public void testScriptExecution(){
String scriptPath = location + "simple.stp";
@@ -61,7 +61,7 @@ public class SystemTapCommandGeneratorTest extends AbstractStapTest{
assertEquals("stap -c '" + binaryFilePath + "' " + scriptPath, cmd);
// END
-
+
killStap();
}
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/CallgraphLaunchPlugin.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/CallgraphLaunchPlugin.java
index dc76ce90be..4b05b8d8df 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/CallgraphLaunchPlugin.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/CallgraphLaunchPlugin.java
@@ -80,4 +80,5 @@ public class CallgraphLaunchPlugin extends AbstractUIPlugin {
public static Shell getActiveWorkbenchShell() {
return getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
}
+
}
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java
index 58c675e23e..d823ada505 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java
@@ -70,17 +70,19 @@ public class LaunchStapGraph extends SystemTapLaunchShortcut {
projectName = bin.getCProject().getElementName();
try {
- if (wc == null)
+ if (wc == null) {
wc = createConfiguration(bin, name);
+ }
binaryPath = bin.getResource().getLocation().toString();
- binaryPath = escapeSpecialCharacters(binaryPath);
arguments = binaryPath;
outputPath = PluginConstants.getDefaultIOPath();
- if (writeFunctionListToScript(resourceToSearchFor) == null)
+ if (writeFunctionListToScript(resourceToSearchFor) == null) {
return;
- if (funcs == null || funcs.length() < 0)
+ }
+ if (funcs == null || funcs.length() < 0) {
return;
+ }
needToGenerate = true;
finishLaunch(name, mode, wc);
@@ -110,7 +112,7 @@ public class LaunchStapGraph extends SystemTapLaunchShortcut {
* @return
*/
private String generateProbe(String function) {
- String output = "probe process(@1).function(\"" + function + "\").call ? { if ( ! isinstr(probefunc(), \"___STAP_MARKER___\")) { callFunction(probefunc(),tid()) } } probe process(@1).function(\"" + function + "\").return ? { if ( ! isinstr(probefunc(), \"___STAP_MARKER___\")) returnFunction(probefunc(),tid()) else { printf(\"?%d,,%s\\n\", tid(), user_string(strtol(tokenize($$return, \"return=\"),16)))}}\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String output = "probe process(@1).function(\"" + function + "\").call ? { if ( ! isinstr(\"" + function + "\", \"___STAP_MARKER___\")) { callFunction(\"" + function + "\",tid()) } } probe process(@1).function(\"" + function + "\").return ? { if ( ! isinstr(\"" + function + "\", \"___STAP_MARKER___\")) returnFunction(\"" + function + "\",tid()) else { printf(\"?%d,,%s\\n\", tid(), user_string(strtol(tokenize($$return, \"return=\"),16)))}}\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
return output;
}
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java
index 01003a24c2..59660f7158 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java
@@ -249,7 +249,6 @@ public class LaunchWizard extends SystemTapLaunchShortcut {
public void widgetSelected(SelectionEvent e) {
scriptPath = scriptLocation.getText();
binaryPath = binaryLocation.getText();
- binaryPath = escapeSpecialCharacters(binaryPath);
arguments = argumentsLocation.getText();
ILaunchConfigurationWorkingCopy wc = createConfiguration(null, name);
try {
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchConfigurationDelegate.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchConfigurationDelegate.java
index 4c89ef96c7..e2b7fe1252 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchConfigurationDelegate.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchConfigurationDelegate.java
@@ -4,7 +4,7 @@
* 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 - initial API and implementation
*******************************************************************************/
@@ -43,11 +43,13 @@ import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegat
/**
* Delegate for Stap scripts. The Delegate generates part of the command string
* and schedules a job to finish generation of the command and execute.
- *
+ *
*/
public class SystemTapLaunchConfigurationDelegate extends
ProfileLaunchConfigurationDelegate {
+ private static final String [] escapableChars = new String [] {"(", ")", " "}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
private static final String TEMP_ERROR_OUTPUT =
PluginConstants.getDefaultOutput() + "stapTempError.error"; //$NON-NLS-1$
private String cmd;
@@ -68,7 +70,7 @@ public class SystemTapLaunchConfigurationDelegate extends
protected String getPluginID() {
return null;
}
-
+
/**
* Sets strings to blank, booleans to false and everything else to null
*/
@@ -83,11 +85,11 @@ public class SystemTapLaunchConfigurationDelegate extends
useColour = false;
binaryArguments = ""; //$NON-NLS-1$
}
-
+
@Override
public void launch(ILaunchConfiguration config, String mode,
ILaunch launch, IProgressMonitor m) throws CoreException {
-
+
if (m == null) {
m = new NullProgressMonitor();
}
@@ -99,13 +101,14 @@ public class SystemTapLaunchConfigurationDelegate extends
if (monitor.isCanceled()) {
return;
}
-
+
/*
* Set variables
*/
if (config.getAttribute(LaunchConfigurationConstants.USE_COLOUR,
- LaunchConfigurationConstants.DEFAULT_USE_COLOUR))
- useColour = true;
+ LaunchConfigurationConstants.DEFAULT_USE_COLOUR)) {
+ useColour = true;
+ }
if (!config.getAttribute(LaunchConfigurationConstants.ARGUMENTS,
LaunchConfigurationConstants.DEFAULT_ARGUMENTS).equals(
LaunchConfigurationConstants.DEFAULT_ARGUMENTS)) {
@@ -153,21 +156,20 @@ public class SystemTapLaunchConfigurationDelegate extends
e1.printStackTrace();
}
}
-
+
stap = config.getAttribute(LaunchConfigurationConstants.COMMAND,
PluginConstants.STAP_PATH);
/**
* Generate partial command
*/
- partialCommand = ConfigurationOptionsSetter.setOptions(config);
+ partialCommand = ConfigurationOptionsSetter.setOptions(config);
outputPath = config.getAttribute(
LaunchConfigurationConstants.OUTPUT_PATH,
PluginConstants.getDefaultOutput());
- partialCommand += "-o " + outputPath; //$NON-NLS-1$
- boolean fileExists;
+ boolean fileExists = true;
try {
//Make sure the output file exists
File tempFile = new File(outputPath);
@@ -188,19 +190,21 @@ public class SystemTapLaunchConfigurationDelegate extends
finishLaunch(launch, config, m, true);
}
-
+
/**
* Returns the current SystemTap command, or returns an error message.
* @return
*/
public String getCommand() {
- if (cmd.length() > 0)
+ if (cmd.length() > 0) {
return cmd;
- else
+ }
+ else {
return Messages.getString("SystemTapLaunchConfigurationDelegate.NoCommand"); //$NON-NLS-1$
+ }
}
- private void finishLaunch(ILaunch launch, ILaunchConfiguration config,
+ private void finishLaunch(ILaunch launch, ILaunchConfiguration config,
IProgressMonitor monitor, boolean retry) {
try {
@@ -212,16 +216,16 @@ public class SystemTapLaunchConfigurationDelegate extends
// set the default source locator if required
setDefaultSourceLocator(launch, config);
-
+
/*
- * Fetch a parser
+ * Fetch a parser
*/
- String parserClass = config.getAttribute(LaunchConfigurationConstants.PARSER_CLASS,
+ String parserClass = config.getAttribute(LaunchConfigurationConstants.PARSER_CLASS,
LaunchConfigurationConstants.DEFAULT_PARSER_CLASS);
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] extensions = reg
- .getConfigurationElementsFor(PluginConstants.PARSER_RESOURCE,
- PluginConstants.PARSER_NAME,
+ .getConfigurationElementsFor(PluginConstants.PARSER_RESOURCE,
+ PluginConstants.PARSER_NAME,
parserClass);
if (extensions == null || extensions.length < 1) {
SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages(Messages.getString("SystemTapLaunchConfigurationDelegate.InvalidParser1"), //$NON-NLS-1$
@@ -231,11 +235,11 @@ public class SystemTapLaunchConfigurationDelegate extends
mess.schedule();
return;
}
-
+
IConfigurationElement element = extensions[0];
- SystemTapParser parser =
+ SystemTapParser parser =
(SystemTapParser) element.createExecutableExtension(PluginConstants.ATTR_CLASS);
-
+
//Set parser options
parser.setViewID(config.getAttribute(LaunchConfigurationConstants.VIEW_CLASS,
LaunchConfigurationConstants.VIEW_CLASS));
@@ -246,13 +250,13 @@ public class SystemTapLaunchConfigurationDelegate extends
LaunchConfigurationConstants.DEFAULT_SECONDARY_VIEW_ID));
parser.setKillButtonEnabled(true);
-
+
monitor.worked(1);
/*
* Launch
*/
-
+
File workDir = getWorkingDirectory(config);
if (workDir == null) {
workDir = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -260,7 +264,7 @@ public class SystemTapLaunchConfigurationDelegate extends
//Put command into a shell script
String cmd = generateCommand(config);
- File script = File.createTempFile("org.eclipse.linuxtools.profiling.launch" + System.currentTimeMillis(), ".sh");
+ File script = File.createTempFile("org.eclipse.linuxtools.profiling.launch" + System.currentTimeMillis(), ".sh"); //$NON-NLS-1$ //$NON-NLS-2$
String data = "#!/bin/sh\nexec " + cmd; //$NON-NLS-1$
FileOutputStream out = null;
try {
@@ -282,10 +286,10 @@ public class SystemTapLaunchConfigurationDelegate extends
process.setAttribute(IProcess.ATTR_CMDLINE,cmd);
monitor.worked(1);
-
+
StreamListener s = new StreamListener();
process.getStreamsProxy().getErrorStreamMonitor().addListener(s);
-
+
while (!process.isTerminated()) {
Thread.sleep(100);
if ((monitor != null && monitor.isCanceled()) || parser.isDone()) {
@@ -306,45 +310,46 @@ public class SystemTapLaunchConfigurationDelegate extends
Messages.getString("SystemTapLaunchConfigurationDelegate.CallGraphGenericError"), //$NON-NLS-1$
Messages.getString("SystemTapLaunchConfigurationDelegate.CallGraphGenericError"), //$NON-NLS-1$
Messages.getString("SystemTapLaunchConfigurationDelegate.stapNotFound")); //$NON-NLS-1$
-
+
errorDialog.schedule();
}else{
SystemTapErrorHandler errorHandler = new SystemTapErrorHandler();
-
+
//Prepare stap information
errorHandler.appendToLog(config.getName() + Messages.getString("SystemTapLaunchConfigurationDelegate.stap_command") + cmd+ PluginConstants.NEW_LINE + PluginConstants.NEW_LINE);//$NON-NLS-1$
-
+
//Handle error from TEMP_ERROR_OUTPUT
errorHandler.handle(monitor, new FileReader(TEMP_ERROR_OUTPUT));
- if ((monitor != null && monitor.isCanceled()))
+ if ((monitor != null && monitor.isCanceled())) {
return;
-
+ }
+
errorHandler.finishHandling(monitor, scriptPath);
if (errorHandler.isErrorRecognized()) {
SystemTapUIErrorMessages errorDialog = new SystemTapUIErrorMessages(
Messages.getString("SystemTapLaunchConfigurationDelegate.CallGraphGenericError"), //$NON-NLS-1$
Messages.getString("SystemTapLaunchConfigurationDelegate.CallGraphGenericError"), //$NON-NLS-1$
errorHandler.getErrorMessage());
-
+
errorDialog.schedule();
}
}
return;
}
-
+
if (element.getAttribute(PluginConstants.ATTR_REALTIME).equals(PluginConstants.VAL_TRUE)) {
parser.setRealTime(true);
}
-
+
parser.schedule();
monitor.worked(1);
-
+
String message = generateErrorMessage(config.getName(), binaryArguments);
-
+
DocWriter dw = new DocWriter(Messages.getString("SystemTapLaunchConfigurationDelegate.DocWriterName"), //$NON-NLS-1$
(Helper.getConsoleByName(config.getName())), message);
dw.schedule();
-
+
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
@@ -353,17 +358,17 @@ public class SystemTapLaunchConfigurationDelegate extends
e.printStackTrace();
} finally {
monitor.done();
-
+
}
}
-
+
private String generateErrorMessage(String configName, String binaryCommand) {
String output = ""; //$NON-NLS-1$
-
+
if (binaryCommand == null || binaryCommand.length() < 0) {
output = PluginConstants.NEW_LINE +
PluginConstants.NEW_LINE + "-------------" + //$NON-NLS-1$
- PluginConstants.NEW_LINE +
+ PluginConstants.NEW_LINE +
Messages.getString("SystemTapLaunchConfigurationDelegate.Relaunch10") //$NON-NLS-1$
+ configName + PluginConstants.NEW_LINE +
Messages.getString("SystemTapLaunchConfigurationDelegate.Relaunch8") + //$NON-NLS-1$
@@ -371,9 +376,9 @@ public class SystemTapLaunchConfigurationDelegate extends
"configuration in Profile As --> Profile Configurations." + //$NON-NLS-1$
PluginConstants.NEW_LINE + PluginConstants.NEW_LINE;
} else {
- output = PluginConstants.NEW_LINE
+ output = PluginConstants.NEW_LINE
+ PluginConstants.NEW_LINE +"-------------" //$NON-NLS-1$
- + PluginConstants.NEW_LINE
+ + PluginConstants.NEW_LINE
+ Messages.getString("SystemTapLaunchConfigurationDelegate.EndMessage1") //$NON-NLS-1$
+ configName + PluginConstants.NEW_LINE +
Messages.getString("SystemTapLaunchConfigurationDelegate.EndMessage2") //$NON-NLS-1$
@@ -383,14 +388,14 @@ public class SystemTapLaunchConfigurationDelegate extends
Messages.getString("SystemTapLaunchConfigurationDelegate.EndMessage5") + //$NON-NLS-1$
PluginConstants.NEW_LINE + PluginConstants.NEW_LINE;
}
-
+
return output;
}
private static class StreamListener implements IStreamListener{
private int counter;
private BufferedWriter bw;
-
+
public StreamListener() throws IOException {
File file = new File(TEMP_ERROR_OUTPUT);
file.delete();
@@ -398,14 +403,17 @@ public class SystemTapLaunchConfigurationDelegate extends
bw = Helper.setBufferedWriter(TEMP_ERROR_OUTPUT);
counter = 0;
}
-
+
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
try {
- if (text.length() < 1) return;
+ if (text.length() < 1) {
+ return;
+ }
counter++;
- if (counter < PluginConstants.MAX_ERRORS)
+ if (counter < PluginConstants.MAX_ERRORS) {
bw.append(text);
+ }
} catch (IOException e) {
e.printStackTrace();
}
@@ -418,8 +426,24 @@ public class SystemTapLaunchConfigurationDelegate extends
public String generateCommand(ILaunchConfiguration config) {
// Generate the command
- cmd = SystemTapCommandGenerator.generateCommand(scriptPath, binaryPath,
- partialCommand, needsBinary, needsArguments, arguments, binaryArguments, stap);
+ cmd = SystemTapCommandGenerator.generateCommand(escapeSpecialCharacters(scriptPath), escapeSpecialCharacters(binaryPath),
+ partialCommand, needsBinary, needsArguments, escapeSpecialCharacters(arguments), binaryArguments, stap);
+ cmd += " >& " + escapeSpecialCharacters(outputPath); //$NON-NLS-1$
return cmd;
}
+
+ /**
+ * Escapes special characters in the target string
+ *
+ * @param script the script to be executed by the shell.
+ * @return the formatted string that will be executed.
+ */
+ private String escapeSpecialCharacters(String str) {
+ // Modify script to catch escapable characters.
+ String res = str;
+ for (int i = 0; i < escapableChars.length; i++) {
+ res = res.replace(escapableChars[i], "\\" + escapableChars[i]); //$NON-NLS-1$
+ }
+ return res;
+ }
}
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java
index 02974c28d5..9a890be58a 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java
@@ -130,7 +130,6 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
private Button OKButton;
private boolean testMode = false;
protected String secondaryID = ""; //$NON-NLS-1$
- private final String [] escapableChars = new String [] {"(", ")", " "}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
* Initialize variables. Highly recommend calling this function within the
@@ -233,7 +232,6 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
wc.setAttribute(LaunchConfigurationConstants.BINARY_PATH,binaryPath);
}
- outputPath = escapeSpecialCharacters(outputPath);
wc.setAttribute(LaunchConfigurationConstants.OUTPUT_PATH,outputPath);
wc.setAttribute(LaunchConfigurationConstants.ARGUMENTS, arguments);
wc.setAttribute(LaunchConfigurationConstants.GENERATED_SCRIPT,generatedScript);
@@ -637,7 +635,7 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
if (!(validElement(c))) {
continue;
}
- if (c.getElementName().contains("main") && !output.contains(c)) {
+ if (c.getElementName().contains("main") && !output.contains(c)) { //$NON-NLS-1$
output.add(c);
}
}
@@ -796,7 +794,7 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
}
/**
- * Function for generating scripts. Should be overriden by interested
+ * Function for generating scripts. Should be overridden by interested
* classes
*
* @throws IOException
@@ -935,7 +933,6 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
ILaunchConfigurationWorkingCopy wc = createConfiguration(bin, name);
binaryPath = bin.getResource().getLocation().toString();
- binaryPath = escapeSpecialCharacters(binaryPath);
arguments = binaryPath;
outputPath = PluginConstants.getDefaultIOPath();
finishLaunch(name, mode, wc);
@@ -971,18 +968,4 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
return ""; //$NON-NLS-1$
}
- /**
- * Escapes special characters in the target string
- *
- * @param script the script to be executed by the shell.
- * @return the formatted string that will be executed.
- */
- protected String escapeSpecialCharacters(String str) {
- // Modify script to catch escapable characters.
- String res = str;
- for (int i = 0; i < escapableChars.length; i++) {
- res = res.replace(escapableChars[i], "\\" + escapableChars[i]); //$NON-NLS-1$
- }
- return res;
- }
}

Back to the top