Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 353056 | Differences between
and this patch

Collapse All | Expand All

(-)a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/META-INF/MANIFEST.MF (-2 / +3 lines)
Lines 2-8 Manifest-Version: 1.0 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Bundle-Name
3
Bundle-Name: %Bundle-Name
4
Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.launch.remote;singleton:=true
4
Bundle-SymbolicName: org.eclipse.linuxtools.valgrind.launch.remote;singleton:=true
5
Bundle-Version: 0.8.0.qualifier
5
Bundle-Version: 0.8.1.qualifier
6
Bundle-Activator: org.eclipse.linuxtools.internal.valgrind.launch.remote.ValgrindRemotePlugin
6
Bundle-Activator: org.eclipse.linuxtools.internal.valgrind.launch.remote.ValgrindRemotePlugin
7
Bundle-Vendor: %Bundle-Vendor
7
Bundle-Vendor: %Bundle-Vendor
8
Require-Bundle: org.eclipse.ui,
8
Require-Bundle: org.eclipse.ui,
Lines 10-16 Require-Bundle: org.eclipse.ui, Link Here
10
 org.eclipse.linuxtools.profiling.launch.remote;bundle-version="0.8.0"
10
 org.eclipse.linuxtools.profiling.launch.remote;bundle-version="0.8.0"
11
Bundle-RequiredExecutionEnvironment: J2SE-1.5
11
Bundle-RequiredExecutionEnvironment: J2SE-1.5
12
Bundle-ActivationPolicy: lazy
12
Bundle-ActivationPolicy: lazy
13
Export-Package: org.eclipse.linuxtools.internal.valgrind.launch.remote
13
Export-Package: org.eclipse.linuxtools.internal.valgrind.launch.remote,
14
 org.eclipse.linuxtools.valgrind.launch.remote
14
Import-Package: org.eclipse.cdt.core,
15
Import-Package: org.eclipse.cdt.core,
15
 org.eclipse.cdt.core.model,
16
 org.eclipse.cdt.core.model,
16
 org.eclipse.cdt.debug.core,
17
 org.eclipse.cdt.debug.core,
(-)a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteLaunchDelegate.java (-189 / +6 lines)
Lines 1-193 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 Elliott Baron
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation
10
 *    Red Hat Inc. - rewrite to use RemoteConnection class
11
 *******************************************************************************/ 
