1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

Implementing retargettable actions for Disassembly view.

This commit is contained in:
Mikhail Khodjaiants 2004-04-16 21:45:24 +00:00
parent a2189ff379
commit ce956c49b8
8 changed files with 180 additions and 83 deletions

View file

@ -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

View file

@ -87,8 +87,8 @@
<view
relative="org.eclipse.debug.ui.VariableView"
visible="false"
relationship="stack"
id="org.eclipse.cdt.debug.ui.MemoryView">
id="org.eclipse.cdt.debug.ui.MemoryView"
relationship="stack">
</view>
<viewShortcut
id="org.eclipse.cdt.debug.ui.MemoryView">
@ -96,8 +96,8 @@
<view
relative="org.eclipse.debug.ui.VariableView"
visible="false"
relationship="stack"
id="org.eclipse.cdt.debug.ui.SharedLibrariesView">
id="org.eclipse.cdt.debug.ui.SharedLibrariesView"
relationship="stack">
</view>
<viewShortcut
id="org.eclipse.cdt.debug.ui.SharedLibrariesView">
@ -105,8 +105,8 @@
<view
relative="org.eclipse.debug.ui.VariableView"
visible="false"
relationship="stack"
id="org.eclipse.cdt.debug.ui.SignalsView">
id="org.eclipse.cdt.debug.ui.SignalsView"
relationship="stack">
</view>
<viewShortcut
id="org.eclipse.cdt.debug.ui.SignalsView">
@ -117,8 +117,8 @@
<view
relative="org.eclipse.ui.views.ContentOutline"
visible="false"
relationship="stack"
id="org.eclipse.cdt.debug.ui.DisassemblyView">
id="org.eclipse.cdt.debug.ui.DisassemblyView"
relationship="stack">
</view>
<viewShortcut
id="org.eclipse.cdt.debug.ui.DisassemblyView">
@ -290,8 +290,8 @@
</action>
<action
label="%SwitchToDisassemblyAction.label"
style="toggle"
icon="icons/full/clcl16/disassembly.gif"
style="toggle"
helpContextId="switch_to_disassembly_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.SwitchToDisassemblyActionDelegate"
menubarPath="renderGroup"
@ -686,8 +686,8 @@
label="%LoadSymbolsAction.label"
icon="icons/full/clcl16/load_symbols_co.gif"
helpContextId="load_symbols_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate"
tooltip="%LoadSymbolsAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate"
menubarPath="sharedLibrariesGroup"
enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate">
@ -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">
<enablement>
@ -759,8 +759,8 @@
<action
label="%RestoreDefaultTypeAction.label"
helpContextId="restore_default_type_action_context"
tooltip="%RestoreDefaultTypeAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate"
tooltip="%RestoreDefaultTypeAction.tooltip"
menubarPath="additions"
enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate">
@ -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">
<enablement>
<pluginState
@ -887,8 +887,8 @@
disabledIcon="icons/full/dlcl16/disassembly.gif"
enablesFor="1"
icon="icons/full/elcl16/disassembly.gif"
helpContextId="switch_to_disassembly_action_context"
label="%SwitchToDisassemblyAction.label"
helpContextId="switch_to_disassembly_action_context"
tooltip="%SwitchToDisassemblyAction.tooltip">
<enablement>
<pluginState
@ -903,11 +903,11 @@
id="org.eclipse.cdt.debug.ui.debugView.menu">
<action
label="%ShowFullPathsAction.label"
icon="icons/full/clcl16/show_paths.gif"
style="toggle"
icon="icons/full/clcl16/show_paths.gif"
helpContextId="show_full_paths_context"
tooltip="%ShowFullPathsAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
tooltip="%ShowFullPathsAction.tooltip"
menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
<enablement>
@ -927,11 +927,11 @@
id="org.eclipse.cdt.debug.ui.breakpointView.menu">
<action
label="%ShowFullPathsAction.label"
icon="icons/full/clcl16/show_paths.gif"
style="toggle"
icon="icons/full/clcl16/show_paths.gif"
helpContextId="show_full_paths_context"
tooltip="%ShowFullPathsAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
tooltip="%ShowFullPathsAction.tooltip"
menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
<enablement>
@ -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">
<enablement>
<pluginState
@ -969,11 +969,11 @@
id="org.eclipse.debug.ui.sharedLibrariesView.menu">
<action
label="%ShowFullPathsAction.label"
style="toggle"
icon="icons/full/clcl16/show_paths.gif"
style="toggle"
helpContextId="show_full_paths_context"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
tooltip="%ShowFullPathsAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
<enablement>
@ -1064,20 +1064,20 @@
<extension
point="org.eclipse.debug.core.statusHandlers">
<statusHandler
plugin="org.eclipse.cdt.debug.core"
code="10000"
plugin="org.eclipse.cdt.debug.core"
class="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler">
</statusHandler>
<statusHandler
plugin="org.eclipse.cdt.debug.core"
code="10001"
plugin="org.eclipse.cdt.debug.core"
class="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler">
</statusHandler>
<statusHandler
plugin="org.eclipse.cdt.debug.core"
code="10002"
plugin="org.eclipse.cdt.debug.core"
class="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler">
</statusHandler>
@ -1134,16 +1134,16 @@
point="org.eclipse.ui.editors">
<editor
name="%DisassemblyEditor.name"
icon="icons/full/obj16/disassembly_obj.gif"
extensions="dasm"
icon="icons/full/obj16/disassembly_obj.gif"
class="org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditor"
id="org.eclipse.cdt.debug.ui.DisassemblyEditor">
</editor>
<editor
name="%CDebugEditor.name"
icon="icons/full/obj16/filenotfound_obj.gif"
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
class="org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor"
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
id="org.eclipse.cdt.debug.ui.editor.CDebugEditor">
</editor>
</extension>
@ -1165,8 +1165,8 @@
<context
name="Debugging C/C++"
description="Debugging C/C++ Programs"
parentId="org.eclipse.debug.ui.debugging"
id="org.eclipse.cdt.debug.ui.debugging">
id="org.eclipse.cdt.debug.ui.debugging"
parentId="org.eclipse.debug.ui.debugging">
</context>
</extension>
<extension
@ -1198,8 +1198,8 @@
<extension
point="org.eclipse.ui.editors.annotationTypes">
<type
markerType="org.eclipse.cdt.debug.core.cBreakpointMarker"
super="org.eclipse.debug.core.breakpoint"
markerType="org.eclipse.cdt.debug.core.cBreakpointMarker"
name="org.eclipse.cdt.debug.core.breakpoint">
</type>
<type
@ -1228,8 +1228,8 @@
highlightPreferenceValue="true"
presentationLayer="6"
icon="icons/full/obj16/inst_ptr_top.gif"
label="%DisassemblyCurrentInstructionPointer"
textPreferenceValue="false"
label="%DisassemblyCurrentInstructionPointer"
textPreferenceKey="currentDisassemblyIPIndication"
verticalRulerPreferenceKey="currentDisassemblyIPVerticalRuler"
overviewRulerPreferenceKey="currentDisassemblyIPOverviewRuler">
@ -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">
</adapter>
</factory>
<factory
adaptableType="org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView"
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory">
<adapter
type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
</adapter>
<adapter
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
</adapter>
</factory>
</extension>
</plugin>

View file

@ -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.

View file

@ -29,6 +29,6 @@ public class BreakpointLocationVerifier
public int getValidAddressBreakpointLocation( IDocument doc, int lineNumber )
{
// for now
return lineNumber;
return lineNumber + 1;
}
}

View file

@ -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 ) );
}

View file

@ -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 ) );
}

View file

@ -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;
}
}

View file

@ -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()
*/