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/debug/service/IProcesses.java (-1 / +10 lines)
Lines 101-106 Link Here
101
     * debugging IDMContexts through {@link #getProcessesBeingDebugged(IDMContext, DataRequestMonitor)
101
     * debugging IDMContexts through {@link #getProcessesBeingDebugged(IDMContext, DataRequestMonitor)
102
     */    
102
     */    
103
    void attachDebuggerToProcess(IProcessDMContext procCtx, DataRequestMonitor<IDMContext> rm);
103
    void attachDebuggerToProcess(IProcessDMContext procCtx, DataRequestMonitor<IDMContext> rm);
104
    
105
    /**
106
     * Attaches debugger to the given process.     
107
     * When attaching to a process, a debugging context can now be used to characterize the process.
108
     * This method can optionally choose to return this IDMContext inside the DataRequestMonitor.  
109
     * This can be useful for backends that do not have the ability to obtain the different 
110
     * debugging IDMContexts through {@link #getProcessesBeingDebugged(IDMContext, DataRequestMonitor)
111
     */    
112
    void attachDebuggerToProcess(IProcessDMContext procCtx, String executableFile , DataRequestMonitor<IDMContext> rm);
104
113
105
    /**
114
    /**
106
     * Checks whether it is possible to detach the debugger from the specified process.
115
     * Checks whether it is possible to detach the debugger from the specified process.
Lines 123-129 Link Here
123
     * @param rm Return if it is possible to run a new process.
132
     * @param rm Return if it is possible to run a new process.
124
     */
133
     */
125
    void isRunNewProcessSupported(IDMContext dmc, DataRequestMonitor<Boolean> rm);
134
    void isRunNewProcessSupported(IDMContext dmc, DataRequestMonitor<Boolean> rm);
126
135
    
127
    /**
136
    /**
128
     * Starts a new process.
137
     * Starts a new process.
129
     * @param dmc The processor or core on which we want to run a new process.
138
     * @param dmc The processor or core on which we want to run a new process.
(-)src/org/eclipse/cdt/dsf/gdb/actions/ISelectInferior.java (+22 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Ericsson and others.
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
 *     Ericsson - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.actions;
12
13
14
/**
15
 * @since 1.1
16
 */
17
public interface ISelectInferior {
18
	/**
19
	 * Causes this element to attempt to select a new process
20
	 */
21
	public void selectInferior(Object object);
22
}
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java (+6 lines)
Lines 1130-1133 Link Here
1130
    		}
1130
    		}
1131
    	}	
1131
    	}	
1132
	}
1132
	}
1133
1134
	public void attachDebuggerToProcess(IProcessDMContext procCtx,
1135
			String executableFile, DataRequestMonitor<IDMContext> rm) {
1136
		// TODO Auto-generated method stub
1137
		
1138
	}
1133
}
1139
}
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java (+322 lines)
Added Link Here
1
package org.eclipse.cdt.dsf.gdb.service;
2
3
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
4
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
5
import org.eclipse.cdt.dsf.datamodel.DMContexts;
6
import org.eclipse.cdt.dsf.datamodel.IDMContext;
7
import org.eclipse.cdt.dsf.debug.service.command.BufferedCommandControl;
8
import org.eclipse.cdt.dsf.debug.service.command.CommandCache;
9
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
10
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
11
import org.eclipse.cdt.dsf.gdb.service.command.GDBControlDMContext;
12
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
13
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
14
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
15
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
16
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
17
import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo;
18
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
19
import org.eclipse.cdt.dsf.service.DsfSession;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Status;
22
23
public class GDBProcesses_7_2 extends GDBProcesses_7_1{
24
25
    private CommandFactory fCommandFactory;
26
    // This cache is used when we send command to get the cores.
27
    // The value of the cores can change at any time, but we provide
28
    // an updated value whenever there is a suspended event.
29
    private CommandCache fCommandForCoresCache;
30
    private IGDBControl fCommandControl;
31
    
32
    // A cache for commands about the threadGroups
33
	private CommandCache fContainerCommandCache;
34
	
35
    
36
	public GDBProcesses_7_2(DsfSession session) {
37
		super(session);
38
	}
39
40
	@Override
41
	public void initialize(final RequestMonitor requestMonitor) {
42
		super.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
43
			@Override
44
			protected void handleSuccess() {
45
				doInitialize(requestMonitor);
46
			}
47
		});
48
	}
49
50
	/**
51
	 * This method initializes this service after our superclass's initialize()
52
	 * method succeeds.
53
	 * 
54
	 * @param requestMonitor
55
	 *            The call-back object to notify when this service's
56
	 *            initialization is done.
57
	 */
