37
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2008 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.examples.dsf.pda.launch;
|
|
12 |
|
|
13 |
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
|
14 |
import org.eclipse.cdt.dsf.concurrent.Sequence;
|
|
15 |
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
|
|
16 |
import org.eclipse.cdt.dsf.service.DsfSession;
|
|
17 |
import org.eclipse.cdt.examples.dsf.pda.service.PDABackend;
|
|
18 |
import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpointAttributeTranslator;
|
|
19 |
import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpoints;
|
|
20 |
import org.eclipse.cdt.examples.dsf.pda.service.PDACommandControl;
|
|
21 |
import org.eclipse.cdt.examples.dsf.pda.service.PDAExpressions;
|
|
22 |
import org.eclipse.cdt.examples.dsf.pda.service.PDARegisters;
|
|
23 |
import org.eclipse.cdt.examples.dsf.pda.service.PDARunControl;
|
|
24 |
import org.eclipse.cdt.examples.dsf.pda.service.PDAStack;
|
|
25 |
|
|
26 |
/**
|
|
27 |
* The initialization sequence for PDA debugger services. This sequence contains
|
|
28 |
* the series of steps that are executed to properly initialize the PDA-DSF debug
|
|
29 |
* session. If any of the individual steps fail, the initialization will abort.
|
|
30 |
* <p>
|
|
31 |
* The order in which services are initialized is important. Some services depend
|
|
32 |
* on other services and they assume that they will be initialized only if those
|
|
33 |
* services are active. Also the service events are prioritized and their priority
|
|
34 |
* depends on the order in which the services were initialized.
|
|
35 |
* </p>
|
|
36 |
*/
|
|
37 |
public class PDAServicesInitSequence extends Sequence {
|
|
38 |
|
|
39 |
Step[] fSteps = new Step[] {
|
|
40 |
new Step()
|
|
41 |
{
|
|
42 |
@Override
|
|
43 |
public void execute(RequestMonitor requestMonitor) {
|
|
44 |
// Start PDA back end debugger service.
|
|
45 |
new PDABackend(fSession, fLaunch, fProgram).initialize(requestMonitor);
|
|
46 |
}
|
|
47 |
},
|
|
48 |
new Step()
|
|
49 |
{
|
|
50 |
@Override
|
|
51 |
public void execute(RequestMonitor requestMonitor) {
|
|
52 |
// Start PDA command control service.
|
|
53 |
fCommandControl = new PDACommandControl(fSession);
|
|
54 |
fCommandControl.initialize(requestMonitor);
|
|
55 |
}
|
|
56 |
},
|
|
57 |
new Step() {
|
|
58 |
@Override
|
|
59 |
public void execute(RequestMonitor requestMonitor) {
|
|
60 |
// Start the run control service.
|
|
61 |
fRunControl = new PDARunControl(fSession);
|
|
62 |
fRunControl.initialize(requestMonitor);
|
|
63 |
}
|
|
64 |
},
|
|
65 |
new Step() {
|
|
66 |
@Override
|
|
67 |
public void execute(final RequestMonitor requestMonitor) {
|
|
68 |
// Start the low-level breakpoint service
|
|
69 |
new PDABreakpoints(fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
|
|
70 |
}
|
|
71 |
},
|
|
72 |
new Step() {
|
|
73 |
@Override
|
|
74 |
public void execute(final RequestMonitor requestMonitor) {
|
|
75 |
// Create the breakpoint mediator and start tracking PDA breakpoints.
|
|
76 |
|
|
77 |
final BreakpointsMediator bpmService = new BreakpointsMediator(
|
|
78 |
fSession, new PDABreakpointAttributeTranslator());
|
|
79 |
bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
|
|
80 |
@Override
|
|
81 |
protected void handleSuccess() {
|
|
82 |
bpmService.startTrackingBreakpoints(fCommandControl.getContext(), requestMonitor);
|
|
83 |
}
|
|
84 |
});
|
|
85 |
}
|
|
86 |
},
|
|
87 |
new Step() {
|
|
88 |
@Override
|
|
89 |
public void execute(RequestMonitor requestMonitor) {
|
|
90 |
// Start the stack service.
|
|
91 |
new PDAStack(fSession).initialize(requestMonitor);
|
|
92 |
}
|
|
93 |
},
|
|
94 |
new Step() {
|
|
95 |
@Override
|
|
96 |
public void execute(RequestMonitor requestMonitor) {
|
|
97 |
// Start the service to track expressions.
|
|
98 |
new PDAExpressions(fSession).initialize(requestMonitor);
|
|
99 |
}
|
|
100 |
},
|
|
101 |
new Step() {
|
|
102 |
@Override
|
|
103 |
public void execute(RequestMonitor requestMonitor) {
|
|
104 |
// Start the service to track expressions.
|
|
105 |
new PDARegisters(fSession).initialize(requestMonitor);
|
|
106 |
}
|
|
107 |
},
|
|
108 |
new Step() {
|
|
109 |
@Override
|
|
110 |
public void execute(RequestMonitor requestMonitor) {
|
|
111 |
fRunControl.resume(fCommandControl.getContext(), requestMonitor);
|
|
112 |
}
|
|
113 |
},
|
|
114 |
};
|
|
115 |
|
|
116 |
// Sequence input parameters, used in initializing services.
|
|
117 |
private PDALaunch fLaunch;
|
|
118 |
private DsfSession fSession;
|
|
119 |
private String fProgram;
|
|
120 |
|
|
121 |
// Service references, initialized when created and used in initializing other services.
|
|
122 |
private PDACommandControl fCommandControl;
|
|
123 |
private PDARunControl fRunControl;
|
|
124 |
|
|
125 |
public PDAServicesInitSequence(DsfSession session, PDALaunch launch, String program, RequestMonitor rm)
|
|
126 |
{
|
|
127 |
super(session.getExecutor(), rm);
|
|
128 |
fLaunch = launch;
|
|
129 |
fSession = session;
|
|
130 |
fProgram = program;
|
|
131 |
}
|
|
132 |
|
|
133 |
@Override
|
|
134 |
public Step[] getSteps() {
|
|
135 |
return fSteps;
|
|
136 |
}
|
|
137 |
}
|