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:
parent
bfdf65cacd
commit
dd069579ac
26 changed files with 819 additions and 172 deletions
|
@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.cdt.debug.ui.CDebugUIPlugin
|
|||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
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.breakpoints;x-internal:=true,
|
||||
org.eclipse.cdt.debug.internal.ui.breakpoints;x-internal:=true,
|
||||
|
|
|
@ -58,6 +58,8 @@ AddWatchpoint.label=Add Watchpoint (C/C++)...
|
|||
AddWatchpoint.tooltip=Add Watchpoint (C/C++)
|
||||
AddEventBreakpoint.label=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.tooltip=Add Global Variables
|
||||
|
|
|
@ -970,6 +970,15 @@
|
|||
style="push"
|
||||
tooltip="%AddEventBreakpoint.tooltip">
|
||||
</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
|
||||
targetID="org.eclipse.debug.ui.VariableView"
|
||||
|
|
|
@ -37,11 +37,10 @@ ToggleBreakpointAdapter.Missing_document_2=Missing document
|
|||
ToggleBreakpointAdapter.Missing_resource_2=Missing resource
|
||||
ToggleBreakpointAdapter.Invalid_expression_1=Invalid expression:
|
||||
RunToLineAdapter.Operation_is_not_supported_1=Operation is not supported.
|
||||
EnableDisableBreakpointRulerAction.Enable_Breakpoint_1=&Enable Breakpoint
|
||||
EnableDisableBreakpointRulerAction.Enable_Breakpoint_1=&Enable Breakpoint\tShift+Double Click
|
||||
EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1=Enabling/disabling breakpoints
|
||||
EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1=Exceptions occurred enabling or disabling the breakpoint
|
||||
EnableDisableBreakpointRulerAction.Disable_Breakpoint_1=&Disable Breakpoint
|
||||
ToggleBreakpointRulerAction.Toggle_Breakpoint_1=Toggle &Breakpoint
|
||||
EnableDisableBreakpointRulerAction.Disable_Breakpoint_1=&Disable Breakpoint\tShift+Double Click
|
||||
ToggleWatchpointActionDelegate.Operation_failed_1=Operation failed.
|
||||
ToggleBreakpointRulerAction.Error_1=Error
|
||||
ToggleBreakpointRulerAction.Operation_failed_1=Operation failed
|
||||
|
|
|
@ -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$
|
||||
}
|
||||
}
|
||||
}
|
|
@ -76,16 +76,10 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView
|
|||
}
|
||||
|
||||
try {
|
||||
cToggleTarget.createWatchpoingsInteractive(fView, fSelection);
|
||||
cToggleTarget.createWatchpointsInteractive(fView, fSelection);
|
||||
} catch (CoreException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate1.0" ), e ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.eclipse.swt.widgets.Text;
|
|||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd
|
|||
DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, selection);
|
||||
if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) {
|
||||
IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) toggleTarget;
|
||||
if (extension.canCreateBreakpointsInteractive(fPart, selection)) {
|
||||
extension.createBreakpointsInteractive(fPart, selection);
|
||||
if (extension.canCreateLineBreakpointsInteractive(fPart, selection)) {
|
||||
extension.createLineBreakpointsInteractive(fPart, selection);
|
||||
}
|
||||
}
|
||||
} catch (BadLocationException e) {
|
||||
|
@ -177,7 +177,7 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd
|
|||
}
|
||||
if (adapter instanceof IToggleBreakpointsTargetCExtension) {
|
||||
IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) adapter;
|
||||
if (extension.canCreateBreakpointsInteractive(fPart, selection)) {
|
||||
if (extension.canCreateLineBreakpointsInteractive(fPart, selection)) {
|
||||
setEnabled(true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ public class CToggleMethodBreakpointActionDelegate extends CToggleBreakpointObje
|
|||
{
|
||||
if ((event.stateMask & SWT.MOD1) != 0 &&
|
||||
target instanceof IToggleBreakpointsTargetCExtension &&
|
||||
((IToggleBreakpointsTargetCExtension)target).canCreateBreakpointsInteractive(part, selection))
|
||||
((IToggleBreakpointsTargetCExtension)target).canCreateLineBreakpointsInteractive(part, selection))
|
||||
{
|
||||
((IToggleBreakpointsTargetCExtension)target).createBreakpointsInteractive(part, selection);
|
||||
((IToggleBreakpointsTargetCExtension)target).createLineBreakpointsInteractive(part, selection);
|
||||
}
|
||||
else {
|
||||
target.toggleMethodBreakpoints(part, selection);
|
||||
|
|
|
@ -91,20 +91,11 @@ public class ToggleBreakpointAdapter extends AbstractToggleBreakpointAdapter {
|
|||
protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource,
|
||||
int charStart, int charEnd, int lineNumber, String expression) throws CoreException
|
||||
{
|
||||
// AddWatchpointDialog dlg = new AddWatchpointDialog(part.getSite().getShell(), getMemorySpaceManagement() );
|
||||
// dlg.setExpression( expression );
|
||||
// if ( dlg.open() != Window.OK )
|
||||
// return;
|
||||
// expression = dlg.getExpression();
|
||||
// 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);
|
||||
}
|
||||
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$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
openBreakpointPropertiesDialog(bp, part, resource, attributes);
|
||||
}
|
||||
|
||||
protected int getBreakpointType() {
|
||||
|
|
|
@ -12,26 +12,29 @@
|
|||
###############################################################################
|
||||
|
||||
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.3=C/C++ function breakpoint
|
||||
CBreakpointPropertyPage.4=Not available
|
||||
CBreakpointPropertyPage.function_value_errorMessage=Enter a function expression:
|
||||
CBreakpointPropertyPage.breakpointType_function_label=C/C++ Function Breakpoint
|
||||
CBreakpointPropertyPage.address_valueNotAvailable_label=Not available
|
||||
CBreakpointPropertyPage.address_label=Address:
|
||||
CBreakpointPropertyPage.6=C/C++ address breakpoint
|
||||
CBreakpointPropertyPage.7=File:
|
||||
CBreakpointPropertyPage.8=C/C++ line breakpoint
|
||||
CBreakpointPropertyPage.9=Line number:
|
||||
CBreakpointPropertyPage.10=Project:
|
||||
CBreakpointPropertyPage.11=C/C++ read watchpoint
|
||||
CBreakpointPropertyPage.12=C/C++ watchpoint
|
||||
CBreakpointPropertyPage.13=C/C++ access watchpoint
|
||||
CBreakpointPropertyPage.14=Expression to watch:
|
||||
CBreakpointPropertyPage.15=&Condition:
|
||||
CBreakpointPropertyPage.16=Invalid condition.
|
||||
CBreakpointPropertyPage.17=&Ignore count:
|
||||
CBreakpointPropertyPage.18=Class:
|
||||
CBreakpointPropertyPage.19=Enabled
|
||||
CBreakpointPropertyPage.20=File:
|
||||
CBreakpointPropertyPage.21=C/C++ Event Breakpoint
|
||||
CBreakpointPropertyPage.breakpointType_address_label=C/C++ Address Breakpoint
|
||||
CBreakpointPropertyPage.sourceHandle_label=File:
|
||||
CBreakpointPropertyPage.breakpointType_line_label=C/C++ Line Breakpoint
|
||||
CBreakpointPropertyPage.lineNumber_label=Line number:
|
||||
CBreakpointPropertyPage.breakpointType_event_label=C/C++ Event Breakpoint
|
||||
CBreakpointPropertyPage.project_label=Project:
|
||||
CBreakpointPropertyPage.breakpointType_watchpoint_label=C/C++ Watchpoint
|
||||
CBreakpointPropertyPage.breakpointType_watchpoint_read_label=C/C++ Read Watchpoint
|
||||
CBreakpointPropertyPage.breakpointType_watchpoint_access_label=C/C++ Access Watchpoint
|
||||
CBreakpointPropertyPage.watchpointType_read_label=Read
|
||||
CBreakpointPropertyPage.watchpointType_write_label=Write
|
||||
CBreakpointPropertyPage.watchpoint_expression_label=Expression to watch:
|
||||
CBreakpointPropertyPage.watchpoint_expression_errorMessage=Enter the expression to watch:
|
||||
CBreakpointPropertyPage.condition_label=&Condition:
|
||||
CBreakpointPropertyPage.condition_invalidValue_message=Invalid condition.
|
||||
CBreakpointPropertyPage.ignoreCount_label=&Ignore count:
|
||||
CBreakpointPropertyPage.breakpointType_label=Class:
|
||||
CBreakpointPropertyPage.enabled_label=Enabled
|
||||
|
||||
ThreadFilterEditor.0=&Restrict to Selected Targets and Threads:
|
||||
|
|
|
@ -13,8 +13,14 @@ package org.eclipse.cdt.debug.internal.ui.breakpoints;
|
|||
|
||||
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.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.ICWatchpoint;
|
||||
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
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.ui.contexts.IDebugContextListener;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IActionFilter;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* filter for the CBreakpointContext type.
|
||||
|
@ -155,10 +200,12 @@ class CBreakpointContextActionFilter implements IActionFilter {
|
|||
class CBreakpointContextAdapterFactory implements IAdapterFactory {
|
||||
|
||||
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 IWorkbenchAdapter fgWorkbenchAdapter = new CBreakpointContextWorkbenchAdapter();
|
||||
|
||||
@Override
|
||||
public Object getAdapter(Object obj, @SuppressWarnings("rawtypes") Class adapterType) {
|
||||
|
@ -178,6 +225,11 @@ class CBreakpointContextAdapterFactory implements IAdapterFactory {
|
|||
if (IActionFilter.class.equals(adapterType)) {
|
||||
return fgActionFilter;
|
||||
}
|
||||
|
||||
if (IWorkbenchAdapter.class.equals(adapterType)) {
|
||||
return fgWorkbenchAdapter;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,14 +40,6 @@ import org.eclipse.jface.util.PropertyChangeEvent;
|
|||
*/
|
||||
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
|
||||
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));
|
||||
} else {
|
||||
// this allow set attributes contributed by other plugins
|
||||
String value = getPropertyAsString(property);
|
||||
Object value = fProperties.get(property);
|
||||
if ( value != null ) {
|
||||
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
|
||||
|
||||
|
|
|
@ -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.model.ICAddressBreakpoint;
|
||||
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.ICWatchpoint;
|
||||
|
@ -26,6 +25,7 @@ import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution;
|
|||
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
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.Text;
|
||||
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
|
||||
|
@ -232,8 +233,11 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
|||
}
|
||||
|
||||
private void createMainLabel(ICBreakpoint breakpoint) {
|
||||
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.18" ), //$NON-NLS-1$
|
||||
getBreakpointMainLabel(breakpoint) ) );
|
||||
String label = 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 ) {
|
||||
|
||||
if ( breakpoint instanceof ICFunctionBreakpoint ) {
|
||||
ICFunctionBreakpoint fbrkpt = (ICFunctionBreakpoint)breakpoint;
|
||||
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$
|
||||
}
|
||||
createFunctionEditor(getFieldEditorParent());
|
||||
}
|
||||
else if ( breakpoint instanceof ICAddressBreakpoint ) {
|
||||
ICAddressBreakpoint abrkpt = (ICAddressBreakpoint)breakpoint;
|
||||
String address = BreakpointsMessages.getString( "CBreakpointPropertyPage.4" ); //$NON-NLS-1$
|
||||
try {
|
||||
address = abrkpt.getAddress();
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
}
|
||||
if ( address != null ) {
|
||||
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.address_label" ), address ) ); //$NON-NLS-1$
|
||||
}
|
||||
String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.address_label" ); //$NON-NLS-1$
|
||||
|
||||
String address = getPreferenceStore().getString(ICLineBreakpoint.ADDRESS);
|
||||
if (address == null || address.trim().length() == 0) {
|
||||
address = BreakpointsMessages.getString( "CBreakpointPropertyPage.address_valueNotAvailable_label" ); //$NON-NLS-1$
|
||||
}
|
||||
addField( createLabelEditor( getFieldEditorParent(), title, address ) );
|
||||
}
|
||||
else if ( breakpoint instanceof ICWatchpoint ) {
|
||||
ICWatchpoint watchpoint = (ICWatchpoint)breakpoint;
|
||||
String expression = getPreferenceStore().getString(ICWatchpoint.EXPRESSION);
|
||||
|
||||
IMarker marker = breakpoint.getMarker();
|
||||
if (marker != null) {
|
||||
IProject project = marker.getResource().getProject();
|
||||
IResource resource = getResource();
|
||||
if (resource != null) {
|
||||
IProject project = resource.getProject();
|
||||
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);
|
||||
if (!"".equals(filename)) { //$NON-NLS-1$
|
||||
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.20" ), filename ) ); //$NON-NLS-1$
|
||||
if (filename != null && !"".equals(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 ) {
|
||||
String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
|
||||
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);
|
||||
if (lNumber > 0) {
|
||||
|
@ -300,58 +289,101 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
|||
}
|
||||
|
||||
private String getBreakpointMainLabel(ICBreakpoint breakpoint) {
|
||||
if (breakpoint instanceof ICFunctionBreakpoint)
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.3"); //$NON-NLS-1$
|
||||
if (breakpoint instanceof ICAddressBreakpoint)
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.4"); //$NON-NLS-1$
|
||||
if (breakpoint instanceof ICLineBreakpoint)
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.8"); //$NON-NLS-1$
|
||||
if (breakpoint instanceof ICEventBreakpoint)
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.21"); //$NON-NLS-1$
|
||||
if (breakpoint instanceof ICWatchpoint) {
|
||||
String type = ""; //$NON-NLS-1$
|
||||
boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ);
|
||||
boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE);
|
||||
if (isReadType && !isWriteType)
|
||||
type = BreakpointsMessages.getString("CBreakpointPropertyPage.11"); //$NON-NLS-1$
|
||||
else if (!isReadType && isWriteType)
|
||||
type = BreakpointsMessages.getString("CBreakpointPropertyPage.12"); //$NON-NLS-1$
|
||||
else
|
||||
type = BreakpointsMessages.getString("CBreakpointPropertyPage.13"); //$NON-NLS-1$
|
||||
if (breakpoint instanceof ICWatchpoint && breakpoint.getMarker() != null) {
|
||||
// For an existing breakpoint, calculate watchpoint label based
|
||||
// on read/write type.
|
||||
boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ);
|
||||
boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE);
|
||||
if (isReadType && !isWriteType) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_read_label"); //$NON-NLS-1$
|
||||
} else if (!isReadType && isWriteType) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$
|
||||
} else {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_breakpointType_watchpoint_access_label"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
// default main label is the label of marker type for the breakpoint
|
||||
return CDIDebugModel.calculateMarkerType(breakpoint);
|
||||
IWorkbenchAdapter labelProvider = (IWorkbenchAdapter)getElement().getAdapter(IWorkbenchAdapter.class);
|
||||
if (labelProvider != null) {
|
||||
return labelProvider.getLabel(getElement());
|
||||
}
|
||||
// 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 ) {
|
||||
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);
|
||||
labelFieldEditor.setValidRange( 1, Integer.MAX_VALUE );
|
||||
addField( labelFieldEditor );
|
||||
}
|
||||
|
||||
protected void createAddressEditor( Composite parent ) {
|
||||
String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.addressLabel" ); //$NON-NLS-1$
|
||||
StringFieldEditor fe =new StringFieldEditor( ICLineBreakpoint.ADDRESS ,title, parent);
|
||||
fe.setEmptyStringAllowed(false);
|
||||
addField( fe );
|
||||
}
|
||||
protected void createWatchExpressionEditor( Composite parent ) {
|
||||
ICBreakpoint breakpoint = getBreakpoint();
|
||||
if (breakpoint == null || breakpoint.getMarker() == null) {
|
||||
BreakpointStringFieldEditor expressionEditor =new BreakpointStringFieldEditor(
|
||||
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 ) {
|
||||
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 );
|
||||
}
|
||||
|
||||
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.setErrorMessage( BreakpointsMessages.getString( "CBreakpointPropertyPage.16" ) ); //$NON-NLS-1$
|
||||
fCondition.setErrorMessage( BreakpointsMessages.getString( "CBreakpointPropertyPage.condition_invalidValue_message" ) ); //$NON-NLS-1$
|
||||
addField( fCondition );
|
||||
}
|
||||
|
||||
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 );
|
||||
fIgnoreCountTextControl = fIgnoreCount.getTextControl( parent );
|
||||
fIgnoreCountTextControl.setEnabled( getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0 );
|
||||
|
@ -366,13 +398,26 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
|||
IAdaptable element = getElement();
|
||||
if (element instanceof ICBreakpoint) {
|
||||
return (ICBreakpoint)element;
|
||||
} else if (element instanceof CBreakpointContext) {
|
||||
return ((CBreakpointContext)element).getBreakpoint();
|
||||
} else if (element instanceof ICBreakpointContext) {
|
||||
return ((ICBreakpointContext)element).getBreakpoint();
|
||||
} else {
|
||||
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() {
|
||||
IAdaptable element = getElement();
|
||||
if (element instanceof ICBreakpointContext) {
|
||||
|
|
|
@ -151,23 +151,52 @@ abstract public class AbstractToggleBreakpointAdapter
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreateBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
|
||||
return canToggleBreakpoints( part, selection );
|
||||
public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
|
||||
return canToggleLineBreakpoints( part, selection );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
|
||||
updateBreakpoints(false, true, part, selection);
|
||||
public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
|
||||
updateLineBreakpoints(false, true, part, selection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreateWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) {
|
||||
public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection) {
|
||||
// Gather all input from user if needed.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
|
||||
createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, "");
|
||||
public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.eclipse.ui.IWorkbenchPart;
|
|||
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
|
||||
* breakpoint interactively then it should return <code>false</code>.
|
||||
* <p>
|
||||
|
@ -43,12 +43,15 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa
|
|||
* @return Returns <code>true</code> if toggle target is able interactively
|
||||
* 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
|
||||
* the user to edit all of the breakpoint's settings prior to creating the
|
||||
* breakpoint.
|
||||
* Creates new line breakpoints 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
|
||||
|
@ -58,10 +61,73 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa
|
|||
* @param selection selection on which line breakpoints should be toggled
|
||||
* @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
|
||||
* 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);
|
||||
|
||||
public void createWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ commandContext.name= In Disassembly
|
|||
commandContext.description= When debugging in assembly mode
|
||||
|
||||
# actions
|
||||
action.breakpointProperties.label = Breakpoint Properties...
|
||||
action.toggleBreakpoint.label = Toggle Breakpoint
|
||||
action.breakpointProperties.label = Breakpoint Properties...\Ctrl+Double Click
|
||||
action.toggleBreakpoint.label = Toggle Breakpoint\tDouble Click
|
||||
action.addBreakpoint.label = Add Breakpoint...\tCtrl+Double Click
|
||||
|
||||
menu.updatePolicy = Update Policy
|
||||
menu.threadsUpdatePolicy = Threads Update Policy
|
||||
|
|
|
@ -580,6 +580,12 @@
|
|||
label="%action.breakpointProperties.label"
|
||||
menubarPath="debug">
|
||||
</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
|
||||
class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.RulerToggleBreakpointActionDelegate"
|
||||
definitionId="org.eclipse.cdt.dsf.debug.ui.disassembly.commands.rulerToggleBreakpoint"
|
||||
|
|
|
@ -10,12 +10,17 @@
|
|||
*******************************************************************************/
|
||||
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.debug.core.CDIDebugModel;
|
||||
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.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
/**
|
||||
* 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$
|
||||
}
|
||||
|
||||
@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)
|
||||
* @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$
|
||||
}
|
||||
|
||||
@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() {
|
||||
return ICBreakpointType.REGULAR;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,9 @@ public final class DisassemblyMessages extends NLS {
|
|||
public static String Disassembly_Error_Dialog_title;
|
||||
public static String Disassembly_Error_Dialog_ok_button;
|
||||
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 {
|
||||
NLS.initializeMessages(DisassemblyMessages.class.getName(), DisassemblyMessages.class);
|
||||
|
|
|
@ -18,13 +18,16 @@ Disassembly_action_GotoPC_tooltip=Go to Current Program Counter
|
|||
Disassembly_action_GotoAddress_label=Go to Address...
|
||||
Disassembly_action_Copy_label=&Copy
|
||||
Disassembly_action_SelectAll_label=Select &All
|
||||
Disassembly_action_BreakpointProperties_label=Breakpoint Properties...
|
||||
Disassembly_action_DisableBreakpoint_label=Disable Breakpoint
|
||||
Disassembly_action_EnableBreakpoint_label=Enable Breakpoint
|
||||
Disassembly_action_BreakpointProperties_label=Breakpoint Properties...\tCtrl+Double Click
|
||||
Disassembly_action_DisableBreakpoint_label=Disable Breakpoint\tShift+Double Click
|
||||
Disassembly_action_EnableBreakpoint_label=Enable Breakpoint\tShift+Double Click
|
||||
Disassembly_action_RefreshView_label=Re&fresh View
|
||||
Disassembly_action_OpenPreferences_label=&Preferences...
|
||||
Disassembly_action_Sync_label=Link with Active Debug Context
|
||||
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_label=Address expression:
|
||||
|
|
|
@ -156,6 +156,7 @@ import org.eclipse.swt.layout.FillLayout;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.ToolBar;
|
||||
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$
|
||||
fVerticalRuler.getControl().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent e) {
|
||||
public void mouseDoubleClick(final MouseEvent e) {
|
||||
// invoke toggle breakpoint
|
||||
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
|
||||
if (handlerService != null) {
|
||||
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) {
|
||||
DsfUIPlugin.log(exc);
|
||||
} catch (NotDefinedException exc) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ 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.swt.widgets.Event;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
|
@ -39,7 +40,14 @@ public class RulerToggleBreakpointHandler extends AbstractHandler {
|
|||
final ToggleBreakpointAction toggleBpAction= new ToggleBreakpointAction(part, document, rulerInfo);
|
||||
toggleBpAction.update();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,14 @@ import java.net.URI;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.IDisassemblyPart;
|
||||
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.debug.core.DebugPlugin;
|
||||
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.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.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
|
||||
|
||||
/**
|
||||
* Base class for toggle breakpoint targets for the disassembly part.
|
||||
* @since 2.2
|
||||
*/
|
||||
public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBreakpointsTargetExtension {
|
||||
public abstract class AbstractDisassemblyBreakpointsTarget
|
||||
implements IToggleBreakpointsTargetExtension2, IToggleBreakpointsTargetCExtension
|
||||
{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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();
|
||||
IBreakpoint[] bp = getBreakpointsAtLine( (IDisassemblyPart)part, line );
|
||||
if ( bp == null || bp.length == 0 ) {
|
||||
insertBreakpoint( disassemblySelection );
|
||||
insertBreakpoint(part, disassemblySelection, false);
|
||||
}
|
||||
else {
|
||||
for( int i = 0; i < bp.length; i++ ) {
|
||||
|
@ -121,10 +134,126 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre
|
|||
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;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @since 2.3
|
||||
*/
|
||||
protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address ) throws CoreException {
|
||||
createAddressBreakpoint(resource, address);
|
||||
}
|
||||
|
||||
private IBreakpoint[] getBreakpointsAtLine( IDisassemblyPart part, int line ) {
|
||||
List<IBreakpoint> breakpoints = new ArrayList<IBreakpoint>();
|
||||
IAnnotationModel annotationModel = part.getTextViewer().getAnnotationModel();
|
||||
|
@ -159,7 +288,7 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre
|
|||
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();
|
||||
if ( address == null ) {
|
||||
return;
|
||||
|
@ -180,11 +309,53 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre
|
|||
filePath = URIUtil.toPath( fileUri ).toOSString();
|
||||
}
|
||||
int srcLine = selection.getSourceLine();
|
||||
createLineBreakpoint( filePath, resource, srcLine + 1 );
|
||||
if (interactive) {
|
||||
createLineBreakpointInteractive(part, filePath, resource, srcLine + 1 );
|
||||
} else {
|
||||
createLineBreakpoint( filePath, resource, srcLine + 1 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue