1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 360588 - [breakpoints] Allow user to edit all its properties

prior to creating the breakpoint.

- Added support for double-click action modifiers in the Disassembly
view.
- Added an "Add Breakpoint..." action to the Disassembly view as
well.
- Converted the Breakpoints view's "Add Watchpoint (C/C++)" action
to use a full breakpoint properties dialog when creating a watchpoint.
- Added an "Add Function Breakpoint (C/C++)" action to the
Breakpoints view.  The action opens the full properties dialog and
allows user to enter the function name.
This commit is contained in:
Pawel Piech 2012-03-16 15:45:09 -07:00
parent bfdf65cacd
commit dd069579ac
26 changed files with 819 additions and 172 deletions

View file

@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.cdt.debug.ui.CDebugUIPlugin
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Bundle-Localization: plugin Bundle-Localization: plugin
Export-Package: Export-Package:
org.eclipse.cdt.debug.internal.ui;x-internal:=true, org.eclipse.cdt.debug.internal.ui;x-internal:x-friends:="org.eclipse.cdt.dsf.ui";x-friends:="org.eclipse.cdt.dsf.ui",
org.eclipse.cdt.debug.internal.ui.actions;x-friends:="org.eclipse.cdt.dsf.ui,org.eclipse.cdt.debug.ui.memory.memorybrowser", org.eclipse.cdt.debug.internal.ui.actions;x-friends:="org.eclipse.cdt.dsf.ui,org.eclipse.cdt.debug.ui.memory.memorybrowser",
org.eclipse.cdt.debug.internal.ui.actions.breakpoints;x-internal:=true, org.eclipse.cdt.debug.internal.ui.actions.breakpoints;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.breakpoints;x-internal:=true, org.eclipse.cdt.debug.internal.ui.breakpoints;x-internal:=true,

View file

@ -58,6 +58,8 @@ AddWatchpoint.label=Add Watchpoint (C/C++)...
AddWatchpoint.tooltip=Add Watchpoint (C/C++) AddWatchpoint.tooltip=Add Watchpoint (C/C++)
AddEventBreakpoint.label=Add Event Breakpoint (C/C++)... AddEventBreakpoint.label=Add Event Breakpoint (C/C++)...
AddEventBreakpoint.tooltip=Add Event Breakpoint (C/C++) AddEventBreakpoint.tooltip=Add Event Breakpoint (C/C++)
AddFunctionBreakpoint.label=Add Function Breakpoint (C/C++)...
AddFunctionBreakpoint.tooltip=Add Function Breakpoint (C/C++)
AddGlobalsAction.label=Add Global Variables... AddGlobalsAction.label=Add Global Variables...
AddGlobalsAction.tooltip=Add Global Variables AddGlobalsAction.tooltip=Add Global Variables

View file

@ -970,6 +970,15 @@
style="push" style="push"
tooltip="%AddEventBreakpoint.tooltip"> tooltip="%AddEventBreakpoint.tooltip">
</action> </action>
<action
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.AddFunctionBreakpointActionDelegate"
icon="icons/elcl16/function_brkpt_co.gif"
id="org.eclipse.cdt.debug.ui.addFunctionBreakpoint"
label="%AddFunctionBreakpoint.label"
menubarPath="cDebugActions"
style="push"
helpContextId="add_function_breakpoint_action_context"
tooltip="%AddFunctionBreakpoint.tooltip"/>
</viewContribution> </viewContribution>
<viewContribution <viewContribution
targetID="org.eclipse.debug.ui.VariableView" targetID="org.eclipse.debug.ui.VariableView"

View file

@ -37,11 +37,10 @@ ToggleBreakpointAdapter.Missing_document_2=Missing document
ToggleBreakpointAdapter.Missing_resource_2=Missing resource ToggleBreakpointAdapter.Missing_resource_2=Missing resource
ToggleBreakpointAdapter.Invalid_expression_1=Invalid expression: ToggleBreakpointAdapter.Invalid_expression_1=Invalid expression:
RunToLineAdapter.Operation_is_not_supported_1=Operation is not supported. RunToLineAdapter.Operation_is_not_supported_1=Operation is not supported.
EnableDisableBreakpointRulerAction.Enable_Breakpoint_1=&Enable Breakpoint EnableDisableBreakpointRulerAction.Enable_Breakpoint_1=&Enable Breakpoint\tShift+Double Click
EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1=Enabling/disabling breakpoints EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1=Enabling/disabling breakpoints
EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1=Exceptions occurred enabling or disabling the breakpoint EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1=Exceptions occurred enabling or disabling the breakpoint
EnableDisableBreakpointRulerAction.Disable_Breakpoint_1=&Disable Breakpoint EnableDisableBreakpointRulerAction.Disable_Breakpoint_1=&Disable Breakpoint\tShift+Double Click
ToggleBreakpointRulerAction.Toggle_Breakpoint_1=Toggle &Breakpoint
ToggleWatchpointActionDelegate.Operation_failed_1=Operation failed. ToggleWatchpointActionDelegate.Operation_failed_1=Operation failed.
ToggleBreakpointRulerAction.Error_1=Error ToggleBreakpointRulerAction.Error_1=Error
ToggleBreakpointRulerAction.Operation_failed_1=Operation failed ToggleBreakpointRulerAction.Operation_failed_1=Operation failed

View file

@ -0,0 +1,75 @@
/*******************************************************************************
* Copyright (c) 2004, 2007-7 QNX Software 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:
* QNX Software Systems - Initial API and implementation
* Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions.breakpoints;
import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionDelegate;
/**
* A delegate for the "Add Function Breakpoint" action.
*/
public class AddFunctionBreakpointActionDelegate extends ActionDelegate implements IViewActionDelegate {
private IViewPart fView;
private ISelection fSelection;
private ToggleBreakpointAdapter fDefaultToggleTarget = new ToggleBreakpointAdapter();
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
@Override
public void init( IViewPart view ) {
setView( view );
}
private void setView(IViewPart view) {
fView = view;
}
protected IViewPart getView() {
return fView;
}
@Override
public void selectionChanged(IAction action, ISelection selection) {
fSelection = selection;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run( IAction action ) {
IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fView, fSelection);
IToggleBreakpointsTargetCExtension cToggleTarget = null;
if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) {
cToggleTarget = (IToggleBreakpointsTargetCExtension)toggleTarget;
} else {
cToggleTarget = fDefaultToggleTarget;
}
try {
cToggleTarget.createFunctionBreakpointInteractive(fView, fSelection);
} catch (CoreException e) {
CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate1.0" ), e ); //$NON-NLS-1$
}
}
}

View file

