Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 200320 Details for
Bug 353056
Add support for multiple Valgrind launch configs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Adds capability of creating multiple Valgrind remote configs via new abstract classes
abstract_valgrind.patch (text/plain), 35.90 KB, created by
Corey Ashford
on 2011-07-25 20:31:45 EDT
(
hide
)
Description:
Adds capability of creating multiple Valgrind remote configs via new abstract classes
Filename:
MIME Type:
Creator:
Corey Ashford
Created:
2011-07-25 20:31:45 EDT
Size:
35.90 KB
patch
obsolete
>commit ca39a4998dafc129fff1775f69103ccc76ee1045 >Author: Corey Ashford <cjashfor@linux.vnet.ibm.com> >Date: Mon Jul 25 16:47:38 2011 -0700 > > Valgrind remote: Add support for multiple remote Valgrind launch configs > > In order to make it possible for a another plug-in to add new Valgrind > profile launch configurations, I've made two of the internal classes > Abstract and exported: ValgrindRemoteLaunchDelegate and ValgrindRemoteTab, > now both given the "Abstract" prefix. These two abstract classes are > now extended and instantiated by internal classes of the same previous > names. The net change is unnoticeable by users of Valgrind remote. > > The only parameterization added to the configs, at this point, is the > location of the Valgrind executable, and the attribute used to acquire > the current (i.e. persistent) setting of this location. Other > parameterizations are possible, given further modifications of > the abstract classes. > > Signed-off-by: Corey Ashford <cjashfor@linux.vnet.ibm.com> > >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/META-INF/MANIFEST.MF b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/META-INF/MANIFEST.MF >index 52d8d6b..57362f2 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/META-INF/MANIFEST.MF >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/META-INF/MANIFEST.MF >@@ -2,7 +2,7 @@ Manifest-Version: 1.0 > Bundle-ManifestVersion: 2 > Bundle-Name: %Bundle-Name > Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.launch.remote;singleton:=true >-Bundle-Version: 0.8.0.qualifier >+Bundle-Version: 0.8.1.qualifier > Bundle-Activator: org.eclipse.linuxtools.internal.valgrind.launch.remote.ValgrindRemotePlugin > Bundle-Vendor: %Bundle-Vendor > Require-Bundle: org.eclipse.ui, >@@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.ui, > org.eclipse.linuxtools.profiling.launch.remote;bundle-version="0.8.0" > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Bundle-ActivationPolicy: lazy >-Export-Package: org.eclipse.linuxtools.internal.valgrind.launch.remote >+Export-Package: org.eclipse.linuxtools.internal.valgrind.launch.remote, >+ org.eclipse.linuxtools.valgrind.launch.remote > Import-Package: org.eclipse.cdt.core, > org.eclipse.cdt.core.model, > org.eclipse.cdt.debug.core, >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteLaunchDelegate.java b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteLaunchDelegate.java >index de0b179..607c200 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteLaunchDelegate.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteLaunchDelegate.java >@@ -1,193 +1,10 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 Elliott Baron >- * 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: >- * Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation >- * Red Hat Inc. - rewrite to use RemoteConnection class >- *******************************************************************************/ > package org.eclipse.linuxtools.internal.valgrind.launch.remote; > >-import java.io.IOException; >-import java.util.Map; >+import org.eclipse.linuxtools.valgrind.launch.remote.AbstractValgrindRemoteLaunchDelegate; > >-import org.eclipse.cdt.debug.core.CDebugUtils; >-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; >-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.SubMonitor; >-import org.eclipse.core.runtime.SubProgressMonitor; >-import org.eclipse.debug.core.ILaunch; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.debug.core.ILaunchManager; >-import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchConfigurationDelegate; >-import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchPlugin; >-import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin; >-import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart; >-import org.eclipse.linuxtools.profiling.launch.remote.RemoteConnection; >-import org.eclipse.linuxtools.profiling.launch.remote.RemoteConnectionException; >-import org.eclipse.linuxtools.valgrind.core.IValgrindMessage; >-import org.eclipse.linuxtools.valgrind.launch.IValgrindOutputDirectoryProvider; >- >-public class ValgrindRemoteLaunchDelegate extends >-ValgrindLaunchConfigurationDelegate { >- >- private SubMonitor monitor; >- private IPath localOutputDir; >- private IPath remoteBinFile; >- private RemoteConnection rc; >- >- public void launch(final ILaunchConfiguration config, String mode, >- final ILaunch launch, IProgressMonitor m) throws CoreException { >- if (m == null) { >- m = new NullProgressMonitor(); >- } >- >- // Clear process as we wait on it to be instantiated >- process = null; >- >- monitor = SubMonitor >- .convert( >- m, >- Messages.ValgrindRemoteLaunchDelegate_task_name, 10); >- // check for cancellation >- if (monitor.isCanceled()) { >- return; >- } >- >- this.config = config; >- this.launch = launch; >- try { >- // remove any output from previous run >- ValgrindUIPlugin.getDefault().resetView(); >- // reset stored launch data >- getPlugin().setCurrentLaunchConfiguration(null); >- getPlugin().setCurrentLaunch(null); >- >- rc = new RemoteConnection(config); >- monitor.worked(1); >- >- // Copy binary using FileSystem service >- final IPath exePath = CDebugUtils.verifyProgramPath(config); >- final IPath remoteDir = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR)); >- >- remoteBinFile = remoteDir.append(exePath.lastSegment()); >- >- rc.upload(exePath, remoteDir, new SubProgressMonitor(monitor, 1)); >- >- IPath remoteLogDir = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR)); >- outputPath = remoteLogDir.append("eclipse-valgrind-" + System.currentTimeMillis()); //$NON-NLS-1$ >- >- rc.createFolder(outputPath, new SubProgressMonitor(monitor, 1)); >- >- // Retrieve user-defined Valgrind binary location >- final IPath valgrindLocation = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC)); >- String[] arguments = getProgramArgumentsArray(config); >- // create/empty local output directory >- IValgrindOutputDirectoryProvider provider = getPlugin().getOutputDirectoryProvider(); >- try { >- localOutputDir = provider.getOutputPath(); >- createDirectory(localOutputDir); >- } catch (IOException e2) { >- // TODO Auto-generated catch block >- e2.printStackTrace(); >- } >- >- // tool that was launched >- toolID = getTool(config); >- // ask tool extension for arguments >- dynamicDelegate = getDynamicDelegate(toolID); >- String[] opts = getValgrindArgumentsArray(config); >- Map<String, String> env = (Map<String, String>) config.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>) null); >- boolean usePty = config.getAttribute( >- ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, >- ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT); >- >- String command = valgrindLocation.toString(); >- // Add valgrind options >- for (String opt : opts) { >- command += " " + opt; //$NON-NLS-1$ >- } >- // Add executable to run >- command += " " + remoteBinFile.toString(); >- // Add arguments to pass to executable >- for (String argument : arguments) { >- command += " " + argument; //$NON-NLS-1$ >- } >- @SuppressWarnings("unused") >- String[] output = rc.runCommand(command, remoteDir, new SubProgressMonitor(monitor, 1)); >- >- // delete remote binary >- rc.delete(remoteBinFile, new SubProgressMonitor(monitor, 1)); >- >- // move remote log files to local directory >- rc.download(outputPath, localOutputDir, new SubProgressMonitor(monitor, 1)); >- >- // remove remote log dir and all files under it >- rc.delete(outputPath, new SubProgressMonitor(monitor, 1)); >- >- // store these for use by other classes >- getPlugin().setCurrentLaunchConfiguration(config); >- getPlugin().setCurrentLaunch(launch); >- >- // parse Valgrind logs >- IValgrindMessage[] messages = parseLogs(localOutputDir); >- >- // create launch summary string to distinguish this launch >- launchStr = createLaunchStr(); >- >- // create view >- ValgrindUIPlugin.getDefault().createView(launchStr, toolID); >- // set log messages >- ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView(); >- view.setMessages(messages); >- monitor.worked(1); >- >- // pass off control to extender >- dynamicDelegate.handleLaunch(config, launch, localOutputDir, monitor.newChild(2)); >- >- // initialize tool-specific part of view >- dynamicDelegate.initializeView(view.getDynamicView(), launchStr, monitor.newChild(1)); >- >- // refresh view >- ValgrindUIPlugin.getDefault().refreshView(); >- >- // show view >- ValgrindUIPlugin.getDefault().showView(); >- monitor.worked(1); >- >- >- } catch (IOException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >- } catch (RemoteConnectionException e) { >- // TODO Auto-generated catch block >- abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); >- } finally { >- monitor.done(); >- m.done(); >- } >- } >- >- >- protected String createLaunchStr() { >- return config.getName() >- + " [" + getPlugin().getToolName(toolID) + " on " + rc.getId() + "] "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- } >- >- @Override >- protected String getPluginID() { >- return ValgrindLaunchPlugin.PLUGIN_ID; >- } >- >- public void onError(Throwable t) { >- // for now do nothing >+public class ValgrindRemoteLaunchDelegate extends AbstractValgrindRemoteLaunchDelegate { >+ public ValgrindRemoteLaunchDelegate() { >+ super(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, >+ ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC); > } >- >-} >\ No newline at end of file >+} >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteTab.java b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteTab.java >index d817dc9..3d3e7f3 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteTab.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteTab.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 Elliott Baron >+ * Copyright (c) 2011 Elliott Baron > * 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 >@@ -7,150 +7,18 @@ > * > * Contributors: > * Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation >- *******************************************************************************/ >+ * Corey Ashford <cjashfor@us.ibm.com> - pushed class definition to an abstract >+ * class, and this class now just extends >+ * and instantiates it. >+ *******************************************************************************/ > package org.eclipse.linuxtools.internal.valgrind.launch.remote; > >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >-import org.eclipse.linuxtools.profiling.launch.remote.RemoteTab; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.ModifyEvent; >-import org.eclipse.swt.events.ModifyListener; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Text; >+import org.eclipse.linuxtools.valgrind.launch.remote.AbstractValgrindRemoteTab; > >-public class ValgrindRemoteTab extends RemoteTab { >- >- private Text destDirText; >- private Text tmpDirText; >- private Text valgrindLocText; >- private boolean isInitializing; >+public class ValgrindRemoteTab extends AbstractValgrindRemoteTab { > > public ValgrindRemoteTab() { >- super(Messages.ValgrindRemoteTab_tab_name); >- } >- >- @Override >- protected void localCreateControl(Composite top) { >- >- Composite pathTop = new Composite(top, SWT.NONE); >- pathTop.setLayout(new GridLayout(2, false)); >- pathTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >- >- // Valgrind location >- Label valgrindLocLabel = new Label(pathTop, SWT.NONE); >- valgrindLocLabel.setText(Messages.ValgrindRemoteTab_label_location_VG); >- >- valgrindLocText = new Text(pathTop, SWT.BORDER); >- valgrindLocText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); >- valgrindLocText.addModifyListener(new ModifyListener() { >- >- public void modifyText(ModifyEvent e) { >- updateLaunchConfigurationDialog(); >- } >- }); >- >- // Destination directory >- Label destDirLabel = new Label(pathTop, SWT.NONE); >- destDirLabel.setText(Messages.ValgrindRemoteTab_label_dest_wd); >- >- destDirText = new Text(pathTop, SWT.BORDER); >- destDirText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); >- destDirText.addModifyListener(new ModifyListener() { >- >- public void modifyText(ModifyEvent e) { >- updateLaunchConfigurationDialog(); >- } >- }); >- >- Label tmpDirLabel = new Label(pathTop, SWT.NONE); >- tmpDirLabel.setText(Messages.ValgrindRemoteTab_label_tmp_dir); >- >- tmpDirText = new Text(pathTop, SWT.BORDER); >- tmpDirText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); >- tmpDirText.addModifyListener(new ModifyListener() { >- >- public void modifyText(ModifyEvent e) { >- updateLaunchConfigurationDialog(); >- } >- }); >- } >- >- @Override >- public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { >- super.setDefaults(configuration); >- configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC); >- configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR); >- configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR); >- } >- >- @Override >- public void localInitializeFrom(ILaunchConfiguration configuration) throws CoreException { >- >- String valgrindLoc = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC); >- if (valgrindLoc != null) { >- valgrindLocText.setText(valgrindLoc); >- } >- >- String destDir = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR); >- if (destDir != null) { >- destDirText.setText(destDir); >- } >- >- String tmpDir = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR); >- if (tmpDir != null) { >- tmpDirText.setText(tmpDir); >- } >- } >- >- @Override >- public void performApply(ILaunchConfigurationWorkingCopy configuration) { >- super.performApply(configuration); >- configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, valgrindLocText.getText()); >- configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, destDirText.getText()); >- configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, tmpDirText.getText()); >- } >- >- @Override >- public boolean isValid(ILaunchConfiguration launchConfig) { >- boolean valid = super.isValid(launchConfig); >- if (valid) { >- valid = valgrindLocText.getText().length() > 0; >- if (valid) { >- valid = destDirText.getText().length() > 0; >- if (valid) { >- valid = tmpDirText.getText().length() > 0; >- if (!valid) { >- setErrorMessage(Messages.ValgrindRemoteTab_error_tmp_dir); >- } >- } >- else { >- setErrorMessage(Messages.ValgrindRemoteTab_error_dest_wd); >- } >- } >- else { >- setErrorMessage(Messages.ValgrindRemoteTab_error_location_VG); >- } >- } >- else { >- setErrorMessage(Messages.ValgrindRemoteTab_error_peer); >- } >- >- return valid; >- } >- >- public String getName() { >- return Messages.ValgrindRemoteTab_tab_name; >- } >- >- @Override >- protected void updateLaunchConfigurationDialog() { >- if (!isInitializing) { >- super.updateLaunchConfigurationDialog(); >- } >+ super(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, >+ ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC); > } > } >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/valgrind/launch/remote/AbstractValgrindRemoteLaunchDelegate.java b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/valgrind/launch/remote/AbstractValgrindRemoteLaunchDelegate.java >new file mode 100644 >index 0000000..eb80134 >--- /dev/null >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/valgrind/launch/remote/AbstractValgrindRemoteLaunchDelegate.java >@@ -0,0 +1,208 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 Elliott Baron >+ * 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: >+ * Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation >+ * Red Hat Inc. - rewrite to use RemoteConnection class >+ * Corey Ashford <cjashfor@us.ibm.com> - converted to an abstract class for >+ * the purposes of providing an ability >+ * to create multiple launchers, one for >+ * each Valgrind executable that is >+ * available. >+ *******************************************************************************/ >+package org.eclipse.linuxtools.valgrind.launch.remote; >+ >+import java.io.IOException; >+ >+import java.util.Map; >+ >+import org.eclipse.cdt.debug.core.CDebugUtils; >+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; >+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.SubMonitor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchConfigurationDelegate; >+import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchPlugin; >+import org.eclipse.linuxtools.internal.valgrind.launch.remote.Messages; >+import org.eclipse.linuxtools.internal.valgrind.launch.remote.ValgrindRemoteLaunchConstants; >+import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin; >+import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart; >+import org.eclipse.linuxtools.profiling.launch.remote.RemoteConnection; >+import org.eclipse.linuxtools.profiling.launch.remote.RemoteConnectionException; >+import org.eclipse.linuxtools.valgrind.core.IValgrindMessage; >+import org.eclipse.linuxtools.valgrind.launch.IValgrindOutputDirectoryProvider; >+ >+public abstract class AbstractValgrindRemoteLaunchDelegate extends >+ValgrindLaunchConfigurationDelegate { >+ >+ private SubMonitor monitor; >+ private IPath localOutputDir; >+ private IPath remoteBinFile; >+ private RemoteConnection rc; >+ private String valgrindLocAttr; >+ private String defaultValgrindLoc; >+ >+ public AbstractValgrindRemoteLaunchDelegate(String valgrindLocAttr, String defaultValgrindLoc) { >+ super(); >+ this.valgrindLocAttr = valgrindLocAttr; >+ this.defaultValgrindLoc = defaultValgrindLoc; >+ } >+ >+ public void launch(final ILaunchConfiguration config, String mode, >+ final ILaunch launch, IProgressMonitor m) throws CoreException { >+ if (m == null) { >+ m = new NullProgressMonitor(); >+ } >+ >+ // Clear process as we wait on it to be instantiated >+ process = null; >+ >+ monitor = SubMonitor >+ .convert( >+ m, >+ Messages.ValgrindRemoteLaunchDelegate_task_name, 10); >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ this.config = config; >+ this.launch = launch; >+ try { >+ // remove any output from previous run >+ ValgrindUIPlugin.getDefault().resetView(); >+ // reset stored launch data >+ getPlugin().setCurrentLaunchConfiguration(null); >+ getPlugin().setCurrentLaunch(null); >+ >+ rc = new RemoteConnection(config); >+ monitor.worked(1); >+ >+ // Copy binary using FileSystem service >+ final IPath exePath = CDebugUtils.verifyProgramPath(config); >+ final IPath remoteDir = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR)); >+ >+ remoteBinFile = remoteDir.append(exePath.lastSegment()); >+ >+ rc.upload(exePath, remoteDir, new SubProgressMonitor(monitor, 1)); >+ >+ IPath remoteLogDir = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR)); >+ outputPath = remoteLogDir.append("eclipse-valgrind-" + System.currentTimeMillis()); //$NON-NLS-1$ >+ >+ rc.createFolder(outputPath, new SubProgressMonitor(monitor, 1)); >+ >+ // Retrieve user-defined Valgrind binary location >+ final IPath valgrindLocation = Path.fromOSString(config.getAttribute(valgrindLocAttr, defaultValgrindLoc)); >+ String[] arguments = getProgramArgumentsArray(config); >+ // create/empty local output directory >+ IValgrindOutputDirectoryProvider provider = getPlugin().getOutputDirectoryProvider(); >+ try { >+ localOutputDir = provider.getOutputPath(); >+ createDirectory(localOutputDir); >+ } catch (IOException e2) { >+ // TODO Auto-generated catch block >+ e2.printStackTrace(); >+ } >+ >+ // tool that was launched >+ toolID = getTool(config); >+ // ask tool extension for arguments >+ dynamicDelegate = getDynamicDelegate(toolID); >+ String[] opts = getValgrindArgumentsArray(config); >+ Map<String, String> env = (Map<String, String>) config.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>) null); >+ boolean usePty = config.getAttribute( >+ ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, >+ ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT); >+ >+ String command = valgrindLocation.toString(); >+ // Add valgrind options >+ for (String opt : opts) { >+ command += " " + opt; //$NON-NLS-1$ >+ } >+ // Add executable to run >+ command += " " + remoteBinFile.toString(); >+ // Add arguments to pass to executable >+ for (String argument : arguments) { >+ command += " " + argument; //$NON-NLS-1$ >+ } >+ @SuppressWarnings("unused") >+ String[] output = rc.runCommand(command, remoteDir, new SubProgressMonitor(monitor, 1)); >+ >+ // delete remote binary >+ rc.delete(remoteBinFile, new SubProgressMonitor(monitor, 1)); >+ >+ // move remote log files to local directory >+ rc.download(outputPath, localOutputDir, new SubProgressMonitor(monitor, 1)); >+ >+ // remove remote log dir and all files under it >+ rc.delete(outputPath, new SubProgressMonitor(monitor, 1)); >+ >+ // store these for use by other classes >+ getPlugin().setCurrentLaunchConfiguration(config); >+ getPlugin().setCurrentLaunch(launch); >+ >+ // parse Valgrind logs >+ IValgrindMessage[] messages = parseLogs(localOutputDir); >+ >+ // create launch summary string to distinguish this launch >+ launchStr = createLaunchStr(); >+ >+ // create view >+ ValgrindUIPlugin.getDefault().createView(launchStr, toolID); >+ // set log messages >+ ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView(); >+ view.setMessages(messages); >+ monitor.worked(1); >+ >+ // pass off control to extender >+ dynamicDelegate.handleLaunch(config, launch, localOutputDir, monitor.newChild(2)); >+ >+ // initialize tool-specific part of view >+ dynamicDelegate.initializeView(view.getDynamicView(), launchStr, monitor.newChild(1)); >+ >+ // refresh view >+ ValgrindUIPlugin.getDefault().refreshView(); >+ >+ // show view >+ ValgrindUIPlugin.getDefault().showView(); >+ monitor.worked(1); >+ >+ } catch (IOException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } catch (RemoteConnectionException e) { >+ // TODO Auto-generated catch block >+ abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); >+ } finally { >+ monitor.done(); >+ m.done(); >+ } >+ } >+ >+ >+ protected String createLaunchStr() { >+ return config.getName() >+ + " [" + getPlugin().getToolName(toolID) + " on " + rc.getId() + "] "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ } >+ >+ @Override >+ protected String getPluginID() { >+ return ValgrindLaunchPlugin.PLUGIN_ID; >+ } >+ >+ public void onError(Throwable t) { >+ // for now do nothing >+ } >+ >+} >\ No newline at end of file >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/valgrind/launch/remote/AbstractValgrindRemoteTab.java b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/valgrind/launch/remote/AbstractValgrindRemoteTab.java >new file mode 100644 >index 0000000..5d5302d >--- /dev/null >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/valgrind/launch/remote/AbstractValgrindRemoteTab.java >@@ -0,0 +1,167 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 Elliott Baron >+ * 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: >+ * Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation >+ * Corey Ashford <cjashfor@us.ibm.com> - converted to an abstract class for >+ * the purposes of providing an ability >+ * to create multiple launchers, one for >+ * each Valgrind executable that is >+ * available. >+ *******************************************************************************/ >+package org.eclipse.linuxtools.valgrind.launch.remote; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.linuxtools.internal.valgrind.launch.remote.Messages; >+import org.eclipse.linuxtools.internal.valgrind.launch.remote.ValgrindRemoteLaunchConstants; >+import org.eclipse.linuxtools.profiling.launch.remote.RemoteTab; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+ >+public abstract class AbstractValgrindRemoteTab extends RemoteTab { >+ >+ private Text destDirText; >+ private Text tmpDirText; >+ private Text valgrindLocText; >+ private boolean isInitializing; >+ private String valgrindLocAttr; >+ private String defaultValgrindLoc; >+ >+ public AbstractValgrindRemoteTab(String valgrindLocAttr, String defaultValgrindLoc) { >+ super(Messages.ValgrindRemoteTab_tab_name); >+ this.valgrindLocAttr = valgrindLocAttr; >+ this.defaultValgrindLoc = defaultValgrindLoc; >+ } >+ >+ @Override >+ protected void localCreateControl(Composite top) { >+ >+ Composite pathTop = new Composite(top, SWT.NONE); >+ pathTop.setLayout(new GridLayout(2, false)); >+ pathTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ >+ // Valgrind location >+ Label valgrindLocLabel = new Label(pathTop, SWT.NONE); >+ valgrindLocLabel.setText(Messages.ValgrindRemoteTab_label_location_VG); >+ >+ valgrindLocText = new Text(pathTop, SWT.BORDER); >+ valgrindLocText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); >+ valgrindLocText.addModifyListener(new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) { >+ updateLaunchConfigurationDialog(); >+ } >+ }); >+ >+ // Destination directory >+ Label destDirLabel = new Label(pathTop, SWT.NONE); >+ destDirLabel.setText(Messages.ValgrindRemoteTab_label_dest_wd); >+ >+ destDirText = new Text(pathTop, SWT.BORDER); >+ destDirText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); >+ destDirText.addModifyListener(new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) { >+ updateLaunchConfigurationDialog(); >+ } >+ }); >+ >+ Label tmpDirLabel = new Label(pathTop, SWT.NONE); >+ tmpDirLabel.setText(Messages.ValgrindRemoteTab_label_tmp_dir); >+ >+ tmpDirText = new Text(pathTop, SWT.BORDER); >+ tmpDirText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); >+ tmpDirText.addModifyListener(new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) { >+ updateLaunchConfigurationDialog(); >+ } >+ }); >+ } >+ >+ @Override >+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { >+ super.setDefaults(configuration); >+ configuration.setAttribute(valgrindLocAttr, defaultValgrindLoc); >+ configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR); >+ configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR); >+ } >+ >+ @Override >+ public void localInitializeFrom(ILaunchConfiguration configuration) throws CoreException { >+ >+ String valgrindLoc = configuration.getAttribute(valgrindLocAttr, defaultValgrindLoc); >+ if (valgrindLoc != null) { >+ valgrindLocText.setText(valgrindLoc); >+ } >+ >+ String destDir = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR); >+ if (destDir != null) { >+ destDirText.setText(destDir); >+ } >+ >+ String tmpDir = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR); >+ if (tmpDir != null) { >+ tmpDirText.setText(tmpDir); >+ } >+ } >+ >+ @Override >+ public void performApply(ILaunchConfigurationWorkingCopy configuration) { >+ super.performApply(configuration); >+ configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, valgrindLocText.getText()); >+ configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, destDirText.getText()); >+ configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, tmpDirText.getText()); >+ } >+ >+ @Override >+ public boolean isValid(ILaunchConfiguration launchConfig) { >+ boolean valid = super.isValid(launchConfig); >+ if (valid) { >+ valid = valgrindLocText.getText().length() > 0; >+ if (valid) { >+ valid = destDirText.getText().length() > 0; >+ if (valid) { >+ valid = tmpDirText.getText().length() > 0; >+ if (!valid) { >+ setErrorMessage(Messages.ValgrindRemoteTab_error_tmp_dir); >+ } >+ } >+ else { >+ setErrorMessage(Messages.ValgrindRemoteTab_error_dest_wd); >+ } >+ } >+ else { >+ setErrorMessage(Messages.ValgrindRemoteTab_error_location_VG); >+ } >+ } >+ else { >+ setErrorMessage(Messages.ValgrindRemoteTab_error_peer); >+ } >+ >+ return valid; >+ } >+ >+ public String getName() { >+ return Messages.ValgrindRemoteTab_tab_name; >+ } >+ >+ @Override >+ protected void updateLaunchConfigurationDialog() { >+ if (!isInitializing) { >+ super.updateLaunchConfigurationDialog(); >+ } >+ } >+} >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java >index ac99e5a..56d6061 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java >@@ -49,6 +49,7 @@ import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCommand; > import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCoreParser; > import org.eclipse.linuxtools.internal.valgrind.core.ValgrindError; > import org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame; >+import org.eclipse.linuxtools.internal.valgrind.launch.Messages; > import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin; > import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart; > import org.eclipse.linuxtools.valgrind.core.IValgrindMessage; >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java >index dc24f81..edad6d4 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java >@@ -34,6 +34,8 @@ import org.eclipse.linuxtools.internal.valgrind.core.PluginConstants; > import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCommand; > import org.eclipse.linuxtools.internal.valgrind.core.ValgrindPlugin; > import org.eclipse.linuxtools.internal.valgrind.core.ValgrindPreferencePage; >+import org.eclipse.linuxtools.internal.valgrind.launch.Messages; >+import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindOutputDirectoryProvider; > import org.eclipse.linuxtools.valgrind.launch.IValgrindLaunchDelegate; > import org.eclipse.linuxtools.valgrind.launch.IValgrindOutputDirectoryProvider; > import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage; >diff --git a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java >index 7f3bbb6..3b83d7b 100644 >--- a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java >+++ b/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java >@@ -24,6 +24,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.linuxtools.internal.valgrind.core.LaunchConfigurationConstants; >+import org.eclipse.linuxtools.internal.valgrind.launch.Messages; > import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage; > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 353056
:
200320
|
202543
|
204413
|
204414
|
204417
|
204527
|
204528
|
204529
|
204530
|
205314
|
205315
|
205316