diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java index 621e830dd67..59918fbd473 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java @@ -6,6 +6,16 @@ package org.eclipse.cdt.debug.core; +import org.eclipse.cdt.debug.core.cdi.model.ICTarget; +import org.eclipse.cdt.debug.internal.core.CDebugTarget; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IProcess; + /** @@ -34,4 +44,62 @@ public class CDebugModel { return CDebugCorePlugin.getUniqueIdentifier(); } + + /** + * Creates and returns a debug target for the given CDI target, with + * the specified name, and associates the debug target with the + * given process for console I/O. The allow terminate flag specifies whether + * the debug target will support termination (ITerminate). + * The allow disconnect flag specifies whether the debug target will + * support disconnection (IDisconnect). The resume + * flag specifies if the target process should be resumed on startup. + * The debug target is added to the given launch. + * + * @param launch the launch the new debug target will be contained in + * @param cdiTarget the CDI target to create a debug target for + * @param name the name to associate with this target, which will be + * returned from IDebugTarget.getName. + * @param process the process to associate with the debug target, + * which will be returned from IDebugTarget.getProcess + * @param allowTerminate whether the target will support termianation + * @param allowDisconnect whether the target will support disconnection + * @param resume whether the target is to be resumed on startup. + * @return a debug target + * + * @since 2.0 + */ + public static IDebugTarget newDebugTarget( final ILaunch launch, + final ICTarget cdiTarget, + final String name, + final IProcess process, + final IDebugConfiguration config, + final boolean allowTerminate, + final boolean allowDisconnect, + final boolean resume ) + { + final IDebugTarget[] target = new IDebugTarget[1]; + IWorkspaceRunnable r = new IWorkspaceRunnable() + { + public void run( IProgressMonitor m ) + { + target[0] = new CDebugTarget( launch, + cdiTarget, + name, + process, + config, + allowTerminate, + allowDisconnect, + resume ); + } + }; + try + { + ResourcesPlugin.getWorkspace().run( r, null ); + } + catch( CoreException e ) + { + CDebugCorePlugin.log( e ); + } + return target[0]; + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java index 0b9745e3189..8724cc02f2e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java @@ -11,6 +11,7 @@ import java.util.Iterator; import java.util.List; import org.eclipse.cdt.debug.core.CDebugModel; +import org.eclipse.cdt.debug.core.IDebugConfiguration; import org.eclipse.cdt.debug.core.IFormattedMemoryBlock; import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval; import org.eclipse.cdt.debug.core.IInstructionStep; @@ -134,7 +135,10 @@ public class CDebugTarget extends CDebugElement public CDebugTarget( ILaunch launch, ICTarget cdiTarget, String name, - IProcess process, + IProcess process, + IDebugConfiguration config, + boolean allowsTerminate, + boolean allowsDisconnect, boolean resume ) { super( null );