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_7_0.java (-2 / +5 lines)
Lines 7-12 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     Ericsson - initial API and implementation
9
 *     Ericsson - initial API and implementation
10
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.service;
12
package org.eclipse.cdt.dsf.gdb.service;
12
13
Lines 689-695 Link Here
689
    	rm.done();
690
    	rm.done();
690
    }
691
    }
691
    
692
    
692
    private boolean doIsDebuggerAttachSupported() {
693
    /** @since 4.0 */
694
    protected boolean doIsDebuggerAttachSupported() {
693
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
695
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
694
    	if (backend != null) {
696
    	if (backend != null) {
695
    		return backend.getIsAttachSession();
697
    		return backend.getIsAttachSession();
Lines 728-734 Link Here
728
	    }
730
	    }
729
	}
731
	}
730
732
731
    private boolean doCanDetachDebuggerFromProcess() {
733
    /** @since 4.0 */
734
    protected boolean doCanDetachDebuggerFromProcess() {
732
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
735
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
733
    	if (backend != null) {
736
    	if (backend != null) {
734
    		return backend.getIsAttachSession() && fCommandControl.isConnected();
737
    		return backend.getIsAttachSession() && fCommandControl.isConnected();
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java (+154 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 TUBITAK BILGEM-ITI 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
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.service;
12
13
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
14
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
15
import org.eclipse.cdt.dsf.datamodel.DMContexts;
16
import org.eclipse.cdt.dsf.datamodel.IDMContext;
17
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
18
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
19
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
20
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
21
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
22
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
23
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
24
import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo;
25
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
26
import org.eclipse.cdt.dsf.service.DsfSession;
27
import org.eclipse.core.runtime.IStatus;
28
import org.eclipse.core.runtime.Status;
29
30
/**
31
 * Adding support for multi-process with GDB 7.2
32
 * 
33
 * @since 4.0
34
 */
35
public class GDBProcesses_7_2 extends GDBProcesses_7_1 {
36
    
37
    private CommandFactory fCommandFactory;
38
    private IGDBControl fCommandControl;
39
    
40
	public GDBProcesses_7_2(DsfSession session) {
41
		super(session);
42
	}
43
44
	@Override
45
	public void initialize(final RequestMonitor requestMonitor) {
46
		super.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
47
			@Override
48
			protected void handleSuccess() {
49
				doInitialize(requestMonitor);
50
			}
51
		});
52
	}
53
54
	/**
55
	 * This method initializes this service after our superclass's initialize()
56
	 * method succeeds.
57
	 * 
58
	 * @param requestMonitor
59
	 *            The call-back object to notify when this service's
60
	 *            initialization is done.
61
	 */
62
	private void doInitialize(RequestMonitor requestMonitor) {
63
		fCommandControl = getServicesTracker().getService(IGDBControl.class);
64
        fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
65
    	requestMonitor.done();
66
	}
67
68
	@Override
69
	public void shutdown(RequestMonitor requestMonitor) {
70
		super.shutdown(requestMonitor);
71
	}
72
	
73
	@Override
74
    public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> rm) {
75
		if (procCtx instanceof IMIProcessDMContext) {
76
	    	if (!doIsDebuggerAttachSupported()) {
77
	            rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$
78
	            rm.done();    		
79
	    		return;
80
	    	}
81
	    	
82
	    	ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(procCtx, ICommandControlDMContext.class);
83
	        fCommandControl.queueCommand(
84
	        		fCommandFactory.createMIAddInferior(controlDmc),
85
	        		new DataRequestMonitor<MIAddInferiorInfo>(getExecutor(), rm) {
86
	        			@Override
87
	        			protected void handleSuccess() {
88
	        				final String groupId = getData().getGroupId();
89
	        				if (groupId == null || groupId.trim().length() == 0) {
90
     				           rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid gdb group id.", null)); //$NON-NLS-1$
91
    				           rm.done();
92
    				           return;
93
        					}
94
	        				
95
	        				final IMIContainerDMContext containerDmc = createContainerContext(procCtx, groupId);
96
	        				fCommandControl.queueCommand(
97
	        						fCommandFactory.createMITargetAttach(containerDmc, ((IMIProcessDMContext)procCtx).getProcId()),
98
	        						new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
99
	        							@Override
100
	        							protected void handleSuccess() {
101
	        								rm.setData(containerDmc);
102
	        								rm.done();
103
	        							}
104
	        						});
105
	        			}
106
	        		});
107
	    } else {
108
            rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$
109
            rm.done();
110
	    }
111
	}
112
	
113
	@Override
114
    public void detachDebuggerFromProcess(IDMContext dmc, final RequestMonitor rm) {
115
    	
116
		ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class);
117
		final IMIContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IMIContainerDMContext.class);
118
		
119
    	if (controlDmc != null && containerDmc != null) {
120
        	if (!doCanDetachDebuggerFromProcess()) {
121
                rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Detach not supported.", null)); //$NON-NLS-1$
122
                rm.done();
123
                return;
124
        	}
125
126
        	fCommandControl.queueCommand(
127
        			fCommandFactory.createMITargetDetach(controlDmc, containerDmc.getGroupId()),
128
    				new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
129
    					@Override
130
    					protected void handleCompleted() {
131
    						if (isSuccess()) {
132
    						// Bug in GDB 7.2 where removing an inferior will lead to a crash when running other processes.
133
    						// I'm hoping it will be fixed in 7.2.1
134
//    			        	fCommandControl.queueCommand(
135
//    			        			fCommandFactory.createMIRemoveInferior(fCommandControl.getContext(), containerDmc.getGroupId()),
136
//    			    				new DataRequestMonitor<MIInfo>(getExecutor(), rm));
137
    						} else {
138
    							// This command fails with GDB 7.2 because of a GDB bug, which was fixed with GDB 7.2.1
139
    							// In case we get here, we assume we are using GDB 7.2 (although we should not) and we work
140
    							// around it.
141
    							// Also, with GDB 7.2, removing the inferior does not work because of another bug, so we just don't do it.
142
    					       	fCommandControl.queueCommand(
143
    				        			fCommandFactory.createMITargetDetach(containerDmc),
144
    				    				new DataRequestMonitor<MIInfo>(getExecutor(), rm));
145
    						}
146
    					}
147
    				});
148
    	} else {
149
            rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid context.", null)); //$NON-NLS-1$
150
            rm.done();
151
	    }
