1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Implementation of the 'Resume At C/C++ Line' action.

This commit is contained in:
Mikhail Khodjaiants 2003-02-05 22:32:09 +00:00
parent 0b75f23cdd
commit fd783f3c88
13 changed files with 405 additions and 11 deletions

View file

@ -1,3 +1,10 @@
2003-02-05 Mikhail Khodjaiants
Support of the 'Resume At C/C++ Line' action.
* IJumpToLine.java: new
* IJumpToAddress.java: new
* ICDebugTarget.java
* CDebugTarget.java
2003-02-04 Mikhail Khodjaiants
Support of the 'Resume Without Signal' action.
* IResumeWithoutSignal.java: new

View file

@ -21,6 +21,8 @@ public interface ICDebugTarget extends IDebugTarget,
IRestart,
IRunToLine,
IRunToAddress,
IJumpToLine,
IJumpToAddress,
IResumeWithoutSignal,
IState,
ISwitchToThread,

View file

@ -0,0 +1,30 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.DebugException;
/**
* Provides the ability to resume a debug target at the given address.
*
* @since: Feb 5, 2003
*/
public interface IJumpToAddress
{
/**
* Returns whether this operation is currently available for this element.
*
* @return whether this operation is currently available
*/
public boolean canJumpToAddress( long address );
/**
* Causes this element to resume the execution at the specified address.
*
* @exception DebugException on failure. Reasons include:
*/
public void jumpToAddress( long address ) throws DebugException;
}

View file

