diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
index 7c086021cc0..9c9576c9076 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
@@ -162,6 +162,11 @@
+
+
+
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbRunToLineAdapterFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbRunToLineAdapterFactory.java
new file mode 100644
index 00000000000..577fe1927fe
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbRunToLineAdapterFactory.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.internal.ui;
+
+import org.eclipse.cdt.dsf.datamodel.DMContexts;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
+import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRunToLine;
+import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.ISuspendResume;
+
+/**
+ * @since 2.0
+ */
+public class GdbRunToLineAdapterFactory implements IAdapterFactory {
+
+ static class GdbSuspendResume implements ISuspendResume, IAdaptable {
+
+ private final GdbRunToLine fRunToLine;
+
+ GdbSuspendResume(IExecutionDMContext execCtx) {
+ fRunToLine = new GdbRunToLine(execCtx);
+ }
+
+ public Object getAdapter(Class adapter) {
+ if (adapter.isInstance(fRunToLine)) {
+ return fRunToLine;
+ }
+ return null;
+ }
+
+ public boolean canResume() { return false; }
+ public boolean canSuspend() { return false; }
+ public boolean isSuspended() { return false; }
+ public void resume() throws DebugException {}
+ public void suspend() throws DebugException {}
+ }
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (ISuspendResume.class.equals(adapterType)) {
+ if (adaptableObject instanceof IDMVMContext) {
+ IExecutionDMContext execDmc = DMContexts.getAncestorOfType(
+ ((IDMVMContext)adaptableObject).getDMContext(),
+ IExecutionDMContext.class);
+ // It only makes sense to RunToLine if we are dealing with a thread, not a container
+ if (execDmc != null && !(execDmc instanceof IContainerDMContext)) {
+ return new GdbSuspendResume(execDmc);
+ }
+ }
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[] { ISuspendResume.class };
+ }
+}
\ No newline at end of file
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRunToLine.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRunToLine.java
new file mode 100644
index 00000000000..047c6a85aaa
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRunToLine.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.eclipse.cdt.debug.core.model.IRunToLine;
+import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
+import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
+import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
+import org.eclipse.cdt.dsf.concurrent.Query;
+import org.eclipse.cdt.dsf.debug.service.IRunControl;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
+import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
+import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
+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.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.ui.actions.IRunToLineTarget;
+
+/**
+ * Implements the CDT's run to line interface. This interface is called by CDT's
+ * {@link IRunToLineTarget} implementation.
+ *
+ * @since 2.0
+ */
+public class GdbRunToLine implements IRunToLine {
+
+ private final IExecutionDMContext fContext;
+
+ public GdbRunToLine(IExecutionDMContext context) {
+ fContext = context;
+ }
+
+ public boolean canRunToLine(IFile file, int lineNumber) {
+ return canRunToLine();
+ }
+
+ public boolean canRunToLine(String fileName, int lineNumber) {
+ return canRunToLine();
+ }
+
+ private boolean canRunToLine() {
+ DsfSession session = DsfSession.getSession(fContext.getSessionId());
+ if (session != null && session.isActive()) {
+ try {
+ Query query = new Query() {
+ @Override
+ protected void execute(DataRequestMonitor rm) {
+ DsfServicesTracker tracker =
+ new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fContext.getSessionId());
+
+ IRunControl runControl = tracker.getService(IRunControl.class);
+ if (runControl != null) {
+ runControl.canResume(fContext, rm);
+ } else {
+ rm.setData(false);
+ rm.done();
+ }
+ tracker.dispose();
+ }
+ };
+ session.getExecutor().execute(query);
+ return query.get();
+ } catch (RejectedExecutionException e) {
+ } catch (InterruptedException e) {
+ } catch (ExecutionException e) {
+ }
+ }
+ return false;
+ }
+
+ public void runToLine(IFile file, int lineNumber, boolean skipBreakpoints) throws DebugException {
+ runToLine(file.getLocation().makeAbsolute().toOSString(), lineNumber, skipBreakpoints);
+ }
+
+ public void runToLine(final String fileName, final int lineNumber, final boolean skipBreakpoints) throws DebugException {
+ DsfSession session = DsfSession.getSession(fContext.getSessionId());
+ if (session != null && session.isActive()) {
+ Throwable exception = null;
+ try {
+ Query