diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExecuteMoveInstructionPointer.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExecuteMoveInstructionPointer.java
new file mode 100644
index 00000000000..c817c112c44
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExecuteMoveInstructionPointer.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Freescale Secmiconductor 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:
+ * Freescale Semiconductor - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.debug.core.cdi.model;
+
+import org.eclipse.cdt.debug.core.cdi.CDIException;
+import org.eclipse.cdt.debug.core.cdi.ICDILocation;
+
+/**
+ * Provides the ability to perform a jump without changing the run state of a thread or debug target.
+ */
+public interface ICDIExecuteMoveInstructionPointer {
+
+ /**
+ * Moves the instruction pointer to the specified location without changing the run state
+ * The result is undefined if it moves outside of the stackframe.
+ * Can only be called when the associated target is suspended.
+ *
+ * @param location
+ * @throws CDIException if this method fails. Reasons include:
+ */
+ void moveInstructionPointer(ICDILocation location) throws CDIException;
+
+
+}
diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExecuteResume.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExecuteResume.java
index 7e449eb37e8..3b565a008c9 100644
--- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExecuteResume.java
+++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExecuteResume.java
@@ -17,7 +17,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDILocation;
/**
* Provides the ability to resume a thread or debug target.
*/
-interface ICDIExecuteResume {
+public interface ICDIExecuteResume {
/**
* Causes this target to resume its execution.
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java
index f2b95cfc1fb..3844e4504ea 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java
@@ -18,7 +18,7 @@ import org.eclipse.debug.core.model.IValue;
/**
* C/C++ specific extension of IStackFrame
.
*/
-public interface ICStackFrame extends IRunToLine, IRunToAddress, IJumpToLine, IJumpToAddress, IStackFrame, ICDebugElement {
+public interface ICStackFrame extends IRunToLine, IRunToAddress, IResumeAtLine, IResumeAtAddress, IStackFrame, ICDebugElement {
/**
* Returns the address of this stack frame.
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java
new file mode 100644
index 00000000000..833fbc85385
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Freescale Semiconductor 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:
+ * Freescale Semiconductor - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.core.model;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.debug.core.DebugException;
+
+/**
+ * Provides the ability to move the instruction pointer of a debug target to the given address.
+ */
+public interface IMoveToAddress {
+
+ /**
+ * Returns whether this operation is currently available for this element.
+ *
+ * @return whether this operation is currently available
+ */
+ public boolean canMoveToAddress( IAddress address );
+
+ /**
+ * Causes this element can move the instruction pointer to the specified address.
+ *
+ * @exception DebugException on failure. Reasons include:
+ */
+ public void moveToAddress( IAddress address ) throws DebugException;
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java
new file mode 100644
index 00000000000..134cabb95a9
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Freescale Semiconductor 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:
+ * Freescale Semiconductor - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.core.model;
+
+import org.eclipse.debug.core.DebugException;
+
+/**
+ * Provides the ability to move the instruction pointer of a debug target to the given line.
+ */
+public interface IMoveToLine {
+
+ /**
+ * Returns whether this operation is currently available for this file and line number.
+ *
+ * @return whether this operation is currently available
+ */
+ public boolean canMoveToLine( String fileName, int lineNumber );
+
+ /**
+ * Causes this element to move the instruction pointer to the specified line.
+ *
+ * @exception DebugException on failure. Reasons include:
+ */
+ public void moveToLine( String fileName, int lineNumber ) throws DebugException;
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IJumpToAddress.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java
similarity index 81%
rename from debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IJumpToAddress.java
rename to debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java
index 657b121df5d..5f2feac8245 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IJumpToAddress.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * Copyright (c) 2004, 2008 QNX Software 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
@@ -16,19 +16,19 @@ import org.eclipse.debug.core.DebugException;
/**
* Provides the ability to resume a debug target at the given address.
*/
-public interface IJumpToAddress {
+public interface IResumeAtAddress {
/**
* Returns whether this operation is currently available for this element.
*
* @return whether this operation is currently available
*/
- public boolean canJumpToAddress( IAddress address );
+ public boolean canResumeAtAddress( IAddress address );
/**
* Causes this element to resume the execution at the specified address.
*
* @exception DebugException on failure. Reasons include:
*/
- public void jumpToAddress( IAddress address ) throws DebugException;
+ public void resumeAtAddress( IAddress address ) throws DebugException;
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IJumpToLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java
similarity index 80%
rename from debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IJumpToLine.java
rename to debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java
index b6bb95d8c83..2f281216690 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IJumpToLine.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java
@@ -16,14 +16,14 @@ import org.eclipse.debug.core.DebugException;
/**
* Provides the ability to resume a debug target at the given line.
*/
-public interface IJumpToLine {
+public interface IResumeAtLine {
/**
* Returns whether this operation is currently available for this file and line number.
*
* @return whether this operation is currently available
*/
- public boolean canJumpToLine( IFile file, int lineNumber );
+ public boolean canResumeAtLine( IFile file, int lineNumber );
/**
* Causes this element to resume the execution at the specified line.
@@ -31,19 +31,19 @@ public interface IJumpToLine {
* @exception DebugException
* on failure. Reasons include:
*/
- public void jumpToLine( IFile file, int lineNumber ) throws DebugException;
+ public void resumeAtLine( IFile file, int lineNumber ) throws DebugException;
/**
* Returns whether this operation is currently available for this file and line number.
*
* @return whether this operation is currently available
*/
- public boolean canJumpToLine( String fileName, int lineNumber );
+ public boolean canResumeAtLine( String fileName, int lineNumber );
/**
* Causes this element to resume the execution at the specified line.
*
* @exception DebugException on failure. Reasons include:
*/
- public void jumpToLine( String fileName, int lineNumber ) throws DebugException;
+ public void resumeAtLine( String fileName, int lineNumber ) throws DebugException;
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
index b94388c3ddc..838a8c138c2 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
@@ -18,6 +18,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.CDIException;
@@ -25,15 +26,19 @@ import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDILocator;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteMoveInstructionPointer;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
-import org.eclipse.cdt.debug.core.model.IJumpToAddress;
-import org.eclipse.cdt.debug.core.model.IJumpToLine;
+import org.eclipse.cdt.debug.core.model.IMoveToAddress;
+import org.eclipse.cdt.debug.core.model.IMoveToLine;
import org.eclipse.cdt.debug.core.model.IRestart;
+import org.eclipse.cdt.debug.core.model.IResumeAtAddress;
+import org.eclipse.cdt.debug.core.model.IResumeAtLine;
import org.eclipse.cdt.debug.core.model.IResumeWithoutSignal;
import org.eclipse.cdt.debug.core.model.IRunToAddress;
import org.eclipse.cdt.debug.core.model.IRunToLine;
@@ -53,7 +58,7 @@ import org.eclipse.debug.core.model.IVariable;
/**
* Proxy to a stack frame on the target.
*/
-public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart, IResumeWithoutSignal, ICDIEventListener {
+public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart, IResumeWithoutSignal, IMoveToAddress, IMoveToLine, ICDIEventListener {
/**
* Underlying CDI stack frame.
@@ -475,10 +480,16 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
if ( adapter == IRunToAddress.class ) {
return this;
}
- if ( adapter == IJumpToLine.class ) {
+ if ( adapter == IResumeAtLine.class ) {
return this;
}
- if ( adapter == IJumpToAddress.class ) {
+ if ( adapter == IResumeAtAddress.class ) {
+ return this;
+ }
+ if ( adapter == IMoveToLine.class ) {
+ return this;
+ }
+ if ( adapter == IMoveToAddress.class ) {
return this;
}
if ( adapter == CStackFrame.class ) {
@@ -839,37 +850,39 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(org.eclipse.core.resources.IFile, int)
+ * @see org.eclipse.cdt.debug.core.model.IResumeAtLine#canResumeAtLine(org.eclipse.core.resources.IFile, int)
*/
- public boolean canJumpToLine( IFile file, int lineNumber ) {
+ public boolean canResumeAtLine( IFile file, int lineNumber ) {
return getThread().canResume();
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IJumpToLine#jumpToLine(org.eclipse.core.resources.IFile, int)
+ * @see org.eclipse.cdt.debug.core.model.IResumeAtLine#resumeAtLine(org.eclipse.core.resources.IFile, int)
*/
- public void jumpToLine( IFile file, int lineNumber ) throws DebugException {
- if ( !canJumpToLine( file, lineNumber ) )
+ public void resumeAtLine( IFile file, int lineNumber ) throws DebugException {
+ if ( !canResumeAtLine( file, lineNumber ) )
return;
- jumpToLine( file.getLocation().lastSegment(), lineNumber );
+ resumeAtLine( file.getLocation().lastSegment(), lineNumber );
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(java.lang.String, int)
+ * @see org.eclipse.cdt.debug.core.model.IResumeAtLine#canResumeAtLine(java.lang.String, int)
*/
- public boolean canJumpToLine( String fileName, int lineNumber ) {
+ public boolean canResumeAtLine( String fileName, int lineNumber ) {
return getThread().canResume();
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IJumpToLine#jumpToLine(java.lang.String, int)
+ * @see org.eclipse.cdt.debug.core.model.IResumeAtLine#resumeAtLine(java.lang.String, int)
*/
- public void jumpToLine( String fileName, int lineNumber ) throws DebugException {
- if ( !canJumpToLine( fileName, lineNumber ) )
+ public void resumeAtLine( String fileName, int lineNumber ) throws DebugException {
+ if ( !canResumeAtLine( fileName, lineNumber ) )
return;
+
ICDILocation location = getCDITarget().createLineLocation( fileName, lineNumber );
try {
- getCDIThread().resume( location );
+ ICDIExecuteResume resumer = getCDIThread();
+ resumer.resume(location);
}
catch( CDIException e ) {
targetRequestFailed( e.getMessage(), e );
@@ -877,17 +890,17 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IJumpToAddress#canJumpToAddress(org.eclipse.cdt.core.IAddress)
+ * @see org.eclipse.cdt.debug.core.model.IResumeAtAddress#canResumeAtAddress(org.eclipse.cdt.core.IAddress)
*/
- public boolean canJumpToAddress( IAddress address ) {
+ public boolean canResumeAtAddress( IAddress address ) {
return getThread().canResume();
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IJumpToAddress#jumpToAddress(org.eclipse.cdt.core.IAddress)
+ * @see org.eclipse.cdt.debug.core.model.IResumeAtAddress#resumeAtAddress(org.eclipse.cdt.core.IAddress)
*/
- public void jumpToAddress( IAddress address ) throws DebugException {
- if ( !canJumpToAddress( address ) )
+ public void resumeAtAddress( IAddress address ) throws DebugException {
+ if ( !canResumeAtAddress( address ) )
return;
ICDILocation location = getCDITarget().createAddressLocation( new BigInteger( address.toString() ) );
try {
@@ -898,6 +911,52 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IMoveToAddress#canMoveToAddress(org.eclipse.cdt.core.IAddress)
+ */
+ public boolean canMoveToAddress(IAddress address) {
+ return getThread().isSuspended() && (getCDIThread() instanceof ICDIExecuteMoveInstructionPointer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IMoveToAddress#moveToAddress(org.eclipse.cdt.core.IAddress)
+ */
+ public void moveToAddress(IAddress address) throws DebugException {
+ if ( !canMoveToAddress( address ) )
+ return;
+ ICDILocation location = getCDITarget().createAddressLocation( new BigInteger( address.toString() ) );
+ ICDIExecuteMoveInstructionPointer mover = (ICDIExecuteMoveInstructionPointer)getCDIThread();
+ try {
+ mover.moveInstructionPointer( location);
+ }
+ catch( CDIException e ) {
+ targetRequestFailed( e.getMessage(), e );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IMoveToLine#canMoveToLine(java.lang.String, int)
+ */
+ public boolean canMoveToLine(String fileName, int lineNumber) {
+ return getThread().isSuspended() && (getCDIThread() instanceof ICDIExecuteMoveInstructionPointer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IMoveToLine#moveToLine(java.lang.String, int)
+ */
+ public void moveToLine(String fileName, int lineNumber) throws DebugException {
+ if ( !canMoveToLine( fileName, lineNumber ) )
+ return;
+ ICDILocation location= getCDITarget().createLineLocation( fileName, lineNumber );
+ ICDIExecuteMoveInstructionPointer mover = (ICDIExecuteMoveInstructionPointer)getCDIThread();
+ try {
+ mover.moveInstructionPointer( location );
+ }
+ catch( CDIException e ) {
+ targetRequestFailed( e.getMessage(), e );
+ }
+ }
+
private ICDIThread getCDIThread() {
return ((CThread)getThread()).getCDIThread();
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CThread.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CThread.java
index 606af09413a..976b2c220b9 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CThread.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CThread.java
@@ -45,9 +45,11 @@ import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICThread;
import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
-import org.eclipse.cdt.debug.core.model.IJumpToAddress;
-import org.eclipse.cdt.debug.core.model.IJumpToLine;
+import org.eclipse.cdt.debug.core.model.IMoveToAddress;
+import org.eclipse.cdt.debug.core.model.IMoveToLine;
import org.eclipse.cdt.debug.core.model.IRestart;
+import org.eclipse.cdt.debug.core.model.IResumeAtAddress;
+import org.eclipse.cdt.debug.core.model.IResumeAtLine;
import org.eclipse.cdt.debug.core.model.IResumeWithoutSignal;
import org.eclipse.cdt.debug.core.model.IRunToAddress;
import org.eclipse.cdt.debug.core.model.IRunToLine;
@@ -426,6 +428,20 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
return ( fConfig.supportsResume() && isSuspended() );
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IRunToLine#canRunToLine(org.eclipse.core.resources.IFile, int)
+ */
+ public boolean canRunToLine( IFile file, int lineNumber ) {
+ return canRunToLine( file.getLocation().lastSegment(), lineNumber );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IRunToLine#canRunToLine(java.lang.String, int)
+ */
+ public boolean canRunToLine( String fileName, int lineNumber ) {
+ return canResume();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
*/
@@ -458,6 +474,39 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IRunToLine#runToLine(org.eclipse.core.resources.IFile, int, boolean)
+ */
+ public void runToLine( IFile file, int lineNumber, boolean skipBreakpoints ) throws DebugException {
+ runToLine( file.getLocation().lastSegment(), lineNumber, skipBreakpoints );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IRunToLine#runToLine(java.lang.String, int, boolean)
+ */
+ public void runToLine( String fileName, int lineNumber, boolean skipBreakpoints ) throws DebugException {
+ if ( !canRunToLine( fileName, lineNumber ) )
+ return;
+ if ( skipBreakpoints ) {
+ ((CDebugTarget)getDebugTarget()).skipBreakpoints( true );
+ }
+ CDebugElementState oldState = getState();
+ setState( CDebugElementState.RESUMING );
+ ICDILocation location = getCDITarget().createLineLocation( fileName, lineNumber );
+
+ try {
+ final ICDIThread cdiThread = getCDIThread();
+ cdiThread.stepUntil( location );
+ }
+ catch( CDIException e ) {
+ setState( oldState );
+ if ( skipBreakpoints ) {
+ ((CDebugTarget)getDebugTarget()).skipBreakpoints( false );
+ }
+ targetRequestFailed( e.getMessage(), e );
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISuspendResume#suspend()
*/
@@ -848,8 +897,10 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
public Object getAdapter( Class adapter ) {
if ( adapter.equals( IRunToLine.class ) ||
adapter.equals( IRunToAddress.class ) ||
- adapter.equals( IJumpToLine.class ) ||
- adapter.equals( IJumpToAddress.class ) ) {
+ adapter.equals( IResumeAtLine.class ) ||
+ adapter.equals( IResumeAtAddress.class ) ||
+ adapter.equals( IMoveToLine.class ) ||
+ adapter.equals( IMoveToAddress.class ) ) {
try {
// Alain: Put a proper fix later.
Object obj = getTopStackFrame();
@@ -979,52 +1030,5 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
}
setCurrent( cdiThread.equals( currentThread ) );
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IRunToLine#canRunToLine(org.eclipse.core.resources.IFile, int)
- */
- public boolean canRunToLine(IFile file, int lineNumber) {
- return canRunToLine( file.getLocation().lastSegment(), lineNumber );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IRunToLine#canRunToLine(java.lang.String, int)
- */
- public boolean canRunToLine(String fileName, int lineNumber) {
- return canResume();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IRunToLine#runToLine(org.eclipse.core.resources.IFile, int, boolean)
- */
- public void runToLine(IFile file, int lineNumber, boolean skipBreakpoints)
- throws DebugException {
- runToLine( file.getLocation().lastSegment(), lineNumber, skipBreakpoints );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.model.IRunToLine#runToLine(java.lang.String, int, boolean)
- */
- public void runToLine(String fileName, int lineNumber,
- boolean skipBreakpoints) throws DebugException {
- if ( !canRunToLine( fileName, lineNumber ) )
- return;
- if ( skipBreakpoints ) {
- ((CDebugTarget)getDebugTarget()).skipBreakpoints( true );
- }
-
- CDebugElementState oldState = getState();
- setState( CDebugElementState.RESUMING );
- ICDILocation location = getCDITarget().createLineLocation( fileName, lineNumber );
- try {
- getCDIThread().stepUntil( location );
- }
- catch( CDIException e ) {
- setState( oldState );
- if ( skipBreakpoints ) {
- ((CDebugTarget)getDebugTarget()).skipBreakpoints( false );
- }
- targetRequestFailed( e.getMessage(), e );
- }
- }
+
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
index 44ef41fc119..fd32a84e899 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
@@ -31,6 +31,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement3;
import org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteMoveInstructionPointer;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIFunctionBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIGlobalVariable;
@@ -51,6 +52,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDITargetConfiguration;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
+import org.eclipse.cdt.debug.core.model.ICBreakpointType;
import org.eclipse.cdt.debug.mi.core.CoreProcess;
import org.eclipse.cdt.debug.mi.core.IMIConstants;
import org.eclipse.cdt.debug.mi.core.MIException;
@@ -100,7 +102,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo;
/**
*/
-public class Target extends SessionObject implements ICDITarget, ICDIBreakpointManagement3, ICDIAddressToSource, ICDIMemorySpaceManagement {
+public class Target extends SessionObject implements ICDITarget, ICDIBreakpointManagement3, ICDIAddressToSource, ICDIMemorySpaceManagement, ICDIExecuteMoveInstructionPointer {
MISession miSession;
ICDITargetConfiguration fConfiguration;
@@ -717,6 +719,58 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteMoveInstructionPointer#moveInstructionPointer(org.eclipse.cdt.debug.core.cdi.ICDILocation)
+ */
+ public void moveInstructionPointer(ICDILocation location) throws CDIException {
+ // Most of this code was taken from our Resume()
+ // method. The only differences are that we create a temporary
+ // breakpoint for the location and set it before we post
+ // the 'jump' command
+ CommandFactory factory = miSession.getCommandFactory();
+ LocationBreakpoint bkpt = null;
+ String loc = null;
+ File file = null;
+ if (location instanceof ICDIFileLocation) {
+ String filePath = ((ICDIFileLocation)location).getFile();
+ if (filePath != null && filePath.length() > 0)
+ file = new File(filePath);
+ }
+ if (location instanceof ICDILineLocation) {
+ ICDILineLocation lineLocation = (ICDILineLocation)location;
+ if (file != null) {
+ loc = file.getName() + ":" + lineLocation.getLineNumber(); //$NON-NLS-1$
+ }
+ bkpt = new LineBreakpoint(this, ICBreakpointType.TEMPORARY, lineLocation, null, true);
+ } else if (location instanceof ICDIAddressLocation) {
+ ICDIAddressLocation addrLocation = (ICDIAddressLocation)location;
+ if (!addrLocation.getAddress().equals(BigInteger.ZERO)) {
+ loc = "*0x" + addrLocation.getAddress().toString(16); //$NON-NLS-1$
+ }
+ bkpt = new AddressBreakpoint(this, ICBreakpointType.TEMPORARY, addrLocation, null, true);
+ }
+ // Throw an exception we do know where to go
+ if (loc == null) {
+ throw new CDIException(CdiResources.getString("cdi.mode.Target.Bad_location")); //$NON-NLS-1$
+ }
+
+ // Set a temporary breakpoint at the location we're going
+ // to do a 'jump' (resume from) operation
+ Session session = (Session)getSession();
+ session.getBreakpointManager().setLocationBreakpoint(bkpt);
+
+ CLIJump jump = factory.createCLIJump(loc);
+ try {
+ miSession.postCommand(jump);
+ MIInfo info = jump.getMIInfo();
+ if (info == null) {
+ throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
+ }
+ } catch (MIException e) {
+ throw new MI2CDIException(e);
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume#resume(org.eclipse.cdt.debug.core.cdi.model.ICDISignal)
*/
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java
index daf47b2dfca..61edc650270 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java
@@ -19,6 +19,7 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteMoveInstructionPointer;
import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
@@ -42,7 +43,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo;
/**
*/
-public class Thread extends CObject implements ICDIThread {
+public class Thread extends CObject implements ICDIThread, ICDIExecuteMoveInstructionPointer {
static ICDIStackFrame[] noStack = new ICDIStackFrame[0];
int id;
@@ -551,4 +552,14 @@ public class Thread extends CObject implements ICDIThread {
return null;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteMoveInstructionPointer#moveInstructionPointer(org.eclipse.cdt.debug.core.cdi.ICDILocation)
+ */
+ public void moveInstructionPointer(ICDILocation location) throws CDIException {
+ Target target = (Target)getTarget();
+ synchronized(target.getLock()) {
+ target.setCurrentThread(this);
+ target.moveInstructionPointer(location);
+ }
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/move_to_line_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/move_to_line_co.gif
new file mode 100644
index 00000000000..c37e7000b68
Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/move_to_line_co.gif differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/resume_at_line_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/resume_at_line_co.gif
new file mode 100644
index 00000000000..7921bc7a93a
Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/resume_at_line_co.gif differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/elcl16/jump_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/elcl16/jump_co.gif
deleted file mode 100644
index b453f19ddd2..00000000000
Binary files a/debug/org.eclipse.cdt.debug.ui/icons/elcl16/jump_co.gif and /dev/null differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/elcl16/move_to_line_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/elcl16/move_to_line_co.gif
new file mode 100644
index 00000000000..53ee78ea617
Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/elcl16/move_to_line_co.gif differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/elcl16/resume_at_line_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/elcl16/resume_at_line_co.gif
new file mode 100644
index 00000000000..3ae782d5b20
Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/elcl16/resume_at_line_co.gif differ
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index 2a5f1932ad0..4fe789f1efe 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -45,8 +45,10 @@ ToggleWatchpointAction.tooltip=Toggle Variable Watchpoint
BreakpointPropertiesAction.label=P&roperties...
AddExpressionAction.label=Add Watch Expression...
RunToLineAction.label=Run To &Line
-JumpToLineAction.label=Resume At Li&ne
-GlobalJumpToLineAction.label=Resume At Li&ne (C/C++)
+ResumeAtLineAction.label=Resume At Li&ne
+MoveToLineAction.label=&Move To Line
+GlobalResumeAtLineAction.label=Resume At Li&ne (C/C++)
+GlobalMoveToLineAction.label=Move to Line (C/C++)
ShowFullPathsAction.label=Show Full &Paths
ShowFullPathsAction.tooltip=Show Full Paths
AddWatchpoint.label=Add Watchpoint (C/C++)...
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 5ae9c15cf7d..1340aff2615 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -136,13 +136,20 @@
-
+ label="%GlobalResumeAtLineAction.label"
+ menubarPath="org.eclipse.ui.run/stepGroup"/>
+
+ id="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate">
+
+
+ id="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate">
+
+
+
+
+
+
IMoveToLineTarget adapter.
+ */
+public class MoveToLineActionDelegate implements IEditorActionDelegate, IViewActionDelegate, IActionDelegate2 {
+
+ private IWorkbenchPart fActivePart = null;
+
+ private IMoveToLineTarget fPartTarget = null;
+
+ private IAction fAction = null;
+
+ private ISelectionListener fSelectionListener = new DebugSelectionListener();
+
+ protected ISuspendResume fTargetElement = null;
+
+ class DebugSelectionListener implements ISelectionListener {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
+ fTargetElement = null;
+ if ( selection instanceof IStructuredSelection ) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if ( ss.size() == 1 ) {
+ Object object = ss.getFirstElement();
+ if ( object instanceof ISuspendResume ) {
+ fTargetElement = (ISuspendResume)object;
+ }
+ }
+ }
+ update();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
+ */
+ public void setActiveEditor( IAction action, IEditorPart targetEditor ) {
+ init( action );
+ bindTo( targetEditor );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
+ */
+ public void init( IAction action ) {
+ this.fAction = action;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#dispose()
+ */
+ public void dispose() {
+ fActivePart.getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener );
+ fActivePart = null;
+ fPartTarget = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
+ */
+ public void runWithEvent( IAction action, Event event ) {
+ run( action );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run( IAction action ) {
+ if ( fPartTarget != null && fTargetElement != null ) {
+ try {
+ fPartTarget.moveToLine( fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement );
+ }
+ catch( CoreException e ) {
+ ErrorDialog.openError( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "MoveToLineActionDelegate.1" ), ActionMessages.getString( "MoveToLineActionDelegate.2" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IAction action, ISelection selection ) {
+ this.fAction = action;
+ update();
+ }
+
+ protected void update() {
+ if ( fAction == null ) {
+ return;
+ }
+ boolean enabled = false;
+ if ( fPartTarget != null && fTargetElement != null ) {
+ IWorkbenchPartSite site = fActivePart.getSite();
+ if ( site != null ) {
+ ISelectionProvider selectionProvider = site.getSelectionProvider();
+ if ( selectionProvider != null ) {
+ ISelection selection = selectionProvider.getSelection();
+ enabled = fTargetElement.isSuspended() && fPartTarget.canMoveToLine( fActivePart, selection, fTargetElement );
+ }
+ }
+ }
+ fAction.setEnabled( enabled );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init( IViewPart view ) {
+ bindTo( view );
+ }
+
+ /**
+ * Binds this action to operate on the given part's run to line adapter.
+ */
+ private void bindTo( IWorkbenchPart part ) {
+ fActivePart = part;
+ if ( part != null ) {
+ part.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener );
+ fPartTarget = (IMoveToLineTarget)part.getAdapter( IMoveToLineTarget.class );
+ if ( fPartTarget == null ) {
+ IAdapterManager adapterManager = Platform.getAdapterManager();
+ // TODO: we could restrict loading to cases when the debugging context is on
+ if ( adapterManager.hasAdapter( part, IMoveToLineTarget.class.getName() ) ) {
+ fPartTarget = (IMoveToLineTarget)adapterManager.loadAdapter( part, IMoveToLineTarget.class.getName() );
+ }
+ }
+ // Force the selection update
+ ISelection selection = part.getSite().getWorkbenchWindow().getSelectionService().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
+ fSelectionListener.selectionChanged( part, selection );
+ }
+ update();
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineAdapter.java
new file mode 100644
index 00000000000..7f534c1bfad
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineAdapter.java
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 QNX Software 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:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.debug.core.model.IMoveToAddress;
+import org.eclipse.cdt.debug.core.model.IMoveToLine;
+import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
+import org.eclipse.cdt.debug.internal.core.model.CDebugElement;
+import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
+import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
+import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
+import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyEditorInput;
+import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.ISourceLocator;
+import org.eclipse.debug.core.model.ISuspendResume;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Move to line target adapter for the CDI debugger
+ */
+public class MoveToLineAdapter implements IMoveToLineTarget {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget#moveToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
+ */
+ public void moveToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException {
+ String errorMessage = null;
+ if ( part instanceof ITextEditor ) {
+ ITextEditor textEditor = (ITextEditor)part;
+ IEditorInput input = textEditor.getEditorInput();
+ if ( input == null ) {
+ errorMessage = ActionMessages.getString( "MoveToLineAdapter.0" ); //$NON-NLS-1$
+ }
+ else {
+ IDocument document = textEditor.getDocumentProvider().getDocument( input );
+ if ( document == null ) {
+ errorMessage = ActionMessages.getString( "MoveToLineAdapter.1" ); //$NON-NLS-1$
+ }
+ else {
+ final String fileName = getFileName( input );
+ IDebugTarget debugTarget = null;
+ if (target instanceof CDebugElement) { // should always be, but just in case
+ debugTarget = ((CDebugElement)target).getDebugTarget();
+ }
+ if (debugTarget != null) {
+ ITextSelection textSelection = (ITextSelection)selection;
+ final int lineNumber = textSelection.getStartLine() + 1;
+ if ( target instanceof IAdaptable ) {
+ final IPath path = convertPath( fileName, debugTarget );
+ final IMoveToLine moveToLine = (IMoveToLine)((IAdaptable)target).getAdapter( IMoveToLine.class );
+ if ( moveToLine != null && moveToLine.canMoveToLine( path.toPortableString(), lineNumber ) ) {
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ moveToLine.moveToLine(path.toPortableString(), lineNumber );
+ }
+ catch( DebugException e ) {
+ failed( e );
+ }
+ }
+ };
+ runInBackground( r );
+ }
+ }
+ return;
+ }
+ }
+ }
+ }
+ else if ( part instanceof DisassemblyView ) {
+ IEditorInput input = ((DisassemblyView)part).getInput();
+ if ( !(input instanceof DisassemblyEditorInput) ) {
+ errorMessage = ActionMessages.getString( "MoveToLineAdapter.2" ); //$NON-NLS-1$
+ }
+ else {
+ ITextSelection textSelection = (ITextSelection)selection;
+ int lineNumber = textSelection.getStartLine() + 1;
+ final IAddress address = ((DisassemblyEditorInput)input).getAddress( lineNumber );
+ if ( address != null && target instanceof IAdaptable ) {
+ final IMoveToAddress moveToAddress = (IMoveToAddress)((IAdaptable)target).getAdapter( IMoveToAddress.class );
+ if ( moveToAddress != null && moveToAddress.canMoveToAddress( address ) ) {
+ Runnable r = new Runnable() {
+
+ public void run() {
+ try {
+ moveToAddress.moveToAddress( address );
+ }
+ catch( DebugException e ) {
+ failed( e );
+ }
+ }
+ };
+ runInBackground( r );
+ }
+ }
+ return;
+ }
+ }
+ else {
+ errorMessage = ActionMessages.getString( "MoveToLineAdapter.3" ); //$NON-NLS-1$
+ }
+ throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget#canMoveToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
+ */
+ public boolean canMoveToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) {
+ if ( target instanceof IAdaptable ) {
+ if ( part instanceof IEditorPart ) {
+ IMoveToLine moveToLine = (IMoveToLine)((IAdaptable)target).getAdapter( IMoveToLine.class );
+ if ( moveToLine == null)
+ return false;
+ IEditorPart editorPart = (IEditorPart)part;
+ IEditorInput input = editorPart.getEditorInput();
+ if ( input == null ) {
+ return false;
+ }
+ if ( !(editorPart instanceof ITextEditor) ) {
+ return false;
+ }
+ ITextEditor textEditor = (ITextEditor)editorPart;
+ IDocument document = textEditor.getDocumentProvider().getDocument( input );
+ if ( document == null ) {
+ return false;
+ }
+ String fileName = null;
+ try {
+ fileName = getFileName( input );
+ }
+ catch( CoreException e ) {
+ }
+ if (fileName == null) {
+ return false;
+ }
+
+ IDebugTarget debugTarget = null;
+ if (target instanceof CDebugElement) { // should always be, but just in case
+ debugTarget = ((CDebugElement)target).getDebugTarget();
+ }
+ if (debugTarget == null) {
+ return false;
+ }
+
+ final IPath path = convertPath( fileName, debugTarget );
+ ITextSelection textSelection = (ITextSelection)selection;
+ int lineNumber = textSelection.getStartLine() + 1;
+ return moveToLine.canMoveToLine(path.toPortableString(), lineNumber );
+ }
+ if ( part instanceof DisassemblyView ) {
+ IMoveToAddress moveToAddress = (IMoveToAddress)((IAdaptable)target).getAdapter( IMoveToAddress.class );
+ if ( moveToAddress == null )
+ return false;
+ IEditorInput input = ((DisassemblyView)part).getInput();
+ if ( !(input instanceof DisassemblyEditorInput) ) {
+ return false;
+ }
+ ITextSelection textSelection = (ITextSelection)selection;
+ int lineNumber = textSelection.getStartLine() + 1;
+ IAddress address = ((DisassemblyEditorInput)input).getAddress( lineNumber );
+ return moveToAddress.canMoveToAddress( address );
+ }
+ }
+ return false;
+ }
+
+ private String getFileName( IEditorInput input ) throws CoreException {
+ return CDebugUIUtils.getEditorFilePath(input);
+ }
+
+ private void runInBackground( Runnable r ) {
+ DebugPlugin.getDefault().asyncExec( r );
+ }
+
+ protected void failed( Throwable e ) {
+ MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString( "MoveToLineAdapter.4" ), null ); //$NON-NLS-1$
+ ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) );
+ CDebugUtils.error( ms, this );
+ }
+ private IPath convertPath( String sourceHandle, IDebugTarget debugTarget ) {
+ IPath path = null;
+ if ( Path.EMPTY.isValidPath( sourceHandle ) ) {
+ if ( debugTarget != null ) {
+ ISourceLocator sl = debugTarget.getLaunch().getSourceLocator();
+ if ( sl instanceof CSourceLookupDirector ) {
+ path = ((CSourceLookupDirector)sl).getCompilationPath( sourceHandle );
+ }
+ }
+ if ( path == null ) {
+ path = new Path( sourceHandle );
+ }
+ }
+ return path;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java
index 1d832d63b47..a8d1f6e4569 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
-import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;
@@ -81,11 +80,6 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IViewA
*/
public void init( IAction action ) {
this.fAction = action;
- if ( action != null ) {
- action.setText( ActionMessages.getString( "ResumeAtLineActionDelegate.0" ) ); //$NON-NLS-1$
- action.setImageDescriptor( CDebugImages.DESC_LCL_RESUME_AT_LINE );
- action.setDisabledImageDescriptor( CDebugImages.DESC_LCL_RESUME_AT_LINE_DISABLED );
- }
}
/* (non-Javadoc)
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java
index 3c608bc6227..312ee430173 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java
@@ -14,8 +14,8 @@ package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils;
-import org.eclipse.cdt.debug.core.model.IJumpToAddress;
-import org.eclipse.cdt.debug.core.model.IJumpToLine;
+import org.eclipse.cdt.debug.core.model.IResumeAtAddress;
+import org.eclipse.cdt.debug.core.model.IResumeAtLine;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.cdt.debug.internal.core.model.CDebugElement;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
@@ -75,13 +75,12 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
ITextSelection textSelection = (ITextSelection)selection;
final int lineNumber = textSelection.getStartLine() + 1;
if ( target instanceof IAdaptable ) {
- final IJumpToLine jumpToLine = (IJumpToLine)((IAdaptable)target).getAdapter( IJumpToLine.class );
- if ( jumpToLine != null && jumpToLine.canJumpToLine( path.toPortableString(), lineNumber ) ) {
+ final IResumeAtLine resumeAtLine = (IResumeAtLine)((IAdaptable)target).getAdapter( IResumeAtLine.class );
+ if ( resumeAtLine != null && resumeAtLine.canResumeAtLine( path.toPortableString(), lineNumber ) ) {
Runnable r = new Runnable() {
-
public void run() {
try {
- jumpToLine.jumpToLine( path.toPortableString(), lineNumber );
+ resumeAtLine.resumeAtLine( path.toPortableString(), lineNumber );
}
catch( DebugException e ) {
failed( e );
@@ -105,13 +104,13 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
int lineNumber = textSelection.getStartLine() + 1;
final IAddress address = ((DisassemblyEditorInput)input).getAddress( lineNumber );
if ( address != null && target instanceof IAdaptable ) {
- final IJumpToAddress jumpToAddress = (IJumpToAddress)((IAdaptable)target).getAdapter( IJumpToAddress.class );
- if ( jumpToAddress != null && jumpToAddress.canJumpToAddress( address ) ) {
+ final IResumeAtAddress resumeAtAddress = (IResumeAtAddress)((IAdaptable)target).getAdapter( IResumeAtAddress.class );
+ if ( resumeAtAddress != null && resumeAtAddress.canResumeAtAddress( address ) ) {
Runnable r = new Runnable() {
public void run() {
try {
- jumpToAddress.jumpToAddress( address );
+ resumeAtAddress.resumeAtAddress( address );
}
catch( DebugException e ) {
failed( e );
@@ -136,8 +135,8 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
public boolean canResumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) {
if ( target instanceof IAdaptable ) {
if ( part instanceof IEditorPart ) {
- IJumpToLine jumpToLine = (IJumpToLine)((IAdaptable)target).getAdapter( IJumpToLine.class );
- if ( jumpToLine == null )
+ IResumeAtLine jumpToLine = (IResumeAtLine)((IAdaptable)target).getAdapter( IResumeAtLine.class );
+ if ( jumpToLine == null)
return false;
IEditorPart editorPart = (IEditorPart)part;
IEditorInput input = editorPart.getEditorInput();
@@ -165,13 +164,16 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
if ( target instanceof CDebugElement ) { // should always be, but just in case
debugTarget = ((CDebugElement)target).getDebugTarget();
}
- final IPath path = convertPath( fileName, debugTarget );
+ if (debugTarget == null) {
+ return false;
+ }
+ final IPath path = convertPath( fileName, debugTarget );
ITextSelection textSelection = (ITextSelection)selection;
int lineNumber = textSelection.getStartLine() + 1;
- return jumpToLine.canJumpToLine( path.toPortableString(), lineNumber );
+ return jumpToLine.canResumeAtLine( path.toPortableString(), lineNumber );
}
if ( part instanceof DisassemblyView ) {
- IJumpToAddress jumpToAddress = (IJumpToAddress)((IAdaptable)target).getAdapter( IJumpToAddress.class );
+ IResumeAtAddress jumpToAddress = (IResumeAtAddress)((IAdaptable)target).getAdapter( IResumeAtAddress.class );
if ( jumpToAddress == null )
return false;
IEditorInput input = ((DisassemblyView)part).getInput();
@@ -181,7 +183,7 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
ITextSelection textSelection = (ITextSelection)selection;
int lineNumber = textSelection.getStartLine() + 1;
IAddress address = ((DisassemblyEditorInput)input).getAddress( lineNumber );
- return jumpToAddress.canJumpToAddress( address );
+ return jumpToAddress.canResumeAtAddress( address );
}
}
return false;
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetMoveToLineAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetMoveToLineAction.java
new file mode 100644
index 00000000000..c7f3cd07e82
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetMoveToLineAction.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Freescale Semiconductor 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:
+ * Freescale Semiconductor - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.ISuspendResume;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * Global retargettable move to line action.
+ */
+public class RetargetMoveToLineAction extends RetargetAction {
+
+ private ISelectionListener fSelectionListener = new DebugSelectionListener();
+
+ private ISuspendResume fTargetElement = null;
+
+ class DebugSelectionListener implements ISelectionListener {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
+ setTargetElement( null );
+ if ( selection instanceof IStructuredSelection ) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if ( ss.size() == 1 ) {
+ Object object = ss.getFirstElement();
+ if ( object instanceof ISuspendResume ) {
+ setTargetElement( (ISuspendResume)object );
+ }
+ }
+ }
+ update();
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose() {
+ fWindow.getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener );
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init( IWorkbenchWindow window ) {
+ super.init( window );
+ window.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.RetargetAction#performAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ protected void performAction( Object target, ISelection selection, IWorkbenchPart part ) throws CoreException {
+ ((IMoveToLineTarget)target).moveToLine( part, selection, getTargetElement() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.RetargetAction#getAdapterClass()
+ */
+ protected Class> getAdapterClass() {
+ return IMoveToLineTarget.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.RetargetAction#canPerformAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ protected boolean canPerformAction( Object target, ISelection selection, IWorkbenchPart part ) {
+ return getTargetElement() != null && ((IMoveToLineTarget)target).canMoveToLine( part, selection, getTargetElement() );
+ }
+
+ protected ISuspendResume getTargetElement() {
+ return fTargetElement;
+ }
+
+ protected void setTargetElement( ISuspendResume targetElement ) {
+ fTargetElement = targetElement;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java
index caf5373b251..8de0567b3ff 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java
@@ -75,7 +75,7 @@ public class RetargetResumeAtLineAction extends RetargetAction {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.RetargetAction#getAdapterClass()
*/
- protected Class getAdapterClass() {
+ protected Class> getAdapterClass() {
return IResumeAtLineTarget.class;
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java
index e70c7e4fe6c..e120bcae8a8 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java
@@ -33,6 +33,9 @@ public class RetargettableActionAdapterFactory implements IAdapterFactory {
}
if ( adapterType == IResumeAtLineTarget.class ) {
return new ResumeAtLineAdapter();
+ }
+ if ( adapterType == IMoveToLineTarget.class ) {
+ return new MoveToLineAdapter();
}
return null;
}
@@ -41,6 +44,6 @@ public class RetargettableActionAdapterFactory implements IAdapterFactory {
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
public Class[] getAdapterList() {
- return new Class[]{ IRunToLineTarget.class, IToggleBreakpointsTarget.class, IResumeAtLineTarget.class };
+ return new Class[]{ IRunToLineTarget.class, IToggleBreakpointsTarget.class, IResumeAtLineTarget.class, IMoveToLineTarget.class };
}
}