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

Collapse All | Expand All

(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java (-19 / +48 lines)
Lines 375-380 Link Here
375
     *  A map of thread id to thread group id.  We use this to find out to which threadGroup a thread belongs.
375
     *  A map of thread id to thread group id.  We use this to find out to which threadGroup a thread belongs.
376
     */
376
     */
377
    private Map<String, String> fThreadToGroupMap = new HashMap<String, String>();
377
    private Map<String, String> fThreadToGroupMap = new HashMap<String, String>();
378
    /**
379
     *  A map of thread group id to process id.  We use this to find out to which pid a group refers.
380
     */
381
    private Map<String, String> fGroupToPidMap = new HashMap<String, String>();
378
382
379
    private IGDBControl fCommandControl;
383
    private IGDBControl fCommandControl;
380
    private IGDBBackend fBackend;
384
    private IGDBBackend fBackend;
Lines 532-541 Link Here
532
    			}
536
    			}
533
    		}
537
    		}
534
    	}
538
    	}
535
    	IProcessDMContext processDmc = createProcessContext(controlDmc, groupId);
539
    	
536
    	return createContainerContext(processDmc, groupId);
540
    	return createContainerContextFromGroupId(controlDmc, groupId);
537
    }
541
    }
538
542
543
    private IMIContainerDMContext createContainerContextFromGroupId(ICommandControlDMContext controlDmc, String groupId) {
544
    	String pid = fGroupToPidMap.get(groupId);
545
    	if (pid == null) {
546
    		pid = groupId;
547
    	}
548
    	IProcessDMContext processDmc = createProcessContext(controlDmc, pid);
549
    	return createContainerContext(processDmc, groupId);
550
    }
551
    
539
    public IMIExecutionDMContext[] getExecutionContexts(IMIContainerDMContext containerDmc) {
552
    public IMIExecutionDMContext[] getExecutionContexts(IMIContainerDMContext containerDmc) {
540
    	String groupId = containerDmc.getGroupId();
553
    	String groupId = containerDmc.getGroupId();
541
    	List<IMIExecutionDMContext> execDmcList = new ArrayList<IMIExecutionDMContext>(); 
554
    	List<IMIExecutionDMContext> execDmcList = new ArrayList<IMIExecutionDMContext>(); 
Lines 748-758 Link Here
748
						@Override
761
						@Override
749
						protected void handleFailure() {
762
						protected void handleFailure() {
750
							// If the target is not available, generate the list ourselves
763
							// If the target is not available, generate the list ourselves
751
							IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[fDebuggedProcessesAndNames.size()];
764
							IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[fGroupToPidMap.size()];
752
							int i = 0;
765
							int i = 0;
753
							for (String groupId : fDebuggedProcessesAndNames.keySet()) {
766
							for (String groupId : fGroupToPidMap.keySet()) {
754
								IProcessDMContext processDmc = createProcessContext(controlDmc, groupId);
767
								containerDmcs[i++] = createContainerContextFromGroupId(controlDmc, groupId);
755
								containerDmcs[i++] = createContainerContext(processDmc, groupId);
756
							}
768
							}
757
							rm.setData(containerDmcs);
769
							rm.setData(containerDmcs);
758
							rm.done();
770
							rm.done();
Lines 791-799 Link Here
791
		// code can be removed when GDB 7.2 is released
803
		// code can be removed when GDB 7.2 is released
792
		// START OF WORKAROUND
804
		// START OF WORKAROUND
793
		if (groups.length == 0 && fBackend.getSessionType() == SessionType.CORE) {
805
		if (groups.length == 0 && fBackend.getSessionType() == SessionType.CORE) {
794
			String groupId = MIProcesses.UNIQUE_GROUP_ID;
806
			return new IMIContainerDMContext[] {createContainerContextFromGroupId(controlDmc, MIProcesses.UNIQUE_GROUP_ID)};
795
			IProcessDMContext processDmc = createProcessContext(controlDmc, groupId);
796
			return new IMIContainerDMContext[] {createContainerContext(processDmc, groupId)};
797
		}
807
		}
798
		// END OF WORKAROUND to be removed when GDB 7.2 is available
808
		// END OF WORKAROUND to be removed when GDB 7.2 is available
799
		
809
		
Lines 811-818 Link Here
811
				continue;
821
				continue;
812
			}
822
			}
813
			String groupId = group.getGroupId();
823
			String groupId = group.getGroupId();
814
			IProcessDMContext procDmc = createProcessContext(controlDmc, groupId); 
824
			containerDmcs.add(createContainerContextFromGroupId(controlDmc, groupId));
815
			containerDmcs.add(createContainerContext(procDmc, groupId));
816
		}
825
		}
