From 1416e8c3e9b7d58772830812ead29ecf042539d8 Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Wed, 20 Feb 2008 00:49:38 +0000 Subject: [PATCH] [216854] Completed features for EclipseCon tutorial. --- .../eclipse/dd/examples/pda/PDAPlugin.java | 2 +- .../pda/breakpoints/PDALineBreakpoint.java | 2 +- .../pda/breakpoints/PDAWatchpoint.java | 2 +- .../dd/examples/pda/launch/PDALaunch.java | 106 +++++---- .../pda/launch/PDALaunchDelegate.java | 23 +- .../pda/launch/PDAServicesInitSequence.java | 47 ++-- .../launch/PDAServicesShutdownSequence.java | 8 +- .../service/breakpoints/PDABreakpoints.java | 24 +- .../service/command/PDACommandControl.java | 27 +-- .../pda/service/command/PDACommandResult.java | 32 ++- ...mmandBase.java => AbstractPDACommand.java} | 10 +- .../commands/PDAClearBreakpointCommand.java | 13 +- .../commands/PDACommandBaseResult.java | 44 ---- .../command/commands/PDADataCommand.java | 11 +- .../commands/PDADataCommandResult.java | 4 +- .../command/commands/PDADropFrameCommand.java | 11 +- .../command/commands/PDAEvalCommand.java | 11 +- .../command/commands/PDAEventStopCommand.java | 11 +- .../command/commands/PDAExitCommand.java | 11 +- .../service/command/commands/PDAFrame.java | 38 +++ .../command/commands/PDAPopDataCommand.java | 11 +- .../command/commands/PDAPushDataCommand.java | 11 +- .../command/commands/PDAResumeCommand.java | 11 +- .../commands/PDASetBreakpointCommand.java | 13 +- .../command/commands/PDASetDataCommand.java | 11 +- .../command/commands/PDASetVarCommand.java | 11 +- .../command/commands/PDAStackCommand.java | 10 +- .../commands/PDAStackCommandResult.java | 33 +-- .../command/commands/PDAStepCommand.java | 11 +- .../commands/PDAStepReturnCommand.java | 11 +- .../command/commands/PDASuspendCommand.java | 11 +- .../command/commands/PDAVarCommand.java | 13 +- .../command/commands/PDAVarCommandResult.java | 4 +- .../command/commands/PDAWatchCommand.java | 11 +- .../expressions/ExpressionDMContext.java | 48 ++++ .../service/expressions/ExpressionDMData.java | 61 +++++ .../InvalidExpressionDMContext.java | 48 ++++ .../service/expressions/PDAExpressions.java | 224 ++++++++++++++++++ .../pda/service/runcontrol/PDARunControl.java | 10 +- .../pda/service/stack/FrameDMContext.java | 7 +- .../pda/service/stack/FrameDMData.java | 6 +- .../examples/pda/service/stack/PDAStack.java | 131 +++++----- .../tests/pda/service/command/BasicTests.java | 3 +- .../command/CommandControlTestsBase.java | 3 +- .../pda/service/command/PDATestCommand.java} | 11 +- .../sourcelookup/PDASourceLookupDirector.java | 14 +- .../PDASourceLookupParticipant.java | 29 --- 47 files changed, 780 insertions(+), 424 deletions(-) rename plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/{PDACommandBase.java => AbstractPDACommand.java} (79%) delete mode 100644 plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDACommandBaseResult.java create mode 100644 plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAFrame.java create mode 100644 plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/ExpressionDMContext.java create mode 100644 plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/ExpressionDMData.java create mode 100644 plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/InvalidExpressionDMContext.java create mode 100644 plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/PDAExpressions.java rename plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/{examples/pda/service/command/PDACommand.java => tests/pda/service/command/PDATestCommand.java} (63%) delete mode 100644 plugins/org.eclipse.dd.examples.pda/src/org/eclipse/debug/examples/core/pda/sourcelookup/PDASourceLookupParticipant.java diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/PDAPlugin.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/PDAPlugin.java index d910c04dd5d..2df42155121 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/PDAPlugin.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/PDAPlugin.java @@ -169,7 +169,7 @@ public class PDAPlugin extends Plugin { Query launchShutdownQuery = new Query() { @Override protected void execute(DataRequestMonitor rm) { - pdaLaunch.shutdownSession(rm); + pdaLaunch.shutdownServices(rm); } }; diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDALineBreakpoint.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDALineBreakpoint.java index cf93ba6b6d4..bc518e16fe0 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDALineBreakpoint.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDALineBreakpoint.java @@ -48,7 +48,7 @@ public class PDALineBreakpoint extends LineBreakpoint { public PDALineBreakpoint(final IResource resource, final int lineNumber) throws CoreException { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { - IMarker marker = resource.createMarker("org.eclipse.debug.examples.core.pda.markerType.lineBreakpoint"); + IMarker marker = resource.createMarker("org.eclipse.dd.examples.pda.markerType.lineBreakpoint"); setMarker(marker); marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE); marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDAWatchpoint.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDAWatchpoint.java index 809d149e6f4..ac3e9bcc80a 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDAWatchpoint.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDAWatchpoint.java @@ -59,7 +59,7 @@ public class PDAWatchpoint extends PDALineBreakpoint implements IWatchpoint { public PDAWatchpoint(final IResource resource, final int lineNumber, final String functionName, final String varName, final boolean access, final boolean modification) throws CoreException { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { - IMarker marker = resource.createMarker("org.eclipse.debug.examples.core.pda.markerType.watchpoint"); + IMarker marker = resource.createMarker("org.eclipse.dd.examples.pda.markerType.watchpoint"); setMarker(marker); setEnabled(true); ensureMarker().setAttribute(IMarker.LINE_NUMBER, lineNumber); diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunch.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunch.java index 8b5020cf440..587d8c993fc 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunch.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunch.java @@ -10,18 +10,12 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.launch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor; import org.eclipse.dd.dsf.concurrent.DefaultDsfExecutor; import org.eclipse.dd.dsf.concurrent.DsfExecutor; -import org.eclipse.dd.dsf.concurrent.DsfRunnable; import org.eclipse.dd.dsf.concurrent.ImmediateExecutor; import org.eclipse.dd.dsf.concurrent.RequestMonitor; import org.eclipse.dd.dsf.concurrent.Sequence; @@ -29,7 +23,6 @@ import org.eclipse.dd.dsf.concurrent.ThreadSafe; import org.eclipse.dd.dsf.service.DsfServiceEventHandler; import org.eclipse.dd.dsf.service.DsfServicesTracker; import org.eclipse.dd.dsf.service.DsfSession; -import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.examples.pda.PDAPlugin; import org.eclipse.dd.examples.pda.service.command.PDATerminatedEvent; import org.eclipse.debug.core.DebugException; @@ -52,8 +45,9 @@ public class PDALaunch extends Launch @ConfinedToDsfExecutor("getSession().getExecutor()") private DsfServicesTracker fTracker; - private AtomicBoolean fInitialized = new AtomicBoolean(false); - private AtomicBoolean fShutDown = new AtomicBoolean(false); + private Sequence fInitializationSequence = null; + private boolean fInitialized = false; + private boolean fShutDown = false; public PDALaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) { super(launchConfiguration, mode, locator); @@ -70,42 +64,53 @@ public class PDALaunch extends Launch public DsfSession getSession() { return fSession; } - @ConfinedToDsfExecutor("getExecutor") - public void initializeControl() - throws CoreException + @ConfinedToDsfExecutor("getSession().getExecutor()") + public void initializeServices(String program, int requestPort, int eventPort, final RequestMonitor rm) { + fTracker = new DsfServicesTracker(PDAPlugin.getBundleContext(), fSession.getId()); + fSession.addServiceEventListener(PDALaunch.this, null); - Runnable initRunnable = new DsfRunnable() { - public void run() { - fTracker = new DsfServicesTracker(PDAPlugin.getBundleContext(), fSession.getId()); - fSession.addServiceEventListener(PDALaunch.this, null); - fInitialized.set(true); - fireChanged(); - } - }; - - // Invoke the execution code and block waiting for the result. - try { - fExecutor.submit(initRunnable).get(); - } catch (InterruptedException e) { - throw new CoreException(new Status( - IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "Error initializing launch", e)); //$NON-NLS-1$ - } catch (ExecutionException e) { - throw new CoreException(new Status( - IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "Error initializing launch", e.getCause())); //$NON-NLS-1$ + synchronized(this) { + fInitializationSequence = new PDAServicesInitSequence( + getSession(), this, program, requestPort, eventPort, + new RequestMonitor(ImmediateExecutor.getInstance(), rm) { + @Override + protected void handleCompleted() { + boolean doShutdown = false; + synchronized (this) + { + fInitialized = true; + fInitializationSequence = null; + if (fShutDown) { + doShutdown = true; + } + } + if (doShutdown) { + doShutdown(rm); + } else { + if (getStatus().getSeverity() == IStatus.ERROR) { + rm.setStatus(getStatus()); + } + rm.done(); + } + fireChanged(); + } + }); } + getSession().getExecutor().execute(fInitializationSequence); } - @DsfServiceEventHandler public void eventDispatched(PDATerminatedEvent event) { - shutdownSession(new RequestMonitor(ImmediateExecutor.getInstance(), null)); + @DsfServiceEventHandler + public void eventDispatched(PDATerminatedEvent event) { + shutdownServices(new RequestMonitor(ImmediateExecutor.getInstance(), null)); } - public boolean isInitialized() { - return fInitialized.get(); + public synchronized boolean isInitialized() { + return fInitialized; } - public boolean isShutDown() { - return fShutDown.get(); + public synchronized boolean isShutDown() { + return fShutDown; } @Override @@ -138,13 +143,27 @@ public class PDALaunch extends Launch * @param rm The request monitor invoked when the shutdown is complete. */ @ConfinedToDsfExecutor("getSession().getExecutor()") - public void shutdownSession(final RequestMonitor rm) { - if (fShutDown.getAndSet(true)) { - rm.done(); - return; + public void shutdownServices(final RequestMonitor rm) { + boolean doShutdown = false; + synchronized (this) { + if (!fInitialized && fInitializationSequence != null) { + fInitializationSequence.cancel(false); + } else { + doShutdown = !fShutDown && fInitialized; + } + fShutDown = true; } - - Sequence shutdownSeq = new PDAServicesShutdownSequence( + + if (doShutdown) { + doShutdown(rm); + } else { + rm.done(); + } + } + + @ConfinedToDsfExecutor("getSession().getExecutor()") + private void doShutdown(final RequestMonitor rm) { + fExecutor.execute( new PDAServicesShutdownSequence( getDsfExecutor(), fSession.getId(), new RequestMonitor(fSession.getExecutor(), rm) { @Override @@ -166,8 +185,7 @@ public class PDALaunch extends Launch rm.setStatus(getStatus()); rm.done(); } - }); - fExecutor.execute(shutdownSeq); + }) ); } @SuppressWarnings("unchecked") diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunchDelegate.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunchDelegate.java index 8a6c57ee116..0f203cf26d4 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunchDelegate.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunchDelegate.java @@ -28,6 +28,8 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.IValueVariable; import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.dd.dsf.concurrent.DataRequestMonitor; +import org.eclipse.dd.dsf.concurrent.Query; import org.eclipse.dd.examples.pda.PDAPlugin; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; @@ -99,12 +101,8 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate { } launchProcess(launch, program, requestPort, eventPort); - PDALaunch pdaLaunch = (PDALaunch)launch; - initServices(pdaLaunch, program, requestPort, eventPort); - - pdaLaunch.initializeControl(); } private void launchProcess(ILaunch launch, String program, int requestPort, int eventPort) throws CoreException { @@ -149,12 +147,19 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate { DebugPlugin.newProcess(launch, process, path); } - private void initServices(PDALaunch pdaLaunch, String program, int requestPort, int eventPort) throws CoreException { - final PDAServicesInitSequence initSequence = - new PDAServicesInitSequence(pdaLaunch.getSession(), pdaLaunch, program, requestPort, eventPort); - pdaLaunch.getSession().getExecutor().execute(initSequence); + private void initServices(final PDALaunch pdaLaunch, final String program, final int requestPort, final int eventPort) + throws CoreException + { + Query initQuery = new Query() { + @Override + protected void execute(DataRequestMonitor rm) { + pdaLaunch.initializeServices(program, requestPort, eventPort, rm); + } + }; + + pdaLaunch.getSession().getExecutor().execute(initQuery); try { - initSequence.get(); + initQuery.get(); } catch (InterruptedException e1) { throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, "Interrupted Exception in dispatch thread", e1)); //$NON-NLS-1$ } catch (ExecutionException e1) { diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDAServicesInitSequence.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDAServicesInitSequence.java index 60bed1a808c..38b17950fd7 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDAServicesInitSequence.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDAServicesInitSequence.java @@ -18,6 +18,7 @@ import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.examples.pda.service.breakpoints.PDABreakpointAttributeTranslator; import org.eclipse.dd.examples.pda.service.breakpoints.PDABreakpoints; import org.eclipse.dd.examples.pda.service.command.PDACommandControl; +import org.eclipse.dd.examples.pda.service.expressions.PDAExpressions; import org.eclipse.dd.examples.pda.service.runcontrol.PDARunControl; import org.eclipse.dd.examples.pda.service.stack.PDAStack; import org.eclipse.debug.examples.core.pda.sourcelookup.PDASourceLookupDirector; @@ -37,7 +38,8 @@ public class PDAServicesInitSequence extends Sequence { new Step() { @Override public void execute(RequestMonitor requestMonitor) { - new PDARunControl(fSession).initialize(requestMonitor); + fRunControl = new PDARunControl(fSession); + fRunControl.initialize(requestMonitor); } }, new Step() { @@ -71,38 +73,16 @@ public class PDAServicesInitSequence extends Sequence { new PDAStack(fSession).initialize(requestMonitor); } }, - /*new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - new ExpressionService(fSession).initialize(requestMonitor); - }}, new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - fSourceLookup = new CSourceLookup(fSession); - fSourceLookup.initialize(requestMonitor); - }}, + public void execute(RequestMonitor requestMonitor) { + new PDAExpressions(fSession).initialize(requestMonitor); + } + }, new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - fSourceLookup.setSourceLookupDirector( - fCommandControl.getGDBDMContext(), - ((CSourceLookupDirector)fLaunch.getSourceLocator())); - requestMonitor.done(); - }}, - new Step() { @Override - public void execute(final RequestMonitor requestMonitor) { - // Create high-level breakpoint service and install breakpoints - // for the GDB debug context. - final MIBreakpointsManager bpmService = new MIBreakpointsManager(fSession, CDebugCorePlugin.PLUGIN_ID); - bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) { - @Override - protected void handleOK() { - bpmService.startTrackingBreakpoints(fCommandControl.getGDBDMContext(), requestMonitor); - } - }); - }}, - new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - new MIRegisters(fSession).initialize(requestMonitor); - }},*/ + public void execute(RequestMonitor requestMonitor) { + fRunControl.resume(fCommandControl.getDMContext(), requestMonitor); + } + }, }; private DsfSession fSession; @@ -112,12 +92,13 @@ public class PDAServicesInitSequence extends Sequence { private int fEventPort; PDACommandControl fCommandControl; + PDARunControl fRunControl; PDASourceLookupDirector fSourceLookup; public PDAServicesInitSequence(DsfSession session, PDALaunch launch, String program, int requestPort, - int eventPort) + int eventPort, RequestMonitor rm) { - super(session.getExecutor()); + super(session.getExecutor(), rm); fSession = session; fLaunch = launch; fProgram = program; diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDAServicesShutdownSequence.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDAServicesShutdownSequence.java index db75615afc4..583c11b3908 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDAServicesShutdownSequence.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDAServicesShutdownSequence.java @@ -22,6 +22,7 @@ import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.examples.pda.PDAPlugin; import org.eclipse.dd.examples.pda.service.breakpoints.PDABreakpoints; import org.eclipse.dd.examples.pda.service.command.PDACommandControl; +import org.eclipse.dd.examples.pda.service.expressions.PDAExpressions; import org.eclipse.dd.examples.pda.service.runcontrol.PDARunControl; import org.eclipse.dd.examples.pda.service.stack.PDAStack; @@ -75,12 +76,13 @@ public class PDAServicesShutdownSequence extends Sequence { public void execute(RequestMonitor requestMonitor) { shutdownService(CSourceLookup.class, requestMonitor); } - }, new Step() { + },*/ + new Step() { @Override public void execute(RequestMonitor requestMonitor) { - shutdownService(ExpressionService.class, requestMonitor); + shutdownService(PDAExpressions.class, requestMonitor); } - },*/ + }, new Step() { @Override public void execute(RequestMonitor requestMonitor) { diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/breakpoints/PDABreakpoints.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/breakpoints/PDABreakpoints.java index 4f9625ba0f0..c943d8ae43c 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/breakpoints/PDABreakpoints.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/breakpoints/PDABreakpoints.java @@ -25,9 +25,11 @@ import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.examples.pda.PDAPlugin; import org.eclipse.dd.examples.pda.breakpoints.PDAWatchpoint; -import org.eclipse.dd.examples.pda.service.command.PDACommand; import org.eclipse.dd.examples.pda.service.command.PDACommandControl; import org.eclipse.dd.examples.pda.service.command.PDACommandResult; +import org.eclipse.dd.examples.pda.service.command.commands.PDAClearBreakpointCommand; +import org.eclipse.dd.examples.pda.service.command.commands.PDASetBreakpointCommand; +import org.eclipse.dd.examples.pda.service.command.commands.PDAWatchCommand; import org.osgi.framework.BundleContext; /** @@ -148,7 +150,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints fBreakpoints.add(breakpointCtx); fCommandControl.queueCommand( - new PDACommand(fCommandControl.getDMContext(), "set " + line), + new PDASetBreakpointCommand(fCommandControl.getDMContext(), line), new DataRequestMonitor(getExecutor(), rm) { @Override protected void handleOK() { @@ -191,20 +193,18 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints return; } - int watchOperation = 0; + PDAWatchCommand.WatchOperation watchOperation = PDAWatchCommand.WatchOperation.NONE; if (isAccess && isModification) { - watchOperation = 3; + watchOperation = PDAWatchCommand.WatchOperation.BOTH; } else if (isAccess) { - watchOperation = 1; + watchOperation = PDAWatchCommand.WatchOperation.READ; } else if (isModification) { - watchOperation = 2; + watchOperation = PDAWatchCommand.WatchOperation.WRITE; } - String watchCommand = "watch " + function + "::" + variable + " " + watchOperation; - fBreakpoints.add(watchpointCtx); fCommandControl.queueCommand( - new PDACommand(fCommandControl.getDMContext(), watchCommand), + new PDAWatchCommand(fCommandControl.getDMContext(), function, variable, watchOperation), new DataRequestMonitor(getExecutor(), rm) { @Override protected void handleOK() { @@ -244,7 +244,7 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints fBreakpoints.remove(bpCtx); fCommandControl.queueCommand( - new PDACommand(fCommandControl.getDMContext(), "clear " + bpCtx.fLine), + new PDAClearBreakpointCommand(fCommandControl.getDMContext(), bpCtx.fLine), new DataRequestMonitor(getExecutor(), rm)); } @@ -252,9 +252,9 @@ public class PDABreakpoints extends AbstractDsfService implements IBreakpoints fBreakpoints.remove(bpCtx); // Watchpoints are cleared using the same command, but with a "no watch" operation - String command = "watch " + bpCtx.fFunction + "::" + bpCtx.fVariable + " 0"; fCommandControl.queueCommand( - new PDACommand(fCommandControl.getDMContext(), command), + new PDAWatchCommand(fCommandControl.getDMContext(), bpCtx.fFunction, bpCtx.fVariable, + PDAWatchCommand.WatchOperation.NONE), new DataRequestMonitor(getExecutor(), rm)); } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommandControl.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommandControl.java index c2e6b5675f4..1c8013e1f7d 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommandControl.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommandControl.java @@ -32,8 +32,7 @@ import org.eclipse.dd.dsf.service.AbstractDsfService; import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.examples.pda.PDAPlugin; -import org.eclipse.dd.examples.pda.service.command.commands.PDACommandBase; -import org.eclipse.dd.examples.pda.service.command.commands.PDACommandBaseResult; +import org.eclipse.dd.examples.pda.service.command.commands.AbstractPDACommand; import org.eclipse.dd.examples.pda.service.command.commands.PDAExitCommand; import org.osgi.framework.BundleContext; @@ -45,10 +44,10 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon // Structure used to store command information in services internal queues. private static class CommandHandle { - final private PDACommandBase fCommand; - final private DataRequestMonitor fRequestMonitor; + final private AbstractPDACommand fCommand; + final private DataRequestMonitor fRequestMonitor; - CommandHandle(PDACommandBase c, DataRequestMonitor rm) { + CommandHandle(AbstractPDACommand c, DataRequestMonitor rm) { fCommand = c; fRequestMonitor = rm; } @@ -300,16 +299,16 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon } public void queueCommand(ICommand command, DataRequestMonitor rm) { - if (command instanceof PDACommandBase) { + if (command instanceof AbstractPDACommand) { // Cast from command with "" to a more concrete // type to use internally in the command control. @SuppressWarnings("unchecked") - PDACommandBase pdaCommand = (PDACommandBase)command; + AbstractPDACommand pdaCommand = (AbstractPDACommand)command; // Similarly, cast the request monitor to a more concrete type. @SuppressWarnings("unchecked") - DataRequestMonitor pdaRM = (DataRequestMonitor)rm; - + DataRequestMonitor pdaRM = (DataRequestMonitor)rm; + fCommandQueue.add( new CommandHandle(pdaCommand, pdaRM) ); for (ICommandListener listener : fCommandListeners) { listener.commandQueued(command); @@ -362,9 +361,9 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon } private void processCommandDone(CommandHandle handle, String response) { - PDAPlugin.debug(response); + PDAPlugin.debug("R: " + response); - PDACommandBaseResult result = handle.fCommand.createResult(response); + PDACommandResult result = handle.fCommand.createResult(response); handle.fRequestMonitor.setData(result); handle.fRequestMonitor.done(); @@ -385,7 +384,7 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon } private void processEventReceived(String event) { - PDAPlugin.debug(event); + PDAPlugin.debug("E: " + event); for (IEventListener listener : fEventListeners) { listener.eventReceived(event); } @@ -408,7 +407,7 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon // - and there are commands waiting to be sent. CommandHandle handle = fCommandQueue.remove(0); fTxCommands.add(handle); - PDAPlugin.debug(handle.fCommand.getRequest()); + PDAPlugin.debug("C: " + handle.fCommand.getRequest()); for (ICommandListener listener : fCommandListeners) { listener.commandSent(handle.fCommand); } @@ -468,7 +467,7 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon if (!isTerminated()) { queueCommand( new PDAExitCommand(fDMContext), - new DataRequestMonitor(getExecutor(), rm)); + new DataRequestMonitor(getExecutor(), rm)); } else { // If already terminated, indicate success. rm.done(); diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommandResult.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommandResult.java index 1d81993739a..31f49a68b55 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommandResult.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommandResult.java @@ -10,14 +10,36 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command; -import org.eclipse.dd.examples.pda.service.command.commands.PDACommandBaseResult; +import org.eclipse.dd.dsf.debug.service.command.ICommand; +import org.eclipse.dd.dsf.debug.service.command.ICommandResult; /** - * @see PDACommand + * */ -public class PDACommandResult extends PDACommandBaseResult { - PDACommandResult(String response) { - super(response); +public class PDACommandResult implements ICommandResult { + + final public String fResponseText; + + public PDACommandResult(String response) { + fResponseText = response; + } + + public V getSubsetResult(ICommand command) { + return null; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof PDACommandResult) { + PDACommandResult result = (PDACommandResult)obj; + return fResponseText.equals(result.fResponseText); + } + return false; + } + + @Override + public int hashCode() { + return fResponseText.hashCode(); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDACommandBase.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/AbstractPDACommand.java similarity index 79% rename from plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDACommandBase.java rename to plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/AbstractPDACommand.java index 1c0c8e82c3c..719df9cd6ae 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDACommandBase.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/AbstractPDACommand.java @@ -13,16 +13,18 @@ package org.eclipse.dd.examples.pda.service.command.commands; import org.eclipse.dd.dsf.datamodel.IDMContext; import org.eclipse.dd.dsf.debug.service.command.ICommand; import org.eclipse.dd.dsf.debug.service.command.ICommandResult; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * */ -abstract public class PDACommandBase implements ICommand { +abstract public class AbstractPDACommand implements ICommand { final private IDMContext fContext; final private String fRequest; - public PDACommandBase(IDMContext context, String request) { + public AbstractPDACommand(PDACommandControlDMContext context, String request) { fContext = context; fRequest = request; } @@ -43,8 +45,8 @@ abstract public class PDACommandBase implements @Override public boolean equals(Object obj) { - if (obj instanceof PDACommandBase) { - PDACommandBase cmd = (PDACommandBase)obj; + if (obj instanceof AbstractPDACommand) { + AbstractPDACommand cmd = (AbstractPDACommand)obj; return fContext.equals(cmd.fContext) && fRequest.equals(cmd.fRequest); } return false; diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAClearBreakpointCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAClearBreakpointCommand.java index c513d49362d..a394fb2e7f3 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAClearBreakpointCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAClearBreakpointCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Clears any breakpoint set on given line @@ -21,14 +22,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * */ -public class PDAClearBreakpointCommand extends PDACommandBase { +public class PDAClearBreakpointCommand extends AbstractPDACommand { - public PDAClearBreakpointCommand(IDMContext context, int line) { - super(context, "clear " + line); + public PDAClearBreakpointCommand(PDACommandControlDMContext context, int line) { + super(context, "clear " + (line - 1)); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDACommandBaseResult.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDACommandBaseResult.java deleted file mode 100644 index c700ea339a1..00000000000 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDACommandBaseResult.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.dd.examples.pda.service.command.commands; - -import org.eclipse.dd.dsf.debug.service.command.ICommand; -import org.eclipse.dd.dsf.debug.service.command.ICommandResult; - -/** - * - */ -public class PDACommandBaseResult implements ICommandResult { - - final public String fResponseText; - - protected PDACommandBaseResult(String response) { - fResponseText = response; - } - - public V getSubsetResult(ICommand command) { - return null; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof PDACommandBaseResult) { - PDACommandBaseResult result = (PDACommandBaseResult)obj; - return fResponseText.equals(result.fResponseText); - } - return false; - } - - @Override - public int hashCode() { - return fResponseText.hashCode(); - } -} diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADataCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADataCommand.java index 26614c26653..835f5a638a5 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADataCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADataCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Retrieves data stack information @@ -20,14 +21,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * R: {value 1}|{value 2}|{value 3}|...| * */ -public class PDADataCommand extends PDACommandBase { +public class PDADataCommand extends AbstractPDACommand { - public PDADataCommand(IDMContext context) { + public PDADataCommand(PDACommandControlDMContext context) { super(context, "data"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADataCommandResult.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADataCommandResult.java index 322cb3fe1c6..20e895eeab8 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADataCommandResult.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADataCommandResult.java @@ -14,10 +14,12 @@ import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; + /** * @see PDADataCommand */ -public class PDADataCommandResult extends PDACommandBaseResult { +public class PDADataCommandResult extends PDACommandResult { final public int[] fValues; diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADropFrameCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADropFrameCommand.java index dbd705bb7d0..0c09a9b4f87 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADropFrameCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDADropFrameCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Returns from the current frame without executing the rest of instructions. @@ -23,14 +24,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * */ -public class PDADropFrameCommand extends PDACommandBase { +public class PDADropFrameCommand extends AbstractPDACommand { - public PDADropFrameCommand(IDMContext context) { + public PDADropFrameCommand(PDACommandControlDMContext context) { super(context, "drop"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAEvalCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAEvalCommand.java index 7978a3f8485..da38d1957cf 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAEvalCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAEvalCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Sets what events cause the execution to stop. @@ -25,14 +26,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * * Where event_name could be unimpinstr or nosuchlabel. */ -public class PDAEvalCommand extends PDACommandBase { +public class PDAEvalCommand extends AbstractPDACommand { - public PDAEvalCommand(IDMContext context, String operation) { + public PDAEvalCommand(PDACommandControlDMContext context, String operation) { super(context, "eval " + operation); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAEventStopCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAEventStopCommand.java index d6ed8d23f97..d19369f99d4 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAEventStopCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAEventStopCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Sets what events cause the execution to stop. @@ -24,11 +25,11 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * * Where event_name could be unimpinstr or nosuchlabel. */ -public class PDAEventStopCommand extends PDACommandBase { +public class PDAEventStopCommand extends AbstractPDACommand { public enum Event { UNIMPINSTR, NOSUCHLABEL }; - public PDAEventStopCommand(IDMContext context, Event event, boolean enable) { + public PDAEventStopCommand(PDACommandControlDMContext context, Event event, boolean enable) { super(context, "eventstop " + (event == Event.UNIMPINSTR ? "unimpinstr " : "nosuchlabel ") + @@ -36,7 +37,7 @@ public class PDAEventStopCommand extends PDACommandBase { } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAExitCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAExitCommand.java index f1a78b77cf3..dd074c3ed1f 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAExitCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAExitCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Instructs the debugger to exit. @@ -20,14 +21,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * R: ok * */ -public class PDAExitCommand extends PDACommandBase { +public class PDAExitCommand extends AbstractPDACommand { - public PDAExitCommand(IDMContext context) { + public PDAExitCommand(PDACommandControlDMContext context) { super(context, "exit"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAFrame.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAFrame.java new file mode 100644 index 00000000000..bc427e21fa4 --- /dev/null +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAFrame.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.examples.pda.service.command.commands; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +public class PDAFrame { + PDAFrame(String frameString) { + StringTokenizer st = new StringTokenizer(frameString, "|"); + + fFilePath = new Path(st.nextToken()); + fLine = Integer.parseInt(st.nextToken()); + fFunction = st.nextToken(); + + List variablesList = new ArrayList(); + while (st.hasMoreTokens()) { + variablesList.add(st.nextToken()); + } + fVariables = variablesList.toArray(new String[variablesList.size()]); + } + final public IPath fFilePath; + final public int fLine; + final public String fFunction; + final public String[] fVariables; +} \ No newline at end of file diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAPopDataCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAPopDataCommand.java index 3a27d46f5ed..1f35dba715f 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAPopDataCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAPopDataCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Pops the top value from the data stack @@ -20,14 +21,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * R: ok * */ -public class PDAPopDataCommand extends PDACommandBase { +public class PDAPopDataCommand extends AbstractPDACommand { - public PDAPopDataCommand(IDMContext context) { + public PDAPopDataCommand(PDACommandControlDMContext context) { super(context, "popdata"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAPushDataCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAPushDataCommand.java index 73e902b5f65..a2b817e776c 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAPushDataCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAPushDataCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Pushes the given value on top of the data stack. @@ -20,14 +21,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * R: ok * */ -public class PDAPushDataCommand extends PDACommandBase { +public class PDAPushDataCommand extends AbstractPDACommand { - public PDAPushDataCommand(IDMContext context, int value) { + public PDAPushDataCommand(PDACommandControlDMContext context, int value) { super(context, "pushdata " + value); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAResumeCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAResumeCommand.java index c0a29a958e5..40582908460 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAResumeCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAResumeCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Resumes the execution @@ -21,14 +22,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * E: resumed client * */ -public class PDAResumeCommand extends PDACommandBase { +public class PDAResumeCommand extends AbstractPDACommand { - public PDAResumeCommand(IDMContext context) { + public PDAResumeCommand(PDACommandControlDMContext context) { super(context, "resume"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetBreakpointCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetBreakpointCommand.java index 30844bac9be..a46ce388d2c 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetBreakpointCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetBreakpointCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Sets a breakpoint at given line @@ -23,14 +24,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * E: suspended breakpoint line_number * */ -public class PDASetBreakpointCommand extends PDACommandBase { +public class PDASetBreakpointCommand extends AbstractPDACommand { - public PDASetBreakpointCommand(IDMContext context, int line) { - super(context, "set " + line); + public PDASetBreakpointCommand(PDACommandControlDMContext context, int line) { + super(context, "set " + (line - 1)); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetDataCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetDataCommand.java index 7a7c1fa5b0e..fc4a94992da 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetDataCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetDataCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Sets a data value in the data stack at the given location @@ -20,14 +21,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * R: ok * */ -public class PDASetDataCommand extends PDACommandBase { +public class PDASetDataCommand extends AbstractPDACommand { - public PDASetDataCommand(IDMContext context, int index, int value) { + public PDASetDataCommand(PDACommandControlDMContext context, int index, int value) { super(context, "setdata " + index + " " + value); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetVarCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetVarCommand.java index 8a0cb9eaa99..cafbe6d1372 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetVarCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASetVarCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Sets a variable value @@ -20,14 +21,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * R: ok * */ -public class PDASetVarCommand extends PDACommandBase { +public class PDASetVarCommand extends AbstractPDACommand { - public PDASetVarCommand(IDMContext context, String variable, int value) { + public PDASetVarCommand(PDACommandControlDMContext context, String variable, String value) { super(context, "setvar " + variable + " " + value); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStackCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStackCommand.java index 5ca5a30eb05..3db048e2c4e 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStackCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStackCommand.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; /** * Retrieves command stack information @@ -20,14 +20,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * R: {file}|{line}|{function}|{var_1}|{var_2}|...#{file}|{line}|{function}|{var_1}|{var_2}|...#... * */ -public class PDAStackCommand extends PDACommandBase { +public class PDAStackCommand extends AbstractPDACommand { - public PDAStackCommand(IDMContext context) { + public PDAStackCommand(PDACommandControlDMContext context) { super(context, "stack"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDAStackCommandResult createResult(String resultText) { + return new PDAStackCommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStackCommandResult.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStackCommandResult.java index 41cc81a9f29..1b4e07e5560 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStackCommandResult.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStackCommandResult.java @@ -14,44 +14,23 @@ import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * @see PDAStackCommand */ -public class PDAStackCommandResult extends PDACommandBaseResult { +public class PDAStackCommandResult extends PDACommandResult { - public static class Frame { - Frame(String frameString) { - StringTokenizer st = new StringTokenizer(frameString, "|"); - - fFilePath = new Path(st.nextToken()); - fLine = Integer.parseInt(st.nextToken()); - fFunction = st.nextToken(); - - List variablesList = new ArrayList(); - while (st.hasMoreTokens()) { - variablesList.add(st.nextToken()); - } - fVariables = variablesList.toArray(new String[variablesList.size()]); - } - final public IPath fFilePath; - final public int fLine; - final public String fFunction; - final public String[] fVariables; - } - - final public Frame[] fFrames; + final public PDAFrame[] fFrames; PDAStackCommandResult(String response) { super(response); StringTokenizer st = new StringTokenizer(response, "#"); - List framesList = new ArrayList(); + List framesList = new ArrayList(); while (st.hasMoreTokens()) { - framesList.add(new Frame(st.nextToken())); + framesList.add(new PDAFrame(st.nextToken())); } - fFrames = framesList.toArray(new Frame[framesList.size()]); + fFrames = framesList.toArray(new PDAFrame[framesList.size()]); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStepCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStepCommand.java index 97d0311f831..9a3f536fbc5 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStepCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStepCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Executes next instruciton @@ -22,14 +23,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * E: suspended step * */ -public class PDAStepCommand extends PDACommandBase { +public class PDAStepCommand extends AbstractPDACommand { - public PDAStepCommand(IDMContext context) { + public PDAStepCommand(PDACommandControlDMContext context) { super(context, "step"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStepReturnCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStepReturnCommand.java index e8be6d5ec06..4d1d6ec6996 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStepReturnCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAStepReturnCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Executes instructions until the current subroutine is finished @@ -22,14 +23,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * E: suspended step * */ -public class PDAStepReturnCommand extends PDACommandBase { +public class PDAStepReturnCommand extends AbstractPDACommand { - public PDAStepReturnCommand(IDMContext context) { + public PDAStepReturnCommand(PDACommandControlDMContext context) { super(context, "stepreturn"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASuspendCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASuspendCommand.java index 4b07d0a066b..8972c83f830 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASuspendCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDASuspendCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Suspends execution @@ -21,14 +22,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * E: suspended client * */ -public class PDASuspendCommand extends PDACommandBase { +public class PDASuspendCommand extends AbstractPDACommand { - public PDASuspendCommand(IDMContext context) { + public PDASuspendCommand(PDACommandControlDMContext context) { super(context, "suspend"); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAVarCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAVarCommand.java index d4b52df8cd6..95280892e65 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAVarCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAVarCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Retrieves variable value @@ -20,14 +21,14 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * R: {variable_value} * */ -public class PDAVarCommand extends PDACommandBase { +public class PDAVarCommand extends AbstractPDACommand { - public PDAVarCommand(IDMContext context, int frame, String name) { - super(context, "var " + frame + " " + name); + public PDAVarCommand(PDACommandControlDMContext context, int frameId, String name) { + super(context, "var " + frameId + " " + name); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAVarCommandResult.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAVarCommandResult.java index 0b583335661..3275256f41a 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAVarCommandResult.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAVarCommandResult.java @@ -10,11 +10,13 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; + /** * @see PDAVarCommand */ -public class PDAVarCommandResult extends PDACommandBaseResult { +public class PDAVarCommandResult extends PDACommandResult { final public int fValue; diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAWatchCommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAWatchCommand.java index 48a959ed53d..7d23b37c087 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAWatchCommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/commands/PDAWatchCommand.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.command.commands; -import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; /** * Sets a watchpoint on a given variable @@ -23,7 +24,7 @@ import org.eclipse.dd.dsf.datamodel.IDMContext; * E: suspended watch {watch_operation} {function}::{variable_name} * */ -public class PDAWatchCommand extends PDACommandBase { +public class PDAWatchCommand extends AbstractPDACommand { public enum WatchOperation { READ, WRITE, BOTH, NONE }; @@ -40,12 +41,12 @@ public class PDAWatchCommand extends PDACommandBase { } } - public PDAWatchCommand(IDMContext context, String function, String variable, WatchOperation operation) { + public PDAWatchCommand(PDACommandControlDMContext context, String function, String variable, WatchOperation operation) { super(context, "watch " + function+ "::" + variable + " " + getWatchOperationCode(operation)); } @Override - public PDACommandBaseResult createResult(String resultText) { - return new PDACommandBaseResult(resultText); + public PDACommandResult createResult(String resultText) { + return new PDACommandResult(resultText); } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/ExpressionDMContext.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/ExpressionDMContext.java new file mode 100644 index 00000000000..477ee85f6de --- /dev/null +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/ExpressionDMContext.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.examples.pda.service.expressions; + +import org.eclipse.dd.dsf.datamodel.AbstractDMContext; +import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.dsf.debug.service.IExpressions.IExpressionDMContext; +import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext; + +/** + * + */ +public class ExpressionDMContext extends AbstractDMContext implements IExpressionDMContext { + + private final String fExpression; + + ExpressionDMContext(String sessionId, IFrameDMContext frameDmc, String expressin) { + super(sessionId, new IDMContext[] { frameDmc }); + fExpression = expressin; + } + + public String getExpression() { + return fExpression; + } + + @Override + public boolean equals(Object other) { + return super.baseEquals(other) && ((ExpressionDMContext)other).fExpression.equals(fExpression); + } + + @Override + public int hashCode() { + return super.baseHashCode() + fExpression.hashCode(); + } + + @Override + public String toString() { + return baseToString() + ".expression(" + fExpression + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + } +} diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/ExpressionDMData.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/ExpressionDMData.java new file mode 100644 index 00000000000..2929f61c020 --- /dev/null +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/ExpressionDMData.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.examples.pda.service.expressions; + +import java.util.Map; + +import org.eclipse.dd.dsf.debug.service.IExpressions.IExpressionDMData; +import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMContext; + +/** + * + */ +public class ExpressionDMData implements IExpressionDMData { + + final private String fExpression; + + public ExpressionDMData(String expression) { + fExpression = expression; + } + + public BasicType getBasicType() { + return BasicType.basic; + } + + public String getEncoding() { + return null; + } + + public Map getEnumerations() { + return null; + } + + public String getName() { + return fExpression; + } + + public IRegisterDMContext getRegister() { + return null; + } + + public String getStringValue() { + return null; + } + + public String getTypeId() { + return null; + } + + public String getTypeName() { + return null; + } + +} diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/InvalidExpressionDMContext.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/InvalidExpressionDMContext.java new file mode 100644 index 00000000000..56124e06f87 --- /dev/null +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/InvalidExpressionDMContext.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.examples.pda.service.expressions; + +import org.eclipse.dd.dsf.datamodel.AbstractDMContext; +import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.dsf.debug.service.IExpressions.IExpressionDMContext; + +class InvalidExpressionDMContext extends AbstractDMContext + implements IExpressionDMContext +{ + private final String expression; + + public InvalidExpressionDMContext(String sessionId, IDMContext parent, String expr) { + super(sessionId, new IDMContext[] { parent }); + expression = expr; + } + + @Override + public boolean equals(Object other) { + return super.baseEquals(other) && + expression == null + ? ((InvalidExpressionDMContext) other).getExpression() == null + : expression.equals(((InvalidExpressionDMContext) other).getExpression()); + } + + @Override + public int hashCode() { + return expression == null ? super.baseHashCode() : super.baseHashCode() ^ expression.hashCode(); + } + + @Override + public String toString() { + return baseToString() + ".invalid_expr[" + expression + "]"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + public String getExpression() { + return expression; + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/PDAExpressions.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/PDAExpressions.java new file mode 100644 index 00000000000..550882bc74c --- /dev/null +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/expressions/PDAExpressions.java @@ -0,0 +1,224 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.examples.pda.service.expressions; + +import java.util.Hashtable; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.dd.dsf.concurrent.DataRequestMonitor; +import org.eclipse.dd.dsf.concurrent.RequestMonitor; +import org.eclipse.dd.dsf.datamodel.DMContexts; +import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.dsf.debug.service.IExpressions; +import org.eclipse.dd.dsf.debug.service.IStack; +import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent; +import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent; +import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason; +import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext; +import org.eclipse.dd.dsf.debug.service.command.CommandCache; +import org.eclipse.dd.dsf.service.AbstractDsfService; +import org.eclipse.dd.dsf.service.DsfServiceEventHandler; +import org.eclipse.dd.dsf.service.DsfSession; +import org.eclipse.dd.examples.pda.PDAPlugin; +import org.eclipse.dd.examples.pda.service.command.PDACommandControl; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; +import org.eclipse.dd.examples.pda.service.command.commands.PDASetVarCommand; +import org.eclipse.dd.examples.pda.service.command.commands.PDAVarCommand; +import org.osgi.framework.BundleContext; + +/** + * + */ +public class PDAExpressions extends AbstractDsfService implements IExpressions { + + private PDACommandControl fCommandControl; + private IStack fStack; + + private CommandCache fCommandCache; + + public PDAExpressions(DsfSession session) { + super(session); + } + + @Override + protected BundleContext getBundleContext() { + return PDAPlugin.getBundleContext(); + } + + @Override + public void initialize(final RequestMonitor rm) { + super.initialize( + new RequestMonitor(getExecutor(), rm) { + @Override + protected void handleOK() { + doInitialize(rm); + }}); + } + + private void doInitialize(final RequestMonitor rm) { + fCommandControl = getServicesTracker().getService(PDACommandControl.class); + fStack = getServicesTracker().getService(IStack.class); + fCommandCache = new CommandCache(fCommandControl); + + getSession().addServiceEventListener(this, null); + + register(new String[]{IExpressions.class.getName(), PDAExpressions.class.getName()}, new Hashtable()); + + rm.done(); + } + + @Override + public void shutdown(final RequestMonitor rm) { + getSession().removeServiceEventListener(this); + fCommandCache.reset(); + super.shutdown(rm); + } + + public void canWriteExpression(IExpressionDMContext expressionContext, DataRequestMonitor rm) { + rm.setData(true); + rm.done(); + } + + public IExpressionDMContext createExpression(IDMContext ctx, String expression) { + IFrameDMContext frameCtx = DMContexts.getAncestorOfType(ctx, IFrameDMContext.class); + if (frameCtx != null) { + return new ExpressionDMContext(getSession().getId(), frameCtx, expression); + } else { + return new InvalidExpressionDMContext(getSession().getId(), ctx, expression); + } + } + + public void getBaseExpressions(IExpressionDMContext exprContext, DataRequestMonitor rm) { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ + rm.done(); + } + + public void getExpressionAddressData(IExpressionDMContext dmc, DataRequestMonitor rm) { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ + rm.done(); + } + + public void getExpressionData(final IExpressionDMContext exprCtx, final DataRequestMonitor rm) { + if (exprCtx instanceof ExpressionDMContext) { + rm.setData(new ExpressionDMData(exprCtx.getExpression())); + rm.done(); + } else { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid expression context " + exprCtx, null)); //$NON-NLS-1$ + rm.done(); + } + } + + public void getSubExpressionCount(IExpressionDMContext exprCtx, DataRequestMonitor rm) { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ + rm.done(); + } + + public void getSubExpressions(IExpressionDMContext exprCtx, DataRequestMonitor rm) { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ + rm.done(); + } + + public void getSubExpressions(IExpressionDMContext exprCtx, int startIndex, int length, + DataRequestMonitor rm) + { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ + rm.done(); + } + + + public void writeExpression(IExpressionDMContext exprCtx, String exprValue, String formatId, RequestMonitor rm) + { + if (exprCtx instanceof ExpressionDMContext) { + fCommandCache.execute( + new PDASetVarCommand(fCommandControl.getDMContext(), exprCtx.getExpression(), exprValue), + new DataRequestMonitor(getExecutor(), rm)); + } else { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid expression context " + exprCtx, null)); //$NON-NLS-1$ + rm.done(); + } + } + + public void getAvailableFormats(IFormattedDataDMContext dmc, DataRequestMonitor rm) { + rm.setData(new String[] { NATURAL_FORMAT }); + rm.done(); + } + + public FormattedValueDMContext getFormattedValueContext(IFormattedDataDMContext dmc, String formatId) { + return new FormattedValueDMContext(this, dmc, formatId); + } + + public void getFormattedExpressionValue(FormattedValueDMContext formattedCtx, final DataRequestMonitor rm) { + final ExpressionDMContext exprCtx = DMContexts.getAncestorOfType(formattedCtx, ExpressionDMContext.class); + if (exprCtx != null) { + getExpressionValue( + exprCtx, + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleOK() { + rm.setData(new FormattedValueDMData(getData())); + rm.done(); + } + }); + } else { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid expression context " + formattedCtx, null)); //$NON-NLS-1$ + rm.done(); + } + } + + private void getExpressionValue(final ExpressionDMContext exprCtx, final DataRequestMonitor rm) { + final IFrameDMContext frameCtx = DMContexts.getAncestorOfType(exprCtx, IFrameDMContext.class); + fStack.getStackDepth( + frameCtx, 0, + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleOK() { + int frameId = getData() - frameCtx.getLevel() - 1; + fCommandCache.execute( + new PDAVarCommand(fCommandControl.getDMContext(), frameId, exprCtx.getExpression()), + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleOK() { + rm.setData(getData().fResponseText); + rm.done(); + } + }); + } + }); + } + + @Deprecated + public void getModelData(IDMContext dmc, DataRequestMonitor rm) { + if (dmc instanceof IExpressionDMContext) { + getExpressionData((IExpressionDMContext) dmc, (DataRequestMonitor) rm); + } else if (dmc instanceof FormattedValueDMContext) { + getFormattedExpressionValue((FormattedValueDMContext) dmc, (DataRequestMonitor) rm); + } else { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$ + rm.done(); + } + } + + @DsfServiceEventHandler + public void eventDispatched(IResumedDMEvent e) { + fCommandCache.setTargetAvailable(false); + if (!e.getReason().equals(StateChangeReason.STEP)) { + fCommandCache.reset(); + } + } + + + @DsfServiceEventHandler + public void eventDispatched(ISuspendedDMEvent e) { + fCommandCache.setTargetAvailable(true); + fCommandCache.reset(); + } +} diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/runcontrol/PDARunControl.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/runcontrol/PDARunControl.java index 48fb112f4aa..5bc8ec49f41 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/runcontrol/PDARunControl.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/runcontrol/PDARunControl.java @@ -27,9 +27,11 @@ import org.eclipse.dd.dsf.service.DsfServiceEventHandler; import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.examples.pda.PDAPlugin; -import org.eclipse.dd.examples.pda.service.command.PDACommand; import org.eclipse.dd.examples.pda.service.command.PDACommandControl; import org.eclipse.dd.examples.pda.service.command.PDACommandResult; +import org.eclipse.dd.examples.pda.service.command.commands.PDAResumeCommand; +import org.eclipse.dd.examples.pda.service.command.commands.PDAStepCommand; +import org.eclipse.dd.examples.pda.service.command.commands.PDASuspendCommand; import org.osgi.framework.BundleContext; @@ -187,7 +189,7 @@ public class PDARunControl extends AbstractDsfService fCommandCache.setTargetAvailable(false); fCommandControl.queueCommand( - new PDACommand(fCommandControl.getDMContext(), "resume"), + new PDAResumeCommand(fCommandControl.getDMContext()), new DataRequestMonitor(getExecutor(), rm) { @Override protected void handleOK() { @@ -206,7 +208,7 @@ public class PDARunControl extends AbstractDsfService if (canSuspend(context)) { fCommandControl.queueCommand( - new PDACommand(fCommandControl.getDMContext(), "suspend"), + new PDASuspendCommand(fCommandControl.getDMContext()), new DataRequestMonitor(getExecutor(), rm)); } else { @@ -228,7 +230,7 @@ public class PDARunControl extends AbstractDsfService fCommandCache.setTargetAvailable(false); fCommandControl.queueCommand( - new PDACommand(fCommandControl.getDMContext(), "step"), + new PDAStepCommand(fCommandControl.getDMContext()), new DataRequestMonitor(getExecutor(), rm)); } else { diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/FrameDMContext.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/FrameDMContext.java index 7947f0aea5d..48ac9084c67 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/FrameDMContext.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/FrameDMContext.java @@ -14,7 +14,6 @@ import org.eclipse.dd.dsf.datamodel.AbstractDMContext; import org.eclipse.dd.dsf.datamodel.IDMContext; import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext; import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext; -import org.eclipse.dd.examples.pda.service.stack.PDAStack.PDAFrame; /** * @@ -22,16 +21,12 @@ import org.eclipse.dd.examples.pda.service.stack.PDAStack.PDAFrame; class FrameDMContext extends AbstractDMContext implements IFrameDMContext { private final int fLevel; - private final PDAFrame fFrame; - FrameDMContext(String sessionId, IExecutionDMContext execDmc, int level, PDAFrame frame) { + FrameDMContext(String sessionId, IExecutionDMContext execDmc, int level) { super(sessionId, new IDMContext[] { execDmc }); fLevel = level; - fFrame = frame; } - PDAFrame getFrame() { return fFrame; } - public int getLevel() { return fLevel; } @Override diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/FrameDMData.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/FrameDMData.java index c3272d64564..304388503c9 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/FrameDMData.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/FrameDMData.java @@ -12,7 +12,7 @@ package org.eclipse.dd.examples.pda.service.stack; import org.eclipse.cdt.core.IAddress; import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMData; -import org.eclipse.dd.examples.pda.service.stack.PDAStack.PDAFrame; +import org.eclipse.dd.examples.pda.service.command.commands.PDAFrame; /** * @@ -26,7 +26,7 @@ public class FrameDMData implements IFrameDMData { } public String getFile() { - return fFrame.fFilePath; + return fFrame.fFilePath.lastSegment(); } public String getFunction() { @@ -34,7 +34,7 @@ public class FrameDMData implements IFrameDMData { } public int getLine() { - return fFrame.fLine; + return fFrame.fLine + 1; } public int getColumn() { diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/PDAStack.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/PDAStack.java index e11c64dfa54..f533f191328 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/PDAStack.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/stack/PDAStack.java @@ -10,10 +10,7 @@ *******************************************************************************/ package org.eclipse.dd.examples.pda.service.stack; -import java.util.ArrayList; import java.util.Hashtable; -import java.util.List; -import java.util.StringTokenizer; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -33,9 +30,10 @@ import org.eclipse.dd.dsf.service.DsfServiceEventHandler; import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.examples.pda.PDAPlugin; -import org.eclipse.dd.examples.pda.service.command.PDACommand; import org.eclipse.dd.examples.pda.service.command.PDACommandControl; -import org.eclipse.dd.examples.pda.service.command.PDACommandResult; +import org.eclipse.dd.examples.pda.service.command.commands.PDAFrame; +import org.eclipse.dd.examples.pda.service.command.commands.PDAStackCommand; +import org.eclipse.dd.examples.pda.service.command.commands.PDAStackCommandResult; import org.osgi.framework.BundleContext; /** @@ -91,16 +89,29 @@ public class PDAStack extends AbstractDsfService implements IStack { rm.done(); } - public void getFrameData(IFrameDMContext frameCtx, DataRequestMonitor rm) { + public void getFrameData(final IFrameDMContext frameCtx, final DataRequestMonitor rm) { if ( !(frameCtx instanceof FrameDMContext) ) { rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid context " + frameCtx, null)); //$NON-NLS-1$ rm.done(); return; } - PDAFrame pdaFrame = ((FrameDMContext)frameCtx).getFrame(); - rm.setData(new FrameDMData(pdaFrame)); - rm.done(); + fCommandCache.execute( + new PDAStackCommand(fCommandControl.getDMContext()), + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleOK() { + int frameId = getData().fFrames.length - frameCtx.getLevel() - 1; + if (frameId < 0) { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid frame level " + frameCtx, null)); //$NON-NLS-1$ + rm.done(); + return; + } + + rm.setData(new FrameDMData(getData().fFrames[frameId])); + rm.done(); + } + }); } public void getFrames(IDMContext context, final DataRequestMonitor rm) { @@ -111,15 +122,14 @@ public class PDAStack extends AbstractDsfService implements IStack { return; } - fCommandControl.queueCommand( - new PDACommand(execCtx, "stack"), - new DataRequestMonitor(getExecutor(), rm) { + fCommandCache.execute( + new PDAStackCommand(fCommandControl.getDMContext()), + new DataRequestMonitor(getExecutor(), rm) { @Override protected void handleOK() { - PDAFrame[] frames = parseStackResponse(getData().fResponseText); - IFrameDMContext[] frameCtxs = new IFrameDMContext[frames.length]; - for (int i = 0; i < frames.length; i++) { - frameCtxs[i] = new FrameDMContext(getSession().getId(), execCtx, i, frames[i]); + IFrameDMContext[] frameCtxs = new IFrameDMContext[getData().fFrames.length]; + for (int i = 0; i < getData().fFrames.length; i++) { + frameCtxs[i] = new FrameDMContext(getSession().getId(), execCtx, i); } rm.setData(frameCtxs); rm.done(); @@ -127,44 +137,59 @@ public class PDAStack extends AbstractDsfService implements IStack { }); } - public void getLocals(IFrameDMContext frameCtx, DataRequestMonitor rm) { + public void getLocals(final IFrameDMContext frameCtx, final DataRequestMonitor rm) { if ( !(frameCtx instanceof FrameDMContext) ) { rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid context " + frameCtx, null)); //$NON-NLS-1$ rm.done(); return; } - PDAFrame pdaFrame = ((FrameDMContext)frameCtx).getFrame(); - IVariableDMContext[] variableCtxs = new IVariableDMContext[pdaFrame.fVariables.length]; - for (int i = 0; i < pdaFrame.fVariables.length; i++) { - variableCtxs[i] = new VariableDMContext(getSession().getId(), frameCtx, pdaFrame.fVariables[i]); - } - rm.setData(variableCtxs); - rm.done(); + fCommandCache.execute( + new PDAStackCommand(fCommandControl.getDMContext()), + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleOK() { + int frameId = getData().fFrames.length - frameCtx.getLevel() - 1; + if (frameId < 0) { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid frame level " + frameCtx, null)); //$NON-NLS-1$ + rm.done(); + return; + } + + + PDAFrame pdaFrame = getData().fFrames[frameId]; + IVariableDMContext[] variableCtxs = new IVariableDMContext[pdaFrame.fVariables.length]; + for (int i = 0; i < pdaFrame.fVariables.length; i++) { + variableCtxs[i] = new VariableDMContext(getSession().getId(), frameCtx, pdaFrame.fVariables[i]); + } + rm.setData(variableCtxs); + rm.done(); + } + }); + } public void getStackDepth(IDMContext context, int maxDepth, final DataRequestMonitor rm) { - getFrames( - context, - new DataRequestMonitor(getExecutor(), rm) { + fCommandCache.execute( + new PDAStackCommand(fCommandControl.getDMContext()), + new DataRequestMonitor(getExecutor(), rm) { @Override protected void handleOK() { - rm.setData(getData().length); + rm.setData(getData().fFrames.length); rm.done(); } }); } public void getTopFrame(IDMContext context, final DataRequestMonitor rm) { - getFrames( - context, - new DataRequestMonitor(getExecutor(), rm) { - @Override - protected void handleOK() { - rm.setData(getData()[0]); - rm.done(); - } - }); + final IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class); + if (execCtx == null) { + rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid context " + context, null)); //$NON-NLS-1$ + rm.done(); + return; + } + rm.setData(new FrameDMContext(getSession().getId(), execCtx, 0)); + rm.done(); } public void getVariableData(IVariableDMContext variableCtx, DataRequestMonitor rm) { @@ -213,36 +238,4 @@ public class PDAStack extends AbstractDsfService implements IStack { fCommandCache.setTargetAvailable(true); fCommandCache.reset(); } - - public static class PDAFrame { - PDAFrame(String frameString) { - StringTokenizer st = new StringTokenizer(frameString, "|"); - - fFilePath = st.nextToken(); - fLine = Integer.parseInt(st.nextToken()); - fFunction = st.nextToken(); - - List variablesList = new ArrayList(); - while (st.hasMoreTokens()) { - variablesList.add(st.nextToken()); - } - fVariables = variablesList.toArray(new String[variablesList.size()]); - } - - final public String fFilePath; - final public int fLine; - final public String fFunction; - final public String[] fVariables; - } - - private PDAFrame[] parseStackResponse(String response) { - StringTokenizer st = new StringTokenizer(response, "#"); - List framesList = new ArrayList(); - - while (st.hasMoreTokens()) { - framesList.add(new PDAFrame(st.nextToken())); - } - return framesList.toArray(new PDAFrame[framesList.size()]); - } - } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/BasicTests.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/BasicTests.java index 20127ad2d3c..abee9ba1650 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/BasicTests.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/BasicTests.java @@ -23,7 +23,6 @@ import org.eclipse.dd.dsf.concurrent.Query; import org.eclipse.dd.dsf.debug.service.command.ICommand; import org.eclipse.dd.dsf.debug.service.command.ICommandListener; import org.eclipse.dd.dsf.debug.service.command.ICommandResult; -import org.eclipse.dd.examples.pda.service.command.PDACommand; import org.eclipse.dd.examples.pda.service.command.PDACommandResult; import org.junit.BeforeClass; import org.junit.Test; @@ -82,7 +81,7 @@ public class BasicTests extends CommandControlTestsBase { } }); - final PDACommand testCommand = new PDACommand(fCommandControl.getDMContext(), "data"); + final PDATestCommand testCommand = new PDATestCommand(fCommandControl.getDMContext(), "data"); // Test sending the command and checking all listeners were called. Query sendCommandQuery = new Query() { diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/CommandControlTestsBase.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/CommandControlTestsBase.java index 27b2429eba4..9d7a339177c 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/CommandControlTestsBase.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/CommandControlTestsBase.java @@ -27,7 +27,6 @@ import org.eclipse.dd.dsf.concurrent.Query; import org.eclipse.dd.dsf.debug.service.command.IEventListener; import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.examples.pda.service.command.PDACommandControl; -import org.eclipse.dd.examples.pda.service.command.PDACommand; import org.eclipse.dd.examples.pda.service.command.PDACommandResult; import org.eclipse.dd.tests.pda.util.Launching; import org.junit.After; @@ -106,7 +105,7 @@ public class CommandControlTestsBase { protected void sendCommand(String command, String expectedResult) throws Throwable { - final PDACommand testCommand = new PDACommand(fCommandControl.getDMContext(), command); + final PDATestCommand testCommand = new PDATestCommand(fCommandControl.getDMContext(), command); // Test sending the command and checking all listeners were called. Query sendCommandQuery = new Query() { diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommand.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/PDATestCommand.java similarity index 63% rename from plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommand.java rename to plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/PDATestCommand.java index cb6215a4136..0aba7c8441c 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/service/command/PDACommand.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/tests/pda/service/command/PDATestCommand.java @@ -8,16 +8,17 @@ * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.dd.examples.pda.service.command; +package org.eclipse.dd.tests.pda.service.command; -import org.eclipse.dd.dsf.datamodel.IDMContext; -import org.eclipse.dd.examples.pda.service.command.commands.PDACommandBase; +import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext; +import org.eclipse.dd.examples.pda.service.command.PDACommandResult; +import org.eclipse.dd.examples.pda.service.command.commands.AbstractPDACommand; /** * */ -public class PDACommand extends PDACommandBase { - public PDACommand(IDMContext context, String command) { +class PDATestCommand extends AbstractPDACommand { + PDATestCommand(PDACommandControlDMContext context, String command) { super(context, command); } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/debug/examples/core/pda/sourcelookup/PDASourceLookupDirector.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/debug/examples/core/pda/sourcelookup/PDASourceLookupDirector.java index f975cf7c338..27e1cdd8ce1 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/debug/examples/core/pda/sourcelookup/PDASourceLookupDirector.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/debug/examples/core/pda/sourcelookup/PDASourceLookupDirector.java @@ -12,21 +12,13 @@ package org.eclipse.debug.examples.core.pda.sourcelookup; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant; /** - * PDA source lookup director. For PDA source lookup there is one source - * lookup participant. + * PDA source lookup director. */ public class PDASourceLookupDirector extends AbstractSourceLookupDirector { - /* (non-Javadoc) - * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector#initializeParticipants() - */ public void initializeParticipants() { - //#ifdef ex4 -//# // TODO: Exercise 4 - add our participant to this director - //#else - addParticipants(new ISourceLookupParticipant[]{new PDASourceLookupParticipant()}); - //#endif + // No need to add participants here, the surce display adapter will + // add the participant with the correct session ID. } } diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/debug/examples/core/pda/sourcelookup/PDASourceLookupParticipant.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/debug/examples/core/pda/sourcelookup/PDASourceLookupParticipant.java deleted file mode 100644 index 66243d6518f..00000000000 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/debug/examples/core/pda/sourcelookup/PDASourceLookupParticipant.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Bjorn Freeman-Benson - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.examples.core.pda.sourcelookup; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant; - - -/** - * The PDA source lookup participant knows how to translate a - * PDA stack frame into a source file name - */ -public class PDASourceLookupParticipant extends AbstractSourceLookupParticipant { - /* (non-Javadoc) - * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object) - */ - public String getSourceName(Object object) throws CoreException { - return null; - } -}