12
package org.eclipse.linuxtools.internal.valgrind.launch.remote;
1
package org.eclipse.linuxtools.internal.valgrind.launch.remote;
13
2
14
import java.io.IOException;
3
import org.eclipse.linuxtools.valgrind.launch.remote.AbstractValgrindRemoteLaunchDelegate;
15
import java.util.Map;
16
4
17
import org.eclipse.cdt.debug.core.CDebugUtils;
5
public class ValgrindRemoteLaunchDelegate extends AbstractValgrindRemoteLaunchDelegate {
18
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
6
	public ValgrindRemoteLaunchDelegate() {
19
import org.eclipse.core.runtime.CoreException;
7
		super(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC,
20
import org.eclipse.core.runtime.IPath;
8
				ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC);
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.NullProgressMonitor;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.core.runtime.SubMonitor;
25
import org.eclipse.core.runtime.SubProgressMonitor;
26
import org.eclipse.debug.core.ILaunch;
27
import org.eclipse.debug.core.ILaunchConfiguration;
28
import org.eclipse.debug.core.ILaunchManager;
29
import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchConfigurationDelegate;
30
import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchPlugin;
31
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin;
32
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart;
33
import org.eclipse.linuxtools.profiling.launch.remote.RemoteConnection;
34
import org.eclipse.linuxtools.profiling.launch.remote.RemoteConnectionException;
35
import org.eclipse.linuxtools.valgrind.core.IValgrindMessage;
36
import org.eclipse.linuxtools.valgrind.launch.IValgrindOutputDirectoryProvider;
37
38
public class ValgrindRemoteLaunchDelegate extends
39
ValgrindLaunchConfigurationDelegate {
40
41
	private SubMonitor monitor;
42
	private IPath localOutputDir;
43
	private IPath remoteBinFile;
44
	private RemoteConnection rc;
45
46
	public void launch(final ILaunchConfiguration config, String mode,
47
			final ILaunch launch, IProgressMonitor m) throws CoreException {
48
		if (m == null) {
49
			m = new NullProgressMonitor();
50
		}
51
		
52
		// Clear process as we wait on it to be instantiated
53
		process = null;
54
55
		monitor = SubMonitor
56
		.convert(
57
				m,
58
				Messages.ValgrindRemoteLaunchDelegate_task_name, 10);
59
		// check for cancellation
60
		if (monitor.isCanceled()) {
61
			return;
62
		}
63
64
		this.config = config;
65
		this.launch = launch;
66
		try {			
67
			// remove any output from previous run
68
			ValgrindUIPlugin.getDefault().resetView();
69
			// reset stored launch data
70
			getPlugin().setCurrentLaunchConfiguration(null);
71
			getPlugin().setCurrentLaunch(null);
72
73
			rc = new RemoteConnection(config);
74
			monitor.worked(1);
75
76
			// Copy binary using FileSystem service
77
			final IPath exePath = CDebugUtils.verifyProgramPath(config);
78
			final IPath remoteDir = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR));
79
80
			remoteBinFile = remoteDir.append(exePath.lastSegment());
81
			
82
			rc.upload(exePath, remoteDir, new SubProgressMonitor(monitor, 1));
83
			
84
			IPath remoteLogDir = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR));
85
			outputPath = remoteLogDir.append("eclipse-valgrind-" + System.currentTimeMillis()); //$NON-NLS-1$
86
87
			rc.createFolder(outputPath, new SubProgressMonitor(monitor, 1));
88
89
			// Retrieve user-defined Valgrind binary location
90
			final IPath valgrindLocation = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC));
91
			String[] arguments = getProgramArgumentsArray(config);
92
			// create/empty local output directory
93
			IValgrindOutputDirectoryProvider provider = getPlugin().getOutputDirectoryProvider();
94
			try {
95
				localOutputDir = provider.getOutputPath();
96
				createDirectory(localOutputDir);
97
			} catch (IOException e2) {
98
				// TODO Auto-generated catch block
99
				e2.printStackTrace();
100
			}
101
102
			// tool that was launched
103
			toolID = getTool(config);
104
			// ask tool extension for arguments
105
			dynamicDelegate = getDynamicDelegate(toolID);
106
			String[] opts = getValgrindArgumentsArray(config);
107
			Map<String, String> env = (Map<String, String>) config.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>) null);
108
			boolean usePty = config.getAttribute(
109
					ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL,
110
					ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
111
112
			String command = valgrindLocation.toString();
113
			// Add valgrind options
114
			for (String opt : opts) {
115
				command += " " + opt; //$NON-NLS-1$
116
			}
117
			// Add executable to run
118
			command += " " + remoteBinFile.toString();
119
			// Add arguments to pass to executable
120
			for (String argument : arguments) {
121
				command += " " + argument; //$NON-NLS-1$
122
			}
123
			@SuppressWarnings("unused")
124
			String[] output = rc.runCommand(command, remoteDir, new SubProgressMonitor(monitor, 1));
125
126
			// delete remote binary
127
			rc.delete(remoteBinFile, new SubProgressMonitor(monitor, 1));
128
129
			// move remote log files to local directory
130
			rc.download(outputPath, localOutputDir, new SubProgressMonitor(monitor, 1));
131
132
			// remove remote log dir and all files under it
133
			rc.delete(outputPath, new SubProgressMonitor(monitor, 1));
134
			
135
			// store these for use by other classes
136
			getPlugin().setCurrentLaunchConfiguration(config);
137
			getPlugin().setCurrentLaunch(launch);
138
139
			// parse Valgrind logs
140
			IValgrindMessage[] messages = parseLogs(localOutputDir);
141
142
			// create launch summary string to distinguish this launch
143
			launchStr = createLaunchStr();
144
145
			// create view
146
			ValgrindUIPlugin.getDefault().createView(launchStr, toolID);
147
			// set log messages
148
			ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
149
			view.setMessages(messages);
150
			monitor.worked(1);
151
152
			// pass off control to extender
153
			dynamicDelegate.handleLaunch(config, launch, localOutputDir, monitor.newChild(2));
154
			
155
			// initialize tool-specific part of view
156
			dynamicDelegate.initializeView(view.getDynamicView(), launchStr, monitor.newChild(1));
157
158
			// refresh view
159
			ValgrindUIPlugin.getDefault().refreshView();
160
161
			// show view
162
			ValgrindUIPlugin.getDefault().showView();
163
			monitor.worked(1);
164
165
			
166
		} catch (IOException e) {
167
			// TODO Auto-generated catch block
168
			e.printStackTrace();
169
		} catch (RemoteConnectionException e) {
170
			// TODO Auto-generated catch block
171
			abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
172
		} finally {
173
			monitor.done();
174
			m.done();
175
		}
