mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
'Run To C/C++ Line' and 'Resume At C/C++ Line' actions for external files.
This commit is contained in:
parent
783c8d5e5e
commit
c54ca244e4
9 changed files with 178 additions and 64 deletions
|
@ -1,3 +1,10 @@
|
|||
2003-03-28 Mikhail Khodjaiants
|
||||
Core support of the 'Run To C/C++ Line' and 'Resume At C/C++ Line' actions for external files.
|
||||
* IJumpToLine.java
|
||||
* IRunToLine.java
|
||||
* CDebugTarget.java
|
||||
* CThread.java
|
||||
|
||||
2003-03-27 Mikhail Khodjaiants
|
||||
Applied patch from Chris Songer: Assembly View Fixups
|
||||
* ICDIInstruction.java
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.core.model;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
||||
/**
|
||||
|
@ -16,16 +16,30 @@ import org.eclipse.debug.core.DebugException;
|
|||
public interface IJumpToLine
|
||||
{
|
||||
/**
|
||||
* Returns whether this operation is currently available for this element.
|
||||
* Returns whether this operation is currently available for this file and line number.
|
||||
*
|
||||
* @return whether this operation is currently available
|
||||
*/
|
||||
public boolean canJumpToLine( IResource resource, int lineNumber );
|
||||
public boolean canJumpToLine( IFile file, int lineNumber );
|
||||
|
||||
/**
|
||||
* Causes this element to resume the execution at the specified line.
|
||||
*
|
||||
* @exception DebugException on failure. Reasons include:
|
||||
*/
|
||||
public void jumpToLine( IResource resource, int lineNumber ) throws DebugException;
|
||||
public void jumpToLine( 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 );
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.core.model;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
||||
/**
|
||||
|
@ -17,16 +17,30 @@ import org.eclipse.debug.core.DebugException;
|
|||
public interface IRunToLine
|
||||
{
|
||||
/**
|
||||
* Returns whether this operation is currently available for this element.
|
||||
* Returns whether this operation is currently available for this file and line number.
|
||||
*
|
||||
* @return whether this operation is currently available
|
||||
*/
|
||||
public boolean canRunToLine( IResource resource, int lineNumber );
|
||||
public boolean canRunToLine( IFile file, int lineNumber );
|
||||
|
||||
/**
|
||||
* Causes this element to run to specified location.
|
||||
*
|
||||
* @exception DebugException on failure. Reasons include:
|
||||
*/
|
||||
public void runToLine( IResource resource, int lineNumber ) throws DebugException;
|
||||
public void runToLine( 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 canRunToLine( String fileName, int lineNumber );
|
||||
|
||||
/**
|
||||
* Causes this element to run to specified location.
|
||||
*
|
||||
* @exception DebugException on failure. Reasons include:
|
||||
*/
|
||||
public void runToLine( String fileName, int lineNumber ) throws DebugException;
|
||||
}
|
||||
|
|
|
@ -2104,7 +2104,7 @@ public class CDebugTarget extends CDebugElement
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.IRunToLine#canRunToLine(IResource, int)
|
||||
*/
|
||||
public boolean canRunToLine( IResource resource, int lineNumber )
|
||||
public boolean canRunToLine( String fileName, int lineNumber )
|
||||
{
|
||||
// check if supports run to line
|
||||
return canResume();
|
||||
|
@ -2113,12 +2113,12 @@ public class CDebugTarget extends CDebugElement
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.IRunToLine#runToLine(IResource, int)
|
||||
*/
|
||||
public void runToLine( IResource resource, int lineNumber ) throws DebugException
|
||||
public void runToLine( String fileName, int lineNumber ) throws DebugException
|
||||
{
|
||||
if ( !canRunToLine( resource, lineNumber ) )
|
||||
if ( !canRunToLine( fileName, lineNumber ) )
|
||||
return;
|
||||
setBreakpoints();
|
||||
ICDILocation location = getCDISession().getBreakpointManager().createLocation( resource.getLocation().lastSegment(), null, lineNumber );
|
||||
ICDILocation location = getCDISession().getBreakpointManager().createLocation( fileName, null, lineNumber );
|
||||
try
|
||||
{
|
||||
getCDITarget().runUntil( location );
|
||||
|
@ -2129,6 +2129,25 @@ public class CDebugTarget extends CDebugElement
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.IRunToLine#canRunToLine(IResource, int)
|
||||
*/
|
||||
public boolean canRunToLine( IFile file, int lineNumber )
|
||||
{
|
||||
// check if supports run to line
|
||||
return canResume();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.IRunToLine#runToLine(IResource, int)
|
||||
*/
|
||||
public void runToLine( IFile file, int lineNumber ) throws DebugException
|
||||
{
|
||||
if ( !canRunToLine( file, lineNumber ) )
|
||||
return;
|
||||
runToLine( file.getLocation().lastSegment(), lineNumber );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.ISwitchToThread#setCurrentThread(IThread)
|
||||
*/
|
||||
|
@ -2464,7 +2483,7 @@ public class CDebugTarget extends CDebugElement
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(IResource, int)
|
||||
*/
|
||||
public boolean canJumpToLine( IResource resource, int lineNumber )
|
||||
public boolean canJumpToLine( IFile file, int lineNumber )
|
||||
{
|
||||
// check if supports jump to line
|
||||
return canResume();
|
||||
|
@ -2473,12 +2492,31 @@ public class CDebugTarget extends CDebugElement
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IJumpToLine#jumpToLine(IResource, int)
|
||||
*/
|
||||
public void jumpToLine( IResource resource, int lineNumber ) throws DebugException
|
||||
public void jumpToLine( IFile file, int lineNumber ) throws DebugException
|
||||
{
|
||||
if ( !canJumpToLine( resource, lineNumber ) )
|
||||
if ( !canJumpToLine( file, lineNumber ) )
|
||||
return;
|
||||
jumpToLine( file.getLocation().lastSegment(), lineNumber );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(IResource, int)
|
||||
*/
|
||||
public boolean canJumpToLine( String fileName, int lineNumber )
|
||||
{
|
||||
// check if supports jump to line
|
||||
return canResume();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IJumpToLine#jumpToLine(IResource, int)
|
||||
*/
|
||||
public void jumpToLine( String fileName, int lineNumber ) throws DebugException
|
||||
{
|
||||
if ( !canJumpToLine( fileName, lineNumber ) )
|
||||
return;
|
||||
setBreakpoints();
|
||||
ICDILocation location = getCDISession().getBreakpointManager().createLocation( resource.getLocation().lastSegment(), null, lineNumber );
|
||||
ICDILocation location = getCDISession().getBreakpointManager().createLocation( fileName, null, lineNumber );
|
||||
try
|
||||
{
|
||||
getCDITarget().jump( location );
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
|||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISignalReceived;
|
||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
|
||||
|
@ -39,7 +38,6 @@ import org.eclipse.cdt.debug.core.model.ISwitchToFrame;
|
|||
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
||||
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
||||
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
|
@ -60,7 +58,6 @@ public class CThread extends CDebugElement
|
|||
implements IThread,
|
||||
IState,
|
||||
IRestart,
|
||||
IRunToLine,
|
||||
IInstructionStep,
|
||||
IResumeWithoutSignal,
|
||||
ISwitchToFrame,
|
||||
|
@ -1115,32 +1112,6 @@ public class CThread extends CDebugElement
|
|||
return fLastStackDepth;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.IRunToLine#canRunToLine(IResource, int)
|
||||
*/
|
||||
public boolean canRunToLine( IResource resource, int lineNumber )
|
||||
{
|
||||
return canResume();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.IRunToLine#runToLine(IResource, int)
|
||||
*/
|
||||
public void runToLine( IResource resource, int lineNumber ) throws DebugException
|
||||
{
|
||||
if ( !canRunToLine( resource, lineNumber ) )
|
||||
return;
|
||||
ICDILocation location = getCDISession().getBreakpointManager().createLocation( resource.getLocation().lastSegment(), null, lineNumber );
|
||||
try
|
||||
{
|
||||
getCDIThread().runUntil( location );
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
targetRequestFailed( e.toString(), e );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2003-03-28 Mikhail Khodjaiants
|
||||
'Run To C/C++ Line' and 'Resume At C/C++ Line' actions for external files.
|
||||
* JumpToLineActionDelegate.java
|
||||
* RunToLineActionDelegate.java
|
||||
* RunToLineRulerAction.java
|
||||
|
||||
2003-03-25 Mikhail Khodjaiants
|
||||
Fix for bug 35092.
|
||||
* CDebugImages.java
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.core.resources.FileStorage;
|
||||
import org.eclipse.cdt.debug.core.model.IJumpToAddress;
|
||||
import org.eclipse.cdt.debug.core.model.IJumpToLine;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IDebugElement;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
|
@ -93,7 +94,17 @@ public class JumpToLineActionDelegate extends AbstractEditorActionDelegate
|
|||
try
|
||||
{
|
||||
IStorage storage = ((IStorageEditorInput)input).getStorage();
|
||||
if ( storage != null && storage.getAdapter( IDisassemblyStorage.class ) != null )
|
||||
if ( storage instanceof FileStorage )
|
||||
{
|
||||
IPath path = storage.getFullPath();
|
||||
if ( path != null )
|
||||
{
|
||||
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
|
||||
int lineNumber = selection.getStartLine() + 1;
|
||||
jumpToLine( path.lastSegment(), lineNumber );
|
||||
}
|
||||
}
|
||||
else if ( storage != null && storage.getAdapter( IDisassemblyStorage.class ) != null )
|
||||
{
|
||||
IDisassemblyStorage disassemblyStorage = (IDisassemblyStorage)storage.getAdapter( IDisassemblyStorage.class );
|
||||
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
|
||||
|
@ -128,19 +139,40 @@ public class JumpToLineActionDelegate extends AbstractEditorActionDelegate
|
|||
}
|
||||
}
|
||||
|
||||
protected void jumpToLine( IResource resource, int lineNumber )
|
||||
protected void jumpToLine( IFile file, int lineNumber )
|
||||
{
|
||||
IJumpToLine target = (IJumpToLine)getDebugTarget().getAdapter( IJumpToLine.class );
|
||||
if ( target != null )
|
||||
{
|
||||
if ( !target.canJumpToLine( resource, lineNumber ) )
|
||||
if ( !target.canJumpToLine( file, lineNumber ) )
|
||||
{
|
||||
getTargetPart().getSite().getShell().getDisplay().beep();
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
target.jumpToLine( resource, lineNumber );
|
||||
target.jumpToLine( file, lineNumber );
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
CDebugUIPlugin.errorDialog( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void jumpToLine( String fileName, int lineNumber )
|
||||
{
|
||||
IJumpToLine target = (IJumpToLine)getDebugTarget().getAdapter( IJumpToLine.class );
|
||||
if ( target != null )
|
||||
{
|
||||
if ( !target.canJumpToLine( fileName, lineNumber ) )
|
||||
{
|
||||
getTargetPart().getSite().getShell().getDisplay().beep();
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
target.jumpToLine( fileName, lineNumber );
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.core.resources.FileStorage;
|
||||
import org.eclipse.cdt.debug.core.model.IRunToAddress;
|
||||
import org.eclipse.cdt.debug.core.model.IRunToLine;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IDebugElement;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
|
@ -67,7 +68,17 @@ public class RunToLineActionDelegate extends AbstractEditorActionDelegate
|
|||
try
|
||||
{
|
||||
IStorage storage = ((IStorageEditorInput)input).getStorage();
|
||||
if ( storage != null && storage.getAdapter( IDisassemblyStorage.class ) != null )
|
||||
if ( storage instanceof FileStorage )
|
||||
{
|
||||
IPath path = storage.getFullPath();
|
||||
if ( path != null )
|
||||
{
|
||||
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
|
||||
int lineNumber = selection.getStartLine() + 1;
|
||||
runToLine( path.lastSegment(), lineNumber );
|
||||
}
|
||||
}
|
||||
else if ( storage != null && storage.getAdapter( IDisassemblyStorage.class ) != null )
|
||||
{
|
||||
IDisassemblyStorage disassemblyStorage = (IDisassemblyStorage)storage.getAdapter( IDisassemblyStorage.class );
|
||||
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
|
||||
|
@ -128,19 +139,40 @@ public class RunToLineActionDelegate extends AbstractEditorActionDelegate
|
|||
}
|
||||
}
|
||||
|
||||
protected void runToLine( IResource resource, int lineNumber )
|
||||
protected void runToLine( IFile file, int lineNumber )
|
||||
{
|
||||
IRunToLine target = (IRunToLine)getDebugTarget().getAdapter( IRunToLine.class );
|
||||
if ( target != null )
|
||||
{
|
||||
if ( !target.canRunToLine( resource, lineNumber ) )
|
||||
if ( !target.canRunToLine( file, lineNumber ) )
|
||||
{
|
||||
getTargetPart().getSite().getShell().getDisplay().beep();
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
target.runToLine( resource, lineNumber );
|
||||
target.runToLine( file, lineNumber );
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
CDebugUIPlugin.errorDialog( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void runToLine( String fileName, int lineNumber )
|
||||
{
|
||||
IRunToLine target = (IRunToLine)getDebugTarget().getAdapter( IRunToLine.class );
|
||||
if ( target != null )
|
||||
{
|
||||
if ( !target.canRunToLine( fileName, lineNumber ) )
|
||||
{
|
||||
getTargetPart().getSite().getShell().getDisplay().beep();
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
target.runToLine( fileName, lineNumber );
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ package org.eclipse.cdt.debug.internal.ui.actions;
|
|||
|
||||
import org.eclipse.cdt.debug.core.model.IRunToLine;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
|
@ -59,13 +59,13 @@ public class RunToLineRulerAction extends Action
|
|||
public void update()
|
||||
{
|
||||
boolean enabled = false;
|
||||
IResource resource = getResource();
|
||||
IFile file = getFile();
|
||||
int lineNumber = getLineNumber();
|
||||
IDocumentProvider provider = getTextEditor().getDocumentProvider();
|
||||
IDocument doc = provider.getDocument( getTextEditor().getEditorInput() );
|
||||
if ( resource != null && lineNumber <= doc.getNumberOfLines() && lineNumber > 0 )
|
||||
if ( file != null && lineNumber <= doc.getNumberOfLines() && lineNumber > 0 )
|
||||
{
|
||||
enabled = ( getTarget() != null && ((IRunToLine)getTarget()).canRunToLine( resource, lineNumber ) );
|
||||
enabled = ( getTarget() != null && ((IRunToLine)getTarget()).canRunToLine( file, lineNumber ) );
|
||||
}
|
||||
setEnabled( enabled );
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class RunToLineRulerAction extends Action
|
|||
*/
|
||||
public void run()
|
||||
{
|
||||
runToLine( getResource(), getLineNumber() );
|
||||
runToLine( getFile(), getLineNumber() );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -139,7 +139,7 @@ public class RunToLineRulerAction extends Action
|
|||
fTextEditor = textEditor;
|
||||
}
|
||||
|
||||
protected IResource getResource()
|
||||
protected IFile getFile()
|
||||
{
|
||||
IEditorInput input = getTextEditor().getEditorInput();
|
||||
if ( input != null && input instanceof IFileEditorInput )
|
||||
|
@ -154,16 +154,16 @@ public class RunToLineRulerAction extends Action
|
|||
return getInfo().getLineOfLastMouseButtonActivity() + 1;
|
||||
}
|
||||
|
||||
protected void runToLine( IResource resource, int lineNumber )
|
||||
protected void runToLine( IFile file, int lineNumber )
|
||||
{
|
||||
if ( !((IRunToLine)getTarget()).canRunToLine( resource, lineNumber ) )
|
||||
if ( !((IRunToLine)getTarget()).canRunToLine( file, lineNumber ) )
|
||||
{
|
||||
getTextEditor().getSite().getShell().getDisplay().beep();
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
((IRunToLine)getTarget()).runToLine( resource, lineNumber );
|
||||
((IRunToLine)getTarget()).runToLine( file, lineNumber );
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue