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

Collapse All | Expand All

(-)src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java (-3 / +13 lines)
Lines 21-26 Link Here
21
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
21
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
22
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
22
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
23
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
23
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
24
import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress;
24
import org.eclipse.cdt.dsf.concurrent.Sequence;
25
import org.eclipse.cdt.dsf.concurrent.Sequence;
25
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
26
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
26
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
27
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
Lines 33-38 Link Here
33
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
34
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
34
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
35
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
35
import org.eclipse.cdt.dsf.gdb.internal.memory.GdbMemoryBlockRetrieval;
36
import org.eclipse.cdt.dsf.gdb.internal.memory.GdbMemoryBlockRetrieval;
37
import org.eclipse.cdt.dsf.gdb.launching.GdbServicesSequence.ServiceSequenceOperation;
36
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
38
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
37
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
39
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
38
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
40
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
Lines 44-49 Link Here
44
import org.eclipse.core.runtime.CoreException;
46
import org.eclipse.core.runtime.CoreException;
45
import org.eclipse.core.runtime.IStatus;
47
import org.eclipse.core.runtime.IStatus;
46
import org.eclipse.core.runtime.MultiStatus;
48
import org.eclipse.core.runtime.MultiStatus;
49
import org.eclipse.core.runtime.NullProgressMonitor;
47
import org.eclipse.core.runtime.Platform;
50
import org.eclipse.core.runtime.Platform;
48
import org.eclipse.core.runtime.Status;
51
import org.eclipse.core.runtime.Status;
49
import org.eclipse.debug.core.DebugEvent;
52
import org.eclipse.debug.core.DebugEvent;
Lines 242-247 Link Here
242
    public boolean isDisconnected() {
245
    public boolean isDisconnected() {
243
        return isTerminated();
246
        return isTerminated();
244
    }
247
    }
248
    
249
	/**
250
	 * This method can be overridden by subclasses to allow to change the services sequence.
251
	 * @since 4.0
252
	 */
253
	public Sequence getServicesSequence(ServiceSequenceOperation type, RequestMonitorWithProgress rm) {
254
		return new GdbServicesSequence(type, getSession(), this, rm);
255
	}
245
256
246
    @Override
257
    @Override
247
    public void disconnect() throws DebugException {
258
    public void disconnect() throws DebugException {
Lines 270-278 Link Here
270
        }
281
        }
271
        fShutDown = true;
282
        fShutDown = true;
272
            
283
            
