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/service/GDBProcesses.java (-14 / +13 lines)
Lines 57-63 Link Here
57
import org.eclipse.cdt.dsf.service.DsfSession;
57
import org.eclipse.cdt.dsf.service.DsfSession;
58
import org.eclipse.cdt.utils.pty.PTY;
58
import org.eclipse.cdt.utils.pty.PTY;
59
import org.eclipse.core.runtime.CoreException;
59
import org.eclipse.core.runtime.CoreException;
60
import org.eclipse.core.runtime.IPath;
61
import org.eclipse.core.runtime.IStatus;
60
import org.eclipse.core.runtime.IStatus;
62
import org.eclipse.core.runtime.Platform;
61
import org.eclipse.core.runtime.Platform;
63
import org.eclipse.core.runtime.Status;
62
import org.eclipse.core.runtime.Status;
Lines 224-234 Link Here
224
	}
223
	}
225
224
226
	@Override
225
	@Override
227
    public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> rm) {
226
    public void attachDebuggerToProcess(IProcessDMContext procCtx, DataRequestMonitor<IDMContext> rm) {
228
		// For remote attach, we must set the binary first
227
		attachDebuggerToProcess(procCtx, null, rm);
229
		// For a local attach, GDB can figure out the binary automatically,
228
	}
230
		// so we don't specify it.
229
	
231
		
230
    /**
231
	 * @since 4.0
232
	 */
233
    public void attachDebuggerToProcess(final IProcessDMContext procCtx, String binaryPath, final DataRequestMonitor<IDMContext> rm) {
232
		final IMIContainerDMContext containerDmc = createContainerContext(procCtx, MIProcesses.UNIQUE_GROUP_ID);
234
		final IMIContainerDMContext containerDmc = createContainerContext(procCtx, MIProcesses.UNIQUE_GROUP_ID);
233
235
234
		DataRequestMonitor<MIInfo> attachRm = new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm) {
236
		DataRequestMonitor<MIInfo> attachRm = new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm) {
Lines 253-266 Link Here
253
			}
255
			}
254
		};
256
		};
255
		
257
		
256
		if (fBackend.getSessionType() == SessionType.REMOTE) {
258
		if (binaryPath != null) {
257
			final IPath execPath = fBackend.getProgramPath();
259
			fGdb.queueCommand(
258
			if (execPath != null && !execPath.isEmpty()) {
260
				fCommandFactory.createMIFileExecAndSymbols(containerDmc, binaryPath), 
259
				fGdb.queueCommand(
261
				attachRm);
260
					fCommandFactory.createMIFileExecAndSymbols(containerDmc, execPath.toPortableString()), 
262
			return;
261
					attachRm);
262
				return;
263
			}
264
		}
263
		}
265
264
266
		// If we get here, let's do the attach by completing the requestMonitor
265
		// If we get here, let's do the attach by completing the requestMonitor
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java (-10 / +13 lines)
Lines 79-85 Link Here
79
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
79
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
80
import org.eclipse.cdt.dsf.service.DsfSession;
80
import org.eclipse.cdt.dsf.service.DsfSession;
81
import org.eclipse.core.runtime.CoreException;
81
import org.eclipse.core.runtime.CoreException;
82
import org.eclipse.core.runtime.IPath;
83
import org.eclipse.core.runtime.IStatus;
82
import org.eclipse.core.runtime.IStatus;
84
import org.eclipse.core.runtime.Platform;
83
import org.eclipse.core.runtime.Platform;
85
import org.eclipse.core.runtime.Status;
84
import org.eclipse.core.runtime.Status;
Lines 754-760 Link Here
754
    	rm.done();
753
    	rm.done();
755
    }
754
    }
