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 237306 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java (-13 / +39 lines)
Lines 11-16 Link Here
11
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
11
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
12
12
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.HashMap;
14
import java.util.List;
15
import java.util.List;
15
import java.util.concurrent.ExecutionException;
16
import java.util.concurrent.ExecutionException;
16
import java.util.concurrent.RejectedExecutionException;
17
import java.util.concurrent.RejectedExecutionException;
Lines 19-24 Link Here
19
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
20
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
20
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
21
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
21
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
22
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
23
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
22
import org.eclipse.cdt.dsf.concurrent.Query;
24
import org.eclipse.cdt.dsf.concurrent.Query;
23
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
25
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
24
import org.eclipse.cdt.dsf.datamodel.IDMContext;
26
import org.eclipse.cdt.dsf.datamodel.IDMContext;
Lines 29-34 Link Here
29
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
31
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
30
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
32
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
31
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
33
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
34
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo;
32
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo;
35
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo;
33
import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages;
36
import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages;
34
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
37
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
Lines 85-98 Link Here
85
     }
88
     }
86
89
87
    // Need a job because prompter.handleStatus will block
90
    // Need a job because prompter.handleStatus will block
88
    class PromptForPidJob extends Job {
91
    protected class PromptForPidJob extends Job {
89
92
90
    	// The list of processes used in the case of an ATTACH session
93
    	// The list of processes used in the case of an ATTACH session
91
    	IProcessExtendedInfo[] fProcessList = null;
94
    	IProcessExtendedInfo[] fProcessList = null;
92
    	DataRequestMonitor<Integer> fRequestMonitor;
95
    	DataRequestMonitor<Object> fRequestMonitor;
96
    	boolean fNewProcessSupported;
93
97
94
    	public PromptForPidJob(String name, IProcessExtendedInfo[] procs, DataRequestMonitor<Integer> rm) {
98
    	public PromptForPidJob(String name, boolean newProcessSupported, IProcessExtendedInfo[] procs, DataRequestMonitor<Object> rm) {
95
    		super(name);
99
    		super(name);
100
    		fNewProcessSupported = newProcessSupported;
96
    		fProcessList = procs;
101
    		fProcessList = procs;
97
    		fRequestMonitor = rm;
102
    		fRequestMonitor = rm;
98
    	}
103
    	}
Lines 115-124 Link Here
115
    		} 				
120
    		} 				
116
121
117
    		try {
122
    		try {
118
    			Object result = prompter.handleStatus(processPromptStatus, fProcessList);
123
    			PrompterInfo info = new PrompterInfo(fNewProcessSupported, fProcessList);
119
    			if (result instanceof Integer) {
124
    			Object result = prompter.handleStatus(processPromptStatus, info);
120
    				fRequestMonitor.setData((Integer)result);
125
    			if (result instanceof Integer || result instanceof String) {
121
    			} else {
126
    				fRequestMonitor.setData(result);
127
    		    } else {
122
    				fRequestMonitor.setStatus(NO_PID_STATUS);
128
    				fRequestMonitor.setStatus(NO_PID_STATUS);
123
    			}
129
    			}
124
    		} catch (CoreException e) {
130
    		} catch (CoreException e) {
Lines 151-157 Link Here
151
    			ICommandControlService commandControl = fTracker.getService(ICommandControlService.class);
157
    			ICommandControlService commandControl = fTracker.getService(ICommandControlService.class);
152
158
153
    			if (procService != null && commandControl != null) {
159
    			if (procService != null && commandControl != null) {
154
        			final ICommandControlDMContext controlCtx = commandControl.getContext();        
160
        			final ICommandControlDMContext controlCtx = commandControl.getContext();
161
        			procService.isDebugNewProcessSupported(controlCtx, new DataRequestMonitor<Boolean>(fExecutor, null) {
162
        			@Override	
163
        			protected void handleCompleted() {
164
        				final boolean newProcessSupported = isSuccess() && getData();
165
        				
155
    				procService.getRunningProcesses(
166
    				procService.getRunningProcesses(
156
    						controlCtx,        
167
    						controlCtx,        
157
    						new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) {
168
    						new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) {
Lines 165-180 Link Here
165
										@Override
176
										@Override
166
										protected void handleSuccess() {
177
										protected void handleSuccess() {
167
											new PromptForPidJob(
178
											new PromptForPidJob(
168
													"Prompt for Process", procInfoList.toArray(new IProcessExtendedInfo[0]),   //$NON-NLS-1$
179
													"Prompt for Process", newProcessSupported, procInfoList.toArray(new IProcessExtendedInfo[0]),   //$NON-NLS-1$
169
													new DataRequestMonitor<Integer>(fExecutor, rm) {
180
													new DataRequestMonitor<Object>(fExecutor, rm) {
170
														@Override
181
														@Override
171
														protected void handleSuccess() {
182
														protected void handleSuccess() {
172
															// New cycle, look for service again
183
															// New cycle, look for service again
173
															final IMIProcesses procService = fTracker.getService(IMIProcesses.class);
184
															final IMIProcesses procService = fTracker.getService(IMIProcesses.class);
174
															if (procService != null) {
185
															if (procService != null) {
175
																IProcessDMContext procDmc = procService.createProcessContext(controlCtx,
186
																Object data = getData();
176
																		Integer.toString(getData()));
187
																if (data instanceof String) {
177
																procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor<IDMContext>(fExecutor, rm));
188
																	// User wants to start a new process
189
																	String binaryPath = (String)data;
190
																	procService.debugNewProcess(
191
																			controlCtx, binaryPath, 
192
																			// khouzam, maybe we should at least pass stopOnMain?
193
																			new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm));
194
																} else if (data instanceof Integer) {
195
																	IProcessDMContext procDmc = procService.createProcessContext(controlCtx,
196
																			Integer.toString((Integer)getData()));
197
																	procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor<IDMContext>(fExecutor, rm));
198
																} else {
199
														            rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$
200
														            rm.done();
201
																}
178
															}
202
															}
179
														}
203
														}
180
													}).schedule();
204
													}).schedule();
Lines 246-251 Link Here
246
    								}
270
    								}
247
    							}
271
    							}
248
    						});
272
    						});
