Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorMikhail Khodjaiants2008-04-09 13:25:46 +0000
committerMikhail Khodjaiants2008-04-09 13:25:46 +0000
commite9ac88667a8bbac361fa66e05b1217f18ffaee56 (patch)
treeb8d22bd9fd924851827de33ce5918fff53bbf6c4 /debug
parentb4636c8a3c9c7a28adc170554bf425717c6a440c (diff)
downloadorg.eclipse.cdt-e9ac88667a8bbac361fa66e05b1217f18ffaee56.tar.gz
org.eclipse.cdt-e9ac88667a8bbac361fa66e05b1217f18ffaee56.tar.xz
org.eclipse.cdt-e9ac88667a8bbac361fa66e05b1217f18ffaee56.zip
Added support for breakpoint actions to the disassembly editor.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java57
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java4
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IElementToggleBreakpointAdapter.java33
3 files changed, 94 insertions, 0 deletions
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 9bd191f7b2..741f6718b5 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
@@ -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;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java
index 8f76504d5b..1de09659bc 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java
@@ -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 ) {
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IElementToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IElementToggleBreakpointAdapter.java
new file mode 100644
index 0000000000..de01a7555b
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IElementToggleBreakpointAdapter.java
@@ -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 );
+}

Back to the top