58
	private void doInitialize(RequestMonitor requestMonitor) {
59
		fCommandControl = getServicesTracker().getService(IGDBControl.class);
60
61
		BufferedCommandControl bufferedCommandControl = new BufferedCommandControl(fCommandControl, getExecutor(), 2);
62
		
63
		// This caches stores the result of a command when received; also, this cache
64
		// is manipulated when receiving events.  Currently, events are received after
65
		// three scheduling of the executor, while command results after only one.  This
66
		// can cause problems because command results might be processed before an event
67
		// that actually arrived before the command result.
68
		// To solve this, we use a bufferedCommandControl that will delay the command
69
		// result by two scheduling of the executor.
70
		// See bug 280461
71
        fCommandForCoresCache = new CommandCache(getSession(), 
72
        		new BufferedCommandControl(fCommandControl, getExecutor(), 2));
73
        fCommandForCoresCache.setContextAvailable(fCommandControl.getContext(), true);
74
75
        fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
76
        
77
        fContainerCommandCache = new CommandCache(getSession(), bufferedCommandControl);
78
        fContainerCommandCache.setContextAvailable(fCommandControl.getContext(), true);
79
        
80
        getSession().addServiceEventListener(this, null);
81
82
        requestMonitor.done();
83
	}
84
85
	@Override
86
	public void shutdown(RequestMonitor requestMonitor) {
87
        getSession().removeServiceEventListener(this);
88
89
		super.shutdown(requestMonitor);
90
	}
91
	
92
	/* *  inferior x
93
	 *   (gdb)
94
	 */
95
	
96
	public void switchInferior(IDMContext dmc,  Object selection , final DataRequestMonitor<IProcessDMContext> rm ) {
97
		char inferiorId = (char) -1;
98
		if (dmc instanceof GDBControlDMContext) {  //regular expressions ile yap
99
			 	int start = (selection.toString()).indexOf("[");
100
			 	 int len = "[".length();
101
			 	 int count = 1;
102
			 	while (start != -1) {
103
			            start = (selection.toString()).indexOf("[", start+len);
104
			            count++;
105
			            if ( count == 3){
106
			            	inferiorId = (selection.toString()).charAt(start+2); // sadece tek rakamları parse eder 11 , 101 ????
107
			            }
108
			    }
109
			      	
110
			 	if ( inferiorId != -1 && isInteger(String.valueOf(inferiorId)) ){
111
					ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class);
112
					fCommandControl.queueCommand(fCommandFactory.createCLISwitchInferior(controlDmc ,String.valueOf(inferiorId)),
113
			        		new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
114
			    	        	@Override
115
			    	        	protected void handleSuccess() {
116
			    	        		// BUraya sonucu dogrulugu icin info eklenmelidir.
117
			    	        		rm.done();
118
			    	        	}
119
			        });
120
			 	}
121
	    } else {
122
	    	rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$
123
	    	rm.done();
124
	    }		
125
	}
126
	
127
	public boolean isInteger( String input )  
128
	{  
129
	   try  
130
	   {  
131
	      Integer.parseInt( input );  
132
	      return true;  
133
	   }  
134
	   catch( Exception e)  
135
	   {  
136
	      return false;  
137
	   }  
138
	} 
139
	
140
	@Override