176
	}
177
178
179
	protected String createLaunchStr() {
180
		return config.getName()
181
		+ " [" + getPlugin().getToolName(toolID) + " on " + rc.getId() + "] "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
182
	}
183
184
	@Override
185
	protected String getPluginID() {
186
		return ValgrindLaunchPlugin.PLUGIN_ID;
187
	}
188
189
	public void onError(Throwable t) {
190
		// for now do nothing
191
	}
9
	}
192
	
10
}
193
}
(-)a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/internal/valgrind/launch/remote/ValgrindRemoteTab.java (-141 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 Elliott Baron
2
 * Copyright (c) 2011 Elliott Baron
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-156 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation
9
 *    Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation
10
 *******************************************************************************/ 
10
 *    Corey Ashford <cjashfor@us.ibm.com> - pushed class definition to an abstract
11
 *                                          class, and this class now just extends
12
 *                                          and instantiates it.
13
 *******************************************************************************/
11
package org.eclipse.linuxtools.internal.valgrind.launch.remote;
14
package org.eclipse.linuxtools.internal.valgrind.launch.remote;
12
15
13
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.linuxtools.valgrind.launch.remote.AbstractValgrindRemoteTab;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.linuxtools.profiling.launch.remote.RemoteTab;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.ModifyEvent;
19
import org.eclipse.swt.events.ModifyListener;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Label;
24
import org.eclipse.swt.widgets.Text;
25
17
26
public class ValgrindRemoteTab extends RemoteTab {
18
public class ValgrindRemoteTab extends AbstractValgrindRemoteTab {
27
	
28
	private Text destDirText;
29
	private Text tmpDirText;
30
	private Text valgrindLocText;
31
	private boolean isInitializing;
32
19
33
	public ValgrindRemoteTab() {
20
	public ValgrindRemoteTab() {
34
		super(Messages.ValgrindRemoteTab_tab_name);
21
		super(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC,
35
	}
22
				ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC);
36
	
37
	@Override
38
	protected void localCreateControl(Composite top) {
39
40
		Composite pathTop = new Composite(top, SWT.NONE);
41
		pathTop.setLayout(new GridLayout(2, false));
42
		pathTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
43
44
		// Valgrind location
45
		Label valgrindLocLabel = new Label(pathTop, SWT.NONE);
46
		valgrindLocLabel.setText(Messages.ValgrindRemoteTab_label_location_VG);
47
48
		valgrindLocText = new Text(pathTop, SWT.BORDER);
49
		valgrindLocText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
50
		valgrindLocText.addModifyListener(new ModifyListener() {
51
52
			public void modifyText(ModifyEvent e) {
53
				updateLaunchConfigurationDialog();
54
			}
55
		});
56
57
		// Destination directory
58
		Label destDirLabel = new Label(pathTop, SWT.NONE);
59
		destDirLabel.setText(Messages.ValgrindRemoteTab_label_dest_wd);
60
61
		destDirText = new Text(pathTop, SWT.BORDER);
62
		destDirText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
63
		destDirText.addModifyListener(new ModifyListener() {
64
65
			public void modifyText(ModifyEvent e) {
66
				updateLaunchConfigurationDialog();
67
			}
68
		});
69
70
		Label tmpDirLabel = new Label(pathTop, SWT.NONE);
71
		tmpDirLabel.setText(Messages.ValgrindRemoteTab_label_tmp_dir);
72
73
		tmpDirText = new Text(pathTop, SWT.BORDER);
74
		tmpDirText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
75
		tmpDirText.addModifyListener(new ModifyListener() {
76
77
			public void modifyText(ModifyEvent e) {
78
				updateLaunchConfigurationDialog();
79
			}
80
		});
81
	}
82
83
	@Override
84
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
85
		super.setDefaults(configuration);
86
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC);
87
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR);
88
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR);
89
	}