@ -76,16 +76,10 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView
} }
try { try {
cToggleTarget.createWatchpoingsInteractive(fView, fSelection); cToggleTarget.createWatchpointsInteractive(fView, fSelection);
} catch (CoreException e) { } catch (CoreException e) {
// TODO Auto-generated catch block CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate1.0" ), e ); //$NON-NLS-1$
e.printStackTrace();
} }
// AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), getMemorySpaceManagement() );
// if ( dlg.open() == Window.OK ) {
// addWatchpoint( dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange() );
// }
} }
protected void addWatchpoint(boolean write, boolean read, String expression, String memorySpace, BigInteger range) { protected void addWatchpoint(boolean write, boolean read, String expression, String memorySpace, BigInteger range) {

View file

@ -45,6 +45,7 @@ import org.eclipse.swt.widgets.Text;
/** /**
* The "Add Watchpoint" dialog of the "Toggle watchpoint" action. * The "Add Watchpoint" dialog of the "Toggle watchpoint" action.
* @deprecated Replaced by opening a properties dialog on a new breakpoint.
*/ */
public class AddWatchpointDialog extends Dialog implements ModifyListener, SelectionListener { public class AddWatchpointDialog extends Dialog implements ModifyListener, SelectionListener {

View file

@ -97,8 +97,8 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd
DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, selection); DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, selection);
if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) {
IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) toggleTarget; IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) toggleTarget;
if (extension.canCreateBreakpointsInteractive(fPart, selection)) { if (extension.canCreateLineBreakpointsInteractive(fPart, selection)) {
extension.createBreakpointsInteractive(fPart, selection); extension.createLineBreakpointsInteractive(fPart, selection);
} }
} }
} catch (BadLocationException e) { } catch (BadLocationException e) {
@ -177,7 +177,7 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd
} }
if (adapter instanceof IToggleBreakpointsTargetCExtension) { if (adapter instanceof IToggleBreakpointsTargetCExtension) {
IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) adapter; IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) adapter;
if (extension.canCreateBreakpointsInteractive(fPart, selection)) { if (extension.canCreateLineBreakpointsInteractive(fPart, selection)) {
setEnabled(true); setEnabled(true);
return; return;
} }

View file