141
	public void attachDebuggerToProcess(final IProcessDMContext procCtx, final String file , DataRequestMonitor<IDMContext> rm) {
142
		final IProcessDMContext procDmc = procCtx;
143
		final DataRequestMonitor<IDMContext> requestmonitor = rm;
144
		final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(procDmc, ICommandControlDMContext.class);
145
        fCommandControl.queueCommand(fCommandFactory.createMIAddInferior(controlDmc),
146
        		new DataRequestMonitor<MIAddInferiorInfo>(getExecutor(), requestmonitor) {
147
    	        	@Override
148
    	        	protected void handleSuccess() {
149
    	        		if ( getData().getGroupId() != null ){
150
    	        			fCommandControl.queueCommand(fCommandFactory.createCLISwitchInferior(controlDmc ,getData().getGroupId().substring(1, 2)),
151
    	        	        		new DataRequestMonitor<MIInfo>(getExecutor(), requestmonitor) {
152
    	        	    	        	@Override
153
    	        	    	        	protected void handleSuccess() {
154
    	        	    	        		if (procCtx instanceof IMIProcessDMContext) {
155
    	        	    	        			DataRequestMonitor<Boolean> rm_bool = new DataRequestMonitor<Boolean>(getExecutor(), requestmonitor);
156
    	        	    	        			isDebuggerAttachSupported(null, rm_bool);
157
    	        	    	        	    	if (!rm_bool.getData()) {
158
    	        	    	        	    		requestmonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$
159
    	        	    	        	    		requestmonitor.done();    		
160
    	        	    	        	    		return;
161
    	        	    	        	    	}
162
    	        	    	        	    	
163
    	        	    	        	    	final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(procCtx, ICommandControlDMContext.class);
164
    	        	    	        			fCommandControl.queueCommand(
165
    	        	    	        					fCommandFactory.createMITargetAttach(controlDmc, ((IMIProcessDMContext)procCtx).getProcId()),
166
    	        	    	        					new DataRequestMonitor<MIInfo>(getExecutor(), requestmonitor) {
167
    	        	    	        						@Override
168
    	        	    	        						protected void handleSuccess() {
169
    	        	    	        			        		fCommandControl.queueCommand(
170
    	        	    	        			        				fCommandFactory.createMIFileExecAndSymbols(controlDmc, file) ,
171
    	        	    	        			        				 
172
    	        	    	        			        				new DataRequestMonitor<MIInfo>(getExecutor(), requestmonitor));
173
    	        	    	        			        		
174
    	        	    	        							IMIContainerDMContext containerDmc = createContainerContext(procCtx,
175
    	        	    	        									                                                    ((IMIProcessDMContext)procCtx).getProcId());
176
    	        	    	        							requestmonitor.setData(containerDmc);
177
    	        	    	        							requestmonitor.done();
178
    	        	    	        						}
179
    	        	    	        					});
180
181
    	        	    	        	    } else {
182
    	        	    	        	    	requestmonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$
183
    	        	    	        	    	requestmonitor.done();
184
    	        	    	        	    }
185
    	        	    	        	}
186
    	        	        });
187
    	        			
188
    	        		}
189
    	        		
190
    	        	}
191
        });
192
        rm.done();
193
194
	}
195
    
196
/*
197
	public void eventReceived(Object output) {
198
    	for (MIOOBRecord oobr : ((MIOutput)output).getMIOOBRecords()) {
199
			if (oobr instanceof MINotifyAsyncOutput) {
200
    			MINotifyAsyncOutput exec = (MINotifyAsyncOutput) oobr;
201
    			String miEvent = exec.getAsyncClass();
202
    			if ("thread-created".equals(miEvent) || "thread-exited".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$
203
    				String threadId = null;
204
    				String groupId = null;
205
206
    				MIResult[] results = exec.getMIResults();
207
    				for (int i = 0; i < results.length; i++) {
208
    					String var = results[i].getVariable();
209
    					MIValue val = results[i].getMIValue();
210
    					if (var.equals("group-id")) { //$NON-NLS-1$
211
    						if (val instanceof MIConst) {
212
    							groupId = ((MIConst) val).getString();
213
    						}
214
    					} else if (var.equals("id")) { //$NON-NLS-1$
215
    		    			if (val instanceof MIConst) {
216
    							threadId = ((MIConst) val).getString();
217
    		    			}
218
    		    		}
219
    				}
220
221
    		    	if ("thread-created".equals(miEvent)) { //$NON-NLS-1$
222
    		    		// Update the thread to groupId map with the new groupId
223
    		    		fThreadToGroupMap.put(threadId, groupId);
224
    		    	} else {
225
    		    		fThreadToGroupMap.remove(threadId);
226
    		    	}
227
    			} else if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent) ||  //$NON-NLS-1$ //$NON-NLS-2$
228
    					   "thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
229
    				
230
    				String groupId = null;
231
    				String infNo   = null;
232
233
    				MIResult[] results = exec.getMIResults();
234
    				for (int i = 0; i < results.length; i++) {
235
    					String var = results[i].getVariable();
236
    					MIValue val = results[i].getMIValue();
237
    					if (var.equals("pid")) { //$NON-NLS-1$
238
    						if (val instanceof MIConst) {
239
    							groupId = ((MIConst) val).getString().trim();
240
    						}
241
    					}
242
    					if (var.equals("id")) { //$NON-NLS-1$
243
    						if (val instanceof MIConst) {
244
    							infNo = ((MIConst) val).getString().trim();
245
    						}
246
    					}
247
    				}
248
249
    				if (groupId != null) {
250
    					if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$
251
    						fDebuggedProcessesAndNames.put(groupId, ""); //$NON-NLS-1$
252
    					
253
							// GDB is debugging a new process. Let's fetch its
254
							// name and remember it. In order to get the name,
255
							// we have to request all running processes, not
256
							// just the ones being debugged. We got a lot more 
257
    						// information when we request all processes.
258
        					final String finalGroupId = groupId;
259
        					final String finalInfNo   = infNo;
260
    						fListThreadGroupsAvailableCache.execute(
261
    								fCommandFactory.createMIListThreadGroups(fCommandControl.getContext(), true),
262
    								new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), null) {
263
    									@Override
264
    									protected void handleCompleted() {
265
    										// We cannot actually cache this command since the process
266
    										// list may change.  But this cache allows to avoid overlapping
267
    										// sending of this command.
268
    										fListThreadGroupsAvailableCache.reset();
269
270
    										if (isSuccess()) {
271
    											for (IThreadGroupInfo groupInfo : getData().getGroupList()) {
272
    												if (groupInfo.getPid().equals(finalGroupId)) {
273
    													fDebuggedProcessesAndNames.put(finalInfNo, groupInfo.getDesciption());
274
    												}
275
    											}
276
    										}
277
    										else {
278
    											// Looks like this gdb doesn't truly support
279
    											// "-list-thread-groups --available". Get the
280
    											// process list natively if we're debugging locally
281
    											IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
282
    											if (backend.getSessionType() == SessionType.LOCAL) {
283
	    											IProcessList list = null;
284
	    											try {
285
	    												list = CCorePlugin.getDefault().getProcessList();
286
	        											int groupId_int = Integer.parseInt(finalGroupId);
287
	        											for (IProcessInfo procInfo : list.getProcessList()) {
288
	        												if (procInfo.getPid() == groupId_int) {
289
	        													fDebuggedProcessesAndNames.put(finalGroupId, procInfo.getName());
290
	        												}
291
	        											}
292
	    											} catch (CoreException e) {
293
	    											}
294
    											}
295
    										}
296
    									}
297
    								});
298
    					} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
299
    						// GDB is no longer debugging this process.  Remove it from our list.
300
    						fDebuggedProcessesAndNames.remove(groupId);
301
    						
302
    						// Remove any entries for that group from our thread to group map
303
    						// When detaching from a group, we won't have received any thread-exited event
304
    						// but we don't want to keep those entries.
305
    						if (fThreadToGroupMap.containsValue(groupId)) {
306
    							Iterator<Map.Entry<String, String>> iterator = fThreadToGroupMap.entrySet().iterator();
307
    							while (iterator.hasNext()){
308
    								if (iterator.next().getValue().equals(groupId)) {
309
    									iterator.remove();
310
    								}
311
    							}
312
    						}
313
    					}
314
    				}
315
    			}
316
    		}
317
    	}	
318
	}
319
	*/
