Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 450de109ba646541abea5d8de426afd89ef247f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*******************************************************************************
 * Copyright (c) 2008, 2010 Wind River Systems and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.examples.dsf.pda.launch;

import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Sequence;
import org.eclipse.cdt.dsf.datamodel.DataModelInitializedEvent;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.examples.dsf.pda.service.PDABackend;
import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpointAttributeTranslator;
import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpoints;
import org.eclipse.cdt.examples.dsf.pda.service.PDACommandControl;
import org.eclipse.cdt.examples.dsf.pda.service.PDAExpressions;
import org.eclipse.cdt.examples.dsf.pda.service.PDARegisters;
import org.eclipse.cdt.examples.dsf.pda.service.PDARunControl;
import org.eclipse.cdt.examples.dsf.pda.service.PDAStack;

/**
 * The initialization sequence for PDA debugger services.  This sequence contains
 * the series of steps that are executed to properly initialize the PDA-DSF debug
 * session.  If any of the individual steps fail, the initialization will abort.   
 * <p>
 * The order in which services are initialized is important.  Some services depend
 * on other services and they assume that they will be initialized only if those
 * services are active.  Also the service events are prioritized and their priority
 * depends on the order in which the services were initialized.
 * </p>
 */
public class PDAServicesInitSequence extends Sequence {

    Step[] fSteps = new Step[] {
        new Step() 
        { 
            @Override
            public void execute(RequestMonitor requestMonitor) {
                // Start PDA back end debugger service.
                new PDABackend(fSession, fLaunch, fProgram).initialize(requestMonitor);
            }
        },
        new Step() 
        { 
            @Override
            public void execute(RequestMonitor requestMonitor) {
                // Start PDA command control service.
                fCommandControl = new PDACommandControl(fSession);
                fCommandControl.initialize(requestMonitor);
            }
        },
        new Step() { 
            @Override
            public void execute(RequestMonitor requestMonitor) {
                // Start the run control service.
                fRunControl = new PDARunControl(fSession);
                fRunControl.initialize(requestMonitor);
            }
        },
        new Step() { 
            @Override
            public void execute(final RequestMonitor requestMonitor) {
                // Start the low-level breakpoint service 
                new PDABreakpoints(fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
            }
        },
        new Step() { 
            @Override
            public void execute(final RequestMonitor requestMonitor) {
                // Create the breakpoint mediator and start tracking PDA breakpoints.

                final BreakpointsMediator bpmService = new BreakpointsMediator(
                    fSession, new PDABreakpointAttributeTranslator());
                bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
                    @Override
                    protected void handleSuccess() {
                        bpmService.startTrackingBreakpoints(fCommandControl.getContext(), requestMonitor);
                    }
                }); 
            }
        },
        new Step() { 
            @Override
            public void execute(RequestMonitor requestMonitor) {
                // Start the stack service.
                new PDAStack(fSession).initialize(requestMonitor);
            }
        },
        new Step() { 
            @Override
            public void execute(RequestMonitor requestMonitor) {
                // Start the service to track expressions.
                new PDAExpressions(fSession).initialize(requestMonitor);
            }
        },
        new Step() { 
            @Override
            public void execute(RequestMonitor requestMonitor) {
                // Start the service to track expressions.
                new PDARegisters(fSession).initialize(requestMonitor);
            }
        },
        /*
         * Indicate that the Data Model has been filled.  This will trigger the Debug view to expand.
         */
        new Step() {
            @Override
            public void execute(final RequestMonitor requestMonitor) {
                fSession.dispatchEvent(
                    new DataModelInitializedEvent(fCommandControl.getContext()),
                    fCommandControl.getProperties());
                requestMonitor.done();
            }
        }
    };

    // Sequence input parameters, used in initializing services.
    private PDALaunch  fLaunch;
    private DsfSession fSession;
    private String fProgram;

    // Service references, initialized when created and used in initializing other services.
    private PDACommandControl fCommandControl;
    private PDARunControl fRunControl;

    public PDAServicesInitSequence(DsfSession session, PDALaunch launch, String program, RequestMonitor rm) 
    {
        super(session.getExecutor(), rm);
        fLaunch = launch;
        fSession = session;
        fProgram = program;
    }

    @Override
    public Step[] getSteps() {
        return fSteps;
    }
}

Back to the top