From 8c5477d2d07fb443940cec8606d3a43e3354d6b2 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 20 Oct 2009 09:14:17 +0000 Subject: [PATCH] [285225] [disassembly view] DSF Disassembly view does not respect selected breakpoint type --- .../META-INF/MANIFEST.MF | 5 +- dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml | 24 ++- .../DisassemblyToggleBreakpointsTarget.java | 153 ++++++++++++++++ .../gdb/internal/ui/breakpoints/Messages.java | 28 +++ .../ToggleBreakpointsTargetFactory.java | 74 ++++++++ .../ui/breakpoints/messages.properties | 13 ++ .../META-INF/MANIFEST.MF | 4 +- dsf/org.eclipse.cdt.dsf.ui/plugin.properties | 3 + dsf/org.eclipse.cdt.dsf.ui/plugin.xml | 14 ++ .../ui/disassembly/DisassemblyPart.java | 161 ++--------------- .../DisassemblySelectionProvider.java | 92 ++++++++++ .../actions/AbstractDisassemblyAction.java | 4 +- ...tractDisassemblyBreakpointRulerAction.java | 4 +- .../AbstractDisassemblyRulerAction.java | 4 +- ...bstractDisassemblyRulerActionDelegate.java | 4 +- .../actions/ActionGotoAddress.java | 4 +- .../actions/ActionGotoProgramCounter.java | 4 +- .../disassembly/actions/ActionGotoSymbol.java | 4 +- .../BreakpointPropertiesRulerAction.java | 5 +- ...eakpointPropertiesRulerActionDelegate.java | 4 +- .../RulerToggleBreakpointActionDelegate.java | 51 ++++++ .../actions/RulerToggleBreakpointHandler.java | 48 ++++++ .../provisional/DisassemblySelection.java | 163 ++++++++++++++++++ .../{ => provisional}/IDisassemblyPart.java | 9 +- .../provisional/IDisassemblySelection.java | 49 ++++++ 25 files changed, 758 insertions(+), 170 deletions(-) create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleBreakpointsTarget.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblySelectionProvider.java create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointActionDelegate.java create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointHandler.java create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblySelection.java rename dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/{ => provisional}/IDisassemblyPart.java (89%) create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/IDisassemblySelection.java diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF index cc40c0a188e..1d646d7f044 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF @@ -19,7 +19,10 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.ide, org.eclipse.core.variables, org.eclipse.core.expressions, - org.eclipse.ui.console + org.eclipse.ui.console, + org.eclipse.jface.text;bundle-version="3.4.0", + org.eclipse.ui.editors;bundle-version="3.4.0", + org.eclipse.core.filesystem;bundle-version="1.2.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.cdt.dsf.gdb.internal.ui.actions;x-internal:=true, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml index 9c9576c9076..6f1de54d020 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml @@ -186,7 +186,16 @@ name="Filter"> - + + + + + + + + @@ -703,5 +712,16 @@ class="org.eclipse.cdt.dsf.gdb.internal.ui.preferences.GdbPreferenceInitializer"> - + + + + + + + + + + diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleBreakpointsTarget.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleBreakpointsTarget.java new file mode 100644 index 00000000000..cf589a1cdea --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleBreakpointsTarget.java @@ -0,0 +1,153 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; + +import java.math.BigInteger; +import java.net.URI; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.model.ICBreakpointType; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection; +import org.eclipse.cdt.utils.Addr64; +import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.text.Position; +import org.eclipse.jface.text.source.IAnnotationModel; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.texteditor.SimpleMarkerAnnotation; + +/** + * Toggle breakpoint target implementation for the disassembly part. + */ +public class DisassemblyToggleBreakpointsTarget implements IToggleBreakpointsTargetExtension { + + public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + assert part instanceof IDisassemblyPart && selection instanceof ITextSelection; + + if (!(selection instanceof IDisassemblySelection)) { + selection = new DisassemblySelection((ITextSelection) selection, (IDisassemblyPart) part); + } + IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection; + int line = disassemblySelection.getStartLine(); + IBreakpoint[] bp = getBreakpointsAtLine((IDisassemblyPart) part, line); + if (bp == null || bp.length == 0) { + insertBreakpoint(disassemblySelection); + } else { + for (int i = 0; i < bp.length; i++) { + bp[i].delete(); + } + } + } + + public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) { + return part instanceof IDisassemblyPart && selection instanceof ITextSelection; + } + + public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + } + + public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) { + return false; + } + + public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + } + + public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) { + return false; + } + /* + * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension#canToggleBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) { + return canToggleLineBreakpoints(part, selection); + } + /* + * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension#toggleBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + toggleLineBreakpoints(part, selection); + } + + private IBreakpoint[] getBreakpointsAtLine(IDisassemblyPart part, int line) { + List breakpoints = new ArrayList(); + IAnnotationModel annotationModel = part.getTextViewer().getAnnotationModel(); + IDocument document = part.getTextViewer().getDocument(); + if (annotationModel != null) { + Iterator iterator = annotationModel.getAnnotationIterator(); + while (iterator.hasNext()) { + Object object = iterator.next(); + if (object instanceof SimpleMarkerAnnotation) { + SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object; + IMarker marker = markerAnnotation.getMarker(); + try { + if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { + Position position = annotationModel.getPosition(markerAnnotation); + int bpLine = document.getLineOfOffset(position.getOffset()); + if (line == bpLine) { + IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker); + if (breakpoint != null) { + breakpoints.add(breakpoint); + } + } + } + } catch (CoreException e) { + } catch (BadLocationException e) { + } + } + } + } + IBreakpoint[] breakpointsArray = new IBreakpoint[breakpoints.size()]; + return breakpoints.toArray(breakpointsArray ); + } + private void insertBreakpoint(IDisassemblySelection selection) throws CoreException { + BigInteger address = selection.getStartAddress(); + if (address == null) { + return; + } + URI fileUri = selection.getSourceLocationURI(); + if (fileUri != null) { + String filePath = null; + IResource resource = selection.getSourceFile(); + if (resource != null) { + final IPath location= resource.getLocation(); + if (location == null) { + return; + } + filePath = location.toOSString(); + } else { + resource = ResourcesPlugin.getWorkspace().getRoot(); + filePath = URIUtil.toPath(fileUri).toOSString(); + } + int srcLine = selection.getSourceLine(); + CDIDebugModel.createLineBreakpoint(filePath, resource, ICBreakpointType.REGULAR, srcLine + 1, true, 0, "", true); //$NON-NLS-1$ + } else { + IResource resource = ResourcesPlugin.getWorkspace().getRoot(); + CDIDebugModel.createAddressBreakpoint(null, null, resource, ICBreakpointType.REGULAR, new Addr64(address), true, 0, "", true); //$NON-NLS-1$ + } + } +} \ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java new file mode 100644 index 00000000000..82de3a8d337 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME= "org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints.messages"; //$NON-NLS-1$ + + public static String ToggleBreakpointsTargetFactory_description; + public static String ToggleBreakpointsTargetFactory_name; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java new file mode 100644 index 00000000000..e0f44950975 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Toggle breakpoints target factory for disassembly parts. + * + * @since 2.1 + */ +public class ToggleBreakpointsTargetFactory implements IToggleBreakpointsTargetFactory { + + /** + * Toggle breakpoint target-id for normal C breakpoints. + * Note: The id must be the same as in ToggleCBreakpointsTargetFactory + */ + public static final String TOGGLE_C_BREAKPOINT_TARGET_ID = CDebugUIPlugin.PLUGIN_ID + ".toggleCBreakpointTarget"; //$NON-NLS-1$ +// public static final String TOGGLE_C_TRACEPOINT_TARGET_ID = CDebugUIPlugin.PLUGIN_ID + ".toggleCTracepointTarget"; //$NON-NLS-1$ + + private static final Set TOGGLE_TARGET_IDS = new HashSet(2); + static { + TOGGLE_TARGET_IDS.add(TOGGLE_C_BREAKPOINT_TARGET_ID); +// TOGGLE_TARGET_IDS.add(TOGGLE_C_TRACEPOINT_TARGET_ID); + } + + private static final IToggleBreakpointsTarget fgDisassemblyToggleBreakpointsTarget = new DisassemblyToggleBreakpointsTarget(); + + public ToggleBreakpointsTargetFactory() { + } + + public IToggleBreakpointsTarget createToggleTarget(String targetID) { + if (TOGGLE_C_BREAKPOINT_TARGET_ID.equals(targetID)) { + return fgDisassemblyToggleBreakpointsTarget; + } + return null; + } + + public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) { + if (part instanceof IDisassemblyPart) { + return TOGGLE_C_BREAKPOINT_TARGET_ID; + } + return null; + } + + public String getToggleTargetDescription(String targetID) { + return Messages.ToggleBreakpointsTargetFactory_description; + } + + public String getToggleTargetName(String targetID) { + return Messages.ToggleBreakpointsTargetFactory_name; + } + + public Set getToggleTargets(IWorkbenchPart part, ISelection selection) { + return TOGGLE_TARGET_IDS; + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties new file mode 100644 index 00000000000..ef5a5d5c38b --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties @@ -0,0 +1,13 @@ +############################################################################### +# Copyright (c) 2009 Wind River Systems 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: +# Wind River Systems - initial API and implementation +############################################################################### + +ToggleBreakpointsTargetFactory_description=Standard C/C++ Breakpoint Type +ToggleBreakpointsTargetFactory_name=C/C++ Breakpoint diff --git a/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF b/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF index f65dbbd8cd5..952dd8fe927 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF +++ b/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF @@ -15,13 +15,13 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.5.0", org.eclipse.cdt.debug.ui;bundle-version="6.0.0", org.eclipse.jface.text;bundle-version="3.4.0", org.eclipse.ui.editors;bundle-version="3.4.0", - org.eclipse.ui.workbench.texteditor;bundle-version="3.4.0", org.eclipse.ui.ide;bundle-version="3.5.0", org.eclipse.cdt.ui;bundle-version="5.1.0", org.eclipse.core.expressions;bundle-version="3.4.0", org.eclipse.core.filesystem;bundle-version="1.2.0" Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.update.provisional;x-internal:=true, +Export-Package: org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional, + org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.update.provisional;x-internal:=true, org.eclipse.cdt.dsf.debug.ui, org.eclipse.cdt.dsf.debug.ui.actions, org.eclipse.cdt.dsf.debug.ui.contexts, diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties index 3587d60f3bd..c6bf0568ed3 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties +++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties @@ -23,12 +23,15 @@ command.gotoAddress.name=Go to Address... command.gotoAddress.description=Navigate to address command.gotoSymbol.name=Go to Symbol... command.gotoSymbol.description=Navigate to symbolic address +command.rulerToggleBreakpoint.name=Toggle Breakpoint +command.rulerToggleBreakpoint.description=Toggle breakpoint in disassembly ruler commandContext.name= In DSF Disassembly commandContext.description= When debugging in assembly mode # actions action.breakpointProperties.label = Breakpoint Properties... +action.toggleBreakpoint.label = Toggle Breakpoint menu.updatePolicy = Update Policy menu.threadsUpdatePolicy = Threads Update Policy diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml index 55a5523d7ac..fd03214480a 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml +++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml @@ -444,6 +444,13 @@ description="%command.gotoSymbol.description" id="org.eclipse.cdt.dsf.debug.ui.disassembly.commands.gotoSymbol" name="%command.gotoSymbol.name"/> + + @@ -512,6 +519,13 @@ label="%action.breakpointProperties.label" menubarPath="debug"> + + diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java index 140c682215d..e809e640037 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java @@ -23,9 +23,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; import org.eclipse.cdt.core.IAddress; -import org.eclipse.cdt.debug.core.CDIDebugModel; -import org.eclipse.cdt.debug.core.model.ICBreakpoint; -import org.eclipse.cdt.debug.core.model.ICBreakpointType; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DsfExecutor; import org.eclipse.cdt.dsf.concurrent.DsfRunnable; @@ -49,6 +46,7 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourceFileInfo; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourcePosition; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation.DisassemblyIPAnnotation; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.util.HSL; import org.eclipse.cdt.dsf.debug.service.IDisassembly; import org.eclipse.cdt.dsf.debug.service.IExpressions; @@ -76,15 +74,14 @@ import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession.SessionEndedListener; import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; import org.eclipse.cdt.internal.ui.dnd.TextViewerDragAdapter; -import org.eclipse.cdt.utils.Addr64; +import org.eclipse.core.commands.NotEnabledException; +import org.eclipse.core.commands.NotHandledException; +import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IStorage; -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.ListenerList; import org.eclipse.core.runtime.Platform; @@ -92,11 +89,8 @@ import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IBreakpointManager; import org.eclipse.debug.core.model.IBreakpoint; -import org.eclipse.debug.core.model.ISuspendResume; import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.actions.IRunToLineTarget; -import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IAction; @@ -116,7 +110,6 @@ import org.eclipse.jface.text.IFindReplaceTarget; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.ITextPresentationListener; -import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextViewerExtension; import org.eclipse.jface.text.IViewportListener; import org.eclipse.jface.text.Position; @@ -140,7 +133,6 @@ import org.eclipse.jface.text.source.OverviewRuler; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; @@ -169,7 +161,6 @@ import org.eclipse.ui.IActionBars; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchCommandConstants; -import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PlatformUI; @@ -223,7 +214,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem private static final String COMMAND_ID_GOTO_ADDRESS = "org.eclipse.cdt.dsf.debug.ui.disassembly.commands.gotoAddress"; //$NON-NLS-1$ private static final String COMMAND_ID_GOTO_PC = "org.eclipse.cdt.dsf.debug.ui.disassembly.commands.gotoPC"; //$NON-NLS-1$ private static final String COMMAND_ID_GOTO_SYMBOL = "org.eclipse.cdt.dsf.debug.ui.disassembly.commands.gotoSymbol"; //$NON-NLS-1$ -// private static final String COMMAND_ID_TOGGLE_BREAKPOINT = "org.eclipse.debug.ui.commands.ToggleBreakpoint"; //$NON-NLS-1$ + private static final String COMMAND_ID_TOGGLE_BREAKPOINT = "org.eclipse.cdt.dsf.debug.ui.disassembly.commands.rulerToggleBreakpoint"; //$NON-NLS-1$ // private static final String COMMAND_ID_RUN_TO_LINE = "org.eclipse.debug.ui.commands.RunToLine"; //$NON-NLS-1$ // private static final String COMMAND_ID_TOGGLE_STEPPING_MODE = "org.eclipse.cdt.dsf.debug.ui.debug.ui.menu.showDisassemblyAction"; //$NON-NLS-1$ @@ -234,7 +225,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem protected AbstractDisassemblyAction fActionGotoPC; protected AbstractDisassemblyAction fActionGotoAddress; private AbstractDisassemblyAction fActionGotoSymbol; - private AbstractDisassemblyAction fActionToggleBreakpoint; protected AbstractDisassemblyAction fActionToggleSource; private AbstractDisassemblyAction fActionToggleFunctionColumn; private AbstractDisassemblyAction fActionToggleSymbols; @@ -397,43 +387,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } } - private final class ActionToggleBreakpoint extends AbstractDisassemblyAction { - private IBreakpoint fBreakpoint; - private int fLine; - public ActionToggleBreakpoint() { - super(DisassemblyPart.this); - setText(DisassemblyMessages.Disassembly_action_AddBreakpoint_label); - setImageDescriptor(DisassemblyImageRegistry.getImageDescriptor(DisassemblyImageRegistry.ICON_ToggleBreakpoint)); - } - @Override - public void run() { - try { - if (fBreakpoint != null) { - fBreakpoint.delete(); - } else { - insertBreakpoint(fLine, false); - } - } catch (CoreException e) { - DsfUIPlugin.getDefault().getLog().log(e.getStatus()); - } - } - @Override - public void update() { - super.update(); - if (isEnabled()) { - fLine = fVerticalRuler.getLineOfLastMouseButtonActivity(); - IBreakpoint[] bps = getBreakpointsAtLine(fLine); - if (bps == null) { - fBreakpoint = null; - setText(DisassemblyMessages.Disassembly_action_AddBreakpoint_label); - } else { - fBreakpoint = bps[0]; - setText(DisassemblyMessages.Disassembly_action_RemoveBreakpoint_label); - } - } - } - } - private final class ActionToggleBreakpointEnablement extends AbstractDisassemblyAction { private IBreakpoint fBreakpoint; public ActionToggleBreakpointEnablement() { @@ -587,45 +540,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem public void gotoMarker(IMarker marker) { DisassemblyPart.this.gotoMarker(marker); }}; - } else if (IToggleBreakpointsTarget.class.equals(required)) { - return new IToggleBreakpointsTarget() { - public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { - ITextSelection textSelection = (ITextSelection)selection; - int line = textSelection.getStartLine(); - IBreakpoint[] bp = getBreakpointsAtLine(line); - if (bp == null || bp.length == 0) { - insertBreakpoint(line, false); - } else { - for (int i = 0; i < bp.length; i++) { - bp[i].delete(); - } - } - } - public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) { - return fDebugSessionId != null; - } - public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { - } - public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) { - return false; - } - public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException { - } - public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) { - return false; - }}; - } else if (IRunToLineTarget.class.equals(required)) { - return new IRunToLineTarget() { - public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException { -// ITextSelection textSelection = (ITextSelection)selection; -// int line = textSelection.getStartLine(); -// BigInteger address = getAddressOfLine(line); - // TLETODO [disassembly] run to line -// getRunControl().runUntil(...); - } - public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) { - return fTargetContext != null && isSuspended(fTargetContext) ; - }}; } return super.getAdapter(required); } @@ -1265,7 +1179,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem private void contributeToActionBars() { IWorkbenchPartSite site = getSite(); - site.setSelectionProvider(fViewer); + site.setSelectionProvider(new DisassemblySelectionProvider(this)); IContextService ctxService = (IContextService)site.getService(IContextService.class); fContextActivation = ctxService.activateContext(KEY_BINDING_CONTEXT_DISASSEMBLY); contributeToActionBars(getActionBars()); @@ -1315,14 +1229,12 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } protected void fillRulerContextMenu(IMenuManager manager) { - fActionToggleBreakpoint.update(); fActionToggleBreakpointEnablement.update(); fActionToggleAddressColumn.update(); fActionToggleFunctionColumn.update(); manager.add(new GroupMarker("group.top")); // ICommonMenuConstants.GROUP_TOP //$NON-NLS-1$ manager.add(new Separator("group.breakpoints")); //$NON-NLS-1$ - manager.add(fActionToggleBreakpoint); manager.add(fActionToggleBreakpointEnablement); manager.add(new GroupMarker("debug")); //$NON-NLS-1$ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); @@ -1397,15 +1309,20 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem fActionToggleSource = new ActionToggleSource(); fStateDependentActions.add(fActionToggleSource); - fActionToggleBreakpoint = new ActionToggleBreakpoint(); -// fActionToggleBreakpoint.setActionDefinitionId(COMMAND_ID_TOGGLE_BREAKPOINT); -// registerWithHandlerService(fActionToggleBreakpoint); fVerticalRuler.getControl().addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { - fActionToggleBreakpoint.update(); - if (fActionToggleBreakpoint.isEnabled()) { - fActionToggleBreakpoint.run(); + // invoke toggle breakpoint + IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class); + if (handlerService != null) { + try { + handlerService.executeCommand(COMMAND_ID_TOGGLE_BREAKPOINT, null); + } catch (org.eclipse.core.commands.ExecutionException exc) { + DsfUIPlugin.log(exc); + } catch (NotDefinedException exc) { + } catch (NotEnabledException exc) { + } catch (NotHandledException exc) { + } } } }); @@ -1413,8 +1330,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem fActionToggleAddressColumn = new ActionToggleAddressColumn(); fActionToggleFunctionColumn = new ActionToggleFunctionColumn(); fActionToggleSymbols = new ActionToggleSymbols(); -// fActionSourceSteppingMode.setActionDefinitionId(COMMAND_ID_TOGGLE_STEPPING_MODE); -// registerWithHandlerService(fActionSourceSteppingMode); fActionRefreshView = new ActionRefreshView(); fStateDependentActions.add(fActionRefreshView); fGlobalActions.put(ActionFactory.REFRESH.getId(), fActionRefreshView); @@ -3372,48 +3287,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } - private IBreakpoint insertBreakpoint(int line, boolean edit) throws CoreException { - SourcePosition srcPos = null; - try { - int lineOffset = fDocument.getLineOffset(line); - srcPos = fDocument.getSourcePosition(lineOffset); - } catch (BadLocationException e) { - // should not happen, but its safe to ignore anyway - } - - IResource resource; - ICBreakpoint bp; - - if (srcPos != null && srcPos.length > 0) { - SourceFileInfo srcInfo = srcPos.fFileInfo; - String filePath = null; - resource = (IResource)srcInfo.fFile.getAdapter(IResource.class); - if (resource != null) { - final IPath location= resource.getLocation(); - if (location == null) { - return null; - } - filePath = location.toOSString(); - } else { - resource = ResourcesPlugin.getWorkspace().getRoot(); - filePath = srcInfo.fFile.getFullPath().toOSString(); - } - BigInteger address = srcPos.fAddressOffset; - AddressRangePosition pos = fDocument.getDisassemblyPosition(address); - int srcLine = -1; - if (pos instanceof DisassemblyPosition) { - srcLine = ((DisassemblyPosition)pos).getLine(); - } - bp= CDIDebugModel.createLineBreakpoint(filePath, resource, ICBreakpointType.REGULAR, srcLine + 1, true, 0, "", true); //$NON-NLS-1$ - } else { - resource = ResourcesPlugin.getWorkspace().getRoot(); - BigInteger address = getAddressOfLine(line); - bp= CDIDebugModel.createAddressBreakpoint(null, null, resource, ICBreakpointType.REGULAR, new Addr64(address), true, 0, "", true); //$NON-NLS-1$ - } - - return bp; - } - private AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int lineNr) { Object sourceElement = null; if (fFile2Storage.containsKey(file)) { diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblySelectionProvider.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblySelectionProvider.java new file mode 100644 index 00000000000..e3cec114296 --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblySelectionProvider.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; + + +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection; +import org.eclipse.core.runtime.ListenerList; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; + +/** + * Selection provider for disassembly selections. + * Wraps the selection provider of the underlying text viewer and provides + * {@link IDisassemblySelection}s instead of {@link ITextSelection}s. + * + * @since 2.1 + * @see IDisassemblySelection + */ +class DisassemblySelectionProvider implements ISelectionProvider { + + private final ListenerList fListenerList = new ListenerList(ListenerList.IDENTITY); + private final ISelectionChangedListener fListener = new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + fireSelectionChanged(event); + } + }; + private final DisassemblyPart fPart; + + DisassemblySelectionProvider(DisassemblyPart disassemblyPart) { + fPart = disassemblyPart; + fPart.getTextViewer().getSelectionProvider().addSelectionChangedListener(fListener); + } + + private void fireSelectionChanged(SelectionChangedEvent event) { + SelectionChangedEvent newEvent = new SelectionChangedEvent(this, getSelection()); + Object[] listeners = fListenerList.getListeners(); + for (int i = 0; i < listeners.length; i++) { + ISelectionChangedListener listener = (ISelectionChangedListener) listeners[i]; + listener.selectionChanged(newEvent); + } + } + + /* + * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + public void addSelectionChangedListener(ISelectionChangedListener listener) { + fListenerList.add(listener); + } + + /* + * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() + */ + public ISelection getSelection() { + final ISourceViewer textViewer= fPart.getTextViewer(); + ISelectionProvider provider = textViewer.getSelectionProvider(); + if (provider != null) { + return new DisassemblySelection((ITextSelection) provider.getSelection(), fPart); + } + return StructuredSelection.EMPTY; + } + + /* + * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + fListenerList.remove(listener); + } + + /* + * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) + */ + public void setSelection(ISelection selection) { + ISelectionProvider provider = fPart.getTextViewer().getSelectionProvider(); + if (provider != null) { + provider.setSelection(selection); + } + } +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyAction.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyAction.java index 81b935133c0..c3e6dad0076 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyAction.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.action.Action; import org.eclipse.ui.IPropertyListener; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyBreakpointRulerAction.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyBreakpointRulerAction.java index 1a3ad778b39..919a292d8bf 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyBreakpointRulerAction.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyBreakpointRulerAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -12,7 +12,7 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; import java.util.Iterator; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugPlugin; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyRulerAction.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyRulerAction.java index d5af5e28b04..614c76da71f 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyRulerAction.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyRulerAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IVerticalRulerInfo; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyRulerActionDelegate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyRulerActionDelegate.java index 91aafa31b32..261a6ebeea8 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyRulerActionDelegate.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AbstractDisassemblyRulerActionDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoAddress.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoAddress.java index 2b9a597ef15..9002f0fc7e1 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoAddress.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoAddress.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -14,7 +14,7 @@ import java.math.BigInteger; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IInputValidator; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoProgramCounter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoProgramCounter.java index 5dfddfb633e..df5d4b9ed30 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoProgramCounter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoProgramCounter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -11,7 +11,7 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; public final class ActionGotoProgramCounter extends AbstractDisassemblyAction { public ActionGotoProgramCounter(IDisassemblyPart disassemblyPart) { diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoSymbol.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoSymbol.java index 893970968b7..aadb868dcf5 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoSymbol.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/ActionGotoSymbol.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -11,7 +11,7 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; import org.eclipse.cdt.internal.ui.text.CWordFinder; import org.eclipse.jface.dialogs.IDialogConstants; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerAction.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerAction.java index 4aab7e44ea2..6b1bb3df579 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerAction.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -13,7 +13,7 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.internal.ui.CBreakpointContext; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.jface.text.source.IVerticalRulerInfo; @@ -26,6 +26,7 @@ import org.eclipse.ui.dialogs.PropertyDialogAction; /** * Ruler action to display breakpoint properties. */ +@SuppressWarnings("restriction") public class BreakpointPropertiesRulerAction extends AbstractDisassemblyBreakpointRulerAction { private Object fContext; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerActionDelegate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerActionDelegate.java index b5589d0d4f3..e3736b739b4 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerActionDelegate.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerActionDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; -import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.source.IVerticalRulerInfo; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointActionDelegate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointActionDelegate.java new file mode 100644 index 00000000000..13506b449cd --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointActionDelegate.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; + +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; +import org.eclipse.debug.ui.actions.ToggleBreakpointAction; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.source.IVerticalRulerInfo; + +/** + * Ruler toggle breakpoint action delegate for disassembly parts. + * + * @since 2.1 + * + * @see org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate + */ +public class RulerToggleBreakpointActionDelegate extends AbstractDisassemblyRulerActionDelegate { + + private ToggleBreakpointAction fDelegate; + + /* + * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AbstractDisassemblyRulerActionDelegate#createAction(org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart, org.eclipse.jface.text.source.IVerticalRulerInfo) + */ + @Override + protected IAction createAction(IDisassemblyPart disassemblyPart, IVerticalRulerInfo rulerInfo) { + if (fDelegate != null) { + fDelegate.dispose(); + } + return fDelegate = new ToggleBreakpointAction(disassemblyPart, disassemblyPart.getTextViewer().getDocument(), rulerInfo); + } + + /* + * @see org.eclipse.ui.actions.ActionDelegate#dispose() + */ + @Override + public void dispose() { + if (fDelegate != null) { + fDelegate.dispose(); + fDelegate = null; + } + super.dispose(); + } +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointHandler.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointHandler.java new file mode 100644 index 00000000000..398d68504a5 --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointHandler.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; + +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.debug.ui.actions.ToggleBreakpointAction; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * Default handler for the toggle breakpoint command in the disassembly ruler. + * Invoked on double click in the ruler. + * + * @since 2.1 + */ +public class RulerToggleBreakpointHandler extends AbstractHandler { + + public Object execute(ExecutionEvent event) throws ExecutionException { + IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); + if (part instanceof IDisassemblyPart) { + IDisassemblyPart disassemblyPart = (IDisassemblyPart) part; + IDocument document = disassemblyPart.getTextViewer().getDocument(); + final IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) part.getAdapter(IVerticalRulerInfo.class); + if (rulerInfo != null) { + final ToggleBreakpointAction toggleBpAction= new ToggleBreakpointAction(part, document, rulerInfo); + toggleBpAction.update(); + if (toggleBpAction.isEnabled()) { + toggleBpAction.run(); + } + } + } + return null; + } + +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblySelection.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblySelection.java new file mode 100644 index 00000000000..49453b13ecb --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblySelection.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional; + +import java.math.BigInteger; +import java.net.URI; + +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyPosition; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourcePosition; +import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IStorage; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.ITextSelection; + +/** + * Default implementation of {@link IDisassemblySelection}. + * + * @since 2.1 + * @noextend This class is not intended to be subclassed by clients. + */ +public class DisassemblySelection implements IDisassemblySelection { + + private final ITextSelection fTextSelection; + private IStorage fSourceFile; + private int fSourceLine; + private BigInteger fStartAddress; + + /** + * Create a disassembly selection from a normal text selection and a disassembly part. + * + * @param selection the text selection + * @param part the disassembly part + */ + public DisassemblySelection(ITextSelection selection, IDisassemblyPart part) { + this(selection, (DisassemblyDocument) part.getTextViewer().getDocument()); + } + + DisassemblySelection(ITextSelection selection, DisassemblyDocument document) { + fTextSelection = selection; + int offset = selection.getOffset(); + SourcePosition sourcePosition; + try { + sourcePosition = document.getSourcePosition(offset); + } catch (BadLocationException exc) { + sourcePosition = null; + } + if (sourcePosition != null) { + fStartAddress = sourcePosition.fAddressOffset; + if (sourcePosition.length > 0) { + fSourceFile = sourcePosition.fFileInfo.fFile; + DisassemblyPosition pos = (DisassemblyPosition) document.getDisassemblyPosition(fStartAddress); + if (pos != null) { + fSourceLine = pos.getLine(); + } + } + } else { + fStartAddress = document.getAddressOfOffset(offset); + } + } + + /* + * @see org.eclipse.jface.viewers.ISelection#isEmpty() + */ + public boolean isEmpty() { + return fTextSelection.isEmpty(); + } + + /* + * @see org.eclipse.jface.text.ITextSelection#getEndLine() + */ + public int getEndLine() { + return fTextSelection.getEndLine(); + } + + /* + * @see org.eclipse.jface.text.ITextSelection#getLength() + */ + public int getLength() { + return fTextSelection.getLength(); + } + + /* + * @see org.eclipse.jface.text.ITextSelection#getOffset() + */ + public int getOffset() { + return fTextSelection.getOffset(); + } + + /* + * @see org.eclipse.jface.text.ITextSelection#getStartLine() + */ + public int getStartLine() { + return fTextSelection.getStartLine(); + } + + /* + * @see org.eclipse.jface.text.ITextSelection#getText() + */ + public String getText() { + return fTextSelection.getText(); + } + + /* + * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection#getSourceFile() + */ + public IFile getSourceFile() { + if (fSourceFile != null) { + IResource resource = (IResource) fSourceFile.getAdapter(IResource.class); + if (resource instanceof IFile) { + return (IFile) resource; + } + } + return null; + } + + /* + * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection#getSourceLine() + */ + public int getSourceLine() { + if (fSourceFile != null) { + return fSourceLine; + } + return -1; + } + + /* + * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection#getSourceLocationURI() + */ + public URI getSourceLocationURI() { + if (fSourceFile != null) { + IResource resource = (IResource) fSourceFile.getAdapter(IResource.class); + if (resource instanceof IFile) { + return resource.getLocationURI(); + } else { + IPath location = fSourceFile.getFullPath(); + if (location != null) { + return URIUtil.toURI(location); + } + } + } + return null; + } + + /* + * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection#getStartAddress() + */ + public BigInteger getStartAddress() { + return fStartAddress; + } + +} \ No newline at end of file diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/IDisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/IDisassemblyPart.java similarity index 89% rename from dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/IDisassemblyPart.java rename to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/IDisassemblyPart.java index 5b6b2ebe380..bcbbcc132e9 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/IDisassemblyPart.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/IDisassemblyPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. 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 @@ -8,8 +8,7 @@ * Contributors: * Anton Leherbauer (Wind River Systems) - initial API and implementation *******************************************************************************/ - -package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional; import java.math.BigInteger; @@ -19,6 +18,10 @@ import org.eclipse.ui.IWorkbenchPart; /** * Interface which the disassembly view and editor implement. + * + * @since 2.1 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. */ public interface IDisassemblyPart extends IWorkbenchPart { diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/IDisassemblySelection.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/IDisassemblySelection.java new file mode 100644 index 00000000000..b206df6879c --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/IDisassemblySelection.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional; + +import java.math.BigInteger; +import java.net.URI; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.text.ITextSelection; + +/** + * This interface represents a selection in a {@link IDisassemblyPart}. + * In addition to text selection attributes this interface provides information + * about the address and source file position for the start offset of the selection. + * + * @since 2.1 + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface IDisassemblySelection extends ITextSelection { + + /** + * @return the address associated with the start of the selection + */ + BigInteger getStartAddress(); + + /** + * @return the {@link IFile} associated with the selection, may be null + */ + IFile getSourceFile(); + + /** + * @return the source location {@link URI} of the associated source file, may be null + */ + URI getSourceLocationURI(); + + /** + * @return the 0-based line number of the source file associated with the selection, -1 if not available + */ + int getSourceLine(); +}