320
	
321
}
322
(-)src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java (-1 / +4 lines)
Lines 139-144 Link Here
139
		
139
		
140
	@Override
140
	@Override
141
	protected IProcesses createProcessesService(DsfSession session) {
141
	protected IProcesses createProcessesService(DsfSession session) {
142
		if (GDB_7_2_VERSION.compareTo(fVersion) <= 0) {
143
			return new GDBProcesses_7_2(session);
144
		}
142
		if (GDB_7_1_VERSION.compareTo(fVersion) <= 0) {
145
		if (GDB_7_1_VERSION.compareTo(fVersion) <= 0) {
143
			return new GDBProcesses_7_1(session);
146
			return new GDBProcesses_7_1(session);
144
		}
147
		}
Lines 147-153 Link Here
147
		}
150
		}
148
		return new GDBProcesses(session);
151
		return new GDBProcesses(session);
149
	}
152
	}
150
153
	
151
	@Override
154
	@Override
152
	protected IRegisters createRegistersService(DsfSession session) {
155
	protected IRegisters createRegistersService(DsfSession session) {
153
		return new MIRegisters(session);
156
		return new MIRegisters(session);
(-)src/org/eclipse/cdt/dsf/mi/service/MIProcesses.java (+6 lines)
Lines 682-685 Link Here
682
	public void flushCache(IDMContext context) {
682
	public void flushCache(IDMContext context) {
683
        fContainerCommandCache.reset(context);
683
        fContainerCommandCache.reset(context);
684
	}
684
	}
685
686
	public void attachDebuggerToProcess(IProcessDMContext procCtx,
687
			String executableFile, DataRequestMonitor<IDMContext> rm) {
688
		// TODO Auto-generated method stub
689
		
690
	}
685
}
691
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java (+5 lines)
Lines 39-44 Link Here
39
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIPasscount;
39
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIPasscount;
40
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIRecord;
40
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIRecord;
41
import org.eclipse.cdt.dsf.mi.service.command.commands.CLISource;
41
import org.eclipse.cdt.dsf.mi.service.command.commands.CLISource;
42
import org.eclipse.cdt.dsf.mi.service.command.commands.CLISwicthInferior;
42
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIThread;
43
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIThread;
43
import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace;
44
import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace;
44
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetEnv;
45
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetEnv;
Lines 241-246 Link Here
241
		return new CLISource(ctx, file);
242
		return new CLISource(ctx, file);
242
	}