@ -37,9 +37,9 @@ public class CToggleMethodBreakpointActionDelegate extends CToggleBreakpointObje
{ {
if ((event.stateMask & SWT.MOD1) != 0 && if ((event.stateMask & SWT.MOD1) != 0 &&
target instanceof IToggleBreakpointsTargetCExtension && target instanceof IToggleBreakpointsTargetCExtension &&
((IToggleBreakpointsTargetCExtension)target).canCreateBreakpointsInteractive(part, selection)) ((IToggleBreakpointsTargetCExtension)target).canCreateLineBreakpointsInteractive(part, selection))
{ {
((IToggleBreakpointsTargetCExtension)target).createBreakpointsInteractive(part, selection); ((IToggleBreakpointsTargetCExtension)target).createLineBreakpointsInteractive(part, selection);
} }
else { else {
target.toggleMethodBreakpoints(part, selection); target.toggleMethodBreakpoints(part, selection);

View file

@ -91,20 +91,11 @@ public class ToggleBreakpointAdapter extends AbstractToggleBreakpointAdapter {
protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource,
int charStart, int charEnd, int lineNumber, String expression) throws CoreException int charStart, int charEnd, int lineNumber, String expression) throws CoreException
{ {
// AddWatchpointDialog dlg = new AddWatchpointDialog(part.getSite().getShell(), getMemorySpaceManagement() ); ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint();
// dlg.setExpression( expression ); Map<String, Object> attributes = new HashMap<String, Object>();
// if ( dlg.open() != Window.OK ) CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false,
// return; expression, "", new BigInteger("0"), true, 0, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// expression = dlg.getExpression(); openBreakpointPropertiesDialog(bp, part, resource, attributes);
// CDIDebugModel.createWatchpoint(sourceHandle, resource, charStart, charEnd, lineNumber, dlg.getWriteAccess(),
// dlg.getReadAccess(), expression, dlg.getMemorySpace(), dlg.getRange(), true, 0, "", true); //$NON-NLS-1$
if (interactive) {
ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint();
Map<String, Object> attributes = new HashMap<String, Object>();
CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false,
expression, "", new BigInteger("0"), true, 0, ""); //$NON-NLS-1$
openBreakpointPropertiesDialog(bp, part, resource, attributes);
}
} }
protected int getBreakpointType() { protected int getBreakpointType() {

View file

@ -12,26 +12,29 @@
############################################################################### ###############################################################################
CBreakpointPropertyPage.0=Ignore count must be a nonnegative integer CBreakpointPropertyPage.0=Ignore count must be a nonnegative integer
CBreakpointPropertyPage.1=Not available CBreakpointPropertyPage.function_valueNotAvailable_label=Not available
CBreakpointPropertyPage.function_label=Function name: CBreakpointPropertyPage.function_label=Function name:
CBreakpointPropertyPage.3=C/C++ function breakpoint CBreakpointPropertyPage.function_value_errorMessage=Enter a function expression:
CBreakpointPropertyPage.4=Not available CBreakpointPropertyPage.breakpointType_function_label=C/C++ Function Breakpoint
CBreakpointPropertyPage.address_valueNotAvailable_label=Not available
CBreakpointPropertyPage.address_label=Address: CBreakpointPropertyPage.address_label=Address:
CBreakpointPropertyPage.6=C/C++ address breakpoint CBreakpointPropertyPage.breakpointType_address_label=C/C++ Address Breakpoint
CBreakpointPropertyPage.7=File: CBreakpointPropertyPage.sourceHandle_label=File:
CBreakpointPropertyPage.8=C/C++ line breakpoint CBreakpointPropertyPage.breakpointType_line_label=C/C++ Line Breakpoint
CBreakpointPropertyPage.9=Line number: CBreakpointPropertyPage.lineNumber_label=Line number:
CBreakpointPropertyPage.10=Project: CBreakpointPropertyPage.breakpointType_event_label=C/C++ Event Breakpoint
CBreakpointPropertyPage.11=C/C++ read watchpoint CBreakpointPropertyPage.project_label=Project:
CBreakpointPropertyPage.12=C/C++ watchpoint CBreakpointPropertyPage.breakpointType_watchpoint_label=C/C++ Watchpoint
CBreakpointPropertyPage.13=C/C++ access watchpoint CBreakpointPropertyPage.breakpointType_watchpoint_read_label=C/C++ Read Watchpoint
CBreakpointPropertyPage.14=Expression to watch: CBreakpointPropertyPage.breakpointType_watchpoint_access_label=C/C++ Access Watchpoint
CBreakpointPropertyPage.15=&Condition: CBreakpointPropertyPage.watchpointType_read_label=Read
CBreakpointPropertyPage.16=Invalid condition. CBreakpointPropertyPage.watchpointType_write_label=Write
CBreakpointPropertyPage.17=&Ignore count: CBreakpointPropertyPage.watchpoint_expression_label=Expression to watch:
CBreakpointPropertyPage.18=Class: CBreakpointPropertyPage.watchpoint_expression_errorMessage=Enter the expression to watch:
CBreakpointPropertyPage.19=Enabled CBreakpointPropertyPage.condition_label=&Condition:
CBreakpointPropertyPage.20=File: CBreakpointPropertyPage.condition_invalidValue_message=Invalid condition.
CBreakpointPropertyPage.21=C/C++ Event Breakpoint CBreakpointPropertyPage.ignoreCount_label=&Ignore count:
CBreakpointPropertyPage.breakpointType_label=Class:
CBreakpointPropertyPage.enabled_label=Enabled
ThreadFilterEditor.0=&Restrict to Selected Targets and Threads: ThreadFilterEditor.0=&Restrict to Selected Targets and Threads:

View file

@ -13,8 +13,14 @@ package org.eclipse.cdt.debug.internal.ui.breakpoints;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICTracepoint; import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext; import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
@ -26,10 +32,12 @@ import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugModelProvider; import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.debug.ui.contexts.IDebugContextListener; import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionFilter; import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.model.IWorkbenchAdapter;
/** /**
* Input for breakpoint properties dialog. It captures both the * Input for breakpoint properties dialog. It captures both the
@ -148,6 +156,43 @@ class CBreakpointContextActionFilter implements IActionFilter {
} }
} }
class CBreakpointContextWorkbenchAdapter implements IWorkbenchAdapter {
@Override
public String getLabel(Object o) {
if (o instanceof ICBreakpointContext) {
ICBreakpoint bp = ((ICBreakpointContext)o).getBreakpoint();
return getBreakpointMainLabel(bp);
}
return ""; //$NON-NLS-1$
}
@Override
public Object[] getChildren(Object o) { return null; }
@Override
public ImageDescriptor getImageDescriptor(Object object) { return null; }
@Override
public Object getParent(Object o) { return null; }
private String getBreakpointMainLabel(ICBreakpoint breakpoint) {
if (breakpoint instanceof ICFunctionBreakpoint) {
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_function_label"); //$NON-NLS-1$
} else if (breakpoint instanceof ICAddressBreakpoint) {
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_address_label"); //$NON-NLS-1$
} else if (breakpoint instanceof ICLineBreakpoint) {
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_line_label"); //$NON-NLS-1$
} else if (breakpoint instanceof ICEventBreakpoint) {
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_event_label"); //$NON-NLS-1$
} else if (breakpoint instanceof ICWatchpoint) {
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$
}
// default main label is the label of marker type for the breakpoint
return CDIDebugModel.calculateMarkerType(breakpoint);
}
}
/** /**
* Adapter factory which returns the breakpoint object and the action * Adapter factory which returns the breakpoint object and the action
* filter for the CBreakpointContext type. * filter for the CBreakpointContext type.
@ -155,10 +200,12 @@ class CBreakpointContextActionFilter implements IActionFilter {
class CBreakpointContextAdapterFactory implements IAdapterFactory { class CBreakpointContextAdapterFactory implements IAdapterFactory {
private static final Class<?>[] fgAdapterList = new Class[] { private static final Class<?>[] fgAdapterList = new Class[] {
IBreakpoint.class, ICBreakpoint.class, ICTracepoint.class, IActionFilter.class, IPreferenceStore.class IBreakpoint.class, ICBreakpoint.class, ICTracepoint.class, IActionFilter.class, IPreferenceStore.class,
IWorkbenchAdapter.class,
}; };
private static final IActionFilter fgActionFilter = new CBreakpointContextActionFilter(); private static final IActionFilter fgActionFilter = new CBreakpointContextActionFilter();
private static final IWorkbenchAdapter fgWorkbenchAdapter = new CBreakpointContextWorkbenchAdapter();
@Override @Override
public Object getAdapter(Object obj, @SuppressWarnings("rawtypes") Class adapterType) { public Object getAdapter(Object obj, @SuppressWarnings("rawtypes") Class adapterType) {
@ -178,6 +225,11 @@ class CBreakpointContextAdapterFactory implements IAdapterFactory {
if (IActionFilter.class.equals(adapterType)) { if (IActionFilter.class.equals(adapterType)) {
return fgActionFilter; return fgActionFilter;
} }
if (IWorkbenchAdapter.class.equals(adapterType)) {
return fgWorkbenchAdapter;
}
return null; return null;
} }

View file

@ -40,14 +40,6 @@ import org.eclipse.jface.util.PropertyChangeEvent;
*/ */
public class CBreakpointPreferenceStore implements IPersistentPreferenceStore { public class CBreakpointPreferenceStore implements IPersistentPreferenceStore {
// protected final static String ENABLED = "ENABLED"; //$NON-NLS-1$
//
// protected final static String CONDITION = "CONDITION"; //$NON-NLS-1$
//
// protected final static String IGNORE_COUNT = "IGNORE_COUNT"; //$NON-NLS-1$
//
// protected final static String LINE = "LINE"; //$NON-NLS-1$
// This map is the current properties/values being maintained/manipulated // This map is the current properties/values being maintained/manipulated
private HashMap<String, Object> fProperties = new HashMap<String, Object>(); private HashMap<String, Object> fProperties = new HashMap<String, Object>();
@ -149,7 +141,7 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore {
breakpoint.getMarker().setAttribute(ICLineBreakpoint2.REQUESTED_LINE, getInt(IMarker.LINE_NUMBER)); breakpoint.getMarker().setAttribute(ICLineBreakpoint2.REQUESTED_LINE, getInt(IMarker.LINE_NUMBER));
} else { } else {
// this allow set attributes contributed by other plugins // this allow set attributes contributed by other plugins
String value = getPropertyAsString(property); Object value = fProperties.get(property);
if ( value != null ) { if ( value != null ) {
marker.setAttribute(property, value); marker.setAttribute(property, value);
} }
@ -175,14 +167,6 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore {
} }
} }
private String getPropertyAsString(String property) {
if (fProperties.containsKey(property)) {
return getString(property);
} else {
return null;
}
}
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// IPreferenceStore // IPreferenceStore

View file

@ -15,7 +15,6 @@ package org.eclipse.cdt.debug.internal.ui.breakpoints;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
@ -26,6 +25,7 @@ import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution;
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor; import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.model.ILineBreakpoint; import org.eclipse.debug.core.model.ILineBreakpoint;
@ -38,6 +38,7 @@ import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.model.IWorkbenchAdapter;
/** /**
* The preference page used to present the properties of a breakpoint as preferences. A CBreakpointPreferenceStore is used to interface between this page and * The preference page used to present the properties of a breakpoint as preferences. A CBreakpointPreferenceStore is used to interface between this page and
@ -232,8 +233,11 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
} }
private void createMainLabel(ICBreakpoint breakpoint) { private void createMainLabel(ICBreakpoint breakpoint) {
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.18" ), //$NON-NLS-1$ String label = getBreakpointMainLabel(breakpoint);
getBreakpointMainLabel(breakpoint) ) ); addField( createLabelEditor(
getFieldEditorParent(),
BreakpointsMessages.getString( "CBreakpointPropertyPage.breakpointType_label" ), //$NON-NLS-1$
label) );
} }
/** /**
@ -244,52 +248,37 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint ) { private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint ) {
if ( breakpoint instanceof ICFunctionBreakpoint ) { if ( breakpoint instanceof ICFunctionBreakpoint ) {
ICFunctionBreakpoint fbrkpt = (ICFunctionBreakpoint)breakpoint; createFunctionEditor(getFieldEditorParent());
String function = BreakpointsMessages.getString( "CBreakpointPropertyPage.1" ); //$NON-NLS-1$
try {
function = fbrkpt.getFunction();
}
catch( CoreException e ) {
}
catch( NumberFormatException e ) {
}
if ( function != null ) {
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.function_label" ), function ) ); //$NON-NLS-1$
}
} }
else if ( breakpoint instanceof ICAddressBreakpoint ) { else if ( breakpoint instanceof ICAddressBreakpoint ) {
ICAddressBreakpoint abrkpt = (ICAddressBreakpoint)breakpoint; String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.address_label" ); //$NON-NLS-1$
String address = BreakpointsMessages.getString( "CBreakpointPropertyPage.4" ); //$NON-NLS-1$
try { String address = getPreferenceStore().getString(ICLineBreakpoint.ADDRESS);
address = abrkpt.getAddress(); if (address == null || address.trim().length() == 0) {
} address = BreakpointsMessages.getString( "CBreakpointPropertyPage.address_valueNotAvailable_label" ); //$NON-NLS-1$
catch( CoreException e ) { }
} addField( createLabelEditor( getFieldEditorParent(), title, address ) );
if ( address != null ) {
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.address_label" ), address ) ); //$NON-NLS-1$
}
} }
else if ( breakpoint instanceof ICWatchpoint ) { else if ( breakpoint instanceof ICWatchpoint ) {
ICWatchpoint watchpoint = (ICWatchpoint)breakpoint; IResource resource = getResource();
String expression = getPreferenceStore().getString(ICWatchpoint.EXPRESSION); if (resource != null) {
IProject project = resource.getProject();
IMarker marker = breakpoint.getMarker();
if (marker != null) {
IProject project = marker.getResource().getProject();
if ( project != null ) { if ( project != null ) {
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.10" ), project.getName() ) ); //$NON-NLS-1$ addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.project_label" ), project.getName() ) ); //$NON-NLS-1$
} }
} }
String filename = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); String filename = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
if (!"".equals(filename)) { //$NON-NLS-1$ if (filename != null && !"".equals(filename)) { //$NON-NLS-1$
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.20" ), filename ) ); //$NON-NLS-1$ addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ), filename ) ); //$NON-NLS-1$
} }
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.14" ), expression ) ); //$NON-NLS-1$ createWatchExpressionEditor(getFieldEditorParent());
createWatchTypeEditors(getFieldEditorParent());
} }
else if ( breakpoint instanceof ILineBreakpoint ) { else if ( breakpoint instanceof ILineBreakpoint ) {
String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
if ( fileName != null ) { if ( fileName != null ) {
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.7" ), fileName ) ); //$NON-NLS-1$ addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ), fileName ) ); //$NON-NLS-1$
} }
int lNumber = getPreferenceStore().getInt(IMarker.LINE_NUMBER); int lNumber = getPreferenceStore().getInt(IMarker.LINE_NUMBER);
if (lNumber > 0) { if (lNumber > 0) {
@ -300,58 +289,101 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
} }
private String getBreakpointMainLabel(ICBreakpoint breakpoint) { private String getBreakpointMainLabel(ICBreakpoint breakpoint) {
if (breakpoint instanceof ICFunctionBreakpoint) if (breakpoint instanceof ICWatchpoint && breakpoint.getMarker() != null) {
return BreakpointsMessages.getString("CBreakpointPropertyPage.3"); //$NON-NLS-1$ // For an existing breakpoint, calculate watchpoint label based
if (breakpoint instanceof ICAddressBreakpoint) // on read/write type.
return BreakpointsMessages.getString("CBreakpointPropertyPage.4"); //$NON-NLS-1$ boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ);
if (breakpoint instanceof ICLineBreakpoint) boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE);
return BreakpointsMessages.getString("CBreakpointPropertyPage.8"); //$NON-NLS-1$ if (isReadType && !isWriteType) {
if (breakpoint instanceof ICEventBreakpoint) return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_read_label"); //$NON-NLS-1$
return BreakpointsMessages.getString("CBreakpointPropertyPage.21"); //$NON-NLS-1$ } else if (!isReadType && isWriteType) {
if (breakpoint instanceof ICWatchpoint) { return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$
String type = ""; //$NON-NLS-1$ } else {
boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ); return BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_breakpointType_watchpoint_access_label"); //$NON-NLS-1$
boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE); }
if (isReadType && !isWriteType) }
type = BreakpointsMessages.getString("CBreakpointPropertyPage.11"); //$NON-NLS-1$
else if (!isReadType && isWriteType) IWorkbenchAdapter labelProvider = (IWorkbenchAdapter)getElement().getAdapter(IWorkbenchAdapter.class);
type = BreakpointsMessages.getString("CBreakpointPropertyPage.12"); //$NON-NLS-1$ if (labelProvider != null) {
else return labelProvider.getLabel(getElement());
type = BreakpointsMessages.getString("CBreakpointPropertyPage.13"); //$NON-NLS-1$ }
// default main label is the label of marker type for the breakpoint
return type; return CDIDebugModel.calculateMarkerType(breakpoint);
}
// default main label is the label of marker type for the breakpoint
return CDIDebugModel.calculateMarkerType(breakpoint);
} }
protected void createFunctionEditor( Composite parent ) {
ICBreakpoint breakpoint = getBreakpoint();
String title = BreakpointsMessages.getString("CBreakpointPropertyPage.function_label"); //$NON-NLS-1$
if (breakpoint == null || breakpoint.getMarker() == null) {
BreakpointStringFieldEditor expressionEditor = new BreakpointStringFieldEditor(
ICLineBreakpoint.FUNCTION, title, parent);
expressionEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.function_value_errorMessage")); //$NON-NLS-1$
expressionEditor.setEmptyStringAllowed(false);
addField(expressionEditor);
} else {
String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION);
if ( function == null ) {
function = BreakpointsMessages.getString( "CBreakpointPropertyPage.function_valueNotAvailable_label" ); //$NON-NLS-1$
}
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.function_label" ), function ) ); //$NON-NLS-1$
}
}
protected void createLineNumberEditor( Composite parent ) { protected void createLineNumberEditor( Composite parent ) {
String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.9" ); //$NON-NLS-1$ String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.lineNumber_label" ); //$NON-NLS-1$
BreakpointIntegerFieldEditor labelFieldEditor =new BreakpointIntegerFieldEditor( IMarker.LINE_NUMBER ,title, parent); BreakpointIntegerFieldEditor labelFieldEditor =new BreakpointIntegerFieldEditor( IMarker.LINE_NUMBER ,title, parent);
labelFieldEditor.setValidRange( 1, Integer.MAX_VALUE ); labelFieldEditor.setValidRange( 1, Integer.MAX_VALUE );
addField( labelFieldEditor ); addField( labelFieldEditor );
} }
protected void createAddressEditor( Composite parent ) { protected void createWatchExpressionEditor( Composite parent ) {
String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.addressLabel" ); //$NON-NLS-1$ ICBreakpoint breakpoint = getBreakpoint();
StringFieldEditor fe =new StringFieldEditor( ICLineBreakpoint.ADDRESS ,title, parent); if (breakpoint == null || breakpoint.getMarker() == null) {
fe.setEmptyStringAllowed(false); BreakpointStringFieldEditor expressionEditor =new BreakpointStringFieldEditor(
addField( fe ); ICWatchpoint.EXPRESSION,
} BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_label"), //$NON-NLS-1$
parent);
expressionEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_errorMessage")); //$NON-NLS-1$
expressionEditor.setEmptyStringAllowed(false);
addField(expressionEditor);
} else {
addField(createLabelEditor(
parent,
BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_label"), //$NON-NLS-1$
getPreferenceStore().getString(ICWatchpoint.EXPRESSION) ));
}
}
protected void createWatchTypeEditors( Composite parent ) {
// Edit read/write options only when creating the breakpoint.
ICBreakpoint breakpoint = getBreakpoint();
if (breakpoint != null && breakpoint.getMarker() == null) {
addField( new BooleanFieldEditor(
ICWatchpoint.READ,
BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_read_label"), //$NON-NLS-1$
parent) );
addField( new BooleanFieldEditor(
ICWatchpoint.WRITE,
BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_write_label"), //$NON-NLS-1$
parent) );
}
}
protected void createEnabledField( Composite parent ) { protected void createEnabledField( Composite parent ) {
fEnabled = new BooleanFieldEditor( ICBreakpoint.ENABLED, BreakpointsMessages.getString( "CBreakpointPropertyPage.19" ), parent ); //$NON-NLS-1$ fEnabled = new BooleanFieldEditor( ICBreakpoint.ENABLED, BreakpointsMessages.getString( "CBreakpointPropertyPage.enabled_label" ), parent ); //$NON-NLS-1$
addField( fEnabled ); addField( fEnabled );
} }
protected void createConditionEditor( Composite parent ) { protected void createConditionEditor( Composite parent ) {
fCondition = new BreakpointStringFieldEditor( ICBreakpoint.CONDITION, BreakpointsMessages.getString( "CBreakpointPropertyPage.15" ), parent ); //$NON-NLS-1$ fCondition = new BreakpointStringFieldEditor( ICBreakpoint.CONDITION, BreakpointsMessages.getString( "CBreakpointPropertyPage.condition_label" ), parent ); //$NON-NLS-1$
fCondition.setEmptyStringAllowed( true ); fCondition.setEmptyStringAllowed( true );
fCondition.setErrorMessage( BreakpointsMessages.getString( "CBreakpointPropertyPage.16" ) ); //$NON-NLS-1$ fCondition.setErrorMessage( BreakpointsMessages.getString( "CBreakpointPropertyPage.condition_invalidValue_message" ) ); //$NON-NLS-1$
addField( fCondition ); addField( fCondition );
} }
protected void createIgnoreCountEditor( Composite parent ) { protected void createIgnoreCountEditor( Composite parent ) {
fIgnoreCount = new BreakpointIntegerFieldEditor( ICBreakpoint.IGNORE_COUNT, BreakpointsMessages.getString( "CBreakpointPropertyPage.17" ), parent ); //$NON-NLS-1$ fIgnoreCount = new BreakpointIntegerFieldEditor( ICBreakpoint.IGNORE_COUNT, BreakpointsMessages.getString( "CBreakpointPropertyPage.ignoreCount_label" ), parent ); //$NON-NLS-1$
fIgnoreCount.setValidRange( 0, Integer.MAX_VALUE ); fIgnoreCount.setValidRange( 0, Integer.MAX_VALUE );
fIgnoreCountTextControl = fIgnoreCount.getTextControl( parent ); fIgnoreCountTextControl = fIgnoreCount.getTextControl( parent );
fIgnoreCountTextControl.setEnabled( getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0 ); fIgnoreCountTextControl.setEnabled( getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0 );
@ -366,12 +398,25 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
IAdaptable element = getElement(); IAdaptable element = getElement();
if (element instanceof ICBreakpoint) { if (element instanceof ICBreakpoint) {
return (ICBreakpoint)element; return (ICBreakpoint)element;
} else if (element instanceof CBreakpointContext) { } else if (element instanceof ICBreakpointContext) {
return ((CBreakpointContext)element).getBreakpoint(); return ((ICBreakpointContext)element).getBreakpoint();
} else { } else {
return (ICBreakpoint)element.getAdapter(ICBreakpoint.class); return (ICBreakpoint)element.getAdapter(ICBreakpoint.class);
} }
} }
protected IResource getResource() {
IAdaptable element = getElement();
if (element instanceof ICBreakpoint) {
IMarker marker = ((ICBreakpoint)element).getMarker();
if (marker != null) {
return marker.getResource();
}
} else if (element instanceof ICBreakpointContext) {
return ((ICBreakpointContext)element).getResource();
}
return null;
}
public IPreferenceStore getPreferenceStore() { public IPreferenceStore getPreferenceStore() {
IAdaptable element = getElement(); IAdaptable element = getElement();

View file

@ -151,25 +151,54 @@ abstract public class AbstractToggleBreakpointAdapter
} }
@Override @Override
public boolean canCreateBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
return canToggleBreakpoints( part, selection ); return canToggleLineBreakpoints( part, selection );
} }
@Override @Override
public void createBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
updateBreakpoints(false, true, part, selection); updateLineBreakpoints(false, true, part, selection);
} }
@Override @Override
public boolean canCreateWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) { public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection) {
// Gather all input from user if needed.
return true; return true;
} }
@Override @Override
public void createWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, ""); ICElement element = getCElementFromSelection( part, selection );
if (element instanceof IVariable) {
updateVariableWatchpoint(false, true, part, (IVariable)element);
} else {
String text = ""; //$NON-NLS-1$
if (selection instanceof ITextSelection) {
text = ((ITextSelection)selection).getText();
}
createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, text);
}
} }
@Override
public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) {
return true;
}
@Override
public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
ICElement element = getCElementFromSelection( part, selection );
if ( element instanceof IFunction || element instanceof IMethod ) {
updateMethodBreakpoints(false, true, part, (IDeclaration)element);
} else {
String text = ""; //$NON-NLS-1$
if (selection instanceof ITextSelection) {
text = ((ITextSelection)selection).getText();
}
createFunctionBreakpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), text, -1, -1, -1);
}
}
/** /**
* Updates the breakpoint for given part and selection. * Updates the breakpoint for given part and selection.
* Depending on the flags and on whether a breakpoint exists, this method * Depending on the flags and on whether a breakpoint exists, this method

View file

@ -30,7 +30,7 @@ import org.eclipse.ui.IWorkbenchPart;
public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTargetExtension { public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTargetExtension {
/** /**
* Returns whether the toggle target can create a a breakpoint at the * Returns whether the toggle target can create a line breakpoint at the
* given location. If the implementation does not support creating the * given location. If the implementation does not support creating the
* breakpoint interactively then it should return <code>false</code>. * breakpoint interactively then it should return <code>false</code>.
* <p> * <p>
@ -43,12 +43,15 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa
* @return Returns <code>true</code> if toggle target is able interactively * @return Returns <code>true</code> if toggle target is able interactively
* create a breakpoint(s) at the given location. * create a breakpoint(s) at the given location.
*/ */
public boolean canCreateBreakpointsInteractive(IWorkbenchPart part, ISelection selection); public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection);
/** /**
* Creates new breakpoints interactively. The implementation should allows * Creates new line breakpoints interactively. The implementation should
* the user to edit all of the breakpoint's settings prior to creating the * allows the user to edit all of the breakpoint's settings prior to
* breakpoint. * creating the breakpoint. Unlike the
* {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)}
* method, this method does not remove the existing breakpoint at given
* location. It always creates a new breakpoint
* <p> * <p>
* The selection varies depending on the given part. For example, * The selection varies depending on the given part. For example,
* a text selection is provided for text editors, and a structured * a text selection is provided for text editors, and a structured
@ -58,10 +61,73 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa
* @param selection selection on which line breakpoints should be toggled * @param selection selection on which line breakpoints should be toggled
* @throws CoreException if unable to perform the action * @throws CoreException if unable to perform the action
*/ */
public void createBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
public boolean canCreateWatchpoingsInteractive(IWorkbenchPart part, ISelection selection); /**
* Returns whether the toggle target can create a watchpoint at the
public void createWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; * given location. If the implementation does not support creating the
* breakpoint interactively then it should return <code>false</code>.
* <p>
* The selection varies depending on the given part. For example,
* a text selection is provided for text editors, and a structured
* selection is provided for tree views, and may be a multi-selection.
* </p>
* @param part the part on which the action has been invoked
* @param selection selection on which line breakpoints should be toggled
* @return Returns <code>true</code> if toggle target is able interactively
* create a breakpoint(s) at the given location.
*/
public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection);
/**
* Creates new watchpoint interactively. The implementation should
* allows the user to edit all of the breakpoint's settings prior to
* creating the breakpoint. Unlike the
* {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)}
* method, this method does not remove the existing breakpoint at given
* location. It always creates a new breakpoint
* <p>
* The selection varies depending on the given part. For example,
* a text selection is provided for text editors, and a structured
* selection is provided for tree views, and may be a multi-selection.
* </p>
* @param part the part on which the action has been invoked
* @param selection selection on which line breakpoints should be toggled
* @throws CoreException if unable to perform the action
*/
public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
/**
* Returns whether the toggle target can create a function breakpoint at the
* given location. If the implementation does not support creating the
* breakpoint interactively then it should return <code>false</code>.
* <p>
* The selection varies depending on the given part. For example,
* a text selection is provided for text editors, and a structured
* selection is provided for tree views, and may be a multi-selection.
* </p>
* @param part the part on which the action has been invoked
* @param selection selection on which line breakpoints should be toggled
* @return Returns <code>true</code> if toggle target is able interactively
* create a breakpoint(s) at the given location.
*/
public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection);
/**
* Creates new function breakpoint interactively. The implementation should
* allows the user to edit all of the breakpoint's settings prior to
* creating the breakpoint. Unlike the
* {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)}
* method, this method does not remove the existing breakpoint at given
* location. It always creates a new breakpoint
* <p>
* The selection varies depending on the given part. For example,
* a text selection is provided for text editors, and a structured
* selection is provided for tree views, and may be a multi-selection.
* </p>
* @param part the part on which the action has been invoked
* @param selection selection on which line breakpoints should be toggled
* @throws CoreException if unable to perform the action
*/
public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
} }