90
91
	@Override
92
	public void localInitializeFrom(ILaunchConfiguration configuration) throws CoreException {
93
94
		String valgrindLoc = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_VALGRINDLOC);
95
		if (valgrindLoc != null) {
96
			valgrindLocText.setText(valgrindLoc);
97
		}
98
99
		String destDir = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR);
100
		if (destDir != null) {
101
			destDirText.setText(destDir);
102
		}
103
104
		String tmpDir = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR);
105
		if (tmpDir != null) {
106
			tmpDirText.setText(tmpDir);
107
		}
108
	}
109
110
	@Override
111
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
112
		super.performApply(configuration);
113
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, valgrindLocText.getText());
114
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, destDirText.getText());
115
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, tmpDirText.getText());
116
	}
117
	
118
	@Override
119
	public boolean isValid(ILaunchConfiguration launchConfig) {
120
		boolean valid = super.isValid(launchConfig);
121
		if (valid) {
122
			valid = valgrindLocText.getText().length() > 0;
123
			if (valid) {
124
				valid = destDirText.getText().length() > 0;
125
				if (valid) {
126
					valid = tmpDirText.getText().length() > 0;
127
					if (!valid) {
128
						setErrorMessage(Messages.ValgrindRemoteTab_error_tmp_dir);
129
					}
130
				}
131
				else {
132
					setErrorMessage(Messages.ValgrindRemoteTab_error_dest_wd);
133
				}
134
			}
135
			else {
136
				setErrorMessage(Messages.ValgrindRemoteTab_error_location_VG);
137
			}
138
		}
139
		else {
140
			setErrorMessage(Messages.ValgrindRemoteTab_error_peer);
141
		}
142
		
143
		return valid;
144
	}
145
146
	public String getName() {
147
		return Messages.ValgrindRemoteTab_tab_name;
148
	}
149
150
	@Override
151
	protected void updateLaunchConfigurationDialog() {
152
		if (!isInitializing) {
153
			super.updateLaunchConfigurationDialog();
154
		}		
155
	}
23
	}