756
755
757
    public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> dataRm) {
756
    public void attachDebuggerToProcess(IProcessDMContext procCtx, DataRequestMonitor<IDMContext> rm) {
757
		attachDebuggerToProcess(procCtx, null, rm);
758
	}
759
	
760
    /**
761
	 * @since 4.0
762
	 */
763
    public void attachDebuggerToProcess(final IProcessDMContext procCtx, final String binaryPath, final DataRequestMonitor<IDMContext> dataRm) {
758
		if (procCtx instanceof IMIProcessDMContext) {
764
		if (procCtx instanceof IMIProcessDMContext) {
759
	    	if (!doIsDebuggerAttachSupported()) {
765
	    	if (!doIsDebuggerAttachSupported()) {
760
	            dataRm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$
766
	            dataRm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$
Lines 784-797 Link Here
784
	    						// There is no groupId until we attach, so we can use the default groupId
790
	    						// There is no groupId until we attach, so we can use the default groupId
785
	    						fContainerDmc = createContainerContext(procCtx, MIProcesses.UNIQUE_GROUP_ID);
791
	    						fContainerDmc = createContainerContext(procCtx, MIProcesses.UNIQUE_GROUP_ID);
786
792
787
	    				    	if (fBackend.getSessionType() == SessionType.REMOTE) {
793
	    						if (binaryPath != null) {
788
	    				    		final IPath execPath = fBackend.getProgramPath();
794
    				    			fCommandControl.queueCommand(
789
	    				    		if (execPath != null && !execPath.isEmpty()) {
795
    				    					fCommandFactory.createMIFileExecAndSymbols(fContainerDmc, binaryPath), 
790
	    				    			fCommandControl.queueCommand(
796
			    							new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm));
791
	    				    					fCommandFactory.createMIFileExecAndSymbols(fContainerDmc, execPath.toPortableString()), 
797
    				    			return;
792
   				    							new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm));
793
	    				    			return;
794
									}
795
	    						}
798
	    						}
796
799
797
	    				    	rm.done();
800
	    				    	rm.done();
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java (-13 / +14 lines)
Lines 33-39 Link Here
33
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
33
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
34
import org.eclipse.cdt.dsf.service.DsfSession;
34
import org.eclipse.cdt.dsf.service.DsfSession;
35
import org.eclipse.core.runtime.CoreException;
35
import org.eclipse.core.runtime.CoreException;
36
import org.eclipse.core.runtime.IPath;
37
import org.eclipse.core.runtime.IStatus;
36
import org.eclipse.core.runtime.IStatus;
38
import org.eclipse.core.runtime.Status;
37
import org.eclipse.core.runtime.Status;
39
import org.eclipse.debug.core.ILaunch;
38
import org.eclipse.debug.core.ILaunch;
Lines 100-106 Link Here
100
	}
99
	}
101
100
102
	@Override
101
	@Override
103
    public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> dataRm) {
102
    public void attachDebuggerToProcess(IProcessDMContext procCtx, DataRequestMonitor<IDMContext> rm) {
103
		attachDebuggerToProcess(procCtx, null, rm);
104
	}
105
	
106
    /**
107
	 * @since 4.0
108
	 */
109
	@Override
110
	public void attachDebuggerToProcess(final IProcessDMContext procCtx, final String binaryPath, final DataRequestMonitor<IDMContext> dataRm) {
104
		if (procCtx instanceof IMIProcessDMContext) {
111
		if (procCtx instanceof IMIProcessDMContext) {
105
	    	if (!doIsDebuggerAttachSupported()) {
112
	    	if (!doIsDebuggerAttachSupported()) {
106
	            dataRm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$
113
	            dataRm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$
Lines 143-162 Link Here
143
		            	        		});
150
		            	        		});
144
		                    }
151
		                    }
145
		                },
152
		                },
146
	    				// For remote attach, we must set the binary first
147
	    				// For a local attach, GDB can figure out the binary automatically,
148
	    				// so we don't specify it.
149
	    				new Step() { 
153
	    				new Step() { 
150
	    					@Override
154
	    					@Override
151
	    					public void execute(RequestMonitor rm) {
155
	    					public void execute(RequestMonitor rm) {
152
	    				    	if (fBackend.getSessionType() == SessionType.REMOTE) {
156
	    						if (binaryPath != null) {
153
	    				    		final IPath execPath = fBackend.getProgramPath();
157
    				    			fCommandControl.queueCommand(
154
	    				    		if (execPath != null && !execPath.isEmpty()) {
158
    				    					fCommandFactory.createMIFileExecAndSymbols(fContainerDmc, binaryPath), 
155
	    				    			fCommandControl.queueCommand(
159
			    							new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm));
156
	    				    					fCommandFactory.createMIFileExecAndSymbols(fContainerDmc, execPath.toPortableString()), 
160
    				    			return;
157
   				    							new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm));
158
	    				    			return;
159
									}
160
	    						}
161
	    						}
161
162
162
	    				    	rm.done();
163
	    				    	rm.done();
(-)src/org/eclipse/cdt/dsf/gdb/service/IGDBProcesses.java (+13 lines)
Lines 14-19 Link Here
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
16
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
17
import org.eclipse.cdt.dsf.datamodel.IDMContext;
17
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
18
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
18
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
19
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
19
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
20
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
Lines 90-94 Link Here
90
     * @since 4.0
91
     * @since 4.0
91
     */
92
     */
92
	void start(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm);
93
	void start(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm);
94
	
95
    /**
96
     * Attaches debugger to the given process.     
97
     * When attaching to a process, a debugging context can now be used to characterize the process.
98
     * This method can optionally choose to return this IDMContext inside the DataRequestMonitor.  
99
     * This can be useful for backends that do not have the ability to obtain the different 
100
     * debugging IDMContexts through {@link #getProcessesBeingDebugged(IDMContext, DataRequestMonitor)
101
     * 
102
     * @param file Binary to use for the process.
103
     * @since 4.0
104
     */    
105
    void attachDebuggerToProcess(IProcessDMContext procCtx, String file, DataRequestMonitor<IDMContext> rm);
93
106
94
}
107
}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java (-3 / +28 lines)
Lines 34-41 Link Here
34
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo;
34
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo;
35
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo;
35
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo;
36
import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages;
36
import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages;
37
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
38
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses;
37
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
39
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
38
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
40
import org.eclipse.cdt.dsf.gdb.service.SessionType;
39
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
41
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
40
import org.eclipse.cdt.dsf.service.DsfSession;
42
import org.eclipse.cdt.dsf.service.DsfSession;
41
import org.eclipse.core.runtime.CoreException;
43
import org.eclipse.core.runtime.CoreException;
Lines 45-50 Link Here
45
import org.eclipse.core.runtime.jobs.Job;
47
import org.eclipse.core.runtime.jobs.Job;
46
import org.eclipse.debug.core.DebugPlugin;
48
import org.eclipse.debug.core.DebugPlugin;
47
import org.eclipse.debug.core.IStatusHandler;
49
import org.eclipse.debug.core.IStatusHandler;
50
import org.eclipse.swt.SWT;
51
import org.eclipse.swt.widgets.Display;
52
import org.eclipse.swt.widgets.FileDialog;
53
import org.eclipse.swt.widgets.Shell;
54
import org.eclipse.ui.PlatformUI;
48
55
49
public class GdbConnectCommand implements IConnect {
56
public class GdbConnectCommand implements IConnect {
50
    
57
    
Lines 181-187 Link Here
181
														@Override
188
														@Override
182
														protected void handleSuccess() {
189
														protected void handleSuccess() {
183
															// New cycle, look for service again
190
															// New cycle, look for service again
184
															final IMIProcesses procService = fTracker.getService(IMIProcesses.class);
191
															final IGDBProcesses procService = fTracker.getService(IGDBProcesses.class);
185
															if (procService != null) {
192
															if (procService != null) {
186
																Object data = getData();
193
																Object data = getData();
187
																if (data instanceof String) {
194
																if (data instanceof String) {
Lines 192-200 Link Here
192
																			// khouzam, maybe we should at least pass stopOnMain?
199
																			// khouzam, maybe we should at least pass stopOnMain?
193
																			new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm));
200
																			new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm));
194
																} else if (data instanceof Integer) {
201
																} else if (data instanceof Integer) {
202
																	final String[] binaryPath = new String[1];
203
																	binaryPath[0] = null;
204
																	final IGDBBackend backend = fTracker.getService(IGDBBackend.class);
205
																	if (backend != null && backend.getSessionType() == SessionType.REMOTE) {
206
																		// For remote attach, we must set the binary first
207
																		// For a local attach, GDB can figure out the binary automatically,
208
																		// so we don't specify it.
209
																		PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
210
																			public void run() {
211
																				Shell shell = Display.getCurrent().getActiveShell();
212
																				if (shell != null) {
213
																					FileDialog fd = new FileDialog(shell, SWT.NONE);
214
																					binaryPath[0] = fd.open();
215
																				}
216
																			}
217
																		});
218
																	}
219
																	
195
																	IProcessDMContext procDmc = procService.createProcessContext(controlCtx,
220
																	IProcessDMContext procDmc = procService.createProcessContext(controlCtx,
196
																			Integer.toString((Integer)getData()));
221
																			Integer.toString((Integer)getData()));
197
																	procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor<IDMContext>(fExecutor, rm));
222
																	procService.attachDebuggerToProcess(procDmc, binaryPath[0], new DataRequestMonitor<IDMContext>(fExecutor, rm));
198
																} else {
223
																} else {
199
														            rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$
224
														            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();
225
														            rm.done();
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java (-1 / +1 lines)
Lines 30-36 Link Here
30
	@Override
30
	@Override
31
	protected void buttonPressed(int buttonId) {
31
	protected void buttonPressed(int buttonId) {
32
		if (buttonId == NEW_BUTTON_ID) {
32
		if (buttonId == NEW_BUTTON_ID) {
33
			FileDialog fd = new FileDialog(getShell(), SWT.SAVE);
33
			FileDialog fd = new FileDialog(getShell(), SWT.NONE);
34
			fBinaryPath = fd.open();
34
			fBinaryPath = fd.open();
35
35
36
			setReturnCode(OK);
36
			setReturnCode(OK);

Return to bug 237306