273
        Sequence shutdownSeq = new ShutdownSequence(
284
        Sequence shutdownSeq = getServicesSequence(ServiceSequenceOperation.SHUTDOWN,
274
            getDsfExecutor(), fSession.getId(),
285
            new RequestMonitorWithProgress(fSession.getExecutor(), new NullProgressMonitor()) { 
275
            new RequestMonitor(fSession.getExecutor(), rm) { 
276
                @Override
286
                @Override
277
                public void handleCompleted() {
287
                public void handleCompleted() {
278
                    fSession.removeServiceEventListener(GdbLaunch.this);
288
                    fSession.removeServiceEventListener(GdbLaunch.this);
(-)src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java (-6 / +14 lines)
Lines 20-31 Link Here
20
import org.eclipse.cdt.core.model.ICProject;
20
import org.eclipse.cdt.core.model.ICProject;
21
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
21
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
22
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
22
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
23
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
23
import org.eclipse.cdt.dsf.concurrent.Query;
24
import org.eclipse.cdt.dsf.concurrent.Query;
25
import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress;
24
import org.eclipse.cdt.dsf.concurrent.Sequence;
26
import org.eclipse.cdt.dsf.concurrent.Sequence;
25
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
27
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
26
import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory;
28
import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory;
27
import org.eclipse.cdt.dsf.debug.sourcelookup.DsfSourceLookupDirector;
29
import org.eclipse.cdt.dsf.debug.sourcelookup.DsfSourceLookupDirector;
28
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
30
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
31
import org.eclipse.cdt.dsf.gdb.launching.GdbServicesSequence.ServiceSequenceOperation;
29
import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory;
32
import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory;
30
import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactoryNS;
33
import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactoryNS;
31
import org.eclipse.cdt.dsf.gdb.service.SessionType;
34
import org.eclipse.cdt.dsf.gdb.service.SessionType;
Lines 136-141 Link Here
136
    	
139
    	
137
        monitor.worked( 1 );
140
        monitor.worked( 1 );
138
141
142
        fIsNonStopSession = LaunchUtils.getIsNonStopMode(config);
143
        fIsPostMortemTracingSession = LaunchUtils.getIsPostMortemTracing(config);
144
139
        String gdbVersion = getGDBVersion(config);
145
        String gdbVersion = getGDBVersion(config);
140
        
146
        
141
        // First make sure non-stop is supported, if the user want to use this mode
147
        // First make sure non-stop is supported, if the user want to use this mode
Lines 151-158 Link Here
151
157
152
        // Create and invoke the launch sequence to create the debug control and services
158
        // Create and invoke the launch sequence to create the debug control and services
153
        IProgressMonitor subMon1 = new SubProgressMonitor(monitor, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); 
159
        IProgressMonitor subMon1 = new SubProgressMonitor(monitor, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); 
154
        final ServicesLaunchSequence servicesLaunchSequence = 
160
        final Sequence servicesLaunchSequence =
155
            new ServicesLaunchSequence(launch.getSession(), launch, subMon1);
161
        	launch.getServicesSequence(ServiceSequenceOperation.INITIALIZE,  new RequestMonitorWithProgress(ImmediateExecutor.getInstance(), subMon1));
156
        
162
        
157
        launch.getSession().getExecutor().execute(servicesLaunchSequence);
163
        launch.getSession().getExecutor().execute(servicesLaunchSequence);
158
        try {
164
        try {
Lines 276-291 Link Here
276
        // the adapters will be created for the whole session, including 
282
        // the adapters will be created for the whole session, including 
277
        // the source lookup adapter.
283
        // the source lookup adapter.
278
        
284
        
279
		fIsNonStopSession = LaunchUtils.getIsNonStopMode(configuration);
280
		fIsPostMortemTracingSession = LaunchUtils.getIsPostMortemTracing(configuration);
281
282
        GdbLaunch launch = new GdbLaunch(configuration, mode, null);
285
        GdbLaunch launch = new GdbLaunch(configuration, mode, null);
283
        launch.initialize();
286
        launch.initialize();
284
        launch.setSourceLocator(getSourceLocator(configuration, launch.getSession()));
287
        launch.setSourceLocator(getSourceLocator(configuration, launch.getSession()));
285
        return launch;
288
        return launch;
286
    }
289
    }
287
290
288
    private ISourceLocator getSourceLocator(ILaunchConfiguration configuration, DsfSession session) throws CoreException {
291
    /**
292
     * Creates and initializes the source locator for 
293
     * the given launch configuration.
294
     * @since 4.0
295
     */
296
    protected ISourceLocator getSourceLocator(ILaunchConfiguration configuration, DsfSession session) throws CoreException {
289
        DsfSourceLookupDirector locator = new DsfSourceLookupDirector(session);
297
        DsfSourceLookupDirector locator = new DsfSourceLookupDirector(session);
290
        String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
298
        String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
291
        if (memento == null) {
299
        if (memento == null) {
(-)src/org/eclipse/cdt/dsf/gdb/launching/GdbServicesSequence.java (+280 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2010 Wind River Systems 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
 *     Wind River Systems - initial API and implementation
10
 *     Nokia 			  - handled GDBBackend service. Sep. 2008
11
 *     IBM Corporation 
12
 *     Ericsson           - Support for Tracing Control service
13
 *     Ericsson           - Converted to use ReflectionSequence to allow for overriding
14
 *******************************************************************************/
15
package org.eclipse.cdt.dsf.gdb.launching;
16
17
import java.util.ArrayList;
18
import java.util.Arrays;
19
import java.util.Collections;
20
import java.util.List;
21
22
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
23
import org.eclipse.cdt.dsf.concurrent.ReflectionSequence;
24
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
25
import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress;
26
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
27
import org.eclipse.cdt.dsf.debug.service.IDisassembly;
28
import org.eclipse.cdt.dsf.debug.service.IExpressions;
29
import org.eclipse.cdt.dsf.debug.service.IMemory;
30
import org.eclipse.cdt.dsf.debug.service.IModules;
31
import org.eclipse.cdt.dsf.debug.service.IProcesses;
32
import org.eclipse.cdt.dsf.debug.service.IRegisters;
33
import org.eclipse.cdt.dsf.debug.service.IRunControl;
34
import org.eclipse.cdt.dsf.debug.service.ISourceLookup;
35
import org.eclipse.cdt.dsf.debug.service.ISourceLookup.ISourceLookupDMContext;
36
import org.eclipse.cdt.dsf.debug.service.IStack;
37
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
38
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
39
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl;
40
import org.eclipse.cdt.dsf.mi.service.CSourceLookup;
41
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
42
import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager;
43
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
44
import org.eclipse.cdt.dsf.service.DsfSession;
45
import org.eclipse.cdt.dsf.service.IDsfService;
46
47
/**
48
 * This class replaces both ServicesLaunchSequence and ShutdownSequence to
49
 * allow to easily override this functionality.  The two classes have been merged into
50
 * a single class since they are so closely related.
51
 * 
52
 * @since 4.0
53
 */
54
@SuppressWarnings( "restriction" )
55
public class GdbServicesSequence extends ReflectionSequence {
56
57
	public enum ServiceSequenceOperation { INITIALIZE, SHUTDOWN };
58
59
	private final static String[] INITIALIZATION_STEPS = new String[] {
60
		"handleBackendService",   //$NON-NLS-1$
61
		"handleCommandControlService",   //$NON-NLS-1$
62
		"handleProcessesService",    //$NON-NLS-1$
63
		"handleRunControlService",   //$NON-NLS-1$
64
		"handleMemoryService",   //$NON-NLS-1$
65
		"handleModuleService",   //$NON-NLS-1$
66
		"handleStackService",   //$NON-NLS-1$
67
		"handleExpressionsService",   //$NON-NLS-1$
68
		"handleSourceLookupService",   //$NON-NLS-1$
69
		"handleBreakpointsService",   //$NON-NLS-1$
70
		"handleBreakpointsMediatorService",   //$NON-NLS-1$
71
		"handleRegistersService",   //$NON-NLS-1$
72
		"handleDisassemblyService",   //$NON-NLS-1$
73
		"handleTraceControlService",   //$NON-NLS-1$
74
	};
75
76
	private final ServiceSequenceOperation fOperation;
77
	private final DsfSession fSession;
78
	private final GdbLaunch fLaunch;
79
80
	private ICommandControlService fCommandControl;
81
82
	public GdbServicesSequence(ServiceSequenceOperation operation, DsfSession session, GdbLaunch launch, RequestMonitorWithProgress rm) {
83
		super(session.getExecutor(), rm, 
84
				   operation == ServiceSequenceOperation.INITIALIZE ? LaunchMessages.getString("ServicesLaunchSequence_0") : "",    //$NON-NLS-1$ //$NON-NLS-2$
85
				   operation == ServiceSequenceOperation.INITIALIZE ? LaunchMessages.getString("ServicesLaunchSequence_1") : "");   //$NON-NLS-1$ //$NON-NLS-2$
86
		fSession = session;
87
		fLaunch = launch;
88
		fOperation = operation;
89
	}
90
91
	@Override
92
	protected String[] getExecutionOrder(String group) {
93
		if (GROUP_TOP_LEVEL.equals(group)) {
94
			if (fOperation == ServiceSequenceOperation.INITIALIZE) {
95
				return INITIALIZATION_STEPS;
96
			} else {
97
				// Use the reverse order of the initialization sequence
98
				// We need to create a brand new array list or else we'll actually reverse the init_steps array.
99
				List<String> orderedList = new ArrayList<String>(Arrays.asList(INITIALIZATION_STEPS));
100
				Collections.reverse(orderedList);
101
				return orderedList.toArray(new String[orderedList.size()]);
102
			}
103
		}
104
		return null;
105
	}
106
107
	@Execute
108
	public void handleBackendService(RequestMonitor requestMonitor) {
109
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
110
			fLaunch.getServiceFactory().createService(IMIBackend.class, fSession, fLaunch.getLaunchConfiguration()).initialize(requestMonitor);
111
		} else {
112
	        shutdownService(IMIBackend.class, requestMonitor);
113
		}
114
	}
115
116
	@Execute
117
	public void handleCommandControlService(RequestMonitor requestMonitor) {
118
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
119
			fCommandControl = fLaunch.getServiceFactory().createService(ICommandControlService.class, fSession, fLaunch.getLaunchConfiguration());
120
			fCommandControl.initialize(requestMonitor);
121
		} else {
122
	        shutdownService(ICommandControlService.class, requestMonitor);
123
		}
124
	}
125
126
	@Execute
127
	public void handleProcessesService(RequestMonitor requestMonitor) {
128
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
129
			fLaunch.getServiceFactory().createService(IProcesses.class, fSession).initialize(requestMonitor);
130
		} else {
131
	        shutdownService(IProcesses.class, requestMonitor);
132
		}
133
	}
134
135
	@Execute
136
	public void handleRunControlService(RequestMonitor requestMonitor) {
137
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
138
			fLaunch.getServiceFactory().createService(IRunControl.class, fSession).initialize(requestMonitor);
139
		} else {
140
	        shutdownService(IRunControl.class, requestMonitor);
141
		}
142
	}
143
144
	@Execute
145
	public void handleMemoryService(RequestMonitor requestMonitor) {
146
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
147
			fLaunch.getServiceFactory().createService(IMemory.class, fSession).initialize(requestMonitor);
148
		} else {
149
	        shutdownService(IMemory.class, requestMonitor);
150
		}
151
	}
152
153
	@Execute
154
	public void handleModuleService(RequestMonitor requestMonitor) {
155
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
156
			fLaunch.getServiceFactory().createService(IModules.class, fSession).initialize(requestMonitor);
157
		} else {
158
	        shutdownService(IModules.class, requestMonitor);
159
		}
160
	}
161
162
	@Execute
163
	public void handleStackService(RequestMonitor requestMonitor) {
164
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
165
			fLaunch.getServiceFactory().createService(IStack.class, fSession).initialize(requestMonitor);
166
		} else {
167
	        shutdownService(IStack.class, requestMonitor);
168
		}
169
	}
170
171
	@Execute
172
	public void handleExpressionsService(RequestMonitor requestMonitor) {
173
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
174
			fLaunch.getServiceFactory().createService(IExpressions.class, fSession).initialize(requestMonitor);
175
		} else {
176
	        shutdownService(IExpressions.class, requestMonitor);
177
		}
178
	}
179
180
	@Execute
181
	public void handleSourceLookupService(final RequestMonitor requestMonitor) {
182
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
183
			final CSourceLookup sourceLookup = (CSourceLookup)fLaunch.getServiceFactory().createService(ISourceLookup.class, fSession);
184
			sourceLookup.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
185
				@Override
186
				protected void handleSuccess() {
187
					ISourceLookupDMContext sourceLookupDmc = (ISourceLookupDMContext)fCommandControl.getContext();
188
					sourceLookup.setSourceLookupDirector(sourceLookupDmc, (CSourceLookupDirector)fLaunch.getSourceLocator());
189
					requestMonitor.done();
190
				}
191
			});
192
		} else {
193
	        shutdownService(ISourceLookup.class, requestMonitor);
194
		}
195
	}
196
197
	@Execute
198
	public void handleBreakpointsService(final RequestMonitor requestMonitor) {
199
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
200
			fLaunch.getServiceFactory().createService(IBreakpoints.class, fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
201
		} else {
202
	        shutdownService(IBreakpoints.class, requestMonitor);
203
		}
204
	}
205
206
	@Execute
207
	public void handleBreakpointsMediatorService(final RequestMonitor requestMonitor) {
208
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
209
			fLaunch.getServiceFactory().createService(MIBreakpointsManager.class, fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor)); 
210
		} else {
211
	        shutdownService(MIBreakpointsManager.class, requestMonitor);
212
		}