View file

@ -31,8 +31,9 @@ commandContext.name= In Disassembly
commandContext.description= When debugging in assembly mode commandContext.description= When debugging in assembly mode
# actions # actions
action.breakpointProperties.label = Breakpoint Properties... action.breakpointProperties.label = Breakpoint Properties...\Ctrl+Double Click
action.toggleBreakpoint.label = Toggle Breakpoint action.toggleBreakpoint.label = Toggle Breakpoint\tDouble Click
action.addBreakpoint.label = Add Breakpoint...\tCtrl+Double Click
menu.updatePolicy = Update Policy menu.updatePolicy = Update Policy
menu.threadsUpdatePolicy = Threads Update Policy menu.threadsUpdatePolicy = Threads Update Policy

View file

@ -580,6 +580,12 @@
label="%action.breakpointProperties.label" label="%action.breakpointProperties.label"
menubarPath="debug"> menubarPath="debug">
</action> </action>
<action
class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AddBreakpointRulerActionDelegate"
id="org.eclipse.debug.ui.actions.RulerAddBreakpointAction"
label="%action.addBreakpoint.label"
menubarPath="debug">
</action>
<action <action
class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.RulerToggleBreakpointActionDelegate" class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.RulerToggleBreakpointActionDelegate"
definitionId="org.eclipse.cdt.dsf.debug.ui.disassembly.commands.rulerToggleBreakpoint" definitionId="org.eclipse.cdt.dsf.debug.ui.disassembly.commands.rulerToggleBreakpoint"

