From de52271f86afbd5bd29280e76d327810322f88c3 Mon Sep 17 00:00:00 2001
From: Ken Ryall
Date: Tue, 2 Mar 2010 13:29:06 +0000
Subject: Bug 303968, move support for Run To Line, Move To Line, Resume At
Line, to DSF.
---
dsf/org.eclipse.cdt.dsf.ui/plugin.xml | 14 ++
.../internal/ui/SuspendResumeAdapterFactory.java | 91 ++++++++++
.../ui/actions/DisassemblyMoveToLineAdapter.java | 89 ++++++++++
.../ui/actions/DisassemblyResumeAtLineAdapter.java | 89 ++++++++++
.../ui/actions/DisassemblyRunToLineAdapter.java | 98 ++++++++++
.../dsf/debug/internal/ui/actions/MoveToLine.java | 184 +++++++++++++++++++
.../debug/internal/ui/actions/ResumeAtLine.java | 194 ++++++++++++++++++++
.../actions/RetargettableActionAdapterFactory.java | 47 +++++
.../dsf/debug/internal/ui/actions/RunToLine.java | 197 +++++++++++++++++++++
9 files changed, 1003 insertions(+)
create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/SuspendResumeAdapterFactory.java
create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyMoveToLineAdapter.java
create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyResumeAtLineAdapter.java
create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyRunToLineAdapter.java
create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/MoveToLine.java
create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/ResumeAtLine.java
create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RetargettableActionAdapterFactory.java
create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RunToLine.java
(limited to 'dsf/org.eclipse.cdt.dsf.ui')
diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
index 61ae3db7eec..d03d2d442a1 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
+++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
@@ -680,6 +680,20 @@
pattern="org\.eclipse\.cdt\.dsf\.ui/org\.eclipse\.cdt\.dsf\.debug\.ui\.[A-Za-z]+\.viewmodel\.update\.actions\.refresh">
+
+
+
+
+
+
+
+
+
+
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/SuspendResumeAdapterFactory.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/SuspendResumeAdapterFactory.java
new file mode 100644
index 00000000000..1d686ff403d
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/SuspendResumeAdapterFactory.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 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:
+ * Wind River Systems - initial API and implementation
+ * Ericsson - Updated to support Move-To-Line
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.debug.internal.ui;
+
+import org.eclipse.cdt.dsf.datamodel.DMContexts;
+import org.eclipse.cdt.dsf.debug.internal.ui.actions.MoveToLine;
+import org.eclipse.cdt.dsf.debug.internal.ui.actions.ResumeAtLine;
+import org.eclipse.cdt.dsf.debug.internal.ui.actions.RunToLine;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
+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;
+
+/**
+ * Adapter factory for Run-To-Line, Move-To-Line
+ * and Resume-At-Line
+ *
+ * @since 2.1
+ */
+public class SuspendResumeAdapterFactory implements IAdapterFactory {
+
+ static class GdbSuspendResume implements ISuspendResume, IAdaptable {
+
+ private final RunToLine fRunToLine;
+ private final MoveToLine fMoveToLine;
+ private final ResumeAtLine fResumeAtLine;
+
+ GdbSuspendResume(IExecutionDMContext execCtx) {
+ fRunToLine = new RunToLine(execCtx);
+ fMoveToLine = new MoveToLine(execCtx);
+ fResumeAtLine = new ResumeAtLine(execCtx);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class adapter) {
+ if (adapter.isInstance(fRunToLine)) {
+ return fRunToLine;
+ }
+ if (adapter.isInstance(fMoveToLine)) {
+ return fMoveToLine;
+ }
+ if (adapter.isInstance(fResumeAtLine)) {
+ return fResumeAtLine;
+ }
+ return null;
+ }
+
+ public boolean canResume() { return false; }
+ public boolean canSuspend() { return false; }
+ // This must return true because the platform
+ // RunToLineActionDelegate will only enable the
+ // action if we are suspended
+ public boolean isSuspended() { return true; }
+ public void resume() throws DebugException {}
+ public void suspend() throws DebugException {}
+ }
+
+ @SuppressWarnings("rawtypes")
+ 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, MoveToLine or
+ // ResumeAtLine if we are dealing with a thread, not a container
+ if (execDmc != null && !(execDmc instanceof IContainerDMContext)) {
+ return new GdbSuspendResume(execDmc);
+ }
+ }
+ }
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Class[] getAdapterList() {
+ return new Class[] { ISuspendResume.class };
+ }
+}
\ No newline at end of file
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyMoveToLineAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyMoveToLineAdapter.java
new file mode 100644
index 00000000000..fc8b2965460
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyMoveToLineAdapter.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.dsf.debug.internal.ui.actions;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.model.IMoveToAddress;
+import org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget;
+import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
+import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.ISuspendResume;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Move to line target adapter for the DSF Disassembly view
+ *
+ * @since 2.1
+ */
+public class DisassemblyMoveToLineAdapter implements IMoveToLineTarget {
+
+ public void moveToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
+ if (part instanceof IDisassemblyPart && selection instanceof ITextSelection) {
+ if (!(selection instanceof IDisassemblySelection)) {
+ selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
+ }
+ IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
+ final IAddress address = disassemblySelection.getStartAddress();
+
+ if (address != null && target instanceof IAdaptable) {
+ final IMoveToAddress moveToAddress = (IMoveToAddress)((IAdaptable)target).getAdapter(IMoveToAddress.class);
+ if (moveToAddress != null && moveToAddress.canMoveToAddress(address)) {
+ try {
+ moveToAddress.moveToAddress(address);
+ }
+ catch(DebugException e) {
+ failed(e);
+ }
+ }
+ }
+ }
+ }
+
+ public boolean canMoveToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) {
+ if (target instanceof IAdaptable && part instanceof IDisassemblyPart && selection instanceof ITextSelection) {
+ IMoveToAddress moveToAddress = (IMoveToAddress)((IAdaptable)target).getAdapter(IMoveToAddress.class);
+ if (moveToAddress == null) {
+ return false;
+ }
+
+ if (!(selection instanceof IDisassemblySelection)) {
+ selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
+ }
+ IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
+ final IAddress address = disassemblySelection.getStartAddress();
+ if (address == null) {
+ return false;
+ }
+
+ return moveToAddress.canMoveToAddress(address);
+ }
+
+ return false;
+ }
+
+ protected void failed( Throwable e ) {
+ MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), IDsfStatusConstants.REQUEST_FAILED, "MoveToLine failed", null); //$NON-NLS-1$
+ ms.add( new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), IDsfStatusConstants.REQUEST_FAILED, e.getMessage(), e));
+ DsfUIPlugin.log(ms);
+ }
+}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyResumeAtLineAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyResumeAtLineAdapter.java
new file mode 100644
index 00000000000..112f91225c7
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyResumeAtLineAdapter.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.dsf.debug.internal.ui.actions;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.model.IResumeAtAddress;
+import org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget;
+import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
+import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.ISuspendResume;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Resume at line target adapter for the DSF Disassembly view
+ *
+ * @since 2.1
+ */
+public class DisassemblyResumeAtLineAdapter implements IResumeAtLineTarget {
+
+ public void resumeAtLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
+ if (part instanceof IDisassemblyPart && selection instanceof ITextSelection) {
+ if (!(selection instanceof IDisassemblySelection)) {
+ selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
+ }
+ IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
+ final IAddress address = disassemblySelection.getStartAddress();
+
+ if (address != null && target instanceof IAdaptable) {
+ final IResumeAtAddress resumeAtAddress = (IResumeAtAddress)((IAdaptable)target).getAdapter(IResumeAtAddress.class);
+ if (resumeAtAddress != null && resumeAtAddress.canResumeAtAddress(address)) {
+ try {
+ resumeAtAddress.resumeAtAddress(address);
+ }
+ catch(DebugException e) {
+ failed(e);
+ }
+ }
+ }
+ }
+ }
+
+ public boolean canResumeAtLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) {
+ if (target instanceof IAdaptable && part instanceof IDisassemblyPart && selection instanceof ITextSelection) {
+ IResumeAtAddress resumeAtAddress = (IResumeAtAddress)((IAdaptable)target).getAdapter(IResumeAtAddress.class);
+ if (resumeAtAddress == null) {
+ return false;
+ }
+
+ if (!(selection instanceof IDisassemblySelection)) {
+ selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
+ }
+ IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
+ final IAddress address = disassemblySelection.getStartAddress();
+ if (address == null) {
+ return false;
+ }
+
+ return resumeAtAddress.canResumeAtAddress(address);
+ }
+
+ return false;
+ }
+
+ protected void failed( Throwable e ) {
+ MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), IDsfStatusConstants.REQUEST_FAILED, "Resume At Line failed", null); //$NON-NLS-1$
+ ms.add( new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), IDsfStatusConstants.REQUEST_FAILED, e.getMessage(), e));
+ DsfUIPlugin.log(ms);
+ }
+}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyRunToLineAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyRunToLineAdapter.java
new file mode 100644
index 00000000000..5ebca3316ce
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyRunToLineAdapter.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.dsf.debug.internal.ui.actions;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.model.IRunToAddress;
+import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
+import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.ISuspendResume;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.actions.IRunToLineTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Run to line target adapter for the DSF Disassembly view
+ *
+ * @since 2.1
+ */
+public class DisassemblyRunToLineAdapter implements IRunToLineTarget {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
+ */
+ public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
+ if (part instanceof IDisassemblyPart && selection instanceof ITextSelection) {
+ if (!(selection instanceof IDisassemblySelection)) {
+ selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
+ }
+ IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
+ final IAddress address = disassemblySelection.getStartAddress();
+
+ if (address != null && target instanceof IAdaptable) {
+ final IRunToAddress runToAddress = (IRunToAddress)((IAdaptable)target).getAdapter(IRunToAddress.class);
+ if (runToAddress != null && runToAddress.canRunToAddress(address)) {
+ try {
+ boolean skipBreakpoints = DebugUITools.getPreferenceStore().getBoolean(IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE);
+ runToAddress.runToAddress(address, skipBreakpoints);
+ }
+ catch(DebugException e) {
+ failed(e);
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
+ */
+ public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) {
+ if (target instanceof IAdaptable && part instanceof IDisassemblyPart && selection instanceof ITextSelection) {
+ IRunToAddress runToAddress = (IRunToAddress)((IAdaptable)target).getAdapter(IRunToAddress.class);
+ if (runToAddress == null) {
+ return false;
+ }
+
+ if (!(selection instanceof IDisassemblySelection)) {
+ selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
+ }
+ IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
+ final IAddress address = disassemblySelection.getStartAddress();
+ if (address == null) {
+ return false;
+ }
+
+ return runToAddress.canRunToAddress(address);
+ }
+
+ return false;
+ }
+
+ protected void failed( Throwable e ) {
+ MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), IDsfStatusConstants.REQUEST_FAILED, "RunToLine failed", null ); //$NON-NLS-1$
+ ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), IDsfStatusConstants.REQUEST_FAILED, e.getMessage(), e ) );
+ DsfUIPlugin.log(ms);
+ }
+}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/MoveToLine.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/MoveToLine.java
new file mode 100644
index 00000000000..8228f91abf9
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/MoveToLine.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.dsf.debug.internal.ui.actions;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.debug.core.model.IMoveToAddress;
+import org.eclipse.cdt.debug.core.model.IMoveToLine;
+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.IRunControl2;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
+import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
+import org.eclipse.cdt.dsf.service.DsfServicesTracker;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+
+/**
+ * Implements the CDT's move to line interface.
+ *
+ * @since 2.1
+ */
+public class MoveToLine implements IMoveToLine, IMoveToAddress {
+
+ private final IExecutionDMContext fContext;
+
+ public MoveToLine(IExecutionDMContext context) {
+ fContext = context;
+ }
+
+ public boolean canMoveToLine(final String fileName, final int lineNumber) {
+ 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(DsfUIPlugin.getBundleContext(), fContext.getSessionId());
+
+ IRunControl2 runControl = tracker.getService(IRunControl2.class);
+ if (runControl != null) {
+ runControl.canMoveToLine(fContext, fileName, lineNumber, false, 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 moveToLine(final String fileName, final int lineNumber) throws DebugException {
+ DsfSession session = DsfSession.getSession(fContext.getSessionId());
+ if (session != null && session.isActive()) {
+ Throwable exception = null;
+ try {
+ Query