Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 330974 | Differences between
and this patch

Collapse All | Expand All

(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java (-2 / +274 lines)
Lines 9-22 Link Here
9
 *     Wind River Systems - initial API and implementation
9
 *     Wind River Systems - initial API and implementation
10
 *     Ericsson	AB		  - Modified for handling of multiple threads
10
 *     Ericsson	AB		  - Modified for handling of multiple threads
11
 *     Indel AG           - [369622] fixed moveToLine using MinGW
11
 *     Indel AG           - [369622] fixed moveToLine using MinGW
12
 *     Marc Khouzam (Ericsson) - Support for operations on multiple execution contexts (bug 330974)
12
 *******************************************************************************/
13
 *******************************************************************************/
13
14
14
package org.eclipse.cdt.dsf.gdb.service;
15
package org.eclipse.cdt.dsf.gdb.service;
15
16
17
import java.util.ArrayList;
18
import java.util.Arrays;
16
import java.util.HashMap;
19
import java.util.HashMap;
17
import java.util.HashSet;
20
import java.util.HashSet;
18
import java.util.Hashtable;
21
import java.util.Hashtable;
19
import java.util.LinkedList;
22
import java.util.LinkedList;
23
import java.util.List;
20
import java.util.Map;
24
import java.util.Map;
21
import java.util.Set;
25
import java.util.Set;
22
26
Lines 42-47 Link Here
42
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
46
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
43
import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension.IBreakpointHitDMEvent;
47
import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension.IBreakpointHitDMEvent;
44
import org.eclipse.cdt.dsf.debug.service.ICachingService;
48
import org.eclipse.cdt.dsf.debug.service.ICachingService;
49
import org.eclipse.cdt.dsf.debug.service.IMultiRunControl;
45
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
50
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
46
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
51
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
47
import org.eclipse.cdt.dsf.debug.service.IRunControl;
52
import org.eclipse.cdt.dsf.debug.service.IRunControl;
Lines 104-110 Link Here
104
 * sync with the service state.
109
 * sync with the service state.
105
 * @since 1.1
110
 * @since 1.1
106
 */
111
 */
107
public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunControl, ICachingService
112
public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunControl, IMultiRunControl, ICachingService
108
{
113
{
109
	@Immutable
114
	@Immutable
110
	private static class ExecutionData implements IExecutionDMData2 {
115
	private static class ExecutionData implements IExecutionDMData2 {
Lines 396-402 Link Here
396
	private void doInitialize(final RequestMonitor rm) {
401
	private void doInitialize(final RequestMonitor rm) {
397
        register(new String[]{ IRunControl.class.getName(), 
402
        register(new String[]{ IRunControl.class.getName(), 
398
        					   IRunControl2.class.getName(),
403
        					   IRunControl2.class.getName(),
399
        					   IMIRunControl.class.getName()}, 
404
        					   IMIRunControl.class.getName(),
405
        					   IMultiRunControl.class.getName() }, 
400
        	     new Hashtable<String,String>());
406
        	     new Hashtable<String,String>());
401
		fConnection = getServicesTracker().getService(ICommandControlService.class);
407
		fConnection = getServicesTracker().getService(ICommandControlService.class);
402
		fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
408
		fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
Lines 1878-1881 Link Here
1878
    	}
1884
    	}
1879
    	return result;
1885
    	return result;
1880
    }
1886
    }
1887
    
1888
    /**
1889
     * Removes duplicates from the list of execution contexts.
1890
     * Also, remove threads that are part of a process that is also present.
1891
     */
1892
    private List<IExecutionDMContext> extractContextsForOperation(IExecutionDMContext[] contexts) {
1893
    	// Handle duplicate contexts by using a set
1894
    	Set<IExecutionDMContext> specifiedExedDmcSet = new HashSet<IExecutionDMContext>(Arrays.asList(contexts));
1895
1896
    	// A list that ignores threads for which the process is also present
1897
    	List<IExecutionDMContext> execDmcForOperationList = new ArrayList<IExecutionDMContext>(specifiedExedDmcSet.size());
1898
1899
    	// Check for the case of a process selected along with some of its threads
1900
    	for (IExecutionDMContext execDmc : specifiedExedDmcSet) {
1901
    		if (execDmc instanceof IContainerDMContext) {
1902
    			// This is a process: it is automatically part of our list
1903
    			execDmcForOperationList.add(execDmc);
1904
    		} else {
1905
    			// Get the process for this thread
1906
    			IContainerDMContext containerDmc = DMContexts.getAncestorOfType(execDmc, IContainerDMContext.class);
1907
    			// Check if the process is also present
1908
    			if (specifiedExedDmcSet.contains(containerDmc) == false) {
1909
    				// This thread does not belong to a process that is selected, so we keep it.
1910
    				execDmcForOperationList.add(execDmc);
1911
    			}
1912
    		}
1913
    	}
1914
    	return execDmcForOperationList;
1915
    }
1916
1917
    // Multi resume:
1918
    //
1919
    // If one or more more threads of one or many processes are selected, we want to 
1920
    // resume each thread.
1921
    // 
1922
    // If a process is selected along with one or more threads of that process,
1923
    // what does the user want us to do?  Selecting the process means resume all its
1924
    // threads, but what do we do with the selected threads?  Why are they
1925
    // selected?  In an attempt to be user friendly, lets assume that the user
1926
    // wants to resume the entire process.
1927
    //
1928
    // On the other hand, selecting a process and also threads from another
1929
    // process makes perfect sense; the process is resumed, and the threads
1930
    // selected are handled as the normal case.
1931
1932
    /** @since 4.1 */
1933
    @Override
1934
    public void canResumeSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) {
1935
    	assert contexts != null;
1936
1937
    	if (fRunControlOperationsEnabled == false) {
1938
    		rm.done(false);
1939
    		return;
1940
    	}
1941
1942
    	List<IExecutionDMContext> execDmcToResumeList = extractContextsForOperation(contexts);
1943
1944
    	// If any of the threads or processes can be resumed, we allow
1945
    	// the user to perform the operation.
1946
    	for (IExecutionDMContext execDmc : execDmcToResumeList) {
1947
    		if (doCanResume(execDmc)) {
1948
    			rm.done(true);
1949
    			return;
1950
    		}
1951
    	}
1952
1953
    	// Didn't find anything that could be resumed.
1954
    	rm.done(false);
1955
    }
1956
1957
    /** @since 4.1 */
1958
    @Override
1959
    public void canResumeAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) {
1960
    	assert contexts != null;
1961
1962
    	if (fRunControlOperationsEnabled == false) {
1963
    		rm.done(false);
1964
    		return;
1965
    	}
1966
1967
    	List<IExecutionDMContext> execDmcToResumeList = extractContextsForOperation(contexts);
1968
1969
    	// If any of the threads or processes cannot be resumed, we don't allow
1970
    	// the user to perform the operation.
1971
    	for (IExecutionDMContext execDmc : execDmcToResumeList) {
1972
    		if (!doCanResume(execDmc)) {
1973
    			rm.done(false);
1974
    			return;
1975
    		}
1976
    	}
1977
1978
    	// Everything can be resumed
1979
    	rm.done(true);
1980
    }
1981
1982
    /** @since 4.1 */
1983
    @Override
1984
    public void canSuspendSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) {
1985
    	assert contexts != null;
1986
1987
    	if (fRunControlOperationsEnabled == false) {
1988
    		rm.done(false);
1989
    		return;
1990
    	}
1991
1992
    	List<IExecutionDMContext> execDmcToSuspendList = extractContextsForOperation(contexts);
1993
1994
    	// If any of the threads or processes can be suspended, we allow
1995
    	// the user to perform the operation.
1996
    	for (IExecutionDMContext execDmc : execDmcToSuspendList) {
1997
    		if (doCanSuspend(execDmc)) {
1998
    			rm.done(true);
1999
    			return;
2000
    		}
2001
    	}
2002
2003
    	// Didn't find anything that could be suspended.
2004
    	rm.done(false);
2005
    }