817
		return containerDmcs.toArray(new IMIContainerDMContext[containerDmcs.size()]);
826
		return containerDmcs.toArray(new IMIContainerDMContext[containerDmcs.size()]);
818
	}
827
	}
Lines 1020-1025 Link Here
1020
    					   "thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
1029
    					   "thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
1021
    				
1030
    				
1022
    				String groupId = null;
1031
    				String groupId = null;
1032
    				String pId = null;
1023
1033
1024
    				MIResult[] results = exec.getMIResults();
1034
    				MIResult[] results = exec.getMIResults();
1025
    				for (int i = 0; i < results.length; i++) {
1035
    				for (int i = 0; i < results.length; i++) {
Lines 1029-1047 Link Here
1029
    						if (val instanceof MIConst) {
1039
    						if (val instanceof MIConst) {
1030
    							groupId = ((MIConst) val).getString().trim();
1040
    							groupId = ((MIConst) val).getString().trim();
1031
    						}
1041
    						}
1042
    					} else if (var.equals("pid")) { //$NON-NLS-1$
1043
    						// Available starting with GDB 7.2
1044
    						if (val instanceof MIConst) {
1045
    							pId = ((MIConst) val).getString().trim();
1046
    						}
1032
    					}
1047
    					}
1033
    				}
1048
    				}
1034
1049
1050
    				if (pId == null) {
1051
    					// Before GDB 7.2, the groupId was the pid of the process
1052
    					pId = groupId;
1053
    				}