156
}
24
}
(-)a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/valgrind/launch/remote/AbstractValgrindRemoteLaunchDelegate.java (+208 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 Elliott Baron
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation
10
 *    Red Hat Inc. - rewrite to use RemoteConnection class
11
 *    Corey Ashford <cjashfor@us.ibm.com> - converted to an abstract class for
12
 *                                          the purposes of providing an ability
13
 *                                          to create multiple launchers, one for
14
 *                                          each Valgrind executable that is
15
 *                                          available.
16
 *******************************************************************************/
17
package org.eclipse.linuxtools.valgrind.launch.remote;
18
19
import java.io.IOException;
20
21
import java.util.Map;
22
23
import org.eclipse.cdt.debug.core.CDebugUtils;
24
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.IPath;
27
import org.eclipse.core.runtime.IProgressMonitor;
28
import org.eclipse.core.runtime.NullProgressMonitor;
29
import org.eclipse.core.runtime.Path;
30
import org.eclipse.core.runtime.SubMonitor;
31
import org.eclipse.core.runtime.SubProgressMonitor;
32
import org.eclipse.debug.core.ILaunch;
33
import org.eclipse.debug.core.ILaunchConfiguration;
34
import org.eclipse.debug.core.ILaunchManager;
35
import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchConfigurationDelegate;
36
import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindLaunchPlugin;
37
import org.eclipse.linuxtools.internal.valgrind.launch.remote.Messages;
38
import org.eclipse.linuxtools.internal.valgrind.launch.remote.ValgrindRemoteLaunchConstants;
39
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin;
40
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart;
41
import org.eclipse.linuxtools.profiling.launch.remote.RemoteConnection;
42
import org.eclipse.linuxtools.profiling.launch.remote.RemoteConnectionException;
43
import org.eclipse.linuxtools.valgrind.core.IValgrindMessage;
44
import org.eclipse.linuxtools.valgrind.launch.IValgrindOutputDirectoryProvider;
45
46
public abstract class AbstractValgrindRemoteLaunchDelegate extends
47
ValgrindLaunchConfigurationDelegate {
48
49
	private SubMonitor monitor;
50
	private IPath localOutputDir;
51
	private IPath remoteBinFile;
52
	private RemoteConnection rc;
53
	private String valgrindLocAttr;
54
	private String defaultValgrindLoc;
55
56
	public AbstractValgrindRemoteLaunchDelegate(String valgrindLocAttr, String defaultValgrindLoc) {
57
		super();
58
		this.valgrindLocAttr = valgrindLocAttr;
59
		this.defaultValgrindLoc = defaultValgrindLoc;
60
	}
61
62
	public void launch(final ILaunchConfiguration config, String mode,
63
			final ILaunch launch, IProgressMonitor m) throws CoreException {
64
		if (m == null) {
65
			m = new NullProgressMonitor();
66
		}
67
68
		// Clear process as we wait on it to be instantiated
69
		process = null;
70
71
		monitor = SubMonitor
72
		.convert(
73
				m,
74
				Messages.ValgrindRemoteLaunchDelegate_task_name, 10);
75
		// check for cancellation
76
		if (monitor.isCanceled()) {
77
			return;
78
		}
79
80
		this.config = config;
81
		this.launch = launch;
82
		try {
83
			// remove any output from previous run
84
			ValgrindUIPlugin.getDefault().resetView();
85
			// reset stored launch data
86
			getPlugin().setCurrentLaunchConfiguration(null);
87
			getPlugin().setCurrentLaunch(null);
88
89
			rc = new RemoteConnection(config);
90
			monitor.worked(1);
91
92
			// Copy binary using FileSystem service
93
			final IPath exePath = CDebugUtils.verifyProgramPath(config);
94
			final IPath remoteDir = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR));
95
96
			remoteBinFile = remoteDir.append(exePath.lastSegment());
97
98
			rc.upload(exePath, remoteDir, new SubProgressMonitor(monitor, 1));
99
100
			IPath remoteLogDir = Path.fromOSString(config.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR));
101
			outputPath = remoteLogDir.append("eclipse-valgrind-" + System.currentTimeMillis()); //$NON-NLS-1$
102
103
			rc.createFolder(outputPath, new SubProgressMonitor(monitor, 1));
104
105
			// Retrieve user-defined Valgrind binary location
106
			final IPath valgrindLocation = Path.fromOSString(config.getAttribute(valgrindLocAttr, defaultValgrindLoc));
107
			String[] arguments = getProgramArgumentsArray(config);
108
			// create/empty local output directory
109
			IValgrindOutputDirectoryProvider provider = getPlugin().getOutputDirectoryProvider();
110
			try {
111
				localOutputDir = provider.getOutputPath();
112
				createDirectory(localOutputDir);
113
			} catch (IOException e2) {
114
				// TODO Auto-generated catch block
115
				e2.printStackTrace();
116
			}
117
118
			// tool that was launched
119
			toolID = getTool(config);
120
			// ask tool extension for arguments
121
			dynamicDelegate = getDynamicDelegate(toolID);
122
			String[] opts = getValgrindArgumentsArray(config);
123
			Map<String, String> env = (Map<String, String>) config.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>) null);