273
        			}
274
        			});
249
    			} else {
275
    			} else {
250
    				rm.done();
276
    				rm.done();
251
    			}
277
    			}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties (+5 lines)
Lines 222-224 Link Here
222
LocalCDILaunchDelegate.8=Error starting process.
222
LocalCDILaunchDelegate.8=Error starting process.
223
LocalCDILaunchDelegate.9=Eclipse runtime does not support working directory.
223
LocalCDILaunchDelegate.9=Eclipse runtime does not support working directory.
224
LocalCDILaunchDelegate.10=Failed to set program arguments, environment or working directory.
224
LocalCDILaunchDelegate.10=Failed to set program arguments, environment or working directory.
225
226
ProcessPrompter.Core=core
227
ProcessPrompter.Cores=cores
228
ProcessPrompterDialog.New=New...
229
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java (-9 / +28 lines)
Lines 28-44 Link Here
28
import org.eclipse.jface.window.Window;
28
import org.eclipse.jface.window.Window;
29
import org.eclipse.swt.graphics.Image;
29
import org.eclipse.swt.graphics.Image;
30
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
32
31
33
public class ProcessPrompter implements IStatusHandler {
32
public class ProcessPrompter implements IStatusHandler {
34
33
34
	public static class PrompterInfo {
35
		public boolean supportsNewProcess;
36
		public IProcessExtendedInfo[] processList;
37
		
38
		public PrompterInfo(boolean supportsNew, IProcessExtendedInfo[] list) {
39
			supportsNewProcess = supportsNew;
40
			processList = list;
41
		}
42
	}
43
	
35
	/*
44
	/*
36
	 * (non-Javadoc)
45
	 * (non-Javadoc)
37
	 * 
46
	 * 
38
	 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
47
	 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
39
	 *      java.lang.Object)
48
	 *      java.lang.Object)
40
	 */
49
	 */
41
	public Object handleStatus(IStatus status, Object processList) throws CoreException {
50
	public Object handleStatus(IStatus status, Object info) throws CoreException {
42
		Shell shell = GdbUIPlugin.getShell();
51
		Shell shell = GdbUIPlugin.getShell();
43
		if (shell == null) {
52
		if (shell == null) {
44
			IStatus error = new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(),
53
			IStatus error = new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(),
Lines 47-53 Link Here
47
			throw new CoreException(error);
56
			throw new CoreException(error);
48
		}
57
		}
49
58
50
		IProcessExtendedInfo[] plist = (IProcessExtendedInfo[])processList;		
59
		PrompterInfo prompterInfo = (PrompterInfo) info;
60
		IProcessExtendedInfo[] plist = prompterInfo.processList;		
51
		if (plist == null) {
61
		if (plist == null) {
52
			MessageDialog.openError(
62
			MessageDialog.openError(
53
					shell,
63
					shell,
Lines 91-101 Link Here
91
101
92
					String[] cores = info.getCores();
102
					String[] cores = info.getCores();
93
					if (cores != null && cores.length > 0) {
103
					if (cores != null && cores.length > 0) {
104
						String coreStr;
94
						if (cores.length == 1) {
105
						if (cores.length == 1) {
95
							text.append(" [core: ");
106
							coreStr = LaunchUIMessages.getString("ProcessPrompter.Core");   //$NON-NLS-1$
96
						} else {
107
						} else {
97
							text.append(" [cores: ");
108
							coreStr = LaunchUIMessages.getString("ProcessPrompter.Cores");   //$NON-NLS-1$
98
						}
109
						}
110
						text.append(" [" + coreStr + ": ");   //$NON-NLS-1$//$NON-NLS-2$
111
						
99
						for (String core : cores) {
112
						for (String core : cores) {
100
							text.append(core + ", "); //$NON-NLS-1$
113
							text.append(core + ", "); //$NON-NLS-1$
101
						}
114
						}
Lines 133-147 Link Here
133
			};
146
			};
134
147
135
			// Display the list of processes and have the user choose
148
			// Display the list of processes and have the user choose
136
			TwoPaneElementSelector dialog = new TwoPaneElementSelector(shell, provider, qprovider);
149
			ProcessPrompterDialog dialog = new ProcessPrompterDialog(shell, provider, qprovider, prompterInfo.supportsNewProcess);
137
			dialog.setTitle(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$
150
			dialog.setTitle(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$
138
			dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
151
			dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
139
152
140
			dialog.setElements(plist);
153
			dialog.setElements(plist);
141
			if (dialog.open() == Window.OK) {
154
			if (dialog.open() == Window.OK) {
142
				IProcessExtendedInfo info = (IProcessExtendedInfo)dialog.getFirstResult();
155
				// First check if the user pressed the New button
143
				if (info != null) {
156
				String binaryPath = dialog.getBinaryPath();
144
					return new Integer(info.getPid());
157
				if (binaryPath != null) {
158
					return binaryPath;
159
				}
160
				
161
				IProcessExtendedInfo processInfo = (IProcessExtendedInfo)dialog.getFirstResult();
162
				if (processInfo != null) {
163
					return new Integer(processInfo.getPid());
145
				}
164
				}
146
			}
165
			}
147
		}
166
		}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java (+46 lines)
Added Link Here
1
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
2
3
import org.eclipse.jface.viewers.ILabelProvider;
4
import org.eclipse.swt.SWT;
5
import org.eclipse.swt.widgets.Button;
6
import org.eclipse.swt.widgets.Composite;
7
import org.eclipse.swt.widgets.FileDialog;
8
import org.eclipse.swt.widgets.Shell;
9
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
10
11
public class ProcessPrompterDialog extends TwoPaneElementSelector {
12
	private static final int NEW_BUTTON_ID = 9876;
13
	private String fBinaryPath;
14
	private boolean fSupportsNewProcess;
15
16
	public ProcessPrompterDialog(Shell parent, ILabelProvider elementRenderer,
17
			ILabelProvider qualifierRenderer, boolean supportsNewProcess) {
18
		super(parent, elementRenderer, qualifierRenderer);
19
		fSupportsNewProcess = supportsNewProcess;
20
	}
21
22
	@Override
23
	protected void createButtonsForButtonBar(Composite parent) {
24
		Button newButton = createButton(
25
				parent, NEW_BUTTON_ID, LaunchUIMessages.getString("ProcessPrompterDialog.New"), false); //$NON-NLS-1$
26
		newButton.setEnabled(fSupportsNewProcess);
27
		super.createButtonsForButtonBar(parent);
28
	}
29
30
	@Override
31
	protected void buttonPressed(int buttonId) {
32
		if (buttonId == NEW_BUTTON_ID) {
33
			FileDialog fd = new FileDialog(getShell(), SWT.SAVE);
34
			fBinaryPath = fd.open();
35
36
			setReturnCode(OK);
37
			close();
38
		}
39
		super.buttonPressed(buttonId);
40
	}
41
	
42
	public String getBinaryPath() {
43
		return fBinaryPath;
44
	}
45
	
46
}

Return to bug 237306