diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBRunControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBRunControl.java new file mode 100644 index 00000000000..0ecbe109ec8 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBRunControl.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2010 Wind River Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc-Andre Laperle - Mac OS version, fix for bug 265483 + *******************************************************************************/ + +package org.eclipse.cdt.dsf.gdb.service.macos; + +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.datamodel.DMContexts; +import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.dsf.gdb.service.GDBRunControl; +import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; +import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecInterrupt; +import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +public class MacOSGDBRunControl extends GDBRunControl { + + public MacOSGDBRunControl(DsfSession session) { + super(session); + } + + // We use the MIControl code since -exec-interrupt works with Apple gdb + // but SIGINT does not; it seems it runs in async mode by default + @Override + public void suspend(final IExecutionDMContext context, final RequestMonitor rm){ + assert context != null; + + canSuspend( + context, + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleSuccess() { + if (getData()) { + MIExecInterrupt cmd = null; + if (context instanceof IContainerDMContext) { + cmd = new MIExecInterrupt(context); + } else { + IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); + if (dmc == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Given context: " + context + " is not an execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$ + rm.done(); + return; + } + cmd = new MIExecInterrupt(dmc); + } + getConnection().queueCommand(cmd, new DataRequestMonitor(getExecutor(), rm)); + } else { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE, "Context cannot be suspended.", null)); //$NON-NLS-1$ + rm.done(); + } + } + }); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGdbDebugServicesFactory.java index 348c3d8d42d..bc509469db5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGdbDebugServicesFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGdbDebugServicesFactory.java @@ -7,11 +7,13 @@ * * Contributors: * Marc-Andre Laperle - Added support for Mac OS (separate factory) + * - fix for bug 265483 * Ericsson - Added a field for the specific Mac OS version scheme *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.service.macos; import org.eclipse.cdt.dsf.debug.service.IExpressions; +import org.eclipse.cdt.dsf.debug.service.IRunControl; import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; import org.eclipse.cdt.dsf.service.DsfSession; @@ -33,4 +35,9 @@ public class MacOSGdbDebugServicesFactory extends GdbDebugServicesFactory { protected IExpressions createExpressionService(DsfSession session) { return new MacOSGDBExpressions(session); } + + @Override + protected IRunControl createRunControlService(DsfSession session) { + return new MacOSGDBRunControl(session); + } }