2006
2007
    /** @since 4.1 */
2008
    @Override
2009
    public void canSuspendAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) {
2010
    	assert contexts != null;
2011
2012
    	if (fRunControlOperationsEnabled == false) {
2013
    		rm.done(false);
2014
    		return;
2015
    	}
2016
2017
    	List<IExecutionDMContext> execDmcToSuspendList = extractContextsForOperation(contexts);
2018
2019
    	// If any of the threads or processes cannot be suspended, we don't allow
2020
    	// the user to perform the operation.
2021
    	for (IExecutionDMContext execDmc : execDmcToSuspendList) {
2022
    		if (!doCanSuspend(execDmc)) {
2023
    			rm.done(false);
2024
    			return;
2025
    		}
2026
    	}
2027
2028
    	// Everything can be suspended
2029
    	rm.done(true);
2030
    }
2031
2032
    /** @since 4.1 */
2033
    @Override
2034
    public void isSuspendedSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) {
2035
    	assert contexts != null;
2036
2037
    	List<IExecutionDMContext> execDmcSuspendedList = extractContextsForOperation(contexts);
2038
2039
    	// Look for any thread or process that is suspended
2040
    	for (IExecutionDMContext execDmc : execDmcSuspendedList) {
2041
    		if (isSuspended(execDmc)) {
2042
    			rm.done(true);
2043
    			return;
2044
    		}
2045
    	}
2046
2047
    	// Didn't find anything that was suspended.
2048
		rm.done(false);
2049
    }