152
	}
153
}
154
(-)src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java (+8 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Ericsson - initial API and implementation
9
 *     Ericsson - initial API and implementation
10
 *     Nokia - create and use backend service. 
10
 *     Nokia - create and use backend service. 
11
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.cdt.dsf.gdb.service;
13
package org.eclipse.cdt.dsf.gdb.service;
13
14
Lines 27-32 Link Here
27
import org.eclipse.cdt.dsf.gdb.service.command.CommandFactory_6_8;
28
import org.eclipse.cdt.dsf.gdb.service.command.CommandFactory_6_8;
28
import org.eclipse.cdt.dsf.gdb.service.command.GDBControl;
29
import org.eclipse.cdt.dsf.gdb.service.command.GDBControl;
29
import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_0;
30
import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_0;
31
import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_2;
30
import org.eclipse.cdt.dsf.mi.service.CSourceLookup;
32
import org.eclipse.cdt.dsf.mi.service.CSourceLookup;
31
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
33
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
32
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
34
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
Lines 100-105 Link Here
100
	}
102
	}
101
	
103
	
102
	protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) {
104
	protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) {
105
		if (GDB_7_2_VERSION.compareTo(fVersion) <= 0) {
106
			return new GDBControl_7_2(session, config, new CommandFactory_6_8());
107
		}
103
		if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) {
108
		if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) {
104
			return new GDBControl_7_0(session, config, new CommandFactory_6_8());
109
			return new GDBControl_7_0(session, config, new CommandFactory_6_8());
105
		}
110
		}
Lines 139-144 Link Here
139
		
144
		
140
	@Override
145
	@Override