View file

@ -10,12 +10,17 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui; package org.eclipse.cdt.dsf.debug.internal.ui;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.ICBreakpointType; import org.eclipse.cdt.debug.core.model.ICBreakpointType;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.dsf.debug.ui.actions.AbstractDisassemblyBreakpointsTarget; import org.eclipse.cdt.dsf.debug.ui.actions.AbstractDisassemblyBreakpointsTarget;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IWorkbenchPart;
/** /**
* Toggle breakpoint target implementation for the disassembly part. * Toggle breakpoint target implementation for the disassembly part.
@ -30,6 +35,17 @@ public class DisassemblyToggleBreakpointsTarget extends AbstractDisassemblyBreak
CDIDebugModel.createLineBreakpoint( sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", true ); //$NON-NLS-1$ CDIDebugModel.createLineBreakpoint( sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", true ); //$NON-NLS-1$
} }
@Override
protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource,
int lineNumber) throws CoreException
{
ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineBreakpoint();
Map<String, Object> attributes = new HashMap<String, Object>();
CDIDebugModel.setLineBreakpointAttributes(
attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$
openBreakpointPropertiesDialog(lineBp, part, resource, attributes);
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.AbstractDisassemblyBreakpointsTarget#createAddressBreakpoint(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.IAddress) * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.AbstractDisassemblyBreakpointsTarget#createAddressBreakpoint(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.IAddress)
*/ */
@ -38,6 +54,17 @@ public class DisassemblyToggleBreakpointsTarget extends AbstractDisassemblyBreak
CDIDebugModel.createAddressBreakpoint( null, null, resource, getBreakpointType(), address, true, 0, "", true ); //$NON-NLS-1$ CDIDebugModel.createAddressBreakpoint( null, null, resource, getBreakpointType(), address, true, 0, "", true ); //$NON-NLS-1$
} }
@Override
protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address)
throws CoreException
{
ICLineBreakpoint lineBp = CDIDebugModel.createBlankAddressBreakpoint();
Map<String, Object> attributes = new HashMap<String, Object>();
CDIDebugModel.setAddressBreakpointAttributes(
attributes, null, null, getBreakpointType(), -1, address, true, 0, "" ); //$NON-NLS-1$
openBreakpointPropertiesDialog(lineBp, part, resource, attributes);
}
protected int getBreakpointType() { protected int getBreakpointType() {
return ICBreakpointType.REGULAR; return ICBreakpointType.REGULAR;
} }

