diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java index cca13a77e99..5ee31558fa4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java @@ -20,10 +20,10 @@ import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector; 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.ReflectionSequence; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DataModelInitializedEvent; import org.eclipse.cdt.dsf.datamodel.IDMContext; @@ -42,6 +42,7 @@ import org.eclipse.cdt.dsf.mi.service.IMIProcesses; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfServicesTracker; +import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -50,14 +51,11 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.IStatusHandler; public class FinalLaunchSequence extends ReflectionSequence { - private GdbLaunch fLaunch; - private SessionType fSessionType; - private boolean fAttach; - // The launchConfiguration attributes private Map fAttributes; @@ -67,12 +65,15 @@ public class FinalLaunchSequence extends ReflectionSequence { private CommandFactory fCommandFactory; private DsfServicesTracker fTracker; + private DsfSession fSession; - public FinalLaunchSequence(DsfExecutor executor, GdbLaunch launch, SessionType sessionType, boolean attach, IProgressMonitor pm) { - super(executor, pm, LaunchMessages.getString("FinalLaunchSequence.0"), LaunchMessages.getString("FinalLaunchSequence.1")); //$NON-NLS-1$ //$NON-NLS-2$ - fLaunch = launch; - fSessionType = sessionType; - fAttach = attach; + /** + * @since 4.0 + */ + public FinalLaunchSequence(DsfSession session, Map attributes, RequestMonitorWithProgress rm) { + super(session.getExecutor(), rm, LaunchMessages.getString("FinalLaunchSequence.0"), LaunchMessages.getString("FinalLaunchSequence.1")); //$NON-NLS-1$ //$NON-NLS-2$ + fSession = session; + fAttributes = attributes; } @Override @@ -106,14 +107,13 @@ public class FinalLaunchSequence extends ReflectionSequence { } /** - * Initialize the members of the {@link FinalLaunchSequence} class. - * This step is mandatory for the rest fo the sequence to complete. + * Initialize the members of the FinalLaunchSequence class. + * This step is mandatory for the rest of the sequence to complete. * @since 4.0 */ - @SuppressWarnings("unchecked") @Execute public void stepInitializeFinalLaunchSequence(RequestMonitor requestMonitor) { - fTracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fLaunch.getSession().getId()); + fTracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fSession.getId()); fGDBBackend = fTracker.getService(IGDBBackend.class); if (fGDBBackend == null) { requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot obtain GDBBackend service", null)); //$NON-NLS-1$ @@ -137,14 +137,6 @@ public class FinalLaunchSequence extends ReflectionSequence { return; } - try { - fAttributes = fLaunch.getLaunchConfiguration().getAttributes(); - } catch (CoreException e) { - requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot obtain launch configuration attributes", null)); //$NON-NLS-1$ - requestMonitor.done(); - return; - } - requestMonitor.done(); } @@ -190,7 +182,7 @@ public class FinalLaunchSequence extends ReflectionSequence { */ @Execute public void stepSetBreakpointPending(final RequestMonitor requestMonitor) { - if (fSessionType != SessionType.CORE) { + if (fGDBBackend.getSessionType() != SessionType.CORE) { fCommandControl.queueCommand( fCommandFactory.createMIGDBSetBreakpointPending(fCommandControl.getContext(), true), new DataRequestMonitor(getExecutor(), requestMonitor)); @@ -353,7 +345,8 @@ public class FinalLaunchSequence extends ReflectionSequence { @Execute public void stepSetSourceLookupPath(RequestMonitor requestMonitor) { CSourceLookup sourceLookup = fTracker.getService(CSourceLookup.class); - CSourceLookupDirector locator = (CSourceLookupDirector)fLaunch.getSourceLocator(); + ILaunch launch = (ILaunch)fSession.getModelAdapter(ILaunch.class); + CSourceLookupDirector locator = (CSourceLookupDirector)launch.getSourceLocator(); ISourceLookupDMContext sourceLookupDmc = (ISourceLookupDMContext)fCommandControl.getContext(); sourceLookup.setSourceLookupPath(sourceLookupDmc, locator.getSourceContainers(), requestMonitor); @@ -407,7 +400,7 @@ public class FinalLaunchSequence extends ReflectionSequence { */ @Execute public void stepSpecifyCoreFile(final RequestMonitor requestMonitor) { - if (fSessionType == SessionType.CORE) { + if (fGDBBackend.getSessionType() == SessionType.CORE) { String coreFile = CDebugUtils.getAttribute( fAttributes, ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, ""); //$NON-NLS-1$ @@ -478,7 +471,7 @@ public class FinalLaunchSequence extends ReflectionSequence { */ @Execute public void stepRemoteConnection(final RequestMonitor rm) { - if (fSessionType == SessionType.REMOTE && fAttach) { + if (fGDBBackend.getSessionType() == SessionType.REMOTE && fGDBBackend.getIsAttachSession()) { boolean isTcpConnection = CDebugUtils.getAttribute( fAttributes, IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, @@ -518,7 +511,7 @@ public class FinalLaunchSequence extends ReflectionSequence { */ @Execute public void stepNewProcess(final RequestMonitor rm) { - if (!fAttach) { + if (!fGDBBackend.getIsAttachSession()) { boolean noBinarySpecified = CDebugUtils.getAttribute( fAttributes, @@ -548,7 +541,7 @@ public class FinalLaunchSequence extends ReflectionSequence { */ @Execute public void stepAttachToProcess(final RequestMonitor requestMonitor) { - if (fAttach && fSessionType != SessionType.REMOTE) { + if (fGDBBackend.getIsAttachSession() && fGDBBackend.getSessionType() != SessionType.REMOTE) { // Is the process id already stored in the launch? int pid = CDebugUtils.getAttribute( fAttributes, @@ -559,7 +552,7 @@ public class FinalLaunchSequence extends ReflectionSequence { fProcService.createProcessContext(fCommandControl.getContext(), Integer.toString(pid)), new DataRequestMonitor(getExecutor(), requestMonitor)); } else { - IConnect connectCommand = (IConnect)fLaunch.getSession().getModelAdapter(IConnect.class); + IConnect connectCommand = (IConnect)fSession.getModelAdapter(IConnect.class); if (connectCommand != null) { connectCommand.connect(requestMonitor); } else { @@ -577,7 +570,7 @@ public class FinalLaunchSequence extends ReflectionSequence { */ @Execute public void stepDataModelInitializationComplete(final RequestMonitor requestMonitor) { - fLaunch.getSession().dispatchEvent(new DataModelInitializedEvent(fCommandControl.getContext()), + fSession.dispatchEvent(new DataModelInitializedEvent(fCommandControl.getContext()), fCommandControl.getProperties()); requestMonitor.done(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java index 2faf64e1dca..9b36e8862ae 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java @@ -19,9 +19,9 @@ import java.util.concurrent.ExecutionException; import org.eclipse.cdt.core.model.ICProject; 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.Query; -import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; import org.eclipse.cdt.dsf.concurrent.ThreadSafe; import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory; import org.eclipse.cdt.dsf.debug.sourcelookup.DsfSourceLookupDirector; @@ -29,7 +29,9 @@ import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactoryNS; import org.eclipse.cdt.dsf.gdb.service.SessionType; +import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; import org.eclipse.cdt.dsf.gdb.service.macos.MacOSGdbDebugServicesFactory; +import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.launch.AbstractCLaunchDelegate2; import org.eclipse.core.runtime.CoreException; @@ -181,14 +183,32 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 monitor.worked(1); // Create and invoke the final launch sequence to setup GDB - IProgressMonitor subMon2 = new SubProgressMonitor(monitor, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); - final Sequence finalLaunchSequence = - getFinalLaunchSequence(launch.getSession().getExecutor(), launch, sessionType, attach, subMon2); + final IProgressMonitor subMon2 = new SubProgressMonitor(monitor, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); - launch.getSession().getExecutor().execute(finalLaunchSequence); + Query completeLaunchQuery = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + DsfServicesTracker tracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), launch.getSession().getId()); + IGDBControl control = tracker.getService(IGDBControl.class); + tracker.dispose(); + control.completeInitialization(new RequestMonitorWithProgress(ImmediateExecutor.getInstance(), subMon2) { + @Override + protected void handleCompleted() { + if (isCanceled()) { + rm.cancel(); + } else { + rm.setStatus(getStatus()); + } + rm.done(); + } + }); + } + }; + + launch.getSession().getExecutor().execute(completeLaunchQuery); boolean succeed = false; try { - finalLaunchSequence.get(); + completeLaunchQuery.get(); succeed = true; } catch (InterruptedException e1) { throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, "Interrupted Exception in dispatch thread", e1)); //$NON-NLS-1$ @@ -250,14 +270,6 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 return LaunchUtils.getGDBVersion(config); } - /* - * This method can be overridden by subclasses to allow to change the final launch sequence without - * having to change the entire GdbLaunchDelegate - */ - protected Sequence getFinalLaunchSequence(DsfExecutor executor, GdbLaunch launch, SessionType type, boolean attach, IProgressMonitor pm) { - return new FinalLaunchSequence(executor, launch, type, attach, pm); - } - @Override public boolean preLaunchCheck(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException { // no pre launch check for core file diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java index fa7e85e48b8..b013aae8dd3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java @@ -45,11 +45,14 @@ import org.eclipse.debug.core.ILaunchConfiguration; public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { - private static final String GDB_6_8_VERSION = "6.8"; //$NON-NLS-1$ - // This should eventually be "7.0" once GDB 7.0 is released - private static final String GDB_7_0_VERSION = "6.8.50.20090218"; //$NON-NLS-1$ - private static final String GDB_7_1_VERSION = "7.1"; //$NON-NLS-1$ - private static final String GDB_7_2_VERSION = "7.2"; //$NON-NLS-1$ + /** @since 4.0 */ + public static final String GDB_6_8_VERSION = "6.8"; //$NON-NLS-1$ + /** @since 4.0 */ + public static final String GDB_7_0_VERSION = "7.0"; //$NON-NLS-1$ + /** @since 4.0 */ + public static final String GDB_7_1_VERSION = "7.1"; //$NON-NLS-1$ + /** @since 4.0 */ + public static final String GDB_7_2_VERSION = "7.2"; //$NON-NLS-1$ private final String fVersion; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java index fef80ba32dd..93cfc61f5e7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java @@ -19,6 +19,7 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.concurrent.Future; @@ -28,12 +29,15 @@ import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; +import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; import org.eclipse.cdt.dsf.concurrent.Sequence; import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent; import org.eclipse.cdt.dsf.debug.service.command.ICommandControl; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence; import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; import org.eclipse.cdt.dsf.gdb.service.SessionType; import org.eclipse.cdt.dsf.mi.service.IMIBackend; @@ -51,8 +55,11 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.utils.pty.PTY; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.osgi.framework.BundleContext; @@ -313,6 +320,48 @@ public class GDBControl extends AbstractMIControl implements IGDBControl { countingRm.setDoneCount(count); } + /** + * @since 4.0 + */ + @SuppressWarnings("unchecked") + public void completeInitialization(final RequestMonitor rm) { + // We take the attributes from the launchConfiguration + ILaunch launch = (ILaunch)getSession().getModelAdapter(ILaunch.class); + Map attributes = null; + try { + attributes = launch.getLaunchConfiguration().getAttributes(); + } catch (CoreException e) {} + + // We need a RequestMonitorWithProgress, if we don't have one, we create one. + RequestMonitorWithProgress progressRm; + if (rm instanceof RequestMonitorWithProgress) { + progressRm = (RequestMonitorWithProgress)rm; + } else { + progressRm = new RequestMonitorWithProgress(getExecutor(), new NullProgressMonitor()) { + @Override + protected void handleCompleted() { + rm.setStatus(getStatus()); + rm.done(); + } + }; + } + + ImmediateExecutor.getInstance().execute(getCompleteInitializationSequence(attributes, progressRm)); + } + + /** + * Return the sequence that is to be used to complete the initialization of GDB. + * + * @param rm A RequestMonitorWithProgress that will indicate when the sequence is completed, but that + * also contains an IProgressMonitor to be able to cancel the launch. A NullProgressMonitor + * can be used if cancellation is not required. + * + * @since 4.0 + */ + protected Sequence getCompleteInitializationSequence(Map attributes, RequestMonitorWithProgress rm) { + return new FinalLaunchSequence(getSession(), attributes, rm); + } + @DsfServiceEventHandler public void eventDispatched(ICommandControlShutdownDMEvent e) { // Handle our "GDB Exited" event and stop processing commands. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java index 38b47d66cd4..0733d644a24 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java @@ -19,6 +19,7 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.concurrent.Future; @@ -28,12 +29,15 @@ import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; +import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; import org.eclipse.cdt.dsf.concurrent.Sequence; import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent; import org.eclipse.cdt.dsf.debug.service.command.ICommandControl; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence; import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordSelectedChangedDMEvent; import org.eclipse.cdt.dsf.gdb.service.SessionType; @@ -53,8 +57,11 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIListFeaturesInfo; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.utils.pty.PTY; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.osgi.framework.BundleContext; @@ -321,6 +328,48 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { countingRm.setDoneCount(count); } + /** + * @since 4.0 + */ + @SuppressWarnings("unchecked") + public void completeInitialization(final RequestMonitor rm) { + // We take the attributes from the launchConfiguration + ILaunch launch = (ILaunch)getSession().getModelAdapter(ILaunch.class); + Map attributes = null; + try { + attributes = launch.getLaunchConfiguration().getAttributes(); + } catch (CoreException e) {} + + // We need a RequestMonitorWithProgress, if we don't have one, we create one. + RequestMonitorWithProgress progressRm; + if (rm instanceof RequestMonitorWithProgress) { + progressRm = (RequestMonitorWithProgress)rm; + } else { + progressRm = new RequestMonitorWithProgress(getExecutor(), new NullProgressMonitor()) { + @Override + protected void handleCompleted() { + rm.setStatus(getStatus()); + rm.done(); + } + }; + } + + ImmediateExecutor.getInstance().execute(getCompleteInitializationSequence(attributes, progressRm)); + } + + /** + * Return the sequence that is to be used to complete the initialization of GDB. + * + * @param rm A RequestMonitorWithProgress that will indicate when the sequence is completed, but that + * also contains an IProgressMonitor to be able to cancel the launch. A NullProgressMonitor + * can be used if cancellation is not required. + * + * @since 4.0 + */ + protected Sequence getCompleteInitializationSequence(Map attributes, RequestMonitorWithProgress rm) { + return new FinalLaunchSequence(getSession(), attributes, rm); + } + /**@since 4.0 */ public List getFeatures() { return fFeatures; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java index 1024a7c8c91..4fbbb74bb8f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java @@ -32,6 +32,20 @@ public interface IGDBControl extends IMICommandControl { MIInferiorProcess getInferiorProcess(); + + /** + * This method should be called once and only once, during the launch, + * to complete the initialization. It will perform the final steps + * to configure GDB for the type of debugging session chosen by the + * user. + * + * @param requestMonitor The requestMonitor indicating that the + * final steps if initialization are completed. + * + * @since 4.0 + */ + void completeInitialization(RequestMonitor requestMonitor); + /** * @since 2.0 */ diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF b/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF index 0ee25d3702a..6f1e9c26e6f 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.gdbjtag.core;singleton:=true -Bundle-Version: 7.0.0.qualifier +Bundle-Version: 8.0.0.qualifier Bundle-Activator: org.eclipse.cdt.debug.gdbjtag.core.Activator Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java index 7c669a16460..78127a5359f 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java @@ -36,6 +36,7 @@ import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DsfExecutor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; import org.eclipse.cdt.dsf.concurrent.Sequence; import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DataModelInitializedEvent; @@ -58,7 +59,6 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.VariablesPlugin; @@ -745,8 +745,11 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { DsfServicesTracker fTracker; - public GDBJtagDSFFinalLaunchSequence(DsfExecutor executor, GdbLaunch launch, SessionType sessionType, boolean attach, IProgressMonitor pm) { - super(executor, pm, LaunchMessages.getString("FinalLaunchSequence.0"), LaunchMessages.getString("FinalLaunchSequence.1")); //$NON-NLS-1$ //$NON-NLS-2$ + /** + * @since 8.0 + */ + public GDBJtagDSFFinalLaunchSequence(DsfExecutor executor, GdbLaunch launch, SessionType sessionType, boolean attach, RequestMonitorWithProgress rm) { + super(executor, rm, LaunchMessages.getString("FinalLaunchSequence.0"), LaunchMessages.getString("FinalLaunchSequence.1")); //$NON-NLS-1$ //$NON-NLS-2$ fLaunch = launch; fSessionType = sessionType; fAttach = attach; diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java index 81f5c36e132..0b2733fc21e 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial implementation + * Ericsson - Updated for changes in base DSF-GDB launching (Bug 338769) *******************************************************************************/ package org.eclipse.cdt.debug.gdbjtag.core; @@ -15,13 +16,12 @@ package org.eclipse.cdt.debug.gdbjtag.core; * */ -import org.eclipse.cdt.dsf.concurrent.DsfExecutor; -import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.GdbJtagDebugServicesFactory; +import org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.macos.MacOSGdbJtagDebugServicesFactory; import org.eclipse.cdt.dsf.concurrent.ThreadSafe; -import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate; -import org.eclipse.cdt.dsf.gdb.service.SessionType; -import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; /** * The launch configuration delegate for the Jtag hardware debugging using @@ -31,21 +31,23 @@ import org.eclipse.core.runtime.IProgressMonitor; * launch configuration types. *

* It extends the standard DSF/GDB launch delegate GdbLaunchDelegate - * but overrides the getFinalLaunchSequence method to return the Jtag - * hardware debugging specific launch sequence. + * but overrides the newServiceFactory method to return the Jtag + * hardware debugging factory. * @since 7.0 */ @ThreadSafe public class GDBJtagDSFLaunchConfigurationDelegate extends GdbLaunchDelegate { + + protected IDsfDebugServicesFactory newServiceFactory(String version) { + if (version.contains(LaunchUtils.MACOS_GDB_MARKER)) { + // The version string at this point should look like + // 6.3.50-20050815APPLE1346, we extract the gdb version and apple version + String versions [] = version.split(LaunchUtils.MACOS_GDB_MARKER); + if (versions.length == 2) { + return new MacOSGdbJtagDebugServicesFactory(versions[0], versions[1]); + } + } - /* (non-Javadoc) - * @see org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate#getFinalLaunchSequence(org.eclipse.cdt.dsf.concurrent.DsfExecutor, org.eclipse.cdt.dsf.gdb.launching.GdbLaunch, org.eclipse.cdt.dsf.gdb.service.SessionType, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - protected Sequence getFinalLaunchSequence(DsfExecutor executor, - GdbLaunch launch, SessionType type, boolean attach, - IProgressMonitor pm) { - return new GDBJtagDSFFinalLaunchSequence(executor, launch, type, attach, pm); + return new GdbJtagDebugServicesFactory(version); } - } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl.java new file mode 100644 index 00000000000..36b4cc0fea6 --- /dev/null +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Ericsson - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service; + +import java.util.Map; + +import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagDSFFinalLaunchSequence; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; +import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; + + +/** + * Jtag control service which selects the Jtag CompleteInitializationSequence. + * Use for GDB < 7.0 + */ +public class GDBJtagControl extends GDBControl { + + public GDBJtagControl(DsfSession session, ILaunchConfiguration config, CommandFactory factory) { + super(session, config, factory); + } + + protected Sequence getCompleteInitializationSequence(Map attributes, RequestMonitorWithProgress rm) { + GdbLaunch launch = (GdbLaunch)getSession().getModelAdapter(ILaunch.class); + IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class); + return new GDBJtagDSFFinalLaunchSequence(getExecutor(), launch, backend.getSessionType(), backend.getIsAttachSession(), rm); + } +} \ No newline at end of file diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_0.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_0.java new file mode 100644 index 00000000000..de79e4a35c0 --- /dev/null +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_0.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Ericsson - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service; + +import java.util.Map; + +import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagDSFFinalLaunchSequence; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; +import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_0; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; + + +/** + * Jtag control service which selects the Jtag CompleteInitializationSequence. + * Use for GDB >= 7.0 + */ +public class GDBJtagControl_7_0 extends GDBControl_7_0 { + + public GDBJtagControl_7_0(DsfSession session, ILaunchConfiguration config, CommandFactory factory) { + super(session, config, factory); + } + + protected Sequence getCompleteInitializationSequence(Map attributes, RequestMonitorWithProgress rm) { + GdbLaunch launch = (GdbLaunch)getSession().getModelAdapter(ILaunch.class); + IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class); + return new GDBJtagDSFFinalLaunchSequence(getExecutor(), launch, backend.getSessionType(), backend.getIsAttachSession(), rm); + } +} \ No newline at end of file diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_2.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_2.java new file mode 100644 index 00000000000..64aef84436c --- /dev/null +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_2.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Ericsson - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service; + +import java.util.Map; + +import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagDSFFinalLaunchSequence; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; +import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_2; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; + + +/** + * Jtag control service which selects the Jtag CompleteInitializationSequence. + * Use for GDB >= 7.2 + */ +public class GDBJtagControl_7_2 extends GDBControl_7_2 { + + public GDBJtagControl_7_2(DsfSession session, ILaunchConfiguration config, CommandFactory factory) { + super(session, config, factory); + } + + protected Sequence getCompleteInitializationSequence(Map attributes, RequestMonitorWithProgress rm) { + GdbLaunch launch = (GdbLaunch)getSession().getModelAdapter(ILaunch.class); + IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class); + return new GDBJtagDSFFinalLaunchSequence(getExecutor(), launch, backend.getSessionType(), backend.getIsAttachSession(), rm); + } +} \ No newline at end of file diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java new file mode 100644 index 00000000000..47f71444311 --- /dev/null +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Ericsson - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service; + +import org.eclipse.cdt.dsf.debug.service.command.ICommandControl; +import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; +import org.eclipse.cdt.dsf.gdb.service.command.CommandFactory_6_8; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.debug.core.ILaunchConfiguration; + +/** + * @since 8.0 + */ +public class GdbJtagDebugServicesFactory extends GdbDebugServicesFactory { + + + public GdbJtagDebugServicesFactory(String version) { + super(version); + } + + protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) { + if (GDB_7_2_VERSION.compareTo(getVersion()) <= 0) { + return new GDBJtagControl_7_2(session, config, new CommandFactory_6_8()); + } + if (GDB_7_0_VERSION.compareTo(getVersion()) <= 0) { + return new GDBJtagControl_7_0(session, config, new CommandFactory_6_8()); + } + if (GDB_6_8_VERSION.compareTo(getVersion()) <= 0) { + return new GDBJtagControl(session, config, new CommandFactory_6_8()); + } + return new GDBJtagControl(session, config, new CommandFactory()); + } +} diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/macos/MacOSGdbJtagDebugServicesFactory.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/macos/MacOSGdbJtagDebugServicesFactory.java new file mode 100644 index 00000000000..484721546e5 --- /dev/null +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/macos/MacOSGdbJtagDebugServicesFactory.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Ericsson - Initial implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.macos; + +import org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.GDBJtagControl; +import org.eclipse.cdt.dsf.debug.service.command.ICommandControl; +import org.eclipse.cdt.dsf.gdb.service.macos.MacOSCommandFactory; +import org.eclipse.cdt.dsf.gdb.service.macos.MacOSGdbDebugServicesFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.debug.core.ILaunchConfiguration; + +/** @since 8.0 */ +public class MacOSGdbJtagDebugServicesFactory extends MacOSGdbDebugServicesFactory { + + public MacOSGdbJtagDebugServicesFactory(String gdbVersion, String appleVersion) { + super(gdbVersion, appleVersion); + } + + @Override + protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) { + return new GDBJtagControl(session, config, new MacOSCommandFactory()); + } +}