141
	protected IProcesses createProcessesService(DsfSession session) {
146
	protected IProcesses createProcessesService(DsfSession session) {
147
		if (GDB_7_2_VERSION.compareTo(fVersion) <= 0) {
148
			return new GDBProcesses_7_2(session);
149
		}
142
		if (GDB_7_1_VERSION.compareTo(fVersion) <= 0) {
150
		if (GDB_7_1_VERSION.compareTo(fVersion) <= 0) {
143
			return new GDBProcesses_7_1(session);
151
			return new GDBProcesses_7_1(session);
144
		}
152
		}
(-)src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_2.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 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.service.command;
12
13
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
14
import org.eclipse.cdt.dsf.service.DsfSession;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
17
/**
18
 * Turn on the use of the --thread-group option for GDB 7.2
19
 * @since 4.0
20
 */
21
public class GDBControl_7_2 extends GDBControl_7_0 implements IGDBControl {
22
    public GDBControl_7_2(DsfSession session, ILaunchConfiguration config, CommandFactory factory) {
23
    	super(session, config, factory);
24
    	setUseThreadGroupOptions(true);
25
    }
26
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java (-9 / +50 lines)
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Wind River Systems - initial API and implementation
9
 *     Wind River Systems - initial API and implementation
10
 *     Ericsson 		  - Modified for handling of multiple stacks and threads
10
 *     Ericsson 		  - Modified for handling of multiple stacks and threads
11
 *     Nokia - create and use backend service. 
11
 *     Nokia - create and use backend service.
12
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.cdt.dsf.mi.service.command;
14
package org.eclipse.cdt.dsf.mi.service.command;
14
15
Lines 40-45 Link Here
40
import org.eclipse.cdt.dsf.debug.service.command.IEventListener;
41
import org.eclipse.cdt.dsf.debug.service.command.IEventListener;
41
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
42
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
42
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
43
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
44
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
43
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
45
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
44
import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand;
46
import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand;
45
import org.eclipse.cdt.dsf.mi.service.command.commands.RawCommand;
47
import org.eclipse.cdt.dsf.mi.service.command.commands.RawCommand;
Lines 86-91 Link Here
86
    private int fCurrentStackLevel  = -1;
88
    private int fCurrentStackLevel  = -1;
87
    private String fCurrentThreadId = null;
89
    private String fCurrentThreadId = null;
88
    
90
    
91
    // boolean for --thread-group option which helps to handle multiple inferior behavior.
92
    // Since GDB.7.1
93
    private boolean fUseThreadGroupOption;
89
    
94
    
90
    private final BlockingQueue<CommandHandle> fTxCommands = new LinkedBlockingQueue<CommandHandle>();
95
    private final BlockingQueue<CommandHandle> fTxCommands = new LinkedBlockingQueue<CommandHandle>();
91
    private final Map<Integer, CommandHandle>  fRxCommands = Collections.synchronizedMap(new HashMap<Integer, CommandHandle>());
96
    private final Map<Integer, CommandHandle>  fRxCommands = Collections.synchronizedMap(new HashMap<Integer, CommandHandle>());
Lines 124-140 Link Here
124
    private CommandFactory fCommandFactory;
129
    private CommandFactory fCommandFactory;
125
    
130
    
126
    public AbstractMIControl(DsfSession session) {
131
    public AbstractMIControl(DsfSession session) {
127
        super(session);
132
    	this(session, false, false, new CommandFactory());
128
        fUseThreadAndFrameOptions = false;
129
        fCommandFactory = new CommandFactory();
130
    }
133
    }
131
134
132
    /**
135
    /**
133
     * @since 3.0
136
     * @since 3.0
134
     */
137
     */
135
    public AbstractMIControl(DsfSession session, boolean useThreadAndFrameOptions, CommandFactory factory) {
138
    public AbstractMIControl(DsfSession session, boolean useThreadAndFrameOptions, CommandFactory factory) {
139
    	this(session, false, useThreadAndFrameOptions, factory);
140
    }
141
142
    /**
143
	 * @since 4.0
144
	 */
145
    public AbstractMIControl(DsfSession session, boolean useThreadGroupOption, boolean useThreadAndFrameOptions, CommandFactory factory) {
136
        super(session);
146
        super(session);
147
        
148
        // If we use the --thread-group option, we should automatically use the --thread/--frame option
149
        // since the --thread-group was added to GDB later than the --thread/--frame option
150
        assert useThreadGroupOption ? useThreadAndFrameOptions : true;
151
        
152
        fUseThreadGroupOption     = useThreadGroupOption;
137
        fUseThreadAndFrameOptions = useThreadAndFrameOptions;
153
        fUseThreadAndFrameOptions = useThreadAndFrameOptions;
154
        if (fUseThreadGroupOption) {
155
        	// If we use --thread-group option, we should automatically use the --thread option
156
        	fUseThreadAndFrameOptions = true;
157
        }
138
        fCommandFactory = factory;
158
        fCommandFactory = factory;
139
    }
159
    }
140
160
Lines 165-170 Link Here
165
    }
185
    }
166
    
186
    
167
    /**
187
    /**
188
	 * @since 4.0
189
	 */
190
    protected void setUseThreadGroupOptions(boolean shouldUse) {
191
    	fUseThreadGroupOption = shouldUse;
192
    	if (shouldUse) {
193
    		fUseThreadAndFrameOptions = true;
194
    	}
195
    }
196
    
197
    /**
168
     * @since 3.0
198
     * @since 3.0
169
     */
199
     */
170
    public CommandFactory getCommandFactory() {
200
    public CommandFactory getCommandFactory() {
Lines 510-515 Link Here
510
        	return null;
540
        	return null;
511
        } 
541
        } 
512
        
542
        
543
        public String getGroupId() {
544
        	IMIContainerDMContext containerCtx = DMContexts.getAncestorOfType(fCommand.getContext(), IMIContainerDMContext.class);
545
        	if(containerCtx != null)
546
        		return containerCtx.getGroupId();
547
        	return null;
548
        } 
549
        
513
        @Override
550
        @Override
514
        public String toString() {
551
        public String toString() {
515
            return Integer.toString(fTokenId) + fCommand;
552
            return Integer.toString(fTokenId) + fCommand;
Lines 567-579 Link Here
567
                 */
604
                 */
568
605
569
                final String str;
606
                final String str;
570
				// Not all commands support the --thread/--frame options (e.g., CLI commands)
607
                if (commandHandle.getCommand() instanceof RawCommand) {
571
                if (fUseThreadAndFrameOptions && commandHandle.getCommand().supportsThreadAndFrameOptions()) {
572
                	str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand(commandHandle.getThreadId(),
573
                			                                                                       commandHandle.getStackFrameId());
574
                } else if (commandHandle.getCommand() instanceof RawCommand) {
575
                	// RawCommands CANNOT have a token id: GDB would read it as part of the RawCommand!
608
                	// RawCommands CANNOT have a token id: GDB would read it as part of the RawCommand!
576
                	str = commandHandle.getCommand().constructCommand();
609
                	str = commandHandle.getCommand().constructCommand();
610
                } else if (fUseThreadGroupOption) {
611
                	// Implies that fUseThreadAndFrameOptions == true
612
                	str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand(commandHandle.getGroupId(),
613
							   																	   commandHandle.getThreadId(),
614
							   																	   commandHandle.getStackFrameId());                	
615
                } else if (fUseThreadAndFrameOptions) {
616
                	str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand(commandHandle.getThreadId(),
617
							   																	   commandHandle.getStackFrameId());
577
                } else {
618
                } else {
578
                	str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand();
619
                	str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand();
579
                }
620
                }
(-)src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java (+25 lines)
Lines 12-17 Link Here
12
 *     Anna Dushistova (Mentor Graphics) - [318322] Add set solib-absolute-prefix
12
 *     Anna Dushistova (Mentor Graphics) - [318322] Add set solib-absolute-prefix
13
 *     Vladimir Prus (CodeSourcery) - Support for -data-read-memory-bytes (bug 322658)
13
 *     Vladimir Prus (CodeSourcery) - Support for -data-read-memory-bytes (bug 322658)
14
 *     Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
14
 *     Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
15
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
15
 *******************************************************************************/
16
 *******************************************************************************/
16
17
17
package org.eclipse.cdt.dsf.mi.service.command;
18
package org.eclipse.cdt.dsf.mi.service.command;
Lines 28-33 Link Here
28
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
29
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
29
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
30
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
30
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
31
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
32
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
31
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
33
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
32
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIAttach;
34
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIAttach;
33
import org.eclipse.cdt.dsf.mi.service.command.commands.CLICatch;
35
import org.eclipse.cdt.dsf.mi.service.command.commands.CLICatch;
Lines 525-538 Link Here
525
		return new MIExecUntil(dmc, loc);
527
		return new MIExecUntil(dmc, loc);
526
	}
528
	}
527
529
530
	@Deprecated
528
	public ICommand<MIInfo> createMIFileExecAndSymbols(ICommandControlDMContext dmc, String file) {
531
	public ICommand<MIInfo> createMIFileExecAndSymbols(ICommandControlDMContext dmc, String file) {
529
		return new MIFileExecAndSymbols(dmc, file);
532
		return new MIFileExecAndSymbols(dmc, file);
530
	}
533
	}
531
534
535
	@Deprecated
532
	public ICommand<MIInfo> createMIFileExecAndSymbols(ICommandControlDMContext dmc) {
536
	public ICommand<MIInfo> createMIFileExecAndSymbols(ICommandControlDMContext dmc) {
533
		return new MIFileExecAndSymbols(dmc);
537
		return new MIFileExecAndSymbols(dmc);
534
	}
538
	}
535
539
540
	/**  @since 4.0 */
541
	public ICommand<MIInfo> createMIFileExecAndSymbols(IMIContainerDMContext dmc, String file) {
542
		return new MIFileExecAndSymbols(dmc, file);
543
	}
544
545
	/** @since 4.0 */
546
	public ICommand<MIInfo> createMIFileExecAndSymbols(IMIContainerDMContext dmc) {
547
		return new MIFileExecAndSymbols(dmc);
548
	}
549
	
536
	public ICommand<MIInfo> createMIFileExecFile(ICommandControlDMContext dmc, String file) {
550
	public ICommand<MIInfo> createMIFileExecFile(ICommandControlDMContext dmc, String file) {
537
		return new MIFileExecFile(dmc, file);
551
		return new MIFileExecFile(dmc, file);
538
	}
552
	}
Lines 682-695 Link Here
682
		return new MIStackSelectFrame(ctx, frameNum);
696
		return new MIStackSelectFrame(ctx, frameNum);
683
	}
