[Esbox-commits] r402 - in trunk/org.indt.esbox.launch: META-INF src/org/indt/esbox/launch/oprofile src/org/indt/esbox/launch/remote src/org/indt/esbox/launch/valgrind
raul at garage.maemo.org
raul at garage.maemo.org
Wed Feb 13 22:28:24 EET 2008
Author: raul
Date: 2008-02-13 22:28:18 +0200 (Wed, 13 Feb 2008)
New Revision: 402
Modified:
trunk/org.indt.esbox.launch/META-INF/MANIFEST.MF
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java
Log:
bugs fixed.
Modified: trunk/org.indt.esbox.launch/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.indt.esbox.launch/META-INF/MANIFEST.MF 2008-02-13 20:26:10 UTC (rev 401)
+++ trunk/org.indt.esbox.launch/META-INF/MANIFEST.MF 2008-02-13 20:28:18 UTC (rev 402)
@@ -12,6 +12,7 @@
org.eclipse.cdt.core,
org.eclipse.cdt.ui,
org.eclipse.debug.ui,
- org.indt.esbox.core
+ org.indt.esbox.core,
+ org.indt.esbox.ui
Eclipse-LazyStart: true
Export-Package: org.indt.esbox.launch
Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java 2008-02-13 20:26:10 UTC (rev 401)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java 2008-02-13 20:28:18 UTC (rev 402)
@@ -11,14 +11,12 @@
package org.indt.esbox.launch.oprofile;
import java.io.File;
-import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
-import org.eclipse.cdt.utils.pty.PTY;
-import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -28,16 +26,27 @@
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
import org.indt.esbox.core.CoreActivator;
import org.indt.esbox.core.ESboxException;
import org.indt.esbox.core.ESboxPreferenceConstants;
import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+import org.indt.esbox.core.scratchbox.ESboxCommonCommandLauncher;
import org.indt.esbox.core.tool.ESboxToolEngine;
import org.indt.esbox.core.tool.ITool;
+import org.indt.esbox.core.tool.IToolListener;
import org.indt.esbox.core.tool.ToolRunnerInfo;
+import org.indt.esbox.core.tool.oprofile.OPreportToolRunner;
+import org.indt.esbox.core.tool.valgrind.ValgrindToolRunner;
import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
import org.indt.esbox.launch.LaunchActivator;
+import org.indt.esbox.ui.UIActivator;
+import org.indt.esbox.ui.dialogs.PasswordInputDialog;
/**
*
@@ -50,7 +59,7 @@
@Override
protected String getPluginID() {
// TODO Auto-generated method stub
- return null;
+ return LaunchActivator.PLUGIN_ID;
}
/* (non-Javadoc)
@@ -64,7 +73,7 @@
monitor = new NullProgressMonitor();
}
- monitor.beginTask("Launching the application on Device", 10);
+ monitor.beginTask("Running OProfile on Device", 10);
// check for cancellation
if (monitor.isCanceled()) {
return;
@@ -101,55 +110,66 @@
}
IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
- ScratchboxCommandLauncher launcher = new InnerCommandLauncher();
+ ESboxCommonCommandLauncher launcher = new ESboxCommonCommandLauncher();
String program = isRunStandalone ? "run-standalone.sh " : "" + "./" + exePath.lastSegment();
String args[] = new String[] { "-d", remoteMounPoint, program };
-
+
+ String password = promptPassword();
+
try{
- startOProfile();
+ monitor.worked(2);
+ startOProfile(password);
+ monitor.worked(4);
+
Process process = launcher.execute(command, args, new String[] { }, new Path(wd.getAbsolutePath()));
- monitor.worked(3);
+ monitor.worked(6);
DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
- stopOProfile();
+ monitor.worked(8);
+ stopOProfile(password);
+
+ monitor.worked(9);
+ runOPreport();
} catch (ESboxException e) {
e.printStackTrace();
}
+
+ monitor.worked(10);
}
- private void startOProfile() throws ESboxException {
- ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
+ private void startOProfile(String password) throws ESboxException {
+ ESboxCommonCommandLauncher launcher = new ESboxCommonCommandLauncher();
ITool oprofile = ESboxToolEngine.getInstance().getTool("OProfile")[0];
ToolRunnerInfo oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+ changeToolInfo(oprofileInfo,password);
List<String> cmdLine = oprofileInfo.getCommandLine();
cmdLine.add("--init");
Process process = launcher.execute(oprofileInfo);
oprofile.getProvider().getRunner().trackProcess(process);
- oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
- cmdLine = oprofileInfo.getCommandLine();
+ cmdLine.remove(cmdLine.size() - 1);
cmdLine.add("--no-vmlinux");
process = launcher.execute(oprofileInfo);
oprofile.getProvider().getRunner().trackProcess(process);
- oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
- cmdLine = oprofileInfo.getCommandLine();
+ cmdLine.remove(cmdLine.size() - 1);
cmdLine.add("--start");
process = launcher.execute(oprofileInfo);
oprofile.getProvider().getRunner().trackProcess(process);
}
- private void stopOProfile() throws ESboxException {
- ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
+ private void stopOProfile(String password) throws ESboxException {
+ ESboxCommonCommandLauncher launcher = new ESboxCommonCommandLauncher();
ITool oprofile = ESboxToolEngine.getInstance().getTool("OProfile")[0];
ToolRunnerInfo oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+ changeToolInfo(oprofileInfo,password);
List<String> cmdLine = oprofileInfo.getCommandLine();
cmdLine.add("--stop");
@@ -158,6 +178,36 @@
}
+ private void runOPreport() throws ESboxException {
+
+ LaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ try {
+ OPreportToolRunner.getInstance().addListener((IToolListener)UIActivator.getDefault().getView("org.indt.esbox.ui.views.oProfileView"));
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+
+ ESboxCommonCommandLauncher launcher = new ESboxCommonCommandLauncher();
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+
+ final ITool oprofile = ESboxToolEngine.getInstance().getTool("OPreport")[0];
+ ToolRunnerInfo opreportInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+
+ List<String> cmdLine = opreportInfo.getCommandLine();
+ cmdLine.add(0, command.toOSString());
+ cmdLine.add("-a");
+ cmdLine.add("-l");
+ cmdLine.add("-g");
+ final Process process = launcher.execute(opreportInfo);
+
+ oprofile.getProvider().getRunner().trackProcess(process);
+ }
+
private void copyFile(String src, String dst) throws InterruptedException {
CommandLauncher launcher = new CommandLauncher();
Process process = launcher.execute(new Path("cp"), new String[] {src, dst} , new String[] {} , new Path("."));
@@ -165,57 +215,63 @@
process.waitFor();
}
- /**
- *
- */
- class InnerCommandLauncher extends ScratchboxCommandLauncher {
+ private void changeToolInfo(ToolRunnerInfo info, String password) {
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.core.CommandLauncher#execute(org.eclipse.core.runtime.IPath, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
- */
- public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory) {
- try {
- fCommandArgs = constructCommandArray(commandPath.toOSString(),args, env, changeToDirectory);
-
- PTY pty = new PTY();
- fProcess = ProcessFactory.getFactory().exec(fCommandArgs, new String[] {}, changeToDirectory.toFile(), new PTY());
+ String remoteMounPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ remoteMounPoint = tokens[2];
+ }
+
+ IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+ String args[] = new String[] { "echo", "\"" + password + "\"", "|", "sudo", "-S", command.toOSString(), "-d", remoteMounPoint };
+ List<String> listArgs = new ArrayList<String>();
+ for (String string : args) {
+ listArgs.add(string);
+ }
+
+ info.getCommandLine().addAll(0, listArgs);
+ }
+
+ private String promptPassword() {
+ PasswordDialog runnable = new PasswordDialog();
+ LaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(runnable);
+
+ return runnable.getPassword();
+ }
+
+ private Shell getShell() {
+ return UIActivator.getDefault().getWorkbench().getDisplay().getActiveShell();
+ }
+
+ class PasswordDialog implements Runnable {
+
+ private String password;
+
+ public void run() {
+ LaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ // TODO Auto-generated method stub
+ IWorkbenchWindow window = LaunchActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ Shell shell = null;
+
+ if (window != null)
+ shell = window.getShell();
+
+ PasswordInputDialog dialog = new PasswordInputDialog(getShell(),"Password","Insert root password to execute commands with superuser privileges");
+ if (dialog.open() == Window.OK)
+ password = dialog.getPassword();
+ }
+ });
- fErrorMessage = "";
-
- } catch (IOException e) {
- e.printStackTrace();
- setErrorMessage(e.getMessage());
- fProcess = null;
- }
-
- return fProcess;
- }
+ }
- /*
- * (non-Javadoc)
- * @see org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher#constructCommandArray(java.lang.String, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
- */
- protected String[] constructCommandArray(String command,
- String[] commandArgs, String[] env, IPath changeToDirectory)
- throws IOException {
-
- String argString = "";
- // Construct commands arguments to string
- for (int i = 0; i < commandArgs.length; i++) {
- argString = argString.concat(" " + commandArgs[i]);
- }
-
- // construct whole command with exports
- String cmd[] = constructCommandArray(command);
-
- // Replace some pieces of original string
- cmd[2] = cmd[2] + " " + argString;
-
- return cmd;
+ public String getPassword() {
+ return password;
}
-
- }
+ }
}
Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java 2008-02-13 20:26:10 UTC (rev 401)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java 2008-02-13 20:28:18 UTC (rev 402)
@@ -49,7 +49,7 @@
import org.indt.esbox.core.CoreActivator;
import org.indt.esbox.core.ESboxPreferenceConstants;
import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.scratchbox.SbrshCommandLauncher;
+import org.indt.esbox.core.scratchbox.ESboxCommonCommandLauncher;
import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
import org.indt.esbox.launch.LaunchActivator;
@@ -116,7 +116,7 @@
// The launcher for running commands inside the Scratchbox
// environment
- ScratchboxCommandLauncher launcher = new SbrshCommandLauncher();
+ ScratchboxCommandLauncher launcher = new ESboxCommonCommandLauncher();
File wd = getWorkingDirectory(config);
if (wd == null) {
wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java 2008-02-13 20:26:10 UTC (rev 401)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java 2008-02-13 20:28:18 UTC (rev 402)
@@ -20,13 +20,17 @@
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ui.PartInitException;
import org.indt.esbox.core.ESboxException;
import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
import org.indt.esbox.core.tool.ESboxToolEngine;
import org.indt.esbox.core.tool.ITool;
+import org.indt.esbox.core.tool.IToolListener;
import org.indt.esbox.core.tool.ToolRunnerInfo;
+import org.indt.esbox.core.tool.valgrind.ValgrindToolRunner;
import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
import org.indt.esbox.launch.LaunchActivator;
+import org.indt.esbox.ui.UIActivator;
/**
*
@@ -78,6 +82,17 @@
cmdArray.add(args[i]);
}
+ LaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ try {
+ ValgrindToolRunner.getInstance().addListener((IToolListener)UIActivator.getDefault().getView("org.indt.esbox.ui.views.valgrindView"));
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+
ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
Process process = launcher.execute(valgrindInfo);
try {
More information about the Esbox-commits
mailing list