243
	}
243
244
245
	public ICommand<MIInfo> createCLISwitchInferior(ICommandControlDMContext ctx , String groupId) {
246
		return new CLISwicthInferior(ctx, groupId);
247
	}
248
	
244
	public ICommand<CLIThreadInfo> createCLIThread(IContainerDMContext ctx) {
249
	public ICommand<CLIThreadInfo> createCLIThread(IContainerDMContext ctx) {
245
		return new CLIThread(ctx);
250
		return new CLIThread(ctx);
246
	}
251
	}
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/CLISwicthInferior.java (+29 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 TUBITAK-UEKAE.
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
 *     TUBITAK-UEKAE - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.mi.service.command.commands;
13
14
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
15
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
16
17
/**	
18
 *   inferior GROUPID
19
 *   ^done
20
 *   
21
 *   switch the specified inferior.
22
 *   
23
 */
24
public class CLISwicthInferior extends MICommand<MIInfo>
25
{
26
    public CLISwicthInferior(ICommandControlDMContext dmc, String groupId) {
27
        super(dmc, "inferior ", new String[] { groupId }); //$NON-NLS-1$
28
    }
29
}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java (+5 lines)
Lines 40-51 Link Here
40
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.IRefreshAllTarget;
40
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.IRefreshAllTarget;
41
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.DefaultDsfModelSelectionPolicyFactory;
41
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.DefaultDsfModelSelectionPolicyFactory;
42
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
42
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
43
import org.eclipse.cdt.dsf.gdb.actions.ISelectInferior;
43
import org.eclipse.cdt.dsf.gdb.internal.commands.ISelectNextTraceRecordHandler;
44
import org.eclipse.cdt.dsf.gdb.internal.commands.ISelectNextTraceRecordHandler;
44
import org.eclipse.cdt.dsf.gdb.internal.commands.ISelectPrevTraceRecordHandler;
45
import org.eclipse.cdt.dsf.gdb.internal.commands.ISelectPrevTraceRecordHandler;
45
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.DsfTerminateCommand;
46
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.DsfTerminateCommand;
46
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbConnectCommand;
47
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbConnectCommand;
47
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbDisconnectCommand;
48
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbDisconnectCommand;
48
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRestartCommand;
49
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRestartCommand;
50
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbSelectInferiorCommand;
49
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbSteppingModeTarget;
51
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbSteppingModeTarget;
50
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbResumeWithoutSignalCommand;
52
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbResumeWithoutSignalCommand;
51
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseResumeCommand;
53
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseResumeCommand;
Lines 113-118 Link Here
113
        final GdbRestartCommand fRestartCommand;
115
        final GdbRestartCommand fRestartCommand;
114
        final DsfTerminateCommand fTerminateCommand;
116
        final DsfTerminateCommand fTerminateCommand;
115
        final GdbConnectCommand fConnectCommand;
117
        final GdbConnectCommand fConnectCommand;
118
        final GdbSelectInferiorCommand fSelectInferiorCommand;
116
        final GdbDisconnectCommand fDisconnectCommand;
119
        final GdbDisconnectCommand fDisconnectCommand;
117
        final IDebugModelProvider fDebugModelProvider;
120
        final IDebugModelProvider fDebugModelProvider;
118
        final GdbSuspendTrigger fSuspendTrigger;
121
        final GdbSuspendTrigger fSuspendTrigger;
Lines 160-165 Link Here
160
            fRestartCommand = new GdbRestartCommand(session, fLaunch);
163
            fRestartCommand = new GdbRestartCommand(session, fLaunch);
161
            fTerminateCommand = new DsfTerminateCommand(session);
164
            fTerminateCommand = new DsfTerminateCommand(session);
162
            fConnectCommand = new GdbConnectCommand(session);
165
            fConnectCommand = new GdbConnectCommand(session);
166
            fSelectInferiorCommand = new GdbSelectInferiorCommand(session); 
163
            fDisconnectCommand = new GdbDisconnectCommand(session);
167
            fDisconnectCommand = new GdbDisconnectCommand(session);
164
            fSuspendTrigger = new GdbSuspendTrigger(session, fLaunch);
168
            fSuspendTrigger = new GdbSuspendTrigger(session, fLaunch);
165
            fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory();
169
            fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory();
Lines 185-190 Link Here
185
            session.registerModelAdapter(IRestartHandler.class, fRestartCommand);
189
            session.registerModelAdapter(IRestartHandler.class, fRestartCommand);
186
            session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
190
            session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
187
            session.registerModelAdapter(IConnect.class, fConnectCommand);
191
            session.registerModelAdapter(IConnect.class, fConnectCommand);
192
            session.registerModelAdapter(ISelectInferior.class, fSelectInferiorCommand);
188
            session.registerModelAdapter(IDisconnectHandler.class, fDisconnectCommand);
193
            session.registerModelAdapter(IDisconnectHandler.class, fDisconnectCommand);
189
            session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
194
            session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
190
            session.registerModelAdapter(IRefreshAllTarget.class, fRefreshAllTarget);
195
            session.registerModelAdapter(IRefreshAllTarget.class, fRefreshAllTarget);
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java (+27 lines)
Lines 12-22 Link Here
12
12
13
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.AbstractVMProviderActionDelegate;
13
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.AbstractVMProviderActionDelegate;
14
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
14
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
15
import org.eclipse.cdt.dsf.gdb.actions.ISelectInferior;
15
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
16
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
16
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
17
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
17
import org.eclipse.debug.ui.contexts.DebugContextEvent;
18
import org.eclipse.debug.ui.contexts.DebugContextEvent;
18
import org.eclipse.jface.action.IAction;
19
import org.eclipse.jface.action.IAction;
19
import org.eclipse.jface.viewers.ISelection;
20
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.TreeSelection;
20
import org.eclipse.ui.IViewPart;
22
import org.eclipse.ui.IViewPart;
21
23
22
/*
24
/*
Lines 54-63 Link Here
54
56
55
    @Override
57
    @Override
56
	public void selectionChanged(IAction action, ISelection selection) {
58
	public void selectionChanged(IAction action, ISelection selection) {
59
    	// DUMMY USAGE FOR MULTI PROCESS DEBUG
60
61
    	final ISelectInferior selectInferiorCommand = getSelectInferiorCommand();
62
    	
63
		if (selectInferiorCommand != null) {
64
			selectInferiorCommand.selectInferior( ((TreeSelection)selection).getFirstElement());
65
		}
66
67
		// DUMMY USAGE FOR MULTI PROCESS DEBUG
57
		super.selectionChanged(action, selection);
68
		super.selectionChanged(action, selection);
58
		updateEnablement();
69
		updateEnablement();
59
	}
70
	}
60
71
72
	// DUMMY USAGE FOR MULTI PROCESS DEBUG
73
	private ISelectInferior getSelectInferiorCommand() {
74
		ISelectInferior command = null;
75
		Object element = getViewerInput();
76
		if (element instanceof IDMVMContext) {
77
			IDMVMContext dmc = (IDMVMContext)element;
78
			command = (ISelectInferior)dmc.getAdapter(ISelectInferior.class);
79
		} else if (element instanceof GdbLaunch) {
80
			GdbLaunch launch = (GdbLaunch)element;
81
			command = (ISelectInferior)launch.getSession().getModelAdapter(ISelectInferior.class);
82
		}
83
84
		return command;
85
	}
86
	// DUMMY USAGE FOR MULTI PROCESS DEBUG
87
	
61
	private void updateEnablement() {
88
	private void updateEnablement() {
62
		boolean enabled = false;
89
		boolean enabled = false;
63
		final IConnect connectCommand = getConnectCommand();
90
		final IConnect connectCommand = getConnectCommand();
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java (-8 / +14 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 89-97 Link Here
89
90
90
    	// The list of processes used in the case of an ATTACH session
91
    	// The list of processes used in the case of an ATTACH session
91
    	IProcessExtendedInfo[] fProcessList = null;
92
    	IProcessExtendedInfo[] fProcessList = null;
92
    	DataRequestMonitor<Integer> fRequestMonitor;
93
    	DataRequestMonitor<HashMap<String, String>> fRequestMonitor;
93
94
94
    	public PromptForPidJob(String name, IProcessExtendedInfo[] procs, DataRequestMonitor<Integer> rm) {
95
    	public PromptForPidJob(String name, IProcessExtendedInfo[] procs, DataRequestMonitor<HashMap<String, String>> rm) {
95
    		super(name);
96
    		super(name);
96
    		fProcessList = procs;
97
    		fProcessList = procs;
97
    		fRequestMonitor = rm;
98
    		fRequestMonitor = rm;
Lines 116-123 Link Here
116
117
117
    		try {
118
    		try {
118
    			Object result = prompter.handleStatus(processPromptStatus, fProcessList);
119
    			Object result = prompter.handleStatus(processPromptStatus, fProcessList);
119
    			if (result instanceof Integer) {
120
    			if (result instanceof HashMap<?, ?>) {
120
    				fRequestMonitor.setData((Integer)result);
121
    				fRequestMonitor.setData((HashMap<String, String>)result);
121
    			} else {
122
    			} else {
122
    				fRequestMonitor.setStatus(NO_PID_STATUS);
123
    				fRequestMonitor.setStatus(NO_PID_STATUS);
123
    			}
124
    			}
Lines 130-135 Link Here
130
    	}
131
    	}
131
    };
132
    };
132
    
133
    
134
   
133
    public void connect(RequestMonitor requestMonitor)
135
    public void connect(RequestMonitor requestMonitor)
134
    {
136
    {
135
    	// Create a fake rm to avoid null pointer exceptions
137
    	// Create a fake rm to avoid null pointer exceptions
Lines 166-180 Link Here
166
										protected void handleSuccess() {
168
										protected void handleSuccess() {
167
											new PromptForPidJob(
169
											new PromptForPidJob(
168
													"Prompt for Process", procInfoList.toArray(new IProcessExtendedInfo[0]),   //$NON-NLS-1$
170
													"Prompt for Process", procInfoList.toArray(new IProcessExtendedInfo[0]),   //$NON-NLS-1$
169
													new DataRequestMonitor<Integer>(fExecutor, rm) {
171
													new DataRequestMonitor<HashMap<String, String>>(fExecutor, rm) {
170
														@Override
172
														@Override
171
														protected void handleSuccess() {
173
														protected void handleSuccess() {
174
															// ONUR ONUR DUMMY CALL
175
															String pid = getData().get("1");
176
															String file = getData().get("2");
177
															
172
															// New cycle, look for service again
178
															// New cycle, look for service again
173
															final IMIProcesses procService = fTracker.getService(IMIProcesses.class);
179
															final IMIProcesses procService = fTracker.getService(IMIProcesses.class);
174
															if (procService != null) {
180
															if (procService != null) {
175
																IProcessDMContext procDmc = procService.createProcessContext(controlCtx,
181
																IProcessDMContext procDmc = procService.createProcessContext(controlCtx,pid);
176
																		Integer.toString(getData()));
182
																		//Integer.toString(getData()));
177
																procService.attachDebuggerToProcess(procDmc, new DataRequestMonitor<IDMContext>(fExecutor, rm));
183
																procService.attachDebuggerToProcess(procDmc,file, new DataRequestMonitor<IDMContext>(fExecutor, rm));
178
															}
184
															}
179
														}
185
														}
180
													}).schedule();
186
													}).schedule();
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbSelectInferiorCommand.java (+59 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Ericsson and others.
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
 *     Ericsson - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
12
13
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
14
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
15
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
16
import org.eclipse.cdt.dsf.debug.service.IProcesses;
17
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
18
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
19
import org.eclipse.cdt.dsf.gdb.actions.ISelectInferior;
20
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
21
import org.eclipse.cdt.dsf.gdb.service.GDBProcesses_7_2;
22
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
23
import org.eclipse.cdt.dsf.service.DsfSession;
24
25
public class GdbSelectInferiorCommand implements ISelectInferior {
26
    
27
	private final DsfExecutor fExecutor;
28
    private final DsfServicesTracker fTracker;
29
    
30
    public GdbSelectInferiorCommand(DsfSession session) {
31
        fExecutor = session.getExecutor();
32
        fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
33
    }    
34
35
    public void dispose() {
36
        fTracker.dispose();
37
    }
38
39
	public void selectInferior(Object object) {
40
		// Create a fake rm to avoid null pointer exceptions
41
	final RequestMonitor rm = new RequestMonitor(fExecutor, null);
42
    	
43
		final IProcesses procService = fTracker.getService(IProcesses.class);
44
		final ICommandControlService commandControl = fTracker.getService(ICommandControlService.class);
45
46
		//final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class);
47
		if (procService != null && commandControl != null) {  
48
			
49
			((GDBProcesses_7_2)procService).switchInferior(commandControl.getContext(), object, 
50
					new DataRequestMonitor<IProcessDMContext>(fExecutor, rm) {
51
						@Override
52
						protected void handleSuccess() {
53
								rm.done();
54
						}
55
					});
56
		}
57
	}
58
59
}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java (-6 / +58 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
12
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
13
13
14
import java.io.File;
15
import java.util.HashMap;
16
14
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
17
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
15
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
18
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
16
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo;
19
import org.eclipse.cdt.dsf.gdb.launching.IProcessExtendedInfo;
Lines 21-32 Link Here
21
import org.eclipse.core.runtime.Path;
24
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.Status;
25
import org.eclipse.core.runtime.Status;
23
import org.eclipse.debug.core.IStatusHandler;
26
import org.eclipse.debug.core.IStatusHandler;
27
import org.eclipse.jface.dialogs.ErrorDialog;
24
import org.eclipse.jface.dialogs.InputDialog;
28
import org.eclipse.jface.dialogs.InputDialog;
25
import org.eclipse.jface.dialogs.MessageDialog;
29
import org.eclipse.jface.dialogs.MessageDialog;
26
import org.eclipse.jface.viewers.ILabelProvider;
30
import org.eclipse.jface.viewers.ILabelProvider;
27
import org.eclipse.jface.viewers.LabelProvider;
31
import org.eclipse.jface.viewers.LabelProvider;
28
import org.eclipse.jface.window.Window;
32
import org.eclipse.jface.window.Window;
29
import org.eclipse.swt.graphics.Image;
33
import org.eclipse.swt.graphics.Image;
34
import org.eclipse.swt.widgets.FileDialog;
30
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
36
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
32
37
Lines 62-74 Link Here
62
                                                 LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to"), //$NON-NLS-1$
67
                                                 LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to"), //$NON-NLS-1$
63
                                                 null, null);
68
                                                 null, null);
64
69
70
			String pidStr = null;
71
			
65
			if (dialog.open() == Window.OK) {
72
			if (dialog.open() == Window.OK) {
66
				String pidStr = dialog.getValue();
73
				pidStr = dialog.getValue();
67
				try {
74
				/*try {
68
					return Integer.parseInt(pidStr);
75
					return Integer.parseInt(pidStr);
69
				} catch (NumberFormatException e) {
76
				} catch (NumberFormatException e) {
77
				}*/
78
			}