124
			boolean usePty = config.getAttribute(
125
					ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL,
126
					ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
127
128
			String command = valgrindLocation.toString();
129
			// Add valgrind options
130
			for (String opt : opts) {
131
				command += " " + opt; //$NON-NLS-1$
132
			}
133
			// Add executable to run
134
			command += " " + remoteBinFile.toString();
135
			// Add arguments to pass to executable
136
			for (String argument : arguments) {
137
				command += " " + argument; //$NON-NLS-1$
138
			}
139
			@SuppressWarnings("unused")
140
			String[] output = rc.runCommand(command, remoteDir, new SubProgressMonitor(monitor, 1));
141
142
			// delete remote binary
143
			rc.delete(remoteBinFile, new SubProgressMonitor(monitor, 1));
144
145
			// move remote log files to local directory
146
			rc.download(outputPath, localOutputDir, new SubProgressMonitor(monitor, 1));
147
148
			// remove remote log dir and all files under it
149
			rc.delete(outputPath, new SubProgressMonitor(monitor, 1));
150
151
			// store these for use by other classes
152
			getPlugin().setCurrentLaunchConfiguration(config);
153
			getPlugin().setCurrentLaunch(launch);
154
155
			// parse Valgrind logs
156
			IValgrindMessage[] messages = parseLogs(localOutputDir);
157
158
			// create launch summary string to distinguish this launch
159
			launchStr = createLaunchStr();
160
161
			// create view
162
			ValgrindUIPlugin.getDefault().createView(launchStr, toolID);
163
			// set log messages
164
			ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
165
			view.setMessages(messages);
166
			monitor.worked(1);
167
168
			// pass off control to extender
169
			dynamicDelegate.handleLaunch(config, launch, localOutputDir, monitor.newChild(2));
170
171
			// initialize tool-specific part of view
172
			dynamicDelegate.initializeView(view.getDynamicView(), launchStr, monitor.newChild(1));
173
174
			// refresh view
175
			ValgrindUIPlugin.getDefault().refreshView();
176
177
			// show view
178
			ValgrindUIPlugin.getDefault().showView();
179
			monitor.worked(1);
180
181
		} catch (IOException e) {
182
			// TODO Auto-generated catch block
183
			e.printStackTrace();
184
		} catch (RemoteConnectionException e) {
185
			// TODO Auto-generated catch block
186
			abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
187
		} finally {
188
			monitor.done();
189
			m.done();
190
		}
191
	}
192
193
194
	protected String createLaunchStr() {
195
		return config.getName()
196
		+ " [" + getPlugin().getToolName(toolID) + " on " + rc.getId() + "] "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
197
	}
198
199
	@Override
200
	protected String getPluginID() {
201
		return ValgrindLaunchPlugin.PLUGIN_ID;
202
	}
203
204
	public void onError(Throwable t) {
205
		// for now do nothing
206
	}