2050
2051
    /** @since 4.1 */
2052
    @Override
2053
    public void isSuspendedAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) {
2054
    	assert contexts != null;
2055
2056
    	List<IExecutionDMContext> execDmcSuspendedList = extractContextsForOperation(contexts);
2057
2058
    	// Look for any thread or process that is not suspended
2059
    	for (IExecutionDMContext execDmc : execDmcSuspendedList) {
2060
    		if (!isSuspended(execDmc)) {
2061
    			rm.done(false);
2062
    			return;
2063
    		}
2064
    	}
2065
2066
    	// Everything is suspended.
2067
		rm.done(true);
2068
    }
2069
2070
    /** @since 4.1 */
2071
    @Override
2072
    public void canStepSome(IExecutionDMContext[] contexts, StepType stepType, DataRequestMonitor<Boolean> rm) {
2073
        rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$
2074
   }
2075
2076
    /** @since 4.1 */
2077
    @Override
2078
    public void canStepAll(IExecutionDMContext[] contexts, StepType stepType, DataRequestMonitor<Boolean> rm) {
2079
        rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$
2080
    }
2081
2082
    /** @since 4.1 */
2083
    @Override
2084
    public void isSteppingSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) {
2085
        rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$
2086
    }
2087
2088
    /** @since 4.1 */
2089
    @Override
2090
    public void isSteppingAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm) {
2091
        rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$
2092
    }
2093
2094
    /** 
2095
     * {@inheritDoc}
2096
     * 
2097
     * For GDB, a separate resume command will be sent, one for each context
2098
     * that can be resumed.
2099
     * @since 4.1 
2100
     */
2101
    @Override
2102
    public void resume(IExecutionDMContext[] contexts, RequestMonitor rm) {
2103
    	assert contexts != null;
2104
2105
    	List<IExecutionDMContext> execDmcToResumeList = extractContextsForOperation(contexts);
2106
2107
    	CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm);
2108
    	int count = 0;
2109
2110
    	// Perform resume operation on each thread or process that can be resumed
2111
    	for (IExecutionDMContext execDmc : execDmcToResumeList) {
2112
    		if (doCanResume(execDmc)) {
2113
    			count++;
2114
    			resume(execDmc, crm);
2115
    		}
2116
    	}
2117
2118
    	crm.setDoneCount(count);
2119
    }
2120
2121
    /** 
2122
     * {@inheritDoc}
2123
     * 
2124
     * For GDB, a separate suspend command will be sent, one for each context
2125
     * that can be suspended.
2126
     * @since 4.1 
2127
     */
2128
    @Override
2129
    public void suspend(IExecutionDMContext[] contexts, RequestMonitor rm) {
2130
    	assert contexts != null;
2131
2132
    	List<IExecutionDMContext> execDmcToSuspendList = extractContextsForOperation(contexts);
2133
2134
    	CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm);
2135
    	int count = 0;
2136
2137
    	// Perform resume operation on each thread or process that can be resumed
2138
    	for (IExecutionDMContext execDmc : execDmcToSuspendList) {
2139
    		if (doCanSuspend(execDmc)) {
2140
    			count++;
2141
    			suspend(execDmc, crm);
2142
    		}
2143
    	}
2144
2145
    	crm.setDoneCount(count);
2146
    }
2147
2148
    /** @since 4.1 */
2149
    @Override
2150
    public void step(IExecutionDMContext[] contexts, StepType stepType, RequestMonitor rm) {
2151
        rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$
2152
    }
1881
}
2153
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_2_NS.java (+2 lines)
Lines 18-23 Link Here
18
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
18
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
19
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
19
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
20
import org.eclipse.cdt.dsf.datamodel.DMContexts;
20
import org.eclipse.cdt.dsf.datamodel.DMContexts;
21
import org.eclipse.cdt.dsf.debug.service.IMultiRunControl;
21
import org.eclipse.cdt.dsf.debug.service.IRunControl;
22
import org.eclipse.cdt.dsf.debug.service.IRunControl;
22
import org.eclipse.cdt.dsf.debug.service.IRunControl2;
23
import org.eclipse.cdt.dsf.debug.service.IRunControl2;
23
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
24
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
Lines 72-77 Link Here
72
		register(new String[]{ IRunControl.class.getName(), 
73
		register(new String[]{ IRunControl.class.getName(), 
73
				IRunControl2.class.getName(),
74
				IRunControl2.class.getName(),
74
				IMIRunControl.class.getName(),
75
				IMIRunControl.class.getName(),
76
				IMultiRunControl.class.getName(),
75
				GDBRunControl_7_0_NS.class.getName(),
77
				GDBRunControl_7_0_NS.class.getName(),
76
				GDBRunControl_7_2_NS.class.getName(),
78
				GDBRunControl_7_2_NS.class.getName(),
77
		}, 
79
		}, 
(-)a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfCommandRunnable.java (-16 / +39 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 Wind River Systems and others.
2
 * Copyright (c) 2006, 2012 Wind River Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-14 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     Wind River Systems - initial API and implementation
9
 *     Wind River Systems - initial API and implementation
10
 *     Marc Khouzam (Ericsson) - Added support for multiple selection (bug 330974)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.debug.ui.actions;
12
package org.eclipse.cdt.dsf.debug.ui.actions;
13
14
import java.util.HashSet;
15
import java.util.Set;
12
16
13
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
17
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
14
import org.eclipse.cdt.dsf.concurrent.Immutable;
18
import org.eclipse.cdt.dsf.concurrent.Immutable;
Lines 29-39 Link Here
29
 */
33
 */
30
@Immutable
34
@Immutable
31
public abstract class DsfCommandRunnable extends DsfRunnable {
35
public abstract class DsfCommandRunnable extends DsfRunnable {
32
    private final IExecutionDMContext fContext;
36
    private final IExecutionDMContext[] fContexts;
33
    private final DsfServicesTracker fTracker;
37
    private final DsfServicesTracker fTracker;
34
    private final IDebugCommandRequest fRequest;
38
    private final IDebugCommandRequest fRequest;
35
    
39
    
36
    public IExecutionDMContext getContext() { return fContext; }
40
    public IExecutionDMContext getContext() { return fContexts != null ? fContexts[0] : null; }
41
    /** @since 2.3 */
42
    public IExecutionDMContext[] getContexts() { return fContexts; }
37
    public IRunControl getRunControl() {
43
    public IRunControl getRunControl() {
38
        return fTracker.getService(IRunControl.class);
44
        return fTracker.getService(IRunControl.class);
39
    }
45
    }
Lines 42-49 Link Here
42
	 * @since 1.1
48
	 * @since 1.1
43
	 */
49
	 */
44
    public SteppingController getSteppingController() {
50
    public SteppingController getSteppingController() {
45
    	if (fContext != null) {
51
    	if (fContexts != null && fContexts.length > 0) {
46
    		return (SteppingController) fContext.getAdapter(SteppingController.class);
52
    		return (SteppingController) fContexts[0].getAdapter(SteppingController.class);
47
    	}
53
    	}
48
    	return null;
54
    	return null;
49
    }
55
    }
Lines 56-70 Link Here
56
    }
62
    }
57
        
63
        
58
    public DsfCommandRunnable(DsfServicesTracker servicesTracker, Object element, IDebugCommandRequest request) {
64
    public DsfCommandRunnable(DsfServicesTracker servicesTracker, Object element, IDebugCommandRequest request) {
59
        fTracker = servicesTracker;
65
    	this(servicesTracker, new Object[] { element }, request);
60
        if (element instanceof IDMVMContext) {
66
    }
61
            IDMVMContext vmc = (IDMVMContext)element;
67
    
62
            fContext = DMContexts.getAncestorOfType(vmc.getDMContext(), IExecutionDMContext.class);
68
    /** @since 2.3 */
63
        } else {
69
    public DsfCommandRunnable(DsfServicesTracker servicesTracker, Object[] elements, IDebugCommandRequest request) {
64
            fContext = null;
70
    	fTracker = servicesTracker;
65
        }
71
    	fRequest = request;
66
            
72
67
        fRequest = request;
73
		// Extract all select threads and processes, using a set to avoid duplicates
74
		Set<IExecutionDMContext> execDmcSet = new HashSet<IExecutionDMContext>(request.getElements().length);
75
		for (Object element : request.getElements()) {
76
			if (element instanceof IDMVMContext) {
77
				IDMVMContext vmc = (IDMVMContext)element;
78
				IExecutionDMContext execDmc = DMContexts.getAncestorOfType(vmc.getDMContext(), IExecutionDMContext.class);
79
				if (execDmc != null) {
80
					// We have a thread or a process
81
					execDmcSet.add(execDmc);
82
				}
83
			}
84
		}
85
86
		if (execDmcSet.size() == 0) {
87
			fContexts = null;
88
		} else {
89
			fContexts = execDmcSet.toArray(new IExecutionDMContext[execDmcSet.size()]);
90
		}
68
    }
91
    }
69
    
92
    
70
    @Override
93
    @Override
Lines 73-80 Link Here
73
            fRequest.done();
96
            fRequest.done();
74
            return;
97
            return;
75
        }
98
        }
76
        if (getContext() == null) {
99
        if (getContexts() == null) {
77
            fRequest.setStatus(makeError("Selected object does not support run control.", null));             //$NON-NLS-1$
100
            fRequest.setStatus(makeError("Selected objects do not support run control.", null));             //$NON-NLS-1$
78
        } else if (getRunControl() == null || getSteppingController() == null) {
101
        } else if (getRunControl() == null || getSteppingController() == null) {
79
            fRequest.setStatus(makeError("Run Control not available", null)); //$NON-NLS-1$
102
            fRequest.setStatus(makeError("Run Control not available", null)); //$NON-NLS-1$
80
        } else {
103
        } else {
(-)a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfResumeCommand.java (-12 / +51 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 Wind River Systems and others.
2
 * Copyright (c) 2006, 2012 Wind River Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-20 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     Wind River Systems - initial API and implementation
9
 *     Wind River Systems - initial API and implementation
10
 *     Marc Khouzam (Ericsson) - Added support for multi-selection (Bug 330974)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.debug.ui.actions;
12
package org.eclipse.cdt.dsf.debug.ui.actions;
12
13
13
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
14
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
14
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
15
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
15
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
16
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
16
import org.eclipse.cdt.dsf.concurrent.Immutable;
17
import org.eclipse.cdt.dsf.concurrent.Immutable;
17
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
18
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
19
import org.eclipse.cdt.dsf.debug.service.IMultiRunControl;
18
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
20
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
19
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
21
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
20
import org.eclipse.cdt.dsf.service.DsfSession;
22
import org.eclipse.cdt.dsf.service.DsfSession;
Lines 43-59 Link Here
43
45
44
    @Override
46
    @Override
45
	public void canExecute(final IEnabledStateRequest request) {
47
	public void canExecute(final IEnabledStateRequest request) {
46
        if (request.getElements().length != 1) {
48
        if (request.getElements().length == 1) {
47
            request.setEnabled(false);
49
			canExecuteSingle(request);
48
            request.done();
49
            return;
50
            return;
50
        }
51
        }
51
52
53
        fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements(), request) { 
54
            @Override public void doExecute() {
55
    			final IMultiRunControl multiRun = fTracker.getService(IMultiRunControl.class);
56
    			if (multiRun == null) {
57
    				// No multi run control service: multi selection not allowed
58
    				request.setEnabled(false);
59
    				request.done();
60
    				return;
61
    			}
62
    			
63
    			multiRun.canResumeSome(
64
    					getContexts(),
65
    					new ImmediateDataRequestMonitor<Boolean>() {
66
    						@Override
67
    						protected void handleCompleted() {
68
    							request.setEnabled(isSuccess() && getData());
69
    							request.done();
70
    						}
71
    					});
72
            }
73
        });
74
    }
75
    
76
    private void canExecuteSingle(final IEnabledStateRequest request) {
52
        fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { 
77
        fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { 
53
            @Override public void doExecute() {
78
            @Override public void doExecute() {
54
                getRunControl().canResume(
79
                getRunControl().canResume(
55
                    getContext(),
80
                    getContext(),
56
                    new DataRequestMonitor<Boolean>(ImmediateExecutor.getInstance(), null) {
81
                    new ImmediateDataRequestMonitor<Boolean>() {
57
                        @Override
82
                        @Override
58
                        protected void handleCompleted() {
83
                        protected void handleCompleted() {
59
                            request.setEnabled(isSuccess() && getData());
84
                            request.setEnabled(isSuccess() && getData());
Lines 66-82 Link Here
66
    
91
    
67
    @Override
92
    @Override
68
	public boolean execute(final IDebugCommandRequest request) {
93
	public boolean execute(final IDebugCommandRequest request) {
69
        if (request.getElements().length != 1) {
94
   		if (request.getElements().length == 1) {
70
            request.done();
95
   			executeSingle(request);
71
            return false;
96
   			return false;
72
        }
97
        }
98
   		
99
   		fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements(), request) { 
100
            @Override public void doExecute() {
101
    			final IMultiRunControl multiRun = fTracker.getService(IMultiRunControl.class);
102
    			if (multiRun == null) {
103
    				// No multi run control service: multi selection not allowed
104
    				request.done();
105
    				return;
106
    			}
73
107
108
    			multiRun.resume(getContexts(), new ImmediateRequestMonitor());
109
    		}
110
    	});
111
    	return false;
112
    }
113
    
114
	private void executeSingle(IDebugCommandRequest request) {
74
    	fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { 
115
    	fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { 
75
            @Override public void doExecute() {
116
            @Override public void doExecute() {
76
                getRunControl().resume(getContext(), new RequestMonitor(fExecutor, null));
117
                getRunControl().resume(getContext(), new RequestMonitor(fExecutor, null));
77
             }
118
             }
78
        });
119
        });
79
        return false;
80
    }
120
    }
81
82
}
121
}
(-)a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfSuspendCommand.java (-12 / +52 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 Wind River Systems and others.
2
 * Copyright (c) 2006, 2012 Wind River Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-20 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     Wind River Systems - initial API and implementation
9
 *     Wind River Systems - initial API and implementation
10
 *     Marc Khouzam (Ericsson) - Added support for multi-selection (Bug 330974)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.debug.ui.actions;
12
package org.eclipse.cdt.dsf.debug.ui.actions;
12
13
13
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
14
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
14
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
15
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
15
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
16
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
16
import org.eclipse.cdt.dsf.concurrent.Immutable;
17
import org.eclipse.cdt.dsf.concurrent.Immutable;
17
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
18
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
19
import org.eclipse.cdt.dsf.debug.service.IMultiRunControl;
18
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
20
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
19
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
21
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
20
import org.eclipse.cdt.dsf.service.DsfSession;
22
import org.eclipse.cdt.dsf.service.DsfSession;
Lines 42-58 Link Here
42
44
43
    @Override
45
    @Override
44
	public void canExecute(final IEnabledStateRequest request) {
46
	public void canExecute(final IEnabledStateRequest request) {
45
        if (request.getElements().length != 1) {
47
        if (request.getElements().length == 1) {
46
            request.setEnabled(false);
48
			canExecuteSingle(request);
47
            request.done();
48
            return;
49
            return;
49
        }
50
        }
50
        
51
        
52
        fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements(), request) { 
53
            @Override public void doExecute() {
54
    			final IMultiRunControl multiRun = fTracker.getService(IMultiRunControl.class);
55
    			if (multiRun == null) {
56
    				// No multi run control service: multi selection not allowed
57
    				request.setEnabled(false);
58
    				request.done();
59
    				return;
60
    			}
61
    			
62
    			multiRun.canSuspendSome(
63
    					getContexts(),
64
    					new ImmediateDataRequestMonitor<Boolean>() {
65
    						@Override
66
    						protected void handleCompleted() {
67
    							request.setEnabled(isSuccess() && getData());
68
    							request.done();
69
    						}
70
    					});
71
            }
72
        });
73
    }
74
    
75
    private void canExecuteSingle(final IEnabledStateRequest request) {
51
        fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { 
76
        fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { 
52
            @Override public void doExecute() {
77
            @Override public void doExecute() {
53
                getRunControl().canSuspend(
78
                getRunControl().canSuspend(
54
                    getContext(),
79
                    getContext(),
55
                    new DataRequestMonitor<Boolean>(ImmediateExecutor.getInstance(), null) {
80
                    new ImmediateDataRequestMonitor<Boolean>() {
56
                        @Override
81
                        @Override
57
                        protected void handleCompleted() {
82
                        protected void handleCompleted() {
58
                            request.setEnabled(isSuccess() && getData());
83
                            request.setEnabled(isSuccess() && getData());
Lines 65-81 Link Here
65
90
66
    @Override
91
    @Override
67
	public boolean execute(final IDebugCommandRequest request) {
92
	public boolean execute(final IDebugCommandRequest request) {
68
        if (request.getElements().length != 1) {
93
   		if (request.getElements().length == 1) {
69
            request.done();
94
   			executeSingle(request);
70
            return false;
95
   			return false;
71
        }
96
        }
72
        
97
  		
98
   		fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements(), request) { 
99
            @Override public void doExecute() {
100
    			final IMultiRunControl multiRun = fTracker.getService(IMultiRunControl.class);
101
    			if (multiRun == null) {
102
    				// No multi run control service: multi selection not allowed
103
    				request.done();
104
    				return;
105
    			}
106
107
    			multiRun.suspend(getContexts(), new ImmediateRequestMonitor());
108
    		}
109
    	});
110
   		return false;
111
    }
112
    
113
	private void executeSingle(IDebugCommandRequest request) {
73
        fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { 
114
        fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { 
74
            @Override public void doExecute() {
115
            @Override public void doExecute() {
75
                getRunControl().suspend(getContext(), new RequestMonitor(fExecutor, null));
116
                getRunControl().suspend(getContext(), new RequestMonitor(fExecutor, null));
76
            }
117
            }
77
        });
118
        });
78
        return false;
79
    }
119
    }
80
120
81
}
121
}
(-)a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IMultiRunControl.java (+138 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Ericsson and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Marc Khouzam (Ericsson) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.debug.service;
12
13
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
14
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
15
16
/**
17
 * This interface provides the ability to perform run control operations on multiple contexts.
18
 * 
19
 * @see org.eclipse.cdt.dsf.debug.service.IRunControl
20
 * 
21
 * @since 2.3
22
 */
23
public interface IMultiRunControl extends IRunControl
24
{
25
//    public interface IMultiSuspendedDMEvent;
26
//    public interface IMultiResumedDMEvent;
27
//    public interface IMultiContainerSuspendedDMEvent;
28
//    public interface IMultiContainerResumedDMEvent;
29
//    public interface IMultiStartedDMEvent;
30
//    public interface IMultiExitedDMEvent;
31
32
    /**
33
     * Check if at least one of the specified contexts can be resumed
34
     * @param context List of execution contexts that want to be resumed
35
     * @param rm Request monitor returning:
36
     *             true if at least one of the specified contexts can be resumed
37
     *             false if none of the specified contexts can be resumed
38
     */
39
    void canResumeSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm);
40
    
41
    /**
42
     * Check if at all of the specified contexts can be resumed
43
     * @param context List of execution contexts that want to be resumed
44
     * @param rm Request monitor returning:
45
     *             true if all of the specified contexts can be resumed
46
     *             false if any of the specified contexts cannot be resumed
47
     */
48
    void canResumeAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm);
49
50
    /**
51
     * Check if at least one of the specified contexts can be suspended
52
     * @param context List of execution contexts that want to be suspended
53
     * @param rm Request monitor returning:
54
     *             true if at least one of the specified contexts can be suspended
55
     *             false if none of the specified contexts can be suspended
56
     */
57
    void canSuspendSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm);
58
    
59
    /**
60
     * Check if all of the specified contexts can be suspended
61
     * @param context List of execution contexts that want to be suspended
62
     * @param rm Request monitor returning:
63
     *             true if all of the specified contexts can be suspended
64
     *             false if any of the specified contexts cannot be suspended
65
     */
66
    void canSuspendAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm);
67
68
    /**
69
     * Check if any of the specified contexts is suspended.
70
     * @param context List of execution contexts that are to be checked for being suspended
71
     * @param rm Request monitor returning:
72
     *           true if any of the specified contexts is suspended, false otherwise
73
     */
74
    void isSuspendedSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm);
75
76
    /**
77
     * Check if all of the specified contexts are suspended.
78
     * @param context List of execution contexts that are to be checked for being suspended
79
     * @param rm Request monitor returning:
80
     *           true if all of the specified contexts is suspended, false otherwise
81
     */
82
    void isSuspendedAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm);
83
    
84
    /**
85
     * Check if any of the specified contexts can be stepped
86
     * @param context List of execution contexts that want to be stepped
87
     * @param rm Request monitor returning:
88
     *             true if amy of the specified contexts can be stepped
89
     *             false if none of the specified contexts can be stepped
90
     */
91
    void canStepSome(IExecutionDMContext[] contexts, StepType stepType, DataRequestMonitor<Boolean> rm);
92
93
    /**
94
     * Check if all of the specified contexts can be stepped
95
     * @param context List of execution contexts that want to be stepped
96
     * @param rm Request monitor returning:
97
     *             true if all of the specified contexts can be stepped
98
     *             false if any of the specified contexts cannot be stepped
99
     */
100
    void canStepAll(IExecutionDMContext[] contexts, StepType stepType, DataRequestMonitor<Boolean> rm);
101
102
    /**
103
     * Check if any of the specified contexts is currently stepping.
104
     * @param context List of execution contexts that are to be checked for stepping
105
     * @param rm Request monitor returning:
106
     *           true if any of the specified contexts is stepping, false otherwise
107
     */
108
    void isSteppingSome(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm);
109
110
    /**
111
     * Check if all of the specified contexts are currently stepping.
112
     * @param context List of execution contexts that are to be checked for stepping
113
     * @param rm Request monitor returning:
114
     *           true if all of the specified contexts is stepping, false otherwise
115
     */
116
    void isSteppingAll(IExecutionDMContext[] contexts, DataRequestMonitor<Boolean> rm);
117
118
    /**
119
     * Request that all specified context be resumed.  Only contexts that are in a
120
     * state that can be resumed will be, others will be ignored.
121
     * @param context List of execution contexts that are to be resumed
122
     */
123
    void resume(IExecutionDMContext[] contexts, RequestMonitor rm);
124
125
    /**
126
     * Request that all specified context be suspended.  Only contexts that are in a
127
     * state that can be suspended will be, others will be ignored.
128
     * @param context List of execution contexts that are to be suspended
129
     */
130
    void suspend(IExecutionDMContext[] contexts, RequestMonitor rm);
131
132
    /**
133
     * Request that all specified context be stepped.  Only contexts that are in a
134
     * state that can be stepped will be, others will be ignored.
135
     * @param context List of execution contexts that are to be stepped
136
     */
137
    void step(IExecutionDMContext[] contexts, StepType stepType, RequestMonitor rm);
138
}

Return to bug 330974