@ -0,0 +1,31 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.resources.IResource;
import org.eclipse.debug.core.DebugException;
/**
* Provides the ability to resume a debug target at the given line.
*
* @since: Feb 5, 2003
*/
public interface IJumpToLine
{
/**
* Returns whether this operation is currently available for this element.
*
* @return whether this operation is currently available
*/
public boolean canJumpToLine( IResource resource, 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;
}

View file

@ -66,6 +66,8 @@ import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport;
import org.eclipse.cdt.debug.core.model.IExecFileInfo;
import org.eclipse.cdt.debug.core.model.IGlobalVariable;
import org.eclipse.cdt.debug.core.model.IJumpToAddress;
import org.eclipse.cdt.debug.core.model.IJumpToLine;
import org.eclipse.cdt.debug.core.model.IRunToAddress;
import org.eclipse.cdt.debug.core.model.IRunToLine;
import org.eclipse.cdt.debug.core.model.IState;
@ -907,6 +909,10 @@ public class CDebugTarget extends CDebugElement
return this;
if ( adapter.equals( IRunToAddress.class ) )
return this;
if ( adapter.equals( IJumpToLine.class ) )
return this;
if ( adapter.equals( IJumpToAddress.class ) )
return this;
if ( adapter.equals( ICBreakpointManager.class ) )
return this;
if ( adapter.equals( DisassemblyManager.class ) )
@ -2467,4 +2473,60 @@ public class CDebugTarget extends CDebugElement
targetRequestFailed( e.toString(), e );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(IResource, int)
*/
public boolean canJumpToLine( IResource resource, 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( IResource resource, int lineNumber ) throws DebugException
{
if ( !canJumpToLine( resource, lineNumber ) )
return;
setBreakpoints();
ICDILocation location = getCDISession().getBreakpointManager().createLocation( resource.getLocation().lastSegment(), null, lineNumber );
try
{
getCDITarget().jump( location );
}
catch( CDIException e )
{
targetRequestFailed( e.toString(), e );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IJumpToAddress#canJumpToAddress(long)
*/
public boolean canJumpToAddress( long address )
{
// check if supports jump to address
return canResume();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IJumpToAddress#jumpToAddress(long)
*/
public void jumpToAddress( long address ) throws DebugException
{
if ( !canJumpToAddress( address ) )
return;
setBreakpoints();
ICDILocation location = getCDISession().getBreakpointManager().createLocation( address );
try
{
getCDITarget().jump( location );
}
catch( CDIException e )
{
targetRequestFailed( e.toString(), e );
}
}
}

View file

@ -1,3 +1,13 @@
2003-02-05 Mikhail Khodjaiants
Implementation of the 'Resume At C/C++ Line' action.
* RunToLineActionDelegate.java
* JumpToLineActionDelegate.java
* plugin.properties
* plugin.xml
icons/full/clcl16/jump_co.gif
icons/full/dlcl16/jump_co.gif
icons/full/elcl16/jump_co.gif
2003-02-04 Mikhail Khodjaiants
Implementation of the 'Resume Without Signal' action.
* SignalZeroActionDelegate.java

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

View file

@ -37,6 +37,7 @@ ManageWatchpointAction.label=Add C/C++ &Watchpoint...
AddExpressionAction.label=Add C/C++ &Expression...
AddAddressBreakpointAction.label=Add &Address Breakpoint...
RunToLineAction.label=Run To C/C++ &Line
JumpToLineAction.label=Resume At C/C++ Li&ne
ShowFullPathsAction.label=Show Full Paths
ShowFullPathsAction.tooltip=Show Full Paths

View file

@ -135,14 +135,14 @@
</separator>
</menu>
<action
id="org.eclipse.cdt.debug.ui.internal.actions.RestartActionDelegate"
hoverIcon="icons/full/clcl16/restart.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.RestartActionDelegate"
disabledIcon="icons/full/dlcl16/restart.gif"
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
hoverIcon="icons/full/clcl16/jump_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
disabledIcon="icons/full/dlcl16/jump_co.gif"
enablesFor="1"
icon="icons/full/elcl16/restart.gif"
helpContextId="restart_action_context"
label="%RestartAction.label"
icon="icons/full/elcl16/jump_co.gif"
helpContextId="jump_to_line_action_context"
label="%JumpToLineAction.label"
menubarPath="org.eclipse.ui.run/stepGroup">
<enablement>
<pluginState
@ -168,6 +168,23 @@
</pluginState>
</enablement>
</action>
<action
id="org.eclipse.cdt.debug.ui.internal.actions.RestartActionDelegate"
hoverIcon="icons/full/clcl16/restart.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.RestartActionDelegate"
disabledIcon="icons/full/dlcl16/restart.gif"
enablesFor="1"
icon="icons/full/elcl16/restart.gif"
helpContextId="restart_action_context"
label="%RestartAction.label"
menubarPath="org.eclipse.ui.run/stepGroup">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action>
<action
label="%ManageBreakpointAction.label"
icon="icons/full/obj16/brkp_obj.gif"
@ -363,6 +380,21 @@
</pluginState>
</enablement>
</action>
<action
label="%JumpToLineAction.label"
icon="icons/full/clcl16/jump_co.gif"
helpContextId="jump_to_line_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
menubarPath="additions"
enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action>
<action
label="%RunToLineAction.label"
icon="icons/full/clcl16/runtoline_co.gif"
@ -504,6 +536,21 @@
</pluginState>
</enablement>
</action>
<action
menubarPath="additions"
class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
icon="icons/full/clcl16/jump_co.gif"
label="%JumpToLineAction.label"
enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
helpContextId="jump_to_line_action_context">
<enablement>
<pluginState
id="org.eclipse.cdt.debug.ui"
value="activated">
</pluginState>
</enablement>
</action>
<action
label="%RunToLineAction.label"
icon="icons/full/clcl16/runtoline_co.gif"
@ -626,6 +673,21 @@
</pluginState>
</enablement>
</action>
<action
menubarPath="additions"
label="%JumpToLineAction.label"
icon="icons/full/clcl16/jump_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
helpContextId="jump_to_line_action_context">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action>
<action
label="%RunToLineAction.label"
icon="icons/full/clcl16/runtoline_co.gif"
@ -711,8 +773,8 @@
id="org.eclipse.cdt.debug.internal.ui.actions.SignalZeroActionDelegate">
<enablement>
<pluginState
id="org.eclipse.cdt.debug.ui"
value="activated">
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action>
@ -965,6 +1027,21 @@
<action
id="org.eclipse.cdt.debug.internal.ui.AddAddressBreakpointActionDelegate">
</action>
<action
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate">
</action>
<action
id="org.eclipse.cdt.debug.ui.internal.actions.RunToLineActionDelegate">
</action>
<action
id="org.eclipse.cdt.debug.ui.internal.actions.ManageBreakpointActionDelegate">
</action>
<action
id="org.eclipse.cdt.debug.internal.ui.actions.ManageWatchpointActionDelegate">
</action>
<action
id="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate">
</action>
</debugActionGroup>
</extension>
<extension

View file

@ -0,0 +1,172 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.actions;
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.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.ITextEditor;
/**
* Enter type comment.
*
* @since: Feb 5, 2003
*/
public class JumpToLineActionDelegate extends AbstractEditorActionDelegate
{
/**
* Constructor for JumpToLineActionDelegate.
*/
public JumpToLineActionDelegate()
{
super();
}
/* (non-Javadoc)
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
*/
public void selectionChanged( IWorkbenchPart part, ISelection selection )
{
IDebugTarget target = null;
if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) )
{
if ( selection != null && selection instanceof IStructuredSelection )
{
Object element = ((IStructuredSelection)selection).getFirstElement();
if ( element != null && element instanceof IDebugElement )
{
IDebugTarget target1 = ((IDebugElement)element).getDebugTarget();
if ( target1 != null &&
( target1 instanceof IJumpToLine || target1 instanceof IJumpToAddress ) )
{
target = target1;
}
}
}
setDebugTarget( target );
update();
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
public void run( IAction action )
{
if ( getTargetPart() != null && getTargetPart() instanceof ITextEditor )
{
IEditorInput input = ((ITextEditor)getTargetPart()).getEditorInput();
if ( input != null && input instanceof IFileEditorInput )
{
IFile file = ((IFileEditorInput)input).getFile();
if ( file != null )
{
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
int lineNumber = selection.getStartLine() + 1;
jumpToLine( file, lineNumber );
}
}
else if ( input != null && input instanceof IStorageEditorInput )
{
try
{
IStorage storage = ((IStorageEditorInput)input).getStorage();
if ( storage != null && storage.getAdapter( IDisassemblyStorage.class ) != null )
{
IDisassemblyStorage disassemblyStorage = (IDisassemblyStorage)storage.getAdapter( IDisassemblyStorage.class );
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
int lineNumber = selection.getStartLine();
long address = disassemblyStorage.getAddress( lineNumber );
if ( address > 0 )
jumpToAddress( address );
}
}
catch( CoreException e )
{
}
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractEditorActionDelegate#initializeDebugTarget()
*/
protected void initializeDebugTarget()
{
setDebugTarget( null );
IAdaptable context = DebugUITools.getDebugContext();
if ( context != null && context instanceof IDebugElement )
{
IDebugTarget target = ((IDebugElement)context).getDebugTarget();
if ( target != null &&
( target instanceof IJumpToLine || target instanceof IJumpToAddress ) )
{
setDebugTarget( target );
}
}
}
protected void jumpToLine( IResource resource, int lineNumber )
{
IJumpToLine target = (IJumpToLine)getDebugTarget().getAdapter( IJumpToLine.class );
if ( target != null )
{
if ( !target.canJumpToLine( resource, lineNumber ) )
{
getTargetPart().getSite().getShell().getDisplay().beep();
return;
}
try
{
target.jumpToLine( resource, lineNumber );
}
catch( DebugException e )
{
CDebugUIPlugin.errorDialog( e.getMessage(), e );
}
}
}
protected void jumpToAddress( long address )
{
IJumpToAddress target = (IJumpToAddress)getDebugTarget().getAdapter( IJumpToAddress.class );
if ( target != null )
{
if ( !target.canJumpToAddress( address ) )
{
getTargetPart().getSite().getShell().getDisplay().beep();
return;
}
try
{
target.jumpToAddress( address );
}
catch( DebugException e )
{
CDebugUIPlugin.errorDialog( e.getMessage(), e );
}
}
}
}

View file

@ -94,7 +94,8 @@ public class RunToLineActionDelegate extends AbstractEditorActionDelegate
if ( context != null && context instanceof IDebugElement )
{
IDebugTarget target = ((IDebugElement)context).getDebugTarget();
if ( target != null && target instanceof IRunToLine )
if ( target != null &&
( target instanceof IRunToLine || target instanceof IRunToAddress ) )
{
setDebugTarget( target );
}
@ -115,7 +116,8 @@ public class RunToLineActionDelegate extends AbstractEditorActionDelegate
if ( element != null && element instanceof IDebugElement )
{
IDebugTarget target1 = ((IDebugElement)element).getDebugTarget();
if ( target1 != null && target1 instanceof IRunToLine )
if ( target1 != null &&
( target1 instanceof IRunToLine || target1 instanceof IRunToAddress ) )
{
target = target1;
}