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 0d1e1edf137..226008465d9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml @@ -160,18 +160,6 @@ - - - - - - - - diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbMoveToLine.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbMoveToLine.java deleted file mode 100644 index c34703f5cc7..00000000000 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbMoveToLine.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * 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.gdb.internal.ui.actions; - -import java.util.HashMap; -import java.util.Map; -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.Query; -import org.eclipse.cdt.dsf.datamodel.DMContexts; -import org.eclipse.cdt.dsf.debug.service.IBreakpoints; -import org.eclipse.cdt.dsf.debug.service.IRunControl; -import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext; -import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; -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.IMIExecutionDMContext; -import org.eclipse.cdt.dsf.mi.service.IMIRunControl; -import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; -import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; -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 GdbMoveToLine implements IMoveToLine, IMoveToAddress { - - private final IExecutionDMContext fContext; - - public GdbMoveToLine(IExecutionDMContext context) { - fContext = context; - } - - public boolean canMoveToLine(String fileName, int lineNumber) { - return canMoveToLocation(); - } - - public void moveToLine(String fileName, int lineNumber) throws DebugException { - IMIExecutionDMContext threadExecDmc = DMContexts.getAncestorOfType(fContext, IMIExecutionDMContext.class); - if (threadExecDmc == null) { - throw new DebugException(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Invalid thread context", null)); //$NON-NLS-1$ - } - - // Create the breakpoint attributes - Map attr = new HashMap(); - attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); - attr.put(MIBreakpoints.FILE_NAME, fileName); - attr.put(MIBreakpoints.LINE_NUMBER, lineNumber); - attr.put(MIBreakpointDMData.IS_TEMPORARY, true); - attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); - - // Now do the operation - moveToLocation(fileName + ":" + lineNumber, attr); //$NON-NLS-1$ - } - - public boolean canMoveToAddress(IAddress address) { - return canMoveToLocation(); - } - - public void moveToAddress(IAddress address) throws DebugException { - IMIExecutionDMContext threadExecDmc = DMContexts.getAncestorOfType(fContext, IMIExecutionDMContext.class); - if (threadExecDmc == null) { - throw new DebugException(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Invalid thread context", null)); //$NON-NLS-1$ - } - - // Create the breakpoint attributes - Map attr = new HashMap(); - attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); - attr.put(MIBreakpoints.ADDRESS, "0x" + address.toString(16)); //$NON-NLS-1$ - attr.put(MIBreakpointDMData.IS_TEMPORARY, true); - attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); - - // Now do the operation - moveToLocation("*0x" + address.toString(16), attr); //$NON-NLS-1$ - } - - private boolean canMoveToLocation() { - 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); - tracker.dispose(); - if (runControl != null) { - runControl.canResume(fContext, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; - session.getExecutor().execute(query); - return query.get(); - } catch (RejectedExecutionException e) { - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } - } - return false; - } - - - private void moveToLocation(final String location, final Map bpAttributes) throws DebugException { - final DsfSession session = DsfSession.getSession(fContext.getSessionId()); - if (session != null && session.isActive()) { - Throwable exception = null; - try { - Query query = new Query() { - @Override - protected void execute(final DataRequestMonitor rm) { - // first create a temporary breakpoint to stop the execution at - // the location we are about to jump to - final DsfServicesTracker tracker = - new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fContext.getSessionId()); - IBreakpoints bpService = tracker.getService(IBreakpoints.class); - IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fContext, IBreakpointsTargetDMContext.class); - if (bpService != null && bpDmc != null) { - bpService.insertBreakpoint( - bpDmc, bpAttributes, - new DataRequestMonitor(session.getExecutor(), rm) { - @Override - protected void handleSuccess() { - // Now resume at the proper location - IMIRunControl miRunControl = tracker.getService(IMIRunControl.class); - tracker.dispose(); - if (miRunControl != null) { - miRunControl.resumeAtLocation(fContext, location, rm); - } else { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "MIRunControl service not available", null)); //$NON-NLS-1$ - rm.done(); - } - }; - @Override - protected void handleFailure() { - tracker.dispose(); - super.handleFailure(); - }; - }); - } else { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Unable to set breakpoint", null)); //$NON-NLS-1$ - rm.done(); - tracker.dispose(); - } - } - }; - session.getExecutor().execute(query); - query.get(); - } catch (RejectedExecutionException e) { - exception = e; - } catch (InterruptedException e) { - exception = e; - } catch (ExecutionException e) { - exception = e; - } - if (exception != null) { - throw new DebugException(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$ - } - } else { - throw new DebugException(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ - } - } -} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbResumeAtLine.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbResumeAtLine.java deleted file mode 100644 index 564d0b76174..00000000000 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbResumeAtLine.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * 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.gdb.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.IResumeAtAddress; -import org.eclipse.cdt.debug.core.model.IResumeAtLine; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; -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.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; - -/** - * Implements the CDT's resume at line interface. - * - * @since 2.1 - */ -public class GdbResumeAtLine implements IResumeAtLine, IResumeAtAddress { - - private final IExecutionDMContext fContext; - - public GdbResumeAtLine(IExecutionDMContext context) { - fContext = context; - } - - public boolean canResumeAtLine(IFile file, int lineNumber) { - return canResumeAtLocation(); - } - - public boolean canResumeAtLine(String fileName, int lineNumber) { - return canResumeAtLocation(); - } - - public void resumeAtLine(IFile file, int lineNumber) throws DebugException { - resumeAtLine(file.getLocation().makeAbsolute().toOSString(), lineNumber); - } - - public void resumeAtLine(String fileName, int lineNumber) throws DebugException { - resumeAtLocation(fileName + ":" + lineNumber); //$NON-NLS-1$ - } - - public boolean canResumeAtAddress(IAddress address) { - return canResumeAtLocation(); - } - - public void resumeAtAddress(IAddress address) throws DebugException { - resumeAtLocation("*0x" + address.toString(16)); //$NON-NLS-1$ - } - - private boolean canResumeAtLocation() { - 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); - tracker.dispose(); - if (runControl != null) { - runControl.canResume(fContext, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; - session.getExecutor().execute(query); - return query.get(); - } catch (RejectedExecutionException e) { - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } - } - return false; - } - - - private void resumeAtLocation(final String location) throws DebugException { - final DsfSession session = DsfSession.getSession(fContext.getSessionId()); - if (session != null && session.isActive()) { - Throwable exception = null; - try { - Query query = new Query() { - @Override - protected void execute(final DataRequestMonitor rm) { - final DsfServicesTracker tracker = - new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fContext.getSessionId()); - - IMIRunControl miRunControl = tracker.getService(IMIRunControl.class); - tracker.dispose(); - if (miRunControl != null) { - miRunControl.resumeAtLocation(fContext, location, rm); - } else { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "MIRunControl service not available", null)); //$NON-NLS-1$ - rm.done(); - } - } - }; - session.getExecutor().execute(query); - query.get(); - } catch (RejectedExecutionException e) { - exception = e; - } catch (InterruptedException e) { - exception = e; - } catch (ExecutionException e) { - exception = e; - } - if (exception != null) { - throw new DebugException(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing resume at line", exception)); //$NON-NLS-1$ - } - } else { - throw new DebugException(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ - } - } - - -} 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 deleted file mode 100644 index bac32feb781..00000000000 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRunToLine.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * 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 - Added support for IRunToAddress for DSF DisassemblyView (302324) - *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.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.IRunToAddress; -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, IRunToAddress { - - private final IExecutionDMContext fContext; - - public GdbRunToLine(IExecutionDMContext context) { - fContext = context; - } - - public boolean canRunToLine(IFile file, int lineNumber) { - return canRunToLocation(); - } - - public boolean canRunToLine(String fileName, int lineNumber) { - return canRunToLocation(); - } - - public void runToLine(IFile file, int lineNumber, boolean skipBreakpoints) throws DebugException { - runToLine(file.getLocation().makeAbsolute().toOSString(), lineNumber, skipBreakpoints); - } - - public void runToLine(String fileName, int lineNumber, boolean skipBreakpoints) throws DebugException { - runToLocation(fileName + ":" + lineNumber, skipBreakpoints); //$NON-NLS-1$ - } - - /** @since 2.1 */ - public boolean canRunToAddress(IAddress address) { - return canRunToLocation(); - } - - /** @since 2.1 */ - public void runToAddress(IAddress address, boolean skipBreakpoints) throws DebugException { - runToLocation("*0x" + address.toString(16), skipBreakpoints); //$NON-NLS-1$ - } - - private boolean canRunToLocation() { - 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; - } - - private void runToLocation(final String location, final boolean skipBreakpoints) throws DebugException { - DsfSession session = DsfSession.getSession(fContext.getSessionId()); - if (session != null && session.isActive()) { - Throwable exception = null; - try { - Query query = new Query() { - @Override - protected void execute(final DataRequestMonitor rm) { - DsfServicesTracker tracker = - new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fContext.getSessionId()); - - IMIRunControl miRunControl = tracker.getService(IMIRunControl.class); - if (miRunControl != null) { - miRunControl.runToLocation( - fContext, location, skipBreakpoints, - new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); - } else { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "MIRunControl service not available", null)); //$NON-NLS-1$ - rm.done(); - } - tracker.dispose(); - } - }; - session.getExecutor().execute(query); - query.get(); - } catch (RejectedExecutionException e) { - exception = e; - } catch (InterruptedException e) { - exception = e; - } catch (ExecutionException e) { - exception = e; - } - if (exception != null) { - throw new DebugException(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing run to line", exception)); //$NON-NLS-1$ - } - } else { - throw new DebugException(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ - } - } -} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl.java index 02221edb063..8112796b74f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl; +import org.eclipse.cdt.dsf.debug.service.IRunControl2; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext; @@ -102,8 +103,9 @@ public class GDBRunControl extends MIRunControl { fProcService = getServicesTracker().getService(IMIProcesses.class); register(new String[]{IRunControl.class.getName(), - IMIRunControl.class.getName(), - MIRunControl.class.getName(), + IRunControl2.class.getName(), + IMIRunControl.class.getName(), + MIRunControl.class.getName(), GDBRunControl.class.getName()}, new Hashtable()); requestMonitor.done(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java index 045b4baedd3..3d5d949b49c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java @@ -17,7 +17,9 @@ import java.util.Hashtable; import java.util.Map; import java.util.Vector; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.Immutable; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.Sequence; @@ -26,9 +28,11 @@ import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent; import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.datamodel.IDMEvent; +import org.eclipse.cdt.dsf.debug.service.IBreakpoints; import org.eclipse.cdt.dsf.debug.service.ICachingService; import org.eclipse.cdt.dsf.debug.service.IProcesses; import org.eclipse.cdt.dsf.debug.service.IRunControl; +import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext; @@ -40,6 +44,8 @@ import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIProcesses; import org.eclipse.cdt.dsf.mi.service.IMIRunControl; +import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; +import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; import org.eclipse.cdt.dsf.mi.service.MIRunControl; import org.eclipse.cdt.dsf.mi.service.MIStack; import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakDelete; @@ -73,6 +79,7 @@ import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; 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; import org.osgi.framework.BundleContext; /** @@ -1138,4 +1145,155 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo public void flushCache(IDMContext context) { } + private void moveToLocation(final IExecutionDMContext context, + final String location, final Map bpAttributes, + final RequestMonitor rm) { + + // first create a temporary breakpoint to stop the execution at + // the location we are about to jump to + IBreakpoints bpService = getServicesTracker().getService(IBreakpoints.class); + IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class); + if (bpService != null && bpDmc != null) { + bpService.insertBreakpoint(bpDmc, bpAttributes, + new DataRequestMonitor(getExecutor(),rm) { + @Override + protected void handleSuccess() { + // Now resume at the proper location + resumeAtLocation(context, location, rm); + } + }); + } else { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, + IDsfStatusConstants.NOT_SUPPORTED, + "Unable to set breakpoint", null)); //$NON-NLS-1$ + rm.done(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#canRunToLine(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, java.lang.String, int, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + */ + /** + * @since 3.0 + */ + public void canRunToLine(IExecutionDMContext context, String sourceFile, + int lineNumber, DataRequestMonitor rm) { + canResume(context, rm); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#runToLine(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, java.lang.String, int, boolean, org.eclipse.cdt.dsf.concurrent.RequestMonitor) + */ + /** + * @since 3.0 + */ + public void runToLine(IExecutionDMContext context, String sourceFile, + int lineNumber, boolean skipBreakpoints, RequestMonitor rm) { + runToLocation(context, sourceFile + ":" + Integer.toString(lineNumber), skipBreakpoints, rm); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#canRunToAddress(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.core.IAddress, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + */ + /** + * @since 3.0 + */ + public void canRunToAddress(IExecutionDMContext context, IAddress address, + DataRequestMonitor rm) { + canResume(context, rm); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#runToAddress(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.core.IAddress, boolean, org.eclipse.cdt.dsf.concurrent.RequestMonitor) + */ + /** + * @since 3.0 + */ + public void runToAddress(IExecutionDMContext context, IAddress address, + boolean skipBreakpoints, RequestMonitor rm) { + runToLocation(context, "*0x" + address.toHexAddressString(), skipBreakpoints, rm); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#canMoveToLine(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, java.lang.String, int, boolean, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + */ + /** + * @since 3.0 + */ + public void canMoveToLine(IExecutionDMContext context, String sourceFile, + int lineNumber, boolean resume, DataRequestMonitor rm) { + canResume(context, rm); } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#moveToLine(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, java.lang.String, int, boolean, org.eclipse.cdt.dsf.concurrent.RequestMonitor) + */ + /** + * @since 3.0 + */ + public void moveToLine(IExecutionDMContext context, String sourceFile, + int lineNumber, boolean resume, RequestMonitor rm) { + IMIExecutionDMContext threadExecDmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); + if (threadExecDmc == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Invalid thread context", null)); //$NON-NLS-1$ + rm.done(); + } + else + { + // Create the breakpoint attributes + Map attr = new HashMap(); + attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); + attr.put(MIBreakpoints.FILE_NAME, sourceFile); + attr.put(MIBreakpoints.LINE_NUMBER, lineNumber); + attr.put(MIBreakpointDMData.IS_TEMPORARY, true); + attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); + + // Now do the operation + String location = sourceFile + ":" + lineNumber; //$NON-NLS-1$ + if (resume) + resumeAtLocation(context, location, rm); + else + moveToLocation(context, location, attr, rm); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#canMoveToAddress(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.core.IAddress, boolean, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + */ + /** + * @since 3.0 + */ + public void canMoveToAddress(IExecutionDMContext context, IAddress address, + boolean resume, DataRequestMonitor rm) { + canResume(context, rm); + } + + /** (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#moveToAddress(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.core.IAddress, boolean, org.eclipse.cdt.dsf.concurrent.RequestMonitor) + * @since 3.0 + */ + public void moveToAddress(IExecutionDMContext context, IAddress address, + boolean resume, RequestMonitor rm) { + IMIExecutionDMContext threadExecDmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); + if (threadExecDmc == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Invalid thread context", null)); //$NON-NLS-1$ + rm.done(); + } + else + { + // Create the breakpoint attributes + Map attr = new HashMap(); + attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); + attr.put(MIBreakpoints.ADDRESS, "0x" + address.toString(16)); //$NON-NLS-1$ + attr.put(MIBreakpointDMData.IS_TEMPORARY, true); + attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); + + // Now do the operation + String location = "*0x" + address.toString(16); //$NON-NLS-1$ + if (resume) + resumeAtLocation(context, location, rm); + else + moveToLocation(context, location, attr, rm); + } + } + } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IMIRunControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IMIRunControl.java index 0e550ee603f..e907dcb7e37 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IMIRunControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IMIRunControl.java @@ -13,7 +13,7 @@ package org.eclipse.cdt.dsf.mi.service; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.Sequence; import org.eclipse.cdt.dsf.datamodel.IDMContext; -import org.eclipse.cdt.dsf.debug.service.IRunControl; +import org.eclipse.cdt.dsf.debug.service.IRunControl2; /** * This interface provides methods for RunControl that are not @@ -21,27 +21,8 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl; * * @since 2.0 */ -public interface IMIRunControl extends IRunControl +public interface IMIRunControl extends IRunControl2 { - /** - * Request to run the program up to the specified location. - * If skipBreakpoints is false, any other breakpoint will stop this - * command; while if skipBreakpoints is true, the operation will ignore - * other breakpoints and continue until the specified location. - * - * @since 3.0 - */ - void runToLocation(IExecutionDMContext context, String location, boolean skipBreakpoints, RequestMonitor rm); - - /** - * Request to resume the program starting at the specified location. - * The specified location can be anywhere in the program, but proper - * program behavior is not guaranteed after this operation. - * - * @since 3.0 - */ - void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm); - /** * Request that the specified steps be executed by first ensuring the target is available * to receive commands. Once the specified steps are executed, the target should be diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java index 44e8bac3daa..f96f2f0df97 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java @@ -11,9 +11,13 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service; +import java.util.HashMap; +import java.util.Map; import java.util.Vector; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.Immutable; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.Sequence; @@ -23,8 +27,11 @@ import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent; import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.datamodel.IDMEvent; +import org.eclipse.cdt.dsf.debug.service.IBreakpoints; import org.eclipse.cdt.dsf.debug.service.ICachingService; import org.eclipse.cdt.dsf.debug.service.IProcesses; +import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext; +import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; import org.eclipse.cdt.dsf.debug.service.command.BufferedCommandControl; import org.eclipse.cdt.dsf.debug.service.command.CommandCache; @@ -63,6 +70,7 @@ import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; 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; import org.osgi.framework.BundleContext; @@ -80,6 +88,7 @@ import org.osgi.framework.BundleContext; * The purpose of this pattern is to allow clients that listen to service * events and track service state, to be perfectly in sync with the service * state. + * @since 3.0 */ public class MIRunControl extends AbstractDsfService implements IMIRunControl, ICachingService { @@ -910,4 +919,159 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I public void flushCache(IDMContext context) { fMICommandCache.reset(context); } + + private void moveToLocation(final IExecutionDMContext context, + final String location, final Map bpAttributes, + final RequestMonitor rm) { + + // first create a temporary breakpoint to stop the execution at + // the location we are about to jump to + IBreakpoints bpService = getServicesTracker().getService(IBreakpoints.class); + IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class); + if (bpService != null && bpDmc != null) { + bpService.insertBreakpoint(bpDmc, bpAttributes, + new DataRequestMonitor(getExecutor(),rm) { + @Override + protected void handleSuccess() { + // Now resume at the proper location + resumeAtLocation(context, location, rm); + } + }); + } else { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, + IDsfStatusConstants.NOT_SUPPORTED, + "Unable to set breakpoint", null)); //$NON-NLS-1$ + rm.done(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#canRunToLine(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, java.lang.String, int, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + */ + /** + * @since 3.0 + */ + public void canRunToLine(IExecutionDMContext context, String sourceFile, + int lineNumber, DataRequestMonitor rm) { + canResume(context, rm); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#runToLine(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, java.lang.String, int, boolean, org.eclipse.cdt.dsf.concurrent.RequestMonitor) + */ + /** + * @since 3.0 + */ + public void runToLine(IExecutionDMContext context, String sourceFile, + int lineNumber, boolean skipBreakpoints, RequestMonitor rm) { + runToLocation(context, sourceFile + ":" + Integer.toString(lineNumber), skipBreakpoints, rm); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#canRunToAddress(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.core.IAddress, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + */ + /** + * @since 3.0 + */ + public void canRunToAddress(IExecutionDMContext context, IAddress address, + DataRequestMonitor rm) { + canResume(context, rm); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#runToAddress(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.core.IAddress, boolean, org.eclipse.cdt.dsf.concurrent.RequestMonitor) + */ + /** + * @since 3.0 + */ + public void runToAddress(IExecutionDMContext context, IAddress address, + boolean skipBreakpoints, RequestMonitor rm) { + runToLocation(context, "*0x" + address.toHexAddressString(), skipBreakpoints, rm); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#canMoveToLine(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, java.lang.String, int, boolean, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + */ + /** + * @since 3.0 + */ + public void canMoveToLine(IExecutionDMContext context, String sourceFile, + int lineNumber, boolean resume, DataRequestMonitor rm) { + canResume(context, rm); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#moveToLine(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, java.lang.String, int, boolean, org.eclipse.cdt.dsf.concurrent.RequestMonitor) + */ + /** + * @since 3.0 + */ + public void moveToLine(IExecutionDMContext context, String sourceFile, + int lineNumber, boolean resume, RequestMonitor rm) { + IMIExecutionDMContext threadExecDmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); + if (threadExecDmc == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Invalid thread context", null)); //$NON-NLS-1$ + rm.done(); + } + else + { + // Create the breakpoint attributes + Map attr = new HashMap(); + attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); + attr.put(MIBreakpoints.FILE_NAME, sourceFile); + attr.put(MIBreakpoints.LINE_NUMBER, lineNumber); + attr.put(MIBreakpointDMData.IS_TEMPORARY, true); + attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); + + // Now do the operation + String location = sourceFile + ":" + lineNumber; //$NON-NLS-1$ + if (resume) + resumeAtLocation(context, location, rm); + else + moveToLocation(context, location, attr, rm); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#canMoveToAddress(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.core.IAddress, boolean, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + */ + /** + * @since 3.0 + */ + public void canMoveToAddress(IExecutionDMContext context, IAddress address, + boolean resume, DataRequestMonitor rm) { + canResume(context, rm); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.debug.service.IRunControl2#moveToAddress(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.core.IAddress, boolean, org.eclipse.cdt.dsf.concurrent.RequestMonitor) + */ + /** + * @since 3.0 + */ + public void moveToAddress(IExecutionDMContext context, IAddress address, + boolean resume, RequestMonitor rm) { + IMIExecutionDMContext threadExecDmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); + if (threadExecDmc == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Invalid thread context", null)); //$NON-NLS-1$ + rm.done(); + } + else + { + // Create the breakpoint attributes + Map attr = new HashMap(); + attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT); + attr.put(MIBreakpoints.ADDRESS, "0x" + address.toString(16)); //$NON-NLS-1$ + attr.put(MIBreakpointDMData.IS_TEMPORARY, true); + attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId())); + + // Now do the operation + String location = "*0x" + address.toString(16); //$NON-NLS-1$ + if (resume) + resumeAtLocation(context, location, rm); + else + moveToLocation(context, location, attr, rm); + } + } + } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java index 6550cac6f1f..88e8bd5b795 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java @@ -585,7 +585,7 @@ public class MIRunControlTest extends BaseTestCase { fRunCtrl.getExecutor().submit(new Runnable() { public void run() { - fRunCtrl.runToLocation(fThreadExecDmc, SOURCE_NAME + ":27", true, + fRunCtrl.runToLine(fThreadExecDmc, SOURCE_NAME, 27, true, new RequestMonitor(fRunCtrl.getExecutor(), null) { @Override protected void handleCompleted() { 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-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendResumeAdapterFactory.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/SuspendResumeAdapterFactory.java similarity index 83% rename from dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendResumeAdapterFactory.java rename to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/SuspendResumeAdapterFactory.java index 8e3b29808f1..1d686ff403d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendResumeAdapterFactory.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/SuspendResumeAdapterFactory.java @@ -9,14 +9,14 @@ * Wind River Systems - initial API and implementation * Ericsson - Updated to support Move-To-Line *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.internal.ui; +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.gdb.internal.ui.actions.GdbMoveToLine; -import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbResumeAtLine; -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; @@ -29,18 +29,18 @@ import org.eclipse.debug.core.model.ISuspendResume; * * @since 2.1 */ -public class GdbSuspendResumeAdapterFactory implements IAdapterFactory { +public class SuspendResumeAdapterFactory implements IAdapterFactory { static class GdbSuspendResume implements ISuspendResume, IAdaptable { - private final GdbRunToLine fRunToLine; - private final GdbMoveToLine fMoveToLine; - private final GdbResumeAtLine fResumeAtLine; + private final RunToLine fRunToLine; + private final MoveToLine fMoveToLine; + private final ResumeAtLine fResumeAtLine; GdbSuspendResume(IExecutionDMContext execCtx) { - fRunToLine = new GdbRunToLine(execCtx); - fMoveToLine = new GdbMoveToLine(execCtx); - fResumeAtLine = new GdbResumeAtLine(execCtx); + fRunToLine = new RunToLine(execCtx); + fMoveToLine = new MoveToLine(execCtx); + fResumeAtLine = new ResumeAtLine(execCtx); } @SuppressWarnings("rawtypes") diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyMoveToLineAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyMoveToLineAdapter.java similarity index 96% rename from dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyMoveToLineAdapter.java rename to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyMoveToLineAdapter.java index 867a9ac3ae5..fc8b2965460 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyMoveToLineAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyMoveToLineAdapter.java @@ -8,7 +8,7 @@ * Contributors: * Ericsson - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.internal.ui.actions; +package org.eclipse.cdt.dsf.debug.internal.ui.actions; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.debug.core.CDIDebugModel; @@ -18,7 +18,7 @@ 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.gdb.internal.ui.GdbUIPlugin; +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; @@ -84,6 +84,6 @@ public class DisassemblyMoveToLineAdapter implements IMoveToLineTarget { 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)); - GdbUIPlugin.log(ms); + DsfUIPlugin.log(ms); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyResumeAtLineAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyResumeAtLineAdapter.java similarity index 96% rename from dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyResumeAtLineAdapter.java rename to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyResumeAtLineAdapter.java index daa352bd5e0..112f91225c7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyResumeAtLineAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyResumeAtLineAdapter.java @@ -8,7 +8,7 @@ * Contributors: * Ericsson - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.internal.ui.actions; +package org.eclipse.cdt.dsf.debug.internal.ui.actions; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.debug.core.CDIDebugModel; @@ -18,7 +18,7 @@ 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.gdb.internal.ui.GdbUIPlugin; +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; @@ -84,6 +84,6 @@ public class DisassemblyResumeAtLineAdapter implements IResumeAtLineTarget { 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)); - GdbUIPlugin.log(ms); + DsfUIPlugin.log(ms); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyRunToLineAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyRunToLineAdapter.java similarity index 97% rename from dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyRunToLineAdapter.java rename to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyRunToLineAdapter.java index c49fc4d57f4..5ebca3316ce 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DisassemblyRunToLineAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/DisassemblyRunToLineAdapter.java @@ -8,7 +8,7 @@ * Contributors: * Ericsson - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.internal.ui.actions; +package org.eclipse.cdt.dsf.debug.internal.ui.actions; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.debug.core.CDIDebugModel; @@ -17,7 +17,7 @@ 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.gdb.internal.ui.GdbUIPlugin; +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; @@ -93,6 +93,6 @@ public class DisassemblyRunToLineAdapter implements IRunToLineTarget { 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 ) ); - GdbUIPlugin.log(ms); + 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 query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + DsfServicesTracker tracker = + new DsfServicesTracker(DsfUIPlugin.getBundleContext(), fContext.getSessionId()); + + IRunControl2 runControl = tracker.getService(IRunControl2.class); + if (runControl != null) { + runControl.moveToLine( + fContext, fileName, lineNumber, false, + new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + } else { + rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + }; + session.getExecutor().execute(query); + query.get(); + } catch (RejectedExecutionException e) { + exception = e; + } catch (InterruptedException e) { + exception = e; + } catch (ExecutionException e) { + exception = e; + } + if (exception != null) { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$ + } + } else { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ + } + } + + public boolean canMoveToAddress(final IAddress address) { + 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.canMoveToAddress(fContext, address, 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 moveToAddress(final IAddress address) throws DebugException { + DsfSession session = DsfSession.getSession(fContext.getSessionId()); + if (session != null && session.isActive()) { + Throwable exception = null; + try { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + DsfServicesTracker tracker = + new DsfServicesTracker(DsfUIPlugin.getBundleContext(), fContext.getSessionId()); + + IRunControl2 runControl = tracker.getService(IRunControl2.class); + if (runControl != null) { + runControl.moveToAddress( + fContext, address, false, + new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + } else { + rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + }; + session.getExecutor().execute(query); + query.get(); + } catch (RejectedExecutionException e) { + exception = e; + } catch (InterruptedException e) { + exception = e; + } catch (ExecutionException e) { + exception = e; + } + if (exception != null) { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$ + } + } else { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ + } + } +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/ResumeAtLine.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/ResumeAtLine.java new file mode 100644 index 00000000000..7e42df3c305 --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/ResumeAtLine.java @@ -0,0 +1,194 @@ +/******************************************************************************* + * 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.IResumeAtAddress; +import org.eclipse.cdt.debug.core.model.IResumeAtLine; +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.resources.IFile; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugException; + +/** + * Implements the CDT's resume at line interface. + * + * @since 2.1 + */ +public class ResumeAtLine implements IResumeAtLine, IResumeAtAddress { + + private final IExecutionDMContext fContext; + + public ResumeAtLine(IExecutionDMContext context) { + fContext = context; + } + + public boolean canResumeAtLine(IFile file, final int lineNumber) { + return canResumeAtLine(file.getLocation().makeAbsolute().toOSString(), lineNumber); + } + + public boolean canResumeAtLine(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, true, 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 resumeAtLine(IFile file, int lineNumber) throws DebugException { + resumeAtLine(file.getLocation().makeAbsolute().toOSString(), lineNumber); + } + + public void resumeAtLine(final String fileName, final int lineNumber) throws DebugException { + DsfSession session = DsfSession.getSession(fContext.getSessionId()); + if (session != null && session.isActive()) { + Throwable exception = null; + try { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + DsfServicesTracker tracker = + new DsfServicesTracker(DsfUIPlugin.getBundleContext(), fContext.getSessionId()); + + IRunControl2 runControl = tracker.getService(IRunControl2.class); + if (runControl != null) { + runControl.moveToLine( + fContext, fileName, lineNumber, true, + new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + } else { + rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + }; + session.getExecutor().execute(query); + query.get(); + } catch (RejectedExecutionException e) { + exception = e; + } catch (InterruptedException e) { + exception = e; + } catch (ExecutionException e) { + exception = e; + } + if (exception != null) { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$ + } + } else { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ + } + } + + public boolean canResumeAtAddress(final IAddress address) { + 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.canMoveToAddress(fContext, address, true, 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 resumeAtAddress(final IAddress address) throws DebugException { + DsfSession session = DsfSession.getSession(fContext.getSessionId()); + if (session != null && session.isActive()) { + Throwable exception = null; + try { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + DsfServicesTracker tracker = + new DsfServicesTracker(DsfUIPlugin.getBundleContext(), fContext.getSessionId()); + + IRunControl2 runControl = tracker.getService(IRunControl2.class); + if (runControl != null) { + runControl.moveToAddress( + fContext, address, true, + new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + } else { + rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + }; + session.getExecutor().execute(query); + query.get(); + } catch (RejectedExecutionException e) { + exception = e; + } catch (InterruptedException e) { + exception = e; + } catch (ExecutionException e) { + exception = e; + } + if (exception != null) { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$ + } + } else { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ + } + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/RetargettableActionAdapterFactory.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RetargettableActionAdapterFactory.java similarity index 96% rename from dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/RetargettableActionAdapterFactory.java rename to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RetargettableActionAdapterFactory.java index 2c18fb9e290..f554b9b139c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/RetargettableActionAdapterFactory.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RetargettableActionAdapterFactory.java @@ -8,7 +8,7 @@ * Contributors: * Ericsson - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.internal.ui.actions; +package org.eclipse.cdt.dsf.debug.internal.ui.actions; import org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget; import org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RunToLine.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RunToLine.java new file mode 100644 index 00000000000..fbaf2d9e43d --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/actions/RunToLine.java @@ -0,0 +1,197 @@ +/******************************************************************************* + * 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 - Added support for IRunToAddress for DSF DisassemblyView (302324) + *******************************************************************************/ +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.IRunToAddress; +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.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.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 RunToLine implements IRunToLine, IRunToAddress { + + private final IExecutionDMContext fContext; + + public RunToLine(IExecutionDMContext context) { + fContext = context; + } + + public boolean canRunToLine(final IFile file, final int lineNumber) { + return canRunToLine(file.getLocation().makeAbsolute().toOSString(), lineNumber); + } + + public boolean canRunToLine(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.canRunToLine(fContext, fileName, lineNumber, 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 query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + DsfServicesTracker tracker = + new DsfServicesTracker(DsfUIPlugin.getBundleContext(), fContext.getSessionId()); + + IRunControl2 runControl = tracker.getService(IRunControl2.class); + if (runControl != null) { + runControl.runToLine( + fContext, fileName, lineNumber, skipBreakpoints, + new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + } else { + rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + }; + session.getExecutor().execute(query); + query.get(); + } catch (RejectedExecutionException e) { + exception = e; + } catch (InterruptedException e) { + exception = e; + } catch (ExecutionException e) { + exception = e; + } + if (exception != null) { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing run to line", exception)); //$NON-NLS-1$ + } + } else { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ + } + } + + /** @since 2.1 */ + public boolean canRunToAddress(final IAddress address) { + 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.canRunToAddress(fContext, address, 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; + } + + /** @since 2.1 */ + public void runToAddress(final IAddress address, final boolean skipBreakpoints) throws DebugException { + DsfSession session = DsfSession.getSession(fContext.getSessionId()); + if (session != null && session.isActive()) { + Throwable exception = null; + try { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + DsfServicesTracker tracker = + new DsfServicesTracker(DsfUIPlugin.getBundleContext(), fContext.getSessionId()); + + IRunControl2 runControl = tracker.getService(IRunControl2.class); + if (runControl != null) { + runControl.runToAddress(fContext, address, skipBreakpoints, + new DataRequestMonitor(ImmediateExecutor.getInstance(), rm)); + } else { + rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + }; + session.getExecutor().execute(query); + query.get(); + } catch (RejectedExecutionException e) { + exception = e; + } catch (InterruptedException e) { + exception = e; + } catch (ExecutionException e) { + exception = e; + } + if (exception != null) { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing run to line", exception)); //$NON-NLS-1$ + } + } else { + throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$ + } + } + } diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IRunControl2.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IRunControl2.java new file mode 100644 index 00000000000..99fefe2bd2a --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IRunControl2.java @@ -0,0 +1,108 @@ +package org.eclipse.cdt.dsf.debug.service; + +import org.eclipse.cdt.core.IAddress; +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; + +/** + * This interface extends IRunControl to let a service support the + * "Run to Line," "Move to Line," and "Resume at Line" commands. + * @since 2.1 + */ +public interface IRunControl2 extends IRunControl { + + /** + * Returns whether the service can run the specified context to + * a source file and line number. + * + * @param context the execution DM context + * @param sourceFile the source file, full path if possible + * @param lineNumber the line number offset (one-based) into the source file + * @param rm the DataRequestMonitor that will return the result + */ + void canRunToLine(IExecutionDMContext context, String sourceFile, int lineNumber, DataRequestMonitor rm ); + + /** + * Request to run the program up to the specified location. + * If skipBreakpoints is false, any other breakpoint will stop this + * command; while if skipBreakpoints is true, the operation will ignore + * other breakpoints and continue until the specified location. + * + * @param context the execution DM context + * @param sourceFile the source file, full path if possible + * @param lineNumber the line number offset into (one-based) the source file + * @param skipBreakpoints skip breakpoints while performing this operation + * @param rm the Request Monitor + */ + void runToLine(IExecutionDMContext context, String sourceFile, int lineNumber, boolean skipBreakpoints, RequestMonitor rm); + + /** + * Returns whether the service can run the specified context to + * a specified address. + * + * @param context the execution DM context + * @param address the address specifier + * @param rm the DataRequestMonitor that will return the result + */ + void canRunToAddress(IExecutionDMContext context, IAddress address, DataRequestMonitor rm ); + + /** + * Request to run the program up to the specified address. + * If skipBreakpoints is false, any other breakpoint will stop this + * command; while if skipBreakpoints is true, the operation will ignore + * other breakpoints and continue until the specified location. + * + * @param context the execution DM context + * @param address the address specifier + * @param skipBreakpoints the skip breakpoints + * @param rm the Request Monitor + */ + void runToAddress(IExecutionDMContext context, IAddress address, boolean skipBreakpoints, RequestMonitor rm); + + /** + * Determines if the service can move the program counter to the specified + * source location. + * + * @param context the execution DM context + * @param sourceFile the source file, full path if possible + * @param lineNumber the line number offset (one-based) into the source file + * @param resume resume execution after moving the PC + * @param rm the DataRequestMonitor that will return the result + */ + void canMoveToLine(IExecutionDMContext context, String sourceFile, int lineNumber, boolean resume, DataRequestMonitor rm ); + + /** + * Moves the program counter for the specified context to the specified + * source location. + * + * @param context the execution DM context + * @param sourceFile the source file, full path if possible + * @param lineNumber the line number offset (one-based) into the source file + * @param resume resume execution after moving the PC + * @param rm the Request Monitor + */ + void moveToLine(IExecutionDMContext context, String sourceFile, int lineNumber, boolean resume, RequestMonitor rm ); + + /** + * Determines if the service can move the program counter to the specified + * address. + * + * @param context the execution DM context + * @param address the address specifier + * @param resume resume execution after moving the PC + * @param rm the DataRequestMonitor that will return the result + */ + void canMoveToAddress(IExecutionDMContext context, IAddress address, boolean resume, DataRequestMonitor rm ); + + /** + * Moves the program counter for the specified context to the specified + * address. + * + * @param context the execution DM context + * @param address the address specifier + * @param resume resume execution after moving the PC + * @param rm the Request Monitor + */ + void moveToAddress(IExecutionDMContext context, IAddress address, boolean resume, RequestMonitor rm ); + +}