79
			
80
			FileDialog fdialog = new FileDialog(shell);
81
			fdialog.setText(LaunchMessages.getString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$
82
			String res = fdialog.open();
83
			if (res != null) {
84
				File file = new File(res);
85
				if (!file.exists() || !file.canRead()) {
86
					ErrorDialog.openError(shell, LaunchMessages.getString("CoreFileLaunchDelegate.postmortem_debugging_failed"), //$NON-NLS-1$
87
							LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_accessible"), //$NON-NLS-1$
88
							new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(),
89
									ICDTLaunchConfigurationConstants.ERR_NO_COREFILE,
90
									LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_readable"), null)); //$NON-NLS-1$
70
				}
91
				}
92
				//return res;
71
			}
93
			}
94
95
			// ONUR ONUR DUMMY RETURN VALUE
96
			HashMap<String, String> params = new HashMap<String, String>();
97
			params.put("1", pidStr);
98
			params.put("2", res);
99
			return params;
72
		} else {
100
		} else {
73
			ILabelProvider provider = new LabelProvider() {
101
			ILabelProvider provider = new LabelProvider() {
74
				/*
102
				/*
Lines 138-152 Link Here
138
			dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
166
			dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
139
167
140
			dialog.setElements(plist);
168
			dialog.setElements(plist);
169
			
170
			IProcessExtendedInfo info = null;
171
			
141
			if (dialog.open() == Window.OK) {
172
			if (dialog.open() == Window.OK) {
142
				IProcessExtendedInfo info = (IProcessExtendedInfo)dialog.getFirstResult();
173
				info = (IProcessExtendedInfo)dialog.getFirstResult();
143
				if (info != null) {
174
				//if (info != null) {
144
					return new Integer(info.getPid());
175
				//	return new Integer(info.getPid());
176
				//}
177
			}
178
			FileDialog fdialog = new FileDialog(shell);
179
			fdialog.setText(LaunchMessages.getString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$
180
			String res = fdialog.open();
181
			if (res != null) {
182
				File file = new File(res);
183
				if (!file.exists() || !file.canRead()) {
184
					ErrorDialog.openError(shell, LaunchMessages.getString("CoreFileLaunchDelegate.postmortem_debugging_failed"), //$NON-NLS-1$
185
							LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_accessible"), //$NON-NLS-1$
186
							new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(),
187
									ICDTLaunchConfigurationConstants.ERR_NO_COREFILE,
188
									LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_readable"), null)); //$NON-NLS-1$
145
				}
189
				}
190
				//return res;
146
			}
191
			}
192
193
			// ONUR ONUR DUMMY RETURN VALUE
194
			HashMap<String, String> params = new HashMap<String, String>();
195
			params.put("1", String.valueOf(info.getPid()));
196
			params.put("2", res);
197
			return params;
198
			
147
		}
199
		}
148
		
200
		
149
		return null;
201
		//return null;
150
	}
202
	}
151
203
152
}
204
}

Return to bug 237306