mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-14 11:45:38 +02:00
Move-to-line feature. Application of the patch in bugzilla 118147. Includes refactoring of resume-at-line feature which used "jump to line" terminology. While such terminology is aligned with gdb (it invokes the 'jump' command), it is otherwise counter intuitive and collides with the "move to line" concept. The interfaces and code are now consistent throughout in its use of "resume at line" terminology.
This commit is contained in:
parent
076d4c7899
commit
8b0b647c7b
28 changed files with 927 additions and 137 deletions
|
@ -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;
|
||||
|
||||
|
||||
}
|
|
@ -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.
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.debug.core.model.IValue;
|
|||
/**
|
||||
* C/C++ specific extension of <code>IStackFrame</code>.
|
||||
*/
|
||||
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.
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
BIN
debug/org.eclipse.cdt.debug.ui/icons/dlcl16/move_to_line_co.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/dlcl16/move_to_line_co.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 886 B |
Binary file not shown.
After Width: | Height: | Size: 892 B |
Binary file not shown.
Before Width: | Height: | Size: 307 B |
BIN
debug/org.eclipse.cdt.debug.ui/icons/elcl16/move_to_line_co.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/elcl16/move_to_line_co.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 140 B |
Binary file not shown.
After Width: | Height: | Size: 145 B |
|
@ -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++)...
|
||||
|
|
|
@ -136,13 +136,20 @@
|
|||
</menu>
|
||||
<action
|
||||
id="org.eclipse.cdt.debug.ui.actions.ResumeAtLine"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.RetargetResumeAtLineAction"
|
||||
disabledIcon="icons/dlcl16/jump_co.gif"
|
||||
icon="icons/elcl16/jump_co.gif"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.RetargetResumeAtLineAction"
|
||||
disabledIcon="icons/dlcl16/resume_at_line_co.gif"
|
||||
icon="icons/elcl16/resume_at_line_co.gif"
|
||||
helpContextId="jump_to_line_action_context"
|
||||
label="%GlobalJumpToLineAction.label"
|
||||
menubarPath="org.eclipse.ui.run/stepGroup">
|
||||
</action>
|
||||
label="%GlobalResumeAtLineAction.label"
|
||||
menubarPath="org.eclipse.ui.run/stepGroup"/>
|
||||
<action
|
||||
id="org.eclipse.cdt.debug.ui.actions.MoveToLine"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.RetargetMoveToLineAction"
|
||||
disabledIcon="icons/dlcl16/move_to_line_co.gif"
|
||||
icon="icons/elcl16/move_to_line_co.gif"
|
||||
helpContextId="move_to_line_action_context"
|
||||
label="%GlobalMoveToLineAction.label"
|
||||
menubarPath="org.eclipse.ui.run/stepGroup"/>
|
||||
<action
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.SignalZeroWorkbenchActionDelegate"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.SignalZeroWorkbenchActionDelegate"
|
||||
|
@ -264,13 +271,22 @@
|
|||
id="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
label="%JumpToLineAction.label"
|
||||
icon="icons/elcl16/jump_co.gif"
|
||||
helpContextId="jump_to_line_action_context"
|
||||
label="%ResumeAtLineAction.label"
|
||||
icon="icons/elcl16/resume_at_line_co.gif"
|
||||
helpContextId="resume_at_line_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate"
|
||||
menubarPath="additions"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate">
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
label="%MoveToLineAction.label"
|
||||
icon="icons/elcl16/move_to_line_co.gif"
|
||||
helpContextId="move_to_line_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.MoveToLineActionDelegate"
|
||||
menubarPath="additions"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.MoveToLineActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
helpContextId="run_to_line_action_context"
|
||||
|
@ -360,13 +376,22 @@
|
|||
id="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
label="%JumpToLineAction.label"
|
||||
icon="icons/elcl16/jump_co.gif"
|
||||
helpContextId="jump_to_line_action_context"
|
||||
label="%ResumeAtLineAction.label"
|
||||
icon="icons/elcl16/resume_at_line_co.gif"
|
||||
helpContextId="resume_at_line_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate"
|
||||
menubarPath="additions"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate">
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
label="%MoveToLineAction.label"
|
||||
icon="icons/elcl16/move_to_line_co.gif"
|
||||
helpContextId="move_to_line_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.MoveToLineActionDelegate"
|
||||
menubarPath="additions"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.MoveToLineActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
helpContextId="run_to_line_action_context"
|
||||
|
@ -726,10 +751,18 @@
|
|||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate"
|
||||
enablesFor="1"
|
||||
helpContextId="jump_to_line_action_context"
|
||||
icon="icons/elcl16/jump_co.gif"
|
||||
helpContextId="resume_at_line_action_context"
|
||||
icon="icons/elcl16/resume_at_line_co.gif"
|
||||
id="org.eclipse.cdt.debug.ui.resumeAtLineAction"
|
||||
label="%JumpToLineAction.label"
|
||||
label="%ResumeAtLineAction.label"
|
||||
menubarPath="additions"/>
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.MoveToLineActionDelegate"
|
||||
enablesFor="1"
|
||||
helpContextId="move_to_line_action_context"
|
||||
icon="icons/elcl16/move_to_line_co.gif"
|
||||
id="org.eclipse.cdt.debug.ui.moveToLineAction"
|
||||
label="%MoveToLineAction.label"
|
||||
menubarPath="additions"/>
|
||||
<action
|
||||
class="org.eclipse.debug.ui.actions.RunToLineActionDelegate"
|
||||
|
@ -1220,6 +1253,7 @@
|
|||
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
|
||||
</adapter>
|
||||
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
|
||||
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/>
|
||||
</factory>
|
||||
<factory
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
|
||||
|
@ -1231,6 +1265,7 @@
|
|||
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
|
||||
</adapter>
|
||||
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
|
||||
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/>
|
||||
</factory>
|
||||
<factory
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
|
||||
|
@ -1242,6 +1277,7 @@
|
|||
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
|
||||
</adapter>
|
||||
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
|
||||
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/>
|
||||
</factory>
|
||||
<factory
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
|
||||
|
|
|
@ -116,7 +116,6 @@ public class CDebugImages {
|
|||
public static final String IMG_LCL_LOAD_ALL_SYMBOLS = NAME_PREFIX + "load_all_symbols_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_CAST_TO_TYPE = NAME_PREFIX + "casttotype_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_DISPLAY_AS_ARRAY = NAME_PREFIX + "showasarray_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_RESUME_AT_LINE = NAME_PREFIX + "jump_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_DETAIL_PANE_UNDER = NAME_PREFIX + "det_pane_under.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_DETAIL_PANE_RIGHT = NAME_PREFIX + "det_pane_right.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_DETAIL_PANE_HIDE = NAME_PREFIX + "det_pane_hide.gif"; //$NON-NLS-1$
|
||||
|
@ -191,8 +190,6 @@ public class CDebugImages {
|
|||
public static final ImageDescriptor DESC_WIZBAN_PATH_MAP_ENTRY = createManaged( T_WIZBAN, IMG_WIZBAN_PATH_MAP_ENTRY );
|
||||
public static final ImageDescriptor DESC_LCL_CAST_TO_TYPE = createManaged( T_ELCL, IMG_LCL_CAST_TO_TYPE );
|
||||
public static final ImageDescriptor DESC_LCL_DISPLAY_AS_ARRAY = createManaged( T_ELCL, IMG_LCL_DISPLAY_AS_ARRAY );
|
||||
public static final ImageDescriptor DESC_LCL_RESUME_AT_LINE = createManaged( T_ELCL, IMG_LCL_RESUME_AT_LINE );
|
||||
public static final ImageDescriptor DESC_LCL_RESUME_AT_LINE_DISABLED = createManaged( T_DLCL, IMG_LCL_RESUME_AT_LINE );
|
||||
public static final ImageDescriptor DESC_LCL_DETAIL_PANE_UNDER = createManaged( T_ELCL, IMG_LCL_DETAIL_PANE_UNDER );
|
||||
public static final ImageDescriptor DESC_LCL_DETAIL_PANE_UNDER_DISABLED = createManaged( T_DLCL, IMG_LCL_DETAIL_PANE_UNDER );
|
||||
public static final ImageDescriptor DESC_LCL_DETAIL_PANE_RIGHT = createManaged( T_ELCL, IMG_LCL_DETAIL_PANE_RIGHT );
|
||||
|
|
|
@ -50,16 +50,13 @@ ToggleBreakpointRulerAction.Error_1=Error
|
|||
ToggleBreakpointRulerAction.Operation_failed_1=Operation failed
|
||||
CBreakpointPropertiesRulerAction.Breakpoint_Properties=Breakpoint &Properties...
|
||||
ResumeAtLineActionDelegate.Error_1=Error
|
||||
ResumeAtLineActionDelegate.0=Resume At Li&ne
|
||||
ResumeAtLineActionDelegate.1=Error
|
||||
ResumeAtLineActionDelegate.2=Resume at line failed
|
||||
RestoreDefaultTypeActionDelegate.0=Unable to restore the default type.
|
||||
RestoreDefaultRegisterGroupsActionDelegate.0=Error
|
||||
RestoreDefaultRegisterGroupsActionDelegate.1=Error(s) occurred restoring default register groups.
|
||||
ResumeAtLineActionDelegate.Operation_failed_1=Operation failed.
|
||||
ResumeAtLineActionDelegate.Missing_document=Missing document
|
||||
ResumeAtLineActionDelegate.Empty_editor_1=Empty editor
|
||||
ResumeAtLineActionDelegate.Operation_is_not_supported_1=Operation is not supported
|
||||
MoveToLineActionDelegate.1=Error
|
||||
MoveToLineActionDelegate.2=Move to line failed
|
||||
AddGlobalsActionDelegate.title=Global Variables
|
||||
AddGlobalsActionDelegate.Error(s)_occured_adding_globals_1=Error(s) occured adding globals.
|
||||
ManageFunctionBreakpointActionDelegate.Error_1=Error
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************
|
||||
* 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.internal.ui.actions;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.model.ISuspendResume;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
/**
|
||||
* An adapter for a "move to line" operation.
|
||||
*/
|
||||
public interface IMoveToLineTarget {
|
||||
/**
|
||||
* Perform a move to line operation on the given element that is
|
||||
* currently selected and suspended in the Debug view.
|
||||
*
|
||||
* @param part the part on which the action has been invoked
|
||||
* @param selection the selection on which the action has been invoked
|
||||
* @param target suspended element to perform the "resume at line" action on
|
||||
* @throws CoreException if unable to perform the action
|
||||
*/
|
||||
public void moveToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns whether a move to line operation can be performed on the given
|
||||
* element that is currently selected and suspended in the Debug view.
|
||||
*
|
||||
* @param part the part on which the action has been invoked
|
||||
* @param selection the selection on which the action has been invoked
|
||||
* @param target suspended element to perform the "resume at line" action on
|
||||
* @throws CoreException if unable to perform the action
|
||||
*/
|
||||
public boolean canMoveToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target );
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/*******************************************************************************
|
||||
* 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.internal.ui.actions;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdapterManager;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.debug.core.model.ISuspendResume;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.ui.IActionDelegate2;
|
||||
import org.eclipse.ui.IEditorActionDelegate;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchPartSite;
|
||||
|
||||
/**
|
||||
* A move to line action that can be contributed to a an editor. The action
|
||||
* will perform the "move to line" operation for editors that provide
|
||||
* an appropriate <code>IMoveToLineTarget</code> 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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue