Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 214147 Details for
Bug 330974
[run control] If the user selects multiple nodes in the debug view most debug commands are disabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Prototype for resume and suspend
z.patch (text/plain), 32.95 KB, created by
Marc Khouzam
on 2012-04-17 16:44:59 EDT
(
hide
)
Description:
Prototype for resume and suspend
Filename:
MIME Type:
Creator:
Marc Khouzam
Created:
2012-04-17 16:44:59 EDT
Size:
32.95 KB
patch
obsolete
>diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java >index 60eb549..10e85f4 100644 >--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java >+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java >@@ -9,14 +9,18 @@ > * Wind River Systems - initial API and implementation > * Ericsson AB - Modified for handling of multiple threads > * Indel AG - [369622] fixed moveToLine using MinGW >+ * Marc Khouzam (Ericsson) - Support for operations on multiple execution contexts (bug 330974) > *******************************************************************************/ > > package org.eclipse.cdt.dsf.gdb.service; > >+import java.util.ArrayList; >+import java.util.Arrays; > import java.util.HashMap; > import java.util.HashSet; > import java.util.Hashtable; > import java.util.LinkedList; >+import java.util.List; > import java.util.Map; > import java.util.Set; > >@@ -42,6 +46,7 @@ > import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; > import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension.IBreakpointHitDMEvent; > import org.eclipse.cdt.dsf.debug.service.ICachingService; >+import org.eclipse.cdt.dsf.debug.service.IMultiRunControl; > import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; > import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext; > import org.eclipse.cdt.dsf.debug.service.IRunControl; >@@ -104,7 +109,7 @@ > * sync with the service state. > * @since 1.1 > */ >-public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunControl, ICachingService >+public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunControl, IMultiRunControl, ICachingService > { > @Immutable > private static class ExecutionData implements IExecutionDMData2 { >@@ -396,7 +401,8 @@ > private void doInitialize(final RequestMonitor rm) { > register(new String[]{ IRunControl.class.getName(), > IRunControl2.class.getName(), >- IMIRunControl.class.getName()}, >+ IMIRunControl.class.getName(), >+ IMultiRunControl.class.getName() }, > new Hashtable<String,String>()); > fConnection = getServicesTracker().getService(ICommandControlService.class); > fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory(); >@@ -1878,4 +1884,270 @@ > } > return result; > } >+ >+ /** >+ * Removes duplicates from the list of execution contexts. >+ * Also, remove threads that are part of a process that is also present. >+ */ >+ private List<IExecutionDMContext> extractContextsForOperation(IExecutionDMContext[] contexts) { >+ // Handle duplicate contexts by using a set >+ Set<IExecutionDMContext> specifiedExedDmcSet = new HashSet<IExecutionDMContext>(Arrays.asList(contexts)); >+ >+ // A list that ignores threads for which the process is also present >+ List<IExecutionDMContext> execDmcForOperationList = new ArrayList<IExecutionDMContext>(specifiedExedDmcSet.size()); >+ >+ // Check for the case of a process selected along with some of its threads >+ for (IExecutionDMContext execDmc : specifiedExedDmcSet) { >+ if (execDmc instanceof IContainerDMContext) { >+ // This is a process: it is automatically part of our list >+ execDmcForOperationList.add(execDmc); >+ } else { >+ // Get the process for this thread >+ IContainerDMContext containerDmc = DMContexts.getAncestorOfType(execDmc, IContainerDMContext.class); >+ // Check if the process is also present >+ if (specifiedExedDmcSet.contains(containerDmc) == false) { >+ // This thread does not belong to a process that is selected, so we keep it. >+ execDmcForOperationList.add(execDmc); >+ } >+ } >+ } >+ return execDmcForOperationList; >+ } >+ >+ // Multi resume: >+ // >+ // If one or more more threads of one or many processes are selected, we want to >+ // resume each thread. >+ // >+ // If a process is selected along with one or more threads of that process, >+ // what does the user want us to do? Selecting the process means resume all its >+ // threads, but what do we do with the selected threads? Why are they >+ // selected? In an attempt to be user friendly, lets assume that the user >+ // wants to resume the entire process. >+ // >+ // On the other hand, selecting a process and also threads from another >+ // process makes perfect sense; the process is resumed, and the threads >+ // selected are handled as the normal case. >+ >+ /** @since 4.1 */ >+ @Override >+ public void canResumeSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) { >+ assert contexts != null; >+ >+ if (fRunControlOperationsEnabled == false) { >+ rm.done(false); >+ return; >+ } >+ >+ List<IExecutionDMContext> execDmcToResumeList = extractContextsForOperation(contexts); >+ >+ // If any of the threads or processes can be resumed, we allow >+ // the user to perform the operation. >+ for (IExecutionDMContext execDmc : execDmcToResumeList) { >+ if (doCanResume(execDmc)) { >+ rm.done(true); >+ return; >+ } >+ } >+ >+ // Didn't find anything that could be resumed. >+ rm.done(false); >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void canResumeAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) { >+ assert contexts != null; >+ >+ if (fRunControlOperationsEnabled == false) { >+ rm.done(false); >+ return; >+ } >+ >+ List<IExecutionDMContext> execDmcToResumeList = extractContextsForOperation(contexts); >+ >+ // If any of the threads or processes cannot be resumed, we don't allow >+ // the user to perform the operation. >+ for (IExecutionDMContext execDmc : execDmcToResumeList) { >+ if (!doCanResume(execDmc)) { >+ rm.done(false); >+ return; >+ } >+ } >+ >+ // Everything can be resumed >+ rm.done(true); >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void canSuspendSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) { >+ assert contexts != null; >+ >+ if (fRunControlOperationsEnabled == false) { >+ rm.done(false); >+ return; >+ } >+ >+ List<IExecutionDMContext> execDmcToSuspendList = extractContextsForOperation(contexts); >+ >+ // If any of the threads or processes can be suspended, we allow >+ // the user to perform the operation. >+ for (IExecutionDMContext execDmc : execDmcToSuspendList) { >+ if (doCanSuspend(execDmc)) { >+ rm.done(true); >+ return; >+ } >+ } >+ >+ // Didn't find anything that could be suspended. >+ rm.done(false); >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void canSuspendAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) { >+ assert contexts != null; >+ >+ if (fRunControlOperationsEnabled == false) { >+ rm.done(false); >+ return; >+ } >+ >+ List<IExecutionDMContext> execDmcToSuspendList = extractContextsForOperation(contexts); >+ >+ // If any of the threads or processes cannot be suspended, we don't allow >+ // the user to perform the operation. >+ for (IExecutionDMContext execDmc : execDmcToSuspendList) { >+ if (!doCanSuspend(execDmc)) { >+ rm.done(false); >+ return; >+ } >+ } >+ >+ // Everything can be suspended >+ rm.done(true); >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void isSuspendedSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) { >+ assert contexts != null; >+ >+ List<IExecutionDMContext> execDmcSuspendedList = extractContextsForOperation(contexts); >+ >+ // Look for any thread or process that is suspended >+ for (IExecutionDMContext execDmc : execDmcSuspendedList) { >+ if (isSuspended(execDmc)) { >+ rm.done(true); >+ return; >+ } >+ } >+ >+ // Didn't find anything that was suspended. >+ rm.done(false); >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void isSuspendedAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) { >+ assert contexts != null; >+ >+ List<IExecutionDMContext> execDmcSuspendedList = extractContextsForOperation(contexts); >+ >+ // Look for any thread or process that is not suspended >+ for (IExecutionDMContext execDmc : execDmcSuspendedList) { >+ if (!isSuspended(execDmc)) { >+ rm.done(false); >+ return; >+ } >+ } >+ >+ // Everything is suspended. >+ rm.done(true); >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void canStepSome(IExecutionDMContext[] contexts, StepType stepType, DataRequestMonitor<Boolean> rm) { >+ rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$ >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void canStepAll(IExecutionDMContext[] contexts, StepType stepType, DataRequestMonitor<Boolean> rm) { >+ rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$ >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void isSteppingSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) { >+ rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$ >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void isSteppingAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) { >+ rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$ >+ } >+ >+ /** >+ * {@inheritDoc} >+ * >+ * For GDB, a separate resume command will be sent, one for each context >+ * that can be resumed. >+ * @since 4.1 >+ */ >+ @Override >+ public void resume(IExecutionDMContext[] contexts, RequestMonitor rm) { >+ assert contexts != null; >+ >+ List<IExecutionDMContext> execDmcToResumeList = extractContextsForOperation(contexts); >+ >+ CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); >+ int count = 0; >+ >+ // Perform resume operation on each thread or process that can be resumed >+ for (IExecutionDMContext execDmc : execDmcToResumeList) { >+ if (doCanResume(execDmc)) { >+ count++; >+ resume(execDmc, crm); >+ } >+ } >+ >+ crm.setDoneCount(count); >+ } >+ >+ /** >+ * {@inheritDoc} >+ * >+ * For GDB, a separate suspend command will be sent, one for each context >+ * that can be suspended. >+ * @since 4.1 >+ */ >+ @Override >+ public void suspend(IExecutionDMContext[] contexts, RequestMonitor rm) { >+ assert contexts != null; >+ >+ List<IExecutionDMContext> execDmcToSuspendList = extractContextsForOperation(contexts); >+ >+ CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); >+ int count = 0; >+ >+ // Perform resume operation on each thread or process that can be resumed >+ for (IExecutionDMContext execDmc : execDmcToSuspendList) { >+ if (doCanSuspend(execDmc)) { >+ count++; >+ suspend(execDmc, crm); >+ } >+ } >+ >+ crm.setDoneCount(count); >+ } >+ >+ /** @since 4.1 */ >+ @Override >+ public void step(IExecutionDMContext[] contexts, StepType stepType, RequestMonitor rm) { >+ rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$ >+ } > } >diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_2_NS.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_2_NS.java >index 97d1419..7f289ce 100644 >--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_2_NS.java >+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_2_NS.java >@@ -18,6 +18,7 @@ > import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; > import org.eclipse.cdt.dsf.concurrent.RequestMonitor; > import org.eclipse.cdt.dsf.datamodel.DMContexts; >+import org.eclipse.cdt.dsf.debug.service.IMultiRunControl; > import org.eclipse.cdt.dsf.debug.service.IRunControl; > import org.eclipse.cdt.dsf.debug.service.IRunControl2; > import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; >@@ -72,6 +73,7 @@ > register(new String[]{ IRunControl.class.getName(), > IRunControl2.class.getName(), > IMIRunControl.class.getName(), >+ IMultiRunControl.class.getName(), > GDBRunControl_7_0_NS.class.getName(), > GDBRunControl_7_2_NS.class.getName(), > }, >diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfCommandRunnable.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfCommandRunnable.java >index a79fa6e..c39aaf8 100644 >--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfCommandRunnable.java >+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfCommandRunnable.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2009 Wind River Systems and others. >+ * Copyright (c) 2006, 2012 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 >@@ -7,8 +7,12 @@ > * > * Contributors: > * Wind River Systems - initial API and implementation >+ * Marc Khouzam (Ericsson) - Added support for multiple selection (bug 330974) > *******************************************************************************/ > package org.eclipse.cdt.dsf.debug.ui.actions; >+ >+import java.util.HashSet; >+import java.util.Set; > > import org.eclipse.cdt.dsf.concurrent.DsfRunnable; > import org.eclipse.cdt.dsf.concurrent.Immutable; >@@ -29,11 +33,13 @@ > */ > @Immutable > public abstract class DsfCommandRunnable extends DsfRunnable { >- private final IExecutionDMContext fContext; >+ private final IExecutionDMContext[] fContexts; > private final DsfServicesTracker fTracker; > private final IDebugCommandRequest fRequest; > >- public IExecutionDMContext getContext() { return fContext; } >+ public IExecutionDMContext getContext() { return fContexts != null ? fContexts[0] : null; } >+ /** @since 2.3 */ >+ public IExecutionDMContext[] getContexts() { return fContexts; } > public IRunControl getRunControl() { > return fTracker.getService(IRunControl.class); > } >@@ -42,8 +48,8 @@ > * @since 1.1 > */ > public SteppingController getSteppingController() { >- if (fContext != null) { >- return (SteppingController) fContext.getAdapter(SteppingController.class); >+ if (fContexts != null && fContexts.length > 0) { >+ return (SteppingController) fContexts[0].getAdapter(SteppingController.class); > } > return null; > } >@@ -56,15 +62,32 @@ > } > > public DsfCommandRunnable(DsfServicesTracker servicesTracker, Object element, IDebugCommandRequest request) { >- fTracker = servicesTracker; >- if (element instanceof IDMVMContext) { >- IDMVMContext vmc = (IDMVMContext)element; >- fContext = DMContexts.getAncestorOfType(vmc.getDMContext(), IExecutionDMContext.class); >- } else { >- fContext = null; >- } >- >- fRequest = request; >+ this(servicesTracker, new Object[] { element }, request); >+ } >+ >+ /** @since 2.3 */ >+ public DsfCommandRunnable(DsfServicesTracker servicesTracker, Object[] elements, IDebugCommandRequest request) { >+ fTracker = servicesTracker; >+ fRequest = request; >+ >+ // Extract all select threads and processes, using a set to avoid duplicates >+ Set<IExecutionDMContext> execDmcSet = new HashSet<IExecutionDMContext>(request.getElements().length); >+ for (Object element : request.getElements()) { >+ if (element instanceof IDMVMContext) { >+ IDMVMContext vmc = (IDMVMContext)element; >+ IExecutionDMContext execDmc = DMContexts.getAncestorOfType(vmc.getDMContext(), IExecutionDMContext.class); >+ if (execDmc != null) { >+ // We have a thread or a process >+ execDmcSet.add(execDmc); >+ } >+ } >+ } >+ >+ if (execDmcSet.size() == 0) { >+ fContexts = null; >+ } else { >+ fContexts = execDmcSet.toArray(new IExecutionDMContext[execDmcSet.size()]); >+ } > } > > @Override >@@ -73,8 +96,8 @@ > fRequest.done(); > return; > } >- if (getContext() == null) { >- fRequest.setStatus(makeError("Selected object does not support run control.", null)); //$NON-NLS-1$ >+ if (getContexts() == null) { >+ fRequest.setStatus(makeError("Selected objects do not support run control.", null)); //$NON-NLS-1$ > } else if (getRunControl() == null || getSteppingController() == null) { > fRequest.setStatus(makeError("Run Control not available", null)); //$NON-NLS-1$ > } else { >diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfResumeCommand.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfResumeCommand.java >index 10e7c46..99ba5aa 100644 >--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfResumeCommand.java >+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfResumeCommand.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2009 Wind River Systems and others. >+ * Copyright (c) 2006, 2012 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 >@@ -7,14 +7,16 @@ > * > * Contributors: > * Wind River Systems - initial API and implementation >+ * Marc Khouzam (Ericsson) - Added support for multi-selection (Bug 330974) > *******************************************************************************/ > package org.eclipse.cdt.dsf.debug.ui.actions; > >-import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; > import org.eclipse.cdt.dsf.concurrent.DsfExecutor; >-import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; >+import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; >+import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; > import org.eclipse.cdt.dsf.concurrent.Immutable; > import org.eclipse.cdt.dsf.concurrent.RequestMonitor; >+import org.eclipse.cdt.dsf.debug.service.IMultiRunControl; > import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; > import org.eclipse.cdt.dsf.service.DsfServicesTracker; > import org.eclipse.cdt.dsf.service.DsfSession; >@@ -43,17 +45,40 @@ > > @Override > public void canExecute(final IEnabledStateRequest request) { >- if (request.getElements().length != 1) { >- request.setEnabled(false); >- request.done(); >+ if (request.getElements().length == 1) { >+ canExecuteSingle(request); > return; > } > >+ fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements(), request) { >+ @Override public void doExecute() { >+ final IMultiRunControl multiRun = fTracker.getService(IMultiRunControl.class); >+ if (multiRun == null) { >+ // No multi run control service: multi selection not allowed >+ request.setEnabled(false); >+ request.done(); >+ return; >+ } >+ >+ multiRun.canResumeSome( >+ getContexts(), >+ new ImmediateDataRequestMonitor<Boolean>() { >+ @Override >+ protected void handleCompleted() { >+ request.setEnabled(isSuccess() && getData()); >+ request.done(); >+ } >+ }); >+ } >+ }); >+ } >+ >+ private void canExecuteSingle(final IEnabledStateRequest request) { > fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { > @Override public void doExecute() { > getRunControl().canResume( > getContext(), >- new DataRequestMonitor<Boolean>(ImmediateExecutor.getInstance(), null) { >+ new ImmediateDataRequestMonitor<Boolean>() { > @Override > protected void handleCompleted() { > request.setEnabled(isSuccess() && getData()); >@@ -66,17 +91,31 @@ > > @Override > public boolean execute(final IDebugCommandRequest request) { >- if (request.getElements().length != 1) { >- request.done(); >- return false; >+ if (request.getElements().length == 1) { >+ executeSingle(request); >+ return false; > } >+ >+ fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements(), request) { >+ @Override public void doExecute() { >+ final IMultiRunControl multiRun = fTracker.getService(IMultiRunControl.class); >+ if (multiRun == null) { >+ // No multi run control service: multi selection not allowed >+ request.done(); >+ return; >+ } > >+ multiRun.resume(getContexts(), new ImmediateRequestMonitor()); >+ } >+ }); >+ return false; >+ } >+ >+ private void executeSingle(IDebugCommandRequest request) { > fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { > @Override public void doExecute() { > getRunControl().resume(getContext(), new RequestMonitor(fExecutor, null)); > } > }); >- return false; > } >- > } >diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfSuspendCommand.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfSuspendCommand.java >index ebc3261..6296923 100644 >--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfSuspendCommand.java >+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfSuspendCommand.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2009 Wind River Systems and others. >+ * Copyright (c) 2006, 2012 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 >@@ -7,14 +7,16 @@ > * > * Contributors: > * Wind River Systems - initial API and implementation >+ * Marc Khouzam (Ericsson) - Added support for multi-selection (Bug 330974) > *******************************************************************************/ > package org.eclipse.cdt.dsf.debug.ui.actions; > >-import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; > import org.eclipse.cdt.dsf.concurrent.DsfExecutor; >-import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; >+import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; >+import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; > import org.eclipse.cdt.dsf.concurrent.Immutable; > import org.eclipse.cdt.dsf.concurrent.RequestMonitor; >+import org.eclipse.cdt.dsf.debug.service.IMultiRunControl; > import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; > import org.eclipse.cdt.dsf.service.DsfServicesTracker; > import org.eclipse.cdt.dsf.service.DsfSession; >@@ -42,17 +44,40 @@ > > @Override > public void canExecute(final IEnabledStateRequest request) { >- if (request.getElements().length != 1) { >- request.setEnabled(false); >- request.done(); >+ if (request.getElements().length == 1) { >+ canExecuteSingle(request); > return; > } > >+ fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements(), request) { >+ @Override public void doExecute() { >+ final IMultiRunControl multiRun = fTracker.getService(IMultiRunControl.class); >+ if (multiRun == null) { >+ // No multi run control service: multi selection not allowed >+ request.setEnabled(false); >+ request.done(); >+ return; >+ } >+ >+ multiRun.canSuspendSome( >+ getContexts(), >+ new ImmediateDataRequestMonitor<Boolean>() { >+ @Override >+ protected void handleCompleted() { >+ request.setEnabled(isSuccess() && getData()); >+ request.done(); >+ } >+ }); >+ } >+ }); >+ } >+ >+ private void canExecuteSingle(final IEnabledStateRequest request) { > fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { > @Override public void doExecute() { > getRunControl().canSuspend( > getContext(), >- new DataRequestMonitor<Boolean>(ImmediateExecutor.getInstance(), null) { >+ new ImmediateDataRequestMonitor<Boolean>() { > @Override > protected void handleCompleted() { > request.setEnabled(isSuccess() && getData()); >@@ -65,17 +90,32 @@ > > @Override > public boolean execute(final IDebugCommandRequest request) { >- if (request.getElements().length != 1) { >- request.done(); >- return false; >+ if (request.getElements().length == 1) { >+ executeSingle(request); >+ return false; > } >- >+ >+ fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements(), request) { >+ @Override public void doExecute() { >+ final IMultiRunControl multiRun = fTracker.getService(IMultiRunControl.class); >+ if (multiRun == null) { >+ // No multi run control service: multi selection not allowed >+ request.done(); >+ return; >+ } >+ >+ multiRun.suspend(getContexts(), new ImmediateRequestMonitor()); >+ } >+ }); >+ return false; >+ } >+ >+ private void executeSingle(IDebugCommandRequest request) { > fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { > @Override public void doExecute() { > getRunControl().suspend(getContext(), new RequestMonitor(fExecutor, null)); > } > }); >- return false; > } > > } >diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IMultiRunControl.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IMultiRunControl.java >new file mode 100644 >index 0000000..bd84bc3 >--- /dev/null >+++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IMultiRunControl.java >@@ -0,0 +1,138 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 Ericsson 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: >+ * Marc Khouzam (Ericsson) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.dsf.debug.service; >+ >+import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; >+import org.eclipse.cdt.dsf.concurrent.RequestMonitor; >+ >+/** >+ * This interface provides the ability to perform run control operations on multiple contexts. >+ * >+ * @see org.eclipse.cdt.dsf.debug.service.IRunControl >+ * >+ * @since 2.3 >+ */ >+public interface IMultiRunControl extends IRunControl >+{ >+// public interface IMultiSuspendedDMEvent; >+// public interface IMultiResumedDMEvent; >+// public interface IMultiContainerSuspendedDMEvent; >+// public interface IMultiContainerResumedDMEvent; >+// public interface IMultiStartedDMEvent; >+// public interface IMultiExitedDMEvent; >+ >+ /** >+ * Check if at least one of the specified contexts can be resumed >+ * @param context List of execution contexts that want to be resumed >+ * @param rm Request monitor returning: >+ * true if at least one of the specified contexts can be resumed >+ * false if none of the specified contexts can be resumed >+ */ >+ void canResumeSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if at all of the specified contexts can be resumed >+ * @param context List of execution contexts that want to be resumed >+ * @param rm Request monitor returning: >+ * true if all of the specified contexts can be resumed >+ * false if any of the specified contexts cannot be resumed >+ */ >+ void canResumeAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if at least one of the specified contexts can be suspended >+ * @param context List of execution contexts that want to be suspended >+ * @param rm Request monitor returning: >+ * true if at least one of the specified contexts can be suspended >+ * false if none of the specified contexts can be suspended >+ */ >+ void canSuspendSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if all of the specified contexts can be suspended >+ * @param context List of execution contexts that want to be suspended >+ * @param rm Request monitor returning: >+ * true if all of the specified contexts can be suspended >+ * false if any of the specified contexts cannot be suspended >+ */ >+ void canSuspendAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if any of the specified contexts is suspended. >+ * @param context List of execution contexts that are to be checked for being suspended >+ * @param rm Request monitor returning: >+ * true if any of the specified contexts is suspended, false otherwise >+ */ >+ void isSuspendedSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if all of the specified contexts are suspended. >+ * @param context List of execution contexts that are to be checked for being suspended >+ * @param rm Request monitor returning: >+ * true if all of the specified contexts is suspended, false otherwise >+ */ >+ void isSuspendedAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if any of the specified contexts can be stepped >+ * @param context List of execution contexts that want to be stepped >+ * @param rm Request monitor returning: >+ * true if amy of the specified contexts can be stepped >+ * false if none of the specified contexts can be stepped >+ */ >+ void canStepSome(IExecutionDMContext[] contexts, StepType stepType, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if all of the specified contexts can be stepped >+ * @param context List of execution contexts that want to be stepped >+ * @param rm Request monitor returning: >+ * true if all of the specified contexts can be stepped >+ * false if any of the specified contexts cannot be stepped >+ */ >+ void canStepAll(IExecutionDMContext[] contexts, StepType stepType, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if any of the specified contexts is currently stepping. >+ * @param context List of execution contexts that are to be checked for stepping >+ * @param rm Request monitor returning: >+ * true if any of the specified contexts is stepping, false otherwise >+ */ >+ void isSteppingSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Check if all of the specified contexts are currently stepping. >+ * @param context List of execution contexts that are to be checked for stepping >+ * @param rm Request monitor returning: >+ * true if all of the specified contexts is stepping, false otherwise >+ */ >+ void isSteppingAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm); >+ >+ /** >+ * Request that all specified context be resumed. Only contexts that are in a >+ * state that can be resumed will be, others will be ignored. >+ * @param context List of execution contexts that are to be resumed >+ */ >+ void resume(IExecutionDMContext[] contexts, RequestMonitor rm); >+ >+ /** >+ * Request that all specified context be suspended. Only contexts that are in a >+ * state that can be suspended will be, others will be ignored. >+ * @param context List of execution contexts that are to be suspended >+ */ >+ void suspend(IExecutionDMContext[] contexts, RequestMonitor rm); >+ >+ /** >+ * Request that all specified context be stepped. Only contexts that are in a >+ * state that can be stepped will be, others will be ignored. >+ * @param context List of execution contexts that are to be stepped >+ */ >+ void step(IExecutionDMContext[] contexts, StepType stepType, RequestMonitor rm); >+} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
marc.khouzam
:
iplog-
Actions:
View
|
Diff
Attachments on
bug 330974
:
214147
|
214418