207
208
}
(-)a/valgrind/org.eclipse.linuxtools.valgrind.launch.remote/src/org/eclipse/linuxtools/valgrind/launch/remote/AbstractValgrindRemoteTab.java (+167 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 Elliott Baron
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Elliott Baron <ebaron@fedoraproject.org> - initial API and implementation
10
 *    Corey Ashford <cjashfor@us.ibm.com> - converted to an abstract class for
11
 *                                          the purposes of providing an ability
12
 *                                          to create multiple launchers, one for
13
 *                                          each Valgrind executable that is
14
 *                                          available.
15
 *******************************************************************************/
16
package org.eclipse.linuxtools.valgrind.launch.remote;
17
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.debug.core.ILaunchConfiguration;
20
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
21
import org.eclipse.linuxtools.internal.valgrind.launch.remote.Messages;
22
import org.eclipse.linuxtools.internal.valgrind.launch.remote.ValgrindRemoteLaunchConstants;
23
import org.eclipse.linuxtools.profiling.launch.remote.RemoteTab;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.ModifyEvent;
26
import org.eclipse.swt.events.ModifyListener;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Label;
31
import org.eclipse.swt.widgets.Text;
32
33
public abstract class AbstractValgrindRemoteTab extends RemoteTab {
34
35
	private Text destDirText;
36
	private Text tmpDirText;
37
	private Text valgrindLocText;
38
	private boolean isInitializing;
39
	private String valgrindLocAttr;
40
	private String defaultValgrindLoc;
41
42
	public AbstractValgrindRemoteTab(String valgrindLocAttr, String defaultValgrindLoc) {
43
		super(Messages.ValgrindRemoteTab_tab_name);
44
		this.valgrindLocAttr = valgrindLocAttr;
45
		this.defaultValgrindLoc = defaultValgrindLoc;
46
	}
47
48
	@Override
49
	protected void localCreateControl(Composite top) {
50
51
		Composite pathTop = new Composite(top, SWT.NONE);
52
		pathTop.setLayout(new GridLayout(2, false));
53
		pathTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
54
55
		// Valgrind location
56
		Label valgrindLocLabel = new Label(pathTop, SWT.NONE);
57
		valgrindLocLabel.setText(Messages.ValgrindRemoteTab_label_location_VG);
58
59
		valgrindLocText = new Text(pathTop, SWT.BORDER);
60
		valgrindLocText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
61
		valgrindLocText.addModifyListener(new ModifyListener() {
62
63
			public void modifyText(ModifyEvent e) {
64
				updateLaunchConfigurationDialog();
65
			}
66
		});
67
68
		// Destination directory
69
		Label destDirLabel = new Label(pathTop, SWT.NONE);
70
		destDirLabel.setText(Messages.ValgrindRemoteTab_label_dest_wd);
71
72
		destDirText = new Text(pathTop, SWT.BORDER);
73
		destDirText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
74
		destDirText.addModifyListener(new ModifyListener() {
75
76
			public void modifyText(ModifyEvent e) {
77
				updateLaunchConfigurationDialog();
78
			}
79
		});
80
81
		Label tmpDirLabel = new Label(pathTop, SWT.NONE);
82
		tmpDirLabel.setText(Messages.ValgrindRemoteTab_label_tmp_dir);
83
84
		tmpDirText = new Text(pathTop, SWT.BORDER);
85
		tmpDirText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
86
		tmpDirText.addModifyListener(new ModifyListener() {
87
88
			public void modifyText(ModifyEvent e) {
89
				updateLaunchConfigurationDialog();
90
			}
91
		});
92
	}
93
94
	@Override
95
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
96
		super.setDefaults(configuration);
97
		configuration.setAttribute(valgrindLocAttr, defaultValgrindLoc);
98
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR);
99
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR);
100
	}
101
102
	@Override
103
	public void localInitializeFrom(ILaunchConfiguration configuration) throws CoreException {
104
105
		String valgrindLoc = configuration.getAttribute(valgrindLocAttr, defaultValgrindLoc);
106
		if (valgrindLoc != null) {
107
			valgrindLocText.setText(valgrindLoc);
108
		}
109
110
		String destDir = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_DESTDIR);
111
		if (destDir != null) {
112
			destDirText.setText(destDir);
113
		}
114
115
		String tmpDir = configuration.getAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, ValgrindRemoteLaunchConstants.DEFAULT_REMOTE_OUTPUTDIR);
116
		if (tmpDir != null) {
117
			tmpDirText.setText(tmpDir);
118
		}
119
	}
120
121
	@Override
122
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
123
		super.performApply(configuration);
124
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_VALGRINDLOC, valgrindLocText.getText());
125
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_DESTDIR, destDirText.getText());
126
		configuration.setAttribute(ValgrindRemoteLaunchConstants.ATTR_REMOTE_OUTPUTDIR, tmpDirText.getText());
127
	}
128
129
	@Override
130
	public boolean isValid(ILaunchConfiguration launchConfig) {
131
		boolean valid = super.isValid(launchConfig);
132
		if (valid) {
133
			valid = valgrindLocText.getText().length() > 0;
134
			if (valid) {
135
				valid = destDirText.getText().length() > 0;
136
				if (valid) {
137
					valid = tmpDirText.getText().length() > 0;
138
					if (!valid) {
139
						setErrorMessage(Messages.ValgrindRemoteTab_error_tmp_dir);
140
					}
141
				}
142
				else {
143
					setErrorMessage(Messages.ValgrindRemoteTab_error_dest_wd);
144
				}
145
			}
146
			else {
147
				setErrorMessage(Messages.ValgrindRemoteTab_error_location_VG);
148
			}
149
		}
150
		else {
151
			setErrorMessage(Messages.ValgrindRemoteTab_error_peer);
152
		}
153
154
		return valid;
155
	}
156
157
	public String getName() {
158
		return Messages.ValgrindRemoteTab_tab_name;
159
	}
160
161
	@Override
162
	protected void updateLaunchConfigurationDialog() {
163
		if (!isInitializing) {
164
			super.updateLaunchConfigurationDialog();
165
		}
166
	}
167
}
(-)a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchConfigurationDelegate.java (+1 lines)
Lines 49-54 import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCommand; Link Here
49
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCoreParser;
49
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCoreParser;
50
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindError;
50
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindError;
51
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame;
51
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame;
52
import org.eclipse.linuxtools.internal.valgrind.launch.Messages;
52
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin;
53
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin;
53
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart;
54
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart;
54
import org.eclipse.linuxtools.valgrind.core.IValgrindMessage;
55
import org.eclipse.linuxtools.valgrind.core.IValgrindMessage;
(-)a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindLaunchPlugin.java (+2 lines)
Lines 34-39 import org.eclipse.linuxtools.internal.valgrind.core.PluginConstants; Link Here
34
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCommand;
34
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindCommand;
35
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindPlugin;
35
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindPlugin;
36
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindPreferencePage;
36
import org.eclipse.linuxtools.internal.valgrind.core.ValgrindPreferencePage;
37
import org.eclipse.linuxtools.internal.valgrind.launch.Messages;
38
import org.eclipse.linuxtools.internal.valgrind.launch.ValgrindOutputDirectoryProvider;
37
import org.eclipse.linuxtools.valgrind.launch.IValgrindLaunchDelegate;
39
import org.eclipse.linuxtools.valgrind.launch.IValgrindLaunchDelegate;
38
import org.eclipse.linuxtools.valgrind.launch.IValgrindOutputDirectoryProvider;
40
import org.eclipse.linuxtools.valgrind.launch.IValgrindOutputDirectoryProvider;
39
import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage;
41
import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage;
(-)a/valgrind/org.eclipse.linuxtools.valgrind.launch/src/org/eclipse/linuxtools/internal/valgrind/launch/ValgrindOptionsTab.java (+1 lines)
Lines 24-29 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; Link Here
24
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
24
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
25
import org.eclipse.jface.dialogs.IDialogConstants;
25
import org.eclipse.jface.dialogs.IDialogConstants;
26
import org.eclipse.linuxtools.internal.valgrind.core.LaunchConfigurationConstants;
26
import org.eclipse.linuxtools.internal.valgrind.core.LaunchConfigurationConstants;
27
import org.eclipse.linuxtools.internal.valgrind.launch.Messages;
27
import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage;
28
import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage;
28
import org.eclipse.osgi.util.NLS;
29
import org.eclipse.osgi.util.NLS;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;

Return to bug 353056