View file

@ -83,7 +83,10 @@ public final class DisassemblyMessages extends NLS {
public static String Disassembly_Error_Dialog_title; public static String Disassembly_Error_Dialog_title;
public static String Disassembly_Error_Dialog_ok_button; public static String Disassembly_Error_Dialog_ok_button;
public static String DisassemblyBackendDsf_error_UnableToRetrieveData; public static String DisassemblyBackendDsf_error_UnableToRetrieveData;
public static String Disassembly_action_AddBreakpoint_label;
public static String Disassembly_action_AddBreakpoint_errorTitle;
public static String Disassembly_action_AddBreakpoint_errorMessage;
static { static {
NLS.initializeMessages(DisassemblyMessages.class.getName(), DisassemblyMessages.class); NLS.initializeMessages(DisassemblyMessages.class.getName(), DisassemblyMessages.class);
} }

View file

@ -18,13 +18,16 @@ Disassembly_action_GotoPC_tooltip=Go to Current Program Counter
Disassembly_action_GotoAddress_label=Go to Address... Disassembly_action_GotoAddress_label=Go to Address...
Disassembly_action_Copy_label=&Copy Disassembly_action_Copy_label=&Copy
Disassembly_action_SelectAll_label=Select &All Disassembly_action_SelectAll_label=Select &All
Disassembly_action_BreakpointProperties_label=Breakpoint Properties... Disassembly_action_BreakpointProperties_label=Breakpoint Properties...\tCtrl+Double Click
Disassembly_action_DisableBreakpoint_label=Disable Breakpoint Disassembly_action_DisableBreakpoint_label=Disable Breakpoint\tShift+Double Click
Disassembly_action_EnableBreakpoint_label=Enable Breakpoint Disassembly_action_EnableBreakpoint_label=Enable Breakpoint\tShift+Double Click
Disassembly_action_RefreshView_label=Re&fresh View Disassembly_action_RefreshView_label=Re&fresh View
Disassembly_action_OpenPreferences_label=&Preferences... Disassembly_action_OpenPreferences_label=&Preferences...
Disassembly_action_Sync_label=Link with Active Debug Context Disassembly_action_Sync_label=Link with Active Debug Context
Disassembly_action_TrackExpression_label=Track Expression Disassembly_action_TrackExpression_label=Track Expression
Disassembly_action_AddBreakpoint_label=Add Breakpoint...\tCtrl+Double Click
Disassembly_action_AddBreakpoint_errorTitle=Error
Disassembly_action_AddBreakpoint_errorMessage=Unable to create breakpoint
Disassembly_GotoAddressDialog_title=Go to Address Disassembly_GotoAddressDialog_title=Go to Address
Disassembly_GotoAddressDialog_label=Address expression: Disassembly_GotoAddressDialog_label=Address expression:

View file

@ -156,6 +156,7 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IActionBars; import org.eclipse.ui.IActionBars;
@ -1309,12 +1310,23 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fActionToggleSource.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(DsfUIPlugin.PLUGIN_ID, "icons/source.gif")); //$NON-NLS-1$ fActionToggleSource.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(DsfUIPlugin.PLUGIN_ID, "icons/source.gif")); //$NON-NLS-1$
fVerticalRuler.getControl().addMouseListener(new MouseAdapter() { fVerticalRuler.getControl().addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseDoubleClick(MouseEvent e) { public void mouseDoubleClick(final MouseEvent e) {
// invoke toggle breakpoint // invoke toggle breakpoint
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class); IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
if (handlerService != null) { if (handlerService != null) {
try { try {
handlerService.executeCommand(COMMAND_ID_TOGGLE_BREAKPOINT, null); Event event= new Event();
event.display = e.display;
event.widget = e.widget;
event.time = e.time;
event.data = e.data;
event.x = e.x;
event.y = e.y;
event.button = e.button;
event.stateMask = e.stateMask;
event.count = e.count;
handlerService.executeCommand(COMMAND_ID_TOGGLE_BREAKPOINT, event);
} catch (org.eclipse.core.commands.ExecutionException exc) { } catch (org.eclipse.core.commands.ExecutionException exc) {
DsfUIPlugin.log(exc); DsfUIPlugin.log(exc);
} catch (NotDefinedException exc) { } catch (NotDefinedException exc) {

View file

@ -0,0 +1,136 @@
/*******************************************************************************
* Copyright (c) 2008, 2012 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.debug.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
/**
* Ruler action to add breakpoint with a dialog properties.
*/
public class AddBreakpointRulerAction extends AbstractDisassemblyBreakpointRulerAction {
protected AddBreakpointRulerAction(IDisassemblyPart disassemblyPart, IVerticalRulerInfo rulerInfo) {
super(disassemblyPart, rulerInfo);
setText(DisassemblyMessages.Disassembly_action_AddBreakpoint_label);
}
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AbstractDisassemblyAction#run()
*/
@Override
public void run() {
IWorkbenchPart part = getDisassemblyPart();
ISelection selection = getSelection();
IToggleBreakpointsTargetCExtension toggleTarget = getToggleTarget(selection);
if (toggleTarget != null) {
try {
if (toggleTarget.canCreateLineBreakpointsInteractive(part, selection)) {
toggleTarget.createLineBreakpointsInteractive(part, selection);
}
} catch (CoreException e) {
reportException(e);
}
}
}
@Override
public void update() {
IDisassemblyPart part = getDisassemblyPart();
if (part != null && part.isConnected()) {
ISelection selection = getSelection();
IToggleBreakpointsTargetCExtension toggleTarget = getToggleTarget(selection);
if (toggleTarget != null) {
setEnabled( toggleTarget.canCreateLineBreakpointsInteractive(part, selection) );
return;
}
}
setEnabled(false);
}
private IToggleBreakpointsTargetCExtension getToggleTarget(ISelection selection) {
IToggleBreakpointsTargetManager toggleMgr = DebugUITools.getToggleBreakpointsTargetManager();
IToggleBreakpointsTarget toggleTarget = toggleMgr.getToggleBreakpointsTarget(getDisassemblyPart(), selection);
if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) {
return (IToggleBreakpointsTargetCExtension)toggleTarget;
}
return null;
}
/**
* Report an error to the user.
*
* @param e underlying exception
*/
private void reportException(Exception e) {
IStatus status= new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Error creating breakpoint: ", e); //$NON-NLS-1$
ErrorDialog.openError(
getDisassemblyPart().getSite().getShell(),
ActionMessages.getString("DisassemblyMessages.Disassembly_action_AddBreakpoint_errorTitle"), //$NON-NLS-1$
ActionMessages.getString("DisassemblyMessages.Disassembly_action_AddBreakpoint_errorMessage"), //$NON-NLS-1$
status);
CDebugUIPlugin.log(status); //
}
/**
* Determines the text selection for the breakpoint action. If clicking on the ruler inside
* the highlighted text, return the text selection for the highlighted text. Otherwise,
* return a text selection representing the start of the line.
*
* @return An ISelection as described.
* @throws BadLocationException If underlying operations throw.
*/
private ISelection getSelection() {
IDocument document = getDocument();
if (document != null) {
int line = getRulerInfo().getLineOfLastMouseButtonActivity();
try {
IRegion region = getDocument().getLineInformation(line);
ITextSelection textSelection = new TextSelection(document, region.getOffset(), 0);
ISelectionProvider provider = getDisassemblyPart().getSite().getSelectionProvider();
if (provider != null){
ISelection selection = provider.getSelection();
if (selection instanceof ITextSelection
&& ((ITextSelection) selection).getStartLine() <= line
&& ((ITextSelection) selection).getEndLine() >= line) {
textSelection = (ITextSelection) selection;
}
}
return textSelection;
} catch (BadLocationException e) {
}
}
return StructuredSelection.EMPTY;
}
}

View file

@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2008, 2012 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.jface.action.IAction;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
/**
* Ruler action delegate for the "Add Breakpoint..." action.
*/
public class AddBreakpointRulerActionDelegate extends AbstractDisassemblyRulerActionDelegate {
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AbstractDisassemblyRulerActionDelegate#createAction(org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart, org.eclipse.jface.text.source.IVerticalRulerInfo)
*/
@Override
protected IAction createAction(IDisassemblyPart disassemblyPart, IVerticalRulerInfo rulerInfo) {
return new AddBreakpointRulerAction(disassemblyPart, rulerInfo);
}
}

View file

@ -17,6 +17,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.debug.ui.actions.ToggleBreakpointAction; import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IVerticalRulerInfo; import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.handlers.HandlerUtil;
@ -39,7 +40,14 @@ public class RulerToggleBreakpointHandler extends AbstractHandler {
final ToggleBreakpointAction toggleBpAction= new ToggleBreakpointAction(part, document, rulerInfo); final ToggleBreakpointAction toggleBpAction= new ToggleBreakpointAction(part, document, rulerInfo);
toggleBpAction.update(); toggleBpAction.update();
if (toggleBpAction.isEnabled()) { if (toggleBpAction.isEnabled()) {
toggleBpAction.run(); if (event.getTrigger() instanceof Event) {
// Pass through the event that triggered the action.
// This will give toggle action access to key modifiers
// (shift, ctrl, etc.)
toggleBpAction.runWithEvent((Event)event.getTrigger());
} else {
toggleBpAction.run();
}
} }
} }
} }

View file

@ -15,8 +15,14 @@ import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection; 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.IDisassemblyPart;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
@ -28,21 +34,28 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension2;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation; import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
/** /**
* Base class for toggle breakpoint targets for the disassembly part. * Base class for toggle breakpoint targets for the disassembly part.
* @since 2.2 * @since 2.2
*/ */
public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBreakpointsTargetExtension { public abstract class AbstractDisassemblyBreakpointsTarget
implements IToggleBreakpointsTargetExtension2, IToggleBreakpointsTargetCExtension
{
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
@ -58,7 +71,7 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre
int line = disassemblySelection.getStartLine(); int line = disassemblySelection.getStartLine();
IBreakpoint[] bp = getBreakpointsAtLine( (IDisassemblyPart)part, line ); IBreakpoint[] bp = getBreakpointsAtLine( (IDisassemblyPart)part, line );
if ( bp == null || bp.length == 0 ) { if ( bp == null || bp.length == 0 ) {
insertBreakpoint( disassemblySelection ); insertBreakpoint(part, disassemblySelection, false);
} }
else { else {
for( int i = 0; i < bp.length; i++ ) { for( int i = 0; i < bp.length; i++ ) {
@ -121,10 +134,126 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre
return canToggleLineBreakpoints( part, selection ); return canToggleLineBreakpoints( part, selection );
} }
/**
* @since 2.3
*/
@Override
public boolean canToggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) {
return canToggleBreakpoints(part, selection);
}
/**
* @since 2.3
*/
@Override
public void toggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) throws CoreException {
assert part instanceof IDisassemblyPart && selection instanceof ITextSelection;
boolean mod1 = event != null && (event.stateMask & SWT.MOD1) > 0;
boolean mod2 = event != null && (event.stateMask & SWT.MOD2) > 0;
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(part, disassemblySelection, mod1);
}
else {
if(mod2) {
toggleBreakpointEnabled(bp[0]);
return;
} else if (mod1 && bp[0] instanceof ICBreakpoint) {
CDebugUIUtils.editBreakpointProperties(part, (ICBreakpoint)bp[0]);
return;
}
for( int i = 0; i < bp.length; i++ ) {
bp[i].delete();
}
}
}
/**
* @since 2.3
*/
@Override
public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
return canToggleLineBreakpoints(part, selection);
}
/**
* @since 2.3
*/
@Override
public void createLineBreakpointsInteractive(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;
insertBreakpoint(part, disassemblySelection, true);
}
/**
* @since 2.3
*/
@Override
public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) {
return false;
}
/**
* @since 2.3
*/
@Override
public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
}
/**
* @since 2.3
*/
@Override
public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection) {
return false;
}
/**
* @since 2.3
*/
@Override
public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
}
private void toggleBreakpointEnabled(IBreakpoint bp) {
try {
bp.setEnabled(!bp.isEnabled());
} catch (CoreException e) {
CDebugUIPlugin.log(e.getStatus());
}
}
protected abstract void createLineBreakpoint( String sourceHandle, IResource resource, int lineNumber ) throws CoreException; protected abstract void createLineBreakpoint( String sourceHandle, IResource resource, int lineNumber ) throws CoreException;
/**
* @since 2.3
*/
protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource, int lineNumber ) throws CoreException {
createLineBreakpoint(sourceHandle, resource, lineNumber);
}
protected abstract void createAddressBreakpoint( IResource resource, IAddress address ) throws CoreException; protected abstract void createAddressBreakpoint( IResource resource, IAddress address ) throws CoreException;
/**
* @since 2.3
*/
protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address ) throws CoreException {
createAddressBreakpoint(resource, address);
}
private IBreakpoint[] getBreakpointsAtLine( IDisassemblyPart part, int line ) { private IBreakpoint[] getBreakpointsAtLine( IDisassemblyPart part, int line ) {
List<IBreakpoint> breakpoints = new ArrayList<IBreakpoint>(); List<IBreakpoint> breakpoints = new ArrayList<IBreakpoint>();
IAnnotationModel annotationModel = part.getTextViewer().getAnnotationModel(); IAnnotationModel annotationModel = part.getTextViewer().getAnnotationModel();
@ -159,7 +288,7 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre
return breakpoints.toArray( breakpointsArray ); return breakpoints.toArray( breakpointsArray );
} }
private void insertBreakpoint( IDisassemblySelection selection ) throws CoreException { private void insertBreakpoint(IWorkbenchPart part, IDisassemblySelection selection, boolean interactive) throws CoreException {
IAddress address = selection.getStartAddress(); IAddress address = selection.getStartAddress();
if ( address == null ) { if ( address == null ) {
return; return;
@ -180,11 +309,53 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre
filePath = URIUtil.toPath( fileUri ).toOSString(); filePath = URIUtil.toPath( fileUri ).toOSString();
} }
int srcLine = selection.getSourceLine(); int srcLine = selection.getSourceLine();
createLineBreakpoint( filePath, resource, srcLine + 1 ); if (interactive) {
createLineBreakpointInteractive(part, filePath, resource, srcLine + 1 );
} else {
createLineBreakpoint( filePath, resource, srcLine + 1 );
}
} }
else { else {
IResource resource = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = ResourcesPlugin.getWorkspace().getRoot();
createAddressBreakpoint( resource, address ); if (interactive) {
createAddressBreakpointInteractive(part, resource, address );
} else {
createAddressBreakpoint( resource, address );
}
} }
} }
/**
* Opens the properties dialog for the given breakpoint. This method can be
* used on an existing breakpoint or on a blank breakpoint which doesn't
* have an associated marker yet.
*
* @param bp
* The breakpoint to edit. This breakpoint may not have an
* associated marker yet.
* @param part
* Workbench part where the action was invoked.
* @param resource
* Workbench resource to create the breakpoint on.
* @param attributes
* Breakpoint attributes to show in properties dialog. If the
* breakpoint already exists, this attribute map can be used to
* override the attributes currently in the breakpoint. Can be
* <code>null</code>.
* @since 2.3
*/
protected void openBreakpointPropertiesDialog(ICBreakpoint bp, IWorkbenchPart part, IResource resource,
Map<String, Object> attributes)
{
ISelection debugContext = DebugUITools.getDebugContextManager()
.getContextService(part.getSite().getWorkbenchWindow()).getActiveContext(part.getSite().getId());
CBreakpointContext bpContext = new CBreakpointContext(bp, debugContext, resource, attributes);
PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(part.getSite().getShell(), bpContext, null,
null, null);
if (dialog != null) {
dialog.open();
}
}
} }