213
	}
214
215
	@Execute
216
	public void handleRegistersService(RequestMonitor requestMonitor) {
217
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
218
			fLaunch.getServiceFactory().createService(IRegisters.class, fSession).initialize(requestMonitor);
219
		} else {
220
	        shutdownService(IRegisters.class, requestMonitor);
221
		}
222
	}
223
224
	@Execute
225
	public void handleDisassemblyService(RequestMonitor requestMonitor) {
226
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
227
			fLaunch.getServiceFactory().createService(IDisassembly.class, fSession).initialize(requestMonitor);
228
		} else {
229
	        shutdownService(IDisassembly.class, requestMonitor);
230
		}
231
	}
232
233
	@Execute
234
	public void handleTraceControlService(RequestMonitor requestMonitor) {
235
		if (fOperation == ServiceSequenceOperation.INITIALIZE) {
236
			IGDBTraceControl traceService = fLaunch.getServiceFactory().createService(IGDBTraceControl.class, fSession, fLaunch.getLaunchConfiguration());
237
			// Note that for older versions of GDB, we don't support tracing, so there is no trace service.
238
			if (traceService != null) {
239
				traceService.initialize(requestMonitor);
240
			} else {
241
				requestMonitor.done();
242
			}
243
		} else {
244
	        shutdownService(IGDBTraceControl.class, requestMonitor);
245
		}
246
	}