697
	}
684
698
699
	@Deprecated
685
	public ICommand<MIInfo> createMITargetAttach(ICommandControlDMContext ctx, String groupId) {
700
	public ICommand<MIInfo> createMITargetAttach(ICommandControlDMContext ctx, String groupId) {
686
		return new MITargetAttach(ctx, groupId);
701
		return new MITargetAttach(ctx, groupId);
687
	}
702
	}
688
703
704
	/** @since 4.0 */
705
	public ICommand<MIInfo> createMITargetAttach(IMIContainerDMContext ctx, String groupId) {
706
		return new MITargetAttach(ctx, groupId);
707
	}
708
689
	public ICommand<MIInfo> createMITargetDetach(ICommandControlDMContext ctx, String groupId) {
709
	public ICommand<MIInfo> createMITargetDetach(ICommandControlDMContext ctx, String groupId) {
690
		return new MITargetDetach(ctx, groupId);
710
		return new MITargetDetach(ctx, groupId);
691
	}
711
	}
692
712
713
	/** @since 4.0 */
714
	public ICommand<MIInfo> createMITargetDetach(IMIContainerDMContext ctx) {
715
		return new MITargetDetach(ctx);
716
	}
717
693
    public ICommand<MIInfo> createMITargetSelect(IDMContext ctx, String[] params) {
718
    public ICommand<MIInfo> createMITargetSelect(IDMContext ctx, String[] params) {
694
        return new MITargetSelect(ctx, params);
719
        return new MITargetSelect(ctx, params);
695
    }
720
    }
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/MICommand.java (-1 / +18 lines)
Lines 9-14 Link Here
9
 *     QNX Software Systems - Initial API and implementation
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Wind River Systems   - Modified for new DSF Reference Implementation
10
 *     Wind River Systems   - Modified for new DSF Reference Implementation
