mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 11:15:38 +02:00
Added support for breakpoint actions to the disassembly editor.
This commit is contained in:
parent
b4636c8a3c
commit
e9ac88667a
3 changed files with 94 additions and 0 deletions
|
@ -30,20 +30,25 @@ import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
|||
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
|
||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditor;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.viewer.VirtualDocument;
|
||||
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.disassembly.IElementToggleBreakpointAdapter;
|
||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
|
@ -151,6 +156,26 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ( part instanceof DisassemblyEditor && selection instanceof ITextSelection ) {
|
||||
DisassemblyEditor editor = (DisassemblyEditor)part;
|
||||
int lineNumber = ((ITextSelection)selection).getStartLine();
|
||||
if ( lineNumber != -1 ) {
|
||||
IEditorInput input = editor.getEditorInput();
|
||||
if ( input != null ) {
|
||||
VirtualDocument document = (VirtualDocument)editor.getDocumentProvider().getDocument( input );
|
||||
if ( document != null ) {
|
||||
IPresentationContext presentationContext = document.getPresentationContext();
|
||||
Object element = document.getElementAtLine( lineNumber );
|
||||
if ( element != null ) {
|
||||
IElementToggleBreakpointAdapter adapter = getToggleBreakpointAdapter( element );
|
||||
if ( adapter != null ) {
|
||||
adapter.toggleLineBreakpoints( presentationContext, element );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
errorMessage = ActionMessages.getString( "RunToLineAdapter.Operation_is_not_supported_1" ); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -168,6 +193,26 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else if ( part instanceof DisassemblyEditor && selection instanceof ITextSelection ) {
|
||||
DisassemblyEditor editor = (DisassemblyEditor)part;
|
||||
int lineNumber = ((ITextSelection)selection).getStartLine();
|
||||
if ( lineNumber != -1 ) {
|
||||
IEditorInput input = editor.getEditorInput();
|
||||
if ( input != null ) {
|
||||
VirtualDocument document = (VirtualDocument)editor.getDocumentProvider().getDocument( input );
|
||||
if ( document != null ) {
|
||||
IPresentationContext presentationContext = document.getPresentationContext();
|
||||
Object element = document.getElementAtLine( lineNumber );
|
||||
if ( element != null ) {
|
||||
IElementToggleBreakpointAdapter adapter = getToggleBreakpointAdapter( element );
|
||||
if ( adapter != null ) {
|
||||
return adapter.canToggleLineBreakpoints( presentationContext, element );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ( selection instanceof ITextSelection );
|
||||
}
|
||||
|
||||
|
@ -479,4 +524,16 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
|||
}
|
||||
return ResourcesPlugin.getWorkspace().getRoot();
|
||||
}
|
||||
|
||||
private IElementToggleBreakpointAdapter getToggleBreakpointAdapter( Object element ) {
|
||||
IElementToggleBreakpointAdapter adapter = null;
|
||||
if ( element instanceof IElementToggleBreakpointAdapter ) {
|
||||
adapter = (IElementToggleBreakpointAdapter)element;
|
||||
}
|
||||
else if ( element instanceof IAdaptable ) {
|
||||
IAdaptable adaptable = (IAdaptable)element;
|
||||
adapter = (IElementToggleBreakpointAdapter)adaptable.getAdapter( IElementToggleBreakpointAdapter.class );
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,10 @@ public class VirtualDocument extends Document {
|
|||
fCurrentOffset = offset;
|
||||
}
|
||||
|
||||
public Object getElementAtLine( int line ) {
|
||||
return getContentProvider().getElementAtLine( line );
|
||||
}
|
||||
|
||||
public void updateContent( int lineCount, int offset, boolean revealInput ) {
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 ARM Limited and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* ARM Limited - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.ui.disassembly;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
|
||||
/**
|
||||
* An adapter to support breakpoint creation/deletion for the disassembly editor.
|
||||
*
|
||||
* This interface is experimental.
|
||||
*/
|
||||
public interface IElementToggleBreakpointAdapter {
|
||||
|
||||
/**
|
||||
* Creates new line breakpoints or removes existing breakpoints for the given element.
|
||||
*/
|
||||
public void toggleLineBreakpoints( IPresentationContext presentationContext, Object element ) throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns whether line breakpoints can be toggled on the given element.
|
||||
*/
|
||||
public boolean canToggleLineBreakpoints( IPresentationContext presentationContext, Object element );
|
||||
}
|
Loading…
Add table
Reference in a new issue