247
248
    public <V extends IDsfService> void shutdownService(Class<V> clazz, final RequestMonitor requestMonitor) {
249
    	DsfServicesTracker tracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fSession.getId());
250
        IDsfService service = tracker.getService(clazz);
251
        tracker.dispose();
252
        if (service != null) {
253
            service.shutdown(new RequestMonitor(getExecutor(), requestMonitor) {
254
                @Override
255
                protected void handleCompleted() {
256
                    if (!isSuccess()) {
257
                        GdbPlugin.getDefault().getLog().log(getStatus());
258
                    }
259
                    requestMonitor.done();
260
                }
261
            });
262
        } else {
263
        	// It is possible that a particular service was not instantiated at all
264
        	// depending on our backend
265
            requestMonitor.done();
266
        }
267
    }
268
269
    protected ServiceSequenceOperation getOperation() {
270
        return fOperation;
271
    }
272
273
    protected DsfSession getSession() {
274
        return fSession;
275
    }
276
277
    protected GdbLaunch getLaunch() {
278
        return fLaunch;
279
    }
280
}
(-)src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java (-148 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2010 Wind River Systems 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
 *     Wind River Systems - initial API and implementation
10
 *     Nokia 			  - created GDBBackend service. Sep. 2008
11
 *     IBM Corporation 
12
 *     Ericsson           - Support for Tracing Control service
13
 *******************************************************************************/
14
package org.eclipse.cdt.dsf.gdb.launching;
15
16
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
17
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
18
import org.eclipse.cdt.dsf.concurrent.Sequence;
19
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
20
import org.eclipse.cdt.dsf.debug.service.IDisassembly;
21
import org.eclipse.cdt.dsf.debug.service.IExpressions;
22
import org.eclipse.cdt.dsf.debug.service.IMemory;
23
import org.eclipse.cdt.dsf.debug.service.IModules;
24
import org.eclipse.cdt.dsf.debug.service.IProcesses;
25
import org.eclipse.cdt.dsf.debug.service.IRegisters;
26
import org.eclipse.cdt.dsf.debug.service.IRunControl;
27
import org.eclipse.cdt.dsf.debug.service.ISourceLookup;
28
import org.eclipse.cdt.dsf.debug.service.IStack;
29
import org.eclipse.cdt.dsf.debug.service.ISourceLookup.ISourceLookupDMContext;
30
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
31
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl;
32
import org.eclipse.cdt.dsf.mi.service.CSourceLookup;
33
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
34
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
35
import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager;
36
import org.eclipse.cdt.dsf.service.DsfSession;
37
import org.eclipse.core.runtime.IProgressMonitor;
38
39
public class ServicesLaunchSequence extends Sequence {
40
41
    Step[] fSteps = new Step[] {
42
        new Step() { 
43
            @Override
44
            public void execute(RequestMonitor requestMonitor) {
45
                // Create the back end GDB service.
46
                //
47
                fLaunch.getServiceFactory().createService(IMIBackend.class, fSession, fLaunch.getLaunchConfiguration()).initialize(requestMonitor);
48
            }
49
        },
50
        // Create and initialize the Connection service.
51
        new Step() { 
52
            @Override
53
            public void execute(RequestMonitor requestMonitor) {
54
                //
55
                // Create the connection.
56
                //
57
                fCommandControl = fLaunch.getServiceFactory().createService(ICommandControlService.class, fSession, fLaunch.getLaunchConfiguration());
58
                fCommandControl.initialize(requestMonitor);
59
            }
60
        },
61
        new Step() { @Override
62
        public void execute(RequestMonitor requestMonitor) {
63
        	fProcService = (IMIProcesses)fLaunch.getServiceFactory().createService(IProcesses.class, fSession);
64
        	fProcService.initialize(requestMonitor);
65
        }},
66
        new Step() { @Override
67
        public void execute(RequestMonitor requestMonitor) {
68
        	fLaunch.getServiceFactory().createService(IRunControl.class, fSession).initialize(requestMonitor);
69
        }},
70
        new Step() { @Override
71
        public void execute(RequestMonitor requestMonitor) {
72
        	fLaunch.getServiceFactory().createService(IMemory.class, fSession).initialize(requestMonitor);
73
        }},
74
        new Step() { @Override
75
        public void execute(RequestMonitor requestMonitor) {
76
        	fLaunch.getServiceFactory().createService(IModules.class, fSession).initialize(requestMonitor);
77
        }},
78
        new Step() { @Override
79
        public void execute(RequestMonitor requestMonitor) {
80
        	fLaunch.getServiceFactory().createService(IStack.class, fSession).initialize(requestMonitor);
81
        }},
82
        new Step() { @Override
83
        public void execute(RequestMonitor requestMonitor) {
84
        	fLaunch.getServiceFactory().createService(IExpressions.class, fSession).initialize(requestMonitor);
85
        }},
86
        new Step() { @Override
87
        public void execute(RequestMonitor requestMonitor) {
88
        	fSourceLookup = (CSourceLookup)fLaunch.getServiceFactory().createService(ISourceLookup.class, fSession);
89
            fSourceLookup.initialize(requestMonitor);
90
        }},
91
        new Step() { @Override
92
        public void execute(RequestMonitor requestMonitor) {
93
       		ISourceLookupDMContext sourceLookupDmc = (ISourceLookupDMContext)fCommandControl.getContext();
94
            fSourceLookup.setSourceLookupDirector(sourceLookupDmc, (CSourceLookupDirector)fLaunch.getSourceLocator());
95
            requestMonitor.done();
96
        }},
97
        new Step() { @Override
98
        public void execute(final RequestMonitor requestMonitor) {
99
            // Create the low-level breakpoint service 
100
        	fLaunch.getServiceFactory().createService(IBreakpoints.class, fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
101
        }},
102
        new Step() { @Override
103
        public void execute(final RequestMonitor requestMonitor) {
104
            // Create high-level breakpoint service and install breakpoints 
105
            // for the GDB debug context.
106
        	fLaunch.getServiceFactory().createService(MIBreakpointsManager.class, fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor)); 
107
        }},
108
        new Step() { @Override
109
        public void execute(RequestMonitor requestMonitor) {
110
        	fLaunch.getServiceFactory().createService(IRegisters.class, fSession).initialize(requestMonitor);
111
        }},
112
        new Step() { @Override
113
        public void execute(RequestMonitor requestMonitor) {
114
        	fLaunch.getServiceFactory().createService(IDisassembly.class, fSession).initialize(requestMonitor);
115
        }},
116
        new Step() { @Override
117
        public void execute(RequestMonitor requestMonitor) {
118
           	IGDBTraceControl traceService = fLaunch.getServiceFactory().createService(IGDBTraceControl.class, fSession, fLaunch.getLaunchConfiguration());
119
           	// Note that for older versions of GDB, we don't support tracing, so there is no trace service.
120
           	if (traceService != null) {
121
           		traceService.initialize(requestMonitor);
122
           	} else {
123
           		requestMonitor.done();
124
           	}
125
        }},
126
    };
127
128
    DsfSession fSession;
129
    GdbLaunch fLaunch;
130
131
    ICommandControlService fCommandControl;
132
    IMIProcesses fProcService;
133
    CSourceLookup fSourceLookup;
134
    
135
    public ServicesLaunchSequence(DsfSession session, GdbLaunch launch, IProgressMonitor pm) {
136
        super(session.getExecutor(), pm, LaunchMessages.getString("ServicesLaunchSequence_0"), LaunchMessages.getString("ServicesLaunchSequence_1"));   //$NON-NLS-1$ //$NON-NLS-2$
137
        fSession = session;
138
        fLaunch = launch;
139
    }
140
    
141
    @Override
142
    public Step[] getSteps() {
143
        return fSteps;
144
    }
145
    
146
147
148
}
(-)src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java (-166 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2010 Wind River Systems 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
 *     Wind River Systems - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.launching;
12
13
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
14
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
15
import org.eclipse.cdt.dsf.concurrent.Sequence;
16
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
17
import org.eclipse.cdt.dsf.debug.service.IDisassembly;
18
import org.eclipse.cdt.dsf.debug.service.IExpressions;
19
import org.eclipse.cdt.dsf.debug.service.IMemory;
20
import org.eclipse.cdt.dsf.debug.service.IModules;
21
import org.eclipse.cdt.dsf.debug.service.IProcesses;
22
import org.eclipse.cdt.dsf.debug.service.IRegisters;
23
import org.eclipse.cdt.dsf.debug.service.IRunControl;
24
import org.eclipse.cdt.dsf.debug.service.ISourceLookup;
25
import org.eclipse.cdt.dsf.debug.service.IStack;
26
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
27
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
28
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl;
29
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
30
import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager;
31
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
32
import org.eclipse.cdt.dsf.service.IDsfService;
33
34
public class ShutdownSequence extends Sequence {
35
36
    String fSessionId;
37
38
    String fApplicationName;
39
40
    String fDebugModelId;
41
42
    DsfServicesTracker fTracker;
43
44
    public ShutdownSequence(DsfExecutor executor, String sessionId, RequestMonitor requestMonitor) {
45
        super(executor, requestMonitor);
46
        fSessionId = sessionId;
47
    }
48
49
    @Override
50
    public Step[] getSteps() {
51
        return fSteps;
52
    }
53
54
    private final Step[] fSteps = new Step[] { new Step() {
55
        @Override
56
        public void execute(RequestMonitor requestMonitor) {
57
            assert GdbPlugin.getBundleContext() != null;
58
            fTracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fSessionId);
59
            requestMonitor.done();
60
        }
61
62
        @Override
63
        public void rollBack(RequestMonitor requestMonitor) {
64
            fTracker.dispose();
65
            fTracker = null;
66
            requestMonitor.done();
67
        }
68
    }, new Step() {
69
        @Override
70
        public void execute(RequestMonitor requestMonitor) {
71
            shutdownService(IGDBTraceControl.class, requestMonitor);
72
        }
73
    }, new Step() {
74
        @Override
75
        public void execute(RequestMonitor requestMonitor) {
76
            shutdownService(IDisassembly.class, requestMonitor);
77
        }
78
    }, new Step() {
79
        @Override
80
        public void execute(RequestMonitor requestMonitor) {
81
            shutdownService(IRegisters.class, requestMonitor);
82
        }
83
    }, new Step() {
84
        @Override
85
        public void execute(RequestMonitor requestMonitor) {
86
            shutdownService(MIBreakpointsManager.class, requestMonitor);
87
        }
88
    }, new Step() {
89
        @Override
90
        public void execute(RequestMonitor requestMonitor) {
91
            shutdownService(IBreakpoints.class, requestMonitor);
92
        }
93
    }, new Step() {
94
        @Override
95
        public void execute(RequestMonitor requestMonitor) {
96
            shutdownService(ISourceLookup.class, requestMonitor);
97
        }
98
    }, new Step() {
99
        @Override
100
        public void execute(RequestMonitor requestMonitor) {
101
            shutdownService(IExpressions.class, requestMonitor);
102
        }
103
    }, new Step() {
104
        @Override
105
        public void execute(RequestMonitor requestMonitor) {
106
            shutdownService(IStack.class, requestMonitor);
107
        }
108
    }, new Step() {
109
        @Override
110
        public void execute(RequestMonitor requestMonitor) {
111
            shutdownService(IModules.class, requestMonitor);
112
        }
113
    }, new Step() {
114
        @Override
115
        public void execute(RequestMonitor requestMonitor) {
116
            shutdownService(IMemory.class, requestMonitor);
117
        }
118
    }, new Step() {
119
        @Override
120
        public void execute(RequestMonitor requestMonitor) {
121
            shutdownService(IRunControl.class, requestMonitor);
122
        }
123
    }, new Step() {
124
        @Override
125
        public void execute(RequestMonitor requestMonitor) {
126
            shutdownService(IProcesses.class, requestMonitor);
127
        }
128
    }, new Step() {
129
        @Override
130
        public void execute(RequestMonitor requestMonitor) {
131
            shutdownService(ICommandControl.class, requestMonitor);
132
        }
133
    }, new Step() {
134
        @Override
135
        public void execute(RequestMonitor requestMonitor) {
136
            shutdownService(IMIBackend.class, requestMonitor);
137
        }
138
    }, new Step() {
139
        @Override
140
        public void execute(RequestMonitor requestMonitor) {
141
            fTracker.dispose();
142
            fTracker = null;
143
            requestMonitor.done();
144
        }
145
    } };
146
147
    @SuppressWarnings("unchecked")
148
    private void shutdownService(Class clazz, final RequestMonitor requestMonitor) {
149
        IDsfService service = (IDsfService)fTracker.getService(clazz);
150
        if (service != null) {
151
            service.shutdown(new RequestMonitor(getExecutor(), requestMonitor) {
152
                @Override
153
                protected void handleCompleted() {
154
                    if (!isSuccess()) {
155
                        GdbPlugin.getDefault().getLog().log(getStatus());
156
                    }
157
                    requestMonitor.done();
158
                }
159
            });
160
        } else {
161
        	// It is possible that a particular service was not instantiated at all
162
        	// depending on our backend
163
            requestMonitor.done();
164
        }
165
    }
166
}

Return to bug 326951