11
 *     Ericsson 		  	- Modified for additional features in DSF Reference implementation and bug 219920
11
 *     Ericsson 		  	- Modified for additional features in DSF Reference implementation and bug 219920
12
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
12
 *******************************************************************************/
13
 *******************************************************************************/
13
14
14
package org.eclipse.cdt.dsf.mi.service.command.commands;
15
package org.eclipse.cdt.dsf.mi.service.command.commands;
Lines 141-156 Link Here
141
     * @since 1.1
142
     * @since 1.1
142
     */
143
     */
143
    public String constructCommand(String threadId, int frameId) {
144
    public String constructCommand(String threadId, int frameId) {
145
    	return constructCommand(null, threadId, frameId);
146
    }
147
148
    /**
149
     * With GDB 7.1 the --thread-group option is used to support multiple processes.
150
     * @since 4.0
151
     */
152
    public String constructCommand(String groupId, String threadId, int frameId) {
144
        StringBuffer command = new StringBuffer(getOperation());
153
        StringBuffer command = new StringBuffer(getOperation());
145
        
154
        
146
        // Add the --thread option
155
        // Add the --thread option
147
        if (threadId != null) {
156
        if (supportsThreadAndFrameOptions() && threadId != null) {
148
        	command.append(" --thread " + threadId); //$NON-NLS-1$
157
        	command.append(" --thread " + threadId); //$NON-NLS-1$
149
158
150
        	// Add the --frame option, but only if we are using the --thread option
159
        	// Add the --frame option, but only if we are using the --thread option
151
        	if (frameId >= 0) {
160
        	if (frameId >= 0) {
152
        		command.append(" --frame " + frameId); //$NON-NLS-1$
161
        		command.append(" --frame " + frameId); //$NON-NLS-1$
153
        	}
162
        	}
163
        } else if (supportsThreadGroupOption() && groupId != null) {
164
        	// The --thread-group option is only allowed if we are not using the --thread option
165
        	command.append(" --thread-group " + groupId); //$NON-NLS-1$
154
        }
166
        }
155
167
156
        String opt = optionsToString();
168
        String opt = optionsToString();
Lines 241-246 Link Here
241
     * @since 1.1
253
     * @since 1.1
242
     */
254
     */
243
    public boolean supportsThreadAndFrameOptions() { return true; }
255
    public boolean supportsThreadAndFrameOptions() { return true; }
256
257
    /**
258
     * @since 4.0
259
     */
260
    public boolean supportsThreadGroupOption() { return false; }
244
    
261
    
245
    /**
262
    /**
246
     * Compare commands based on the MI command string that they generate, 
263
     * Compare commands based on the MI command string that they generate, 
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/MIFileExecAndSymbols.java (+23 lines)
Lines 7-17 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Ericsson - Initial API and implementation
9
 *     Ericsson - Initial API and implementation
10
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.cdt.dsf.mi.service.command.commands;
13
package org.eclipse.cdt.dsf.mi.service.command.commands;
13
14
14
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
15
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
16
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
15
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
17
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
16
18
17
/**
19
/**
Lines 27-41 Link Here
27
{
29
{
28
    /**
30
    /**
29
     * @since 1.1
31
     * @since 1.1
32
     * @deprecated Replaced with MIFileExecAndSymbols(IMIContainerDMContext, String)
33
     * since this command is container-specific
30
     */
34
     */
35
	@Deprecated
31
    public MIFileExecAndSymbols(ICommandControlDMContext dmc, String file) {
36
    public MIFileExecAndSymbols(ICommandControlDMContext dmc, String file) {
32
        super(dmc, "-file-exec-and-symbols", null, new String[] {file}); //$NON-NLS-1$
37
        super(dmc, "-file-exec-and-symbols", null, new String[] {file}); //$NON-NLS-1$
33
    }
38
    }
34
   
39
   
35
    /**
40
    /**
36
     * @since 1.1
41
     * @since 1.1
42
     * @deprecated Replaced with  MIFileExecAndSymbols(IMIContainerDMContext)
43
     * since this command is container-specific
37
     */
44
     */
45
	@Deprecated
38
    public MIFileExecAndSymbols(ICommandControlDMContext dmc) {
46
    public MIFileExecAndSymbols(ICommandControlDMContext dmc) {
39
        super(dmc, "-file-exec-and-symbols"); //$NON-NLS-1$
47
        super(dmc, "-file-exec-and-symbols"); //$NON-NLS-1$
40
    }
48
    }
49
    
50
    /** @since 4.0 */
51
    public MIFileExecAndSymbols(IMIContainerDMContext dmc) {
52
    	this(dmc, null);
53
    }
54
55
    /** @since 4.0 */
56
    public MIFileExecAndSymbols(IMIContainerDMContext dmc, String file) {
57
        super(dmc, "-file-exec-and-symbols", null, file == null ? null : new String[] {file}); //$NON-NLS-1$
58
    }
59
60
    @Override
61
    public boolean supportsThreadGroupOption() {
62
    	return true;
63
    }
41
}
64
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetAttach.java (-3 / +28 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 Ericsson and others.
2
 * Copyright (c) 2008, 2010 Ericsson and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-28 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Ericsson - Initial API and implementation
9
 *     Ericsson - Initial API and implementation
10
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
13
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
14
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
15
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
14
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
16
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
15
17
16
/**
18
/**
17
 * -target-attach < --pid PID | THREAD_GROUP_ID >
19
 * -target-attach < PID | THREAD_GROUP_ID >
18
 * 
20
 * 
19
 * This command attaches to the process specified by the PID
21
 * This command attaches to the process specified by the PID
20
 * or THREAD_GROUP_ID
22
 * or THREAD_GROUP_ID. If attaching to a thread group, the id
23
 * previously returned by `-list-thread-groups --available' must be used.
24
 * 
21
 * @since 1.1
25
 * @since 1.1
22
 */
26
 */
23
public class MITargetAttach extends MICommand<MIInfo> {
27
public class MITargetAttach extends MICommand<MIInfo> {
24
28
29
30
	/**
31
	 *  @deprecated Replaced with MITargetAttach(IMIContainerDMContext, String)
32
     * since this command is container-specific
33
     */
34
	@Deprecated
25
	public MITargetAttach(ICommandControlDMContext ctx, String groupId) {
35
	public MITargetAttach(ICommandControlDMContext ctx, String groupId) {
26
		super(ctx, "-target-attach", new String[] {groupId}); //$NON-NLS-1$
36
		super(ctx, "-target-attach", new String[] {groupId}); //$NON-NLS-1$
27
	}
37
	}
38
	
39
	/**
40
	 * @param ctx indicates which inferior should be used when doing the attach
41
	 * @param id the pid of the process to attach to
42
	 * 
43
	 * @since 4.0
44
	 */
45
	public MITargetAttach(IMIContainerDMContext ctx, String pid) {
46
		super(ctx, "-target-attach", new String[] { pid }); //$NON-NLS-1$
47
	}
48
	
49
    @Override
50
    public boolean supportsThreadGroupOption() {
51
    	return true;
52
    }
28
}
53
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetDetach.java (-2 / +32 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 Ericsson and others.
2
 * Copyright (c) 2008, 2010 Ericsson and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-20 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Ericsson - Initial API and implementation
9
 *     Ericsson - Initial API and implementation
10
 *     Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
13
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
14
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
15
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
14
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
16
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
15
17
16
/**
18
/**
17
 * -target-detach < --pid PID | THREAD_GROUP_ID >
19
 * -target-detach < PID | THREAD_GROUP_ID >
18
 * 
20
 * 
19
 * This command detaches from the process specified by the PID
21
 * This command detaches from the process specified by the PID
20
 * or THREAD_GROUP_ID
22
 * or THREAD_GROUP_ID
Lines 22-28 Link Here
22
 */
24
 */
23
public class MITargetDetach extends MICommand<MIInfo> {
25
public class MITargetDetach extends MICommand<MIInfo> {
24
	
26
	
27
	/*
28
	 * No need to specify an IMIContainerDMContext because
29
	 * only one such context is associated with ID; therefore,
30
	 * GDB will know which inferior to detach using only ID.
31
	 */
25
	public MITargetDetach(ICommandControlDMContext ctx, String groupId) {
32
	public MITargetDetach(ICommandControlDMContext ctx, String groupId) {
26
		super(ctx, "-target-detach", new String[] {groupId}); //$NON-NLS-1$
33
		super(ctx, "-target-detach", new String[] {groupId}); //$NON-NLS-1$
27
	}
34
	}
35
	
36
	/*
37
	 * This method does not follow our convention of passing the highest required
38
	 * context and proper parameters.  The proper way is handled by the method above
39
	 * MITargetDetach(ICommandControlDMContext, String)
40
	 * However, this method here will trigger the command in the form
41
	 * Form 1: -target-detach --thread-group i2
42
	 * instead of the way the above method does, which is
43
	 * Form 2: -target-detach i2
44
	 * Because of a bug in GDB 7.2, form 2 does not work.  
45
	 * However, this has been fixed with GDB 7.2.1, which is why we keep both 
46
	 * approaches. 
47
	 */  
48
	/** @since 4.0 */
49
	public MITargetDetach(IMIContainerDMContext ctx) {
50
		super(ctx, "-target-detach"); //$NON-NLS-1$
51
	}
52
	
53
	@Override
54
	public boolean supportsThreadGroupOption() {
55
		return true;
56
	}
57
28
}
58
}

Return to bug 237306