1054
1035
    				if (groupId != null) {
1055
    				if (groupId != null) {
1036
    					if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$
1056
    					if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$
1037
    						fDebuggedProcessesAndNames.put(groupId, ""); //$NON-NLS-1$
1057
    						
1058
    						fGroupToPidMap.put(groupId, pId);
1059
    						
1060
    						fDebuggedProcessesAndNames.put(pId, ""); //$NON-NLS-1$
1038
    					
1061
    					
1039
							// GDB is debugging a new process. Let's fetch its
1062
							// GDB is debugging a new process. Let's fetch its
1040
							// name and remember it. In order to get the name,
1063
							// name and remember it. In order to get the name,
1041
							// we have to request all running processes, not
1064
							// we have to request all running processes, not
1042
							// just the ones being debugged. We got a lot more 
1065
							// just the ones being debugged. We got a lot more 
1043
    						// information when we request all processes.
1066
    						// information when we request all processes.
1044
        					final String finalGroupId = groupId;
1067
        					final String finalPId = pId;
1045
    						fListThreadGroupsAvailableCache.execute(
1068
    						fListThreadGroupsAvailableCache.execute(
1046
    								fCommandFactory.createMIListThreadGroups(fCommandControl.getContext(), true),
1069
    								fCommandFactory.createMIListThreadGroups(fCommandControl.getContext(), true),
1047
    								new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), null) {
1070
    								new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), null) {
Lines 1052-1061 Link Here
1052
    										// sending of this command.
1075
    										// sending of this command.
1053
    										fListThreadGroupsAvailableCache.reset();
1076
    										fListThreadGroupsAvailableCache.reset();
1054
1077
1078
    										// Note that the output of the "-list-thread-groups --available" command
1079
    										// still shows the pid as a groupId, even for GDB 7.2.
1055
    										if (isSuccess()) {
1080
    										if (isSuccess()) {
1056
    											for (IThreadGroupInfo groupInfo : getData().getGroupList()) {
1081
    											for (IThreadGroupInfo groupInfo : getData().getGroupList()) {
1057
    												if (groupInfo.getPid().equals(finalGroupId)) {
1082
    												if (groupInfo.getPid().equals(finalPId)) {
1058
    													fDebuggedProcessesAndNames.put(finalGroupId, groupInfo.getName());
1083
    													fDebuggedProcessesAndNames.put(finalPId, groupInfo.getName());
1059
    												}
1084
    												}
1060
    											}
1085
    											}
1061
    										}
1086
    										}
Lines 1068-1077 Link Here
1068
	    											IProcessList list = null;
1093
	    											IProcessList list = null;
1069
	    											try {
1094
	    											try {
1070
	    												list = CCorePlugin.getDefault().getProcessList();
1095
	    												list = CCorePlugin.getDefault().getProcessList();
1071
	        											int groupId_int = Integer.parseInt(finalGroupId);
1096
	        											int pId_int = Integer.parseInt(finalPId);
1072
	        											for (IProcessInfo procInfo : list.getProcessList()) {
1097
	        											for (IProcessInfo procInfo : list.getProcessList()) {
1073
	        												if (procInfo.getPid() == groupId_int) {
1098
	        												if (procInfo.getPid() == pId_int) {
1074
	        													fDebuggedProcessesAndNames.put(finalGroupId, procInfo.getName());
1099
	        													fDebuggedProcessesAndNames.put(finalPId, procInfo.getName());
1100
	        													break;
1075
	        												}
1101
	        												}
1076
	        											}
1102
	        											}
1077
	    											} catch (CoreException e) {
1103
	    											} catch (CoreException e) {
Lines 1081-1088 Link Here
1081
    									}
1107
    									}
1082
    								});
1108
    								});
1083
    					} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
1109
    					} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
1110
    						
1111
    						fGroupToPidMap.remove(groupId);
1112
1084
    						// GDB is no longer debugging this process.  Remove it from our list.
1113
    						// GDB is no longer debugging this process.  Remove it from our list.
1085
    						fDebuggedProcessesAndNames.remove(groupId);
1114
    						fDebuggedProcessesAndNames.remove(pId);
1086
    						
1115
    						
1087
    						// Remove any entries for that group from our thread to group map
1116
    						// Remove any entries for that group from our thread to group map
1088
    						// When detaching from a group, we won't have received any thread-exited event
1117
    						// When detaching from a group, we won't have received any thread-exited event
(-)src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor_7_0.java (-5 / +36 lines)
Lines 11-18 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.cdt.dsf.mi.service.command;
12
package org.eclipse.cdt.dsf.mi.service.command;
13
13
14
import java.util.HashMap;
14
import java.util.LinkedList;
15
import java.util.LinkedList;
15
import java.util.List;
16
import java.util.List;
17
import java.util.Map;
16
18
17
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
19
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
18
import org.eclipse.cdt.dsf.datamodel.DMContexts;
20
import org.eclipse.cdt.dsf.datamodel.DMContexts;
Lines 89-95 Link Here
89
    private final ICommandControlDMContext fControlDmc; 
91
    private final ICommandControlDMContext fControlDmc; 
90
    
92
    
91
    private final DsfServicesTracker fServicesTracker;
93
    private final DsfServicesTracker fServicesTracker;
92
    
94
95
    /**
96
     *  A map of thread group id to process id.  We use this to find out to which pid a group refers.
97
     */
98
    private Map<String, String> fGroupToPidMap = new HashMap<String, String>();
