1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Implementation of the 'Run To Line' action for disassembly.

This commit is contained in:
Mikhail Khodjaiants 2003-01-13 22:28:48 +00:00
parent a729d837b8
commit 40300813c0
2 changed files with 50 additions and 1 deletions

View file

@ -1,3 +1,7 @@
2003-01-10 Mikhail Khodjaiants
Implementation of the 'Run To Line' action for disassembly.
* RunToLineActionDelegate.java
2003-01-13 Alain Magloire
* src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java (getHoverInfo):

View file

@ -5,10 +5,14 @@
*/
package org.eclipse.cdt.debug.internal.ui.actions;
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.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
@ -21,6 +25,7 @@ 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;
@ -52,11 +57,30 @@ public class RunToLineActionDelegate extends AbstractEditorActionDelegate
IFile file = ((IFileEditorInput)input).getFile();
if ( file != null )
{
ITextSelection selection= (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
int lineNumber = selection.getStartLine() + 1;
runToLine( 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 )
runToAddress( address );
}
}
catch( CoreException e )
{
}
}
}
}
@ -122,4 +146,25 @@ public class RunToLineActionDelegate extends AbstractEditorActionDelegate
}
}
}
protected void runToAddress( long address )
{
IRunToAddress target = (IRunToAddress)getDebugTarget().getAdapter( IRunToAddress.class );
if ( target != null )
{
if ( !target.canRunToAddress( address ) )
{
getTargetPart().getSite().getShell().getDisplay().beep();
return;
}
try
{
target.runToAddress( address );
}
catch( DebugException e )
{
CDebugUIPlugin.errorDialog( e.getMessage(), e );
}
}
}
}