diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index dbc8398e519..5a32a26c7cd 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,13 @@ +2004-04-16 Mikhail Khodjaiants + Implementing retargettable actions for Disassembly view. + * plugin.xml + * DisassemblyView.java: new + * DisassemblyEditorInput.java + * BreakpointLocationVerifier.java + * ActionMessages.properties + * RunToLineAdapter.java + * ToggleBreakpointAdapter.java + 2004-04-15 Mikhail Khodjaiants Implementing the Disassembly view. New pacckage: org.eclipse.cdt.debug.internal.ui.views.disassembly diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 53956b70cb2..f7dbc68698f 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -87,8 +87,8 @@ + id="org.eclipse.cdt.debug.ui.MemoryView" + relationship="stack"> @@ -96,8 +96,8 @@ + id="org.eclipse.cdt.debug.ui.SharedLibrariesView" + relationship="stack"> @@ -105,8 +105,8 @@ + id="org.eclipse.cdt.debug.ui.SignalsView" + relationship="stack"> @@ -117,8 +117,8 @@ + id="org.eclipse.cdt.debug.ui.DisassemblyView" + relationship="stack"> @@ -290,8 +290,8 @@ @@ -706,8 +706,8 @@ label="%SignalAction.label" icon="icons/full/clcl16/signal_co.gif" helpContextId="signal_action_context" - class="org.eclipse.cdt.debug.internal.ui.actions.SignalActionDelegate" tooltip="%SignalAction.tooltip" + class="org.eclipse.cdt.debug.internal.ui.actions.SignalActionDelegate" menubarPath="additions" enablesFor="1" id="org.eclipse.cdt.debug.internal.ui.actions.SignalActionDelegate"> @@ -722,8 +722,8 @@ label="%SignalPropertiesAction.label" style="pulldown" helpContextId="signal_properties_action_context" - class="org.eclipse.cdt.debug.internal.ui.actions.SignalPropertiesActionDelegate" tooltip="%SignalPropertiesAction.tooltip" + class="org.eclipse.cdt.debug.internal.ui.actions.SignalPropertiesActionDelegate" enablesFor="1" id="org.eclipse.cdt.debug.ui.SignalPropertiesAction"> @@ -759,8 +759,8 @@ @@ -775,8 +775,8 @@ label="%CastToTypeAction.label" icon="icons/full/clcl16/casttotype_co.gif" helpContextId="cast_to_type_action_context" - tooltip="%CastToTypeAction.tooltip" class="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate" + tooltip="%CastToTypeAction.tooltip" menubarPath="additions" enablesFor="1" id="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate"> @@ -791,8 +791,8 @@ label="%CastToArrayAction.label" icon="icons/full/clcl16/showasarray_co.gif" helpContextId="cast_to_array_action_context" - tooltip="%CastToArrayAction.tooltip" class="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate" + tooltip="%CastToArrayAction.tooltip" menubarPath="additions" enablesFor="1" id="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate"> @@ -811,8 +811,8 @@ label="%ManageFunctionBreakpointAction.label" icon="icons/full/obj16/funbrkp_obj.gif" helpContextId="manage_function_breakpoint_action_context" - tooltip="%ManageFunctionBreakpointAction.tooltip" class="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate" + tooltip="%ManageFunctionBreakpointAction.tooltip" menubarPath="additions" enablesFor="1" id="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate"> @@ -831,8 +831,8 @@ label="%DisableVariablesAction.label" icon="icons/full/clcl16/disabled_co.gif" helpContextId="disable_variables_action_context" - tooltip="%DisableVariablesAction.tooltip" class="org.eclipse.cdt.debug.internal.ui.actions.DisableVariablesActionDelegate" + tooltip="%DisableVariablesAction.tooltip" menubarPath="variableGroup" enablesFor="2+" id="org.eclipse.cdt.debug.internal.ui.actions.DisableVariablesActionDelegate"> @@ -844,8 +844,8 @@ label="%EnableVariablesAction.label" icon="icons/full/clcl16/enabled_co.gif" helpContextId="enable_variables_action_context" - tooltip="%EnableVariablesAction.tooltip" class="org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate" + tooltip="%EnableVariablesAction.tooltip" menubarPath="variableGroup" enablesFor="2+" id="org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate"> @@ -868,8 +868,8 @@ disabledIcon="icons/full/dlcl16/restart.gif" enablesFor="1" icon="icons/full/elcl16/restart.gif" - helpContextId="restart_action_context" label="%RestartAction.label" + helpContextId="restart_action_context" tooltip="%RestartAction.tooltip"> @@ -927,11 +927,11 @@ id="org.eclipse.cdt.debug.ui.breakpointView.menu"> @@ -953,8 +953,8 @@ disabledIcon="icons/full/dlcl16/watch_globals.gif" enablesFor="1" icon="icons/full/elcl16/watch_globals.gif" - helpContextId="add_globals_action_context" label="%AddGlobalsAction.label" + helpContextId="add_globals_action_context" tooltip="%AddGlobalsAction.tooltip"> @@ -1064,20 +1064,20 @@ @@ -1134,16 +1134,16 @@ point="org.eclipse.ui.editors"> @@ -1165,8 +1165,8 @@ + id="org.eclipse.cdt.debug.ui.debugging" + parentId="org.eclipse.debug.ui.debugging"> @@ -1244,8 +1244,8 @@ highlightPreferenceValue="true" presentationLayer="6" icon="icons/full/obj16/inst_ptr.gif" - label="%DisassemblySecondaryInstructionPointer" textPreferenceValue="false" + label="%DisassemblySecondaryInstructionPointer" textPreferenceKey="secondaryDisassemblyIPIndication" verticalRulerPreferenceKey="secondaryDisassemblyIPVerticalRuler" overviewRulerPreferenceKey="secondaryDisassemblyIPOverviewRuler"> @@ -1273,6 +1273,16 @@ type="org.eclipse.debug.ui.actions.IRunToLineTarget"> + + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties index a65abd42fa7..8b572fac8c4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties @@ -22,3 +22,4 @@ ToggleBreakpointAdapter.Empty_editor_2=Empty editor ToggleBreakpointAdapter.Missing_document_2=Missing document ToggleBreakpointAdapter.Missing_resource_2=Missing resource ToggleBreakpointAdapter.Invalid_expression_1=Invalid expression: +RunToLineAdapter.Operation_is_not_supported_1=Operation is not supported. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java index 6ee353e13f1..fc4da97a58c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java @@ -29,6 +29,6 @@ public class BreakpointLocationVerifier public int getValidAddressBreakpointLocation( IDocument doc, int lineNumber ) { // for now - return lineNumber; + return lineNumber + 1; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java index a4af1410a23..dd00243bbf9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java @@ -11,7 +11,10 @@ package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.model.IRunToAddress; import org.eclipse.cdt.debug.core.model.IRunToLine; +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.cdt.debug.ui.ICDebugUIConstants; import org.eclipse.core.runtime.CoreException; @@ -43,30 +46,52 @@ public class RunToLineAdapter implements IRunToLineTarget { * org.eclipse.debug.core.model.ISuspendResume) */ public void runToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException { - IEditorPart editorPart = (IEditorPart)part; - IEditorInput input = editorPart.getEditorInput(); String errorMessage = null; - if ( input == null ) { - errorMessage = ActionMessages.getString( "RunToLineAdapter.Empty_editor_1" ); //$NON-NLS-1$ - } - else { - final ITextEditor textEditor = (ITextEditor)editorPart; - final IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { - errorMessage = ActionMessages.getString( "RunToLineAdapter.Missing_document_1" ); //$NON-NLS-1$ + if ( part instanceof IEditorPart ) { + IEditorPart editorPart = (IEditorPart)part; + IEditorInput input = editorPart.getEditorInput(); + if ( input == null ) { + errorMessage = ActionMessages.getString( "RunToLineAdapter.Empty_editor_1" ); //$NON-NLS-1$ + } + else { + ITextEditor textEditor = (ITextEditor)editorPart; + IDocument document = textEditor.getDocumentProvider().getDocument( input ); + if ( document == null ) { + errorMessage = ActionMessages.getString( "RunToLineAdapter.Missing_document_1" ); //$NON-NLS-1$ + } + else { + String fileName = getFileName( input ); + ITextSelection textSelection = (ITextSelection)selection; + int lineNumber = textSelection.getStartLine() + 1; + if ( target instanceof IAdaptable ) { + IRunToLine runToLine = (IRunToLine)((IAdaptable)target).getAdapter( IRunToLine.class ); + if ( runToLine != null && runToLine.canRunToLine( fileName, lineNumber ) ) + runToLine.runToLine( fileName, lineNumber ); + } + return; + } + } + } + else if ( part instanceof DisassemblyView ) { + IEditorInput input = ((DisassemblyView)part).getInput(); + if ( !(input instanceof DisassemblyEditorInput) ) { + errorMessage = ActionMessages.getString( "RunToLineAdapter.Empty_editor_1" ); //$NON-NLS-1$ } else { - String fileName = getFileName( input ); ITextSelection textSelection = (ITextSelection)selection; int lineNumber = textSelection.getStartLine() + 1; + long address = ((DisassemblyEditorInput)input).getAddress( lineNumber ); if ( target instanceof IAdaptable ) { - IRunToLine runToLine = (IRunToLine)((IAdaptable)target).getAdapter( IRunToLine.class ); - if ( runToLine != null && runToLine.canRunToLine( fileName, lineNumber ) ) - runToLine.runToLine( fileName, lineNumber ); + IRunToAddress runToAddress = (IRunToAddress)((IAdaptable)target).getAdapter( IRunToAddress.class ); + if ( runToAddress != null && runToAddress.canRunToAddress( address ) ) + runToAddress.runToAddress( address ); } return; } } + else { + errorMessage = ActionMessages.getString( "RunToLineAdapter.Operation_is_not_supported_1" ); //$NON-NLS-1$ + } throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) ); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java index f0b52e0b190..1f67856e8e8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java @@ -11,8 +11,11 @@ package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint; +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.cdt.debug.ui.ICDebugUIConstants; import org.eclipse.core.resources.IResource; @@ -36,7 +39,6 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.ITextEditor; - /** * Toggles a line breakpoint in a C/C++ editor. */ @@ -46,49 +48,86 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) */ public void toggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException { - IEditorPart editorPart = (IEditorPart)part; - IEditorInput input = editorPart.getEditorInput(); String errorMessage = null; - if ( input == null ) { - errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Empty_editor_1" ); //$NON-NLS-1$ - } - else { - ITextEditor textEditor = (ITextEditor)editorPart; - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { - errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_document_1" ); //$NON-NLS-1$ + if ( part instanceof IEditorPart ) { + IEditorPart editorPart = (IEditorPart)part; + IEditorInput input = editorPart.getEditorInput(); + if ( input == null ) { + errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Empty_editor_1" ); //$NON-NLS-1$ } else { - IResource resource = getResource( textEditor ); - if ( resource == null ) { - errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_resource_1" ); //$NON-NLS-1$ + ITextEditor textEditor = (ITextEditor)editorPart; + IDocument document = textEditor.getDocumentProvider().getDocument( input ); + if ( document == null ) { + errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_document_1" ); //$NON-NLS-1$ } else { - BreakpointLocationVerifier bv = new BreakpointLocationVerifier(); - int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine() ); - if ( lineNumber == -1 ) { - errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$ + IResource resource = getResource( textEditor ); + if ( resource == null ) { + errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_resource_1" ); //$NON-NLS-1$ } else { - String sourceHandle = getSourceHandle( input ); - ICLineBreakpoint breakpoint = CDIDebugModel.lineBreakpointExists( sourceHandle, resource, lineNumber ); - if ( breakpoint != null ) { - DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); + BreakpointLocationVerifier bv = new BreakpointLocationVerifier(); + int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine() ); + if ( lineNumber == -1 ) { + errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$ } else { - CDIDebugModel.createLineBreakpoint( sourceHandle, - resource, - lineNumber, - true, - 0, - "", //$NON-NLS-1$ - true ); + String sourceHandle = getSourceHandle( input ); + ICLineBreakpoint breakpoint = CDIDebugModel.lineBreakpointExists( sourceHandle, resource, lineNumber ); + if ( breakpoint != null ) { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); + } + else { + CDIDebugModel.createLineBreakpoint( sourceHandle, + resource, + lineNumber, + true, + 0, + "", //$NON-NLS-1$ + true ); + } + return; } - return; } } } } + else if ( part instanceof DisassemblyView ) { + IEditorInput input = ((DisassemblyView)part).getInput(); + if ( !(input instanceof DisassemblyEditorInput) ) { + errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Empty_editor_1" ); //$NON-NLS-1$ + } + else { + BreakpointLocationVerifier bv = new BreakpointLocationVerifier(); + int lineNumber = bv.getValidAddressBreakpointLocation( null, ((ITextSelection)selection).getStartLine() ); + if ( lineNumber == -1 ) { + errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$ + } + else { + IResource resource = ResourcesPlugin.getWorkspace().getRoot(); + String sourceHandle = getSourceHandle( input ); + long address = ((DisassemblyEditorInput)input).getAddress( lineNumber ); + ICAddressBreakpoint breakpoint = CDIDebugModel.addressBreakpointExists( sourceHandle, resource, address ); + if ( breakpoint != null ) { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); + } + else { + CDIDebugModel.createAddressBreakpoint( sourceHandle, + resource, + address, + true, + 0, + "", //$NON-NLS-1$ + true ); + } + return; + } + } + } + else { + errorMessage = ActionMessages.getString( "RunToLineAdapter.Operation_is_not_supported_1" ); //$NON-NLS-1$ + } throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) ); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyEditorInput.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyEditorInput.java index 4569cf48e6d..a806c439b87 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyEditorInput.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyEditorInput.java @@ -129,6 +129,12 @@ public class DisassemblyEditorInput implements IEditorInput { } return 0; } + + public long getAddress( int lineNumber ) throws IllegalArgumentException { + if ( lineNumber > 0 && lineNumber <= fInstructions.length ) + return fInstructions[--lineNumber].getAdress(); + throw new IllegalArgumentException(); + } } public static final IEditorInput EMPTY_EDITOR_INPUT = new DisassemblyEditorInput(); @@ -217,4 +223,8 @@ public class DisassemblyEditorInput implements IEditorInput { public int getLineNumber( long address ) { return ( fStorage != null ) ? fStorage.getLineNumber( address ) : 0; } + + public long getAddress( int lineNumber ) throws IllegalArgumentException { + return ( fStorage != null ) ? fStorage.getAddress( lineNumber ) : 0; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java index 207be7333e6..2d5f2a478ab 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java @@ -146,6 +146,7 @@ public class DisassemblyView extends AbstractDebugEventHandlerView CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this ); getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + getSite().setSelectionProvider( viewer.getSelectionProvider() ); setEventHandler( createEventHandler() ); viewer.setDocument( getDocumentProvider().getDocument( DisassemblyEditorInput.EMPTY_EDITOR_INPUT ), getDocumentProvider().getAnnotationModel( null ) ); @@ -415,7 +416,7 @@ public class DisassemblyView extends AbstractDebugEventHandlerView return null; } - protected IEditorInput getInput() { + public IEditorInput getInput() { if ( getSourceViewer() != null ) { Object input = getSourceViewer().getInput(); if ( input instanceof IEditorInput ) @@ -568,6 +569,7 @@ public class DisassemblyView extends AbstractDebugEventHandlerView selectionChanged( null, new StructuredSelection() ); super.becomesHidden(); } + /* (non-Javadoc) * @see org.eclipse.debug.ui.AbstractDebugView#becomesVisible() */