99
93
    /**
100
    /**
94
     * Creates the event processor and registers it as listener with the debugger
101
     * Creates the event processor and registers it as listener with the debugger
95
     * control.
102
     * control.
Lines 197-203 Link Here
197
    		    	IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
204
    		    	IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
198
205
199
    		    	if (procService != null) {
206
    		    	if (procService != null) {
200
    		    		IProcessDMContext procDmc = procService.createProcessContext(fControlDmc, groupId);
207
    		        	String pid = fGroupToPidMap.get(groupId);
208
    		        	if (pid == null) {
209
    		        		pid = groupId;
210
    		        	}
211
    		    		IProcessDMContext procDmc = procService.createProcessContext(fControlDmc, pid);
201
    		    		IContainerDMContext processContainerDmc = procService.createContainerContext(procDmc, groupId);
212
    		    		IContainerDMContext processContainerDmc = procService.createContainerContext(procDmc, groupId);
202
213
203
    		    		MIEvent<?> event = null;
214
    		    		MIEvent<?> event = null;
Lines 216-221 Link Here
216
    					   "thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
227
    					   "thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
217
    				
228
    				
218
    				String groupId = null;
229
    				String groupId = null;
230
    				String pId = null;
219
231
220
    				MIResult[] results = exec.getMIResults();
232
    				MIResult[] results = exec.getMIResults();
221
    				for (int i = 0; i < results.length; i++) {
233
    				for (int i = 0; i < results.length; i++) {
Lines 225-241 Link Here
225
    						if (val instanceof MIConst) {
237
    						if (val instanceof MIConst) {
226
    							groupId = ((MIConst) val).getString().trim();
238
    							groupId = ((MIConst) val).getString().trim();
227
    						}
239
    						}
240
    					} else if (var.equals("pid")) { //$NON-NLS-1$
241
    						// Available starting with GDB 7.2
242
    						if (val instanceof MIConst) {
243
    							pId = ((MIConst) val).getString().trim();
244
    						}
228
    					}
245
    					}
229
    				}
246
    				}
247
    				
248
    				if (pId == null) {
249
    					// Before GDB 7.2, the groupId was the pid of the process
250
    					pId = groupId;
251
    				}
230
252
231
					IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
253
					IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
232
    				if (groupId != null && procService != null) {
254
    				if (pId != null && procService != null) {
233
    					IProcessDMContext procDmc = procService.createProcessContext(fControlDmc, groupId);
255
    					IProcessDMContext procDmc = procService.createProcessContext(fControlDmc, pId);
234
256
235
    					MIEvent<?> event = null;
257
    					MIEvent<?> event = null;
236
    					if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$
258
    					if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$
259
    						fGroupToPidMap.put(groupId, pId);
260
237
    						event = new MIThreadGroupCreatedEvent(procDmc, exec.getToken(), groupId);
261
    						event = new MIThreadGroupCreatedEvent(procDmc, exec.getToken(), groupId);
238
    					} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
262
    					} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$
263
    						fGroupToPidMap.remove(groupId);
264
239
    						event = new MIThreadGroupExitedEvent(procDmc, exec.getToken(), groupId);
265
    						event = new MIThreadGroupExitedEvent(procDmc, exec.getToken(), groupId);
240
    					}
266
    					}
241
267
Lines 295-301 Link Here
295
   				procDmc = DMContexts.getAncestorOfType(containerDmc, IProcessDMContext.class);
321
   				procDmc = DMContexts.getAncestorOfType(containerDmc, IProcessDMContext.class);
296
    		} else {
322
    		} else {
297
    			// This code would only trigger if the groupId was provided by MI
323
    			// This code would only trigger if the groupId was provided by MI
298
    			procDmc = procService.createProcessContext(fControlDmc, groupId);
324
	        	String pid = fGroupToPidMap.get(groupId);
325
	        	if (pid == null) {
326
	        		pid = groupId;
327
	        	}
328
329
    			procDmc = procService.createProcessContext(fControlDmc, pid);
299
    			containerDmc = procService.createContainerContext(procDmc, groupId);
330
    			containerDmc = procService.createContainerContext(procDmc, groupId);
300
    		}
331
    		}
301
332

Return to bug 317500