mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[220446] Updated the PDA Debugger example.
This commit is contained in:
parent
f2615af486
commit
fd0cf814cc
51 changed files with 4048 additions and 237 deletions
|
@ -174,7 +174,6 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
|
||||||
// Returns the adapter type for the launch object.
|
// Returns the adapter type for the launch object.
|
||||||
if (adapterType.equals(IElementContentProvider.class)) return adapterSet.fViewModelAdapter;
|
if (adapterType.equals(IElementContentProvider.class)) return adapterSet.fViewModelAdapter;
|
||||||
else if (adapterType.equals(IModelProxyFactory.class)) return adapterSet.fViewModelAdapter;
|
else if (adapterType.equals(IModelProxyFactory.class)) return adapterSet.fViewModelAdapter;
|
||||||
else if (adapterType.equals(IColumnPresentationFactory.class)) return adapterSet.fViewModelAdapter;
|
|
||||||
else return null;
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,223 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDAAdapterFactory.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-10T20:15:58+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2006 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.ui;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import java.util.Collections;</font>
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.HashMap;</font>
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import java.util.Map;</font>
|
||||||
|
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.core.runtime.IAdapterFactory;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.Immutable;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ThreadSafe;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.actions.DsfResumeCommand;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.actions.DsfStepIntoCommand;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.actions.DsfStepOverCommand;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.actions.DsfStepReturnCommand;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.actions.DsfSuspendCommand;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.sourcelookup.MISourceDisplayAdapter;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.dd.examples.pda.launch.PDALaunch;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.dd.examples.pda.ui.actions.PDATerminateCommand;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.dd.examples.pda.ui.viewmodel.PDAVMAdapter;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.debug.core.DebugPlugin;</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#228B22">import org.eclipse.debug.core.ILaunch;</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#228B22">import org.eclipse.debug.core.ILaunchesListener2;</font>
|
||||||
|
<a name="line34"> 34: </a><font color="#228B22">import org.eclipse.debug.core.commands.IResumeHandler;</font>
|
||||||
|
<a name="line35"> 35: </a><font color="#228B22">import org.eclipse.debug.core.commands.IStepIntoHandler;</font>
|
||||||
|
<a name="line36"> 36: </a><font color="#228B22">import org.eclipse.debug.core.commands.IStepOverHandler;</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#228B22">import org.eclipse.debug.core.commands.IStepReturnHandler;</font>
|
||||||
|
<a name="line38"> 38: </a><font color="#228B22">import org.eclipse.debug.core.commands.ISuspendHandler;</font>
|
||||||
|
<a name="line39"> 39: </a><font color="#228B22">import org.eclipse.debug.core.commands.ITerminateHandler;</font>
|
||||||
|
<a name="line40"> 40: </a><font color="#228B22">import org.eclipse.debug.core.model.IDebugModelProvider;</font>
|
||||||
|
<a name="line41"> 41: </a><font color="#228B22">import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;</font>
|
||||||
|
<a name="line42"> 42: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;</font>
|
||||||
|
<a name="line43"> 43: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;</font>
|
||||||
|
<a name="line44"> 44: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;</font>
|
||||||
|
<a name="line45"> 45: </a><font color="#228B22">import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;</font>
|
||||||
|
|
||||||
|
<a name="line47"> 47: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line48"> 48: </a><font color="#B22222"> * The adapter factory is the central point of control of view model and other</font>
|
||||||
|
<a name="line49"> 49: </a><font color="#B22222"> * UI adapters of a DSF-based debugger. As new launches are created and </font>
|
||||||
|
<a name="line50"> 50: </a><font color="#B22222"> * old ones removed, this factory manages the life cycle of the associated</font>
|
||||||
|
<a name="line51"> 51: </a><font color="#B22222"> * UI adapters. </font>
|
||||||
|
<a name="line52"> 52: </a><font color="#B22222"> * <p></font>
|
||||||
|
<a name="line53"> 53: </a><font color="#B22222"> * As a platform adapter factory, this factory only provides adapters for</font>
|
||||||
|
<a name="line54"> 54: </a><font color="#B22222"> * the launch object. Adapters for all other objects in the DSF model hierarchy</font>
|
||||||
|
<a name="line55"> 55: </a><font color="#B22222"> * are registered with the DSF session. </font>
|
||||||
|
<a name="line56"> 56: </a><font color="#B22222"> * </p></font>
|
||||||
|
<a name="line57"> 57: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line58"> 58: </a>@ThreadSafe
|
||||||
|
<a name="line59"> 59: </a>@SuppressWarnings({<font color="#666666">"restriction"</font>})
|
||||||
|
<a name="line60"> 60: </a><strong><font color="#4169E1"><a name="PDAAdapterFactory"></a>public class PDAAdapterFactory implements IAdapterFactory</font></strong>, ILaunchesListener2
|
||||||
|
<a name="line61"> 61: </a>{
|
||||||
|
<a name="line62"> 62: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line63"> 63: </a><font color="#B22222"> * Contains the set of adapters that are created for eacy launch instance.</font>
|
||||||
|
<a name="line64"> 64: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line65"> 65: </a> @Immutable
|
||||||
|
<a name="line66"> 66: </a> private static class LaunchAdapterSet {
|
||||||
|
<a name="line67"> 67: </a> <font color="#B22222">// View Model adapter</font>
|
||||||
|
<a name="line68"> 68: </a> final PDAVMAdapter fViewModelAdapter;
|
||||||
|
<a name="line69"> 69: </a>
|
||||||
|
<a name="line70"> 70: </a> <font color="#B22222">// Source lookup and positioning adapter</font>
|
||||||
|
<a name="line71"> 71: </a> final MISourceDisplayAdapter fSourceDisplayAdapter;
|
||||||
|
<a name="line72"> 72: </a>
|
||||||
|
<a name="line73"> 73: </a> <font color="#B22222">// Command adapters</font>
|
||||||
|
<a name="line74"> 74: </a> final DsfStepIntoCommand fStepIntoCommand;
|
||||||
|
<a name="line75"> 75: </a> final DsfStepOverCommand fStepOverCommand;
|
||||||
|
<a name="line76"> 76: </a> final DsfStepReturnCommand fStepReturnCommand;
|
||||||
|
<a name="line77"> 77: </a> final DsfSuspendCommand fSuspendCommand;
|
||||||
|
<a name="line78"> 78: </a> final DsfResumeCommand fResumeCommand;
|
||||||
|
<a name="line79"> 79: </a> final PDATerminateCommand fTerminateCommand;
|
||||||
|
<a name="line80"> 80: </a>
|
||||||
|
<a name="line81"> 81: </a> <font color="#B22222">// Adapters for integration with other UI actions</font>
|
||||||
|
<a name="line82"> 82: </a> final IDebugModelProvider fDebugModelProvider;
|
||||||
|
<a name="line83"> 83: </a> final PDALaunch fLaunch;
|
||||||
|
|
||||||
|
<a name="line85"> 85: </a> LaunchAdapterSet(PDALaunch launch) {
|
||||||
|
<a name="line86"> 86: </a> <font color="#B22222">// Initialize launch and session.</font>
|
||||||
|
<a name="line87"> 87: </a> fLaunch = launch;
|
||||||
|
<a name="line88"> 88: </a> DsfSession session = launch.getSession();
|
||||||
|
<a name="line89"> 89: </a>
|
||||||
|
<a name="line90"> 90: </a> <font color="#B22222">// Initialize VM</font>
|
||||||
|
<a name="line91"> 91: </a> fViewModelAdapter = new PDAVMAdapter(session);
|
||||||
|
|
||||||
|
<a name="line93"> 93: </a> <font color="#B22222">// Initialize source lookup</font>
|
||||||
|
<a name="line94"> 94: </a> fSourceDisplayAdapter = new MISourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator());
|
||||||
|
<a name="line95"> 95: </a> session.registerModelAdapter(ISourceDisplay.class, fSourceDisplayAdapter);
|
||||||
|
<a name="line96"> 96: </a>
|
||||||
|
<a name="line97"> 97: </a> <font color="#B22222">// Initialize retargetable command handler.</font>
|
||||||
|
<a name="line98"> 98: </a> fStepIntoCommand = new DsfStepIntoCommand(session);
|
||||||
|
<a name="line99"> 99: </a> fStepOverCommand = new DsfStepOverCommand(session);
|
||||||
|
<a name="line100">100: </a> fStepReturnCommand = new DsfStepReturnCommand(session);
|
||||||
|
<a name="line101">101: </a> fSuspendCommand = new DsfSuspendCommand(session);
|
||||||
|
<a name="line102">102: </a> fResumeCommand = new DsfResumeCommand(session);
|
||||||
|
<a name="line103">103: </a> fTerminateCommand = new PDATerminateCommand(session);
|
||||||
|
<a name="line104">104: </a> session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand);
|
||||||
|
<a name="line105">105: </a> session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand);
|
||||||
|
<a name="line106">106: </a> session.registerModelAdapter(IStepReturnHandler.class, fStepReturnCommand);
|
||||||
|
<a name="line107">107: </a> session.registerModelAdapter(ISuspendHandler.class, fSuspendCommand);
|
||||||
|
<a name="line108">108: </a> session.registerModelAdapter(IResumeHandler.class, fResumeCommand);
|
||||||
|
<a name="line109">109: </a> session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
|
||||||
|
|
||||||
|
<a name="line111">111: </a> <font color="#B22222">// Initialize debug model provider</font>
|
||||||
|
<a name="line112">112: </a> fDebugModelProvider = new IDebugModelProvider() {
|
||||||
|
<a name="line113">113: </a> public String[] getModelIdentifiers() {
|
||||||
|
<a name="line114">114: </a> <font color="#4169E1">return</font> new String[] { PDAPlugin.ID_PDA_DEBUG_MODEL };
|
||||||
|
<a name="line115">115: </a> }
|
||||||
|
<a name="line116">116: </a> };
|
||||||
|
<a name="line117">117: </a> session.registerModelAdapter(IDebugModelProvider.class, fDebugModelProvider);
|
||||||
|
<a name="line118">118: </a>
|
||||||
|
<a name="line119">119: </a> <font color="#B22222">// Register the launch as an adapter This ensures that the launch, </font>
|
||||||
|
<a name="line120">120: </a> <font color="#B22222">// and debug model ID will be associated with all DMContexts from this </font>
|
||||||
|
<a name="line121">121: </a> <font color="#B22222">// session. </font>
|
||||||
|
<a name="line122">122: </a> session.registerModelAdapter(ILaunch.class, fLaunch);
|
||||||
|
<a name="line123">123: </a> }
|
||||||
|
<a name="line124">124: </a>
|
||||||
|
<a name="line125">125: </a> void dispose() {
|
||||||
|
<a name="line126">126: </a> DsfSession session = fLaunch.getSession();
|
||||||
|
|
||||||
|
<a name="line128">128: </a> fViewModelAdapter.dispose();
|
||||||
|
|
||||||
|
<a name="line130">130: </a> session.unregisterModelAdapter(ISourceDisplay.class);
|
||||||
|
<a name="line131">131: </a> <font color="#4169E1">if</font> (fSourceDisplayAdapter != null) fSourceDisplayAdapter.dispose();
|
||||||
|
<a name="line132">132: </a>
|
||||||
|
<a name="line133">133: </a> session.unregisterModelAdapter(IStepIntoHandler.class);
|
||||||
|
<a name="line134">134: </a> session.unregisterModelAdapter(IStepOverHandler.class);
|
||||||
|
<a name="line135">135: </a> session.unregisterModelAdapter(IStepReturnHandler.class);
|
||||||
|
<a name="line136">136: </a> session.unregisterModelAdapter(ISuspendHandler.class);
|
||||||
|
<a name="line137">137: </a> session.unregisterModelAdapter(IResumeHandler.class);
|
||||||
|
<a name="line138">138: </a> session.unregisterModelAdapter(ITerminateHandler.class);
|
||||||
|
<a name="line139">139: </a> fStepIntoCommand.dispose();
|
||||||
|
<a name="line140">140: </a> fStepOverCommand.dispose();
|
||||||
|
<a name="line141">141: </a> fStepReturnCommand.dispose();
|
||||||
|
<a name="line142">142: </a> fSuspendCommand.dispose();
|
||||||
|
<a name="line143">143: </a> fResumeCommand.dispose();
|
||||||
|
<a name="line144">144: </a> fTerminateCommand.dispose();
|
||||||
|
<a name="line145">145: </a> }
|
||||||
|
<a name="line146">146: </a> }
|
||||||
|
|
||||||
|
<a name="line148">148: </a> private Map<PDALaunch, LaunchAdapterSet> fLaunchAdapterSets =
|
||||||
|
<a name="line149">149: </a> Collections.synchronizedMap(new HashMap<PDALaunch, LaunchAdapterSet>());
|
||||||
|
<a name="line150">150: </a>
|
||||||
|
<a name="line151">151: </a><strong><font color="#4169E1"> public PDAAdapterFactory()</font></strong> {
|
||||||
|
<a name="line152">152: </a> DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
||||||
|
<a name="line153">153: </a> }
|
||||||
|
|
||||||
|
<a name="line155">155: </a> <font color="#B22222">// This IAdapterFactory method returns adapters for the PDA launch object only. </font>
|
||||||
|
<a name="line156">156: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>) <font color="#B22222">// IAdapterFactory is Java 1.3</font>
|
||||||
|
<a name="line157">157: </a><strong><font color="#4169E1"> public Object getAdapter(Object adaptableObject, Class adapterType)</font></strong> {
|
||||||
|
<a name="line158">158: </a> <font color="#4169E1">if</font> (!(adaptableObject instanceof PDALaunch)) <font color="#4169E1">return</font> null;
|
||||||
|
|
||||||
|
<a name="line160">160: </a> PDALaunch launch = (PDALaunch)adaptableObject;
|
||||||
|
|
||||||
|
<a name="line162">162: </a> <font color="#B22222">// Find the correct set of adapters based on the launch. If not found</font>
|
||||||
|
<a name="line163">163: </a> <font color="#B22222">// it means that we have a new launch, and we have to create a </font>
|
||||||
|
<a name="line164">164: </a> <font color="#B22222">// new set of adapters. </font>
|
||||||
|
<a name="line165">165: </a> LaunchAdapterSet adapterSet;
|
||||||
|
<a name="line166">166: </a> synchronized(fLaunchAdapterSets) {
|
||||||
|
<a name="line167">167: </a> adapterSet = fLaunchAdapterSets.get(launch);
|
||||||
|
<a name="line168">168: </a> <font color="#4169E1">if</font> (adapterSet == null) {
|
||||||
|
<a name="line169">169: </a> adapterSet = new LaunchAdapterSet(launch);
|
||||||
|
<a name="line170">170: </a> fLaunchAdapterSets.put(launch, adapterSet);
|
||||||
|
<a name="line171">171: </a> }
|
||||||
|
<a name="line172">172: </a> }
|
||||||
|
<a name="line173">173: </a>
|
||||||
|
<a name="line174">174: </a> <font color="#B22222">// Returns the adapter type for the launch object.</font>
|
||||||
|
<a name="line175">175: </a> <font color="#4169E1">if</font> (adapterType.equals(IElementContentProvider.class)) <font color="#4169E1">return</font> adapterSet.fViewModelAdapter;
|
||||||
|
<a name="line176">176: </a> <font color="#4169E1">else</font> <font color="#4169E1">if</font> (adapterType.equals(IModelProxyFactory.class)) <font color="#4169E1">return</font> adapterSet.fViewModelAdapter;
|
||||||
|
<a name="line177">177: </a> <font color="#4169E1">else</font> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line178">178: </a> }
|
||||||
|
|
||||||
|
<a name="line180">180: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>) <font color="#B22222">// IAdapterFactory is Java 1.3</font>
|
||||||
|
<a name="line181">181: </a> public Class[] getAdapterList() {
|
||||||
|
<a name="line182">182: </a> <font color="#4169E1">return</font> new Class[] { IElementContentProvider.class, IModelProxyFactory.class, IColumnPresentationFactory.class };
|
||||||
|
<a name="line183">183: </a> }
|
||||||
|
|
||||||
|
<a name="line185">185: </a><strong><font color="#4169E1"> public void launchesRemoved(ILaunch[] launches)</font></strong> {
|
||||||
|
<a name="line186">186: </a> <font color="#B22222">// Dispose the set of adapters for a launch only after the launch is </font>
|
||||||
|
<a name="line187">187: </a> <font color="#B22222">// removed from the view. If the launch is terminated, the adapters</font>
|
||||||
|
<a name="line188">188: </a> <font color="#B22222">// are still needed to populate the contents of the view.</font>
|
||||||
|
<a name="line189">189: </a> <font color="#4169E1">for</font> (ILaunch launch : launches) {
|
||||||
|
<a name="line190">190: </a> <font color="#4169E1">if</font> (launch instanceof PDALaunch) {
|
||||||
|
<a name="line191">191: </a> PDALaunch pdaLaunch = (PDALaunch)launch;
|
||||||
|
<a name="line192">192: </a> synchronized(fLaunchAdapterSets) {
|
||||||
|
<a name="line193">193: </a> <font color="#4169E1">if</font> ( fLaunchAdapterSets.containsKey(pdaLaunch) ) {
|
||||||
|
<a name="line194">194: </a> fLaunchAdapterSets.remove(pdaLaunch).dispose();
|
||||||
|
<a name="line195">195: </a> }
|
||||||
|
<a name="line196">196: </a> }
|
||||||
|
<a name="line197">197: </a> }
|
||||||
|
<a name="line198">198: </a> }
|
||||||
|
<a name="line199">199: </a> }
|
||||||
|
|
||||||
|
<a name="line201">201: </a><strong><font color="#4169E1"> public void launchesTerminated(ILaunch[] launches)</font></strong> {
|
||||||
|
<a name="line202">202: </a> }
|
||||||
|
|
||||||
|
<a name="line204">204: </a><strong><font color="#4169E1"> public void launchesAdded(ILaunch[] launches)</font></strong> {
|
||||||
|
<a name="line205">205: </a> }
|
||||||
|
<a name="line206">206: </a>
|
||||||
|
<a name="line207">207: </a><strong><font color="#4169E1"> public void launchesChanged(ILaunch[] launches)</font></strong> {
|
||||||
|
<a name="line208">208: </a> }
|
||||||
|
<a name="line209">209: </a>
|
||||||
|
<a name="line210">210: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -12,13 +12,11 @@ package org.eclipse.dd.examples.pda.ui.viewmodel;
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.concurrent.ThreadSafe;
|
import org.eclipse.dd.dsf.concurrent.ThreadSafe;
|
||||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
|
import org.eclipse.dd.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
|
||||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.modules.ModulesVMProvider;
|
|
||||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.register.RegisterVMProvider;
|
|
||||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.variable.VariableVMProvider;
|
import org.eclipse.dd.dsf.debug.ui.viewmodel.variable.VariableVMProvider;
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMAdapter;
|
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMAdapter;
|
||||||
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
||||||
import org.eclipse.dd.examples.pda.ui.viewmodel.launch.LaunchVMProvider;
|
import org.eclipse.dd.examples.pda.ui.viewmodel.launch.PDALaunchVMProvider;
|
||||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
|
||||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
|
@ -44,11 +42,9 @@ public class PDAVMAdapter extends AbstractDMVMAdapter
|
||||||
@Override
|
@Override
|
||||||
protected AbstractDMVMProvider createViewModelProvider(IPresentationContext context) {
|
protected AbstractDMVMProvider createViewModelProvider(IPresentationContext context) {
|
||||||
if ( IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId()) ) {
|
if ( IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId()) ) {
|
||||||
return new LaunchVMProvider(this, context, getSession());
|
return new PDALaunchVMProvider(this, context, getSession());
|
||||||
} else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId()) ) {
|
} else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId()) ) {
|
||||||
return new VariableVMProvider(this, context, getSession());
|
return new VariableVMProvider(this, context, getSession());
|
||||||
} else if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId()) ) {
|
|
||||||
return new RegisterVMProvider(this, context, getSession());
|
|
||||||
} else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) {
|
} else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) {
|
||||||
return new ExpressionVMProvider(this, context, getSession());
|
return new ExpressionVMProvider(this, context, getSession());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDAVMAdapter.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-10T21:49:37+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2006 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.ui.viewmodel;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ThreadSafe;</font>
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;</font>
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.viewmodel.variable.VariableVMProvider;</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMAdapter;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.examples.pda.ui.viewmodel.launch.LaunchVMProvider;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.debug.ui.IDebugUIConstants;</font>
|
||||||
|
|
||||||
|
<a name="line24"> 24: </a><font color="#B22222">/* </font>
|
||||||
|
<a name="line25"> 25: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line26"> 26: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line27"> 27: </a>@ThreadSafe
|
||||||
|
<a name="line28"> 28: </a>@SuppressWarnings(<font color="#666666">"restriction"</font>)
|
||||||
|
<a name="line29"> 29: </a><strong><font color="#4169E1"><a name="PDAVMAdapter"></a>public class PDAVMAdapter extends AbstractDMVMAdapter</font></strong>
|
||||||
|
<a name="line30"> 30: </a>{
|
||||||
|
<a name="line31"> 31: </a><strong><font color="#4169E1"> public PDAVMAdapter(DsfSession session)</font></strong> {
|
||||||
|
<a name="line32"> 32: </a> super(session);
|
||||||
|
<a name="line33"> 33: </a> getSession().registerModelAdapter(IColumnPresentationFactory.class, this);
|
||||||
|
<a name="line34"> 34: </a> }
|
||||||
|
|
||||||
|
<a name="line36"> 36: </a> @Override
|
||||||
|
<a name="line37"> 37: </a><strong><font color="#4169E1"> public void dispose()</font></strong> {
|
||||||
|
<a name="line38"> 38: </a> getSession().unregisterModelAdapter(IColumnPresentationFactory.class);
|
||||||
|
<a name="line39"> 39: </a> super.dispose();
|
||||||
|
<a name="line40"> 40: </a> }
|
||||||
|
<a name="line41"> 41: </a>
|
||||||
|
<a name="line42"> 42: </a> @Override
|
||||||
|
<a name="line43"> 43: </a><strong><font color="#4169E1"> protected AbstractDMVMProvider createViewModelProvider(IPresentationContext context)</font></strong> {
|
||||||
|
<a name="line44"> 44: </a> <font color="#4169E1">if</font> ( IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId()) ) {
|
||||||
|
<a name="line45"> 45: </a> <font color="#4169E1">return</font> new PDALaunchVMProvider(this, context, getSession());
|
||||||
|
<a name="line46"> 46: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId()) ) {
|
||||||
|
<a name="line47"> 47: </a> <font color="#4169E1">return</font> new VariableVMProvider(this, context, getSession());
|
||||||
|
<a name="line48"> 48: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) {
|
||||||
|
<a name="line49"> 49: </a> <font color="#4169E1">return</font> new ExpressionVMProvider(this, context, getSession());
|
||||||
|
<a name="line50"> 50: </a> }
|
||||||
|
<a name="line51"> 51: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line52"> 52: </a> }
|
||||||
|
<a name="line53"> 53: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -43,11 +43,11 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class LaunchVMProvider extends AbstractDMVMProvider
|
public class PDALaunchVMProvider extends AbstractDMVMProvider
|
||||||
implements IDebugEventSetListener, ILaunchesListener2
|
implements IDebugEventSetListener, ILaunchesListener2
|
||||||
{
|
{
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public LaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session)
|
public PDALaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session)
|
||||||
{
|
{
|
||||||
super(adapter, presentationContext, session);
|
super(adapter, presentationContext, session);
|
||||||
|
|
||||||
|
@ -55,13 +55,13 @@ public class LaunchVMProvider extends AbstractDMVMProvider
|
||||||
setRootNode(launchNode);
|
setRootNode(launchNode);
|
||||||
|
|
||||||
// Launch node is a parent to the processes and program nodes.
|
// Launch node is a parent to the processes and program nodes.
|
||||||
IVMNode threadsNode = new PDAProgramVMNode(this, getSession());
|
IVMNode pdaProgramNode = new PDAProgramVMNode(this, getSession());
|
||||||
IVMNode processesNode = new StandardProcessVMNode(this);
|
IVMNode processesNode = new StandardProcessVMNode(this);
|
||||||
addChildNodes(launchNode, new IVMNode[] { threadsNode, processesNode});
|
addChildNodes(launchNode, new IVMNode[] { pdaProgramNode, processesNode});
|
||||||
|
|
||||||
// Stack frames node is under the PDA program node.
|
// Stack frames node is under the PDA program node.
|
||||||
IVMNode stackFramesNode = new StackFramesVMNode(this, getSession());
|
IVMNode stackFramesNode = new StackFramesVMNode(this, getSession());
|
||||||
addChildNodes(threadsNode, new IVMNode[] { stackFramesNode });
|
addChildNodes(pdaProgramNode, new IVMNode[] { stackFramesNode });
|
||||||
|
|
||||||
// Register the LaunchVM provider as a listener to debug and launch
|
// Register the LaunchVM provider as a listener to debug and launch
|
||||||
// events. These events are used by the launch and processes nodes.
|
// events. These events are used by the launch and processes nodes.
|
|
@ -0,0 +1,149 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDALaunchVMProvider.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-11T03:37:34+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2006 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> * Ericsson - Modified for new functionality </font>
|
||||||
|
<a name="line11"> 11: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line12"> 12: </a>package org.eclipse.dd.examples.pda.ui.viewmodel.launch;
|
||||||
|
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.concurrent.RejectedExecutionException;</font>
|
||||||
|
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ThreadSafe;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.viewmodel.launch.LaunchRootVMNode;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.viewmodel.launch.StackFramesVMNode;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.viewmodel.launch.StandardProcessVMNode;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.ui.viewmodel.launch.LaunchRootVMNode.LaunchesEvent;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.IRootVMNode;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.IVMNode;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.debug.core.DebugEvent;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.debug.core.DebugPlugin;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.debug.core.IDebugEventSetListener;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.debug.core.ILaunch;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.debug.core.ILaunchesListener2;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;</font>
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line34"> 34: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line35"> 35: </a><font color="#B22222"> * View Model provider for the Launch (AKA Debug) view. The PDA debugger is </font>
|
||||||
|
<a name="line36"> 36: </a><font color="#B22222"> * single-threaded, so there is no need for a debug target element to be visible</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#B22222"> * in the debug view. Therefore the launch VM provider is configured with three nodes:</font>
|
||||||
|
<a name="line38"> 38: </a><font color="#B22222"> * <ul></font>
|
||||||
|
<a name="line39"> 39: </a><font color="#B22222"> * <li> LaunchRootVMNode - This is the root of the PDA view model.</li> </font>
|
||||||
|
<a name="line40"> 40: </a><font color="#B22222"> * <li> ThreadVMNode - Supplies the PDA program element.</li> </font>
|
||||||
|
<a name="line41"> 41: </a><font color="#B22222"> * <li> StackFramesVMNode - Supplies the stack frame elements.</li> </font>
|
||||||
|
<a name="line42"> 42: </a><font color="#B22222"> * <li> StandardProcessVMNode - Supplies elements representing the PDA debugger process.</li></font>
|
||||||
|
<a name="line43"> 43: </a><font color="#B22222"> * </ul> </font>
|
||||||
|
<a name="line44"> 44: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line45"> 45: </a>@SuppressWarnings(<font color="#666666">"restriction"</font>)
|
||||||
|
<a name="line46"> 46: </a><strong><font color="#4169E1"><a name="PDALaunchVMProvider"></a>public class PDALaunchVMProvider extends AbstractDMVMProvider </font></strong>
|
||||||
|
<a name="line47"> 47: </a> implements IDebugEventSetListener, ILaunchesListener2
|
||||||
|
<a name="line48"> 48: </a>{
|
||||||
|
<a name="line49"> 49: </a> @ThreadSafe
|
||||||
|
<a name="line50"> 50: </a><strong><font color="#4169E1"> public PDALaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session)</font></strong>
|
||||||
|
<a name="line51"> 51: </a> {
|
||||||
|
<a name="line52"> 52: </a> super(adapter, presentationContext, session);
|
||||||
|
<a name="line53"> 53: </a>
|
||||||
|
<a name="line54"> 54: </a> IRootVMNode launchNode = new LaunchRootVMNode(this);
|
||||||
|
<a name="line55"> 55: </a> setRootNode(launchNode);
|
||||||
|
|
||||||
|
<a name="line57"> 57: </a> <font color="#B22222">// Launch node is a parent to the processes and program nodes.</font>
|
||||||
|
<a name="line58"> 58: </a> IVMNode pdaProgramNode = new PDAProgramVMNode(this, getSession());
|
||||||
|
<a name="line59"> 59: </a> IVMNode processesNode = new StandardProcessVMNode(this);
|
||||||
|
<a name="line60"> 60: </a> addChildNodes(launchNode, new IVMNode[] { pdaProgramNode, processesNode});
|
||||||
|
<a name="line61"> 61: </a>
|
||||||
|
<a name="line62"> 62: </a> <font color="#B22222">// Stack frames node is under the PDA program node.</font>
|
||||||
|
<a name="line63"> 63: </a> IVMNode stackFramesNode = new StackFramesVMNode(this, getSession());
|
||||||
|
<a name="line64"> 64: </a> addChildNodes(pdaProgramNode, new IVMNode[] { stackFramesNode });
|
||||||
|
|
||||||
|
<a name="line66"> 66: </a> <font color="#B22222">// Register the LaunchVM provider as a listener to debug and launch </font>
|
||||||
|
<a name="line67"> 67: </a> <font color="#B22222">// events. These events are used by the launch and processes nodes.</font>
|
||||||
|
<a name="line68"> 68: </a> DebugPlugin.getDefault().addDebugEventListener(this);
|
||||||
|
<a name="line69"> 69: </a> DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
||||||
|
<a name="line70"> 70: </a> }
|
||||||
|
<a name="line71"> 71: </a>
|
||||||
|
<a name="line72"> 72: </a>
|
||||||
|
<a name="line73"> 73: </a><strong><font color="#4169E1"> public void handleDebugEvents(final DebugEvent[] events)</font></strong> {
|
||||||
|
<a name="line74"> 74: </a> <font color="#4169E1">if</font> (isDisposed()) <font color="#4169E1">return</font>;
|
||||||
|
<a name="line75"> 75: </a>
|
||||||
|
<a name="line76"> 76: </a> <font color="#B22222">// This method may be called on any thread. Switch to the </font>
|
||||||
|
<a name="line77"> 77: </a> <font color="#B22222">// view model executor thread before processing.</font>
|
||||||
|
<a name="line78"> 78: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line79"> 79: </a> getExecutor().execute(new Runnable() {
|
||||||
|
<a name="line80"> 80: </a><strong><font color="#4169E1"> public void run()</font></strong> {
|
||||||
|
<a name="line81"> 81: </a> <font color="#4169E1">if</font> (isDisposed()) <font color="#4169E1">return</font>;
|
||||||
|
<a name="line82"> 82: </a>
|
||||||
|
<a name="line83"> 83: </a> <font color="#4169E1">for</font> (final DebugEvent event : events) {
|
||||||
|
<a name="line84"> 84: </a> handleEvent(event);
|
||||||
|
<a name="line85"> 85: </a> }
|
||||||
|
<a name="line86"> 86: </a> }});
|
||||||
|
<a name="line87"> 87: </a> } <font color="#4169E1">catch</font> (RejectedExecutionException e) {
|
||||||
|
<a name="line88"> 88: </a> <font color="#B22222">// Ignore. This exception could be thrown if the view model is being </font>
|
||||||
|
<a name="line89"> 89: </a> <font color="#B22222">// shut down. </font>
|
||||||
|
<a name="line90"> 90: </a> }
|
||||||
|
<a name="line91"> 91: </a> }
|
||||||
|
|
||||||
|
<a name="line93"> 93: </a> @Override
|
||||||
|
<a name="line94"> 94: </a><strong><font color="#4169E1"> public void dispose()</font></strong> {
|
||||||
|
<a name="line95"> 95: </a> DebugPlugin.getDefault().removeDebugEventListener(this);
|
||||||
|
<a name="line96"> 96: </a> DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
|
||||||
|
<a name="line97"> 97: </a> super.dispose();
|
||||||
|
<a name="line98"> 98: </a> }
|
||||||
|
<a name="line99"> 99: </a>
|
||||||
|
<a name="line100">100: </a><strong><font color="#4169E1"> public void launchesAdded(ILaunch[] launches)</font></strong> {
|
||||||
|
<a name="line101">101: </a> handleLaunchesEvent(new LaunchesEvent(launches, LaunchesEvent.Type.ADDED));
|
||||||
|
<a name="line102">102: </a> }
|
||||||
|
<a name="line103">103: </a>
|
||||||
|
<a name="line104">104: </a><strong><font color="#4169E1"> public void launchesRemoved(ILaunch[] launches)</font></strong> {
|
||||||
|
<a name="line105">105: </a> handleLaunchesEvent(new LaunchesEvent(launches, LaunchesEvent.Type.REMOVED));
|
||||||
|
<a name="line106">106: </a> }
|
||||||
|
<a name="line107">107: </a>
|
||||||
|
<a name="line108">108: </a><strong><font color="#4169E1"> public void launchesChanged(ILaunch[] launches)</font></strong> {
|
||||||
|
<a name="line109">109: </a> handleLaunchesEvent(new LaunchesEvent(launches, LaunchesEvent.Type.CHANGED));
|
||||||
|
<a name="line110">110: </a> }
|
||||||
|
<a name="line111">111: </a>
|
||||||
|
<a name="line112">112: </a><strong><font color="#4169E1"> public void launchesTerminated(ILaunch[] launches)</font></strong> {
|
||||||
|
<a name="line113">113: </a> handleLaunchesEvent(new LaunchesEvent(launches, LaunchesEvent.Type.TERMINATED));
|
||||||
|
<a name="line114">114: </a> }
|
||||||
|
<a name="line115">115: </a>
|
||||||
|
<a name="line116">116: </a><strong><font color="#4169E1"> private void handleLaunchesEvent(final LaunchesEvent event)</font></strong> {
|
||||||
|
<a name="line117">117: </a> <font color="#4169E1">if</font> (isDisposed()) <font color="#4169E1">return</font>;
|
||||||
|
<a name="line118">118: </a>
|
||||||
|
<a name="line119">119: </a> <font color="#B22222">// This method also may be called on any thread. Switch to the </font>
|
||||||
|
<a name="line120">120: </a> <font color="#B22222">// view model executor thread before processing.</font>
|
||||||
|
<a name="line121">121: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line122">122: </a> getExecutor().execute(new Runnable() {
|
||||||
|
<a name="line123">123: </a><strong><font color="#4169E1"> public void run()</font></strong> {
|
||||||
|
<a name="line124">124: </a> <font color="#4169E1">if</font> (isDisposed()) <font color="#4169E1">return</font>;
|
||||||
|
<a name="line125">125: </a>
|
||||||
|
<a name="line126">126: </a> IRootVMNode rootLayoutNode = getRootVMNode();
|
||||||
|
<a name="line127">127: </a> <font color="#4169E1">if</font> (rootLayoutNode != null && rootLayoutNode.getDeltaFlags(event) != 0) {
|
||||||
|
<a name="line128">128: </a> handleEvent(event);
|
||||||
|
<a name="line129">129: </a> }
|
||||||
|
<a name="line130">130: </a> }});
|
||||||
|
<a name="line131">131: </a> } <font color="#4169E1">catch</font> (RejectedExecutionException e) {
|
||||||
|
<a name="line132">132: </a> <font color="#B22222">// Ignore. This exception could be thrown if the view model is being </font>
|
||||||
|
<a name="line133">133: </a> <font color="#B22222">// shut down. </font>
|
||||||
|
<a name="line134">134: </a> }
|
||||||
|
<a name="line135">135: </a> }
|
||||||
|
<a name="line136">136: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -133,16 +133,18 @@ public class PDAProgramVMNode extends AbstractDMVMNode
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateElementsInSessionThread(final IChildrenUpdate update) {
|
protected void updateElementsInSessionThread(final IChildrenUpdate update) {
|
||||||
// Check if service is still available. checkService() is a convenience
|
|
||||||
// method that marks the update as failed if the needed service is not
|
|
||||||
// available.
|
|
||||||
if (!checkService(PDACommandControl.class, null, update)) return;
|
|
||||||
|
|
||||||
// Get the instance of the service. Note that there is no race condition
|
// Get the instance of the service. Note that there is no race condition
|
||||||
// in getting the service since this method is called only in the
|
// in getting the service since this method is called only in the
|
||||||
// service executor thred.
|
// service executor thread.
|
||||||
final PDACommandControl commandControl = getServicesTracker().getService(PDACommandControl.class);
|
final PDACommandControl commandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
|
||||||
|
// Check if the service is available. If it is not, no elements are
|
||||||
|
// updated.
|
||||||
|
if (commandControl == null) {
|
||||||
|
handleFailedUpdate(update);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
update.setChild(createVMContext(commandControl.getProgramDMContext()), 0);
|
update.setChild(createVMContext(commandControl.getProgramDMContext()), 0);
|
||||||
update.done();
|
update.done();
|
||||||
}
|
}
|
||||||
|
@ -172,8 +174,11 @@ public class PDAProgramVMNode extends AbstractDMVMNode
|
||||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||||
private void updateProgramLabelInSessionThread(final ILabelUpdate update) {
|
private void updateProgramLabelInSessionThread(final ILabelUpdate update) {
|
||||||
// Get a reference to the run control service.
|
// Get a reference to the run control service.
|
||||||
if (!checkService(IRunControl.class, null, update)) return;
|
|
||||||
final IRunControl runControl = getServicesTracker().getService(IRunControl.class);
|
final IRunControl runControl = getServicesTracker().getService(IRunControl.class);
|
||||||
|
if (runControl == null) {
|
||||||
|
handleFailedUpdate(update);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the PDA program context.
|
// Find the PDA program context.
|
||||||
final PDAProgramDMContext programCtx =
|
final PDAProgramDMContext programCtx =
|
||||||
|
@ -191,7 +196,7 @@ public class PDAProgramVMNode extends AbstractDMVMNode
|
||||||
}
|
}
|
||||||
update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
|
update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
|
||||||
|
|
||||||
// Retrieve the last state chagne reason
|
// Retrieve the last state change reason
|
||||||
runControl.getExecutionData(
|
runControl.getExecutionData(
|
||||||
programCtx,
|
programCtx,
|
||||||
new DataRequestMonitor<IExecutionDMData>(ImmediateExecutor.getInstance(), null)
|
new DataRequestMonitor<IExecutionDMData>(ImmediateExecutor.getInstance(), null)
|
||||||
|
|
|
@ -0,0 +1,303 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDAProgramVMNode.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-11T04:46:58+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2006 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> * Ericsson - Modified for multi threaded functionality </font>
|
||||||
|
<a name="line11"> 11: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line12"> 12: </a>package org.eclipse.dd.examples.pda.ui.viewmodel.launch;
|
||||||
|
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.concurrent.RejectedExecutionException;</font>
|
||||||
|
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import org.eclipse.core.runtime.CoreException;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DsfRunnable;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ImmediateExecutor;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.RequestMonitor;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.IDMEvent;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMData;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMContext;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.IVMAdapter;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.IVMNode;</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMNode;</font>
|
||||||
|
<a name="line34"> 34: </a><font color="#228B22">import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;</font>
|
||||||
|
<a name="line35"> 35: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line36"> 36: </a><font color="#228B22">import org.eclipse.dd.examples.pda.launch.PDALaunch;</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDACommandControl;</font>
|
||||||
|
<a name="line38"> 38: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;</font>
|
||||||
|
<a name="line39"> 39: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDAStartedEvent;</font>
|
||||||
|
<a name="line40"> 40: </a><font color="#228B22">import org.eclipse.debug.core.ILaunch;</font>
|
||||||
|
<a name="line41"> 41: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;</font>
|
||||||
|
<a name="line42"> 42: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;</font>
|
||||||
|
<a name="line43"> 43: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;</font>
|
||||||
|
<a name="line44"> 44: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;</font>
|
||||||
|
<a name="line45"> 45: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;</font>
|
||||||
|
<a name="line46"> 46: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;</font>
|
||||||
|
<a name="line47"> 47: </a><font color="#228B22">import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;</font>
|
||||||
|
<a name="line48"> 48: </a><font color="#228B22">import org.eclipse.debug.ui.DebugUITools;</font>
|
||||||
|
<a name="line49"> 49: </a><font color="#228B22">import org.eclipse.debug.ui.IDebugUIConstants;</font>
|
||||||
|
<a name="line50"> 50: </a><font color="#228B22">import org.eclipse.jface.viewers.TreePath;</font>
|
||||||
|
|
||||||
|
<a name="line52"> 52: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line53"> 53: </a><font color="#B22222"> * View Model node representing a PDA program. </font>
|
||||||
|
<a name="line54"> 54: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line55"> 55: </a>@SuppressWarnings(<font color="#666666">"restriction"</font>)
|
||||||
|
<a name="line56"> 56: </a><strong><font color="#4169E1"><a name="PDAProgramVMNode"></a>public class PDAProgramVMNode extends AbstractDMVMNode </font></strong>
|
||||||
|
<a name="line57"> 57: </a> implements IElementLabelProvider
|
||||||
|
<a name="line58"> 58: </a>{
|
||||||
|
<a name="line59"> 59: </a> <font color="#B22222">// View model context representing a terminated PDA program.</font>
|
||||||
|
<a name="line60"> 60: </a> <font color="#B22222">// It's purpose is to show a terminated program in the debug view</font>
|
||||||
|
<a name="line61"> 61: </a> <font color="#B22222">// even after the DSF session is terminated.</font>
|
||||||
|
<a name="line62"> 62: </a> <font color="#B22222">// </font>
|
||||||
|
<a name="line63"> 63: </a> <font color="#B22222">// Note: this context does not implement the IDMVMContext</font>
|
||||||
|
<a name="line64"> 64: </a> <font color="#B22222">// interfaces, as it does not use an IDMContext as its root.</font>
|
||||||
|
<a name="line65"> 65: </a> <font color="#B22222">// </font>
|
||||||
|
<a name="line66"> 66: </a> <font color="#B22222">// To implement comparison methods, this contexts uses the</font>
|
||||||
|
<a name="line67"> 67: </a> <font color="#B22222">// VM node object, such that two terminated program contexts</font>
|
||||||
|
<a name="line68"> 68: </a> <font color="#B22222">// from the same instance of VM node will be equal. </font>
|
||||||
|
<a name="line69"> 69: </a> private static class TerminatedProgramVMContext extends AbstractVMContext {
|
||||||
|
<a name="line70"> 70: </a> TerminatedProgramVMContext(IVMAdapter adapter, IVMNode node) {
|
||||||
|
<a name="line71"> 71: </a> super(adapter, node);
|
||||||
|
<a name="line72"> 72: </a> }
|
||||||
|
<a name="line73"> 73: </a>
|
||||||
|
<a name="line74"> 74: </a> @Override
|
||||||
|
<a name="line75"> 75: </a><strong><font color="#4169E1"> public boolean equals(Object obj)</font></strong> {
|
||||||
|
<a name="line76"> 76: </a> <font color="#4169E1">if</font> (obj instanceof TerminatedProgramVMContext) {
|
||||||
|
<a name="line77"> 77: </a> TerminatedProgramVMContext context = (TerminatedProgramVMContext)obj;
|
||||||
|
<a name="line78"> 78: </a> <font color="#4169E1">return</font> getVMNode().equals(context.getVMNode());
|
||||||
|
<a name="line79"> 79: </a> }
|
||||||
|
<a name="line80"> 80: </a> <font color="#4169E1">return</font> false;
|
||||||
|
<a name="line81"> 81: </a> }
|
||||||
|
<a name="line82"> 82: </a>
|
||||||
|
<a name="line83"> 83: </a> @Override
|
||||||
|
<a name="line84"> 84: </a><strong><font color="#4169E1"> public int hashCode()</font></strong> {
|
||||||
|
<a name="line85"> 85: </a> <font color="#4169E1">return</font> getVMNode().hashCode();
|
||||||
|
<a name="line86"> 86: </a> }
|
||||||
|
<a name="line87"> 87: </a> }
|
||||||
|
<a name="line88"> 88: </a>
|
||||||
|
<a name="line89"> 89: </a><strong><font color="#4169E1"> public PDAProgramVMNode(AbstractDMVMProvider provider, DsfSession session)</font></strong> {
|
||||||
|
<a name="line90"> 90: </a> super(provider, session, IExecutionDMContext.class);
|
||||||
|
<a name="line91"> 91: </a> }
|
||||||
|
|
||||||
|
<a name="line93"> 93: </a> @Override
|
||||||
|
<a name="line94"> 94: </a><strong><font color="#4169E1"> public void update(IHasChildrenUpdate[] updates)</font></strong> {
|
||||||
|
<a name="line95"> 95: </a> <font color="#4169E1">for</font> (IHasChildrenUpdate update : updates) {
|
||||||
|
<a name="line96"> 96: </a> <font color="#B22222">// Check if the launch is initialized. PDA program element should </font>
|
||||||
|
<a name="line97"> 97: </a> <font color="#B22222">// be shown only if the launch has completed initializing.</font>
|
||||||
|
<a name="line98"> 98: </a> PDALaunch launch = findLaunchInPath(update.getElementPath());
|
||||||
|
<a name="line99"> 99: </a> update.setHasChilren(launch != null && launch.isInitialized());
|
||||||
|
<a name="line100">100: </a> update.done();
|
||||||
|
<a name="line101">101: </a> }
|
||||||
|
<a name="line102">102: </a> }
|
||||||
|
|
||||||
|
<a name="line104">104: </a> @Override
|
||||||
|
<a name="line105">105: </a><strong><font color="#4169E1"> public void update(IChildrenCountUpdate[] updates)</font></strong> {
|
||||||
|
<a name="line106">106: </a> <font color="#4169E1">for</font> (IChildrenCountUpdate update : updates) {
|
||||||
|
<a name="line107">107: </a> <font color="#B22222">// Check if the launch is initialized. PDA program element should </font>
|
||||||
|
<a name="line108">108: </a> <font color="#B22222">// be shown only if the launch has completed initializing.</font>
|
||||||
|
<a name="line109">109: </a> PDALaunch launch = findLaunchInPath(update.getElementPath());
|
||||||
|
<a name="line110">110: </a> <font color="#4169E1">if</font> (launch != null && launch.isInitialized()) {
|
||||||
|
<a name="line111">111: </a> update.setChildCount(1);
|
||||||
|
<a name="line112">112: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line113">113: </a> update.setChildCount(0);
|
||||||
|
<a name="line114">114: </a> }
|
||||||
|
<a name="line115">115: </a> update.done();
|
||||||
|
<a name="line116">116: </a> }
|
||||||
|
<a name="line117">117: </a> }
|
||||||
|
|
||||||
|
<a name="line119">119: </a> @Override
|
||||||
|
<a name="line120">120: </a><strong><font color="#4169E1"> public void update(IChildrenUpdate[] updates)</font></strong> {
|
||||||
|
<a name="line121">121: </a> <font color="#4169E1">for</font> (IChildrenUpdate update : updates) {
|
||||||
|
<a name="line122">122: </a> PDALaunch launch = findLaunchInPath(update.getElementPath());
|
||||||
|
<a name="line123">123: </a> <font color="#4169E1">if</font> (launch != null && launch.isInitialized() && launch.isShutDown()) {
|
||||||
|
<a name="line124">124: </a> <font color="#B22222">// If the debug session has been shut down, add a dummy </font>
|
||||||
|
<a name="line125">125: </a> <font color="#B22222">// VM context representing the PDA thread.</font>
|
||||||
|
<a name="line126">126: </a> update.setChild(new TerminatedProgramVMContext(getVMProvider().getVMAdapter(), this), 0);
|
||||||
|
<a name="line127">127: </a> update.done();
|
||||||
|
<a name="line128">128: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line129">129: </a> super.update(new IChildrenUpdate[] { update });
|
||||||
|
<a name="line130">130: </a> }
|
||||||
|
<a name="line131">131: </a> }
|
||||||
|
<a name="line132">132: </a> }
|
||||||
|
<a name="line133">133: </a>
|
||||||
|
<a name="line134">134: </a> @Override
|
||||||
|
<a name="line135">135: </a><strong><font color="#4169E1"> protected void updateElementsInSessionThread(final IChildrenUpdate update)</font></strong> {
|
||||||
|
<a name="line136">136: </a> <font color="#B22222">// Get the instance of the service. Note that there is no race condition</font>
|
||||||
|
<a name="line137">137: </a> <font color="#B22222">// in getting the service since this method is called only in the </font>
|
||||||
|
<a name="line138">138: </a> <font color="#B22222">// service executor thread.</font>
|
||||||
|
<a name="line139">139: </a> final PDACommandControl commandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
|
||||||
|
<a name="line141">141: </a> <font color="#B22222">// Check if the service is available. If it is not, no elements are </font>
|
||||||
|
<a name="line142">142: </a> <font color="#B22222">// updated.</font>
|
||||||
|
<a name="line143">143: </a> <font color="#4169E1">if</font> (commandControl == null) {
|
||||||
|
<a name="line144">144: </a> handleFailedUpdate(update);
|
||||||
|
<a name="line145">145: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line146">146: </a> }
|
||||||
|
<a name="line147">147: </a>
|
||||||
|
<a name="line148">148: </a> update.setChild(createVMContext(commandControl.getProgramDMContext()), 0);
|
||||||
|
<a name="line149">149: </a> update.done();
|
||||||
|
<a name="line150">150: </a> }
|
||||||
|
|
||||||
|
<a name="line152">152: </a><strong><font color="#4169E1"> public void update(final ILabelUpdate[] updates)</font></strong> {
|
||||||
|
<a name="line153">153: </a> <font color="#4169E1">for</font> (final ILabelUpdate update : updates) {
|
||||||
|
<a name="line154">154: </a> <font color="#4169E1">if</font> (update.getElement() instanceof TerminatedProgramVMContext) {
|
||||||
|
<a name="line155">155: </a> <font color="#B22222">// If the element is a terminated program, update the label </font>
|
||||||
|
<a name="line156">156: </a> <font color="#B22222">// in the View Model thread.</font>
|
||||||
|
<a name="line157">157: </a> updateTerminatedThreadLabel(update);
|
||||||
|
<a name="line158">158: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line159">159: </a> <font color="#B22222">// If the element is the PDA Program context, try to switch</font>
|
||||||
|
<a name="line160">160: </a> <font color="#B22222">// to the DSF session thread before updating the label.</font>
|
||||||
|
<a name="line161">161: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line162">162: </a> getSession().getExecutor().execute(new DsfRunnable() {
|
||||||
|
<a name="line163">163: </a><strong><font color="#4169E1"> public void run()</font></strong> {
|
||||||
|
<a name="line164">164: </a> updateProgramLabelInSessionThread(update);
|
||||||
|
<a name="line165">165: </a> }});
|
||||||
|
<a name="line166">166: </a> } <font color="#4169E1">catch</font> (RejectedExecutionException e) {
|
||||||
|
<a name="line167">167: </a> <font color="#B22222">// Acceptable race condition: DSF session terminated.</font>
|
||||||
|
<a name="line168">168: </a> handleFailedUpdate(update);
|
||||||
|
<a name="line169">169: </a> }
|
||||||
|
<a name="line170">170: </a> }
|
||||||
|
<a name="line171">171: </a> }
|
||||||
|
<a name="line172">172: </a> }
|
||||||
|
<a name="line173">173: </a>
|
||||||
|
<a name="line174">174: </a> @ConfinedToDsfExecutor(<font color="#666666">"getSession().getExecutor()"</font>)
|
||||||
|
<a name="line175">175: </a><strong><font color="#4169E1"> private void updateProgramLabelInSessionThread(final ILabelUpdate update)</font></strong> {
|
||||||
|
<a name="line176">176: </a> <font color="#B22222">// Get a reference to the run control service.</font>
|
||||||
|
<a name="line177">177: </a> final IRunControl runControl = getServicesTracker().getService(IRunControl.class);
|
||||||
|
<a name="line178">178: </a> <font color="#4169E1">if</font> (runControl == null) {
|
||||||
|
<a name="line179">179: </a> handleFailedUpdate(update);
|
||||||
|
<a name="line180">180: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line181">181: </a> }
|
||||||
|
<a name="line182">182: </a>
|
||||||
|
<a name="line183">183: </a> <font color="#B22222">// Find the PDA program context.</font>
|
||||||
|
<a name="line184">184: </a> final PDAProgramDMContext programCtx =
|
||||||
|
<a name="line185">185: </a> findDmcInPath(update.getViewerInput(), update.getElementPath(), PDAProgramDMContext.class);
|
||||||
|
|
||||||
|
<a name="line187">187: </a> <font color="#B22222">// Call service to get current program state</font>
|
||||||
|
<a name="line188">188: </a> final boolean isSuspended = runControl.isSuspended(programCtx);
|
||||||
|
|
||||||
|
<a name="line190">190: </a> <font color="#B22222">// Set the program icon based on the running state of the program.</font>
|
||||||
|
<a name="line191">191: </a> String imageKey = null;
|
||||||
|
<a name="line192">192: </a> <font color="#4169E1">if</font> (isSuspended) {
|
||||||
|
<a name="line193">193: </a> imageKey = IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
|
||||||
|
<a name="line194">194: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line195">195: </a> imageKey = IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
|
||||||
|
<a name="line196">196: </a> }
|
||||||
|
<a name="line197">197: </a> update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
|
||||||
|
|
||||||
|
<a name="line199">199: </a> <font color="#B22222">// Retrieve the last state chagne reason </font>
|
||||||
|
<a name="line200">200: </a> runControl.getExecutionData(
|
||||||
|
<a name="line201">201: </a> programCtx,
|
||||||
|
<a name="line202">202: </a> new DataRequestMonitor<IExecutionDMData>(ImmediateExecutor.getInstance(), null)
|
||||||
|
<a name="line203">203: </a> {
|
||||||
|
<a name="line204">204: </a> @Override
|
||||||
|
<a name="line205">205: </a><strong><font color="#4169E1"> public void handleCompleted()</font></strong>{
|
||||||
|
<a name="line206">206: </a> <font color="#B22222">// If the request failed, fail the udpate. </font>
|
||||||
|
<a name="line207">207: </a> <font color="#4169E1">if</font> (!getStatus().isOK()) {
|
||||||
|
<a name="line208">208: </a> handleFailedUpdate(update);
|
||||||
|
<a name="line209">209: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line210">210: </a> }
|
||||||
|
<a name="line211">211: </a>
|
||||||
|
<a name="line212">212: </a> <font color="#B22222">// Compose the thread name string.</font>
|
||||||
|
<a name="line213">213: </a> final StringBuilder builder = new StringBuilder();
|
||||||
|
<a name="line214">214: </a>
|
||||||
|
<a name="line215">215: </a> builder.append(<font color="#666666">"PDA ["</font>);
|
||||||
|
<a name="line216">216: </a> builder.append(programCtx.getProgram());
|
||||||
|
<a name="line217">217: </a> builder.append(<font color="#666666">"]"</font>);
|
||||||
|
<a name="line218">218: </a>
|
||||||
|
<a name="line219">219: </a> <font color="#4169E1">if</font>(isSuspended) {
|
||||||
|
<a name="line220">220: </a> builder.append(<font color="#666666">" (Suspended"</font>);
|
||||||
|
<a name="line221">221: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line222">222: </a> builder.append(<font color="#666666">" (Running"</font>);
|
||||||
|
<a name="line223">223: </a> }
|
||||||
|
<a name="line224">224: </a> <font color="#B22222">// Reason will be null before ContainerSuspendEvent is fired</font>
|
||||||
|
<a name="line225">225: </a> <font color="#4169E1">if</font>(getData().getStateChangeReason() != null) {
|
||||||
|
<a name="line226">226: </a> builder.append(<font color="#666666">" : "</font>);
|
||||||
|
<a name="line227">227: </a> builder.append(getData().getStateChangeReason());
|
||||||
|
<a name="line228">228: </a> }
|
||||||
|
<a name="line229">229: </a> builder.append(<font color="#666666">")"</font>);
|
||||||
|
<a name="line230">230: </a> update.setLabel(builder.toString(), 0);
|
||||||
|
<a name="line231">231: </a> update.done();
|
||||||
|
<a name="line232">232: </a> }
|
||||||
|
<a name="line233">233: </a> });
|
||||||
|
<a name="line234">234: </a> }
|
||||||
|
<a name="line235">235: </a>
|
||||||
|
<a name="line236">236: </a><strong><font color="#4169E1"> private void updateTerminatedThreadLabel(ILabelUpdate update)</font></strong> {
|
||||||
|
<a name="line237">237: </a> update.setLabel(<font color="#666666">"<terminated> PDA ["</font> + getProgramName(update) + <font color="#666666">"]"</font>, 0);
|
||||||
|
<a name="line238">238: </a> update.setImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED), 0);
|
||||||
|
<a name="line239">239: </a> update.done();
|
||||||
|
<a name="line240">240: </a> }
|
||||||
|
|
||||||
|
<a name="line242">242: </a><strong><font color="#4169E1"> private String getProgramName(IViewerUpdate update)</font></strong> {
|
||||||
|
<a name="line243">243: </a> <font color="#B22222">// Retrieve the program name from the launch object in the update path.</font>
|
||||||
|
<a name="line244">244: </a> String program = <font color="#666666">"unknown program"</font>;
|
||||||
|
<a name="line245">245: </a> ILaunch launch = findLaunchInPath(update.getElementPath());
|
||||||
|
<a name="line246">246: </a> <font color="#4169E1">if</font> (launch != null) {
|
||||||
|
<a name="line247">247: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line248">248: </a> program = launch.getLaunchConfiguration().getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, program);
|
||||||
|
<a name="line249">249: </a> } <font color="#4169E1">catch</font> (CoreException e) {
|
||||||
|
<a name="line250">250: </a> <font color="#B22222">// Ignore, label will revert to default.</font>
|
||||||
|
<a name="line251">251: </a> }
|
||||||
|
<a name="line252">252: </a> }
|
||||||
|
<a name="line253">253: </a> <font color="#4169E1">return</font> program;
|
||||||
|
<a name="line254">254: </a> }
|
||||||
|
<a name="line255">255: </a>
|
||||||
|
<a name="line256">256: </a><strong><font color="#4169E1"> private PDALaunch findLaunchInPath(TreePath path)</font></strong> {
|
||||||
|
<a name="line257">257: </a> <font color="#4169E1">for</font> (int i = 0; i < path.getSegmentCount(); i++) {
|
||||||
|
<a name="line258">258: </a> <font color="#4169E1">if</font> (path.getSegment(i) instanceof PDALaunch) {
|
||||||
|
<a name="line259">259: </a> <font color="#4169E1">return</font> (PDALaunch)path.getSegment(i);
|
||||||
|
<a name="line260">260: </a> }
|
||||||
|
<a name="line261">261: </a> }
|
||||||
|
<a name="line262">262: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line263">263: </a> }
|
||||||
|
|
||||||
|
<a name="line265">265: </a><strong><font color="#4169E1"> public int getDeltaFlags(Object e)</font></strong> {
|
||||||
|
<a name="line266">266: </a> <font color="#4169E1">if</font>(e instanceof IResumedDMEvent || e instanceof ISuspendedDMEvent) {
|
||||||
|
<a name="line267">267: </a> <font color="#4169E1">return</font> IModelDelta.STATE;
|
||||||
|
<a name="line268">268: </a> }
|
||||||
|
<a name="line269">269: </a> <font color="#4169E1">if</font> (e instanceof PDAStartedEvent) {
|
||||||
|
<a name="line270">270: </a> <font color="#4169E1">return</font> IModelDelta.EXPAND | IModelDelta.SELECT;
|
||||||
|
<a name="line271">271: </a> }
|
||||||
|
<a name="line272">272: </a> <font color="#4169E1">return</font> IModelDelta.NO_CHANGE;
|
||||||
|
<a name="line273">273: </a> }
|
||||||
|
|
||||||
|
<a name="line275">275: </a><strong><font color="#4169E1"> public void buildDelta(Object e, VMDelta parentDelta, int nodeOffset, RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line276">276: </a> <font color="#4169E1">if</font>(e instanceof IResumedDMEvent || e instanceof ISuspendedDMEvent) {
|
||||||
|
<a name="line277">277: </a> <font color="#B22222">// If a suspended/resumed event is received, just update the </font>
|
||||||
|
<a name="line278">278: </a> <font color="#B22222">// state of the program. StackFramesVMNode will take care of </font>
|
||||||
|
<a name="line279">279: </a> <font color="#B22222">// refreshing the stack frames.</font>
|
||||||
|
<a name="line280">280: </a> parentDelta.addNode(createVMContext(((IDMEvent<?>)e).getDMContext()), IModelDelta.STATE);
|
||||||
|
<a name="line281">281: </a> }
|
||||||
|
<a name="line282">282: </a> <font color="#4169E1">if</font> (e instanceof PDAStartedEvent) {
|
||||||
|
<a name="line283">283: </a> <font color="#B22222">// When debug session is started expand and select the program.</font>
|
||||||
|
<a name="line284">284: </a> <font color="#B22222">// If the program hits a breakpoint, the top stack frame will then</font>
|
||||||
|
<a name="line285">285: </a> <font color="#B22222">// be selected.</font>
|
||||||
|
<a name="line286">286: </a> parentDelta.addNode(createVMContext(((PDAStartedEvent)e).getDMContext()), IModelDelta.EXPAND | IModelDelta.SELECT);
|
||||||
|
<a name="line287">287: </a> }
|
||||||
|
<a name="line288">288: </a> rm.done();
|
||||||
|
<a name="line289">289: </a> }
|
||||||
|
<a name="line290">290: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -43,17 +43,19 @@ import org.eclipse.debug.core.model.ITerminate;
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public class PDALaunch extends Launch
|
public class PDALaunch extends Launch
|
||||||
implements ITerminate
|
implements ITerminate
|
||||||
{
|
{
|
||||||
// DSF executor and session. Both are created and shutdown by the launch.
|
// DSF executor and session. Both are created and shutdown by the launch.
|
||||||
private final DefaultDsfExecutor fExecutor;
|
private final DefaultDsfExecutor fExecutor;
|
||||||
private final DsfSession fSession;
|
private final DsfSession fSession;
|
||||||
|
|
||||||
// Objects used to track the status of the DSF session.
|
// Objects used to track the status of the DSF session.
|
||||||
private Sequence fInitializationSequence = null;
|
|
||||||
private boolean fInitialized = false;
|
private boolean fInitialized = false;
|
||||||
private boolean fShutDown = false;
|
private boolean fShutDown = false;
|
||||||
|
|
||||||
|
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||||
|
private Sequence fInitializationSequence = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch constructor creates the launch for given parameters. The
|
* Launch constructor creates the launch for given parameters. The
|
||||||
* constructor also creates a DSF session and an executor, so that
|
* constructor also creates a DSF session and an executor, so that
|
||||||
|
@ -90,7 +92,7 @@ public class PDALaunch extends Launch
|
||||||
{
|
{
|
||||||
// Double-check that we're being called in the correct thread.
|
// Double-check that we're being called in the correct thread.
|
||||||
assert fExecutor.isInExecutorThread();
|
assert fExecutor.isInExecutorThread();
|
||||||
|
|
||||||
// Check if shutdownServices() was called already, which would be
|
// Check if shutdownServices() was called already, which would be
|
||||||
// highly unusual, but if so we don't need to do anything except set
|
// highly unusual, but if so we don't need to do anything except set
|
||||||
// the initialized flag.
|
// the initialized flag.
|
||||||
|
@ -100,51 +102,47 @@ public class PDALaunch extends Launch
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the launch as listener for services events.
|
// Register the launch as listener for services events.
|
||||||
fSession.addServiceEventListener(PDALaunch.this, null);
|
fSession.addServiceEventListener(PDALaunch.this, null);
|
||||||
|
|
||||||
// Initialize the fInitializationSequence attribute in a synchronized
|
|
||||||
// block, because it may be accessed in another thread by shutdown().
|
|
||||||
// The initialization sequence is stored in a field to allow it to be
|
// The initialization sequence is stored in a field to allow it to be
|
||||||
// canceled if shutdownServices() is called before the sequence
|
// canceled if shutdownServices() is called before the sequence
|
||||||
// completes.
|
// completes.
|
||||||
synchronized(this) {
|
fInitializationSequence = new PDAServicesInitSequence(
|
||||||
fInitializationSequence = new PDAServicesInitSequence(
|
getSession(), program, requestPort, eventPort,
|
||||||
getSession(), program, requestPort, eventPort,
|
new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
|
||||||
new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
|
@Override
|
||||||
@Override
|
protected void handleCompleted() {
|
||||||
protected void handleCompleted() {
|
// Set the initialized flag and check whether the
|
||||||
// Set the initialized flag and check whether the
|
// shutdown flag is set. Access the flags in a
|
||||||
// shutdown flag is set. Access the flags in a
|
// synchronized section as these flags can be accessed
|
||||||
// synchronized section as these flags can be accessed
|
// on any thread.
|
||||||
// on any thread.
|
boolean doShutdown = false;
|
||||||
boolean doShutdown = false;
|
synchronized (this) {
|
||||||
synchronized (this) {
|
fInitialized = true;
|
||||||
fInitialized = true;
|
fInitializationSequence = null;
|
||||||
fInitializationSequence = null;
|
if (fShutDown) {
|
||||||
if (fShutDown) {
|
doShutdown = true;
|
||||||
doShutdown = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doShutdown) {
|
|
||||||
// If shutdownServices() was already called, start the
|
|
||||||
// shutdown sequence now.
|
|
||||||
doShutdown(rm);
|
|
||||||
} else {
|
|
||||||
// If there was an error in the startup sequence,
|
|
||||||
// report the error to the client.
|
|
||||||
if (getStatus().getSeverity() == IStatus.ERROR) {
|
|
||||||
rm.setStatus(getStatus());
|
|
||||||
}
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
fireChanged();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
if (doShutdown) {
|
||||||
|
// If shutdownServices() was already called, start the
|
||||||
|
// shutdown sequence now.
|
||||||
|
doShutdown(rm);
|
||||||
|
} else {
|
||||||
|
// If there was an error in the startup sequence,
|
||||||
|
// report the error to the client.
|
||||||
|
if (getStatus().getSeverity() == IStatus.ERROR) {
|
||||||
|
rm.setStatus(getStatus());
|
||||||
|
}
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
fireChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Finally, execute the sequence.
|
// Finally, execute the sequence.
|
||||||
getSession().getExecutor().execute(fInitializationSequence);
|
getSession().getExecutor().execute(fInitializationSequence);
|
||||||
}
|
}
|
||||||
|
@ -163,7 +161,7 @@ public class PDALaunch extends Launch
|
||||||
public synchronized boolean isInitialized() {
|
public synchronized boolean isInitialized() {
|
||||||
return fInitialized;
|
return fInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the DSF services have been set to shut down.
|
* Returns whether the DSF services have been set to shut down.
|
||||||
* @return
|
* @return
|
||||||
|
@ -171,7 +169,7 @@ public class PDALaunch extends Launch
|
||||||
public synchronized boolean isShutDown() {
|
public synchronized boolean isShutDown() {
|
||||||
return fShutDown;
|
return fShutDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTerminate() {
|
public boolean canTerminate() {
|
||||||
return super.canTerminate() && isInitialized() && !isShutDown();
|
return super.canTerminate() && isInitialized() && !isShutDown();
|
||||||
|
@ -223,7 +221,7 @@ public class PDALaunch extends Launch
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||||
private void doShutdown(final RequestMonitor rm) {
|
private void doShutdown(final RequestMonitor rm) {
|
||||||
fExecutor.execute( new PDAServicesShutdownSequence(
|
fExecutor.execute( new PDAServicesShutdownSequence(
|
||||||
|
@ -242,13 +240,13 @@ public class PDALaunch extends Launch
|
||||||
// session-ended event, finish step only after the dispatch.
|
// session-ended event, finish step only after the dispatch.
|
||||||
fExecutor.shutdown();
|
fExecutor.shutdown();
|
||||||
fireTerminate();
|
fireTerminate();
|
||||||
|
|
||||||
rm.setStatus(getStatus());
|
rm.setStatus(getStatus());
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
}) );
|
}) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Object getAdapter(Class adapter) {
|
public Object getAdapter(Class adapter) {
|
||||||
|
|
|
@ -0,0 +1,271 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDALaunch.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-07T23:52:00+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2008 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.launch;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import org.eclipse.core.runtime.IStatus;</font>
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import org.eclipse.core.runtime.MultiStatus;</font>
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import org.eclipse.core.runtime.Platform;</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DefaultDsfExecutor;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ImmediateExecutor;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.RequestMonitor;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.Sequence;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ThreadSafe;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfServiceEventHandler;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDATerminatedEvent;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.debug.core.DebugException;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.debug.core.ILaunchConfiguration;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.debug.core.Launch;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.debug.core.model.ISourceLocator;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.debug.core.model.ITerminate;</font>
|
||||||
|
|
||||||
|
<a name="line32"> 32: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#B22222"> * The PDA launch object. In general, a DSF-based debugger has to override </font>
|
||||||
|
<a name="line34"> 34: </a><font color="#B22222"> * the base launch class in order to supply its own content providers for the </font>
|
||||||
|
<a name="line35"> 35: </a><font color="#B22222"> * debug view. Additionally, the PDA launch is used to monitor the state of the</font>
|
||||||
|
<a name="line36"> 36: </a><font color="#B22222"> * PDA debugger and to shutdown the DSF services and session belonging to the </font>
|
||||||
|
<a name="line37"> 37: </a><font color="#B22222"> * launch.</font>
|
||||||
|
<a name="line38"> 38: </a><font color="#B22222"> * <p></font>
|
||||||
|
<a name="line39"> 39: </a><font color="#B22222"> * The PDA launch class mostly contains methods and fields that can be accessed</font>
|
||||||
|
<a name="line40"> 40: </a><font color="#B22222"> * on any thread. However, some fields and methods used for managing the DSF</font>
|
||||||
|
<a name="line41"> 41: </a><font color="#B22222"> * session need to be synchronized using the DSF executor.</font>
|
||||||
|
<a name="line42"> 42: </a><font color="#B22222"> * </p></font>
|
||||||
|
<a name="line43"> 43: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line44"> 44: </a>@ThreadSafe
|
||||||
|
<a name="line45"> 45: </a><strong><font color="#4169E1"><a name="PDALaunch"></a>public class PDALaunch extends Launch</font></strong>
|
||||||
|
<a name="line46"> 46: </a>implements ITerminate
|
||||||
|
<a name="line47"> 47: </a>{
|
||||||
|
<a name="line48"> 48: </a> <font color="#B22222">// DSF executor and session. Both are created and shutdown by the launch. </font>
|
||||||
|
<a name="line49"> 49: </a> private final DefaultDsfExecutor fExecutor;
|
||||||
|
<a name="line50"> 50: </a> private final DsfSession fSession;
|
||||||
|
|
||||||
|
<a name="line52"> 52: </a> <font color="#B22222">// Objects used to track the status of the DSF session.</font>
|
||||||
|
<a name="line53"> 53: </a> private boolean fInitialized = false;
|
||||||
|
<a name="line54"> 54: </a> private boolean fShutDown = false;
|
||||||
|
<a name="line55"> 55: </a>
|
||||||
|
<a name="line56"> 56: </a> @ConfinedToDsfExecutor(<font color="#666666">"getSession().getExecutor()"</font>)
|
||||||
|
<a name="line57"> 57: </a> private Sequence fInitializationSequence = null;
|
||||||
|
|
||||||
|
<a name="line59"> 59: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line60"> 60: </a><font color="#B22222"> * Launch constructor creates the launch for given parameters. The</font>
|
||||||
|
<a name="line61"> 61: </a><font color="#B22222"> * constructor also creates a DSF session and an executor, so that </font>
|
||||||
|
<a name="line62"> 62: </a><font color="#B22222"> * {@link #getSession()} returns a valid value, however no services </font>
|
||||||
|
<a name="line63"> 63: </a><font color="#B22222"> * are initialized yet. </font>
|
||||||
|
<a name="line64"> 64: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line65"> 65: </a><font color="#B22222"> * @see Launch</font>
|
||||||
|
<a name="line66"> 66: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line67"> 67: </a><strong><font color="#4169E1"> public PDALaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator)</font></strong> {
|
||||||
|
<a name="line68"> 68: </a> super(launchConfiguration, mode, locator);
|
||||||
|
|
||||||
|
<a name="line70"> 70: </a> <font color="#B22222">// Create the dispatch queue to be used by debugger control and services </font>
|
||||||
|
<a name="line71"> 71: </a> <font color="#B22222">// that belong to this launch</font>
|
||||||
|
<a name="line72"> 72: </a> final DefaultDsfExecutor dsfExecutor = new DefaultDsfExecutor(PDAPlugin.ID_PDA_DEBUG_MODEL);
|
||||||
|
<a name="line73"> 73: </a> dsfExecutor.prestartCoreThread();
|
||||||
|
<a name="line74"> 74: </a> fExecutor = dsfExecutor;
|
||||||
|
<a name="line75"> 75: </a> fSession = DsfSession.startSession(fExecutor, PDAPlugin.ID_PDA_DEBUG_MODEL);
|
||||||
|
<a name="line76"> 76: </a> }
|
||||||
|
|
||||||
|
<a name="line78"> 78: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line79"> 79: </a><font color="#B22222"> * Returns the DSF services session that belongs to this launch. This </font>
|
||||||
|
<a name="line80"> 80: </a><font color="#B22222"> * method will always return a DsfSession object, however if the debugger </font>
|
||||||
|
<a name="line81"> 81: </a><font color="#B22222"> * is shut down, the session will no longer active.</font>
|
||||||
|
<a name="line82"> 82: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line83"> 83: </a><strong><font color="#4169E1"> public DsfSession getSession()</font></strong> { <font color="#4169E1">return</font> fSession; }
|
||||||
|
|
||||||
|
<a name="line85"> 85: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line86"> 86: </a><font color="#B22222"> * Initializes the DSF services using the specified parameters. This </font>
|
||||||
|
<a name="line87"> 87: </a><font color="#B22222"> * method has to be called on the executor thread in order to avoid </font>
|
||||||
|
<a name="line88"> 88: </a><font color="#B22222"> * synchronization issues. </font>
|
||||||
|
<a name="line89"> 89: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line90"> 90: </a> @ConfinedToDsfExecutor(<font color="#666666">"getSession().getExecutor()"</font>)
|
||||||
|
<a name="line91"> 91: </a><strong><font color="#4169E1"> public void initializeServices(String program, int requestPort, int eventPort, final RequestMonitor rm)</font></strong>
|
||||||
|
<a name="line92"> 92: </a> {
|
||||||
|
<a name="line93"> 93: </a> <font color="#B22222">// Double-check that we're being called in the correct thread.</font>
|
||||||
|
<a name="line94"> 94: </a> assert fExecutor.isInExecutorThread();
|
||||||
|
|
||||||
|
<a name="line96"> 96: </a> <font color="#B22222">// Check if shutdownServices() was called already, which would be </font>
|
||||||
|
<a name="line97"> 97: </a> <font color="#B22222">// highly unusual, but if so we don't need to do anything except set </font>
|
||||||
|
<a name="line98"> 98: </a> <font color="#B22222">// the initialized flag.</font>
|
||||||
|
<a name="line99"> 99: </a> synchronized(this) {
|
||||||
|
<a name="line100">100: </a> <font color="#4169E1">if</font> (fShutDown) {
|
||||||
|
<a name="line101">101: </a> fInitialized = true;
|
||||||
|
<a name="line102">102: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line103">103: </a> }
|
||||||
|
<a name="line104">104: </a> }
|
||||||
|
|
||||||
|
<a name="line106">106: </a> <font color="#B22222">// Register the launch as listener for services events.</font>
|
||||||
|
<a name="line107">107: </a> fSession.addServiceEventListener(PDALaunch.this, null);
|
||||||
|
|
||||||
|
<a name="line109">109: </a> <font color="#B22222">// The initialization sequence is stored in a field to allow it to be </font>
|
||||||
|
<a name="line110">110: </a> <font color="#B22222">// canceled if shutdownServices() is called before the sequence </font>
|
||||||
|
<a name="line111">111: </a> <font color="#B22222">// completes.</font>
|
||||||
|
<a name="line112">112: </a> fInitializationSequence = new PDAServicesInitSequence(
|
||||||
|
<a name="line113">113: </a> getSession(), program, requestPort, eventPort,
|
||||||
|
<a name="line114">114: </a> new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
|
||||||
|
<a name="line115">115: </a> @Override
|
||||||
|
<a name="line116">116: </a><strong><font color="#4169E1"> protected void handleCompleted()</font></strong> {
|
||||||
|
<a name="line117">117: </a> <font color="#B22222">// Set the initialized flag and check whether the </font>
|
||||||
|
<a name="line118">118: </a> <font color="#B22222">// shutdown flag is set. Access the flags in a </font>
|
||||||
|
<a name="line119">119: </a> <font color="#B22222">// synchronized section as these flags can be accessed</font>
|
||||||
|
<a name="line120">120: </a> <font color="#B22222">// on any thread.</font>
|
||||||
|
<a name="line121">121: </a> boolean doShutdown = false;
|
||||||
|
<a name="line122">122: </a> synchronized (this) {
|
||||||
|
<a name="line123">123: </a> fInitialized = true;
|
||||||
|
<a name="line124">124: </a> fInitializationSequence = null;
|
||||||
|
<a name="line125">125: </a> <font color="#4169E1">if</font> (fShutDown) {
|
||||||
|
<a name="line126">126: </a> doShutdown = true;
|
||||||
|
<a name="line127">127: </a> }
|
||||||
|
<a name="line128">128: </a> }
|
||||||
|
|
||||||
|
<a name="line130">130: </a> <font color="#4169E1">if</font> (doShutdown) {
|
||||||
|
<a name="line131">131: </a> <font color="#B22222">// If shutdownServices() was already called, start the </font>
|
||||||
|
<a name="line132">132: </a> <font color="#B22222">// shutdown sequence now.</font>
|
||||||
|
<a name="line133">133: </a> doShutdown(rm);
|
||||||
|
<a name="line134">134: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line135">135: </a> <font color="#B22222">// If there was an error in the startup sequence, </font>
|
||||||
|
<a name="line136">136: </a> <font color="#B22222">// report the error to the client.</font>
|
||||||
|
<a name="line137">137: </a> <font color="#4169E1">if</font> (getStatus().getSeverity() == IStatus.ERROR) {
|
||||||
|
<a name="line138">138: </a> rm.setStatus(getStatus());
|
||||||
|
<a name="line139">139: </a> }
|
||||||
|
<a name="line140">140: </a> rm.done();
|
||||||
|
<a name="line141">141: </a> }
|
||||||
|
<a name="line142">142: </a> fireChanged();
|
||||||
|
<a name="line143">143: </a> }
|
||||||
|
<a name="line144">144: </a> });
|
||||||
|
|
||||||
|
<a name="line146">146: </a> <font color="#B22222">// Finally, execute the sequence. </font>
|
||||||
|
<a name="line147">147: </a> getSession().getExecutor().execute(fInitializationSequence);
|
||||||
|
<a name="line148">148: </a> }
|
||||||
|
|
||||||
|
<a name="line150">150: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line151">151: </a><font color="#B22222"> * Event handler for a debugger terminated event. </font>
|
||||||
|
<a name="line152">152: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line153">153: </a> @DsfServiceEventHandler
|
||||||
|
<a name="line154">154: </a><strong><font color="#4169E1"> public void eventDispatched(PDATerminatedEvent event)</font></strong> {
|
||||||
|
<a name="line155">155: </a> shutdownServices(new RequestMonitor(ImmediateExecutor.getInstance(), null));
|
||||||
|
<a name="line156">156: </a> }
|
||||||
|
|
||||||
|
<a name="line158">158: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line159">159: </a><font color="#B22222"> * Returns whether the DSF service initialization sequence has completed yet.</font>
|
||||||
|
<a name="line160">160: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line161">161: </a><strong><font color="#4169E1"> public synchronized boolean isInitialized()</font></strong> {
|
||||||
|
<a name="line162">162: </a> <font color="#4169E1">return</font> fInitialized;
|
||||||
|
<a name="line163">163: </a> }
|
||||||
|
|
||||||
|
<a name="line165">165: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line166">166: </a><font color="#B22222"> * Returns whether the DSF services have been set to shut down.</font>
|
||||||
|
<a name="line167">167: </a><font color="#B22222"> * @return</font>
|
||||||
|
<a name="line168">168: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line169">169: </a><strong><font color="#4169E1"> public synchronized boolean isShutDown()</font></strong> {
|
||||||
|
<a name="line170">170: </a> <font color="#4169E1">return</font> fShutDown;
|
||||||
|
<a name="line171">171: </a> }
|
||||||
|
|
||||||
|
<a name="line173">173: </a> @Override
|
||||||
|
<a name="line174">174: </a><strong><font color="#4169E1"> public boolean canTerminate()</font></strong> {
|
||||||
|
<a name="line175">175: </a> <font color="#4169E1">return</font> super.canTerminate() && isInitialized() && !isShutDown();
|
||||||
|
<a name="line176">176: </a> }
|
||||||
|
|
||||||
|
<a name="line178">178: </a> @Override
|
||||||
|
<a name="line179">179: </a><strong><font color="#4169E1"> public boolean isTerminated()</font></strong> {
|
||||||
|
<a name="line180">180: </a> <font color="#4169E1">return</font> super.isTerminated() || isShutDown();
|
||||||
|
<a name="line181">181: </a> }
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line184">184: </a> @Override
|
||||||
|
<a name="line185">185: </a><strong><font color="#4169E1"> public void terminate()</font></strong> <font color="#4169E1">throws</font> DebugException {
|
||||||
|
<a name="line186">186: </a> <font color="#4169E1">if</font> (isShutDown()) <font color="#4169E1">return</font>;
|
||||||
|
<a name="line187">187: </a> super.terminate();
|
||||||
|
<a name="line188">188: </a> }
|
||||||
|
|
||||||
|
<a name="line190">190: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line191">191: </a><font color="#B22222"> * Shuts down the services, the session and the executor associated with </font>
|
||||||
|
<a name="line192">192: </a><font color="#B22222"> * this launch. </font>
|
||||||
|
<a name="line193">193: </a><font color="#B22222"> * <p></font>
|
||||||
|
<a name="line194">194: </a><font color="#B22222"> * Note: The argument request monitor to this method should NOT use the</font>
|
||||||
|
<a name="line195">195: </a><font color="#B22222"> * executor that belongs to this launch. By the time the shutdown is </font>
|
||||||
|
<a name="line196">196: </a><font color="#B22222"> * complete, this executor will not be dispatching anymore and the </font>
|
||||||
|
<a name="line197">197: </a><font color="#B22222"> * request monitor will never be invoked. Instead callers should use</font>
|
||||||
|
<a name="line198">198: </a><font color="#B22222"> * the {@link ImmediateExecutor}.</font>
|
||||||
|
<a name="line199">199: </a><font color="#B22222"> * </p></font>
|
||||||
|
<a name="line200">200: </a><font color="#B22222"> * @param rm The request monitor invoked when the shutdown is complete. </font>
|
||||||
|
<a name="line201">201: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line202">202: </a> @ConfinedToDsfExecutor(<font color="#666666">"getSession().getExecutor()"</font>)
|
||||||
|
<a name="line203">203: </a><strong><font color="#4169E1"> public void shutdownServices(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line204">204: </a> <font color="#B22222">// Check initialize and shutdown flags to determine if the shutdown</font>
|
||||||
|
<a name="line205">205: </a> <font color="#B22222">// sequence can be called yet.</font>
|
||||||
|
<a name="line206">206: </a> boolean doShutdown = false;
|
||||||
|
<a name="line207">207: </a> synchronized (this) {
|
||||||
|
<a name="line208">208: </a> <font color="#4169E1">if</font> (!fInitialized && fInitializationSequence != null) {
|
||||||
|
<a name="line209">209: </a> <font color="#B22222">// Launch has not yet initialized, try to cancel the </font>
|
||||||
|
<a name="line210">210: </a> <font color="#B22222">// shutdown sequence.</font>
|
||||||
|
<a name="line211">211: </a> fInitializationSequence.cancel(false);
|
||||||
|
<a name="line212">212: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line213">213: </a> doShutdown = !fShutDown && fInitialized;
|
||||||
|
<a name="line214">214: </a> }
|
||||||
|
<a name="line215">215: </a> fShutDown = true;
|
||||||
|
<a name="line216">216: </a> }
|
||||||
|
|
||||||
|
<a name="line218">218: </a> <font color="#4169E1">if</font> (doShutdown) {
|
||||||
|
<a name="line219">219: </a> doShutdown(rm);
|
||||||
|
<a name="line220">220: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line221">221: </a> rm.done();
|
||||||
|
<a name="line222">222: </a> }
|
||||||
|
<a name="line223">223: </a> }
|
||||||
|
|
||||||
|
<a name="line225">225: </a> @ConfinedToDsfExecutor(<font color="#666666">"getSession().getExecutor()"</font>)
|
||||||
|
<a name="line226">226: </a><strong><font color="#4169E1"> private void doShutdown(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line227">227: </a> fExecutor.execute( new PDAServicesShutdownSequence(
|
||||||
|
<a name="line228">228: </a> fExecutor, fSession.getId(),
|
||||||
|
<a name="line229">229: </a> new RequestMonitor(fSession.getExecutor(), rm) {
|
||||||
|
<a name="line230">230: </a> @Override
|
||||||
|
<a name="line231">231: </a><strong><font color="#4169E1"> public void handleCompleted()</font></strong> {
|
||||||
|
<a name="line232">232: </a> fSession.removeServiceEventListener(PDALaunch.this);
|
||||||
|
<a name="line233">233: </a> <font color="#4169E1">if</font> (!getStatus().isOK()) {
|
||||||
|
<a name="line234">234: </a> PDAPlugin.getDefault().getLog().log(new MultiStatus(
|
||||||
|
<a name="line235">235: </a> PDAPlugin.PLUGIN_ID, -1, new IStatus[]{getStatus()}, <font color="#666666">"Session shutdown failed"</font>, null)); <font color="#B22222">//$NON-NLS-1$</font>
|
||||||
|
<a name="line236">236: </a> }
|
||||||
|
<a name="line237">237: </a> <font color="#B22222">// Last order of business, shutdown the dispatch queue.</font>
|
||||||
|
<a name="line238">238: </a> DsfSession.endSession(fSession);
|
||||||
|
<a name="line239">239: </a> <font color="#B22222">// endSession takes a full dispatch to distribute the </font>
|
||||||
|
<a name="line240">240: </a> <font color="#B22222">// session-ended event, finish step only after the dispatch.</font>
|
||||||
|
<a name="line241">241: </a> fExecutor.shutdown();
|
||||||
|
<a name="line242">242: </a> fireTerminate();
|
||||||
|
|
||||||
|
<a name="line244">244: </a> rm.setStatus(getStatus());
|
||||||
|
<a name="line245">245: </a> rm.done();
|
||||||
|
<a name="line246">246: </a> }
|
||||||
|
<a name="line247">247: </a> }) );
|
||||||
|
<a name="line248">248: </a> }
|
||||||
|
|
||||||
|
<a name="line250">250: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>)
|
||||||
|
<a name="line251">251: </a> @Override
|
||||||
|
<a name="line252">252: </a><strong><font color="#4169E1"> public Object getAdapter(Class adapter)</font></strong> {
|
||||||
|
<a name="line253">253: </a> <font color="#B22222">// Force adapters to be loaded. Otherwise the adapter manager may not find</font>
|
||||||
|
<a name="line254">254: </a> <font color="#B22222">// the model proxy adapter for DSF-based debug elements.</font>
|
||||||
|
<a name="line255">255: </a> Platform.getAdapterManager().loadAdapter(this, adapter.getName());
|
||||||
|
<a name="line256">256: </a> <font color="#4169E1">return</font> super.getAdapter(adapter);
|
||||||
|
<a name="line257">257: </a> }
|
||||||
|
<a name="line258">258: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,234 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDALaunchDelegate.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-02-22T04:38:30+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2005, 2008 IBM Corporation and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> *</font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * IBM Corporation - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> * Bjorn Freeman-Benson - initial API and implementation</font>
|
||||||
|
<a name="line11"> 11: </a><font color="#B22222"> * Wind River Systems - adopted to use with DSF</font>
|
||||||
|
<a name="line12"> 12: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line13"> 13: </a>package org.eclipse.dd.examples.pda.launch;
|
||||||
|
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import java.io.File;</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import java.io.IOException;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import java.net.ServerSocket;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import java.text.MessageFormat;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import java.util.ArrayList;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import java.util.List;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import java.util.concurrent.ExecutionException;</font>
|
||||||
|
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.core.resources.IFile;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.core.resources.ResourcesPlugin;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.core.runtime.CoreException;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.core.runtime.IProgressMonitor;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.core.runtime.IStatus;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.core.runtime.Path;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.core.runtime.Status;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.core.variables.IValueVariable;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.core.variables.VariablesPlugin;</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.Query;</font>
|
||||||
|
<a name="line34"> 34: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line35"> 35: </a><font color="#228B22">import org.eclipse.debug.core.DebugException;</font>
|
||||||
|
<a name="line36"> 36: </a><font color="#228B22">import org.eclipse.debug.core.DebugPlugin;</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#228B22">import org.eclipse.debug.core.ILaunch;</font>
|
||||||
|
<a name="line38"> 38: </a><font color="#228B22">import org.eclipse.debug.core.ILaunchConfiguration;</font>
|
||||||
|
<a name="line39"> 39: </a><font color="#228B22">import org.eclipse.debug.core.model.IPersistableSourceLocator;</font>
|
||||||
|
<a name="line40"> 40: </a><font color="#228B22">import org.eclipse.debug.core.model.ISourceLocator;</font>
|
||||||
|
<a name="line41"> 41: </a><font color="#228B22">import org.eclipse.debug.core.model.LaunchConfigurationDelegate;</font>
|
||||||
|
<a name="line42"> 42: </a><font color="#228B22">import org.eclipse.debug.core.sourcelookup.IPersistableSourceLocator2;</font>
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line45"> 45: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line46"> 46: </a><font color="#B22222"> * Launches PDA program on a PDA interpretter written in Perl </font>
|
||||||
|
<a name="line47"> 47: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line48"> 48: </a><strong><font color="#4169E1"><a name="PDALaunchDelegate"></a>public class PDALaunchDelegate extends LaunchConfigurationDelegate </font></strong>{
|
||||||
|
|
||||||
|
<a name="line50"> 50: </a> @Override
|
||||||
|
<a name="line51"> 51: </a><strong><font color="#4169E1"> public ILaunch getLaunch(ILaunchConfiguration configuration, String mode)</font></strong> <font color="#4169E1">throws</font> CoreException {
|
||||||
|
<a name="line52"> 52: </a> <font color="#B22222">// Need to configure the source locator before creating the launch</font>
|
||||||
|
<a name="line53"> 53: </a> <font color="#B22222">// because once the launch is created and added to launch manager, </font>
|
||||||
|
<a name="line54"> 54: </a> <font color="#B22222">// the adapters will be created for the whole session, including </font>
|
||||||
|
<a name="line55"> 55: </a> <font color="#B22222">// the source lookup adapter.</font>
|
||||||
|
<a name="line56"> 56: </a> ISourceLocator locator = getSourceLocator(configuration);
|
||||||
|
|
||||||
|
<a name="line58"> 58: </a> <font color="#4169E1">return</font> new PDALaunch(configuration, mode, locator);
|
||||||
|
<a name="line59"> 59: </a> }
|
||||||
|
|
||||||
|
<a name="line61"> 61: </a> @Override
|
||||||
|
<a name="line62"> 62: </a><strong><font color="#4169E1"> public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor)</font></strong> <font color="#4169E1">throws</font> CoreException {
|
||||||
|
<a name="line63"> 63: </a> <font color="#B22222">// PDA programs do not require building.</font>
|
||||||
|
<a name="line64"> 64: </a> <font color="#4169E1">return</font> false;
|
||||||
|
<a name="line65"> 65: </a> }
|
||||||
|
|
||||||
|
<a name="line67"> 67: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line68"> 68: </a><font color="#B22222"> * Returns a source locator created based on the attributes in the launch configuration.</font>
|
||||||
|
<a name="line69"> 69: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line70"> 70: </a><strong><font color="#4169E1"> private ISourceLocator getSourceLocator(ILaunchConfiguration configuration)</font></strong> <font color="#4169E1">throws</font> CoreException {
|
||||||
|
<a name="line71"> 71: </a> String type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
|
||||||
|
<a name="line72"> 72: </a> <font color="#4169E1">if</font> (type == null) {
|
||||||
|
<a name="line73"> 73: </a> type = configuration.getType().getSourceLocatorId();
|
||||||
|
<a name="line74"> 74: </a> }
|
||||||
|
<a name="line75"> 75: </a> <font color="#4169E1">if</font> (type != null) {
|
||||||
|
<a name="line76"> 76: </a> IPersistableSourceLocator locator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(type);
|
||||||
|
<a name="line77"> 77: </a> String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
|
||||||
|
<a name="line78"> 78: </a> <font color="#4169E1">if</font> (memento == null) {
|
||||||
|
<a name="line79"> 79: </a> locator.initializeDefaults(configuration);
|
||||||
|
<a name="line80"> 80: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line81"> 81: </a> <font color="#4169E1">if</font>(locator instanceof IPersistableSourceLocator2)
|
||||||
|
<a name="line82"> 82: </a> ((IPersistableSourceLocator2)locator).initializeFromMemento(memento, configuration);
|
||||||
|
<a name="line83"> 83: </a> <font color="#4169E1">else</font>
|
||||||
|
<a name="line84"> 84: </a> locator.initializeFromMemento(memento);
|
||||||
|
<a name="line85"> 85: </a> }
|
||||||
|
<a name="line86"> 86: </a> <font color="#4169E1">return</font> locator;
|
||||||
|
<a name="line87"> 87: </a> }
|
||||||
|
<a name="line88"> 88: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line89"> 89: </a> }
|
||||||
|
|
||||||
|
<a name="line91"> 91: </a><strong><font color="#4169E1"> public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)</font></strong> <font color="#4169E1">throws</font> CoreException {
|
||||||
|
<a name="line92"> 92: </a> String program = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
|
||||||
|
<a name="line93"> 93: </a> <font color="#4169E1">if</font> (program == null) {
|
||||||
|
<a name="line94"> 94: </a> abort(<font color="#666666">"Perl program unspecified."</font>, null);
|
||||||
|
<a name="line95"> 95: </a> }
|
||||||
|
|
||||||
|
<a name="line97"> 97: </a> int requestPort = findFreePort();
|
||||||
|
<a name="line98"> 98: </a> int eventPort = findFreePort();
|
||||||
|
<a name="line99"> 99: </a> <font color="#4169E1">if</font> (requestPort == -1 || eventPort == -1) {
|
||||||
|
<a name="line100">100: </a> abort(<font color="#666666">"Unable to find free port"</font>, null);
|
||||||
|
<a name="line101">101: </a> }
|
||||||
|
|
||||||
|
<a name="line103">103: </a> launchProcess(launch, program, requestPort, eventPort);
|
||||||
|
<a name="line104">104: </a> PDALaunch pdaLaunch = (PDALaunch)launch;
|
||||||
|
<a name="line105">105: </a> initServices(pdaLaunch, program, requestPort, eventPort);
|
||||||
|
<a name="line106">106: </a> }
|
||||||
|
|
||||||
|
<a name="line108">108: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line109">109: </a><font color="#B22222"> * Launches PDA interpreter with the given program.</font>
|
||||||
|
<a name="line110">110: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line111">111: </a><font color="#B22222"> * @param launch Launch that will contain the new process.</font>
|
||||||
|
<a name="line112">112: </a><font color="#B22222"> * @param program PDA program to use in the interpreter.</font>
|
||||||
|
<a name="line113">113: </a><font color="#B22222"> * @param requestPort The port number for connecting the request socket.</font>
|
||||||
|
<a name="line114">114: </a><font color="#B22222"> * @param eventPort The port number for connecting the events socket.</font>
|
||||||
|
<a name="line115">115: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line116">116: </a><font color="#B22222"> * @throws CoreException </font>
|
||||||
|
<a name="line117">117: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line118">118: </a><strong><font color="#4169E1"> private void launchProcess(ILaunch launch, String program, int requestPort, int eventPort)</font></strong> <font color="#4169E1">throws</font> CoreException {
|
||||||
|
<a name="line119">119: </a> List<String> commandList = new ArrayList<String>();
|
||||||
|
|
||||||
|
<a name="line121">121: </a> <font color="#B22222">// Find Perl executable</font>
|
||||||
|
<a name="line122">122: </a> IValueVariable perl = VariablesPlugin.getDefault().getStringVariableManager().getValueVariable(PDAPlugin.VARIALBE_PERL_EXECUTABLE);
|
||||||
|
<a name="line123">123: </a> <font color="#4169E1">if</font> (perl == null) {
|
||||||
|
<a name="line124">124: </a> abort(<font color="#666666">"Perl executable location undefined. Check value of ${dsfPerlExecutable}."</font>, null);
|
||||||
|
<a name="line125">125: </a> }
|
||||||
|
<a name="line126">126: </a> String path = perl.getValue();
|
||||||
|
<a name="line127">127: </a> <font color="#4169E1">if</font> (path == null) {
|
||||||
|
<a name="line128">128: </a> abort(<font color="#666666">"Perl executable location unspecified. Check value of ${dsfPerlExecutable}."</font>, null);
|
||||||
|
<a name="line129">129: </a> }
|
||||||
|
<a name="line130">130: </a> File exe = new File(path);
|
||||||
|
<a name="line131">131: </a> <font color="#4169E1">if</font> (!exe.exists()) {
|
||||||
|
<a name="line132">132: </a> abort(MessageFormat.format(<font color="#666666">"Specified Perl executable {0} does not exist. Check value of $dsfPerlExecutable."</font>, new Object[]{path}), null);
|
||||||
|
<a name="line133">133: </a> }
|
||||||
|
<a name="line134">134: </a> commandList.add(path);
|
||||||
|
|
||||||
|
<a name="line136">136: </a> <font color="#B22222">// Add PDA VM</font>
|
||||||
|
<a name="line137">137: </a> File vm = PDAPlugin.getFileInPlugin(new Path(<font color="#666666">"pdavm/pda.pl"</font>));
|
||||||
|
<a name="line138">138: </a> <font color="#4169E1">if</font> (vm == null) {
|
||||||
|
<a name="line139">139: </a> abort(<font color="#666666">"Missing PDA VM"</font>, null);
|
||||||
|
<a name="line140">140: </a> }
|
||||||
|
<a name="line141">141: </a> commandList.add(vm.getAbsolutePath());
|
||||||
|
|
||||||
|
<a name="line143">143: </a> <font color="#B22222">// Add PDA program</font>
|
||||||
|
<a name="line144">144: </a> IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program));
|
||||||
|
<a name="line145">145: </a> <font color="#4169E1">if</font> (!file.exists()) {
|
||||||
|
<a name="line146">146: </a> abort(MessageFormat.format(<font color="#666666">"Perl program {0} does not exist."</font>, new Object[] {file.getFullPath().toString()}), null);
|
||||||
|
<a name="line147">147: </a> }
|
||||||
|
|
||||||
|
<a name="line149">149: </a> commandList.add(file.getLocation().toOSString());
|
||||||
|
|
||||||
|
<a name="line151">151: </a> <font color="#B22222">// Add debug arguments - i.e. '-debug requestPort eventPort'</font>
|
||||||
|
<a name="line152">152: </a> commandList.add(<font color="#666666">"-debug"</font>);
|
||||||
|
<a name="line153">153: </a> commandList.add(<font color="#666666">""</font> + requestPort);
|
||||||
|
<a name="line154">154: </a> commandList.add(<font color="#666666">""</font> + eventPort);
|
||||||
|
|
||||||
|
<a name="line156">156: </a> <font color="#B22222">// Launch the perl process.</font>
|
||||||
|
<a name="line157">157: </a> String[] commandLine = commandList.toArray(new String[commandList.size()]);
|
||||||
|
<a name="line158">158: </a> Process process = DebugPlugin.exec(commandLine, null);
|
||||||
|
|
||||||
|
<a name="line160">160: </a> <font color="#B22222">// Create a debug platform process object and add it to the launch.</font>
|
||||||
|
<a name="line161">161: </a> DebugPlugin.newProcess(launch, process, path);
|
||||||
|
<a name="line162">162: </a> }
|
||||||
|
|
||||||
|
<a name="line164">164: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line165">165: </a><font color="#B22222"> * Calls the launch to initialize DSF services for this launch.</font>
|
||||||
|
<a name="line166">166: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line167">167: </a><strong><font color="#4169E1"> private void initServices(final PDALaunch pdaLaunch, final String program, final int requestPort, final int eventPort)</font></strong>
|
||||||
|
<a name="line168">168: </a> <font color="#4169E1">throws</font> CoreException
|
||||||
|
<a name="line169">169: </a> {
|
||||||
|
<a name="line170">170: </a> <font color="#B22222">// Synchronization object to use when waiting for the services initialization.</font>
|
||||||
|
<a name="line171">171: </a> Query<Object> initQuery = new Query<Object>() {
|
||||||
|
<a name="line172">172: </a> @Override
|
||||||
|
<a name="line173">173: </a> protected void execute(DataRequestMonitor<Object> rm) {
|
||||||
|
<a name="line174">174: </a> pdaLaunch.initializeServices(program, requestPort, eventPort, rm);
|
||||||
|
<a name="line175">175: </a> }
|
||||||
|
<a name="line176">176: </a> };
|
||||||
|
|
||||||
|
<a name="line178">178: </a> <font color="#B22222">// Submit the query to the executor.</font>
|
||||||
|
<a name="line179">179: </a> pdaLaunch.getSession().getExecutor().execute(initQuery);
|
||||||
|
<a name="line180">180: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line181">181: </a> <font color="#B22222">// Block waiting for query results.</font>
|
||||||
|
<a name="line182">182: </a> initQuery.get();
|
||||||
|
<a name="line183">183: </a> } <font color="#4169E1">catch</font> (InterruptedException e1) {
|
||||||
|
<a name="line184">184: </a> <font color="#4169E1">throw</font> new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, <font color="#666666">"Interrupted Exception in dispatch thread"</font>, e1)); <font color="#B22222">//$NON-NLS-1$</font>
|
||||||
|
<a name="line185">185: </a> } <font color="#4169E1">catch</font> (ExecutionException e1) {
|
||||||
|
<a name="line186">186: </a> <font color="#4169E1">throw</font> new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, <font color="#666666">"Error in launch sequence"</font>, e1.getCause())); <font color="#B22222">//$NON-NLS-1$</font>
|
||||||
|
<a name="line187">187: </a> }
|
||||||
|
<a name="line188">188: </a> }
|
||||||
|
|
||||||
|
<a name="line190">190: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line191">191: </a><font color="#B22222"> * Throws an exception with a new status containing the given</font>
|
||||||
|
<a name="line192">192: </a><font color="#B22222"> * message and optional exception.</font>
|
||||||
|
<a name="line193">193: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line194">194: </a><font color="#B22222"> * @param message error message</font>
|
||||||
|
<a name="line195">195: </a><font color="#B22222"> * @param e underlying exception</font>
|
||||||
|
<a name="line196">196: </a><font color="#B22222"> * @throws CoreException</font>
|
||||||
|
<a name="line197">197: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line198">198: </a><strong><font color="#4169E1"> private void abort(String message, Throwable e)</font></strong> <font color="#4169E1">throws</font> CoreException {
|
||||||
|
<a name="line199">199: </a> <font color="#4169E1">throw</font> new CoreException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, 0, message, e));
|
||||||
|
<a name="line200">200: </a> }
|
||||||
|
|
||||||
|
<a name="line202">202: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line203">203: </a><font color="#B22222"> * Returns a free port number on localhost, or -1 if unable to find a free port.</font>
|
||||||
|
<a name="line204">204: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line205">205: </a><strong><font color="#4169E1"> public static int findFreePort()</font></strong> {
|
||||||
|
<a name="line206">206: </a> ServerSocket socket= null;
|
||||||
|
<a name="line207">207: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line208">208: </a> socket= new ServerSocket(0);
|
||||||
|
<a name="line209">209: </a> <font color="#4169E1">return</font> socket.getLocalPort();
|
||||||
|
<a name="line210">210: </a> } <font color="#4169E1">catch</font> (IOException e) {
|
||||||
|
<a name="line211">211: </a> } finally {
|
||||||
|
<a name="line212">212: </a> <font color="#4169E1">if</font> (socket != null) {
|
||||||
|
<a name="line213">213: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line214">214: </a> socket.close();
|
||||||
|
<a name="line215">215: </a> } <font color="#4169E1">catch</font> (IOException e) {
|
||||||
|
<a name="line216">216: </a> }
|
||||||
|
<a name="line217">217: </a> }
|
||||||
|
<a name="line218">218: </a> }
|
||||||
|
<a name="line219">219: </a> <font color="#4169E1">return</font> -1;
|
||||||
|
<a name="line220">220: </a> }
|
||||||
|
<a name="line221">221: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -44,12 +44,6 @@ public class PDAServicesInitSequence extends Sequence {
|
||||||
fCommandControl = new PDACommandControl(fSession, fProgram, fRequestPort, fEventPort);
|
fCommandControl = new PDACommandControl(fSession, fProgram, fRequestPort, fEventPort);
|
||||||
fCommandControl.initialize(requestMonitor);
|
fCommandControl.initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void rollBack(RequestMonitor rm) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.rollBack(rm);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
new Step() {
|
new Step() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,7 +71,7 @@ public class PDAServicesInitSequence extends Sequence {
|
||||||
@Override
|
@Override
|
||||||
public void execute(final RequestMonitor requestMonitor) {
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
// Create the breakpoint mediator and start tracking PDA breakpoints.
|
// Create the breakpoint mediator and start tracking PDA breakpoints.
|
||||||
|
|
||||||
final BreakpointsMediator bpmService = new BreakpointsMediator(
|
final BreakpointsMediator bpmService = new BreakpointsMediator(
|
||||||
fSession, new PDABreakpointAttributeTranslator());
|
fSession, new PDABreakpointAttributeTranslator());
|
||||||
bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
|
bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
|
||||||
|
@ -88,19 +82,22 @@ public class PDAServicesInitSequence extends Sequence {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() { @Override
|
new Step() {
|
||||||
|
@Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
// Start the stack service.
|
// Start the stack service.
|
||||||
new PDAStack(fSession).initialize(requestMonitor);
|
new PDAStack(fSession).initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() { @Override
|
new Step() {
|
||||||
|
@Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
// Start the service to track expressions.
|
// Start the service to track expressions.
|
||||||
new PDAExpressions(fSession).initialize(requestMonitor);
|
new PDAExpressions(fSession).initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() { @Override
|
new Step() {
|
||||||
|
@Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fRunControl.resume(fCommandControl.getProgramDMContext(), requestMonitor);
|
fRunControl.resume(fCommandControl.getProgramDMContext(), requestMonitor);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +122,7 @@ public class PDAServicesInitSequence extends Sequence {
|
||||||
fRequestPort = requestPort;
|
fRequestPort = requestPort;
|
||||||
fEventPort = eventPort;
|
fEventPort = eventPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Step[] getSteps() {
|
public Step[] getSteps() {
|
||||||
return fSteps;
|
return fSteps;
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDAServicesInitSequence.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-08T00:07:39+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2008 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.launch;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.RequestMonitor;</font>
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.Sequence;</font>
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.BreakpointsMediator;</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.StepQueueManager;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDABreakpointAttributeTranslator;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDABreakpoints;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDACommandControl;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDAExpressions;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDARunControl;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDAStack;</font>
|
||||||
|
|
||||||
|
<a name="line25"> 25: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#B22222"> * The initialization sequence for PDA debugger services. This sequence contains</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#B22222"> * the series of steps that are executed to properly initialize the PDA-DSF debug</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#B22222"> * session. If any of the individual steps fail, the initialization will abort. </font>
|
||||||
|
<a name="line29"> 29: </a><font color="#B22222"> * <p></font>
|
||||||
|
<a name="line30"> 30: </a><font color="#B22222"> * The order in which services are initialized is important. Some services depend</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#B22222"> * on other services and they assume that they will be initialized only if those</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#B22222"> * services are active. Also the service events are prioritized and their priority</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#B22222"> * depends on the order in which the services were initialized.</font>
|
||||||
|
<a name="line34"> 34: </a><font color="#B22222"> * </p></font>
|
||||||
|
<a name="line35"> 35: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line36"> 36: </a><strong><font color="#4169E1"><a name="PDAServicesInitSequence"></a>public class PDAServicesInitSequence extends Sequence </font></strong>{
|
||||||
|
|
||||||
|
<a name="line38"> 38: </a> Step[] fSteps = new Step[] {
|
||||||
|
<a name="line39"> 39: </a> new Step()
|
||||||
|
<a name="line40"> 40: </a> {
|
||||||
|
<a name="line41"> 41: </a> @Override
|
||||||
|
<a name="line42"> 42: </a><strong><font color="#4169E1"> public void execute(RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line43"> 43: </a> <font color="#B22222">// Create the connection to PDA debugger.</font>
|
||||||
|
<a name="line44"> 44: </a> fCommandControl = new PDACommandControl(fSession, fProgram, fRequestPort, fEventPort);
|
||||||
|
<a name="line45"> 45: </a> fCommandControl.initialize(requestMonitor);
|
||||||
|
<a name="line46"> 46: </a> }
|
||||||
|
<a name="line47"> 47: </a> },
|
||||||
|
<a name="line48"> 48: </a> new Step() {
|
||||||
|
<a name="line49"> 49: </a> @Override
|
||||||
|
<a name="line50"> 50: </a><strong><font color="#4169E1"> public void execute(RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line51"> 51: </a> <font color="#B22222">// Start the run control service.</font>
|
||||||
|
<a name="line52"> 52: </a> fRunControl = new PDARunControl(fSession);
|
||||||
|
<a name="line53"> 53: </a> fRunControl.initialize(requestMonitor);
|
||||||
|
<a name="line54"> 54: </a> }
|
||||||
|
<a name="line55"> 55: </a> },
|
||||||
|
<a name="line56"> 56: </a> new Step() {
|
||||||
|
<a name="line57"> 57: </a> @Override
|
||||||
|
<a name="line58"> 58: </a><strong><font color="#4169E1"> public void execute(RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line59"> 59: </a> <font color="#B22222">// Start the service to manage step actions.</font>
|
||||||
|
<a name="line60"> 60: </a> new StepQueueManager(fSession).initialize(requestMonitor);
|
||||||
|
<a name="line61"> 61: </a> }
|
||||||
|
<a name="line62"> 62: </a> },
|
||||||
|
<a name="line63"> 63: </a> new Step() {
|
||||||
|
<a name="line64"> 64: </a> @Override
|
||||||
|
<a name="line65"> 65: </a><strong><font color="#4169E1"> public void execute(final RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line66"> 66: </a> <font color="#B22222">// Start the low-level breakpoint service </font>
|
||||||
|
<a name="line67"> 67: </a> new PDABreakpoints(fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
|
||||||
|
<a name="line68"> 68: </a> }
|
||||||
|
<a name="line69"> 69: </a> },
|
||||||
|
<a name="line70"> 70: </a> new Step() {
|
||||||
|
<a name="line71"> 71: </a> @Override
|
||||||
|
<a name="line72"> 72: </a><strong><font color="#4169E1"> public void execute(final RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line73"> 73: </a> <font color="#B22222">// Create the breakpoint mediator and start tracking PDA breakpoints.</font>
|
||||||
|
|
||||||
|
<a name="line75"> 75: </a> final BreakpointsMediator bpmService = new BreakpointsMediator(
|
||||||
|
<a name="line76"> 76: </a> fSession, new PDABreakpointAttributeTranslator());
|
||||||
|
<a name="line77"> 77: </a> bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
|
||||||
|
<a name="line78"> 78: </a> @Override
|
||||||
|
<a name="line79"> 79: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line80"> 80: </a> bpmService.startTrackingBreakpoints(fCommandControl.getProgramDMContext(), requestMonitor);
|
||||||
|
<a name="line81"> 81: </a> }
|
||||||
|
<a name="line82"> 82: </a> });
|
||||||
|
<a name="line83"> 83: </a> }
|
||||||
|
<a name="line84"> 84: </a> },
|
||||||
|
<a name="line85"> 85: </a> new Step() { @Override
|
||||||
|
<a name="line86"> 86: </a><strong><font color="#4169E1"> public void execute(RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line87"> 87: </a> <font color="#B22222">// Start the stack service.</font>
|
||||||
|
<a name="line88"> 88: </a> new PDAStack(fSession).initialize(requestMonitor);
|
||||||
|
<a name="line89"> 89: </a> }
|
||||||
|
<a name="line90"> 90: </a> },
|
||||||
|
<a name="line91"> 91: </a> new Step() { @Override
|
||||||
|
<a name="line92"> 92: </a><strong><font color="#4169E1"> public void execute(RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line93"> 93: </a> <font color="#B22222">// Start the service to track expressions.</font>
|
||||||
|
<a name="line94"> 94: </a> new PDAExpressions(fSession).initialize(requestMonitor);
|
||||||
|
<a name="line95"> 95: </a> }
|
||||||
|
<a name="line96"> 96: </a> },
|
||||||
|
<a name="line97"> 97: </a> new Step() { @Override
|
||||||
|
<a name="line98"> 98: </a><strong><font color="#4169E1"> public void execute(RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line99"> 99: </a> fRunControl.resume(fCommandControl.getProgramDMContext(), requestMonitor);
|
||||||
|
<a name="line100">100: </a> }
|
||||||
|
<a name="line101">101: </a> },
|
||||||
|
<a name="line102">102: </a> };
|
||||||
|
|
||||||
|
<a name="line104">104: </a> <font color="#B22222">// Sequence input parameters, used in initializing services.</font>
|
||||||
|
<a name="line105">105: </a> private DsfSession fSession;
|
||||||
|
<a name="line106">106: </a> private String fProgram;
|
||||||
|
<a name="line107">107: </a> private int fRequestPort;
|
||||||
|
<a name="line108">108: </a> private int fEventPort;
|
||||||
|
|
||||||
|
<a name="line110">110: </a> <font color="#B22222">// Service references, initialized when created and used in initializing other services.</font>
|
||||||
|
<a name="line111">111: </a> private PDACommandControl fCommandControl;
|
||||||
|
<a name="line112">112: </a> private PDARunControl fRunControl;
|
||||||
|
|
||||||
|
<a name="line114">114: </a><strong><font color="#4169E1"> public PDAServicesInitSequence(DsfSession session, String program, int requestPort, int eventPort, RequestMonitor rm)</font></strong>
|
||||||
|
<a name="line115">115: </a> {
|
||||||
|
<a name="line116">116: </a> super(session.getExecutor(), rm);
|
||||||
|
<a name="line117">117: </a> fSession = session;
|
||||||
|
<a name="line118">118: </a> fProgram = program;
|
||||||
|
<a name="line119">119: </a> fRequestPort = requestPort;
|
||||||
|
<a name="line120">120: </a> fEventPort = eventPort;
|
||||||
|
<a name="line121">121: </a> }
|
||||||
|
|
||||||
|
<a name="line123">123: </a> @Override
|
||||||
|
<a name="line124">124: </a> public Step[] getSteps() {
|
||||||
|
<a name="line125">125: </a> <font color="#4169E1">return</font> fSteps;
|
||||||
|
<a name="line126">126: </a> }
|
||||||
|
<a name="line127">127: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -63,7 +63,7 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
public List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
||||||
throws CoreException
|
throws CoreException
|
||||||
{
|
{
|
||||||
Map<String, Object> attrs = new HashMap<String, Object>();
|
Map<String, Object> attrs = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
@ -82,15 +82,15 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
// Copy breakpoint attributes.
|
// Copy breakpoint attributes.
|
||||||
if (bp instanceof PDAWatchpoint) {
|
if (bp instanceof PDAWatchpoint) {
|
||||||
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
||||||
|
|
||||||
copyAttributes(platformBpAttrs, attrs, fgPDAWatchpointAttributes);
|
copyAttributes(platformBpAttrs, attrs, fgPDAWatchpointAttributes);
|
||||||
} else if (bp instanceof PDALineBreakpoint) {
|
} else if (bp instanceof PDALineBreakpoint) {
|
||||||
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_LINE_BREAKPOINT);
|
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_LINE_BREAKPOINT);
|
||||||
attrs.put(PDABreakpoints.ATTR_PROGRAM_PATH, marker.getResource().getFullPath().toString());
|
attrs.put(PDABreakpoints.ATTR_PROGRAM_PATH, marker.getResource().getFullPath().toString());
|
||||||
|
|
||||||
copyAttributes(platformBpAttrs, attrs, fgPDALineBreakpointAttributes);
|
copyAttributes(platformBpAttrs, attrs, fgPDALineBreakpointAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the breakpoint manager is disabled, override the enabled attribute.
|
// If the breakpoint manager is disabled, override the enabled attribute.
|
||||||
if (!bpManagerEnabled) {
|
if (!bpManagerEnabled) {
|
||||||
attrs.put(IBreakpoint.ENABLED, false);
|
attrs.put(IBreakpoint.ENABLED, false);
|
||||||
|
@ -111,7 +111,7 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta) {
|
public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta) {
|
||||||
// PDA debugger only allows updating of the action property of the watchpoint.
|
// PDA debugger only allows updating of the action property of the watchpoint.
|
||||||
// All other breakpoint updates will require a re-installation.
|
// All other breakpoint updates will require a re-installation.
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDABreakpointAttributeTranslator.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-12T20:11:41+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2008 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import java.util.ArrayList;</font>
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.HashMap;</font>
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import java.util.List;</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import java.util.Map;</font>
|
||||||
|
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.core.resources.IMarker;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.core.runtime.CoreException;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.core.runtime.IStatus;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.core.runtime.Status;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.BreakpointsMediator;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IBreakpointAttributeTranslator;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IBreakpoints.IBreakpointDMContext;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.dd.examples.pda.breakpoints.PDALineBreakpoint;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.dd.examples.pda.breakpoints.PDAWatchpoint;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.debug.core.DebugException;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.debug.core.model.IBreakpoint;</font>
|
||||||
|
|
||||||
|
<a name="line31"> 31: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#B22222"> * Translator between {@link PDALineBreakpoint} object attributes and </font>
|
||||||
|
<a name="line33"> 33: </a><font color="#B22222"> * attributes used by the {@link PDABreakpoints} service. </font>
|
||||||
|
<a name="line34"> 34: </a><font color="#B22222"> * <p></font>
|
||||||
|
<a name="line35"> 35: </a><font color="#B22222"> * The attribute translator is used by the standard {@link BreakpointsMediator} </font>
|
||||||
|
<a name="line36"> 36: </a><font color="#B22222"> * service to map between platform breakpoint attributes and target-side DSF</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#B22222"> * breakpoint attributes. Thus, this object encapsulates the model-specific</font>
|
||||||
|
<a name="line38"> 38: </a><font color="#B22222"> * functionality of synchronizing target side and IDE-side breakpoint objects. </font>
|
||||||
|
<a name="line39"> 39: </a><font color="#B22222"> * </p></font>
|
||||||
|
<a name="line40"> 40: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line41"> 41: </a><strong><font color="#4169E1"><a name="PDABreakpointAttributeTranslator"></a>public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTranslator </font></strong>{
|
||||||
|
|
||||||
|
<a name="line43"> 43: </a> <font color="#B22222">// Arrays of common attributes between the two breakpoint types. These </font>
|
||||||
|
<a name="line44"> 44: </a> <font color="#B22222">// attributes can be copied directly without translation.</font>
|
||||||
|
<a name="line45"> 45: </a> private static final String[] fgPDALineBreakpointAttributes = {
|
||||||
|
<a name="line46"> 46: </a> IBreakpoint.ENABLED,
|
||||||
|
<a name="line47"> 47: </a> IMarker.LINE_NUMBER,
|
||||||
|
<a name="line48"> 48: </a> };
|
||||||
|
<a name="line49"> 49: </a> private static final String[] fgPDAWatchpointAttributes = {
|
||||||
|
<a name="line50"> 50: </a> IBreakpoint.ENABLED,
|
||||||
|
<a name="line51"> 51: </a> PDAWatchpoint.FUNCTION_NAME,
|
||||||
|
<a name="line52"> 52: </a> PDAWatchpoint.VAR_NAME,
|
||||||
|
<a name="line53"> 53: </a> PDAWatchpoint.ACCESS,
|
||||||
|
<a name="line54"> 54: </a> PDAWatchpoint.MODIFICATION
|
||||||
|
<a name="line55"> 55: </a> };
|
||||||
|
|
||||||
|
<a name="line57"> 57: </a> <font color="#B22222">// PDA breakpoints translator doesn't keep any state and it doesn't </font>
|
||||||
|
<a name="line58"> 58: </a> <font color="#B22222">// need to initialize or clean up.</font>
|
||||||
|
<a name="line59"> 59: </a><strong><font color="#4169E1"> public void initialize(BreakpointsMediator mediator)</font></strong> {
|
||||||
|
<a name="line60"> 60: </a> }
|
||||||
|
|
||||||
|
<a name="line62"> 62: </a><strong><font color="#4169E1"> public void dispose()</font></strong> {
|
||||||
|
<a name="line63"> 63: </a> }
|
||||||
|
|
||||||
|
<a name="line65"> 65: </a> public List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
||||||
|
<a name="line66"> 66: </a> <font color="#4169E1">throws</font> CoreException
|
||||||
|
<a name="line67"> 67: </a> {
|
||||||
|
<a name="line68"> 68: </a> Map<String, Object> attrs = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
<a name="line70"> 70: </a> <font color="#B22222">// Check that the marker exists and retrieve its attributes. </font>
|
||||||
|
<a name="line71"> 71: </a> <font color="#B22222">// Due to accepted race conditions, the breakpiont marker may become null </font>
|
||||||
|
<a name="line72"> 72: </a> <font color="#B22222">// while this method is being invoked. In this case throw an exception</font>
|
||||||
|
<a name="line73"> 73: </a> <font color="#B22222">// and let the caller handle it.</font>
|
||||||
|
<a name="line74"> 74: </a> IMarker marker = bp.getMarker();
|
||||||
|
<a name="line75"> 75: </a> <font color="#4169E1">if</font> (marker == null || !marker.exists()) {
|
||||||
|
<a name="line76"> 76: </a> <font color="#4169E1">throw</font> new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, <font color="#666666">"Breakpoint marker does not exist"</font>, null));
|
||||||
|
<a name="line77"> 77: </a> }
|
||||||
|
<a name="line78"> 78: </a> <font color="#B22222">// Suppress cast warning: platform is still on Java 1.3</font>
|
||||||
|
<a name="line79"> 79: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>)
|
||||||
|
<a name="line80"> 80: </a> Map<String, Object> platformBpAttrs = marker.getAttributes();
|
||||||
|
|
||||||
|
<a name="line82"> 82: </a> <font color="#B22222">// Copy breakpoint attributes.</font>
|
||||||
|
<a name="line83"> 83: </a> <font color="#4169E1">if</font> (bp instanceof PDAWatchpoint) {
|
||||||
|
<a name="line84"> 84: </a> attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
||||||
|
|
||||||
|
<a name="line86"> 86: </a> copyAttributes(platformBpAttrs, attrs, fgPDAWatchpointAttributes);
|
||||||
|
<a name="line87"> 87: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (bp instanceof PDALineBreakpoint) {
|
||||||
|
<a name="line88"> 88: </a> attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_LINE_BREAKPOINT);
|
||||||
|
<a name="line89"> 89: </a> attrs.put(PDABreakpoints.ATTR_PROGRAM_PATH, marker.getResource().getFullPath().toString());
|
||||||
|
|
||||||
|
<a name="line91"> 91: </a> copyAttributes(platformBpAttrs, attrs, fgPDALineBreakpointAttributes);
|
||||||
|
<a name="line92"> 92: </a> }
|
||||||
|
|
||||||
|
<a name="line94"> 94: </a> <font color="#B22222">// If the breakpoint manager is disabled, override the enabled attribute.</font>
|
||||||
|
<a name="line95"> 95: </a> <font color="#4169E1">if</font> (!bpManagerEnabled) {
|
||||||
|
<a name="line96"> 96: </a> attrs.put(IBreakpoint.ENABLED, false);
|
||||||
|
<a name="line97"> 97: </a> }
|
||||||
|
|
||||||
|
<a name="line99"> 99: </a> <font color="#B22222">// The breakpoint mediator allows for multiple target-side breakpoints </font>
|
||||||
|
<a name="line100">100: </a> <font color="#B22222">// to be created for each IDE breakpoint. Although in case of PDA this </font>
|
||||||
|
<a name="line101">101: </a> <font color="#B22222">// feature is never used, we still have to return a list of attributes.</font>
|
||||||
|
<a name="line102">102: </a> List<Map<String, Object>> retVal = new ArrayList<Map<String, Object>>(1);
|
||||||
|
<a name="line103">103: </a> retVal.add(attrs);
|
||||||
|
<a name="line104">104: </a> <font color="#4169E1">return</font> retVal;
|
||||||
|
<a name="line105">105: </a> }
|
||||||
|
|
||||||
|
<a name="line107">107: </a> private void copyAttributes(Map<String, Object> srcMap, Map<String, Object> destMap, String[] attrs) {
|
||||||
|
<a name="line108">108: </a> <font color="#4169E1">for</font> (String attr : attrs) {
|
||||||
|
<a name="line109">109: </a> <font color="#4169E1">if</font> (srcMap.containsKey(attr)) {
|
||||||
|
<a name="line110">110: </a> destMap.put(attr, srcMap.get(attr));
|
||||||
|
<a name="line111">111: </a> }
|
||||||
|
<a name="line112">112: </a> }
|
||||||
|
<a name="line113">113: </a> }
|
||||||
|
|
||||||
|
<a name="line115">115: </a> public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta) {
|
||||||
|
<a name="line116">116: </a> <font color="#B22222">// PDA debugger only allows updating of the action property of the watchpoint.</font>
|
||||||
|
<a name="line117">117: </a> <font color="#B22222">// All other breakpoint updates will require a re-installation.</font>
|
||||||
|
<a name="line118">118: </a> <font color="#4169E1">if</font> (bp instanceof PDAWatchpoint) {
|
||||||
|
<a name="line119">119: </a> Map<String, Object> deltaCopy = new HashMap<String, Object>(delta);
|
||||||
|
<a name="line120">120: </a> deltaCopy.remove(PDAWatchpoint.ACCESS);
|
||||||
|
<a name="line121">121: </a> deltaCopy.remove(PDAWatchpoint.MODIFICATION);
|
||||||
|
<a name="line122">122: </a> <font color="#4169E1">return</font> !deltaCopy.isEmpty();
|
||||||
|
<a name="line123">123: </a> }
|
||||||
|
<a name="line124">124: </a> <font color="#4169E1">return</font> false;
|
||||||
|
<a name="line125">125: </a> }
|
||||||
|
|
||||||
|
<a name="line127">127: </a><strong><font color="#4169E1"> public boolean supportsBreakpoint(IBreakpoint bp)</font></strong> {
|
||||||
|
<a name="line128">128: </a> <font color="#4169E1">return</font> bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL);
|
||||||
|
<a name="line129">129: </a> }
|
||||||
|
|
||||||
|
<a name="line131">131: </a><strong><font color="#4169E1"> public void updateBreakpointStatus(IBreakpoint bp)</font></strong> {
|
||||||
|
<a name="line132">132: </a> <font color="#B22222">// PDA breakpoints do not support status reporting</font>
|
||||||
|
<a name="line133">133: </a> }
|
||||||
|
|
||||||
|
<a name="line135">135: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -60,7 +60,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return baseEquals(obj) && (fLine.equals(((BreakpointDMContext) obj).fLine));
|
return baseEquals(obj) && (fLine.equals(((BreakpointDMContext) obj).fLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return baseHashCode() + fLine.hashCode();
|
return baseHashCode() + fLine.hashCode();
|
||||||
|
@ -71,7 +71,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
return baseToString() + ".breakpoint(" + fLine + ")"; //$NON-NLS-1$//$NON-NLS-2$*/
|
return baseToString() + ".breakpoint(" + fLine + ")"; //$NON-NLS-1$//$NON-NLS-2$*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context representing a watch point. In PDA debugger, a watchpoint is
|
* Context representing a watch point. In PDA debugger, a watchpoint is
|
||||||
* uniquely identified using the function and variable.
|
* uniquely identified using the function and variable.
|
||||||
|
@ -97,7 +97,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return baseHashCode() + fFunction.hashCode() + fVariable.hashCode();
|
return baseHashCode() + fFunction.hashCode() + fVariable.hashCode();
|
||||||
|
@ -108,119 +108,119 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
return baseToString() + ".watchpoint(" + fFunction + "::" + fVariable + ")";
|
return baseToString() + ".watchpoint(" + fFunction + "::" + fVariable + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attribute names
|
// Attribute names
|
||||||
public static final String ATTR_BREAKPOINT_TYPE = PDAPlugin.PLUGIN_ID + ".pdaBreakpointType"; //$NON-NLS-1$
|
public static final String ATTR_BREAKPOINT_TYPE = PDAPlugin.PLUGIN_ID + ".pdaBreakpointType"; //$NON-NLS-1$
|
||||||
public static final String PDA_LINE_BREAKPOINT = "breakpoint"; //$NON-NLS-1$
|
public static final String PDA_LINE_BREAKPOINT = "breakpoint"; //$NON-NLS-1$
|
||||||
public static final String PDA_WATCHPOINT = "watchpoint"; //$NON-NLS-1$
|
public static final String PDA_WATCHPOINT = "watchpoint"; //$NON-NLS-1$
|
||||||
public static final String ATTR_PROGRAM_PATH = PDAPlugin.PLUGIN_ID + ".pdaProgramPath"; //$NON-NLS-1$
|
public static final String ATTR_PROGRAM_PATH = PDAPlugin.PLUGIN_ID + ".pdaProgramPath"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
private PDACommandControl fCommandControl;
|
private PDACommandControl fCommandControl;
|
||||||
|
|
||||||
// Breakpoints currently installed
|
// Breakpoints currently installed
|
||||||
private Set<IBreakpointDMContext> fBreakpoints = new HashSet<IBreakpointDMContext>();
|
private Set<IBreakpointDMContext> fBreakpoints = new HashSet<IBreakpointDMContext>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The service constructor
|
* The service constructor
|
||||||
*
|
*
|
||||||
* @param session The debugging session this service belongs to.
|
* @param session The debugging session this service belongs to.
|
||||||
*/
|
*/
|
||||||
public PDABreakpoints(DsfSession session) {
|
public PDABreakpoints(DsfSession session) {
|
||||||
super(session);
|
super(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(final RequestMonitor rm) {
|
public void initialize(final RequestMonitor rm) {
|
||||||
super.initialize(new RequestMonitor(getExecutor(), rm) {
|
super.initialize(new RequestMonitor(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleOK() {
|
protected void handleOK() {
|
||||||
doInitialize(rm);
|
doInitialize(rm);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doInitialize(final RequestMonitor rm) {
|
private void doInitialize(final RequestMonitor rm) {
|
||||||
// Get the services references
|
// Get the services references
|
||||||
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
|
||||||
// Register this service
|
// Register this service
|
||||||
register(new String[] { IBreakpoints.class.getName(), PDABreakpoints.class.getName() },
|
register(new String[] { IBreakpoints.class.getName(), PDABreakpoints.class.getName() },
|
||||||
new Hashtable<String, String>());
|
new Hashtable<String, String>());
|
||||||
|
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown(final RequestMonitor rm) {
|
public void shutdown(final RequestMonitor rm) {
|
||||||
unregister();
|
unregister();
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BundleContext getBundleContext() {
|
protected BundleContext getBundleContext() {
|
||||||
return PDAPlugin.getBundleContext();
|
return PDAPlugin.getBundleContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getBreakpoints(final IBreakpointsTargetDMContext context, final DataRequestMonitor<IBreakpointDMContext[]> rm) {
|
public void getBreakpoints(final IBreakpointsTargetDMContext context, final DataRequestMonitor<IBreakpointDMContext[]> rm) {
|
||||||
// Validate the context
|
// Validate the context
|
||||||
if (!fCommandControl.getProgramDMContext().equals(context)) {
|
if (!fCommandControl.getProgramDMContext().equals(context)) {
|
||||||
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoints target context");
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoints target context");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rm.setData(fBreakpoints.toArray(new IBreakpointDMContext[fBreakpoints.size()]));
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getBreakpointDMData(IBreakpointDMContext dmc, DataRequestMonitor<IBreakpointDMData> rm) {
|
|
||||||
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Retrieving breakpoint data is not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void insertBreakpoint(IBreakpointsTargetDMContext context, Map<String, Object> attributes,
|
|
||||||
DataRequestMonitor<IBreakpointDMContext> rm)
|
|
||||||
{
|
|
||||||
Boolean enabled = (Boolean)attributes.get(IBreakpoint.ENABLED);
|
|
||||||
if (enabled != null && !enabled.booleanValue()) {
|
|
||||||
// If the breakpoint is disabled, just fail the request.
|
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint is disabled");
|
|
||||||
} else {
|
|
||||||
String type = (String) attributes.get(ATTR_BREAKPOINT_TYPE);
|
|
||||||
|
|
||||||
if (PDA_LINE_BREAKPOINT.equals(type)) {
|
|
||||||
// Retrieve the PDA program context from the context given in the
|
|
||||||
// argument. This service is typically only called by the
|
|
||||||
// breakpoints mediator, which was called with the program context
|
|
||||||
// in the services initialization sequence. So checking if
|
|
||||||
// programCtx != null is mostly a formality.
|
|
||||||
PDAProgramDMContext programCtx = DMContexts.getAncestorOfType(context, PDAProgramDMContext.class);
|
|
||||||
if (programCtx != null) {
|
|
||||||
doInsertBreakpoint(programCtx, attributes, rm);
|
|
||||||
} else {
|
|
||||||
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Unknown breakpoint type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (PDA_WATCHPOINT.equals(type)) {
|
|
||||||
doInsertWatchpoint(attributes, rm);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Unknown breakpoint type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doInsertBreakpoint(PDAProgramDMContext programCtx, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
|
||||||
{
|
|
||||||
// Compare the program path in the breakpoint with the path in the PDA
|
|
||||||
// program context. Only insert the breakpoint if the program matches.
|
|
||||||
String program = (String)attributes.get(ATTR_PROGRAM_PATH);
|
|
||||||
if (!programCtx.getProgram().equals(program)) {
|
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Invalid file name");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the line.
|
rm.setData(fBreakpoints.toArray(new IBreakpointDMContext[fBreakpoints.size()]));
|
||||||
Integer line = (Integer)attributes.get(IMarker.LINE_NUMBER);
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getBreakpointDMData(IBreakpointDMContext dmc, DataRequestMonitor<IBreakpointDMData> rm) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Retrieving breakpoint data is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertBreakpoint(IBreakpointsTargetDMContext context, Map<String, Object> attributes,
|
||||||
|
DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
|
{
|
||||||
|
Boolean enabled = (Boolean)attributes.get(IBreakpoint.ENABLED);
|
||||||
|
if (enabled != null && !enabled.booleanValue()) {
|
||||||
|
// If the breakpoint is disabled, just fail the request.
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint is disabled");
|
||||||
|
} else {
|
||||||
|
String type = (String) attributes.get(ATTR_BREAKPOINT_TYPE);
|
||||||
|
|
||||||
|
if (PDA_LINE_BREAKPOINT.equals(type)) {
|
||||||
|
// Retrieve the PDA program context from the context given in the
|
||||||
|
// argument. This service is typically only called by the
|
||||||
|
// breakpoints mediator, which was called with the program context
|
||||||
|
// in the services initialization sequence. So checking if
|
||||||
|
// programCtx != null is mostly a formality.
|
||||||
|
PDAProgramDMContext programCtx = DMContexts.getAncestorOfType(context, PDAProgramDMContext.class);
|
||||||
|
if (programCtx != null) {
|
||||||
|
doInsertBreakpoint(programCtx, attributes, rm);
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Unknown breakpoint type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (PDA_WATCHPOINT.equals(type)) {
|
||||||
|
doInsertWatchpoint(attributes, rm);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Unknown breakpoint type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doInsertBreakpoint(PDAProgramDMContext programCtx, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
|
{
|
||||||
|
// Compare the program path in the breakpoint with the path in the PDA
|
||||||
|
// program context. Only insert the breakpoint if the program matches.
|
||||||
|
String program = (String)attributes.get(ATTR_PROGRAM_PATH);
|
||||||
|
if (!programCtx.getProgram().equals(program)) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Invalid file name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the line.
|
||||||
|
Integer line = (Integer)attributes.get(IMarker.LINE_NUMBER);
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "No breakpoint line specified");
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "No breakpoint line specified");
|
||||||
return;
|
return;
|
||||||
|
@ -235,7 +235,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint already set");
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint already set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new breakpoint context to the list of known breakpoints.
|
// Add the new breakpoint context to the list of known breakpoints.
|
||||||
// Adding it here, before the set command is completed will prevent
|
// Adding it here, before the set command is completed will prevent
|
||||||
// a possibility of a second breakpoint being installed in the same
|
// a possibility of a second breakpoint being installed in the same
|
||||||
|
@ -251,7 +251,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
rm.setData(breakpointCtx);
|
rm.setData(breakpointCtx);
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleErrorOrCancel() {
|
protected void handleErrorOrCancel() {
|
||||||
// If inserting of the breakpoint failed, remove it from
|
// If inserting of the breakpoint failed, remove it from
|
||||||
|
@ -260,10 +260,10 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
super.handleErrorOrCancel();
|
super.handleErrorOrCancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doInsertWatchpoint(final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
private void doInsertWatchpoint(final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
{
|
{
|
||||||
String function = (String)attributes.get(PDAWatchpoint.FUNCTION_NAME);
|
String function = (String)attributes.get(PDAWatchpoint.FUNCTION_NAME);
|
||||||
if (function == null) {
|
if (function == null) {
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "No function specified");
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "No function specified");
|
||||||
|
@ -291,7 +291,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Watchpoint already set");
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Watchpoint already set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the watch operation to perform.
|
// Determine the watch operation to perform.
|
||||||
PDAWatchCommand.WatchOperation watchOperation = PDAWatchCommand.WatchOperation.NONE;
|
PDAWatchCommand.WatchOperation watchOperation = PDAWatchCommand.WatchOperation.NONE;
|
||||||
if (isAccess && isModification) {
|
if (isAccess && isModification) {
|
||||||
|
@ -317,7 +317,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
rm.setData(watchpointCtx);
|
rm.setData(watchpointCtx);
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleErrorOrCancel() {
|
protected void handleErrorOrCancel() {
|
||||||
// Since the command failed, we need to remove the breakpoint from
|
// Since the command failed, we need to remove the breakpoint from
|
||||||
|
@ -326,29 +326,29 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
super.handleErrorOrCancel();
|
super.handleErrorOrCancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBreakpoint(IBreakpointDMContext bpCtx, RequestMonitor rm) {
|
public void removeBreakpoint(IBreakpointDMContext bpCtx, RequestMonitor rm) {
|
||||||
if (!fBreakpoints.contains(bpCtx)) {
|
if (!fBreakpoints.contains(bpCtx)) {
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint already removed");
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint already removed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bpCtx instanceof BreakpointDMContext) {
|
if (bpCtx instanceof BreakpointDMContext) {
|
||||||
doRemoveBreakpoint((BreakpointDMContext)bpCtx, rm);
|
doRemoveBreakpoint((BreakpointDMContext)bpCtx, rm);
|
||||||
} else if (bpCtx instanceof WatchpointDMContext) {
|
} else if (bpCtx instanceof WatchpointDMContext) {
|
||||||
doRemoveWatchpoint((WatchpointDMContext)bpCtx, rm);
|
doRemoveWatchpoint((WatchpointDMContext)bpCtx, rm);
|
||||||
} else {
|
} else {
|
||||||
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoint");
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoint");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doRemoveBreakpoint(BreakpointDMContext bpCtx, RequestMonitor rm) {
|
private void doRemoveBreakpoint(BreakpointDMContext bpCtx, RequestMonitor rm) {
|
||||||
// Remove the breakpoint from the table right away, so that even when
|
// Remove the breakpoint from the table right away, so that even when
|
||||||
// the remove is being processed, a new breakpoint can be created at the same
|
// the remove is being processed, a new breakpoint can be created at the same
|
||||||
// location.
|
// location.
|
||||||
fBreakpoints.remove(bpCtx);
|
fBreakpoints.remove(bpCtx);
|
||||||
|
|
||||||
fCommandControl.queueCommand(
|
fCommandControl.queueCommand(
|
||||||
new PDAClearBreakpointCommand(fCommandControl.getProgramDMContext(), bpCtx.fLine),
|
new PDAClearBreakpointCommand(fCommandControl.getProgramDMContext(), bpCtx.fLine),
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
|
@ -356,23 +356,31 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
|
|
||||||
private void doRemoveWatchpoint(WatchpointDMContext bpCtx, RequestMonitor rm) {
|
private void doRemoveWatchpoint(WatchpointDMContext bpCtx, RequestMonitor rm) {
|
||||||
fBreakpoints.remove(bpCtx);
|
fBreakpoints.remove(bpCtx);
|
||||||
|
|
||||||
// Watchpoints are cleared using the same command, but with a "no watch" operation
|
// Watchpoints are cleared using the same command, but with a "no watch" operation
|
||||||
fCommandControl.queueCommand(
|
fCommandControl.queueCommand(
|
||||||
new PDAWatchCommand(
|
new PDAWatchCommand(
|
||||||
fCommandControl.getProgramDMContext(), bpCtx.fFunction, bpCtx.fVariable, PDAWatchCommand.WatchOperation.NONE),
|
fCommandControl.getProgramDMContext(), bpCtx.fFunction, bpCtx.fVariable, PDAWatchCommand.WatchOperation.NONE),
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateBreakpoint(final IBreakpointDMContext bpCtx, Map<String, Object> attributes, final RequestMonitor rm) {
|
public void updateBreakpoint(final IBreakpointDMContext bpCtx, Map<String, Object> attributes, final RequestMonitor rm) {
|
||||||
if (!fBreakpoints.contains(bpCtx)) {
|
if (!fBreakpoints.contains(bpCtx)) {
|
||||||
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint not installed");
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint not installed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bpCtx instanceof BreakpointDMContext) {
|
if (bpCtx instanceof BreakpointDMContext) {
|
||||||
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Modifying PDA breakpoints is not supported");
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Modifying PDA breakpoints is not supported");
|
||||||
} else if (bpCtx instanceof WatchpointDMContext) {
|
} else if (bpCtx instanceof WatchpointDMContext) {
|
||||||
|
WatchpointDMContext wpCtx = (WatchpointDMContext)bpCtx;
|
||||||
|
if (!wpCtx.fFunction.equals(attributes.get(PDAWatchpoint.FUNCTION_NAME)) ||
|
||||||
|
!wpCtx.fVariable.equals(attributes.get(PDAWatchpoint.VAR_NAME)) )
|
||||||
|
{
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Cannot modify watchpoint function or variable");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// PDA debugger can only track one watchpoint in the same location,
|
// PDA debugger can only track one watchpoint in the same location,
|
||||||
// so we can simply remove the existing context from the set and
|
// so we can simply remove the existing context from the set and
|
||||||
// call insert again.
|
// call insert again.
|
||||||
|
@ -391,5 +399,5 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
} else {
|
} else {
|
||||||
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoint");
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoint");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,416 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDABreakpoints.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-12T17:15:51+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2007 Ericsson and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> *</font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Ericsson - Initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
|
||||||
|
<a name="line12"> 12: </a>package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.HashSet;</font>
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import java.util.Hashtable;</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import java.util.Map;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import java.util.Set;</font>
|
||||||
|
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.core.resources.IMarker;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.Immutable;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.RequestMonitor;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.AbstractDMContext;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.DMContexts;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.IDMContext;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IBreakpoints;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.dd.dsf.service.AbstractDsfService;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.dd.examples.pda.breakpoints.PDAWatchpoint;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAClearBreakpointCommand;</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDASetBreakpointCommand;</font>
|
||||||
|
<a name="line34"> 34: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAWatchCommand;</font>
|
||||||
|
<a name="line35"> 35: </a><font color="#228B22">import org.eclipse.debug.core.model.IBreakpoint;</font>
|
||||||
|
<a name="line36"> 36: </a><font color="#228B22">import org.osgi.framework.BundleContext;</font>
|
||||||
|
|
||||||
|
<a name="line38"> 38: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line39"> 39: </a><font color="#B22222"> * Initial breakpoint service implementation.</font>
|
||||||
|
<a name="line40"> 40: </a><font color="#B22222"> * Implements the IBreakpoints interface.</font>
|
||||||
|
<a name="line41"> 41: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line42"> 42: </a><strong><font color="#4169E1"><a name="PDABreakpoints"></a>public class PDABreakpoints extends AbstractDsfService implements IBreakpoints</font></strong>
|
||||||
|
<a name="line43"> 43: </a>{
|
||||||
|
<a name="line44"> 44: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line45"> 45: </a><font color="#B22222"> * Context representing a PDA line breakpoint. In PDA debugger, since there is only </font>
|
||||||
|
<a name="line46"> 46: </a><font color="#B22222"> * one file being debugged at a time, a breakpoint is uniquely identified using the </font>
|
||||||
|
<a name="line47"> 47: </a><font color="#B22222"> * line number only.</font>
|
||||||
|
<a name="line48"> 48: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line49"> 49: </a> @Immutable
|
||||||
|
<a name="line50"> 50: </a> private static class BreakpointDMContext extends AbstractDMContext implements IBreakpointDMContext {
|
||||||
|
|
||||||
|
<a name="line52"> 52: </a> final Integer fLine;
|
||||||
|
|
||||||
|
<a name="line54"> 54: </a><strong><font color="#4169E1"> public BreakpointDMContext(String sessionId, PDAProgramDMContext commandControlCtx, Integer line)</font></strong> {
|
||||||
|
<a name="line55"> 55: </a> super(sessionId, new IDMContext[] { commandControlCtx });
|
||||||
|
<a name="line56"> 56: </a> fLine = line;
|
||||||
|
<a name="line57"> 57: </a> }
|
||||||
|
|
||||||
|
<a name="line59"> 59: </a> @Override
|
||||||
|
<a name="line60"> 60: </a><strong><font color="#4169E1"> public boolean equals(Object obj)</font></strong> {
|
||||||
|
<a name="line61"> 61: </a> <font color="#4169E1">return</font> baseEquals(obj) && (fLine.equals(((BreakpointDMContext) obj).fLine));
|
||||||
|
<a name="line62"> 62: </a> }
|
||||||
|
|
||||||
|
<a name="line64"> 64: </a> @Override
|
||||||
|
<a name="line65"> 65: </a><strong><font color="#4169E1"> public int hashCode()</font></strong> {
|
||||||
|
<a name="line66"> 66: </a> <font color="#4169E1">return</font> baseHashCode() + fLine.hashCode();
|
||||||
|
<a name="line67"> 67: </a> }
|
||||||
|
|
||||||
|
<a name="line69"> 69: </a> @Override
|
||||||
|
<a name="line70"> 70: </a><strong><font color="#4169E1"> public String toString()</font></strong> {
|
||||||
|
<a name="line71"> 71: </a> <font color="#4169E1">return</font> baseToString() + <font color="#666666">".breakpoint("</font> + fLine + <font color="#666666">")"</font>; <font color="#B22222">//$NON-NLS-1$//$NON-NLS-2$*/</font>
|
||||||
|
<a name="line72"> 72: </a> }
|
||||||
|
<a name="line73"> 73: </a> }
|
||||||
|
|
||||||
|
<a name="line75"> 75: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line76"> 76: </a><font color="#B22222"> * Context representing a watch point. In PDA debugger, a watchpoint is </font>
|
||||||
|
<a name="line77"> 77: </a><font color="#B22222"> * uniquely identified using the function and variable.</font>
|
||||||
|
<a name="line78"> 78: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line79"> 79: </a> @Immutable
|
||||||
|
<a name="line80"> 80: </a> private static class WatchpointDMContext extends AbstractDMContext implements IBreakpointDMContext {
|
||||||
|
<a name="line81"> 81: </a> final String fFunction;
|
||||||
|
<a name="line82"> 82: </a> final String fVariable;
|
||||||
|
|
||||||
|
<a name="line84"> 84: </a><strong><font color="#4169E1"> public WatchpointDMContext(String sessionId, PDAProgramDMContext commandControlCtx, String function, </font></strong>
|
||||||
|
<a name="line85"> 85: </a><strong><font color="#4169E1"> String variable)</font></strong>
|
||||||
|
<a name="line86"> 86: </a> {
|
||||||
|
<a name="line87"> 87: </a> super(sessionId, new IDMContext[] { commandControlCtx });
|
||||||
|
<a name="line88"> 88: </a> fFunction = function;
|
||||||
|
<a name="line89"> 89: </a> fVariable = variable;
|
||||||
|
<a name="line90"> 90: </a> }
|
||||||
|
|
||||||
|
<a name="line92"> 92: </a> @Override
|
||||||
|
<a name="line93"> 93: </a><strong><font color="#4169E1"> public boolean equals(Object obj)</font></strong> {
|
||||||
|
<a name="line94"> 94: </a> <font color="#4169E1">if</font> (baseEquals(obj)) {
|
||||||
|
<a name="line95"> 95: </a> WatchpointDMContext watchpointCtx = (WatchpointDMContext)obj;
|
||||||
|
<a name="line96"> 96: </a> <font color="#4169E1">return</font> fFunction.equals(watchpointCtx.fFunction) && fVariable.equals(watchpointCtx.fVariable);
|
||||||
|
<a name="line97"> 97: </a> }
|
||||||
|
<a name="line98"> 98: </a> <font color="#4169E1">return</font> false;
|
||||||
|
<a name="line99"> 99: </a> }
|
||||||
|
|
||||||
|
<a name="line101">101: </a> @Override
|
||||||
|
<a name="line102">102: </a><strong><font color="#4169E1"> public int hashCode()</font></strong> {
|
||||||
|
<a name="line103">103: </a> <font color="#4169E1">return</font> baseHashCode() + fFunction.hashCode() + fVariable.hashCode();
|
||||||
|
<a name="line104">104: </a> }
|
||||||
|
|
||||||
|
<a name="line106">106: </a> @Override
|
||||||
|
<a name="line107">107: </a><strong><font color="#4169E1"> public String toString()</font></strong> {
|
||||||
|
<a name="line108">108: </a> <font color="#4169E1">return</font> baseToString() + <font color="#666666">".watchpoint("</font> + fFunction + <font color="#666666">"::"</font> + fVariable + <font color="#666666">")"</font>;
|
||||||
|
<a name="line109">109: </a> }
|
||||||
|
<a name="line110">110: </a> }
|
||||||
|
|
||||||
|
<a name="line112">112: </a> <font color="#B22222">// Attribute names</font>
|
||||||
|
<a name="line113">113: </a> public static final String ATTR_BREAKPOINT_TYPE = PDAPlugin.PLUGIN_ID + <font color="#666666">".pdaBreakpointType"</font>; <font color="#B22222">//$NON-NLS-1$</font>
|
||||||
|
<a name="line114">114: </a> public static final String PDA_LINE_BREAKPOINT = <font color="#666666">"breakpoint"</font>; <font color="#B22222">//$NON-NLS-1$</font>
|
||||||
|
<a name="line115">115: </a> public static final String PDA_WATCHPOINT = <font color="#666666">"watchpoint"</font>; <font color="#B22222">//$NON-NLS-1$</font>
|
||||||
|
<a name="line116">116: </a> public static final String ATTR_PROGRAM_PATH = PDAPlugin.PLUGIN_ID + <font color="#666666">".pdaProgramPath"</font>; <font color="#B22222">//$NON-NLS-1$</font>
|
||||||
|
|
||||||
|
<a name="line118">118: </a> <font color="#B22222">// Services</font>
|
||||||
|
<a name="line119">119: </a> private PDACommandControl fCommandControl;
|
||||||
|
|
||||||
|
<a name="line121">121: </a> <font color="#B22222">// Breakpoints currently installed</font>
|
||||||
|
<a name="line122">122: </a> private Set<IBreakpointDMContext> fBreakpoints = new HashSet<IBreakpointDMContext>();
|
||||||
|
|
||||||
|
<a name="line124">124: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line125">125: </a><font color="#B22222"> * The service constructor</font>
|
||||||
|
<a name="line126">126: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line127">127: </a><font color="#B22222"> * @param session The debugging session this service belongs to.</font>
|
||||||
|
<a name="line128">128: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line129">129: </a><strong><font color="#4169E1"> public PDABreakpoints(DsfSession session)</font></strong> {
|
||||||
|
<a name="line130">130: </a> super(session);
|
||||||
|
<a name="line131">131: </a> }
|
||||||
|
|
||||||
|
<a name="line133">133: </a> @Override
|
||||||
|
<a name="line134">134: </a><strong><font color="#4169E1"> public void initialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line135">135: </a> super.initialize(new RequestMonitor(getExecutor(), rm) {
|
||||||
|
<a name="line136">136: </a> @Override
|
||||||
|
<a name="line137">137: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line138">138: </a> doInitialize(rm);
|
||||||
|
<a name="line139">139: </a> }
|
||||||
|
<a name="line140">140: </a> });
|
||||||
|
<a name="line141">141: </a> }
|
||||||
|
|
||||||
|
<a name="line143">143: </a><strong><font color="#4169E1"> private void doInitialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line144">144: </a> <font color="#B22222">// Get the services references</font>
|
||||||
|
<a name="line145">145: </a> fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
|
||||||
|
<a name="line147">147: </a> <font color="#B22222">// Register this service</font>
|
||||||
|
<a name="line148">148: </a> register(new String[] { IBreakpoints.class.getName(), PDABreakpoints.class.getName() },
|
||||||
|
<a name="line149">149: </a> new Hashtable<String, String>());
|
||||||
|
|
||||||
|
<a name="line151">151: </a> rm.done();
|
||||||
|
<a name="line152">152: </a> }
|
||||||
|
|
||||||
|
<a name="line154">154: </a> @Override
|
||||||
|
<a name="line155">155: </a><strong><font color="#4169E1"> public void shutdown(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line156">156: </a> unregister();
|
||||||
|
<a name="line157">157: </a> rm.done();
|
||||||
|
<a name="line158">158: </a> }
|
||||||
|
|
||||||
|
<a name="line160">160: </a> @Override
|
||||||
|
<a name="line161">161: </a><strong><font color="#4169E1"> protected BundleContext getBundleContext()</font></strong> {
|
||||||
|
<a name="line162">162: </a> <font color="#4169E1">return</font> PDAPlugin.getBundleContext();
|
||||||
|
<a name="line163">163: </a> }
|
||||||
|
|
||||||
|
<a name="line165">165: </a> public void getBreakpoints(final IBreakpointsTargetDMContext context, final DataRequestMonitor<IBreakpointDMContext[]> rm) {
|
||||||
|
<a name="line166">166: </a> <font color="#B22222">// Validate the context</font>
|
||||||
|
<a name="line167">167: </a> <font color="#4169E1">if</font> (!fCommandControl.getProgramDMContext().equals(context)) {
|
||||||
|
<a name="line168">168: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Invalid breakpoints target context"</font>);
|
||||||
|
<a name="line169">169: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line170">170: </a> }
|
||||||
|
|
||||||
|
<a name="line172">172: </a> rm.setData(fBreakpoints.toArray(new IBreakpointDMContext[fBreakpoints.size()]));
|
||||||
|
<a name="line173">173: </a> rm.done();
|
||||||
|
<a name="line174">174: </a> }
|
||||||
|
|
||||||
|
<a name="line176">176: </a> public void getBreakpointDMData(IBreakpointDMContext dmc, DataRequestMonitor<IBreakpointDMData> rm) {
|
||||||
|
<a name="line177">177: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Retrieving breakpoint data is not supported"</font>);
|
||||||
|
<a name="line178">178: </a> }
|
||||||
|
|
||||||
|
<a name="line180">180: </a> public void insertBreakpoint(IBreakpointsTargetDMContext context, Map<String, Object> attributes,
|
||||||
|
<a name="line181">181: </a> DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
|
<a name="line182">182: </a> {
|
||||||
|
<a name="line183">183: </a> Boolean enabled = (Boolean)attributes.get(IBreakpoint.ENABLED);
|
||||||
|
<a name="line184">184: </a> <font color="#4169E1">if</font> (enabled != null && !enabled.booleanValue()) {
|
||||||
|
<a name="line185">185: </a> <font color="#B22222">// If the breakpoint is disabled, just fail the request. </font>
|
||||||
|
<a name="line186">186: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"Breakpoint is disabled"</font>);
|
||||||
|
<a name="line187">187: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line188">188: </a> String type = (String) attributes.get(ATTR_BREAKPOINT_TYPE);
|
||||||
|
|
||||||
|
<a name="line190">190: </a> <font color="#4169E1">if</font> (PDA_LINE_BREAKPOINT.equals(type)) {
|
||||||
|
<a name="line191">191: </a> <font color="#B22222">// Retrieve the PDA program context from the context given in the </font>
|
||||||
|
<a name="line192">192: </a> <font color="#B22222">// argument. This service is typically only called by the </font>
|
||||||
|
<a name="line193">193: </a> <font color="#B22222">// breakpoints mediator, which was called with the program context</font>
|
||||||
|
<a name="line194">194: </a> <font color="#B22222">// in the services initialization sequence. So checking if </font>
|
||||||
|
<a name="line195">195: </a> <font color="#B22222">// programCtx != null is mostly a formality.</font>
|
||||||
|
<a name="line196">196: </a> PDAProgramDMContext programCtx = DMContexts.getAncestorOfType(context, PDAProgramDMContext.class);
|
||||||
|
<a name="line197">197: </a> <font color="#4169E1">if</font> (programCtx != null) {
|
||||||
|
<a name="line198">198: </a> doInsertBreakpoint(programCtx, attributes, rm);
|
||||||
|
<a name="line199">199: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line200">200: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Unknown breakpoint type"</font>);
|
||||||
|
<a name="line201">201: </a> }
|
||||||
|
<a name="line202">202: </a> }
|
||||||
|
<a name="line203">203: </a> <font color="#4169E1">else</font> <font color="#4169E1">if</font> (PDA_WATCHPOINT.equals(type)) {
|
||||||
|
<a name="line204">204: </a> doInsertWatchpoint(attributes, rm);
|
||||||
|
<a name="line205">205: </a> }
|
||||||
|
<a name="line206">206: </a> <font color="#4169E1">else</font> {
|
||||||
|
<a name="line207">207: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"Unknown breakpoint type"</font>);
|
||||||
|
<a name="line208">208: </a> }
|
||||||
|
<a name="line209">209: </a> }
|
||||||
|
<a name="line210">210: </a> }
|
||||||
|
|
||||||
|
<a name="line212">212: </a> private void doInsertBreakpoint(PDAProgramDMContext programCtx, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
|
<a name="line213">213: </a> {
|
||||||
|
<a name="line214">214: </a> <font color="#B22222">// Compare the program path in the breakpoint with the path in the PDA </font>
|
||||||
|
<a name="line215">215: </a> <font color="#B22222">// program context. Only insert the breakpoint if the program matches. </font>
|
||||||
|
<a name="line216">216: </a> String program = (String)attributes.get(ATTR_PROGRAM_PATH);
|
||||||
|
<a name="line217">217: </a> <font color="#4169E1">if</font> (!programCtx.getProgram().equals(program)) {
|
||||||
|
<a name="line218">218: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"Invalid file name"</font>);
|
||||||
|
<a name="line219">219: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line220">220: </a> }
|
||||||
|
|
||||||
|
<a name="line222">222: </a> <font color="#B22222">// Retrieve the line.</font>
|
||||||
|
<a name="line223">223: </a> Integer line = (Integer)attributes.get(IMarker.LINE_NUMBER);
|
||||||
|
<a name="line224">224: </a> <font color="#4169E1">if</font> (line == null) {
|
||||||
|
<a name="line225">225: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"No breakpoint line specified"</font>);
|
||||||
|
<a name="line226">226: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line227">227: </a> }
|
||||||
|
|
||||||
|
<a name="line229">229: </a> <font color="#B22222">// Create a new breakpoint context object and check that it's not </font>
|
||||||
|
<a name="line230">230: </a> <font color="#B22222">// installed already. PDA can only track a single breakpoint at a </font>
|
||||||
|
<a name="line231">231: </a> <font color="#B22222">// given line, attempting to set the second breakpoint should fail.</font>
|
||||||
|
<a name="line232">232: </a> final BreakpointDMContext breakpointCtx =
|
||||||
|
<a name="line233">233: </a> new BreakpointDMContext(getSession().getId(), fCommandControl.getProgramDMContext(), line);
|
||||||
|
<a name="line234">234: </a> <font color="#4169E1">if</font> (fBreakpoints.contains(breakpointCtx)) {
|
||||||
|
<a name="line235">235: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"Breakpoint already set"</font>);
|
||||||
|
<a name="line236">236: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line237">237: </a> }
|
||||||
|
|
||||||
|
<a name="line239">239: </a> <font color="#B22222">// Add the new breakpoint context to the list of known breakpoints. </font>
|
||||||
|
<a name="line240">240: </a> <font color="#B22222">// Adding it here, before the set command is completed will prevent </font>
|
||||||
|
<a name="line241">241: </a> <font color="#B22222">// a possibility of a second breakpoint being installed in the same </font>
|
||||||
|
<a name="line242">242: </a> <font color="#B22222">// location while this breakpoint is being processed. It will also</font>
|
||||||
|
<a name="line243">243: </a> <font color="#B22222">// allow the breakpoint to be removed or updated even while it is </font>
|
||||||
|
<a name="line244">244: </a> <font color="#B22222">// still being processed here.</font>
|
||||||
|
<a name="line245">245: </a> fBreakpoints.add(breakpointCtx);
|
||||||
|
<a name="line246">246: </a> fCommandControl.queueCommand(
|
||||||
|
<a name="line247">247: </a> new PDASetBreakpointCommand(fCommandControl.getProgramDMContext(), line),
|
||||||
|
<a name="line248">248: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line249">249: </a> @Override
|
||||||
|
<a name="line250">250: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line251">251: </a> rm.setData(breakpointCtx);
|
||||||
|
<a name="line252">252: </a> rm.done();
|
||||||
|
<a name="line253">253: </a> }
|
||||||
|
|
||||||
|
<a name="line255">255: </a> @Override
|
||||||
|
<a name="line256">256: </a><strong><font color="#4169E1"> protected void handleErrorOrCancel()</font></strong> {
|
||||||
|
<a name="line257">257: </a> <font color="#B22222">// If inserting of the breakpoint failed, remove it from</font>
|
||||||
|
<a name="line258">258: </a> <font color="#B22222">// the set of installed breakpoints.</font>
|
||||||
|
<a name="line259">259: </a> fBreakpoints.remove(breakpointCtx);
|
||||||
|
<a name="line260">260: </a> super.handleErrorOrCancel();
|
||||||
|
<a name="line261">261: </a> }
|
||||||
|
<a name="line262">262: </a> });
|
||||||
|
<a name="line263">263: </a> }
|
||||||
|
|
||||||
|
<a name="line265">265: </a> private void doInsertWatchpoint(final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
|
<a name="line266">266: </a> {
|
||||||
|
<a name="line267">267: </a> String function = (String)attributes.get(PDAWatchpoint.FUNCTION_NAME);
|
||||||
|
<a name="line268">268: </a> <font color="#4169E1">if</font> (function == null) {
|
||||||
|
<a name="line269">269: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"No function specified"</font>);
|
||||||
|
<a name="line270">270: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line271">271: </a> }
|
||||||
|
|
||||||
|
<a name="line273">273: </a> String variable = (String)attributes.get(PDAWatchpoint.VAR_NAME);
|
||||||
|
<a name="line274">274: </a> <font color="#4169E1">if</font> (variable == null) {
|
||||||
|
<a name="line275">275: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"No variable specified"</font>);
|
||||||
|
<a name="line276">276: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line277">277: </a> }
|
||||||
|
|
||||||
|
<a name="line279">279: </a> Boolean isAccess = (Boolean)attributes.get(PDAWatchpoint.ACCESS);
|
||||||
|
<a name="line280">280: </a> isAccess = isAccess != null ? isAccess : Boolean.FALSE;
|
||||||
|
|
||||||
|
<a name="line282">282: </a> Boolean isModification = (Boolean)attributes.get(PDAWatchpoint.MODIFICATION);
|
||||||
|
<a name="line283">283: </a> isModification = isModification != null ? isModification : Boolean.FALSE;
|
||||||
|
|
||||||
|
<a name="line285">285: </a> <font color="#B22222">// Create a new watchpoint context object and check that it's not </font>
|
||||||
|
<a name="line286">286: </a> <font color="#B22222">// installed already. PDA can only track a single watchpoint for a given</font>
|
||||||
|
<a name="line287">287: </a> <font color="#B22222">// function::variable, attempting to set the second breakpoint should fail.</font>
|
||||||
|
<a name="line288">288: </a> final WatchpointDMContext watchpointCtx =
|
||||||
|
<a name="line289">289: </a> new WatchpointDMContext(getSession().getId(), fCommandControl.getProgramDMContext(), function, variable);
|
||||||
|
<a name="line290">290: </a> <font color="#4169E1">if</font> (fBreakpoints.contains(watchpointCtx)) {
|
||||||
|
<a name="line291">291: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"Watchpoint already set"</font>);
|
||||||
|
<a name="line292">292: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line293">293: </a> }
|
||||||
|
|
||||||
|
<a name="line295">295: </a> <font color="#B22222">// Determine the watch operation to perform.</font>
|
||||||
|
<a name="line296">296: </a> PDAWatchCommand.WatchOperation watchOperation = PDAWatchCommand.WatchOperation.NONE;
|
||||||
|
<a name="line297">297: </a> <font color="#4169E1">if</font> (isAccess && isModification) {
|
||||||
|
<a name="line298">298: </a> watchOperation = PDAWatchCommand.WatchOperation.BOTH;
|
||||||
|
<a name="line299">299: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (isAccess) {
|
||||||
|
<a name="line300">300: </a> watchOperation = PDAWatchCommand.WatchOperation.READ;
|
||||||
|
<a name="line301">301: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (isModification) {
|
||||||
|
<a name="line302">302: </a> watchOperation = PDAWatchCommand.WatchOperation.WRITE;
|
||||||
|
<a name="line303">303: </a> }
|
||||||
|
|
||||||
|
<a name="line305">305: </a> <font color="#B22222">// Add the new breakpoint context to the list of known breakpoints. </font>
|
||||||
|
<a name="line306">306: </a> <font color="#B22222">// Adding it here, before the set command is completed will prevent </font>
|
||||||
|
<a name="line307">307: </a> <font color="#B22222">// a possibility of a second breakpoint being installed in the same </font>
|
||||||
|
<a name="line308">308: </a> <font color="#B22222">// location while this breakpoint is being processed. It will also</font>
|
||||||
|
<a name="line309">309: </a> <font color="#B22222">// allow the breakpoint to be removed or updated even while it is </font>
|
||||||
|
<a name="line310">310: </a> <font color="#B22222">// still being processed here.</font>
|
||||||
|
<a name="line311">311: </a> fBreakpoints.add(watchpointCtx);
|
||||||
|
<a name="line312">312: </a> fCommandControl.queueCommand(
|
||||||
|
<a name="line313">313: </a> new PDAWatchCommand(fCommandControl.getProgramDMContext(), function, variable, watchOperation),
|
||||||
|
<a name="line314">314: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line315">315: </a> @Override
|
||||||
|
<a name="line316">316: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line317">317: </a> rm.setData(watchpointCtx);
|
||||||
|
<a name="line318">318: </a> rm.done();
|
||||||
|
<a name="line319">319: </a> }
|
||||||
|
|
||||||
|
<a name="line321">321: </a> @Override
|
||||||
|
<a name="line322">322: </a><strong><font color="#4169E1"> protected void handleErrorOrCancel()</font></strong> {
|
||||||
|
<a name="line323">323: </a> <font color="#B22222">// Since the command failed, we need to remove the breakpoint from </font>
|
||||||
|
<a name="line324">324: </a> <font color="#B22222">// the existing breakpoint set.</font>
|
||||||
|
<a name="line325">325: </a> fBreakpoints.remove(watchpointCtx);
|
||||||
|
<a name="line326">326: </a> super.handleErrorOrCancel();
|
||||||
|
<a name="line327">327: </a> }
|
||||||
|
<a name="line328">328: </a> });
|
||||||
|
<a name="line329">329: </a> }
|
||||||
|
|
||||||
|
<a name="line331">331: </a><strong><font color="#4169E1"> public void removeBreakpoint(IBreakpointDMContext bpCtx, RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line332">332: </a> <font color="#4169E1">if</font> (!fBreakpoints.contains(bpCtx)) {
|
||||||
|
<a name="line333">333: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"Breakpoint already removed"</font>);
|
||||||
|
<a name="line334">334: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line335">335: </a> }
|
||||||
|
|
||||||
|
<a name="line337">337: </a> <font color="#4169E1">if</font> (bpCtx instanceof BreakpointDMContext) {
|
||||||
|
<a name="line338">338: </a> doRemoveBreakpoint((BreakpointDMContext)bpCtx, rm);
|
||||||
|
<a name="line339">339: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (bpCtx instanceof WatchpointDMContext) {
|
||||||
|
<a name="line340">340: </a> doRemoveWatchpoint((WatchpointDMContext)bpCtx, rm);
|
||||||
|
<a name="line341">341: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line342">342: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Invalid breakpoint"</font>);
|
||||||
|
<a name="line343">343: </a> }
|
||||||
|
<a name="line344">344: </a> }
|
||||||
|
|
||||||
|
<a name="line346">346: </a><strong><font color="#4169E1"> private void doRemoveBreakpoint(BreakpointDMContext bpCtx, RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line347">347: </a> <font color="#B22222">// Remove the breakpoint from the table right away, so that even when </font>
|
||||||
|
<a name="line348">348: </a> <font color="#B22222">// the remove is being processed, a new breakpoint can be created at the same </font>
|
||||||
|
<a name="line349">349: </a> <font color="#B22222">// location.</font>
|
||||||
|
<a name="line350">350: </a> fBreakpoints.remove(bpCtx);
|
||||||
|
|
||||||
|
<a name="line352">352: </a> fCommandControl.queueCommand(
|
||||||
|
<a name="line353">353: </a> new PDAClearBreakpointCommand(fCommandControl.getProgramDMContext(), bpCtx.fLine),
|
||||||
|
<a name="line354">354: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
|
<a name="line355">355: </a> }
|
||||||
|
|
||||||
|
<a name="line357">357: </a><strong><font color="#4169E1"> private void doRemoveWatchpoint(WatchpointDMContext bpCtx, RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line358">358: </a> fBreakpoints.remove(bpCtx);
|
||||||
|
|
||||||
|
<a name="line360">360: </a> <font color="#B22222">// Watchpoints are cleared using the same command, but with a "no watch" operation</font>
|
||||||
|
<a name="line361">361: </a> fCommandControl.queueCommand(
|
||||||
|
<a name="line362">362: </a> new PDAWatchCommand(
|
||||||
|
<a name="line363">363: </a> fCommandControl.getProgramDMContext(), bpCtx.fFunction, bpCtx.fVariable, PDAWatchCommand.WatchOperation.NONE),
|
||||||
|
<a name="line364">364: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
|
<a name="line365">365: </a> }
|
||||||
|
|
||||||
|
<a name="line367">367: </a> public void updateBreakpoint(final IBreakpointDMContext bpCtx, Map<String, Object> attributes, final RequestMonitor rm) {
|
||||||
|
<a name="line368">368: </a> <font color="#4169E1">if</font> (!fBreakpoints.contains(bpCtx)) {
|
||||||
|
<a name="line369">369: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"Breakpoint not installed"</font>);
|
||||||
|
<a name="line370">370: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line371">371: </a> }
|
||||||
|
|
||||||
|
<a name="line373">373: </a> <font color="#4169E1">if</font> (bpCtx instanceof BreakpointDMContext) {
|
||||||
|
<a name="line374">374: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Modifying PDA breakpoints is not supported"</font>);
|
||||||
|
<a name="line375">375: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (bpCtx instanceof WatchpointDMContext) {
|
||||||
|
<a name="line376">376: </a> WatchpointDMContext wpCtx = (WatchpointDMContext)bpCtx;
|
||||||
|
<a name="line377">377: </a> <font color="#4169E1">if</font> (!wpCtx.fFunction.equals(attributes.get(PDAWatchpoint.FUNCTION_NAME)) ||
|
||||||
|
<a name="line378">378: </a> !wpCtx.fVariable.equals(attributes.get(PDAWatchpoint.VAR_NAME)) )
|
||||||
|
<a name="line379">379: </a> {
|
||||||
|
<a name="line380">380: </a> PDAPlugin.failRequest(rm, REQUEST_FAILED, <font color="#666666">"Cannot modify watchpoint function or variable"</font>);
|
||||||
|
<a name="line381">381: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line382">382: </a> }
|
||||||
|
<a name="line383">383: </a>
|
||||||
|
<a name="line384">384: </a> <font color="#B22222">// PDA debugger can only track one watchpoint in the same location, </font>
|
||||||
|
<a name="line385">385: </a> <font color="#B22222">// so we can simply remove the existing context from the set and </font>
|
||||||
|
<a name="line386">386: </a> <font color="#B22222">// call insert again. </font>
|
||||||
|
<a name="line387">387: </a> fBreakpoints.remove(bpCtx);
|
||||||
|
<a name="line388">388: </a> doInsertWatchpoint(
|
||||||
|
<a name="line389">389: </a> attributes,
|
||||||
|
<a name="line390">390: </a> new DataRequestMonitor<IBreakpointDMContext>(getExecutor(), rm) {
|
||||||
|
<a name="line391">391: </a> @Override
|
||||||
|
<a name="line392">392: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line393">393: </a> <font color="#B22222">// The inserted watchpoint context will equal the </font>
|
||||||
|
<a name="line394">394: </a> <font color="#B22222">// current context.</font>
|
||||||
|
<a name="line395">395: </a> assert bpCtx.equals(getData());
|
||||||
|
<a name="line396">396: </a> rm.done();
|
||||||
|
<a name="line397">397: </a> }
|
||||||
|
<a name="line398">398: </a> });
|
||||||
|
<a name="line399">399: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line400">400: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Invalid breakpoint"</font>);
|
||||||
|
<a name="line401">401: </a> }
|
||||||
|
<a name="line402">402: </a> }
|
||||||
|
<a name="line403">403: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -83,15 +83,20 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
private final List<IEventListener> fEventListeners = new ArrayList<IEventListener>();
|
private final List<IEventListener> fEventListeners = new ArrayList<IEventListener>();
|
||||||
|
|
||||||
// Sockets for communicating with PDA debugger
|
// Sockets for communicating with PDA debugger
|
||||||
|
@ThreadSafe
|
||||||
private Socket fRequestSocket;
|
private Socket fRequestSocket;
|
||||||
|
@ThreadSafe
|
||||||
private PrintWriter fRequestWriter;
|
private PrintWriter fRequestWriter;
|
||||||
|
@ThreadSafe
|
||||||
private BufferedReader fRequestReader;
|
private BufferedReader fRequestReader;
|
||||||
|
@ThreadSafe
|
||||||
private Socket fEventSocket;
|
private Socket fEventSocket;
|
||||||
|
@ThreadSafe
|
||||||
private BufferedReader fEventReader;
|
private BufferedReader fEventReader;
|
||||||
|
|
||||||
// Jobs servicing the sockets.
|
// Jobs servicing the sockets.
|
||||||
private EventDispatchJob fEventDispatchJob;
|
private EventDispatchJob fEventDispatchJob;
|
||||||
private CommandSendJob fRequestJob;
|
private CommandSendJob fCommandSendJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command control constructor.
|
* Command control constructor.
|
||||||
|
@ -170,8 +175,8 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
fEventDispatchJob = new EventDispatchJob();
|
fEventDispatchJob = new EventDispatchJob();
|
||||||
fEventDispatchJob.schedule();
|
fEventDispatchJob.schedule();
|
||||||
|
|
||||||
fRequestJob = new CommandSendJob();
|
fCommandSendJob = new CommandSendJob();
|
||||||
fRequestJob.schedule();
|
fCommandSendJob.schedule();
|
||||||
|
|
||||||
socketsInitializeRm.done();
|
socketsInitializeRm.done();
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
|
|
|
@ -0,0 +1,547 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDACommandControl.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-10T17:13:55+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a>package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
|
<a name="line3"> 3: </a><font color="#228B22">import java.io.BufferedReader;</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#228B22">import java.io.IOException;</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#228B22">import java.io.InputStreamReader;</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#228B22">import java.io.PrintWriter;</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#228B22">import java.net.Socket;</font>
|
||||||
|
<a name="line8"> 8: </a><font color="#228B22">import java.net.UnknownHostException;</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#228B22">import java.util.ArrayList;</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#228B22">import java.util.Hashtable;</font>
|
||||||
|
<a name="line11"> 11: </a><font color="#228B22">import java.util.Iterator;</font>
|
||||||
|
<a name="line12"> 12: </a><font color="#228B22">import java.util.LinkedList;</font>
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import java.util.List;</font>
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.concurrent.BlockingQueue;</font>
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import java.util.concurrent.LinkedBlockingQueue;</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import java.util.concurrent.RejectedExecutionException;</font>
|
||||||
|
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.core.runtime.IProgressMonitor;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.core.runtime.IStatus;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.core.runtime.Status;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.core.runtime.jobs.Job;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DsfRunnable;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.RequestMonitor;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.ThreadSafe;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.command.ICommand;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.command.ICommandControl;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.command.ICommandListener;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.command.ICommandResult;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.command.IEventListener;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.dd.dsf.service.AbstractDsfService;</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line34"> 34: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.AbstractPDACommand;</font>
|
||||||
|
<a name="line35"> 35: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;</font>
|
||||||
|
<a name="line36"> 36: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAExitCommand;</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#228B22">import org.osgi.framework.BundleContext;</font>
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line40"> 40: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line41"> 41: </a><font color="#B22222"> * Service that handles communication with a PDA debugger back end. </font>
|
||||||
|
<a name="line42"> 42: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line43"> 43: </a><strong><font color="#4169E1"><a name="PDACommandControl"></a>public class PDACommandControl extends AbstractDsfService implements ICommandControl </font></strong>{
|
||||||
|
|
||||||
|
<a name="line45"> 45: </a> <font color="#B22222">// Structure used to store command information in services internal queues.</font>
|
||||||
|
<a name="line46"> 46: </a> private static class CommandHandle {
|
||||||
|
<a name="line47"> 47: </a> final private AbstractPDACommand<PDACommandResult> fCommand;
|
||||||
|
<a name="line48"> 48: </a> final private DataRequestMonitor<PDACommandResult> fRequestMonitor;
|
||||||
|
<a name="line49"> 49: </a>
|
||||||
|
<a name="line50"> 50: </a> CommandHandle(AbstractPDACommand<PDACommandResult> c, DataRequestMonitor<PDACommandResult> rm) {
|
||||||
|
<a name="line51"> 51: </a> fCommand = c;
|
||||||
|
<a name="line52"> 52: </a> fRequestMonitor = rm;
|
||||||
|
<a name="line53"> 53: </a> }
|
||||||
|
<a name="line54"> 54: </a> }
|
||||||
|
|
||||||
|
<a name="line56"> 56: </a> <font color="#B22222">// Parameters that the command control is created with.</font>
|
||||||
|
<a name="line57"> 57: </a> final private String fProgram;
|
||||||
|
<a name="line58"> 58: </a> final private int fRequestPort;
|
||||||
|
<a name="line59"> 59: </a> final private int fEventPort;
|
||||||
|
|
||||||
|
<a name="line61"> 61: </a> <font color="#B22222">// Queue of commands waiting to be sent to the debugger. As long as commands</font>
|
||||||
|
<a name="line62"> 62: </a> <font color="#B22222">// are in this queue, they can still be removed by clients. </font>
|
||||||
|
<a name="line63"> 63: </a> private final List<CommandHandle> fCommandQueue = new LinkedList<CommandHandle>();
|
||||||
|
<a name="line64"> 64: </a>
|
||||||
|
<a name="line65"> 65: </a> <font color="#B22222">// Queue of commands that are being sent to the debugger. This queue is read</font>
|
||||||
|
<a name="line66"> 66: </a> <font color="#B22222">// by the send job, so as soon as commands are inserted into this queue, they can</font>
|
||||||
|
<a name="line67"> 67: </a> <font color="#B22222">// be considered as sent.</font>
|
||||||
|
<a name="line68"> 68: </a> @ThreadSafe
|
||||||
|
<a name="line69"> 69: </a> private final BlockingQueue<CommandHandle> fTxCommands = new LinkedBlockingQueue<CommandHandle>();
|
||||||
|
<a name="line70"> 70: </a>
|
||||||
|
<a name="line71"> 71: </a> <font color="#B22222">// Flag indicating that the PDA debugger started</font>
|
||||||
|
<a name="line72"> 72: </a> private boolean fStarted = false;
|
||||||
|
<a name="line73"> 73: </a>
|
||||||
|
<a name="line74"> 74: </a> <font color="#B22222">// Flag indicating that the PDA debugger has been disconnected </font>
|
||||||
|
<a name="line75"> 75: </a> @ThreadSafe
|
||||||
|
<a name="line76"> 76: </a> private boolean fTerminated = false;
|
||||||
|
<a name="line77"> 77: </a>
|
||||||
|
<a name="line78"> 78: </a> <font color="#B22222">// Data Model context of this command control. </font>
|
||||||
|
<a name="line79"> 79: </a> private PDAProgramDMContext fDMContext;
|
||||||
|
|
||||||
|
<a name="line81"> 81: </a> <font color="#B22222">// Synchronous listeners for commands and events.</font>
|
||||||
|
<a name="line82"> 82: </a> private final List<ICommandListener> fCommandListeners = new ArrayList<ICommandListener>();
|
||||||
|
<a name="line83"> 83: </a> private final List<IEventListener> fEventListeners = new ArrayList<IEventListener>();
|
||||||
|
<a name="line84"> 84: </a>
|
||||||
|
<a name="line85"> 85: </a> <font color="#B22222">// Sockets for communicating with PDA debugger </font>
|
||||||
|
<a name="line86"> 86: </a> @ThreadSafe
|
||||||
|
<a name="line87"> 87: </a> private Socket fRequestSocket;
|
||||||
|
<a name="line88"> 88: </a> @ThreadSafe
|
||||||
|
<a name="line89"> 89: </a> private PrintWriter fRequestWriter;
|
||||||
|
<a name="line90"> 90: </a> @ThreadSafe
|
||||||
|
<a name="line91"> 91: </a> private BufferedReader fRequestReader;
|
||||||
|
<a name="line92"> 92: </a> @ThreadSafe
|
||||||
|
<a name="line93"> 93: </a> private Socket fEventSocket;
|
||||||
|
<a name="line94"> 94: </a> @ThreadSafe
|
||||||
|
<a name="line95"> 95: </a> private BufferedReader fEventReader;
|
||||||
|
|
||||||
|
<a name="line97"> 97: </a> <font color="#B22222">// Jobs servicing the sockets.</font>
|
||||||
|
<a name="line98"> 98: </a> private EventDispatchJob fEventDispatchJob;
|
||||||
|
<a name="line99"> 99: </a> private CommandSendJob fCommandSendJob;
|
||||||
|
<a name="line100">100: </a>
|
||||||
|
<a name="line101">101: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line102">102: </a><font color="#B22222"> * Command control constructor. </font>
|
||||||
|
<a name="line103">103: </a><font color="#B22222"> * @param session The DSF session that this service is a part of. </font>
|
||||||
|
<a name="line104">104: </a><font color="#B22222"> * @param requestPort Port number for sending PDA commands.</font>
|
||||||
|
<a name="line105">105: </a><font color="#B22222"> * @param eventPort Port for listening to PDA events.</font>
|
||||||
|
<a name="line106">106: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line107">107: </a><strong><font color="#4169E1"> public PDACommandControl(DsfSession session, String program, int requestPort, int eventPort)</font></strong> {
|
||||||
|
<a name="line108">108: </a> super(session);
|
||||||
|
<a name="line109">109: </a> fProgram = program;
|
||||||
|
<a name="line110">110: </a> fRequestPort = requestPort;
|
||||||
|
<a name="line111">111: </a> fEventPort = eventPort;
|
||||||
|
<a name="line112">112: </a> }
|
||||||
|
<a name="line113">113: </a>
|
||||||
|
<a name="line114">114: </a> @Override
|
||||||
|
<a name="line115">115: </a><strong><font color="#4169E1"> public void initialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line116">116: </a> <font color="#B22222">// Call the super-class to perform initialization first.</font>
|
||||||
|
<a name="line117">117: </a> super.initialize( new RequestMonitor(getExecutor(), rm) {
|
||||||
|
<a name="line118">118: </a> @Override
|
||||||
|
<a name="line119">119: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line120">120: </a> doInitialize(rm);
|
||||||
|
<a name="line121">121: </a> }
|
||||||
|
<a name="line122">122: </a> });
|
||||||
|
<a name="line123">123: </a> }
|
||||||
|
|
||||||
|
<a name="line125">125: </a><strong><font color="#4169E1"> private void doInitialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line126">126: </a> <font color="#B22222">// Create the control's data model context.</font>
|
||||||
|
<a name="line127">127: </a> fDMContext = new PDAProgramDMContext(getSession().getId(), fProgram);
|
||||||
|
|
||||||
|
<a name="line129">129: </a> <font color="#B22222">// Add a listener for PDA events to track the started/terminated state.</font>
|
||||||
|
<a name="line130">130: </a> addEventListener(new IEventListener() {
|
||||||
|
<a name="line131">131: </a><strong><font color="#4169E1"> public void eventReceived(Object output)</font></strong> {
|
||||||
|
<a name="line132">132: </a> <font color="#4169E1">if</font> (<font color="#666666">"started"</font>.equals(output)) {
|
||||||
|
<a name="line133">133: </a> setStarted();
|
||||||
|
<a name="line134">134: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (<font color="#666666">"terminated"</font>.equals(output)) {
|
||||||
|
<a name="line135">135: </a> setTerminated();
|
||||||
|
<a name="line136">136: </a> }
|
||||||
|
<a name="line137">137: </a> }
|
||||||
|
<a name="line138">138: </a> });
|
||||||
|
<a name="line139">139: </a>
|
||||||
|
<a name="line140">140: </a> <font color="#B22222">// Request monitor that will be invoked when the socket initialization is</font>
|
||||||
|
<a name="line141">141: </a> <font color="#B22222">// completed. </font>
|
||||||
|
<a name="line142">142: </a> final RequestMonitor socketsInitializeRm = new RequestMonitor(getExecutor(), rm) {
|
||||||
|
<a name="line143">143: </a> @Override
|
||||||
|
<a name="line144">144: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line145">145: </a> <font color="#B22222">// Register the service with OSGi as the last step in initialization of </font>
|
||||||
|
<a name="line146">146: </a> <font color="#B22222">// the service.</font>
|
||||||
|
<a name="line147">147: </a> register(
|
||||||
|
<a name="line148">148: </a> new String[]{ ICommandControl.class.getName(), PDACommandControl.class.getName() },
|
||||||
|
<a name="line149">149: </a> new Hashtable<String,String>());
|
||||||
|
<a name="line150">150: </a> rm.done();
|
||||||
|
<a name="line151">151: </a> }
|
||||||
|
<a name="line152">152: </a> };
|
||||||
|
<a name="line153">153: </a>
|
||||||
|
<a name="line154">154: </a> <font color="#B22222">// To avoid blocking the DSF dispatch thread use a job to initialize communication sockets. </font>
|
||||||
|
<a name="line155">155: </a> new Job(<font color="#666666">"PDA Initialize"</font>) {
|
||||||
|
<a name="line156">156: </a> @Override
|
||||||
|
<a name="line157">157: </a><strong><font color="#4169E1"> protected IStatus run(IProgressMonitor monitor)</font></strong> {
|
||||||
|
<a name="line158">158: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line159">159: </a> <font color="#B22222">// give interpreter a chance to start</font>
|
||||||
|
<a name="line160">160: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line161">161: </a> Thread.sleep(1000);
|
||||||
|
<a name="line162">162: </a> } <font color="#4169E1">catch</font> (InterruptedException e) {
|
||||||
|
<a name="line163">163: </a> }
|
||||||
|
<a name="line164">164: </a> fRequestSocket = new Socket(<font color="#666666">"localhost"</font>, fRequestPort);
|
||||||
|
<a name="line165">165: </a> fRequestWriter = new PrintWriter(fRequestSocket.getOutputStream());
|
||||||
|
<a name="line166">166: </a> fRequestReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream()));
|
||||||
|
<a name="line167">167: </a> <font color="#B22222">// give interpreter a chance to open next socket</font>
|
||||||
|
<a name="line168">168: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line169">169: </a> Thread.sleep(1000);
|
||||||
|
<a name="line170">170: </a> } <font color="#4169E1">catch</font> (InterruptedException e) {
|
||||||
|
<a name="line171">171: </a> }
|
||||||
|
<a name="line172">172: </a> fEventSocket = new Socket(<font color="#666666">"localhost"</font>, fEventPort);
|
||||||
|
<a name="line173">173: </a> fEventReader = new BufferedReader(new InputStreamReader(fEventSocket.getInputStream()));
|
||||||
|
|
||||||
|
<a name="line175">175: </a> fEventDispatchJob = new EventDispatchJob();
|
||||||
|
<a name="line176">176: </a> fEventDispatchJob.schedule();
|
||||||
|
<a name="line177">177: </a>
|
||||||
|
<a name="line178">178: </a> fCommandSendJob = new CommandSendJob();
|
||||||
|
<a name="line179">179: </a> fCommandSendJob.schedule();
|
||||||
|
|
||||||
|
<a name="line181">181: </a> socketsInitializeRm.done();
|
||||||
|
<a name="line182">182: </a> } <font color="#4169E1">catch</font> (UnknownHostException e) {
|
||||||
|
<a name="line183">183: </a> socketsInitializeRm.setStatus(new Status(
|
||||||
|
<a name="line184">184: </a> IStatus.ERROR, PDAPlugin.PLUGIN_ID, REQUEST_FAILED, <font color="#666666">"Unable to connect to PDA VM"</font>, e));
|
||||||
|
<a name="line185">185: </a> socketsInitializeRm.done();
|
||||||
|
<a name="line186">186: </a> } <font color="#4169E1">catch</font> (IOException e) {
|
||||||
|
<a name="line187">187: </a> socketsInitializeRm.setStatus(new Status(
|
||||||
|
<a name="line188">188: </a> IStatus.ERROR, PDAPlugin.PLUGIN_ID, REQUEST_FAILED, <font color="#666666">"Unable to connect to PDA VM"</font>, e));
|
||||||
|
<a name="line189">189: </a> socketsInitializeRm.done();
|
||||||
|
<a name="line190">190: </a> }
|
||||||
|
<a name="line191">191: </a> <font color="#4169E1">return</font> Status.OK_STATUS;
|
||||||
|
<a name="line192">192: </a> }
|
||||||
|
<a name="line193">193: </a> }.schedule();
|
||||||
|
<a name="line194">194: </a> }
|
||||||
|
|
||||||
|
<a name="line196">196: </a> @Override
|
||||||
|
<a name="line197">197: </a><strong><font color="#4169E1"> public void shutdown(final RequestMonitor requestMonitor)</font></strong> {
|
||||||
|
<a name="line198">198: </a> <font color="#B22222">// Unregister the service first, so that clients may no longer gain access to it.</font>
|
||||||
|
<a name="line199">199: </a> unregister();
|
||||||
|
<a name="line200">200: </a>
|
||||||
|
<a name="line201">201: </a> <font color="#4169E1">if</font> (!isTerminated()) {
|
||||||
|
<a name="line202">202: </a> <font color="#B22222">// If the debugger is still connected, send it the exit command.</font>
|
||||||
|
<a name="line203">203: </a> terminate(new RequestMonitor(getExecutor(), requestMonitor) {
|
||||||
|
<a name="line204">204: </a> @Override
|
||||||
|
<a name="line205">205: </a><strong><font color="#4169E1"> protected void handleCompleted()</font></strong> {
|
||||||
|
<a name="line206">206: </a> <font color="#B22222">// Mark the command control as terminated.</font>
|
||||||
|
<a name="line207">207: </a> setTerminated();
|
||||||
|
|
||||||
|
<a name="line209">209: </a> <font color="#B22222">// Ignore any error resulting from the exit command. </font>
|
||||||
|
<a name="line210">210: </a> <font color="#B22222">// Errors will most likely result if the PDA process is </font>
|
||||||
|
<a name="line211">211: </a> <font color="#B22222">// already terminated.</font>
|
||||||
|
<a name="line212">212: </a> requestMonitor.done();
|
||||||
|
<a name="line213">213: </a> }
|
||||||
|
<a name="line214">214: </a> });
|
||||||
|
<a name="line215">215: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line216">216: </a> requestMonitor.done();
|
||||||
|
<a name="line217">217: </a> }
|
||||||
|
<a name="line218">218: </a> }
|
||||||
|
|
||||||
|
<a name="line220">220: </a> @Override
|
||||||
|
<a name="line221">221: </a><strong><font color="#4169E1"> protected BundleContext getBundleContext()</font></strong> {
|
||||||
|
<a name="line222">222: </a> <font color="#4169E1">return</font> PDAPlugin.getBundleContext();
|
||||||
|
<a name="line223">223: </a> }
|
||||||
|
<a name="line224">224: </a>
|
||||||
|
<a name="line225">225: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line226">226: </a><font color="#B22222"> * Job that services the send command queue. </font>
|
||||||
|
<a name="line227">227: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line228">228: </a> private class CommandSendJob extends Job {
|
||||||
|
<a name="line229">229: </a> CommandSendJob() {
|
||||||
|
<a name="line230">230: </a> super(<font color="#666666">"PDA Command Send"</font>);
|
||||||
|
<a name="line231">231: </a> setSystem(true);
|
||||||
|
<a name="line232">232: </a> }
|
||||||
|
<a name="line233">233: </a>
|
||||||
|
<a name="line234">234: </a> @Override
|
||||||
|
<a name="line235">235: </a><strong><font color="#4169E1"> protected IStatus run(IProgressMonitor monitor)</font></strong> {
|
||||||
|
<a name="line236">236: </a> <font color="#4169E1">while</font> (!isTerminated()) {
|
||||||
|
<a name="line237">237: </a> synchronized(fTxCommands) {
|
||||||
|
<a name="line238">238: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line239">239: </a> <font color="#B22222">// Remove comamnd from send queue.</font>
|
||||||
|
<a name="line240">240: </a> final CommandHandle commandHandle = fTxCommands.take();
|
||||||
|
<a name="line241">241: </a>
|
||||||
|
<a name="line242">242: </a> <font color="#B22222">// Send the request to PDA</font>
|
||||||
|
<a name="line243">243: </a> fRequestWriter.println(commandHandle.fCommand.getRequest());
|
||||||
|
<a name="line244">244: </a> fRequestWriter.flush();
|
||||||
|
<a name="line245">245: </a>
|
||||||
|
<a name="line246">246: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line247">247: </a> <font color="#B22222">// wait for reply</font>
|
||||||
|
<a name="line248">248: </a> final String response = fRequestReader.readLine();
|
||||||
|
<a name="line249">249: </a>
|
||||||
|
<a name="line250">250: </a> <font color="#B22222">// Process the reply in the executor thread.</font>
|
||||||
|
<a name="line251">251: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line252">252: </a> getExecutor().execute(new DsfRunnable() {
|
||||||
|
<a name="line253">253: </a><strong><font color="#4169E1"> public void run()</font></strong> {
|
||||||
|
<a name="line254">254: </a> processCommandDone(commandHandle, response);
|
||||||
|
<a name="line255">255: </a> }
|
||||||
|
<a name="line256">256: </a> });
|
||||||
|
<a name="line257">257: </a> } <font color="#4169E1">catch</font> (RejectedExecutionException e) {
|
||||||
|
<a name="line258">258: </a> <font color="#B22222">// Acceptable race condition may see the session shut down</font>
|
||||||
|
<a name="line259">259: </a> <font color="#B22222">// while we're waiting for command response. Still complete</font>
|
||||||
|
<a name="line260">260: </a> <font color="#B22222">// the request monitor.</font>
|
||||||
|
<a name="line261">261: </a> assert isTerminated();
|
||||||
|
<a name="line262">262: </a> assert isTerminated();
|
||||||
|
<a name="line263">263: </a> PDAPlugin.failRequest(commandHandle.fRequestMonitor, REQUEST_FAILED, <font color="#666666">"Command control shut down."</font>);
|
||||||
|
<a name="line264">264: </a> }
|
||||||
|
<a name="line265">265: </a> } <font color="#4169E1">catch</font> (final IOException e) {
|
||||||
|
<a name="line266">266: </a> <font color="#B22222">// Process error it in the executor thread</font>
|
||||||
|
<a name="line267">267: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line268">268: </a> getExecutor().execute(new DsfRunnable() {
|
||||||
|
<a name="line269">269: </a><strong><font color="#4169E1"> public void run()</font></strong> {
|
||||||
|
<a name="line270">270: </a> processCommandException(commandHandle, e);
|
||||||
|
<a name="line271">271: </a> }
|
||||||
|
<a name="line272">272: </a> });
|
||||||
|
<a name="line273">273: </a> } <font color="#4169E1">catch</font> (RejectedExecutionException re) {
|
||||||
|
<a name="line274">274: </a> <font color="#B22222">// Acceptable race condition... see above</font>
|
||||||
|
<a name="line275">275: </a> assert isTerminated();
|
||||||
|
<a name="line276">276: </a> PDAPlugin.failRequest(commandHandle.fRequestMonitor, REQUEST_FAILED, <font color="#666666">"Command control shut down."</font>);
|
||||||
|
<a name="line277">277: </a> }
|
||||||
|
<a name="line278">278: </a> }
|
||||||
|
<a name="line279">279: </a> } <font color="#4169E1">catch</font> (InterruptedException e) {
|
||||||
|
<a name="line280">280: </a> <font color="#4169E1">break</font>; <font color="#B22222">// Shutting down.</font>
|
||||||
|
<a name="line281">281: </a> }
|
||||||
|
<a name="line282">282: </a> }
|
||||||
|
<a name="line283">283: </a> }
|
||||||
|
<a name="line284">284: </a> <font color="#4169E1">return</font> Status.OK_STATUS;
|
||||||
|
<a name="line285">285: </a> }
|
||||||
|
<a name="line286">286: </a>
|
||||||
|
<a name="line287">287: </a> }
|
||||||
|
<a name="line288">288: </a>
|
||||||
|
<a name="line289">289: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line290">290: </a><font color="#B22222"> * Job that services the PDA event socket.</font>
|
||||||
|
<a name="line291">291: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line292">292: </a><strong><font color="#4169E1"><a name="EventDispatchJob"></a> class EventDispatchJob extends Job </font></strong>{
|
||||||
|
<a name="line293">293: </a>
|
||||||
|
<a name="line294">294: </a><strong><font color="#4169E1"> public EventDispatchJob()</font></strong> {
|
||||||
|
<a name="line295">295: </a> super(<font color="#666666">"PDA Event Listner"</font>);
|
||||||
|
<a name="line296">296: </a> setSystem(true);
|
||||||
|
<a name="line297">297: </a> }
|
||||||
|
|
||||||
|
<a name="line299">299: </a> @Override
|
||||||
|
<a name="line300">300: </a><strong><font color="#4169E1"> protected IStatus run(IProgressMonitor monitor)</font></strong> {
|
||||||
|
<a name="line301">301: </a> <font color="#4169E1">while</font> (!isTerminated()) {
|
||||||
|
<a name="line302">302: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line303">303: </a> <font color="#B22222">// Wait for an event.</font>
|
||||||
|
<a name="line304">304: </a> final String event = fEventReader.readLine();
|
||||||
|
<a name="line305">305: </a> <font color="#4169E1">if</font> (event != null) {
|
||||||
|
<a name="line306">306: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line307">307: </a> <font color="#B22222">// Process the event in executor thread.</font>
|
||||||
|
<a name="line308">308: </a> getExecutor().execute(new DsfRunnable() {
|
||||||
|
<a name="line309">309: </a><strong><font color="#4169E1"> public void run()</font></strong> {
|
||||||
|
<a name="line310">310: </a> processEventReceived(event);
|
||||||
|
<a name="line311">311: </a> }
|
||||||
|
<a name="line312">312: </a> });
|
||||||
|
<a name="line313">313: </a> } <font color="#4169E1">catch</font> (RejectedExecutionException e) {}
|
||||||
|
<a name="line314">314: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line315">315: </a> <font color="#4169E1">break</font>;
|
||||||
|
<a name="line316">316: </a> }
|
||||||
|
<a name="line317">317: </a> } <font color="#4169E1">catch</font> (IOException e) {
|
||||||
|
<a name="line318">318: </a> <font color="#4169E1">break</font>;
|
||||||
|
<a name="line319">319: </a> }
|
||||||
|
<a name="line320">320: </a> }
|
||||||
|
<a name="line321">321: </a> <font color="#4169E1">if</font> (!isTerminated()) {
|
||||||
|
<a name="line322">322: </a> <font color="#B22222">// Exception from the event socket is an indicator that the PDA debugger</font>
|
||||||
|
<a name="line323">323: </a> <font color="#B22222">// has exited. Call setTerminated() in executor thread.</font>
|
||||||
|
<a name="line324">324: </a> <font color="#4169E1">try</font> {
|
||||||
|
<a name="line325">325: </a> getExecutor().execute(new DsfRunnable() {
|
||||||
|
<a name="line326">326: </a><strong><font color="#4169E1"> public void run()</font></strong> {
|
||||||
|
<a name="line327">327: </a> setTerminated();
|
||||||
|
<a name="line328">328: </a> }
|
||||||
|
<a name="line329">329: </a> });
|
||||||
|
<a name="line330">330: </a> } <font color="#4169E1">catch</font> (RejectedExecutionException e) {}
|
||||||
|
<a name="line331">331: </a> }
|
||||||
|
<a name="line332">332: </a> <font color="#4169E1">return</font> Status.OK_STATUS;
|
||||||
|
<a name="line333">333: </a> }
|
||||||
|
<a name="line334">334: </a>
|
||||||
|
<a name="line335">335: </a> }
|
||||||
|
<a name="line336">336: </a>
|
||||||
|
<a name="line337">337: </a> public <V extends ICommandResult> void queueCommand(ICommand<V> command, DataRequestMonitor<V> rm) {
|
||||||
|
<a name="line338">338: </a> <font color="#4169E1">if</font> (command instanceof AbstractPDACommand<?>) {
|
||||||
|
<a name="line339">339: </a> <font color="#B22222">// Cast from command with "<V extends ICommandResult>" to a more concrete</font>
|
||||||
|
<a name="line340">340: </a> <font color="#B22222">// type to use internally in the command control.</font>
|
||||||
|
<a name="line341">341: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>)
|
||||||
|
<a name="line342">342: </a> AbstractPDACommand<PDACommandResult> pdaCommand = (AbstractPDACommand<PDACommandResult>)command;
|
||||||
|
<a name="line343">343: </a>
|
||||||
|
<a name="line344">344: </a> <font color="#B22222">// Similarly, cast the request monitor to a more concrete type.</font>
|
||||||
|
<a name="line345">345: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>)
|
||||||
|
<a name="line346">346: </a> DataRequestMonitor<PDACommandResult> pdaRM = (DataRequestMonitor<PDACommandResult>)rm;
|
||||||
|
|
||||||
|
<a name="line348">348: </a> <font color="#B22222">// Add the command to the queue and notify command listeners.</font>
|
||||||
|
<a name="line349">349: </a> fCommandQueue.add( new CommandHandle(pdaCommand, pdaRM) );
|
||||||
|
<a name="line350">350: </a> <font color="#4169E1">for</font> (ICommandListener listener : fCommandListeners) {
|
||||||
|
<a name="line351">351: </a> listener.commandQueued(command);
|
||||||
|
<a name="line352">352: </a> }
|
||||||
|
<a name="line353">353: </a>
|
||||||
|
<a name="line354">354: </a> <font color="#B22222">// In a separate dispatch cycle. This allows command listeners to repond to the </font>
|
||||||
|
<a name="line355">355: </a> <font color="#B22222">// command queued event. </font>
|
||||||
|
<a name="line356">356: </a> getExecutor().execute(new DsfRunnable() {
|
||||||
|
<a name="line357">357: </a><strong><font color="#4169E1"> public void run()</font></strong> {
|
||||||
|
<a name="line358">358: </a> processQueues();
|
||||||
|
<a name="line359">359: </a> }
|
||||||
|
<a name="line360">360: </a> });
|
||||||
|
<a name="line361">361: </a>
|
||||||
|
<a name="line362">362: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line363">363: </a> PDAPlugin.failRequest(rm, INTERNAL_ERROR, <font color="#666666">"Unrecognized command: "</font> + command);
|
||||||
|
<a name="line364">364: </a> }
|
||||||
|
<a name="line365">365: </a> }
|
||||||
|
|
||||||
|
<a name="line367">367: </a> public void cancelCommand(ICommand<? extends ICommandResult> command) {
|
||||||
|
<a name="line368">368: </a> <font color="#B22222">// This debugger is unable of canceling commands once they have </font>
|
||||||
|
<a name="line369">369: </a> <font color="#B22222">// been sent.</font>
|
||||||
|
<a name="line370">370: </a> }
|
||||||
|
|
||||||
|
<a name="line372">372: </a> public void removeCommand(ICommand<? extends ICommandResult> command) {
|
||||||
|
<a name="line373">373: </a> <font color="#B22222">// Removes given command from the queue and notify the listeners</font>
|
||||||
|
<a name="line374">374: </a> <font color="#4169E1">for</font> (Iterator<CommandHandle> itr = fCommandQueue.iterator(); itr.hasNext();) {
|
||||||
|
<a name="line375">375: </a> CommandHandle handle = itr.next();
|
||||||
|
<a name="line376">376: </a> <font color="#4169E1">if</font> (command.equals(handle.fCommand)) {
|
||||||
|
<a name="line377">377: </a> itr.remove();
|
||||||
|
<a name="line378">378: </a> <font color="#4169E1">for</font> (ICommandListener listener : fCommandListeners) {
|
||||||
|
<a name="line379">379: </a> listener.commandRemoved(command);
|
||||||
|
<a name="line380">380: </a> }
|
||||||
|
<a name="line381">381: </a> }
|
||||||
|
<a name="line382">382: </a> }
|
||||||
|
<a name="line383">383: </a> }
|
||||||
|
<a name="line384">384: </a>
|
||||||
|
<a name="line385">385: </a><strong><font color="#4169E1"> public void addCommandListener(ICommandListener processor)</font></strong> {
|
||||||
|
<a name="line386">386: </a> fCommandListeners.add(processor);
|
||||||
|
<a name="line387">387: </a> }
|
||||||
|
<a name="line388">388: </a>
|
||||||
|
<a name="line389">389: </a><strong><font color="#4169E1"> public void removeCommandListener(ICommandListener processor)</font></strong> {
|
||||||
|
<a name="line390">390: </a> fCommandListeners.remove(processor);
|
||||||
|
<a name="line391">391: </a> }
|
||||||
|
<a name="line392">392: </a>
|
||||||
|
<a name="line393">393: </a><strong><font color="#4169E1"> public void addEventListener(IEventListener processor)</font></strong> {
|
||||||
|
<a name="line394">394: </a> fEventListeners.add(processor);
|
||||||
|
<a name="line395">395: </a> }
|
||||||
|
<a name="line396">396: </a>
|
||||||
|
<a name="line397">397: </a><strong><font color="#4169E1"> public void removeEventListener(IEventListener processor)</font></strong> {
|
||||||
|
<a name="line398">398: </a> fEventListeners.remove(processor);
|
||||||
|
<a name="line399">399: </a> }
|
||||||
|
|
||||||
|
<a name="line401">401: </a><strong><font color="#4169E1"> private void processCommandDone(CommandHandle handle, String response)</font></strong> {
|
||||||
|
<a name="line402">402: </a> <font color="#B22222">// Trace to debug output.</font>
|
||||||
|
<a name="line403">403: </a> PDAPlugin.debug(<font color="#666666">"R: "</font> + response);
|
||||||
|
<a name="line404">404: </a>
|
||||||
|
<a name="line405">405: </a> <font color="#B22222">// Given the PDA response string, create the result using the command</font>
|
||||||
|
<a name="line406">406: </a> <font color="#B22222">// that was sent.</font>
|
||||||
|
<a name="line407">407: </a> PDACommandResult result = handle.fCommand.createResult(response);
|
||||||
|
<a name="line408">408: </a>
|
||||||
|
<a name="line409">409: </a> <font color="#B22222">// Set the result to the request monitor and return to sender.</font>
|
||||||
|
<a name="line410">410: </a> <font color="#B22222">// Note: as long as PDA sends some response, a PDA command will never</font>
|
||||||
|
<a name="line411">411: </a> <font color="#B22222">// return an error.</font>
|
||||||
|
<a name="line412">412: </a> handle.fRequestMonitor.setData(result);
|
||||||
|
<a name="line413">413: </a> handle.fRequestMonitor.done();
|
||||||
|
|
||||||
|
<a name="line415">415: </a> <font color="#B22222">// Notify listeners of the response</font>
|
||||||
|
<a name="line416">416: </a> <font color="#4169E1">for</font> (ICommandListener listener : fCommandListeners) {
|
||||||
|
<a name="line417">417: </a> listener.commandDone(handle.fCommand, result);
|
||||||
|
<a name="line418">418: </a> }
|
||||||
|
<a name="line419">419: </a>
|
||||||
|
<a name="line420">420: </a> <font color="#B22222">// Process next command in queue.</font>
|
||||||
|
<a name="line421">421: </a> processQueues();
|
||||||
|
<a name="line422">422: </a> }
|
||||||
|
|
||||||
|
<a name="line424">424: </a>
|
||||||
|
<a name="line425">425: </a><strong><font color="#4169E1"> private void processCommandException(CommandHandle handle, Throwable exception)</font></strong> {
|
||||||
|
<a name="line426">426: </a>
|
||||||
|
<a name="line427">427: </a> <font color="#B22222">// If sending a command resulted in an exception, notify the client.</font>
|
||||||
|
<a name="line428">428: </a> handle.fRequestMonitor.setStatus(new Status(
|
||||||
|
<a name="line429">429: </a> IStatus.ERROR, PDAPlugin.PLUGIN_ID, REQUEST_FAILED, <font color="#666666">"Exception reading request response"</font>, exception));
|
||||||
|
<a name="line430">430: </a> handle.fRequestMonitor.done();
|
||||||
|
|
||||||
|
<a name="line432">432: </a> <font color="#B22222">// Notify listeners also.</font>
|
||||||
|
<a name="line433">433: </a> <font color="#4169E1">for</font> (ICommandListener listener : fCommandListeners) {
|
||||||
|
<a name="line434">434: </a> listener.commandDone(handle.fCommand, null);
|
||||||
|
<a name="line435">435: </a> }
|
||||||
|
<a name="line436">436: </a> }
|
||||||
|
|
||||||
|
<a name="line438">438: </a><strong><font color="#4169E1"> private void processEventReceived(String event)</font></strong> {
|
||||||
|
<a name="line439">439: </a> <font color="#B22222">// Notify the listeners only.</font>
|
||||||
|
<a name="line440">440: </a> PDAPlugin.debug(<font color="#666666">"E: "</font> + event);
|
||||||
|
<a name="line441">441: </a> <font color="#4169E1">for</font> (IEventListener listener : fEventListeners) {
|
||||||
|
<a name="line442">442: </a> listener.eventReceived(event);
|
||||||
|
<a name="line443">443: </a> }
|
||||||
|
<a name="line444">444: </a> }
|
||||||
|
<a name="line445">445: </a>
|
||||||
|
<a name="line446">446: </a><strong><font color="#4169E1"> private synchronized void processQueues()</font></strong> {
|
||||||
|
<a name="line447">447: </a> <font color="#4169E1">if</font> (isTerminated()) {
|
||||||
|
<a name="line448">448: </a> <font color="#B22222">// If the PDA debugger is terminated. Return all submitted commands </font>
|
||||||
|
<a name="line449">449: </a> <font color="#B22222">// with an error.</font>
|
||||||
|
<a name="line450">450: </a> <font color="#4169E1">for</font> (CommandHandle handle : fCommandQueue) {
|
||||||
|
<a name="line451">451: </a> handle.fRequestMonitor.setStatus(new Status(
|
||||||
|
<a name="line452">452: </a> IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_STATE, <font color="#666666">"Command control is terminated"</font>, null));
|
||||||
|
<a name="line453">453: </a> handle.fRequestMonitor.done();
|
||||||
|
<a name="line454">454: </a> }
|
||||||
|
<a name="line455">455: </a> fCommandQueue.clear();
|
||||||
|
<a name="line456">456: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (fStarted && fTxCommands.isEmpty() && !fCommandQueue.isEmpty()) {
|
||||||
|
<a name="line457">457: </a> <font color="#B22222">// Process the queues if:</font>
|
||||||
|
<a name="line458">458: </a> <font color="#B22222">// - the PDA debugger has started,</font>
|
||||||
|
<a name="line459">459: </a> <font color="#B22222">// - there are no pending commands in the send queue,</font>
|
||||||
|
<a name="line460">460: </a> <font color="#B22222">// - and there are commands waiting to be sent.</font>
|
||||||
|
<a name="line461">461: </a> CommandHandle handle = fCommandQueue.remove(0);
|
||||||
|
<a name="line462">462: </a> fTxCommands.add(handle);
|
||||||
|
<a name="line463">463: </a> PDAPlugin.debug(<font color="#666666">"C: "</font> + handle.fCommand.getRequest());
|
||||||
|
<a name="line464">464: </a> <font color="#4169E1">for</font> (ICommandListener listener : fCommandListeners) {
|
||||||
|
<a name="line465">465: </a> listener.commandSent(handle.fCommand);
|
||||||
|
<a name="line466">466: </a> }
|
||||||
|
<a name="line467">467: </a> }
|
||||||
|
<a name="line468">468: </a> }
|
||||||
|
<a name="line469">469: </a>
|
||||||
|
<a name="line470">470: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line471">471: </a><font color="#B22222"> * Return the PDA Debugger top-level Data Model context. </font>
|
||||||
|
<a name="line472">472: </a><font color="#B22222"> * @see PDAProgramDMContext</font>
|
||||||
|
<a name="line473">473: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line474">474: </a> @ThreadSafe
|
||||||
|
<a name="line475">475: </a><strong><font color="#4169E1"> public PDAProgramDMContext getProgramDMContext()</font></strong> {
|
||||||
|
<a name="line476">476: </a> <font color="#4169E1">return</font> fDMContext;
|
||||||
|
<a name="line477">477: </a> }
|
||||||
|
|
||||||
|
<a name="line479">479: </a><strong><font color="#4169E1"> private void setStarted()</font></strong> {
|
||||||
|
<a name="line480">480: </a> <font color="#B22222">// Mark the command control as started and ready to process commands.</font>
|
||||||
|
<a name="line481">481: </a> fStarted = true;
|
||||||
|
<a name="line482">482: </a>
|
||||||
|
<a name="line483">483: </a> <font color="#B22222">// Process any commands which may have been queued before the </font>
|
||||||
|
<a name="line484">484: </a> processQueues();
|
||||||
|
|
||||||
|
<a name="line486">486: </a> <font color="#B22222">// Issue a data model event.</font>
|
||||||
|
<a name="line487">487: </a> getSession().dispatchEvent(new PDAStartedEvent(getProgramDMContext()), getProperties());
|
||||||
|
<a name="line488">488: </a> }
|
||||||
|
<a name="line489">489: </a>
|
||||||
|
<a name="line490">490: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line491">491: </a><font color="#B22222"> * Returns whether the PDA debugger has started and is processing commands.</font>
|
||||||
|
<a name="line492">492: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line493">493: </a><strong><font color="#4169E1"> public boolean isStarted()</font></strong> {
|
||||||
|
<a name="line494">494: </a> <font color="#4169E1">return</font> fStarted;
|
||||||
|
<a name="line495">495: </a> }
|
||||||
|
<a name="line496">496: </a>
|
||||||
|
<a name="line497">497: </a> @ThreadSafe
|
||||||
|
<a name="line498">498: </a><strong><font color="#4169E1"> private synchronized void setTerminated()</font></strong> {
|
||||||
|
<a name="line499">499: </a> <font color="#B22222">// Set terminated may be called more than once: by event listener thread, </font>
|
||||||
|
<a name="line500">500: </a> <font color="#B22222">// by the terminate command, etc, so protect against sending events multiple</font>
|
||||||
|
<a name="line501">501: </a> <font color="#B22222">// times.</font>
|
||||||
|
<a name="line502">502: </a> <font color="#4169E1">if</font> (!fTerminated) {
|
||||||
|
<a name="line503">503: </a> fTerminated = true;
|
||||||
|
<a name="line504">504: </a>
|
||||||
|
<a name="line505">505: </a> <font color="#B22222">// Process any waiting commands, they all should return with an error.</font>
|
||||||
|
<a name="line506">506: </a> processQueues();
|
||||||
|
<a name="line507">507: </a>
|
||||||
|
<a name="line508">508: </a> <font color="#B22222">// Issue a data model event.</font>
|
||||||
|
<a name="line509">509: </a> getSession().dispatchEvent(new PDATerminatedEvent(getProgramDMContext()), getProperties());
|
||||||
|
<a name="line510">510: </a> }
|
||||||
|
<a name="line511">511: </a> }
|
||||||
|
|
||||||
|
<a name="line513">513: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line514">514: </a><font color="#B22222"> * Returns whether the PDA debugger has been terminated.</font>
|
||||||
|
<a name="line515">515: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line516">516: </a> @ThreadSafe
|
||||||
|
<a name="line517">517: </a><strong><font color="#4169E1"> public synchronized boolean isTerminated()</font></strong> {
|
||||||
|
<a name="line518">518: </a> <font color="#4169E1">return</font> fTerminated;
|
||||||
|
<a name="line519">519: </a> }
|
||||||
|
|
||||||
|
<a name="line521">521: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line522">522: </a><font color="#B22222"> * Sends a command to PDA debugger to terminate.</font>
|
||||||
|
<a name="line523">523: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line524">524: </a><strong><font color="#4169E1"> public void terminate(RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line525">525: </a> <font color="#4169E1">if</font> (!isTerminated()) {
|
||||||
|
<a name="line526">526: </a> queueCommand(
|
||||||
|
<a name="line527">527: </a> new PDAExitCommand(fDMContext),
|
||||||
|
<a name="line528">528: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
|
<a name="line529">529: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line530">530: </a> <font color="#B22222">// If already terminated, indicate success.</font>
|
||||||
|
<a name="line531">531: </a> rm.done();
|
||||||
|
<a name="line532">532: </a> }
|
||||||
|
<a name="line533">533: </a> }
|
||||||
|
<a name="line534">534: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,386 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDAExpressions.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-02-22T00:00:40+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2008 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import java.util.Hashtable;</font>
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.Map;</font>
|
||||||
|
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.Immutable;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.RequestMonitor;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.AbstractDMContext;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.DMContexts;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.IDMContext;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IExpressions;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IStack;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMContext;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.command.CommandCache;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.dd.dsf.service.AbstractDsfService;</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfServiceEventHandler;</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line34"> 34: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line35"> 35: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;</font>
|
||||||
|
<a name="line36"> 36: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDASetVarCommand;</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAVarCommand;</font>
|
||||||
|
<a name="line38"> 38: </a><font color="#228B22">import org.osgi.framework.BundleContext;</font>
|
||||||
|
|
||||||
|
<a name="line40"> 40: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line41"> 41: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line42"> 42: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line43"> 43: </a><strong><font color="#4169E1"><a name="PDAExpressions"></a>public class PDAExpressions extends AbstractDsfService implements IExpressions </font></strong>{
|
||||||
|
|
||||||
|
<a name="line45"> 45: </a> @Immutable
|
||||||
|
<a name="line46"> 46: </a> private static class ExpressionDMContext extends AbstractDMContext implements IExpressionDMContext {
|
||||||
|
|
||||||
|
<a name="line48"> 48: </a> final private String fExpression;
|
||||||
|
<a name="line49"> 49: </a>
|
||||||
|
<a name="line50"> 50: </a> ExpressionDMContext(String sessionId, IFrameDMContext frameDmc, String expressin) {
|
||||||
|
<a name="line51"> 51: </a> super(sessionId, new IDMContext[] { frameDmc });
|
||||||
|
<a name="line52"> 52: </a> fExpression = expressin;
|
||||||
|
<a name="line53"> 53: </a> }
|
||||||
|
|
||||||
|
<a name="line55"> 55: </a><strong><font color="#4169E1"> public String getExpression()</font></strong> {
|
||||||
|
<a name="line56"> 56: </a> <font color="#4169E1">return</font> fExpression;
|
||||||
|
<a name="line57"> 57: </a> }
|
||||||
|
<a name="line58"> 58: </a>
|
||||||
|
<a name="line59"> 59: </a> @Override
|
||||||
|
<a name="line60"> 60: </a><strong><font color="#4169E1"> public boolean equals(Object other)</font></strong> {
|
||||||
|
<a name="line61"> 61: </a> <font color="#4169E1">return</font> super.baseEquals(other) && ((ExpressionDMContext)other).fExpression.equals(fExpression);
|
||||||
|
<a name="line62"> 62: </a> }
|
||||||
|
<a name="line63"> 63: </a>
|
||||||
|
<a name="line64"> 64: </a> @Override
|
||||||
|
<a name="line65"> 65: </a><strong><font color="#4169E1"> public int hashCode()</font></strong> {
|
||||||
|
<a name="line66"> 66: </a> <font color="#4169E1">return</font> super.baseHashCode() + fExpression.hashCode();
|
||||||
|
<a name="line67"> 67: </a> }
|
||||||
|
<a name="line68"> 68: </a>
|
||||||
|
<a name="line69"> 69: </a> @Override
|
||||||
|
<a name="line70"> 70: </a><strong><font color="#4169E1"> public String toString()</font></strong> {
|
||||||
|
<a name="line71"> 71: </a> <font color="#4169E1">return</font> baseToString() + <font color="#666666">".expression("</font> + fExpression + <font color="#666666">")"</font>;
|
||||||
|
<a name="line72"> 72: </a> }
|
||||||
|
<a name="line73"> 73: </a> }
|
||||||
|
|
||||||
|
<a name="line75"> 75: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line76"> 76: </a><font color="#B22222"> * PDA expressions are simply variables. Only the variable name </font>
|
||||||
|
<a name="line77"> 77: </a><font color="#B22222"> * is relevant for its data.</font>
|
||||||
|
<a name="line78"> 78: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line79"> 79: </a> @Immutable
|
||||||
|
<a name="line80"> 80: </a> private static class ExpressionDMData implements IExpressionDMData {
|
||||||
|
|
||||||
|
<a name="line82"> 82: </a> final private String fExpression;
|
||||||
|
<a name="line83"> 83: </a>
|
||||||
|
<a name="line84"> 84: </a><strong><font color="#4169E1"> public ExpressionDMData(String expression)</font></strong> {
|
||||||
|
<a name="line85"> 85: </a> fExpression = expression;
|
||||||
|
<a name="line86"> 86: </a> }
|
||||||
|
<a name="line87"> 87: </a>
|
||||||
|
<a name="line88"> 88: </a><strong><font color="#4169E1"> public BasicType getBasicType()</font></strong> {
|
||||||
|
<a name="line89"> 89: </a> <font color="#4169E1">return</font> BasicType.basic;
|
||||||
|
<a name="line90"> 90: </a> }
|
||||||
|
|
||||||
|
<a name="line92"> 92: </a><strong><font color="#4169E1"> public String getEncoding()</font></strong> {
|
||||||
|
<a name="line93"> 93: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line94"> 94: </a> }
|
||||||
|
|
||||||
|
<a name="line96"> 96: </a> public Map<String, Integer> getEnumerations() {
|
||||||
|
<a name="line97"> 97: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line98"> 98: </a> }
|
||||||
|
|
||||||
|
<a name="line100">100: </a><strong><font color="#4169E1"> public String getName()</font></strong> {
|
||||||
|
<a name="line101">101: </a> <font color="#4169E1">return</font> fExpression;
|
||||||
|
<a name="line102">102: </a> }
|
||||||
|
|
||||||
|
<a name="line104">104: </a><strong><font color="#4169E1"> public IRegisterDMContext getRegister()</font></strong> {
|
||||||
|
<a name="line105">105: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line106">106: </a> }
|
||||||
|
|
||||||
|
<a name="line108">108: </a><strong><font color="#4169E1"> public String getStringValue()</font></strong> {
|
||||||
|
<a name="line109">109: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line110">110: </a> }
|
||||||
|
|
||||||
|
<a name="line112">112: </a><strong><font color="#4169E1"> public String getTypeId()</font></strong> {
|
||||||
|
<a name="line113">113: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line114">114: </a> }
|
||||||
|
|
||||||
|
<a name="line116">116: </a><strong><font color="#4169E1"> public String getTypeName()</font></strong> {
|
||||||
|
<a name="line117">117: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line118">118: </a> }
|
||||||
|
|
||||||
|
<a name="line120">120: </a> }
|
||||||
|
|
||||||
|
<a name="line122">122: </a> <font color="#B22222">// @see #createExpression()</font>
|
||||||
|
<a name="line123">123: </a> @Immutable
|
||||||
|
<a name="line124">124: </a> private static class InvalidExpressionDMContext extends AbstractDMContext implements IExpressionDMContext {
|
||||||
|
<a name="line125">125: </a> final private String fExpression;
|
||||||
|
<a name="line126">126: </a>
|
||||||
|
<a name="line127">127: </a><strong><font color="#4169E1"> public InvalidExpressionDMContext(String sessionId, IDMContext parent, String expr)</font></strong> {
|
||||||
|
<a name="line128">128: </a> super(sessionId, new IDMContext[] { parent });
|
||||||
|
<a name="line129">129: </a> fExpression = expr;
|
||||||
|
<a name="line130">130: </a> }
|
||||||
|
<a name="line131">131: </a>
|
||||||
|
<a name="line132">132: </a> @Override
|
||||||
|
<a name="line133">133: </a><strong><font color="#4169E1"> public boolean equals(Object other)</font></strong> {
|
||||||
|
<a name="line134">134: </a> <font color="#4169E1">return</font> super.baseEquals(other) &&
|
||||||
|
<a name="line135">135: </a> fExpression == null
|
||||||
|
<a name="line136">136: </a> ? ((InvalidExpressionDMContext) other).getExpression() == null
|
||||||
|
<a name="line137">137: </a> : fExpression.equals(((InvalidExpressionDMContext) other).getExpression());
|
||||||
|
<a name="line138">138: </a> }
|
||||||
|
<a name="line139">139: </a>
|
||||||
|
<a name="line140">140: </a> @Override
|
||||||
|
<a name="line141">141: </a><strong><font color="#4169E1"> public int hashCode()</font></strong> {
|
||||||
|
<a name="line142">142: </a> <font color="#4169E1">return</font> fExpression == null ? super.baseHashCode() : super.baseHashCode() ^ fExpression.hashCode();
|
||||||
|
<a name="line143">143: </a> }
|
||||||
|
<a name="line144">144: </a>
|
||||||
|
<a name="line145">145: </a> @Override
|
||||||
|
<a name="line146">146: </a><strong><font color="#4169E1"> public String toString()</font></strong> {
|
||||||
|
<a name="line147">147: </a> <font color="#4169E1">return</font> baseToString() + <font color="#666666">".invalid_expr["</font> + fExpression + <font color="#666666">"]"</font>;
|
||||||
|
<a name="line148">148: </a> }
|
||||||
|
<a name="line149">149: </a>
|
||||||
|
<a name="line150">150: </a><strong><font color="#4169E1"> public String getExpression()</font></strong> {
|
||||||
|
<a name="line151">151: </a> <font color="#4169E1">return</font> fExpression;
|
||||||
|
<a name="line152">152: </a> }
|
||||||
|
<a name="line153">153: </a> }
|
||||||
|
<a name="line154">154: </a>
|
||||||
|
<a name="line155">155: </a> @Immutable
|
||||||
|
<a name="line156">156: </a> private static class ExpressionChangedDMEvent extends AbstractDMEvent<IExpressionDMContext>
|
||||||
|
<a name="line157">157: </a> implements IExpressionChangedDMEvent
|
||||||
|
<a name="line158">158: </a> {
|
||||||
|
<a name="line159">159: </a> ExpressionChangedDMEvent(IExpressionDMContext expression) {
|
||||||
|
<a name="line160">160: </a> super(expression);
|
||||||
|
<a name="line161">161: </a> }
|
||||||
|
<a name="line162">162: </a> }
|
||||||
|
|
||||||
|
<a name="line164">164: </a>
|
||||||
|
<a name="line165">165: </a> private PDACommandControl fCommandControl;
|
||||||
|
<a name="line166">166: </a> private IStack fStack;
|
||||||
|
|
||||||
|
<a name="line168">168: </a> private CommandCache fCommandCache;
|
||||||
|
|
||||||
|
<a name="line170">170: </a><strong><font color="#4169E1"> public PDAExpressions(DsfSession session)</font></strong> {
|
||||||
|
<a name="line171">171: </a> super(session);
|
||||||
|
<a name="line172">172: </a> }
|
||||||
|
|
||||||
|
<a name="line174">174: </a> @Override
|
||||||
|
<a name="line175">175: </a><strong><font color="#4169E1"> protected BundleContext getBundleContext()</font></strong> {
|
||||||
|
<a name="line176">176: </a> <font color="#4169E1">return</font> PDAPlugin.getBundleContext();
|
||||||
|
<a name="line177">177: </a> }
|
||||||
|
|
||||||
|
<a name="line179">179: </a> @Override
|
||||||
|
<a name="line180">180: </a><strong><font color="#4169E1"> public void initialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line181">181: </a> super.initialize(
|
||||||
|
<a name="line182">182: </a> new RequestMonitor(getExecutor(), rm) {
|
||||||
|
<a name="line183">183: </a> @Override
|
||||||
|
<a name="line184">184: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line185">185: </a> doInitialize(rm);
|
||||||
|
<a name="line186">186: </a> }});
|
||||||
|
<a name="line187">187: </a> }
|
||||||
|
|
||||||
|
<a name="line189">189: </a><strong><font color="#4169E1"> private void doInitialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line190">190: </a> fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
<a name="line191">191: </a> fStack = getServicesTracker().getService(IStack.class);
|
||||||
|
<a name="line192">192: </a> fCommandCache = new CommandCache(fCommandControl);
|
||||||
|
|
||||||
|
<a name="line194">194: </a> getSession().addServiceEventListener(this, null);
|
||||||
|
<a name="line195">195: </a>
|
||||||
|
<a name="line196">196: </a> register(new String[]{IExpressions.class.getName(), PDAExpressions.class.getName()}, new Hashtable<String,String>());
|
||||||
|
<a name="line197">197: </a>
|
||||||
|
<a name="line198">198: </a> rm.done();
|
||||||
|
<a name="line199">199: </a> }
|
||||||
|
|
||||||
|
<a name="line201">201: </a> @Override
|
||||||
|
<a name="line202">202: </a><strong><font color="#4169E1"> public void shutdown(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line203">203: </a> getSession().removeServiceEventListener(this);
|
||||||
|
<a name="line204">204: </a> fCommandCache.reset();
|
||||||
|
<a name="line205">205: </a> super.shutdown(rm);
|
||||||
|
<a name="line206">206: </a> }
|
||||||
|
|
||||||
|
<a name="line208">208: </a> public void canWriteExpression(IExpressionDMContext expressionContext, DataRequestMonitor<Boolean> rm) {
|
||||||
|
<a name="line209">209: </a> rm.setData(true);
|
||||||
|
<a name="line210">210: </a> rm.done();
|
||||||
|
<a name="line211">211: </a> }
|
||||||
|
|
||||||
|
<a name="line213">213: </a><strong><font color="#4169E1"> public IExpressionDMContext createExpression(IDMContext ctx, String expression)</font></strong> {
|
||||||
|
<a name="line214">214: </a> <font color="#B22222">// Create an expression based on the given context and string expression. </font>
|
||||||
|
<a name="line215">215: </a> <font color="#B22222">// The PDA debugger can only evaluate variables as expressions and only</font>
|
||||||
|
<a name="line216">216: </a> <font color="#B22222">// in context of a frame. </font>
|
||||||
|
<a name="line217">217: </a> IFrameDMContext frameCtx = DMContexts.getAncestorOfType(ctx, IFrameDMContext.class);
|
||||||
|
<a name="line218">218: </a> <font color="#4169E1">if</font> (frameCtx != null) {
|
||||||
|
<a name="line219">219: </a> <font color="#4169E1">return</font> new ExpressionDMContext(getSession().getId(), frameCtx, expression);
|
||||||
|
<a name="line220">220: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line221">221: </a> <font color="#B22222">// If a frame cannot be found in context, return an "invalid" </font>
|
||||||
|
<a name="line222">222: </a> <font color="#B22222">// expression context, because a null return value is not allowed.</font>
|
||||||
|
<a name="line223">223: </a> <font color="#B22222">// Evaluating an invalid expression context will always yield an </font>
|
||||||
|
<a name="line224">224: </a> <font color="#B22222">// error.</font>
|
||||||
|
<a name="line225">225: </a> <font color="#4169E1">return</font> new InvalidExpressionDMContext(getSession().getId(), ctx, expression);
|
||||||
|
<a name="line226">226: </a> }
|
||||||
|
<a name="line227">227: </a> }
|
||||||
|
|
||||||
|
<a name="line229">229: </a> public void getBaseExpressions(IExpressionDMContext exprContext, DataRequestMonitor<IExpressionDMContext[]> rm) {
|
||||||
|
<a name="line230">230: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Not supported"</font>);
|
||||||
|
<a name="line231">231: </a> }
|
||||||
|
|
||||||
|
<a name="line233">233: </a> public void getExpressionAddressData(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMAddress> rm) {
|
||||||
|
<a name="line234">234: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Not supported"</font>);
|
||||||
|
<a name="line235">235: </a> }
|
||||||
|
|
||||||
|
<a name="line237">237: </a> public void getExpressionData(final IExpressionDMContext exprCtx, final DataRequestMonitor<IExpressionDMData> rm) {
|
||||||
|
<a name="line238">238: </a> <font color="#B22222">// Since expression data doesn't contain any more information than the </font>
|
||||||
|
<a name="line239">239: </a> <font color="#B22222">// context, it doesn't require any debugger commmands.</font>
|
||||||
|
<a name="line240">240: </a> <font color="#4169E1">if</font> (exprCtx instanceof ExpressionDMContext) {
|
||||||
|
<a name="line241">241: </a> rm.setData(new ExpressionDMData(exprCtx.getExpression()));
|
||||||
|
<a name="line242">242: </a> rm.done();
|
||||||
|
<a name="line243">243: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line244">244: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Invalid expression context "</font> + exprCtx);
|
||||||
|
<a name="line245">245: </a> }
|
||||||
|
<a name="line246">246: </a> }
|
||||||
|
|
||||||
|
<a name="line248">248: </a> public void getSubExpressionCount(IExpressionDMContext exprCtx, DataRequestMonitor<Integer> rm) {
|
||||||
|
<a name="line249">249: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Not supported"</font>);
|
||||||
|
<a name="line250">250: </a> }
|
||||||
|
|
||||||
|
<a name="line252">252: </a> public void getSubExpressions(IExpressionDMContext exprCtx, DataRequestMonitor<IExpressionDMContext[]> rm) {
|
||||||
|
<a name="line253">253: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Not supported"</font>);
|
||||||
|
<a name="line254">254: </a> }
|
||||||
|
|
||||||
|
<a name="line256">256: </a> public void getSubExpressions(IExpressionDMContext exprCtx, int startIndex, int length,
|
||||||
|
<a name="line257">257: </a> DataRequestMonitor<IExpressionDMContext[]> rm)
|
||||||
|
<a name="line258">258: </a> {
|
||||||
|
<a name="line259">259: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Not supported"</font>);
|
||||||
|
<a name="line260">260: </a> }
|
||||||
|
|
||||||
|
<a name="line262">262: </a> public void getAvailableFormats(IFormattedDataDMContext dmc, DataRequestMonitor<String[]> rm) {
|
||||||
|
<a name="line263">263: </a> <font color="#B22222">// PDA debugger doesn't support formatting the expression. Natural </font>
|
||||||
|
<a name="line264">264: </a> <font color="#B22222">// formatting is the only available option.</font>
|
||||||
|
<a name="line265">265: </a> rm.setData(new String[] { NATURAL_FORMAT });
|
||||||
|
<a name="line266">266: </a> rm.done();
|
||||||
|
<a name="line267">267: </a> }
|
||||||
|
|
||||||
|
<a name="line269">269: </a><strong><font color="#4169E1"> public FormattedValueDMContext getFormattedValueContext(IFormattedDataDMContext exprCtx, String formatId)</font></strong> {
|
||||||
|
<a name="line270">270: </a> <font color="#B22222">// Creates a context that can be used to retrieve a formatted value.</font>
|
||||||
|
<a name="line271">271: </a> <font color="#4169E1">return</font> new FormattedValueDMContext(this, exprCtx, formatId);
|
||||||
|
<a name="line272">272: </a> }
|
||||||
|
|
||||||
|
<a name="line274">274: </a> public void getFormattedExpressionValue(FormattedValueDMContext formattedCtx,
|
||||||
|
<a name="line275">275: </a> final DataRequestMonitor<FormattedValueDMData> rm)
|
||||||
|
<a name="line276">276: </a> {
|
||||||
|
<a name="line277">277: </a> final ExpressionDMContext exprCtx = DMContexts.getAncestorOfType(formattedCtx, ExpressionDMContext.class);
|
||||||
|
<a name="line278">278: </a> <font color="#4169E1">if</font> (exprCtx != null) {
|
||||||
|
<a name="line279">279: </a> final IFrameDMContext frameCtx = DMContexts.getAncestorOfType(exprCtx, IFrameDMContext.class);
|
||||||
|
<a name="line280">280: </a>
|
||||||
|
<a name="line281">281: </a> <font color="#B22222">// First retrieve the stack depth, needed to properly calculate</font>
|
||||||
|
<a name="line282">282: </a> <font color="#B22222">// the frame index that is used by the PDAVarCommand. </font>
|
||||||
|
<a name="line283">283: </a> fStack.getStackDepth(
|
||||||
|
<a name="line284">284: </a> frameCtx, 0,
|
||||||
|
<a name="line285">285: </a> new DataRequestMonitor<Integer>(getExecutor(), rm) {
|
||||||
|
<a name="line286">286: </a> @Override
|
||||||
|
<a name="line287">287: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line288">288: </a> <font color="#B22222">// Calculate the frame index.</font>
|
||||||
|
<a name="line289">289: </a> int frameId = getData() - frameCtx.getLevel() - 1;
|
||||||
|
<a name="line290">290: </a>
|
||||||
|
<a name="line291">291: </a> <font color="#B22222">// Send the command to evaluate the variable.</font>
|
||||||
|
<a name="line292">292: </a> fCommandCache.execute(
|
||||||
|
<a name="line293">293: </a> new PDAVarCommand(fCommandControl.getProgramDMContext(), frameId, exprCtx.getExpression()),
|
||||||
|
<a name="line294">294: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line295">295: </a> @Override
|
||||||
|
<a name="line296">296: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line297">297: </a> rm.setData(new FormattedValueDMData(getData().fResponseText));
|
||||||
|
<a name="line298">298: </a> rm.done();
|
||||||
|
<a name="line299">299: </a> }
|
||||||
|
<a name="line300">300: </a> });
|
||||||
|
<a name="line301">301: </a> }
|
||||||
|
<a name="line302">302: </a> });
|
||||||
|
<a name="line303">303: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line304">304: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Invalid expression context "</font> + formattedCtx);
|
||||||
|
<a name="line305">305: </a> rm.done();
|
||||||
|
<a name="line306">306: </a> }
|
||||||
|
<a name="line307">307: </a> }
|
||||||
|
|
||||||
|
<a name="line309">309: </a><strong><font color="#4169E1"> public void writeExpression(final IExpressionDMContext exprCtx, final String exprValue, String formatId, </font></strong>
|
||||||
|
<a name="line310">310: </a><strong><font color="#4169E1"> final RequestMonitor rm)</font></strong>
|
||||||
|
<a name="line311">311: </a> {
|
||||||
|
<a name="line312">312: </a> <font color="#4169E1">if</font> (exprCtx instanceof ExpressionDMContext) {
|
||||||
|
<a name="line313">313: </a> final IFrameDMContext frameCtx = DMContexts.getAncestorOfType(exprCtx, IFrameDMContext.class);
|
||||||
|
<a name="line314">314: </a>
|
||||||
|
<a name="line315">315: </a> <font color="#B22222">// Similarly to retrieving the variable, retrieve the </font>
|
||||||
|
<a name="line316">316: </a> <font color="#B22222">// stack depth first.</font>
|
||||||
|
<a name="line317">317: </a> fStack.getStackDepth(
|
||||||
|
<a name="line318">318: </a> frameCtx, 0,
|
||||||
|
<a name="line319">319: </a> new DataRequestMonitor<Integer>(getExecutor(), rm) {
|
||||||
|
<a name="line320">320: </a> @Override
|
||||||
|
<a name="line321">321: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line322">322: </a> <font color="#B22222">// Calculate the frame index.</font>
|
||||||
|
<a name="line323">323: </a> int frameId = getData() - frameCtx.getLevel() - 1;
|
||||||
|
<a name="line324">324: </a>
|
||||||
|
<a name="line325">325: </a> <font color="#B22222">// Send the "write" command to PDA debugger</font>
|
||||||
|
<a name="line326">326: </a> fCommandCache.execute(
|
||||||
|
<a name="line327">327: </a> new PDASetVarCommand(fCommandControl.getProgramDMContext(), frameId, exprCtx.getExpression(), exprValue),
|
||||||
|
<a name="line328">328: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line329">329: </a> @Override
|
||||||
|
<a name="line330">330: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line331">331: </a> getSession().dispatchEvent(new ExpressionChangedDMEvent(exprCtx), getProperties());
|
||||||
|
<a name="line332">332: </a> rm.done();
|
||||||
|
<a name="line333">333: </a> }
|
||||||
|
<a name="line334">334: </a> });
|
||||||
|
<a name="line335">335: </a> }
|
||||||
|
<a name="line336">336: </a> });
|
||||||
|
<a name="line337">337: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line338">338: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Invalid expression context "</font> + exprCtx);
|
||||||
|
<a name="line339">339: </a> rm.done();
|
||||||
|
<a name="line340">340: </a> }
|
||||||
|
<a name="line341">341: </a> }
|
||||||
|
|
||||||
|
<a name="line343">343: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>)
|
||||||
|
<a name="line344">344: </a> @Deprecated
|
||||||
|
<a name="line345">345: </a> public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
||||||
|
<a name="line346">346: </a> <font color="#4169E1">if</font> (dmc instanceof IExpressionDMContext) {
|
||||||
|
<a name="line347">347: </a> getExpressionData((IExpressionDMContext) dmc, (DataRequestMonitor<IExpressionDMData>) rm);
|
||||||
|
<a name="line348">348: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (dmc instanceof FormattedValueDMContext) {
|
||||||
|
<a name="line349">349: </a> getFormattedExpressionValue((FormattedValueDMContext) dmc, (DataRequestMonitor<FormattedValueDMData>) rm);
|
||||||
|
<a name="line350">350: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line351">351: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Unknown DMC type"</font>);
|
||||||
|
<a name="line352">352: </a> rm.done();
|
||||||
|
<a name="line353">353: </a> }
|
||||||
|
<a name="line354">354: </a> }
|
||||||
|
|
||||||
|
<a name="line356">356: </a> @DsfServiceEventHandler
|
||||||
|
<a name="line357">357: </a><strong><font color="#4169E1"> public void eventDispatched(IResumedDMEvent e)</font></strong> {
|
||||||
|
<a name="line358">358: </a> <font color="#B22222">// Mark the cache as not available, so that data retrieval commands </font>
|
||||||
|
<a name="line359">359: </a> <font color="#B22222">// will fail. Also reset the cache unless it was a step command.</font>
|
||||||
|
<a name="line360">360: </a> fCommandCache.setTargetAvailable(false);
|
||||||
|
<a name="line361">361: </a> <font color="#4169E1">if</font> (!e.getReason().equals(StateChangeReason.STEP)) {
|
||||||
|
<a name="line362">362: </a> fCommandCache.reset();
|
||||||
|
<a name="line363">363: </a> }
|
||||||
|
<a name="line364">364: </a> }
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line367">367: </a> @DsfServiceEventHandler
|
||||||
|
<a name="line368">368: </a><strong><font color="#4169E1"> public void eventDispatched(ISuspendedDMEvent e)</font></strong> {
|
||||||
|
<a name="line369">369: </a> <font color="#B22222">// Enable sending commands to target and clear the cache.</font>
|
||||||
|
<a name="line370">370: </a> fCommandCache.setTargetAvailable(true);
|
||||||
|
<a name="line371">371: </a> fCommandCache.reset();
|
||||||
|
<a name="line372">372: </a> }
|
||||||
|
<a name="line373">373: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -182,7 +182,7 @@ public class PDARunControl extends AbstractDsfService
|
||||||
if (!(output instanceof String)) return;
|
if (!(output instanceof String)) return;
|
||||||
String event = (String)output;
|
String event = (String)output;
|
||||||
|
|
||||||
// Handle PDA debugger suspende/resumed events and issue the
|
// Handle PDA debugger suspended/resumed events and issue the
|
||||||
// corresponding Data Model events. Do not update the state
|
// corresponding Data Model events. Do not update the state
|
||||||
// information until we start dispatching the service events.
|
// information until we start dispatching the service events.
|
||||||
if (event.startsWith("suspended")) {
|
if (event.startsWith("suspended")) {
|
||||||
|
@ -248,6 +248,7 @@ public class PDARunControl extends AbstractDsfService
|
||||||
// If the resume command failed, we no longer
|
// If the resume command failed, we no longer
|
||||||
// expect to receive a resumed event.
|
// expect to receive a resumed event.
|
||||||
fResumePending = false;
|
fResumePending = false;
|
||||||
|
super.handleErrorOrCancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,330 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDARunControl.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-11T22:38:18+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2006 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> * Ericsson AB - Modified for handling of multiple threads</font>
|
||||||
|
<a name="line11"> 11: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line12"> 12: </a>package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.Hashtable;</font>
|
||||||
|
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.Immutable;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.RequestMonitor;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.IDMContext;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.IDMEvent;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.command.IEventListener;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.service.AbstractDsfService;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfServiceEventHandler;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.dd.dsf.service.IDsfService;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAResumeCommand;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAStepCommand;</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDASuspendCommand;</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#228B22">import org.osgi.framework.BundleContext;</font>
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line36"> 36: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#B22222"> * Service for monitoring and controlling execution state of the DPA </font>
|
||||||
|
<a name="line38"> 38: </a><font color="#B22222"> * program.</font>
|
||||||
|
<a name="line39"> 39: </a><font color="#B22222"> * <p></font>
|
||||||
|
<a name="line40"> 40: </a><font color="#B22222"> * This service depends on the {@link PDACommandControl} service.</font>
|
||||||
|
<a name="line41"> 41: </a><font color="#B22222"> * It must be initialized before this service is initialized.</font>
|
||||||
|
<a name="line42"> 42: </a><font color="#B22222"> * </p></font>
|
||||||
|
<a name="line43"> 43: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line44"> 44: </a><strong><font color="#4169E1"><a name="PDARunControl"></a>public class PDARunControl extends AbstractDsfService </font></strong>
|
||||||
|
<a name="line45"> 45: </a> implements IRunControl, IEventListener
|
||||||
|
<a name="line46"> 46: </a>{
|
||||||
|
<a name="line47"> 47: </a> <font color="#B22222">// Implementation note about tracking execution state:</font>
|
||||||
|
<a name="line48"> 48: </a> <font color="#B22222">// This class implements event handlers for the events that are generated by </font>
|
||||||
|
<a name="line49"> 49: </a> <font color="#B22222">// this service itself. When the event is dispatched, these handlers will</font>
|
||||||
|
<a name="line50"> 50: </a> <font color="#B22222">// be called first, before any of the clients. These handlers update the </font>
|
||||||
|
<a name="line51"> 51: </a> <font color="#B22222">// service's internal state information to make them consistent with the </font>
|
||||||
|
<a name="line52"> 52: </a> <font color="#B22222">// events being issued. Doing this in the handlers as opposed to when </font>
|
||||||
|
<a name="line53"> 53: </a> <font color="#B22222">// the events are generated, guarantees that the state of the service will</font>
|
||||||
|
<a name="line54"> 54: </a> <font color="#B22222">// always be consistent with the events.</font>
|
||||||
|
<a name="line55"> 55: </a> <font color="#B22222">// The purpose of this pattern is to allow clients that listen to service </font>
|
||||||
|
<a name="line56"> 56: </a> <font color="#B22222">// events and track service state, to be perfectly in sync with the service</font>
|
||||||
|
<a name="line57"> 57: </a> <font color="#B22222">// state.</font>
|
||||||
|
<a name="line58"> 58: </a>
|
||||||
|
<a name="line59"> 59: </a> @Immutable
|
||||||
|
<a name="line60"> 60: </a> private static class ExecutionDMData implements IExecutionDMData {
|
||||||
|
<a name="line61"> 61: </a> private final StateChangeReason fReason;
|
||||||
|
<a name="line62"> 62: </a> ExecutionDMData(StateChangeReason reason) {
|
||||||
|
<a name="line63"> 63: </a> fReason = reason;
|
||||||
|
<a name="line64"> 64: </a> }
|
||||||
|
<a name="line65"> 65: </a><strong><font color="#4169E1"> public StateChangeReason getStateChangeReason()</font></strong> { <font color="#4169E1">return</font> fReason; }
|
||||||
|
<a name="line66"> 66: </a> }
|
||||||
|
<a name="line67"> 67: </a>
|
||||||
|
<a name="line68"> 68: </a> @Immutable
|
||||||
|
<a name="line69"> 69: </a> private static class ResumedEvent extends AbstractDMEvent<IExecutionDMContext>
|
||||||
|
<a name="line70"> 70: </a> implements IResumedDMEvent
|
||||||
|
<a name="line71"> 71: </a> {
|
||||||
|
<a name="line72"> 72: </a> private final String fPDAEvent;
|
||||||
|
|
||||||
|
<a name="line74"> 74: </a> ResumedEvent(IExecutionDMContext ctx, String pdaEvent) {
|
||||||
|
<a name="line75"> 75: </a> super(ctx);
|
||||||
|
<a name="line76"> 76: </a> fPDAEvent = pdaEvent;
|
||||||
|
<a name="line77"> 77: </a> }
|
||||||
|
<a name="line78"> 78: </a>
|
||||||
|
<a name="line79"> 79: </a><strong><font color="#4169E1"> public StateChangeReason getReason()</font></strong> {
|
||||||
|
<a name="line80"> 80: </a> <font color="#4169E1">if</font> (fPDAEvent.startsWith(<font color="#666666">"resumed breakpoint"</font>) || fPDAEvent.startsWith(<font color="#666666">"suspended watch"</font>)) {
|
||||||
|
<a name="line81"> 81: </a> <font color="#4169E1">return</font> StateChangeReason.BREAKPOINT;
|
||||||
|
<a name="line82"> 82: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (fPDAEvent.equals(<font color="#666666">"resumed step"</font>) || fPDAEvent.equals(<font color="#666666">"resumed drop"</font>)) {
|
||||||
|
<a name="line83"> 83: </a> <font color="#4169E1">return</font> StateChangeReason.STEP;
|
||||||
|
<a name="line84"> 84: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (fPDAEvent.equals(<font color="#666666">"resumed client"</font>)) {
|
||||||
|
<a name="line85"> 85: </a> <font color="#4169E1">return</font> StateChangeReason.USER_REQUEST;
|
||||||
|
<a name="line86"> 86: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line87"> 87: </a> <font color="#4169E1">return</font> StateChangeReason.UNKNOWN;
|
||||||
|
<a name="line88"> 88: </a> }
|
||||||
|
<a name="line89"> 89: </a> }
|
||||||
|
<a name="line90"> 90: </a> }
|
||||||
|
<a name="line91"> 91: </a>
|
||||||
|
<a name="line92"> 92: </a> @Immutable
|
||||||
|
<a name="line93"> 93: </a> private static class SuspendedEvent extends AbstractDMEvent<IExecutionDMContext>
|
||||||
|
<a name="line94"> 94: </a> implements ISuspendedDMEvent
|
||||||
|
<a name="line95"> 95: </a> {
|
||||||
|
<a name="line96"> 96: </a> private final String fPDAEvent;
|
||||||
|
<a name="line97"> 97: </a>
|
||||||
|
<a name="line98"> 98: </a> SuspendedEvent(IExecutionDMContext ctx, String pdaEvent) {
|
||||||
|
<a name="line99"> 99: </a> super(ctx);
|
||||||
|
<a name="line100">100: </a> fPDAEvent = pdaEvent;
|
||||||
|
<a name="line101">101: </a> }
|
||||||
|
<a name="line102">102: </a>
|
||||||
|
<a name="line103">103: </a><strong><font color="#4169E1"> public StateChangeReason getReason()</font></strong> {
|
||||||
|
<a name="line104">104: </a> <font color="#4169E1">if</font> (fPDAEvent.startsWith(<font color="#666666">"suspended breakpoint"</font>) || fPDAEvent.startsWith(<font color="#666666">"suspended watch"</font>)) {
|
||||||
|
<a name="line105">105: </a> <font color="#4169E1">return</font> StateChangeReason.BREAKPOINT;
|
||||||
|
<a name="line106">106: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (fPDAEvent.equals(<font color="#666666">"suspended step"</font>) || fPDAEvent.equals(<font color="#666666">"suspended drop"</font>)) {
|
||||||
|
<a name="line107">107: </a> <font color="#4169E1">return</font> StateChangeReason.STEP;
|
||||||
|
<a name="line108">108: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (fPDAEvent.equals(<font color="#666666">"suspended client"</font>)) {
|
||||||
|
<a name="line109">109: </a> <font color="#4169E1">return</font> StateChangeReason.USER_REQUEST;
|
||||||
|
<a name="line110">110: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line111">111: </a> <font color="#4169E1">return</font> StateChangeReason.UNKNOWN;
|
||||||
|
<a name="line112">112: </a> }
|
||||||
|
<a name="line113">113: </a> }
|
||||||
|
<a name="line114">114: </a> }
|
||||||
|
|
||||||
|
<a name="line116">116: </a> <font color="#B22222">// Services </font>
|
||||||
|
<a name="line117">117: </a> private PDACommandControl fCommandControl;
|
||||||
|
<a name="line118">118: </a>
|
||||||
|
<a name="line119">119: </a> <font color="#B22222">// State flags</font>
|
||||||
|
<a name="line120">120: </a> private boolean fSuspended = true;
|
||||||
|
<a name="line121">121: </a> private boolean fResumePending = false;
|
||||||
|
<a name="line122">122: </a> private boolean fStepping = false;
|
||||||
|
<a name="line123">123: </a> private StateChangeReason fStateChangeReason;
|
||||||
|
<a name="line124">124: </a>
|
||||||
|
<a name="line125">125: </a><strong><font color="#4169E1"> public PDARunControl(DsfSession session)</font></strong> {
|
||||||
|
<a name="line126">126: </a> super(session);
|
||||||
|
<a name="line127">127: </a> }
|
||||||
|
<a name="line128">128: </a>
|
||||||
|
<a name="line129">129: </a> @Override
|
||||||
|
<a name="line130">130: </a><strong><font color="#4169E1"> protected BundleContext getBundleContext()</font></strong> {
|
||||||
|
<a name="line131">131: </a> <font color="#4169E1">return</font> PDAPlugin.getBundleContext();
|
||||||
|
<a name="line132">132: </a> }
|
||||||
|
<a name="line133">133: </a>
|
||||||
|
<a name="line134">134: </a> @Override
|
||||||
|
<a name="line135">135: </a><strong><font color="#4169E1"> public void initialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line136">136: </a> super.initialize(
|
||||||
|
<a name="line137">137: </a> new RequestMonitor(getExecutor(), rm) {
|
||||||
|
<a name="line138">138: </a> @Override
|
||||||
|
<a name="line139">139: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line140">140: </a> doInitialize(rm);
|
||||||
|
<a name="line141">141: </a> }});
|
||||||
|
<a name="line142">142: </a> }
|
||||||
|
|
||||||
|
<a name="line144">144: </a><strong><font color="#4169E1"> private void doInitialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line145">145: </a> fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
|
||||||
|
<a name="line147">147: </a> <font color="#B22222">// Add ourselves as a listener to PDA events, to catch suspended/resumed </font>
|
||||||
|
<a name="line148">148: </a> <font color="#B22222">// events.</font>
|
||||||
|
<a name="line149">149: </a> fCommandControl.addEventListener(this);
|
||||||
|
<a name="line150">150: </a>
|
||||||
|
<a name="line151">151: </a> <font color="#B22222">// Add ourselves as a listener to service events, in order to process</font>
|
||||||
|
<a name="line152">152: </a> <font color="#B22222">// our own suspended/resumed events.</font>
|
||||||
|
<a name="line153">153: </a> getSession().addServiceEventListener(this, null);
|
||||||
|
<a name="line154">154: </a>
|
||||||
|
<a name="line155">155: </a> <font color="#B22222">// Register the service with OSGi</font>
|
||||||
|
<a name="line156">156: </a> register(new String[]{IRunControl.class.getName(), PDARunControl.class.getName()}, new Hashtable<String,String>());
|
||||||
|
<a name="line157">157: </a>
|
||||||
|
<a name="line158">158: </a> rm.done();
|
||||||
|
<a name="line159">159: </a> }
|
||||||
|
|
||||||
|
<a name="line161">161: </a> @Override
|
||||||
|
<a name="line162">162: </a><strong><font color="#4169E1"> public void shutdown(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line163">163: </a> fCommandControl.removeEventListener(this);
|
||||||
|
<a name="line164">164: </a> getSession().removeServiceEventListener(this);
|
||||||
|
<a name="line165">165: </a> super.shutdown(rm);
|
||||||
|
<a name="line166">166: </a> }
|
||||||
|
<a name="line167">167: </a>
|
||||||
|
<a name="line168">168: </a> @Deprecated
|
||||||
|
<a name="line169">169: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>)
|
||||||
|
<a name="line170">170: </a> public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
||||||
|
<a name="line171">171: </a> <font color="#B22222">// The getModelData() is deprecated and clients are expected to switch</font>
|
||||||
|
<a name="line172">172: </a> <font color="#B22222">// to getExecutionData() and other data retrieve methods directly.</font>
|
||||||
|
<a name="line173">173: </a> <font color="#B22222">// However the UI cache still uses it for now.</font>
|
||||||
|
<a name="line174">174: </a> <font color="#4169E1">if</font> (dmc instanceof IExecutionDMContext) {
|
||||||
|
<a name="line175">175: </a> getExecutionData((IExecutionDMContext)dmc, (DataRequestMonitor<IExecutionDMData>)rm);
|
||||||
|
<a name="line176">176: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line177">177: </a> PDAPlugin.failRequest(rm, INVALID_HANDLE, <font color="#666666">"Unknown DMC type"</font>);
|
||||||
|
<a name="line178">178: </a> }
|
||||||
|
<a name="line179">179: </a> }
|
||||||
|
<a name="line180">180: </a>
|
||||||
|
<a name="line181">181: </a><strong><font color="#4169E1"> public void eventReceived(Object output)</font></strong> {
|
||||||
|
<a name="line182">182: </a> <font color="#4169E1">if</font> (!(output instanceof String)) <font color="#4169E1">return</font>;
|
||||||
|
<a name="line183">183: </a> String event = (String)output;
|
||||||
|
<a name="line184">184: </a>
|
||||||
|
<a name="line185">185: </a> <font color="#B22222">// Handle PDA debugger suspended/resumed events and issue the </font>
|
||||||
|
<a name="line186">186: </a> <font color="#B22222">// corresponding Data Model events. Do not update the state</font>
|
||||||
|
<a name="line187">187: </a> <font color="#B22222">// information until we start dispatching the service events.</font>
|
||||||
|
<a name="line188">188: </a> <font color="#4169E1">if</font> (event.startsWith(<font color="#666666">"suspended"</font>)) {
|
||||||
|
<a name="line189">189: </a> IDMEvent<?> dmEvent = new SuspendedEvent(fCommandControl.getProgramDMContext(), event);
|
||||||
|
<a name="line190">190: </a> getSession().dispatchEvent(dmEvent, getProperties());
|
||||||
|
<a name="line191">191: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (event.startsWith(<font color="#666666">"resumed"</font>)) {
|
||||||
|
<a name="line192">192: </a> IDMEvent<?> dmEvent = new ResumedEvent(fCommandControl.getProgramDMContext(), event);
|
||||||
|
<a name="line193">193: </a> getSession().dispatchEvent(dmEvent, getProperties());
|
||||||
|
<a name="line194">194: </a> }
|
||||||
|
<a name="line195">195: </a> }
|
||||||
|
<a name="line196">196: </a>
|
||||||
|
<a name="line197">197: </a>
|
||||||
|
<a name="line198">198: </a> @DsfServiceEventHandler
|
||||||
|
<a name="line199">199: </a><strong><font color="#4169E1"> public void eventDispatched(ResumedEvent e)</font></strong> {
|
||||||
|
<a name="line200">200: </a> <font color="#B22222">// This service should be the first to receive the ResumedEvent, </font>
|
||||||
|
<a name="line201">201: </a> <font color="#B22222">// (before any other listeners are called). Here, update the</font>
|
||||||
|
<a name="line202">202: </a> <font color="#B22222">// service state information based on the the resumed event.</font>
|
||||||
|
<a name="line203">203: </a> fSuspended = false;
|
||||||
|
<a name="line204">204: </a> fResumePending = false;
|
||||||
|
<a name="line205">205: </a> fStateChangeReason = e.getReason();
|
||||||
|
<a name="line206">206: </a> fStepping = e.getReason().equals(StateChangeReason.STEP);
|
||||||
|
<a name="line207">207: </a> }
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line210">210: </a> @DsfServiceEventHandler
|
||||||
|
<a name="line211">211: </a><strong><font color="#4169E1"> public void eventDispatched(SuspendedEvent e)</font></strong> {
|
||||||
|
<a name="line212">212: </a> <font color="#B22222">// This service should be the first to receive the SuspendedEvent also, </font>
|
||||||
|
<a name="line213">213: </a> <font color="#B22222">// (before any other listeners are called). Here, update the</font>
|
||||||
|
<a name="line214">214: </a> <font color="#B22222">// service state information based on the the suspended event.</font>
|
||||||
|
<a name="line215">215: </a> fStateChangeReason = e.getReason();
|
||||||
|
<a name="line216">216: </a> fResumePending = false;
|
||||||
|
<a name="line217">217: </a> fSuspended = true;
|
||||||
|
<a name="line218">218: </a> fStepping = false;
|
||||||
|
<a name="line219">219: </a> }
|
||||||
|
<a name="line220">220: </a>
|
||||||
|
<a name="line221">221: </a>
|
||||||
|
<a name="line222">222: </a><strong><font color="#4169E1"> public boolean canResume(IExecutionDMContext context)</font></strong> {
|
||||||
|
<a name="line223">223: </a> <font color="#4169E1">return</font> isSuspended(context) && !fResumePending;
|
||||||
|
<a name="line224">224: </a> }
|
||||||
|
|
||||||
|
<a name="line226">226: </a><strong><font color="#4169E1"> public boolean canSuspend(IExecutionDMContext context)</font></strong> {
|
||||||
|
<a name="line227">227: </a> <font color="#4169E1">return</font> !isSuspended(context);
|
||||||
|
<a name="line228">228: </a> }
|
||||||
|
|
||||||
|
<a name="line230">230: </a><strong><font color="#4169E1"> public boolean isSuspended(IExecutionDMContext context)</font></strong> {
|
||||||
|
<a name="line231">231: </a> <font color="#4169E1">return</font> fSuspended;
|
||||||
|
<a name="line232">232: </a> }
|
||||||
|
|
||||||
|
<a name="line234">234: </a><strong><font color="#4169E1"> public boolean isStepping(IExecutionDMContext context)</font></strong> {
|
||||||
|
<a name="line235">235: </a> <font color="#4169E1">return</font> !isSuspended(context) && fStepping;
|
||||||
|
<a name="line236">236: </a> }
|
||||||
|
|
||||||
|
<a name="line238">238: </a><strong><font color="#4169E1"> public void resume(IExecutionDMContext context, final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line239">239: </a> assert context != null;
|
||||||
|
|
||||||
|
<a name="line241">241: </a> <font color="#4169E1">if</font> (canResume(context)) {
|
||||||
|
<a name="line242">242: </a> fResumePending = true;
|
||||||
|
<a name="line243">243: </a> fCommandControl.queueCommand(
|
||||||
|
<a name="line244">244: </a> new PDAResumeCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
<a name="line245">245: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line246">246: </a> @Override
|
||||||
|
<a name="line247">247: </a><strong><font color="#4169E1"> protected void handleErrorOrCancel()</font></strong> {
|
||||||
|
<a name="line248">248: </a> <font color="#B22222">// If the resume command failed, we no longer</font>
|
||||||
|
<a name="line249">249: </a> <font color="#B22222">// expect to receive a resumed event.</font>
|
||||||
|
<a name="line250">250: </a> fResumePending = false;
|
||||||
|
<a name="line251">251: </a> }
|
||||||
|
<a name="line252">252: </a> }
|
||||||
|
<a name="line253">253: </a> );
|
||||||
|
<a name="line254">254: </a> }<font color="#4169E1">else</font> {
|
||||||
|
<a name="line255">255: </a> PDAPlugin.failRequest(rm, INVALID_STATE, <font color="#666666">"Given context: "</font> + context + <font color="#666666">", is already running."</font>);
|
||||||
|
<a name="line256">256: </a> }
|
||||||
|
<a name="line257">257: </a> }
|
||||||
|
<a name="line258">258: </a>
|
||||||
|
<a name="line259">259: </a><strong><font color="#4169E1"> public void suspend(IExecutionDMContext context, final RequestMonitor rm)</font></strong>{
|
||||||
|
<a name="line260">260: </a> assert context != null;
|
||||||
|
|
||||||
|
<a name="line262">262: </a> <font color="#4169E1">if</font> (canSuspend(context)) {
|
||||||
|
<a name="line263">263: </a> fCommandControl.queueCommand(
|
||||||
|
<a name="line264">264: </a> new PDASuspendCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
<a name="line265">265: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
|
<a name="line266">266: </a>
|
||||||
|
<a name="line267">267: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line268">268: </a> PDAPlugin.failRequest(rm, IDsfService.INVALID_STATE, <font color="#666666">"Given context: "</font> + context + <font color="#666666">", is already suspended."</font>);
|
||||||
|
<a name="line269">269: </a> }
|
||||||
|
<a name="line270">270: </a> }
|
||||||
|
<a name="line271">271: </a>
|
||||||
|
<a name="line272">272: </a><strong><font color="#4169E1"> public boolean canStep(IExecutionDMContext context)</font></strong> {
|
||||||
|
<a name="line273">273: </a> <font color="#4169E1">return</font> canResume(context);
|
||||||
|
<a name="line274">274: </a> }
|
||||||
|
<a name="line275">275: </a>
|
||||||
|
<a name="line276">276: </a><strong><font color="#4169E1"> public void step(IExecutionDMContext context, StepType stepType, final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line277">277: </a> assert context != null;
|
||||||
|
<a name="line278">278: </a>
|
||||||
|
<a name="line279">279: </a> <font color="#4169E1">if</font> (canResume(context)) {
|
||||||
|
<a name="line280">280: </a> fResumePending = true;
|
||||||
|
<a name="line281">281: </a> fStepping = true;
|
||||||
|
|
||||||
|
<a name="line283">283: </a> fCommandControl.queueCommand(
|
||||||
|
<a name="line284">284: </a> new PDAStepCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
<a name="line285">285: </a> new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line286">286: </a> @Override
|
||||||
|
<a name="line287">287: </a><strong><font color="#4169E1"> protected void handleErrorOrCancel()</font></strong> {
|
||||||
|
<a name="line288">288: </a> <font color="#B22222">// If the step command failed, we no longer</font>
|
||||||
|
<a name="line289">289: </a> <font color="#B22222">// expect to receive a resumed event.</font>
|
||||||
|
<a name="line290">290: </a> fResumePending = false;
|
||||||
|
<a name="line291">291: </a> fStepping = false;
|
||||||
|
<a name="line292">292: </a> }
|
||||||
|
<a name="line293">293: </a> });
|
||||||
|
|
||||||
|
<a name="line295">295: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line296">296: </a> PDAPlugin.failRequest(rm, INVALID_STATE, <font color="#666666">"Cannot resume context"</font>);
|
||||||
|
<a name="line297">297: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line298">298: </a> }
|
||||||
|
<a name="line299">299: </a> }
|
||||||
|
|
||||||
|
<a name="line301">301: </a><strong><font color="#4169E1"> public boolean canInstructionStep(IExecutionDMContext context)</font></strong> {
|
||||||
|
<a name="line302">302: </a> <font color="#4169E1">return</font> false;
|
||||||
|
<a name="line303">303: </a> }
|
||||||
|
<a name="line304">304: </a>
|
||||||
|
<a name="line305">305: </a><strong><font color="#4169E1"> public void instructionStep(IExecutionDMContext context, StepType stepType, RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line306">306: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Operation not implemented"</font>);
|
||||||
|
<a name="line307">307: </a> }
|
||||||
|
|
||||||
|
<a name="line309">309: </a> public void getExecutionContexts(final IContainerDMContext containerDmc, final DataRequestMonitor<IExecutionDMContext[]> rm) {
|
||||||
|
<a name="line310">310: </a> PDAPlugin.failRequest(rm, NOT_SUPPORTED, <font color="#666666">"Operation not implemented"</font>);
|
||||||
|
<a name="line311">311: </a> }
|
||||||
|
<a name="line312">312: </a>
|
||||||
|
<a name="line313">313: </a> public void getExecutionData(IExecutionDMContext dmc, DataRequestMonitor<IExecutionDMData> rm){
|
||||||
|
<a name="line314">314: </a> rm.setData( new ExecutionDMData(fStateChangeReason) );
|
||||||
|
<a name="line315">315: </a> rm.done();
|
||||||
|
<a name="line316">316: </a> }
|
||||||
|
<a name="line317">317: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -54,24 +54,24 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
private static class FrameDMContext extends AbstractDMContext implements IFrameDMContext {
|
private static class FrameDMContext extends AbstractDMContext implements IFrameDMContext {
|
||||||
|
|
||||||
final private int fLevel;
|
final private int fLevel;
|
||||||
|
|
||||||
FrameDMContext(String sessionId, IExecutionDMContext execDmc, int level) {
|
FrameDMContext(String sessionId, IExecutionDMContext execDmc, int level) {
|
||||||
super(sessionId, new IDMContext[] { execDmc });
|
super(sessionId, new IDMContext[] { execDmc });
|
||||||
fLevel = level;
|
fLevel = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLevel() { return fLevel; }
|
public int getLevel() { return fLevel; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return super.baseEquals(other) && ((FrameDMContext)other).fLevel == fLevel;
|
return super.baseEquals(other) && ((FrameDMContext)other).fLevel == fLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return super.baseHashCode() ^ fLevel;
|
return super.baseHashCode() ^ fLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return baseToString() + ".frame[" + fLevel + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
return baseToString() + ".frame[" + fLevel + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -85,11 +85,11 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
private static class FrameDMData implements IFrameDMData {
|
private static class FrameDMData implements IFrameDMData {
|
||||||
|
|
||||||
final private PDAFrame fFrame;
|
final private PDAFrame fFrame;
|
||||||
|
|
||||||
FrameDMData(PDAFrame frame) {
|
FrameDMData(PDAFrame frame) {
|
||||||
fFrame = frame;
|
fFrame = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFile() {
|
public String getFile() {
|
||||||
return fFrame.fFilePath.lastSegment();
|
return fFrame.fFilePath.lastSegment();
|
||||||
}
|
}
|
||||||
|
@ -118,24 +118,24 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
private static class VariableDMContext extends AbstractDMContext implements IVariableDMContext {
|
private static class VariableDMContext extends AbstractDMContext implements IVariableDMContext {
|
||||||
|
|
||||||
final private String fVariable;
|
final private String fVariable;
|
||||||
|
|
||||||
VariableDMContext(String sessionId, IFrameDMContext frameCtx, String variable) {
|
VariableDMContext(String sessionId, IFrameDMContext frameCtx, String variable) {
|
||||||
super(sessionId, new IDMContext[] { frameCtx });
|
super(sessionId, new IDMContext[] { frameCtx });
|
||||||
fVariable = variable;
|
fVariable = variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getVariable() { return fVariable; }
|
String getVariable() { return fVariable; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return super.baseEquals(other) && ((VariableDMContext)other).fVariable.equals(fVariable);
|
return super.baseEquals(other) && ((VariableDMContext)other).fVariable.equals(fVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return super.baseHashCode() + fVariable.hashCode();
|
return super.baseHashCode() + fVariable.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return baseToString() + ".variable(" + fVariable + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
return baseToString() + ".variable(" + fVariable + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -149,11 +149,11 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
private static class VariableDMData implements IVariableDMData {
|
private static class VariableDMData implements IVariableDMData {
|
||||||
|
|
||||||
final private String fVariable;
|
final private String fVariable;
|
||||||
|
|
||||||
VariableDMData(String variable) {
|
VariableDMData(String variable) {
|
||||||
fVariable = variable;
|
fVariable = variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return fVariable;
|
return fVariable;
|
||||||
}
|
}
|
||||||
|
@ -193,16 +193,16 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
// Initialize service references that stack service depends on
|
// Initialize service references that stack service depends on
|
||||||
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
fRunControl = getServicesTracker().getService(IRunControl.class);
|
fRunControl = getServicesTracker().getService(IRunControl.class);
|
||||||
|
|
||||||
// Create the commands cache
|
// Create the commands cache
|
||||||
fCommandCache = new CommandCache(fCommandControl);
|
fCommandCache = new CommandCache(fCommandControl);
|
||||||
|
|
||||||
// Register to listen for run control events, to clear cache accordingly.
|
// Register to listen for run control events, to clear cache accordingly.
|
||||||
getSession().addServiceEventListener(this, null);
|
getSession().addServiceEventListener(this, null);
|
||||||
|
|
||||||
// Register stack service with OSGi
|
// Register stack service with OSGi
|
||||||
register(new String[]{IStack.class.getName(), PDAStack.class.getName()}, new Hashtable<String,String>());
|
register(new String[]{IStack.class.getName(), PDAStack.class.getName()}, new Hashtable<String,String>());
|
||||||
|
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
super.shutdown(rm);
|
super.shutdown(rm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getArguments(IFrameDMContext frameCtx, DataRequestMonitor<IVariableDMContext[]> rm) {
|
public void getArguments(IFrameDMContext frameCtx, DataRequestMonitor<IVariableDMContext[]> rm) {
|
||||||
PDAPlugin.failRequest(rm, IDsfService.NOT_SUPPORTED, "PDA debugger does not support function arguments.");
|
PDAPlugin.failRequest(rm, IDsfService.NOT_SUPPORTED, "PDA debugger does not support function arguments.");
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid frame level " + frameCtx);
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid frame level " + frameCtx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the frame data object based on the corresponding PDAFrame
|
// Create the frame data object based on the corresponding PDAFrame
|
||||||
rm.setData(new FrameDMData(getData().fFrames[frameId]));
|
rm.setData(new FrameDMData(getData().fFrames[frameId]));
|
||||||
rm.done();
|
rm.done();
|
||||||
|
@ -240,7 +240,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getFrames(IDMContext context, final DataRequestMonitor<IFrameDMContext[]> rm) {
|
public void getFrames(IDMContext context, final DataRequestMonitor<IFrameDMContext[]> rm) {
|
||||||
// Can only create stack frames for an execution context as a parent,
|
// Can only create stack frames for an execution context as a parent,
|
||||||
// however the argument context is a generic context type, so it could
|
// however the argument context is a generic context type, so it could
|
||||||
|
@ -251,7 +251,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid context " + context);
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid context " + context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the stack command and create the corresponding frame contexts.
|
// Execute the stack command and create the corresponding frame contexts.
|
||||||
fCommandCache.execute(
|
fCommandCache.execute(
|
||||||
new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
@ -282,7 +282,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDAFrame pdaFrame = getData().fFrames[frameId];
|
PDAFrame pdaFrame = getData().fFrames[frameId];
|
||||||
|
|
||||||
// Create variable contexts for all variables in frame.
|
// Create variable contexts for all variables in frame.
|
||||||
IVariableDMContext[] variableCtxs = new IVariableDMContext[pdaFrame.fVariables.length];
|
IVariableDMContext[] variableCtxs = new IVariableDMContext[pdaFrame.fVariables.length];
|
||||||
for (int i = 0; i < pdaFrame.fVariables.length; i++) {
|
for (int i = 0; i < pdaFrame.fVariables.length; i++) {
|
||||||
|
@ -334,7 +334,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
// The variable data doen't contain a value. So there's no need to
|
// The variable data doen't contain a value. So there's no need to
|
||||||
// go to the back end to retrieve it.
|
// go to the back end to retrieve it.
|
||||||
String variable = ((VariableDMContext)variableCtx).getVariable();
|
String variable = ((VariableDMContext)variableCtx).getVariable();
|
||||||
|
|
||||||
rm.setData(new VariableDMData(variable));
|
rm.setData(new VariableDMData(variable));
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Unknown context type");
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Unknown context type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(IResumedDMEvent e) {
|
public void eventDispatched(IResumedDMEvent e) {
|
||||||
// Mark the cache as not available, so that stack commands will
|
// Mark the cache as not available, so that stack commands will
|
||||||
|
|
|
@ -0,0 +1,393 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDAStack.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-12T20:38:01+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2008 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import java.util.Hashtable;</font>
|
||||||
|
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import org.eclipse.cdt.core.IAddress;</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;</font>
|
||||||
|
<a name="line17"> 17: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.Immutable;</font>
|
||||||
|
<a name="line18"> 18: </a><font color="#228B22">import org.eclipse.dd.dsf.concurrent.RequestMonitor;</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.AbstractDMContext;</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.DMContexts;</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#228B22">import org.eclipse.dd.dsf.datamodel.IDMContext;</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl;</font>
|
||||||
|
<a name="line23"> 23: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IStack;</font>
|
||||||
|
<a name="line24"> 24: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;</font>
|
||||||
|
<a name="line25"> 25: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;</font>
|
||||||
|
<a name="line26"> 26: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;</font>
|
||||||
|
<a name="line27"> 27: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;</font>
|
||||||
|
<a name="line28"> 28: </a><font color="#228B22">import org.eclipse.dd.dsf.debug.service.command.CommandCache;</font>
|
||||||
|
<a name="line29"> 29: </a><font color="#228B22">import org.eclipse.dd.dsf.service.AbstractDsfService;</font>
|
||||||
|
<a name="line30"> 30: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfServiceEventHandler;</font>
|
||||||
|
<a name="line31"> 31: </a><font color="#228B22">import org.eclipse.dd.dsf.service.DsfSession;</font>
|
||||||
|
<a name="line32"> 32: </a><font color="#228B22">import org.eclipse.dd.dsf.service.IDsfService;</font>
|
||||||
|
<a name="line33"> 33: </a><font color="#228B22">import org.eclipse.dd.examples.pda.PDAPlugin;</font>
|
||||||
|
<a name="line34"> 34: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAFrame;</font>
|
||||||
|
<a name="line35"> 35: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAStackCommand;</font>
|
||||||
|
<a name="line36"> 36: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.commands.PDAStackCommandResult;</font>
|
||||||
|
<a name="line37"> 37: </a><font color="#228B22">import org.osgi.framework.BundleContext;</font>
|
||||||
|
|
||||||
|
<a name="line39"> 39: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line40"> 40: </a><font color="#B22222"> * Service for retrieving PDA debugger stack data. </font>
|
||||||
|
<a name="line41"> 41: </a><font color="#B22222"> * <p></font>
|
||||||
|
<a name="line42"> 42: </a><font color="#B22222"> * This service depends on the {@link PDACommandControl} service and the </font>
|
||||||
|
<a name="line43"> 43: </a><font color="#B22222"> * {@link IRunControl} service. These services must be initialized before </font>
|
||||||
|
<a name="line44"> 44: </a><font color="#B22222"> * this service is initialized.</font>
|
||||||
|
<a name="line45"> 45: </a><font color="#B22222"> * </p></font>
|
||||||
|
<a name="line46"> 46: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line47"> 47: </a><strong><font color="#4169E1"><a name="PDAStack"></a>public class PDAStack extends AbstractDsfService implements IStack </font></strong>{
|
||||||
|
|
||||||
|
<a name="line49"> 49: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line50"> 50: </a><font color="#B22222"> * PDA stack frame contains only the stack frame level. It is only </font>
|
||||||
|
<a name="line51"> 51: </a><font color="#B22222"> * used as an index into the frame data returned by the PDA debugger.</font>
|
||||||
|
<a name="line52"> 52: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line53"> 53: </a> @Immutable
|
||||||
|
<a name="line54"> 54: </a> private static class FrameDMContext extends AbstractDMContext implements IFrameDMContext {
|
||||||
|
|
||||||
|
<a name="line56"> 56: </a> final private int fLevel;
|
||||||
|
|
||||||
|
<a name="line58"> 58: </a> FrameDMContext(String sessionId, IExecutionDMContext execDmc, int level) {
|
||||||
|
<a name="line59"> 59: </a> super(sessionId, new IDMContext[] { execDmc });
|
||||||
|
<a name="line60"> 60: </a> fLevel = level;
|
||||||
|
<a name="line61"> 61: </a> }
|
||||||
|
|
||||||
|
<a name="line63"> 63: </a><strong><font color="#4169E1"> public int getLevel()</font></strong> { <font color="#4169E1">return</font> fLevel; }
|
||||||
|
|
||||||
|
<a name="line65"> 65: </a> @Override
|
||||||
|
<a name="line66"> 66: </a><strong><font color="#4169E1"> public boolean equals(Object other)</font></strong> {
|
||||||
|
<a name="line67"> 67: </a> <font color="#4169E1">return</font> super.baseEquals(other) && ((FrameDMContext)other).fLevel == fLevel;
|
||||||
|
<a name="line68"> 68: </a> }
|
||||||
|
|
||||||
|
<a name="line70"> 70: </a> @Override
|
||||||
|
<a name="line71"> 71: </a><strong><font color="#4169E1"> public int hashCode()</font></strong> {
|
||||||
|
<a name="line72"> 72: </a> <font color="#4169E1">return</font> super.baseHashCode() ^ fLevel;
|
||||||
|
<a name="line73"> 73: </a> }
|
||||||
|
|
||||||
|
<a name="line75"> 75: </a> @Override
|
||||||
|
<a name="line76"> 76: </a><strong><font color="#4169E1"> public String toString()</font></strong> {
|
||||||
|
<a name="line77"> 77: </a> <font color="#4169E1">return</font> baseToString() + <font color="#666666">".frame["</font> + fLevel + <font color="#666666">"]"</font>; <font color="#B22222">//$NON-NLS-1$ //$NON-NLS-2$</font>
|
||||||
|
<a name="line78"> 78: </a> }
|
||||||
|
<a name="line79"> 79: </a> }
|
||||||
|
|
||||||
|
<a name="line81"> 81: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line82"> 82: </a><font color="#B22222"> * Frame data based on the PDAFrame object returned by the PDA debugger.</font>
|
||||||
|
<a name="line83"> 83: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line84"> 84: </a> @Immutable
|
||||||
|
<a name="line85"> 85: </a> private static class FrameDMData implements IFrameDMData {
|
||||||
|
|
||||||
|
<a name="line87"> 87: </a> final private PDAFrame fFrame;
|
||||||
|
|
||||||
|
<a name="line89"> 89: </a> FrameDMData(PDAFrame frame) {
|
||||||
|
<a name="line90"> 90: </a> fFrame = frame;
|
||||||
|
<a name="line91"> 91: </a> }
|
||||||
|
|
||||||
|
<a name="line93"> 93: </a><strong><font color="#4169E1"> public String getFile()</font></strong> {
|
||||||
|
<a name="line94"> 94: </a> <font color="#4169E1">return</font> fFrame.fFilePath.lastSegment();
|
||||||
|
<a name="line95"> 95: </a> }
|
||||||
|
|
||||||
|
<a name="line97"> 97: </a><strong><font color="#4169E1"> public String getFunction()</font></strong> {
|
||||||
|
<a name="line98"> 98: </a> <font color="#4169E1">return</font> fFrame.fFunction;
|
||||||
|
<a name="line99"> 99: </a> }
|
||||||
|
|
||||||
|
<a name="line101">101: </a><strong><font color="#4169E1"> public int getLine()</font></strong> {
|
||||||
|
<a name="line102">102: </a> <font color="#4169E1">return</font> fFrame.fLine + 1;
|
||||||
|
<a name="line103">103: </a> }
|
||||||
|
|
||||||
|
<a name="line105">105: </a><strong><font color="#4169E1"> public int getColumn()</font></strong> {
|
||||||
|
<a name="line106">106: </a> <font color="#4169E1">return</font> 0;
|
||||||
|
<a name="line107">107: </a> }
|
||||||
|
|
||||||
|
<a name="line109">109: </a><strong><font color="#4169E1"> public IAddress getAddress()</font></strong> {
|
||||||
|
<a name="line110">110: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line111">111: </a> }
|
||||||
|
<a name="line112">112: </a> }
|
||||||
|
|
||||||
|
<a name="line114">114: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line115">115: </a><font color="#B22222"> * Context representing a variable in a given stack frame.</font>
|
||||||
|
<a name="line116">116: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line117">117: </a> @Immutable
|
||||||
|
<a name="line118">118: </a> private static class VariableDMContext extends AbstractDMContext implements IVariableDMContext {
|
||||||
|
|
||||||
|
<a name="line120">120: </a> final private String fVariable;
|
||||||
|
|
||||||
|
<a name="line122">122: </a> VariableDMContext(String sessionId, IFrameDMContext frameCtx, String variable) {
|
||||||
|
<a name="line123">123: </a> super(sessionId, new IDMContext[] { frameCtx });
|
||||||
|
<a name="line124">124: </a> fVariable = variable;
|
||||||
|
<a name="line125">125: </a> }
|
||||||
|
|
||||||
|
<a name="line127">127: </a> String getVariable() { <font color="#4169E1">return</font> fVariable; }
|
||||||
|
|
||||||
|
<a name="line129">129: </a> @Override
|
||||||
|
<a name="line130">130: </a><strong><font color="#4169E1"> public boolean equals(Object other)</font></strong> {
|
||||||
|
<a name="line131">131: </a> <font color="#4169E1">return</font> super.baseEquals(other) && ((VariableDMContext)other).fVariable.equals(fVariable);
|
||||||
|
<a name="line132">132: </a> }
|
||||||
|
|
||||||
|
<a name="line134">134: </a> @Override
|
||||||
|
<a name="line135">135: </a><strong><font color="#4169E1"> public int hashCode()</font></strong> {
|
||||||
|
<a name="line136">136: </a> <font color="#4169E1">return</font> super.baseHashCode() + fVariable.hashCode();
|
||||||
|
<a name="line137">137: </a> }
|
||||||
|
|
||||||
|
<a name="line139">139: </a> @Override
|
||||||
|
<a name="line140">140: </a><strong><font color="#4169E1"> public String toString()</font></strong> {
|
||||||
|
<a name="line141">141: </a> <font color="#4169E1">return</font> baseToString() + <font color="#666666">".variable("</font> + fVariable + <font color="#666666">")"</font>; <font color="#B22222">//$NON-NLS-1$ //$NON-NLS-2$</font>
|
||||||
|
<a name="line142">142: </a> }
|
||||||
|
<a name="line143">143: </a> }
|
||||||
|
|
||||||
|
<a name="line145">145: </a> <font color="#B22222">/**</font>
|
||||||
|
<a name="line146">146: </a><font color="#B22222"> * PDA variable data, only supports returning the variable name.</font>
|
||||||
|
<a name="line147">147: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line148">148: </a> @Immutable
|
||||||
|
<a name="line149">149: </a> private static class VariableDMData implements IVariableDMData {
|
||||||
|
|
||||||
|
<a name="line151">151: </a> final private String fVariable;
|
||||||
|
|
||||||
|
<a name="line153">153: </a> VariableDMData(String variable) {
|
||||||
|
<a name="line154">154: </a> fVariable = variable;
|
||||||
|
<a name="line155">155: </a> }
|
||||||
|
|
||||||
|
<a name="line157">157: </a><strong><font color="#4169E1"> public String getName()</font></strong> {
|
||||||
|
<a name="line158">158: </a> <font color="#4169E1">return</font> fVariable;
|
||||||
|
<a name="line159">159: </a> }
|
||||||
|
|
||||||
|
<a name="line161">161: </a><strong><font color="#4169E1"> public String getValue()</font></strong> {
|
||||||
|
<a name="line162">162: </a> <font color="#4169E1">return</font> null;
|
||||||
|
<a name="line163">163: </a> }
|
||||||
|
<a name="line164">164: </a> }
|
||||||
|
|
||||||
|
<a name="line166">166: </a> <font color="#B22222">// Services that this service depends on.</font>
|
||||||
|
<a name="line167">167: </a> private PDACommandControl fCommandControl;
|
||||||
|
<a name="line168">168: </a> private IRunControl fRunControl;
|
||||||
|
|
||||||
|
<a name="line170">170: </a> <font color="#B22222">// Command cache </font>
|
||||||
|
<a name="line171">171: </a> private CommandCache fCommandCache;
|
||||||
|
|
||||||
|
<a name="line173">173: </a><strong><font color="#4169E1"> public PDAStack(DsfSession session)</font></strong> {
|
||||||
|
<a name="line174">174: </a> super(session);
|
||||||
|
<a name="line175">175: </a> }
|
||||||
|
|
||||||
|
<a name="line177">177: </a> @Override
|
||||||
|
<a name="line178">178: </a><strong><font color="#4169E1"> protected BundleContext getBundleContext()</font></strong> {
|
||||||
|
<a name="line179">179: </a> <font color="#4169E1">return</font> PDAPlugin.getBundleContext();
|
||||||
|
<a name="line180">180: </a> }
|
||||||
|
|
||||||
|
<a name="line182">182: </a> @Override
|
||||||
|
<a name="line183">183: </a><strong><font color="#4169E1"> public void initialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line184">184: </a> super.initialize(
|
||||||
|
<a name="line185">185: </a> new RequestMonitor(getExecutor(), rm) {
|
||||||
|
<a name="line186">186: </a> @Override
|
||||||
|
<a name="line187">187: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line188">188: </a> doInitialize(rm);
|
||||||
|
<a name="line189">189: </a> }});
|
||||||
|
<a name="line190">190: </a> }
|
||||||
|
|
||||||
|
<a name="line192">192: </a><strong><font color="#4169E1"> private void doInitialize(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line193">193: </a> <font color="#B22222">// Initialize service references that stack service depends on</font>
|
||||||
|
<a name="line194">194: </a> fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
<a name="line195">195: </a> fRunControl = getServicesTracker().getService(IRunControl.class);
|
||||||
|
|
||||||
|
<a name="line197">197: </a> <font color="#B22222">// Create the commands cache</font>
|
||||||
|
<a name="line198">198: </a> fCommandCache = new CommandCache(fCommandControl);
|
||||||
|
|
||||||
|
<a name="line200">200: </a> <font color="#B22222">// Register to listen for run control events, to clear cache accordingly.</font>
|
||||||
|
<a name="line201">201: </a> getSession().addServiceEventListener(this, null);
|
||||||
|
|
||||||
|
<a name="line203">203: </a> <font color="#B22222">// Register stack service with OSGi</font>
|
||||||
|
<a name="line204">204: </a> register(new String[]{IStack.class.getName(), PDAStack.class.getName()}, new Hashtable<String,String>());
|
||||||
|
|
||||||
|
<a name="line206">206: </a> rm.done();
|
||||||
|
<a name="line207">207: </a> }
|
||||||
|
|
||||||
|
<a name="line209">209: </a> @Override
|
||||||
|
<a name="line210">210: </a><strong><font color="#4169E1"> public void shutdown(final RequestMonitor rm)</font></strong> {
|
||||||
|
<a name="line211">211: </a> getSession().removeServiceEventListener(this);
|
||||||
|
<a name="line212">212: </a> fCommandCache.reset();
|
||||||
|
<a name="line213">213: </a> super.shutdown(rm);
|
||||||
|
<a name="line214">214: </a> }
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line217">217: </a> public void getArguments(IFrameDMContext frameCtx, DataRequestMonitor<IVariableDMContext[]> rm) {
|
||||||
|
<a name="line218">218: </a> PDAPlugin.failRequest(rm, IDsfService.NOT_SUPPORTED, <font color="#666666">"PDA debugger does not support function arguments."</font>);
|
||||||
|
<a name="line219">219: </a> }
|
||||||
|
|
||||||
|
<a name="line221">221: </a> public void getFrameData(final IFrameDMContext frameCtx, final DataRequestMonitor<IFrameDMData> rm) {
|
||||||
|
<a name="line222">222: </a> <font color="#B22222">// Execute the PDA stack command, or retrieve the result from cache if already available.</font>
|
||||||
|
<a name="line223">223: </a> fCommandCache.execute(
|
||||||
|
<a name="line224">224: </a> new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
<a name="line225">225: </a> new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line226">226: </a> @Override
|
||||||
|
<a name="line227">227: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line228">228: </a> <font color="#B22222">// PDAFrame array is ordered highest to lowest. We need to </font>
|
||||||
|
<a name="line229">229: </a> <font color="#B22222">// calculate the index based on frame level.</font>
|
||||||
|
<a name="line230">230: </a> int frameId = getData().fFrames.length - frameCtx.getLevel() - 1;
|
||||||
|
<a name="line231">231: </a> <font color="#4169E1">if</font> (frameId < 0) {
|
||||||
|
<a name="line232">232: </a> PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, <font color="#666666">"Invalid frame level "</font> + frameCtx);
|
||||||
|
<a name="line233">233: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line234">234: </a> }
|
||||||
|
|
||||||
|
<a name="line236">236: </a> <font color="#B22222">// Create the frame data object based on the corresponding PDAFrame</font>
|
||||||
|
<a name="line237">237: </a> rm.setData(new FrameDMData(getData().fFrames[frameId]));
|
||||||
|
<a name="line238">238: </a> rm.done();
|
||||||
|
<a name="line239">239: </a> }
|
||||||
|
<a name="line240">240: </a> });
|
||||||
|
<a name="line241">241: </a> }
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line244">244: </a> public void getFrames(IDMContext context, final DataRequestMonitor<IFrameDMContext[]> rm) {
|
||||||
|
<a name="line245">245: </a> <font color="#B22222">// Can only create stack frames for an execution context as a parent, </font>
|
||||||
|
<a name="line246">246: </a> <font color="#B22222">// however the argument context is a generic context type, so it could </font>
|
||||||
|
<a name="line247">247: </a> <font color="#B22222">// be an execution context, a frame, a variable, etc. Search the </font>
|
||||||
|
<a name="line248">248: </a> <font color="#B22222">// hierarchy of the argument context to find the execution one.</font>
|
||||||
|
<a name="line249">249: </a> final IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
||||||
|
<a name="line250">250: </a> <font color="#4169E1">if</font> (execCtx == null) {
|
||||||
|
<a name="line251">251: </a> PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, <font color="#666666">"Invalid context "</font> + context);
|
||||||
|
<a name="line252">252: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line253">253: </a> }
|
||||||
|
|
||||||
|
<a name="line255">255: </a> <font color="#B22222">// Execute the stack command and create the corresponding frame contexts.</font>
|
||||||
|
<a name="line256">256: </a> fCommandCache.execute(
|
||||||
|
<a name="line257">257: </a> new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
<a name="line258">258: </a> new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line259">259: </a> @Override
|
||||||
|
<a name="line260">260: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line261">261: </a> IFrameDMContext[] frameCtxs = new IFrameDMContext[getData().fFrames.length];
|
||||||
|
<a name="line262">262: </a> <font color="#4169E1">for</font> (int i = 0; i < getData().fFrames.length; i++) {
|
||||||
|
<a name="line263">263: </a> frameCtxs[i] = new FrameDMContext(getSession().getId(), execCtx, i);
|
||||||
|
<a name="line264">264: </a> }
|
||||||
|
<a name="line265">265: </a> rm.setData(frameCtxs);
|
||||||
|
<a name="line266">266: </a> rm.done();
|
||||||
|
<a name="line267">267: </a> }
|
||||||
|
<a name="line268">268: </a> });
|
||||||
|
<a name="line269">269: </a> }
|
||||||
|
|
||||||
|
<a name="line271">271: </a> public void getLocals(final IFrameDMContext frameCtx, final DataRequestMonitor<IVariableDMContext[]> rm) {
|
||||||
|
<a name="line272">272: </a> <font color="#B22222">// Execute the stack command again.</font>
|
||||||
|
<a name="line273">273: </a> fCommandCache.execute(
|
||||||
|
<a name="line274">274: </a> new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
<a name="line275">275: </a> new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line276">276: </a> @Override
|
||||||
|
<a name="line277">277: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line278">278: </a> <font color="#B22222">// Find the correct PDAFrame</font>
|
||||||
|
<a name="line279">279: </a> int frameId = getData().fFrames.length - frameCtx.getLevel() - 1;
|
||||||
|
<a name="line280">280: </a> <font color="#4169E1">if</font> (frameId < 0) {
|
||||||
|
<a name="line281">281: </a> PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, <font color="#666666">"Invalid frame level "</font> + frameCtx);
|
||||||
|
<a name="line282">282: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line283">283: </a> }
|
||||||
|
<a name="line284">284: </a> PDAFrame pdaFrame = getData().fFrames[frameId];
|
||||||
|
|
||||||
|
<a name="line286">286: </a> <font color="#B22222">// Create variable contexts for all variables in frame.</font>
|
||||||
|
<a name="line287">287: </a> IVariableDMContext[] variableCtxs = new IVariableDMContext[pdaFrame.fVariables.length];
|
||||||
|
<a name="line288">288: </a> <font color="#4169E1">for</font> (int i = 0; i < pdaFrame.fVariables.length; i++) {
|
||||||
|
<a name="line289">289: </a> variableCtxs[i] = new VariableDMContext(getSession().getId(), frameCtx, pdaFrame.fVariables[i]);
|
||||||
|
<a name="line290">290: </a> }
|
||||||
|
<a name="line291">291: </a> rm.setData(variableCtxs);
|
||||||
|
<a name="line292">292: </a> rm.done();
|
||||||
|
<a name="line293">293: </a> }
|
||||||
|
<a name="line294">294: </a> });
|
||||||
|
|
||||||
|
<a name="line296">296: </a> }
|
||||||
|
|
||||||
|
<a name="line298">298: </a> public void getStackDepth(IDMContext context, int maxDepth, final DataRequestMonitor<Integer> rm) {
|
||||||
|
<a name="line299">299: </a> <font color="#B22222">// Execute stack command and return the data's size.</font>
|
||||||
|
<a name="line300">300: </a> fCommandCache.execute(
|
||||||
|
<a name="line301">301: </a> new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
<a name="line302">302: </a> new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
||||||
|
<a name="line303">303: </a> @Override
|
||||||
|
<a name="line304">304: </a><strong><font color="#4169E1"> protected void handleOK()</font></strong> {
|
||||||
|
<a name="line305">305: </a> rm.setData(getData().fFrames.length);
|
||||||
|
<a name="line306">306: </a> rm.done();
|
||||||
|
<a name="line307">307: </a> }
|
||||||
|
<a name="line308">308: </a> });
|
||||||
|
<a name="line309">309: </a> }
|
||||||
|
|
||||||
|
<a name="line311">311: </a> public void getTopFrame(IDMContext context, final DataRequestMonitor<IFrameDMContext> rm) {
|
||||||
|
<a name="line312">312: </a> <font color="#B22222">// Can only create stack frames for an execution context as a parent, </font>
|
||||||
|
<a name="line313">313: </a> <font color="#B22222">// however the argument context is a generic context type, so it could </font>
|
||||||
|
<a name="line314">314: </a> <font color="#B22222">// be an execution context, a frame, a variable, etc. Search the </font>
|
||||||
|
<a name="line315">315: </a> <font color="#B22222">// hierarchy of the argument context to find the execution one.</font>
|
||||||
|
<a name="line316">316: </a> final IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
||||||
|
<a name="line317">317: </a> <font color="#4169E1">if</font> (execCtx == null) {
|
||||||
|
<a name="line318">318: </a> PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, <font color="#666666">"Invalid context "</font> + context);
|
||||||
|
<a name="line319">319: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line320">320: </a> }
|
||||||
|
|
||||||
|
<a name="line322">322: </a> <font color="#B22222">// Since the frame context only contain the level, there's no need to </font>
|
||||||
|
<a name="line323">323: </a> <font color="#B22222">// call the PDA debugger. Simply create a context for level 0. </font>
|
||||||
|
<a name="line324">324: </a> rm.setData(new FrameDMContext(getSession().getId(), execCtx, 0));
|
||||||
|
<a name="line325">325: </a> rm.done();
|
||||||
|
<a name="line326">326: </a> }
|
||||||
|
|
||||||
|
<a name="line328">328: </a> public void getVariableData(IVariableDMContext variableCtx, DataRequestMonitor<IVariableDMData> rm) {
|
||||||
|
<a name="line329">329: </a> <font color="#4169E1">if</font> ( !(variableCtx instanceof VariableDMContext) ) {
|
||||||
|
<a name="line330">330: </a> PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, <font color="#666666">"Invalid context "</font> + variableCtx);
|
||||||
|
<a name="line331">331: </a> <font color="#4169E1">return</font>;
|
||||||
|
<a name="line332">332: </a> }
|
||||||
|
|
||||||
|
<a name="line334">334: </a> <font color="#B22222">// The variable data doen't contain a value. So there's no need to </font>
|
||||||
|
<a name="line335">335: </a> <font color="#B22222">// go to the back end to retrieve it.</font>
|
||||||
|
<a name="line336">336: </a> String variable = ((VariableDMContext)variableCtx).getVariable();
|
||||||
|
|
||||||
|
<a name="line338">338: </a> rm.setData(new VariableDMData(variable));
|
||||||
|
<a name="line339">339: </a> rm.done();
|
||||||
|
<a name="line340">340: </a> }
|
||||||
|
|
||||||
|
<a name="line342">342: </a><strong><font color="#4169E1"> public boolean isStackAvailable(IDMContext context)</font></strong> {
|
||||||
|
<a name="line343">343: </a> <font color="#B22222">// Stack is available if the program is suspended or stepping.</font>
|
||||||
|
<a name="line344">344: </a> IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
||||||
|
<a name="line345">345: </a> <font color="#4169E1">return</font> execCtx != null && (fRunControl.isSuspended(execCtx) || (fRunControl.isStepping(execCtx)));
|
||||||
|
<a name="line346">346: </a> }
|
||||||
|
|
||||||
|
<a name="line348">348: </a> @SuppressWarnings(<font color="#666666">"unchecked"</font>)
|
||||||
|
<a name="line349">349: </a> @Deprecated
|
||||||
|
<a name="line350">350: </a> public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
||||||
|
<a name="line351">351: </a> <font color="#B22222">// The getModelData() is deprecated and clients are expected to switch</font>
|
||||||
|
<a name="line352">352: </a> <font color="#B22222">// to getExecutionData() and other data retrieve methods directly.</font>
|
||||||
|
<a name="line353">353: </a> <font color="#B22222">// However the UI cache still uses it for now.</font>
|
||||||
|
<a name="line354">354: </a> <font color="#4169E1">if</font> (dmc instanceof IFrameDMContext) {
|
||||||
|
<a name="line355">355: </a> getFrameData((IFrameDMContext)dmc, (DataRequestMonitor<IFrameDMData>)rm);
|
||||||
|
<a name="line356">356: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (dmc instanceof IVariableDMContext) {
|
||||||
|
<a name="line357">357: </a> getVariableData((IVariableDMContext)dmc, (DataRequestMonitor<IVariableDMData>)rm);
|
||||||
|
<a name="line358">358: </a> } <font color="#4169E1">else</font> {
|
||||||
|
<a name="line359">359: </a> PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, <font color="#666666">"Unknown context type"</font>);
|
||||||
|
<a name="line360">360: </a> }
|
||||||
|
<a name="line361">361: </a> }
|
||||||
|
|
||||||
|
<a name="line363">363: </a> @DsfServiceEventHandler
|
||||||
|
<a name="line364">364: </a><strong><font color="#4169E1"> public void eventDispatched(IResumedDMEvent e)</font></strong> {
|
||||||
|
<a name="line365">365: </a> <font color="#B22222">// Mark the cache as not available, so that stack commands will</font>
|
||||||
|
<a name="line366">366: </a> <font color="#B22222">// fail. Also reset the cache unless it was a step command.</font>
|
||||||
|
<a name="line367">367: </a> fCommandCache.setTargetAvailable(false);
|
||||||
|
<a name="line368">368: </a> <font color="#4169E1">if</font> (!e.getReason().equals(StateChangeReason.STEP)) {
|
||||||
|
<a name="line369">369: </a> fCommandCache.reset();
|
||||||
|
<a name="line370">370: </a> }
|
||||||
|
<a name="line371">371: </a> }
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line374">374: </a> @DsfServiceEventHandler
|
||||||
|
<a name="line375">375: </a><strong><font color="#4169E1"> public void eventDispatched(ISuspendedDMEvent e)</font></strong> {
|
||||||
|
<a name="line376">376: </a> <font color="#B22222">// Enable sending commands to target and clear the cache.</font>
|
||||||
|
<a name="line377">377: </a> fCommandCache.setTargetAvailable(true);
|
||||||
|
<a name="line378">378: </a> fCommandCache.reset();
|
||||||
|
<a name="line379">379: </a> }
|
||||||
|
<a name="line380">380: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
||||||
|
@ -20,6 +21,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* a context. Since the PDA debugger protocol is stateless, the context is only
|
* a context. Since the PDA debugger protocol is stateless, the context is only
|
||||||
* needed to satisfy the ICommand interface.
|
* needed to satisfy the ICommand interface.
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
abstract public class AbstractPDACommand<V extends PDACommandResult> implements ICommand<V> {
|
abstract public class AbstractPDACommand<V extends PDACommandResult> implements ICommand<V> {
|
||||||
|
|
||||||
final private IDMContext fContext;
|
final private IDMContext fContext;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +22,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* </pre>
|
* </pre>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAClearBreakpointCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAClearBreakpointCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAClearBreakpointCommand(PDAProgramDMContext context, int line) {
|
public PDAClearBreakpointCommand(PDAProgramDMContext context, int line) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
||||||
* PDA response. Sub-classes may override to optionally parse the response text
|
* PDA response. Sub-classes may override to optionally parse the response text
|
||||||
* and return higher-level objects.
|
* and return higher-level objects.
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDACommandResult implements ICommandResult {
|
public class PDACommandResult implements ICommandResult {
|
||||||
|
|
||||||
final public String fResponseText;
|
final public String fResponseText;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,14 +21,15 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* R: {value 1}|{value 2}|{value 3}|...|
|
* R: {value 1}|{value 2}|{value 3}|...|
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class PDADataCommand extends AbstractPDACommand<PDACommandResult> {
|
@Immutable
|
||||||
|
public class PDADataCommand extends AbstractPDACommand<PDADataCommandResult> {
|
||||||
|
|
||||||
public PDADataCommand(PDAProgramDMContext context) {
|
public PDADataCommand(PDAProgramDMContext context) {
|
||||||
super(context, "data");
|
super(context, "data");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PDACommandResult createResult(String resultText) {
|
public PDADataCommandResult createResult(String resultText) {
|
||||||
return new PDACommandResult(resultText);
|
return new PDADataCommandResult(resultText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDADataCommand.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-03-11T23:19:44+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2008 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;</font>
|
||||||
|
|
||||||
|
<a name="line15"> 15: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#B22222"> * Retrieves data stack information </font>
|
||||||
|
<a name="line17"> 17: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line18"> 18: </a><font color="#B22222"> * <pre></font>
|
||||||
|
<a name="line19"> 19: </a><font color="#B22222"> * C: data</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#B22222"> * R: {value 1}|{value 2}|{value 3}|...|</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#B22222"> * </pre></font>
|
||||||
|
<a name="line22"> 22: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line23"> 23: </a><strong><font color="#4169E1"><a name="PDADataCommand"></a>public class PDADataCommand extends AbstractPDACommand</font></strong><PDADataCommandResult> {
|
||||||
|
|
||||||
|
<a name="line25"> 25: </a><strong><font color="#4169E1"> public PDADataCommand(PDAProgramDMContext context)</font></strong> {
|
||||||
|
<a name="line26"> 26: </a> super(context, <font color="#666666">"data"</font>);
|
||||||
|
<a name="line27"> 27: </a> }
|
||||||
|
<a name="line28"> 28: </a>
|
||||||
|
<a name="line29"> 29: </a> @Override
|
||||||
|
<a name="line30"> 30: </a><strong><font color="#4169E1"> public PDADataCommandResult createResult(String resultText)</font></strong> {
|
||||||
|
<a name="line31"> 31: </a> <font color="#4169E1">return</font> new PDADataCommandResult(resultText);
|
||||||
|
<a name="line32"> 32: </a> }
|
||||||
|
<a name="line33"> 33: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -14,10 +14,13 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PDADataCommand
|
* @see PDADataCommand
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDADataCommandResult extends PDACommandResult {
|
public class PDADataCommandResult extends PDACommandResult {
|
||||||
|
|
||||||
final public String[] fValues;
|
final public String[] fValues;
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDADataCommandResult.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-02-21T04:11:00+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2008 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import java.util.ArrayList;</font>
|
||||||
|
<a name="line14"> 14: </a><font color="#228B22">import java.util.List;</font>
|
||||||
|
<a name="line15"> 15: </a><font color="#228B22">import java.util.StringTokenizer;</font>
|
||||||
|
|
||||||
|
|
||||||
|
<a name="line18"> 18: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line19"> 19: </a><font color="#B22222"> * @see PDADataCommand</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line21"> 21: </a><strong><font color="#4169E1"><a name="PDADataCommandResult"></a>public class PDADataCommandResult extends PDACommandResult </font></strong>{
|
||||||
|
<a name="line22"> 22: </a>
|
||||||
|
<a name="line23"> 23: </a> final public String[] fValues;
|
||||||
|
<a name="line24"> 24: </a>
|
||||||
|
<a name="line25"> 25: </a> PDADataCommandResult(String response) {
|
||||||
|
<a name="line26"> 26: </a> super(response);
|
||||||
|
<a name="line27"> 27: </a> StringTokenizer st = new StringTokenizer(response, <font color="#666666">"|"</font>);
|
||||||
|
<a name="line28"> 28: </a> List<String> valuesList = new ArrayList<String>();
|
||||||
|
<a name="line29"> 29: </a>
|
||||||
|
<a name="line30"> 30: </a> <font color="#4169E1">while</font> (st.hasMoreTokens()) {
|
||||||
|
<a name="line31"> 31: </a> String token = st.nextToken();
|
||||||
|
<a name="line32"> 32: </a> <font color="#4169E1">if</font> (token.length() != 0) {
|
||||||
|
<a name="line33"> 33: </a> valuesList.add(st.nextToken());
|
||||||
|
<a name="line34"> 34: </a> }
|
||||||
|
<a name="line35"> 35: </a> }
|
||||||
|
<a name="line36"> 36: </a>
|
||||||
|
<a name="line37"> 37: </a> fValues = new String[valuesList.size()];
|
||||||
|
<a name="line38"> 38: </a> <font color="#4169E1">for</font> (int i = 0; i < valuesList.size(); i++) {
|
||||||
|
<a name="line39"> 39: </a> fValues[i] = valuesList.get(i);
|
||||||
|
<a name="line40"> 40: </a> }
|
||||||
|
<a name="line41"> 41: </a> }
|
||||||
|
<a name="line42"> 42: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +24,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* </pre>
|
* </pre>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDADropFrameCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDADropFrameCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDADropFrameCommand(PDAProgramDMContext context) {
|
public PDADropFrameCommand(PDAProgramDMContext context) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +26,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
*
|
*
|
||||||
* Where event_name could be <code>unimpinstr</code> or <code>nosuchlabel</code>.
|
* Where event_name could be <code>unimpinstr</code> or <code>nosuchlabel</code>.
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAEvalCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAEvalCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAEvalCommand(PDAProgramDMContext context, String operation) {
|
public PDAEvalCommand(PDAProgramDMContext context, String operation) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +25,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
*
|
*
|
||||||
* Where event_name could be <code>unimpinstr</code> or <code>nosuchlabel</code>.
|
* Where event_name could be <code>unimpinstr</code> or <code>nosuchlabel</code>.
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAEventStopCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAEventStopCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public enum Event { UNIMPINSTR, NOSUCHLABEL };
|
public enum Event { UNIMPINSTR, NOSUCHLABEL };
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* R: ok
|
* R: ok
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAExitCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAExitCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAExitCommand(PDAProgramDMContext context) {
|
public PDAExitCommand(PDAProgramDMContext context) {
|
||||||
|
|
|
@ -16,12 +16,14 @@ import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object representing a frame in the stack command results.
|
* Object representing a frame in the stack command results.
|
||||||
*
|
*
|
||||||
* @see PDAStackCommand
|
* @see PDAStackCommand
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAFrame {
|
public class PDAFrame {
|
||||||
|
|
||||||
final public IPath fFilePath;
|
final public IPath fFilePath;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* R: ok
|
* R: ok
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAPopDataCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAPopDataCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAPopDataCommand(PDAProgramDMContext context) {
|
public PDAPopDataCommand(PDAProgramDMContext context) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* R: ok
|
* R: ok
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAPushDataCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAPushDataCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAPushDataCommand(PDAProgramDMContext context, int value) {
|
public PDAPushDataCommand(PDAProgramDMContext context, int value) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +22,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* E: resumed client
|
* E: resumed client
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAResumeCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAResumeCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAResumeCommand(PDAProgramDMContext context) {
|
public PDAResumeCommand(PDAProgramDMContext context) {
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PDAResumeCommand.java</title>
|
||||||
|
<meta name="generator" content="java2html 0.9.2">
|
||||||
|
<meta name="date" content="2008-02-21T04:11:00+00:00">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF">
|
||||||
|
<pre width="80"><a name="line1"> 1: </a><font color="#B22222">/*******************************************************************************</font>
|
||||||
|
<a name="line2"> 2: </a><font color="#B22222"> * Copyright (c) 2008 Wind River Systems and others.</font>
|
||||||
|
<a name="line3"> 3: </a><font color="#B22222"> * All rights reserved. This program and the accompanying materials</font>
|
||||||
|
<a name="line4"> 4: </a><font color="#B22222"> * are made available under the terms of the Eclipse Public License v1.0</font>
|
||||||
|
<a name="line5"> 5: </a><font color="#B22222"> * which accompanies this distribution, and is available at</font>
|
||||||
|
<a name="line6"> 6: </a><font color="#B22222"> * http://www.eclipse.org/legal/epl-v10.html</font>
|
||||||
|
<a name="line7"> 7: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line8"> 8: </a><font color="#B22222"> * Contributors:</font>
|
||||||
|
<a name="line9"> 9: </a><font color="#B22222"> * Wind River Systems - initial API and implementation</font>
|
||||||
|
<a name="line10"> 10: </a><font color="#B22222"> *******************************************************************************/</font>
|
||||||
|
<a name="line11"> 11: </a>package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
<a name="line13"> 13: </a><font color="#228B22">import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;</font>
|
||||||
|
|
||||||
|
<a name="line15"> 15: </a><font color="#B22222">/**</font>
|
||||||
|
<a name="line16"> 16: </a><font color="#B22222"> * Resumes the execution </font>
|
||||||
|
<a name="line17"> 17: </a><font color="#B22222"> * </font>
|
||||||
|
<a name="line18"> 18: </a><font color="#B22222"> * <pre></font>
|
||||||
|
<a name="line19"> 19: </a><font color="#B22222"> * C: resume</font>
|
||||||
|
<a name="line20"> 20: </a><font color="#B22222"> * R: ok</font>
|
||||||
|
<a name="line21"> 21: </a><font color="#B22222"> * E: resumed client</font>
|
||||||
|
<a name="line22"> 22: </a><font color="#B22222"> * </pre></font>
|
||||||
|
<a name="line23"> 23: </a><font color="#B22222"> */</font>
|
||||||
|
<a name="line24"> 24: </a><strong><font color="#4169E1"><a name="PDAResumeCommand"></a>public class PDAResumeCommand extends AbstractPDACommand</font></strong><PDACommandResult> {
|
||||||
|
|
||||||
|
<a name="line26"> 26: </a><strong><font color="#4169E1"> public PDAResumeCommand(PDAProgramDMContext context)</font></strong> {
|
||||||
|
<a name="line27"> 27: </a> super(context, <font color="#666666">"resume"</font>);
|
||||||
|
<a name="line28"> 28: </a> }
|
||||||
|
<a name="line29"> 29: </a>
|
||||||
|
<a name="line30"> 30: </a> @Override
|
||||||
|
<a name="line31"> 31: </a><strong><font color="#4169E1"> public PDACommandResult createResult(String resultText)</font></strong> {
|
||||||
|
<a name="line32"> 32: </a> <font color="#4169E1">return</font> new PDACommandResult(resultText);
|
||||||
|
<a name="line33"> 33: </a> }
|
||||||
|
<a name="line34"> 34: </a>}
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +24,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* E: suspended breakpoint line_number
|
* E: suspended breakpoint line_number
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDASetBreakpointCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDASetBreakpointCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDASetBreakpointCommand(PDAProgramDMContext context, int line) {
|
public PDASetBreakpointCommand(PDAProgramDMContext context, int line) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* R: ok
|
* R: ok
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDASetDataCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDASetDataCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDASetDataCommand(PDAProgramDMContext context, int index, String value) {
|
public PDASetDataCommand(PDAProgramDMContext context, int index, String value) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* R: ok
|
* R: ok
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDASetVarCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDASetVarCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDASetVarCommand(PDAProgramDMContext context, int frame, String variable, String value) {
|
public PDASetVarCommand(PDAProgramDMContext context, int frame, String variable, String value) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* R: {file}|{line}|{function}|{var_1}|{var_2}|...#{file}|{line}|{function}|{var_1}|{var_2}|...#...
|
* R: {file}|{line}|{function}|{var_1}|{var_2}|...#{file}|{line}|{function}|{var_1}|{var_2}|...#...
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAStackCommand extends AbstractPDACommand<PDAStackCommandResult> {
|
public class PDAStackCommand extends AbstractPDACommand<PDAStackCommandResult> {
|
||||||
|
|
||||||
public PDAStackCommand(PDAProgramDMContext context) {
|
public PDAStackCommand(PDAProgramDMContext context) {
|
||||||
|
|
|
@ -14,10 +14,13 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PDAStackCommand
|
* @see PDAStackCommand
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAStackCommandResult extends PDACommandResult {
|
public class PDAStackCommandResult extends PDACommandResult {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes next instruciton
|
* Executes next instruction
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* C: step
|
* C: step
|
||||||
|
@ -22,6 +23,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* E: suspended step
|
* E: suspended step
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAStepCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAStepCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAStepCommand(PDAProgramDMContext context) {
|
public PDAStepCommand(PDAProgramDMContext context) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +23,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* E: suspended step
|
* E: suspended step
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAStepReturnCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAStepReturnCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAStepReturnCommand(PDAProgramDMContext context) {
|
public PDAStepReturnCommand(PDAProgramDMContext context) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +22,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* E: suspended client
|
* E: suspended client
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDASuspendCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDASuspendCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDASuspendCommand(PDAProgramDMContext context) {
|
public PDASuspendCommand(PDAProgramDMContext context) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* R: {variable_value}
|
* R: {variable_value}
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAVarCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAVarCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAVarCommand(PDAProgramDMContext context, int frameId, String name) {
|
public PDAVarCommand(PDAProgramDMContext context, int frameId, String name) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +24,7 @@ import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
* E: suspended watch {watch_operation} {function}::{variable_name}
|
* E: suspended watch {watch_operation} {function}::{variable_name}
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class PDAWatchCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAWatchCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public enum WatchOperation { READ, WRITE, BOTH, NONE };
|
public enum WatchOperation { READ, WRITE, BOTH, NONE };
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
|
||||||
*/
|
*/
|
||||||
public class PDASourceLookupDirector extends AbstractSourceLookupDirector {
|
public class PDASourceLookupDirector extends AbstractSourceLookupDirector {
|
||||||
public void initializeParticipants() {
|
public void initializeParticipants() {
|
||||||
// No need to add participants here, the surce display adapter will
|
// No need to add participants here, the source display adapter will
|
||||||
// add the participant with the correct session ID.
|
// add the participant with the correct session ID.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue