cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDAServicesInitSequence.java
author l12wang
Wed, 11 Nov 2009 16:36:23 -0600
changeset 114 ecab18a5e4de
parent 37 c2bce6dd59e7
child 122 d94b9ba55bed
permissions -rw-r--r--
Changes corresponding to BreakpointsMediator change.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     1
/*******************************************************************************
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2008 Wind River Systems and others.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     3
 * All rights reserved. This program and the accompanying materials
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     4
 * are made available under the terms of the Eclipse Public License v1.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     5
 * which accompanies this distribution, and is available at
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     6
 * http://www.eclipse.org/legal/epl-v10.html
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     7
 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     8
 * Contributors:
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     9
 *     Wind River Systems - initial API and implementation
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    10
 *******************************************************************************/
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    11
package org.eclipse.cdt.examples.dsf.pda.launch;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    12
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    13
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    14
import org.eclipse.cdt.dsf.concurrent.Sequence;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    15
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    16
import org.eclipse.cdt.dsf.service.DsfSession;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    17
import org.eclipse.cdt.examples.dsf.pda.service.PDABackend;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    18
import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpointAttributeTranslator;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    19
import org.eclipse.cdt.examples.dsf.pda.service.PDABreakpoints;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    20
import org.eclipse.cdt.examples.dsf.pda.service.PDACommandControl;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    21
import org.eclipse.cdt.examples.dsf.pda.service.PDAExpressions;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    22
import org.eclipse.cdt.examples.dsf.pda.service.PDARegisters;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    23
import org.eclipse.cdt.examples.dsf.pda.service.PDARunControl;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    24
import org.eclipse.cdt.examples.dsf.pda.service.PDAStack;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    25
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    26
/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    27
 * The initialization sequence for PDA debugger services.  This sequence contains
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    28
 * the series of steps that are executed to properly initialize the PDA-DSF debug
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    29
 * session.  If any of the individual steps fail, the initialization will abort.   
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    30
 * <p>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    31
 * The order in which services are initialized is important.  Some services depend
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    32
 * on other services and they assume that they will be initialized only if those
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    33
 * services are active.  Also the service events are prioritized and their priority
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    34
 * depends on the order in which the services were initialized.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    35
 * </p>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    36
 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    37
public class PDAServicesInitSequence extends Sequence {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    38
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    39
    Step[] fSteps = new Step[] {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    40
        new Step() 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    41
        { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    42
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    43
            public void execute(RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    44
                // Start PDA back end debugger service.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    45
                new PDABackend(fSession, fLaunch, fProgram).initialize(requestMonitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    46
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    47
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    48
        new Step() 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    49
        { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    50
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    51
            public void execute(RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    52
                // Start PDA command control service.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    53
                fCommandControl = new PDACommandControl(fSession);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    54
                fCommandControl.initialize(requestMonitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    55
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    56
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    57
        new Step() { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    58
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    59
            public void execute(RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    60
                // Start the run control service.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    61
                fRunControl = new PDARunControl(fSession);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    62
                fRunControl.initialize(requestMonitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    63
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    64
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    65
        new Step() { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    66
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    67
            public void execute(final RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    68
                // Start the low-level breakpoint service 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    69
                new PDABreakpoints(fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    70
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    71
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    72
        new Step() { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    73
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    74
            public void execute(final RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    75
                // Create the breakpoint mediator and start tracking PDA breakpoints.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    76
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    77
                final BreakpointsMediator bpmService = new BreakpointsMediator(
114
ecab18a5e4de Changes corresponding to BreakpointsMediator change.
l12wang
parents: 37
diff changeset
    78
                    fSession, new PDABreakpointAttributeTranslator(fCommandControl.getContext()));
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    79
                bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    80
                    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    81
                    protected void handleSuccess() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    82
                        bpmService.startTrackingBreakpoints(fCommandControl.getContext(), requestMonitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    83
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    84
                }); 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    85
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    86
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    87
        new Step() { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    88
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    89
            public void execute(RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    90
                // Start the stack service.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    91
                new PDAStack(fSession).initialize(requestMonitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    92
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    93
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    94
        new Step() { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    95
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    96
            public void execute(RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    97
                // Start the service to track expressions.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    98
                new PDAExpressions(fSession).initialize(requestMonitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    99
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   100
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   101
        new Step() { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   102
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   103
            public void execute(RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   104
                // Start the service to track expressions.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   105
                new PDARegisters(fSession).initialize(requestMonitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   106
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   107
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   108
        new Step() { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   109
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   110
            public void execute(RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   111
                fRunControl.resume(fCommandControl.getContext(), requestMonitor);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   112
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   113
        },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   114
    };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   115
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   116
    // Sequence input parameters, used in initializing services.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   117
    private PDALaunch  fLaunch;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   118
    private DsfSession fSession;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   119
    private String fProgram;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   120
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   121
    // Service references, initialized when created and used in initializing other services.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   122
    private PDACommandControl fCommandControl;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   123
    private PDARunControl fRunControl;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   124
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   125
    public PDAServicesInitSequence(DsfSession session, PDALaunch launch, String program, RequestMonitor rm) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   126
    {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   127
        super(session.getExecutor(), rm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   128
        fLaunch = launch;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   129
        fSession = session;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   130
        fProgram = program;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   131
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   132
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   133
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   134
    public Step[] getSteps() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   135
        return fSteps;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   136
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   137
}