[Esbox-commits] r399 - in trunk: org.indt.esbox.launch org.indt.esbox.launch/src/org/indt/esbox/launch/internal org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile org.indt.esbox.launch/src/org/indt/esbox/launch/remote org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind org.indt.esbox.python.debug/META-INF org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger org.indt.esbox.python.launch org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind org.indt.esbox.python.ui org.indt.esbox.ui/META-INF org.indt.esbox.ui/src/org/indt/esbox/ui org.indt.esbox.ui/src/org/indt/esbox/ui/views org.indt.esbox.ui/src/org/indt/esbox/ui/wizards
raul at garage.maemo.org
raul at garage.maemo.org
Mon Feb 11 20:03:47 EET 2008
Author: raul
Date: 2008-02-11 20:03:03 +0200 (Mon, 11 Feb 2008)
New Revision: 399
Added:
trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonRemoteDebugger.java
trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/PythonDebugger.java
Removed:
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/
Modified:
trunk/org.indt.esbox.launch/plugin.xml
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/ValgrindLaunchConfigurationTabGroup.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java
trunk/org.indt.esbox.python.debug/META-INF/MANIFEST.MF
trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonDebugger.java
trunk/org.indt.esbox.python.launch/plugin.xml
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local/ESboxPythonLaunchConfigurationDelegate.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationTabGroup.java
trunk/org.indt.esbox.python.ui/plugin.xml
trunk/org.indt.esbox.ui/META-INF/MANIFEST.MF
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/UIActivator.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/ValgrindView.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizardPage.java
Log:
refactoring. Tools were moved from launch to core. Command launcher was also modified.
Modified: trunk/org.indt.esbox.launch/plugin.xml
===================================================================
--- trunk/org.indt.esbox.launch/plugin.xml 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.launch/plugin.xml 2008-02-11 18:03:03 UTC (rev 399)
@@ -258,28 +258,5 @@
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
</extension>
- <extension
- point="org.indt.esbox.core.tool">
- <tool
- id="org.indt.esbox.tool.oprofile"
- name="OProfile">
- <provider
- class="org.indt.esbox.launch.internal.core.tool.OProfileToolProvider">
- </provider>
- </tool>
- <tool
- id="org.indt.esbox.tool.valgrind"
- name="Valgrind">
- <provider
- class="org.indt.esbox.launch.internal.core.tool.ValgrindToolProvider"></provider>
- </tool>
- <tool
- id="org.indt.esbox.tool.opreport"
- name="OPreport">
- <provider
- class="org.indt.esbox.launch.internal.core.tool.OPreportToolProvider"></provider>
- </tool>
- </extension>
-
</plugin>
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-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -10,91 +10,39 @@
*******************************************************************************/
package org.indt.esbox.launch.oprofile;
-import org.eclipse.cdt.core.model.IBinary;
+import java.io.File;
+import java.io.IOException;
+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;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Preferences;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
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.tool.ESboxToolEngine;
import org.indt.esbox.core.tool.ITool;
+import org.indt.esbox.core.tool.ToolRunnerInfo;
+import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
+import org.indt.esbox.launch.LaunchActivator;
/**
*
*/
public class OProfileLaunchDelegate extends AbstractCLaunchDelegate {
-
-// runOProfileTool(new String[] {"--init"});
-// runOProfileTool(new String[] {"--no-vmlinux"});
-// runOProfileTool(new String[] {"--dump"});
-// runOProfileTool(new String[] {"--start"});
-//
-// runApplication(bin,mode);
-//
-// runOProfileTool(new String[] {"--stop"});
-//
-// runOPreportTool(new String[] { "" });
-//
-// IWorkbench workbench = PlatformUI.getWorkbench();
-// IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
-// try {
-// workbenchWindow.getActivePage().showView("org.indt.esbox.ui.views.oProfileView");
-// } catch (PartInitException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//}
-//
-//private void runApplication(IBinary bin, String mode) {
-// ILaunchConfiguration config = findLaunchConfiguration(bin, mode);
-//
-//// IPath exePath = verifyProgramPath(config);
-//// ICProject project = verifyCProject(config);
-//// IBinaryObject exeFile = verifyBinary(project, exePath);
-//// String arguments[] = getProgramArgumentsArray(config);
-//
-//
-// Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
-// String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
-//
-// String remoteMounPoint = "";
-// String localMountPoint = "";
-// if (!sbrshBinPath.equals("")) {
-// String tokens[] = sbrshBinPath.split("#");
-// localMountPoint = tokens[1];
-// remoteMounPoint = tokens[2];
-// }
-//
-//// boolean isRunStandalone = config.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE, IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
-//// boolean copyBinary = config.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_COPY_BINS, IESboxCDTLaunchConfigurationConstants.COPY_BINS_DEFAULT);
-//// if (copyBinary) {
-//// try {
-//// copyFile(exePath.toOSString(),localMountPoint + File.separatorChar + exePath.lastSegment());
-//// } catch (InterruptedException e) {
-//// ErrorLogger errorLogger = LaunchActivator.getDefault().getErrorLogger();
-//// errorLogger.logAndShowError("Scratchbox error", e);
-//// }
-//// }
-//
-//
-//}
-//
-//private void runOProfileTool(String args[]) {
-// ITool tool = ESboxToolEngine.getInstance().getTool("OProfile")[0];
-// tool.getProvider().getRunner().runTool(args);
-//}
-//
-//private void runOPreportTool(String args[]) {
-// ITool tool = ESboxToolEngine.getInstance().getTool("OPreport")[0];
-// tool.getProvider().getRunner().runTool(args);
-//}
/* (non-Javadoc)
* @see org.eclipse.cdt.launch.AbstractCLaunchDelegate#getPluginID()
@@ -111,8 +59,163 @@
@Override
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
+
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ monitor.beginTask("Launching the application on Device", 10);
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ IPath exePath = verifyProgramPath(configuration);
+ ICProject project = verifyCProject(configuration);
+
+ File wd = getWorkingDirectory(configuration);
+ if (wd == null) {
+ wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+ String localMountPoint = "";
+ String remoteMounPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ localMountPoint = tokens[1];
+ remoteMounPoint = tokens[2];
+ }
+
+ boolean isRunStandalone = configuration.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE, IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+ boolean copyBinary = configuration.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_COPY_BINS, IESboxCDTLaunchConfigurationConstants.COPY_BINS_DEFAULT);
+ if (copyBinary) {
+ try {
+ copyFile(exePath.toOSString(),localMountPoint + File.separatorChar + exePath.lastSegment());
+ } catch (InterruptedException e) {
+ ErrorLogger errorLogger = LaunchActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Scratchbox error", e);
+ }
+ }
+
+ IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+ ScratchboxCommandLauncher launcher = new InnerCommandLauncher();
+ String program = isRunStandalone ? "run-standalone.sh " : "" + "./" + exePath.lastSegment();
+ String args[] = new String[] { "-d", remoteMounPoint, program };
+
+ try{
+ startOProfile();
+
+ Process process = launcher.execute(command, args, new String[] { }, new Path(wd.getAbsolutePath()));
+
+ monitor.worked(3);
+ DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
+
+ stopOProfile();
+ } catch (ESboxException e) {
+ e.printStackTrace();
+ }
+
}
+
+ private void startOProfile() throws ESboxException {
+ ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
+
+ ITool oprofile = ESboxToolEngine.getInstance().getTool("OProfile")[0];
+ ToolRunnerInfo oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+
+ 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.add("--no-vmlinux");
+ process = launcher.execute(oprofileInfo);
+ oprofile.getProvider().getRunner().trackProcess(process);
+
+ oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+ cmdLine = oprofileInfo.getCommandLine();
+ cmdLine.add("--start");
+ process = launcher.execute(oprofileInfo);
+ oprofile.getProvider().getRunner().trackProcess(process);
+
+ }
+
+ private void stopOProfile() throws ESboxException {
+ ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
+
+ ITool oprofile = ESboxToolEngine.getInstance().getTool("OProfile")[0];
+ ToolRunnerInfo oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+
+ List<String> cmdLine = oprofileInfo.getCommandLine();
+ cmdLine.add("--stop");
+ Process process = launcher.execute(oprofileInfo);
+ 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("."));
+
+ process.waitFor();
+ }
+
+ /**
+ *
+ */
+ class InnerCommandLauncher extends ScratchboxCommandLauncher {
+
+ /*
+ * (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());
+
+ 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;
+ }
+
+
+ }
+
}
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-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/remote/ESboxRemoteRunLaunchDelegate.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -49,6 +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.ScratchboxCommandLauncher;
import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
import org.indt.esbox.launch.LaunchActivator;
@@ -115,7 +116,7 @@
// The launcher for running commands inside the Scratchbox
// environment
- InnerCommandLauncher launcher = new InnerCommandLauncher();
+ ScratchboxCommandLauncher launcher = new SbrshCommandLauncher();
File wd = getWorkingDirectory(config);
if (wd == null) {
wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -259,57 +260,5 @@
process.waitFor();
}
-
- /**
- *
- */
- class InnerCommandLauncher extends ScratchboxCommandLauncher {
-
- /*
- * (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());
-
- 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;
- }
-
-
- }
}
\ No newline at end of file
Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchConfigurationTabGroup.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchConfigurationTabGroup.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchConfigurationTabGroup.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -12,6 +12,8 @@
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.indt.esbox.launch.internal.ui.ESboxCMainTab;
/**
*
@@ -23,8 +25,9 @@
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- // TODO Auto-generated method stub
-
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new ESboxCMainTab() };
+ setTabs(tabs);
}
}
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-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -10,11 +10,23 @@
*******************************************************************************/
package org.indt.esbox.launch.valgrind;
+import java.util.List;
+
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+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.ToolRunnerInfo;
+import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
+import org.indt.esbox.launch.LaunchActivator;
/**
*
@@ -26,8 +38,7 @@
*/
@Override
protected String getPluginID() {
- // TODO Auto-generated method stub
- return null;
+ return LaunchActivator.PLUGIN_ID;
}
/* (non-Javadoc)
@@ -36,8 +47,48 @@
@Override
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
-
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ monitor.beginTask("Launching the application on Device", 10);
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ IPath exePath = verifyProgramPath(configuration);
+
+ ITool valgrind = ESboxToolEngine.getInstance().getTool("Valgrind")[0];
+ ToolRunnerInfo valgrindInfo = null;
+
+ try {
+ valgrindInfo = valgrind.getProvider().getRunner().createToolRunnerInfo();
+ } catch (ESboxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ boolean isRunStandalone = configuration.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE, IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+
+ String args[] = new String[] { "-q --tool=memcheck --leak-check=yes", isRunStandalone ? "run-standalone.sh " : "" , exePath.toOSString() };
+
+ List<String> cmdArray = valgrindInfo.getCommandLine();
+ for (int i = 0; i < args.length; i++) {
+ cmdArray.add(args[i]);
+ }
+
+ ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
+ Process process = launcher.execute(valgrindInfo);
+ try {
+ valgrind.getProvider().getRunner().trackProcess(process);
+ } catch (ESboxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ monitor.worked(3);
+ DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
}
}
Modified: trunk/org.indt.esbox.python.debug/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.indt.esbox.python.debug/META-INF/MANIFEST.MF 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.python.debug/META-INF/MANIFEST.MF 2008-02-11 18:03:03 UTC (rev 399)
@@ -13,6 +13,7 @@
org.python.pydev.core,
org.python.pydev,
org.eclipse.debug.ui,
- org.eclipse.core.variables
+ org.eclipse.core.variables,
+ org.eclipse.cdt.core
Eclipse-LazyStart: true
Export-Package: org.indt.esbox.python.debug.debugger
Modified: trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonDebugger.java
===================================================================
--- trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonDebugger.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonDebugger.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -11,21 +11,12 @@
package org.indt.esbox.python.debug.debugger;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -33,76 +24,46 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.variables.IStringVariableManager;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.ui.CommonTab;
-import org.eclipse.debug.ui.IDebugUIConstants;
import org.indt.esbox.core.CoreActivator;
import org.indt.esbox.core.ESboxPreferenceConstants;
import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
-import org.indt.esbox.python.debug.PythonDebugActivator;
import org.python.copiedfromeclipsesrc.JDTNotAvailableException;
-import org.python.pydev.debug.core.Constants;
import org.python.pydev.debug.core.PydevDebugPlugin;
import org.python.pydev.debug.model.PyDebugTarget;
import org.python.pydev.debug.model.PySourceLocator;
import org.python.pydev.debug.model.remote.RemoteDebugger;
import org.python.pydev.debug.ui.launching.PythonRunnerConfig;
-import org.python.pydev.plugin.SocketUtil;
import org.python.pydev.runners.SimpleRunner;
-import org.python.pydev.ui.NotConfiguredInterpreterException;
/**
* Python debugger.
* @author Paulo Romulo (paulo at embedded.ufcg.edu.br) (UFCG)
*/
-public class ESboxPythonDebugger {
+public class ESboxPythonDebugger extends PythonDebugger {
public static final String DEFAULT_LOCAL_CLIENT_IP = "127.0.0.1";
- private String[] debugScripts;
/**
* Singleton pattern.
*/
- private static ESboxPythonDebugger instance;
+ protected static PythonDebugger instance;
/**
* Constructor.
* @throws CoreException
*/
private ESboxPythonDebugger() {
- initDebugScriptList();
-
+ super();
}
- private void initDebugScriptList() {
- debugScripts = new String[] {
- "pydevd_additional_thread_info.py",
- "pydevd_comm.py",
- "pydevd_constants.py",
- "pydevd_file_utils.py",
- "pydevd_frame.py",
- "pydevd_io.py",
- "pydevd_resolver.py",
- "pydevd_tracing.py",
- "pydevd_vars.py",
- "pydevd_vm_type.py",
- "pydevd.py"
- };
- }
-
/**
* Returns a unique instance of ESboxPythonDebugger
*/
- public static ESboxPythonDebugger getInstance() {
+ public static PythonDebugger getInstance() {
if (instance == null) {
instance = new ESboxPythonDebugger();
}
@@ -123,11 +84,8 @@
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 5);
subMonitor.beginTask("Launching python", 1);
- if (clientIP.equals(DEFAULT_LOCAL_CLIENT_IP))
- copyDebugScriptsToWorkspace();
- else
- copyDebugScriptsToDevice();
-
+ copyDebugScriptsToWorkspace();
+
// Launch & connect to the debugger
RemoteDebugger debugger = new RemoteDebugger(pythonConfiguration);
debugger.startConnect(subMonitor);
@@ -136,7 +94,7 @@
exePath.toOSString(), clientIP, isRunStandalone);
ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
- Process p = launcher.execInsideSbox(cmdLine, pythonConfiguration.envp);
+ Process p = launcher.execute(cmdLine, pythonConfiguration.envp);
IProcess process = registerWithDebugPlugin(pythonConfiguration, launch, p);
subMonitor.subTask("Waiting for connection...");
@@ -171,7 +129,7 @@
return SimpleRunner.getCommandLineAsString(args);
}
- private String[] getCommandLine(PythonRunnerConfig pythonConfiguration, String[] vmArgumentsArray, String arguments,
+ protected String[] getCommandLine(PythonRunnerConfig pythonConfiguration, String[] vmArgumentsArray, String arguments,
String exePath, String clientIP, boolean isRunStandalone) throws CoreException {
List<String> cmdArgs = new ArrayList<String>();
@@ -213,127 +171,5 @@
cmdArgs.toArray(retVal);
return retVal;
}
-
- private IStringVariableManager getStringVariableManager() {
- // TODO Auto-generated method stub
- return VariablesPlugin.getDefault().getStringVariableManager();
- }
-
- private void copyDebugScriptsToDevice() {
- Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
- String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
- String localMountPoint = "";
- if (!sbrshBinPath.equals("")) {
- String tokens[] = sbrshBinPath.split("#");
- localMountPoint = tokens[1];
- }
-
- for (int i = 0; i < debugScripts.length; i++) {
- verifyScript(localMountPoint + File.separatorChar + ".esbox" ,debugScripts[i]);
- }
- }
-
- private void copyDebugScriptsToWorkspace() {
- Preferences preferences = CoreActivator.getDefault().getPluginPreferences();
- String prefix = preferences.getString(ESboxPreferenceConstants.RUN_SCRIPT_LOC.toString());
-
- for (int i = 0; i < debugScripts.length; i++) {
- verifyScript(prefix,debugScripts[i]);
- }
- }
-
- private void verifyScript(String prefix, String name) {
- File runScript = new File(prefix + File.separator + name);
- if (!runScript.exists()) {
- File runScriptPath = new File(prefix);
- if( !runScriptPath.exists() )
- runScriptPath.mkdir();
- copyScriptToWorkspace(prefix + File.separator + name, name);
- }
- }
-
- private void copyScriptToWorkspace(String location, String name) {
- try {
- BufferedReader in = new BufferedReader(new InputStreamReader(PythonDebugActivator.getDefault().getInputStream("./python_debug_scripts/" + name)));
- BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(location)));
-
- String line = "";
- String newLine = System.getProperty("line.separator");;
- while ( (line = in.readLine()) != null) {
- out.write(line);
- out.write(newLine);
- }
-
- in.close();
- out.close();
- } catch(IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * The debug plugin needs to be notified about our process.
- * It'll then display the appropriate UI.
- * @throws JDTNotAvailableException
- */
- private static IProcess registerWithDebugPlugin(PythonRunnerConfig config, ILaunch launch, Process p) throws JDTNotAvailableException {
- HashMap processAttributes = new HashMap();
- processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString());
- return registerWithDebugPlugin(config.resource.lastSegment(), launch,p, processAttributes);
- }
-
- /**
- * The debug plugin needs to be notified about our process.
- * It'll then display the appropriate UI.
- */
- private static IProcess registerWithDebugPlugin(String label, ILaunch launch, Process p, Map processAttributes) {
- processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE);
- processAttributes.put(IProcess.ATTR_PROCESS_LABEL, label);
- processAttributes.put(DebugPlugin.ATTR_CAPTURE_OUTPUT, "true");
- return DebugPlugin.newProcess(launch,p, label, processAttributes);
- }
-
- private ILaunchConfiguration createDefaultLaunchConfiguration(String launchConfigurationType, String projectName,
- String exePath, String location, String arguments, String vmArguments) {
- ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType);
- if (type == null) {
- //reportError("Python launch configuration not found", null);
- return null;
- }
-
- StringBuffer buffer = new StringBuffer(projectName);
- buffer.append(" ");
- String name = buffer.toString().trim();
- name = manager.generateUniqueLaunchConfigurationNameFrom(name);
-
- try {
-
- ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name);
-
- workingCopy.setAttribute(Constants.ATTR_PROJECT, projectName);
- workingCopy.setAttribute(Constants.ATTR_RESOURCE_TYPE, IResource.FILE);
- workingCopy.setAttribute(Constants.ATTR_INTERPRETER, Constants.ATTR_INTERPRETER_DEFAULT);
-
- workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
- workingCopy.setAttribute(Constants.ATTR_LOCATION, location);
- workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY, exePath.substring(0, exePath.lastIndexOf('/')));
- workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, arguments);
- workingCopy.setAttribute(Constants.ATTR_VM_ARGUMENTS, vmArguments);
-
- // Common Tab Arguments
- CommonTab tab = new CommonTab();
- tab.setDefaults(workingCopy);
- tab.dispose();
- return workingCopy.doSave();
- } catch (NotConfiguredInterpreterException e) {
- //reportError(e.getMessage(), e);
- throw e;
- } catch (CoreException e) {
- //reportError(null, e);
- return null;
- }
- }
-
}
Added: trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonRemoteDebugger.java
===================================================================
--- trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonRemoteDebugger.java (rev 0)
+++ trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonRemoteDebugger.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.python.debug.debugger;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.SocketTimeoutException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.IProcess;
+import org.indt.esbox.core.CoreActivator;
+import org.indt.esbox.core.ESboxPreferenceConstants;
+import org.indt.esbox.core.scratchbox.SbrshCommandLauncher;
+import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+import org.python.copiedfromeclipsesrc.JDTNotAvailableException;
+import org.python.pydev.debug.core.PydevDebugPlugin;
+import org.python.pydev.debug.model.PyDebugTarget;
+import org.python.pydev.debug.model.PySourceLocator;
+import org.python.pydev.debug.model.remote.RemoteDebugger;
+import org.python.pydev.debug.ui.launching.PythonRunnerConfig;
+import org.python.pydev.runners.SimpleRunner;
+
+/**
+ *
+ */
+public class ESboxPythonRemoteDebugger extends PythonDebugger {
+
+
+ /**
+ * Singleton pattern.
+ */
+ protected static PythonDebugger instance;
+
+ /**
+ * Constructor.
+ * @throws CoreException
+ */
+ private ESboxPythonRemoteDebugger() {
+ super();
+ }
+
+ /**
+ * Returns a unique instance of ESboxPythonDebugger
+ */
+ public static PythonDebugger getInstance() {
+ if (instance == null) {
+ instance = new ESboxPythonRemoteDebugger();
+ }
+ return instance;
+ }
+
+ public void debugPython(IProject project, String mode, ILaunch launch, IProgressMonitor monitor,
+ IPath exePath, String arguments, String[] vmArgumentsArray, String vmArguments,
+ String clientIP, boolean isRunStandalone) throws CoreException, IOException {
+ String location = project.getLocation().toOSString();
+ String projectName = project.getName();
+ ILaunchConfiguration configuration = createDefaultLaunchConfiguration("esboxPythonLocalLaunchType",
+ projectName, exePath.toOSString(), location, arguments, vmArguments);
+ PythonRunnerConfig pythonConfiguration = new PythonRunnerConfig(configuration, mode, "RUN_REGULAR");
+
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 5);
+ subMonitor.beginTask("Launching python", 1);
+
+ copyDebugScriptsToDevice();
+
+ // Launch & connect to the debugger
+ RemoteDebugger debugger = new RemoteDebugger(pythonConfiguration);
+ debugger.startConnect(subMonitor);
+ subMonitor.subTask("Constructing command_line...");
+ String cmdLine = getCommandLineAsString(pythonConfiguration, vmArgumentsArray, arguments,
+ exePath.lastSegment(), clientIP, isRunStandalone);
+
+ ScratchboxCommandLauncher launcher = new SbrshCommandLauncher();
+
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+ IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+
+ String remoteMounPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ remoteMounPoint = tokens[2];
+ }
+
+ String args[] = new String[] { "-d", remoteMounPoint, cmdLine };
+ Process p = launcher.execute(command, args, pythonConfiguration.envp, new Path("."));
+ IProcess process = registerWithDebugPlugin(pythonConfiguration, launch, p);
+
+ subMonitor.subTask("Waiting for connection...");
+ try {
+ boolean userCanceled = debugger.waitForConnect(subMonitor, p, process);
+ if (userCanceled) {
+ debugger.dispose();
+ return;
+ }
+ }
+ catch (Exception ex) {
+ process.terminate();
+ p.destroy();
+ String message = "Unexpected error setting up the debugger";
+ if (ex instanceof SocketTimeoutException)
+ message = "Timed out after " + Float.toString(pythonConfiguration.acceptTimeout/1000) + " seconds while waiting for python script to connect.";
+ throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, message, ex));
+ }
+ subMonitor.subTask("Done");
+ // hook up debug model, and we are off & running
+ PyDebugTarget t = new PyDebugTarget(launch, process, pythonConfiguration.resource, debugger);
+ launch.setSourceLocator(new PySourceLocator());
+ debugger.startTransmission(); // this starts reading/writing from sockets
+ t.initialize();
+ t.addConsoleInputListener();
+ }
+
+ public String getCommandLineAsString(PythonRunnerConfig pythonConfiguration, String[] vmArgumentsArray, String arguments,
+ String exePath, String clientIP, boolean isRunStandalone) throws JDTNotAvailableException, CoreException {
+ String[] args;
+ args = getCommandLine(pythonConfiguration, vmArgumentsArray, arguments, exePath, clientIP, isRunStandalone);
+ return SimpleRunner.getCommandLineAsString(args);
+ }
+
+ protected String[] getCommandLine(PythonRunnerConfig pythonConfiguration, String[] vmArgumentsArray, String arguments,
+ String exePath, String clientIP, boolean isRunStandalone) throws CoreException {
+
+ List<String> cmdArgs = new ArrayList<String>();
+
+ if (isRunStandalone) {
+ cmdArgs.add("run-standalone.sh");
+ }
+
+ if(vmArgumentsArray != null){
+ for (int i = 0; i < vmArgumentsArray.length; i++){
+ cmdArgs.add(vmArgumentsArray[i]);
+ }
+ }
+
+ String scriptLocation = ".esbox" + File.separator;
+
+ cmdArgs.add("python");
+ cmdArgs.add(scriptLocation + "pydevd.py");
+ cmdArgs.add("--vm_type");
+ cmdArgs.add("python");
+ cmdArgs.add("--client");
+ cmdArgs.add(clientIP);
+ cmdArgs.add("--port");
+ cmdArgs.add(Integer.toString(pythonConfiguration.getDebugPort()));
+ cmdArgs.add("--file");
+ cmdArgs.add(exePath);
+
+ String runArguments[] = null;
+ if (arguments != null) {
+ String expanded = getStringVariableManager().performStringSubstitution(arguments);
+ runArguments = PythonRunnerConfig.parseStringIntoList(expanded);
+ }
+
+ for (int i=0; runArguments != null && i<runArguments.length; i++){
+ cmdArgs.add(runArguments[i]);
+ }
+
+ String[] retVal = new String[cmdArgs.size()];
+ cmdArgs.toArray(retVal);
+ return retVal;
+ }
+
+}
Added: trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/PythonDebugger.java
===================================================================
--- trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/PythonDebugger.java (rev 0)
+++ trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/PythonDebugger.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.python.debug.debugger;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.indt.esbox.core.CoreActivator;
+import org.indt.esbox.core.ESboxPreferenceConstants;
+import org.indt.esbox.python.debug.PythonDebugActivator;
+import org.python.copiedfromeclipsesrc.JDTNotAvailableException;
+import org.python.pydev.debug.core.Constants;
+import org.python.pydev.debug.ui.launching.PythonRunnerConfig;
+import org.python.pydev.ui.NotConfiguredInterpreterException;
+
+/**
+ *
+ */
+public abstract class PythonDebugger {
+
+ protected String[] debugScripts;
+
+ /**
+ * Constructor.
+ * @throws CoreException
+ */
+ protected PythonDebugger() {
+ initDebugScriptList();
+ }
+
+ protected void initDebugScriptList() {
+ debugScripts = new String[] {
+ "pydevd_additional_thread_info.py",
+ "pydevd_comm.py",
+ "pydevd_constants.py",
+ "pydevd_file_utils.py",
+ "pydevd_frame.py",
+ "pydevd_io.py",
+ "pydevd_resolver.py",
+ "pydevd_tracing.py",
+ "pydevd_vars.py",
+ "pydevd_vm_type.py",
+ "pydevd.py"
+ };
+ }
+
+ protected IStringVariableManager getStringVariableManager() {
+ // TODO Auto-generated method stub
+ return VariablesPlugin.getDefault().getStringVariableManager();
+ }
+
+ protected void copyDebugScriptsToDevice() {
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+
+ String localMountPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ localMountPoint = tokens[1];
+ }
+
+ for (int i = 0; i < debugScripts.length; i++) {
+ verifyScript(localMountPoint + File.separatorChar + ".esbox" ,debugScripts[i]);
+ }
+ }
+
+ protected void copyDebugScriptsToWorkspace() {
+ Preferences preferences = CoreActivator.getDefault().getPluginPreferences();
+ String prefix = preferences.getString(ESboxPreferenceConstants.RUN_SCRIPT_LOC.toString());
+
+ for (int i = 0; i < debugScripts.length; i++) {
+ verifyScript(prefix,debugScripts[i]);
+ }
+ }
+
+ protected void verifyScript(String prefix, String name) {
+ File runScript = new File(prefix + File.separator + name);
+ if (!runScript.exists()) {
+ File runScriptPath = new File(prefix);
+ if( !runScriptPath.exists() )
+ runScriptPath.mkdir();
+ copyScriptToWorkspace(prefix + File.separator + name, name);
+ }
+ }
+
+ protected void copyScriptToWorkspace(String location, String name) {
+ try {
+ BufferedReader in = new BufferedReader(new InputStreamReader(PythonDebugActivator.getDefault().getInputStream("./python_debug_scripts/" + name)));
+ BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(location)));
+
+ String line = "";
+ String newLine = System.getProperty("line.separator");;
+ while ( (line = in.readLine()) != null) {
+ out.write(line);
+ out.write(newLine);
+ }
+
+ in.close();
+ out.close();
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * The debug plugin needs to be notified about our process.
+ * It'll then display the appropriate UI.
+ * @throws JDTNotAvailableException
+ */
+ protected static IProcess registerWithDebugPlugin(PythonRunnerConfig config, ILaunch launch, Process p) throws JDTNotAvailableException {
+ HashMap processAttributes = new HashMap();
+ processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString());
+ return registerWithDebugPlugin(config.resource.lastSegment(), launch,p, processAttributes);
+ }
+
+ /**
+ * The debug plugin needs to be notified about our process.
+ * It'll then display the appropriate UI.
+ */
+ protected static IProcess registerWithDebugPlugin(String label, ILaunch launch, Process p, Map processAttributes) {
+ processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE);
+ processAttributes.put(IProcess.ATTR_PROCESS_LABEL, label);
+ processAttributes.put(DebugPlugin.ATTR_CAPTURE_OUTPUT, "true");
+ return DebugPlugin.newProcess(launch,p, label, processAttributes);
+ }
+
+ protected ILaunchConfiguration createDefaultLaunchConfiguration(String launchConfigurationType, String projectName,
+ String exePath, String location, String arguments, String vmArguments) {
+ ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType);
+ if (type == null) {
+ //reportError("Python launch configuration not found", null);
+ return null;
+ }
+
+ StringBuffer buffer = new StringBuffer(projectName);
+ buffer.append(" ");
+ String name = buffer.toString().trim();
+ name = manager.generateUniqueLaunchConfigurationNameFrom(name);
+
+ try {
+
+ ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name);
+
+ workingCopy.setAttribute(Constants.ATTR_PROJECT, projectName);
+ workingCopy.setAttribute(Constants.ATTR_RESOURCE_TYPE, IResource.FILE);
+ workingCopy.setAttribute(Constants.ATTR_INTERPRETER, Constants.ATTR_INTERPRETER_DEFAULT);
+
+ workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
+ workingCopy.setAttribute(Constants.ATTR_LOCATION, location);
+ workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY, exePath.substring(0, exePath.lastIndexOf('/')));
+ workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, arguments);
+ workingCopy.setAttribute(Constants.ATTR_VM_ARGUMENTS, vmArguments);
+
+ // Common Tab Arguments
+ CommonTab tab = new CommonTab();
+ tab.setDefaults(workingCopy);
+ tab.dispose();
+ return workingCopy.doSave();
+ } catch (NotConfiguredInterpreterException e) {
+ //reportError(e.getMessage(), e);
+ throw e;
+ } catch (CoreException e) {
+ //reportError(null, e);
+ return null;
+ }
+ }
+
+ public abstract void debugPython(IProject project, String mode, ILaunch launch, IProgressMonitor monitor,
+ IPath exePath, String arguments, String[] vmArgumentsArray, String vmArguments,
+ String clientIP, boolean isRunStandalone) throws CoreException, IOException;
+
+ protected abstract String getCommandLineAsString(PythonRunnerConfig pythonConfiguration, String[] vmArgumentsArray, String arguments,
+ String exePath, String clientIP, boolean isRunStandalone) throws JDTNotAvailableException, CoreException;
+
+ protected abstract String[] getCommandLine(PythonRunnerConfig pythonConfiguration, String[] vmArgumentsArray, String arguments,
+ String exePath, String clientIP, boolean isRunStandalone) throws CoreException;
+
+}
Modified: trunk/org.indt.esbox.python.launch/plugin.xml
===================================================================
--- trunk/org.indt.esbox.python.launch/plugin.xml 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.python.launch/plugin.xml 2008-02-11 18:03:03 UTC (rev 399)
@@ -21,14 +21,14 @@
delegate="org.indt.esbox.python.launch.oprofile.OProfilePythonConfigurationDelegate"
id="esboxPythonOProfileLaunchType"
modes="run"
- name="OProfile Profiler"
+ name="OProfile Profiler (Python)"
public="true">
</launchConfigurationType>
<launchConfigurationType
delegate="org.indt.esbox.python.launch.valgrind.ValgrindPythonConfigurationDelegate"
id="esboxPythonValgrindLaunchType"
modes="run"
- name="Valgrind Profiler"
+ name="Valgrind Profiler (Python)"
public="true">
</launchConfigurationType>
</extension>
@@ -155,7 +155,7 @@
class="org.indt.esbox.python.launch.valgrind.ValgrindPythonLaunchShortcut"
icon="icons/valgrind.png"
id="valgrindPythonShortcut"
- label="Valgrind Profiler"
+ label="Valgrind Profiler (Python)"
modes="run">
<contextualLaunch>
<enablement>
@@ -191,7 +191,7 @@
class="org.indt.esbox.python.launch.oprofile.OProfilePythonShortcut"
icon="icons/maemo_project.png"
id="oprofilePythonShortcut"
- label="OProfile Profiler"
+ label="OProfile Profiler (Python)"
modes="run">
<contextualLaunch>
<enablement>
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local/ESboxPythonLaunchConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local/ESboxPythonLaunchConfigurationDelegate.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local/ESboxPythonLaunchConfigurationDelegate.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -30,8 +30,6 @@
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.indt.esbox.core.ESboxPreferenceConstants;
import org.indt.esbox.core.ESboxProjectProperties;
import org.indt.esbox.core.ESboxScriptLauncher;
import org.indt.esbox.core.ErrorLogger;
@@ -39,6 +37,7 @@
import org.indt.esbox.core.scratchbox.ScratchboxException;
import org.indt.esbox.core.scratchbox.ScratchboxFacade;
import org.indt.esbox.python.debug.debugger.ESboxPythonDebugger;
+import org.indt.esbox.python.debug.debugger.PythonDebugger;
import org.indt.esbox.python.launch.PythonLaunchActivator;
import org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate;
import org.indt.esbox.python.launch.internal.core.ESboxPythonLaunchConstants;
@@ -92,7 +91,7 @@
}
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- ESboxPythonDebugger debugger = ESboxPythonDebugger.getInstance();
+ PythonDebugger debugger = ESboxPythonDebugger.getInstance();
String[] vmArgumentsArray = super.getVMArgumentsAsArray(configuration);
String vmArguments = super.getVMArguments(configuration);
String programArguments = super.getArguments(configuration);
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -17,6 +17,7 @@
import java.util.Properties;
import org.eclipse.cdt.core.CommandLauncher;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -31,8 +32,11 @@
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.ScratchboxCommandLauncher;
import org.indt.esbox.python.debug.debugger.ESboxPythonDebugger;
+import org.indt.esbox.python.debug.debugger.ESboxPythonRemoteDebugger;
+import org.indt.esbox.python.debug.debugger.PythonDebugger;
import org.indt.esbox.python.launch.PythonLaunchActivator;
import org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate;
import org.indt.esbox.python.launch.internal.core.ESboxPythonLaunchConstants;
@@ -89,14 +93,14 @@
// The launcher for running commands inside the Scratchbox
// environment
- InnerCommandLauncher launcher = new InnerCommandLauncher();
+ ScratchboxCommandLauncher launcher = new SbrshCommandLauncher();
File wd = getWorkingDirectory(configuration);
if (wd == null) {
wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- ESboxPythonDebugger debugger = ESboxPythonDebugger.getInstance();
+ PythonDebugger debugger = ESboxPythonRemoteDebugger.getInstance();
String[] vmArgumentsArray = super.getVMArgumentsAsArray(configuration);
String vmArguments = super.getVMArguments(configuration);
String programArguments = super.getArguments(configuration);
@@ -123,14 +127,14 @@
IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
String program = isRunStandalone ? "run-standalone.sh " : "";
- program += "./" + exePath.lastSegment();
+ program += "python -u " + exePath.lastSegment();
String args[] = new String[] { "-d", remoteMounPoint, program };
Process process;
process = launcher.execute(command, args,
- env, new Path(wd.getAbsolutePath()));
+ env, new Path("."));
monitor.worked(3);
DebugPlugin.newProcess(launch, process,
@@ -153,56 +157,6 @@
@Override
protected String getPluginID() {
return PythonLaunchActivator.getBundleInfo().getPluginID();
- }
-
- /**
- *
- */
- class InnerCommandLauncher extends ScratchboxCommandLauncher {
-
- /*
- * (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);
-
- fProcess = Runtime.getRuntime().exec(fCommandArgs, new String[] {}, changeToDirectory.toFile());
-
- 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;
- }
}
}
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -10,11 +10,23 @@
*******************************************************************************/
package org.indt.esbox.python.launch.valgrind;
+import java.util.List;
+
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+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.ToolRunnerInfo;
+import org.indt.esbox.python.launch.PythonLaunchActivator;
import org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate;
+import org.indt.esbox.python.launch.internal.core.ESboxPythonLaunchConstants;
/**
*
@@ -28,7 +40,7 @@
@Override
protected String getPluginID() {
// TODO Auto-generated method stub
- return null;
+ return PythonLaunchActivator.PLUGIN_ID;
}
/* (non-Javadoc)
@@ -37,7 +49,48 @@
@Override
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ monitor.beginTask("Launching the application on Device", 10);
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ IPath exePath = verifyProgramPath(configuration);
+
+ ITool valgrind = ESboxToolEngine.getInstance().getTool("Valgrind")[0];
+ ToolRunnerInfo valgrindInfo = null;
+
+ try {
+ valgrindInfo = valgrind.getProvider().getRunner().createToolRunnerInfo();
+ } catch (ESboxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ boolean isRunStandalone = configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_RUN_STANDALONE, ESboxPythonLaunchConstants.RUN_STANDALONE_DEFAULT);
+
+ String args[] = new String[] { "-q --tool=memcheck --leak-check=yes", isRunStandalone ? "run-standalone.sh " : "" , exePath.toOSString() };
+
+ List<String> cmdArray = valgrindInfo.getCommandLine();
+ for (int i = 0; i < args.length; i++) {
+ cmdArray.add(args[i]);
+ }
+
+ ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
+ Process process = launcher.execute(valgrindInfo);
+ try {
+ valgrind.getProvider().getRunner().trackProcess(process);
+ } catch (ESboxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ monitor.worked(3);
+ DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
}
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationTabGroup.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationTabGroup.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationTabGroup.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -12,6 +12,8 @@
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.indt.esbox.python.launch.internal.ui.MainModuleTab;
/**
*
@@ -23,8 +25,9 @@
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- // TODO Auto-generated method stub
-
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new MainModuleTab() };
+ setTabs(tabs);
}
}
Modified: trunk/org.indt.esbox.python.ui/plugin.xml
===================================================================
--- trunk/org.indt.esbox.python.ui/plugin.xml 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.python.ui/plugin.xml 2008-02-11 18:03:03 UTC (rev 399)
@@ -33,14 +33,14 @@
<action
class="org.indt.esbox.ui.actions.CreateDebianPackageAction"
enablesFor="1"
- id="org.indt.esbox.python.ui.action2"
+ id="org.indt.esbox.python.ui.createdebianpackage"
label="Create Debian Package"
menubarPath="org.indt.esbox.python.ui.menu/content">
</action>
<action
class="org.indt.esbox.ui.actions.DeployDebianPackageAction"
enablesFor="1"
- id="org.indt.esbox.python.ui.createdebianpackage"
+ id="org.indt.esbox.python.ui.installdebianpackage"
label="Install Debian Package on Device"
menubarPath="org.indt.esbox.python.ui.menu/content">
</action>
Modified: trunk/org.indt.esbox.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.indt.esbox.ui/META-INF/MANIFEST.MF 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.ui/META-INF/MANIFEST.MF 2008-02-11 18:03:03 UTC (rev 399)
@@ -23,6 +23,7 @@
org.eclipse.ltk.core.refactoring
Eclipse-LazyStart: true
Export-Package: org.indt.esbox.ui,
+ org.indt.esbox.ui.actions,
org.indt.esbox.ui.connection,
org.indt.esbox.ui.wizards
Bundle-Localization: plugin
Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/UIActivator.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/UIActivator.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/UIActivator.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -16,16 +16,21 @@
import java.util.ResourceBundle;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.core.templateengine.TemplateInfo;
import org.eclipse.cdt.core.templateengine.TemplateInitializationException;
import org.eclipse.cdt.managedbuilder.gnu.ui.GnuUIPlugin;
import org.eclipse.cdt.ui.templateengine.Template;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.env.ESboxEnvironmentVariableManager;
import org.indt.esbox.core.templateengine.ESboxTemplateEngine;
+import org.indt.esbox.core.tool.IToolListener;
+import org.indt.esbox.core.tool.valgrind.ValgrindToolRunner;
import org.osgi.framework.BundleContext;
/**
@@ -54,6 +59,7 @@
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ subscribeDefaultListeners();
}
/*
@@ -135,7 +141,7 @@
*/
public Template[] getTemplates() {
TemplateInfo[] templateInfoArray = ESboxTemplateEngine.getDefault().getTemplateInfos();
- List/*<Template>*/ templatesList = new ArrayList/*<Template>*/();
+ List<Template> templatesList = new ArrayList<Template>();
for (int i=0; i<templateInfoArray.length; i++) {
try {
templatesList.add(new Template(templateInfoArray[i]));
@@ -147,4 +153,13 @@
return (Template[]) templatesList.toArray(new Template[templatesList.size()]);
}
+ private void subscribeDefaultListeners() throws PartInitException {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IViewPart valgrindView = workbenchWindow.getActivePage().showView("org.indt.esbox.ui.views.valgrindView");
+ ValgrindToolRunner.getInstance().addListener((IToolListener)valgrindView);
+
+ // add listeners to oprofile
+ }
+
}
Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -12,8 +12,8 @@
package org.indt.esbox.ui.views;
import java.io.BufferedReader;
-import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
@@ -44,9 +44,11 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
+import org.indt.esbox.core.tool.IToolListener;
+import org.indt.esbox.core.tool.ToolEvent;
import org.indt.esbox.ui.UIActivator;
-public class OProfileView extends ViewPart {
+public class OProfileView extends ViewPart implements IToolListener {
/**
* Table that contains the oprofile entries
@@ -204,17 +206,8 @@
}
});
- initTable();
-
+ initTable();
table.pack();
-
- try {
- fillTable();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
}
public void initTable() {
@@ -229,8 +222,8 @@
}
- public void fillTable() throws IOException {
- BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("/home/raul/oprofile_output/opreport_e.txt")));
+ public void fillTable(InputStream input) throws IOException {
+ BufferedReader in = new BufferedReader(new InputStreamReader(input));
String line = "";
while( (line = in.readLine()) != null) {
@@ -252,9 +245,9 @@
} catch (NumberFormatException e) {
}
- }
-
- }
+ }
+ }
+ table.pack();
}
public List<String> getTokens(String line) {
@@ -282,8 +275,7 @@
result.add(element);
element = "";
}
- }
-
+ }
return result;
}
@@ -304,4 +296,13 @@
return UIActivator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
}
-}
+ public void toolExecuted(ToolEvent event) {
+ Process process = (Process)event.getSource();
+ try {
+ fillTable(process.getInputStream());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/ValgrindView.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/ValgrindView.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/ValgrindView.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 INdT.
+ * Copyright (c) 2007-2008 INdT.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,8 +12,8 @@
package org.indt.esbox.ui.views;
import java.io.BufferedReader;
-import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
@@ -34,9 +34,10 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.DrillDownAdapter;
import org.eclipse.ui.part.ViewPart;
-import org.indt.esbox.ui.UIActivator;
+import org.indt.esbox.core.tool.IToolListener;
+import org.indt.esbox.core.tool.ToolEvent;
-public class ValgrindView extends ViewPart {
+public class ValgrindView extends ViewPart implements IToolListener {
private TreeViewer viewer;
private DrillDownAdapter drillDownAdapter;
@@ -98,13 +99,8 @@
}
public Object[] getElements(Object parent) {
if (parent.equals(getViewSite())) {
- if (invisibleRoot==null) {
- try {
- initialize();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ if (invisibleRoot == null)
+ invisibleRoot = new TreeParent("");
return getChildren(invisibleRoot);
}
return getChildren(parent);
@@ -126,28 +122,7 @@
return ((TreeParent)parent).hasChildren();
return false;
}
-
- private void initialize() throws IOException {
- BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("/home/romulo/valgrind.out")));
- invisibleRoot = new TreeParent("");
- TreeParent root = new TreeParent("");
- String line = "";
- while( (line = in.readLine()) != null) {
- if (line.startsWith("==") && !line.endsWith("==")) {
- if (isRoot(line)) {
- root = new TreeParent(line.trim());
- invisibleRoot.addChild(root);
- } else {
- root.addChild(new TreeObject(line));
- }
- }
- }
-
- }
- private boolean isRoot(String line) {
- return !(line.contains(" at ") || line.contains(" by "));
- }
}
class ViewLabelProvider extends LabelProvider {
@@ -177,10 +152,12 @@
public void createPartControl(Composite parent) {
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
drillDownAdapter = new DrillDownAdapter(viewer);
+
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setSorter(new NameSorter());
viewer.setInput(getViewSite());
+
makeActions();
createMenu();
}
@@ -188,11 +165,11 @@
private void makeActions() {
removeAction = new Action() {
public void run() {
- for (Object o : invisibleRoot.children) {
- TreeParent tp = (TreeParent) o;
- invisibleRoot.removeChild(tp);
- }
- viewer.refresh();
+ TreeObject[] children = invisibleRoot.getChildren();
+ for (TreeObject treeObject : children) {
+ invisibleRoot.removeChild(treeObject);
+ }
+ refreshTree();
}
};
removeAction.setText("Delete");
@@ -205,14 +182,53 @@
IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
toolBar.add(removeAction);
}
-
- @Override
- public void setFocus() {
- //TODO
+
+ public void fillTree(InputStream input) throws IOException {
+ BufferedReader in = new BufferedReader(new InputStreamReader(input));
+ invisibleRoot = new TreeParent("");
+ TreeParent root = new TreeParent("");
+ String line = "";
+ while( (line = in.readLine()) != null) {
+ line = line.trim();
+ if (line.startsWith("==") && !line.endsWith("==")) {
+ if (isRoot(line)) {
+ root = new TreeParent(line);
+ invisibleRoot.addChild(root);
+ } else {
+ root.addChild(new TreeObject(line));
+ }
+ }
+ }
+ refreshTree();
}
+ private void refreshTree() {
+ getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ viewer.refresh();
+ }
+ });
+ }
+
+ private boolean isRoot(String line) {
+ return !(line.contains(" at ") || line.contains(" by "));
+ }
+
private Shell getShell() {
- return UIActivator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+ return getViewSite().getShell();
}
+
+ public void toolExecuted(ToolEvent event) {
+ Process process = (Process)event.getSource();
+ try {
+ fillTree(process.getErrorStream());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void setFocus() { }
}
Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -11,16 +11,17 @@
package org.indt.esbox.ui.wizards;
+import java.io.IOException;
+
import org.eclipse.jface.wizard.Wizard;
import org.indt.esbox.core.ESboxScriptLauncher;
import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.core.StreamMonitor;
import org.indt.esbox.core.scratchbox.ScratchboxException;
import org.indt.esbox.ui.UIActivator;
import org.indt.esbox.ui.connection.ExecConnection;
import org.indt.esbox.ui.connection.Sftp;
-import com.jcraft.jsch.SftpException;
-
public class DeployDebianPackageWizard extends Wizard {
private DeployDebianPackageWizardPage deployPage;
@@ -58,12 +59,48 @@
ESboxScriptLauncher.getInstance().makeDebianPackage(deployPage.getProject().getLocation());
}
+// private void copyPackage() throws InterruptedException {
+// String packageLocation = deployPage.getPackageLocation();
+// String packageName = (new Path(packageLocation)).lastSegment();
+// String localMountPoint = deployPage.getLocalPoint();
+// copyFile(packageLocation,localMountPoint + File.separatorChar + packageName);
+// }
+//
+// private void installDebianPackage() {
+// String packageLocation = deployPage.getPackageLocation();
+// String packageName = (new Path(packageLocation)).lastSegment();
+// String remoteMountPoint = deployPage.getInstallLocation();
+// IPath dpkgCommand = new Path("dpkg");
+// String args[] = new String[] { "-i", remoteMountPoint + File.separator + packageName };
+// ScratchboxCommandLauncher launcher = new SbrshCommandLauncher();
+//
+// Process process = launcher.execute(dpkgCommand, args, new String[] { }, new Path("."));
+// try {
+// process.waitFor();
+// } catch (InterruptedException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+//
+// 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("."));
+//
+// process.waitFor();
+// }
+
private void installDebianPackage() {
ExecConnection execConnection = ExecConnection.getInstance();
execConnection.setCommand("dpkg -i " + getPackageRemoteLocation());
try {
execConnection.start();
- } catch (ScratchboxException e) {
+ // print all output to console
+ new StreamMonitor(execConnection.getInputStream(), true, new String(
+ "Installing .deb package"));
+ new StreamMonitor(execConnection.getErrInputStream(), true, new String(
+ "Installing .deb package"));
+ } catch (Exception e) {
ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
errorLogger.logAndShowError("Connection error", e);
}
Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizardPage.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizardPage.java 2008-02-11 17:22:22 UTC (rev 398)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizardPage.java 2008-02-11 18:03:03 UTC (rev 399)
@@ -17,6 +17,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
@@ -27,6 +28,7 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
@@ -42,13 +44,14 @@
private Button createDeb, installDeb;
private Text packageName;
- private Text remoteInstallLocation;
+ private Text remotePoint;
+ private Text localPoint;
private Button browserButton;
private FileDialog fileDialog;
protected DeployDebianPackageWizardPage() {
- super("Deploy Debebian Package");
- setTitle("Deploy Debebian Package");
+ super("Deploy Debian Package");
+ setTitle("Deploy Debian Package");
setDescription("Deploy a Debian Package in device");
setPageComplete(false);
}
@@ -57,7 +60,7 @@
Composite composite = createComposite(parent);
- project = ( (IProject) extractSelection() );
+ project = (IProject) extractSelection();
createText(composite, "Project Name: ");
@@ -67,9 +70,9 @@
fileDialog = new FileDialog(getShell(),SWT.OPEN);
fileDialog.setFilterPath(CoreActivator.getDefault().getPluginPreferences().getString(ESboxPreferenceConstants.SBOX_WORKSPACE.toString()));
- createRemoteLocationGroup(composite);
+ createPackageGroup(composite);
- createLocationGroup(composite);
+ createLocationGroup(composite);
/* Separator */
new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -94,20 +97,48 @@
return composite;
}
- private void createRemoteLocationGroup(Composite composite) {
- Composite remoteLocationGroup = new Composite(composite, SWT.NONE);
- remoteLocationGroup.setLayout(new GridLayout(2, false));
- remoteLocationGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(remoteLocationGroup, SWT.LEFT);
- label.setText("Remote Location: ");
+ private void createLocationGroup(Composite composite) {
+ Composite locationGroup = new Composite(composite, SWT.NONE);
+ locationGroup.setLayout(new GridLayout(6, false));
+ locationGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- remoteInstallLocation = new Text(remoteLocationGroup, SWT.BORDER | SWT.READ_ONLY);
- remoteInstallLocation.setText("/home/user");
- remoteInstallLocation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+
+ String remoteMounPoint = "";
+ String localMountPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ localMountPoint = tokens[1];
+ remoteMounPoint = tokens[2];
+ }
+
+ Label labelRemote = new Label(locationGroup, SWT.LEFT);
+ labelRemote.setText("Remote Point: ");
+
+ remotePoint = new Text(locationGroup, SWT.BORDER | SWT.READ_ONLY);
+ remotePoint.setText(remoteMounPoint);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 5;
+ data.minimumWidth = 240;
+ remotePoint.setLayoutData(data);
+ remotePoint.setEditable(false);
+ remotePoint.setEnabled(false);
+
+ Label labelLocal = new Label(locationGroup, SWT.LEFT);
+ labelLocal.setText("Local Point: ");
+
+ localPoint = new Text(locationGroup, SWT.BORDER | SWT.READ_ONLY);
+ localPoint.setText(localMountPoint);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 5;
+ data.minimumWidth = 240;
+ localPoint.setLayoutData(data);
+ localPoint.setEditable(false);
+ localPoint.setEnabled(false);
}
- private void createLocationGroup(Composite parent) {
+ private void createPackageGroup(Composite parent) {
Composite packageLocationGroup = new Composite(parent, SWT.NONE);
packageLocationGroup.setLayout(new GridLayout(6, false));
packageLocationGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -146,12 +177,13 @@
Text text = new Text(textGroup, SWT.BORDER | SWT.READ_ONLY);
text.setText(getProjectName());
text.setEditable(false);
+ text.setEnabled(false);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
return text;
}
private IResource extractSelection() {
- ISelection selection = Workbench.getInstance().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ ISelection selection = Workbench.getInstance().getActiveWorkbenchWindow().getSelectionService().getSelection();
if(!(selection instanceof IStructuredSelection))
return null;
IStructuredSelection ss = (IStructuredSelection)selection;
@@ -201,7 +233,11 @@
}
public String getInstallLocation() {
- return remoteInstallLocation.getText();
+ return remotePoint.getText();
}
+
+ public String getLocalPoint() {
+ return localPoint.getText();
+ }
}
More information about the Esbox-commits
mailing list