diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 54bc0312f99..c782f088d7d 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,17 @@ +2003-04-11 Mikhail Khodjaiants + Method and function breakpoints. + * plugin.properties + * plugin.xml + * icons/full/obj16/brkpd_obj.gif: new + * icons/full/obj16/funbrkp_obj.gif: new + * icons/full/obj16/funbrkpd_obj.gif: new + * CDTDebugModelPresentation.java + * CDebugImages.java + * CBreakpointPreferencePage.java + * ManageFunctionBreakpointActionDelegate.java: new + * DisassemblyMarkerAnnotation.java + * DisassemblyMarkerAnnotationModel.java + 2003-04-08 Mikhail Khodjaiants Removed unused private methods and members. * CDebugEditor.java diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/brkpd_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/brkpd_obj.gif new file mode 100644 index 00000000000..8e8cac5a9d7 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/brkpd_obj.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/funbrkp_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/funbrkp_obj.gif new file mode 100644 index 00000000000..a61b6bce3d7 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/funbrkp_obj.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/funbrkpd_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/funbrkpd_obj.gif new file mode 100644 index 00000000000..f047c8ec4b3 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/funbrkpd_obj.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 35d9ee8bf89..a4cb0ce86bf 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -33,6 +33,8 @@ AddBreakpoint.label=Add/Remove &Breakpoint EnableBreakpoint.label=T&oggle Breakpoint BreakpointProperties.label=Breakpoint P&roperties... GlobalManageBreakpointAction.label=Add/Remove Brea&kpoint (C/C++) +ManageFunctionBreakpointAction.label=Add/Remove Breakpoint +ManageFunctionBreakpointAction.tooltip=Add/Remove Function Breakpoint BreakpointPropertiesAction.label=P&roperties... GlobalManageWatchpointAction.label=Add &Watchpoint (C/C++)... AddExpressionAction.label=Add &Expression... diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 851db3061ed..5cbfa0fbe84 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -854,6 +854,25 @@ + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java index 0a76e201d50..1fa812be608 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java @@ -531,6 +531,10 @@ public class CDTDebugModelPresentation extends LabelProvider { return getAddressBreakpointImage( (ICAddressBreakpoint)breakpoint ); } + if ( breakpoint instanceof ICFunctionBreakpoint ) + { + return getFunctionBreakpointImage( (ICFunctionBreakpoint)breakpoint ); + } if ( breakpoint instanceof ICLineBreakpoint ) { return getLineBreakpointImage( (ICLineBreakpoint)breakpoint ); @@ -572,6 +576,21 @@ public class CDTDebugModelPresentation extends LabelProvider return fDebugImageRegistry.get( descriptor ); } + protected Image getFunctionBreakpointImage( ICFunctionBreakpoint breakpoint ) throws CoreException + { + int flags = computeBreakpointAdornmentFlags( breakpoint ); + CImageDescriptor descriptor = null; + if ( breakpoint.isEnabled() ) + { + descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_FUNCTION_BREAKPOINT_ENABLED, flags ); + } + else + { + descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_FUNCTION_BREAKPOINT_DISABLED, flags ); + } + return fDebugImageRegistry.get( descriptor ); + } + protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException { int flags = computeBreakpointAdornmentFlags( watchpoint ); @@ -608,14 +627,14 @@ public class CDTDebugModelPresentation extends LabelProvider { return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified ); } - if ( breakpoint instanceof ICLineBreakpoint ) - { - return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified ); - } if ( breakpoint instanceof ICFunctionBreakpoint ) { return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified ); } + if ( breakpoint instanceof ICLineBreakpoint ) + { + return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified ); + } if ( breakpoint instanceof ICWatchpoint ) { return getWatchpointText( (ICWatchpoint)breakpoint, qualified ); @@ -655,7 +674,12 @@ public class CDTDebugModelPresentation extends LabelProvider protected String getFunctionBreakpointText( ICFunctionBreakpoint breakpoint, boolean qualified ) throws CoreException { - return null; + StringBuffer label = new StringBuffer(); + appendResourceName( breakpoint, label, qualified ); + appendFunction( breakpoint, label ); + appendIgnoreCount( breakpoint, label ); + appendCondition( breakpoint, label ); + return label.toString(); } protected StringBuffer appendResourceName( ICBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException @@ -695,6 +719,20 @@ public class CDTDebugModelPresentation extends LabelProvider return label; } + protected StringBuffer appendFunction( ICFunctionBreakpoint breakpoint, StringBuffer label ) throws CoreException + { + String function = breakpoint.getFunction(); + if ( function != null && function.trim().length() > 0 ) + { + label.append( " [" ); //$NON-NLS-1$ + label.append( "function:" ); + label.append( ' ' ); + label.append( function.trim() ); + label.append( ']' ); + } + return label; + } + protected StringBuffer appendIgnoreCount( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException { int ignoreCount = breakpoint.getIgnoreCount(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index abf894d3481..36ad61ac309 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -53,6 +53,8 @@ public class CDebugImages public static final String IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED = NAME_PREFIX + "addrbrkp_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED = NAME_PREFIX + "addrbrkpd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_FUNCTION_BREAKPOINT_ENABLED = NAME_PREFIX + "funbrkp_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_FUNCTION_BREAKPOINT_DISABLED = NAME_PREFIX + "funbrkpd_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_WATCHPOINT_ENABLED = NAME_PREFIX + "readwrite_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_WATCHPOINT_DISABLED = NAME_PREFIX + "readwrite_obj_disabled.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_READ_WATCHPOINT_ENABLED = NAME_PREFIX + "read_obj.gif"; //$NON-NLS-1$ @@ -104,6 +106,8 @@ public class CDebugImages public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED ); public static final ImageDescriptor DESC_OBJS_ADDRESS_BREAKPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED ); public static final ImageDescriptor DESC_OBJS_ADDRESS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED ); + public static final ImageDescriptor DESC_OBJS_FUNCTION_BREAKPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_FUNCTION_BREAKPOINT_ENABLED ); + public static final ImageDescriptor DESC_OBJS_FUNCTION_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_FUNCTION_BREAKPOINT_DISABLED ); public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED ); public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_DISABLED ); public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_ENABLED ); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java index c459701ff49..bf1ac4f6b9a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java @@ -7,6 +7,7 @@ package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.internal.core.CDebugUtils; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; @@ -289,7 +290,27 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage */ private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint ) { - if ( breakpoint instanceof ICAddressBreakpoint ) + if ( breakpoint instanceof ICFunctionBreakpoint ) + { + ICFunctionBreakpoint fbrkpt = (ICFunctionBreakpoint)breakpoint; + String function = "Not available"; + try + { + function = fbrkpt.getFunction(); + } + catch( CoreException e ) + { + } + catch( NumberFormatException e ) + { + } + if ( function != null ) + { + addField( createLabelEditor( getFieldEditorParent(), "Function name: ", function ) ); + } + setTitle( "C/C++ Function Breakpoint Properties" ); + } + else if ( breakpoint instanceof ICAddressBreakpoint ) { ICAddressBreakpoint abrkpt = (ICAddressBreakpoint)breakpoint; String address = "Not available"; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java new file mode 100644 index 00000000000..b33c884ab45 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java @@ -0,0 +1,148 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.IFunction; +import org.eclipse.cdt.core.model.IMethod; +import org.eclipse.cdt.debug.core.CDebugModel; +import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.actions.ActionDelegate; + +/** + * Enter type comment. + * + * @since Apr 2, 2003 + */ +public class ManageFunctionBreakpointActionDelegate extends ActionDelegate + implements IObjectActionDelegate +{ +// private IFunction fFunction = null; + private ICElement fElement = null; + + /** + * + */ + public ManageFunctionBreakpointActionDelegate() + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) + */ + public void setActivePart( IAction action, IWorkbenchPart targetPart ) + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run( IAction action ) + { + if ( getMethod() != null ) + manageBreakpoint( getMethod() ); + else if ( getFunction() != null ) + manageBreakpoint( getFunction() ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged( IAction action, ISelection selection ) + { + if ( selection instanceof IStructuredSelection ) + { + Object element = ((IStructuredSelection)selection).getFirstElement(); + if ( element instanceof ICElement ) + { + boolean enabled = enablesFor( (ICElement)element ); + action.setEnabled( enabled ); + if ( enabled ) + { + setElement( (ICElement)element ); + return; + } + } + } + action.setEnabled( false ); + setElement( null ); + } + + public ICElement getElement() + { + return fElement; + } + + public void setElement( ICElement element ) + { + fElement = element; + } + + private boolean enablesFor( ICElement element ) + { + // for now + return true; + } + + private void manageBreakpoint( IFunction function ) + { + try + { + ICFunctionBreakpoint breakpoint = CDebugModel.functionBreakpointExists( function ); + if ( breakpoint != null ) + { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); + } + else + { + CDebugModel.createFunctionBreakpoint( function, true, 0, "", true ); + } + } + catch( CoreException e ) + { + CDebugUIPlugin.errorDialog( "Cannot add breakpoint", e ); + } + } + + private IFunction getFunction() + { + return ( getElement() != null ) ? (IFunction)getElement().getAdapter( IFunction.class ) : null; + } + + private void manageBreakpoint( IMethod method ) + { + try + { + ICFunctionBreakpoint breakpoint = CDebugModel.methodBreakpointExists( method ); + if ( breakpoint != null ) + { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); + } + else + { + CDebugModel.createMethodBreakpoint( method, true, 0, "", true ); + } + } + catch( CoreException e ) + { + CDebugUIPlugin.errorDialog( "Cannot add breakpoint", e ); + } + } + + private IMethod getMethod() + { + return ( getElement() != null ) ? (IMethod)getElement().getAdapter( IMethod.class ) : null; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java index 08e66b3a3c2..2b9e5b7a577 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java @@ -6,6 +6,7 @@ package org.eclipse.cdt.debug.internal.ui.editors; import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint; +import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint; import org.eclipse.core.resources.IMarker; import org.eclipse.debug.ui.DebugUITools; @@ -39,7 +40,8 @@ public class DisassemblyMarkerAnnotation extends MarkerAnnotation IMarker marker = getMarker(); if ( MarkerUtilities.isMarkerType( marker, CLineBreakpoint.getMarkerType() ) || - MarkerUtilities.isMarkerType( marker, CAddressBreakpoint.getMarkerType() ) ) + MarkerUtilities.isMarkerType( marker, CFunctionBreakpoint.getMarkerType() ) || + MarkerUtilities.isMarkerType( marker, CAddressBreakpoint.getMarkerType() ) ) { if ( fPresentation == null ) fPresentation = DebugUITools.newDebugModelPresentation(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java index 2a5174d4d6e..0c715b2b635 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java @@ -11,6 +11,7 @@ import org.eclipse.cdt.debug.core.ICBreakpointManager; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage; import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint; +import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; @@ -167,6 +168,7 @@ public class DisassemblyMarkerAnnotationModel extends AbstractMarkerAnnotationMo try { return ( marker.getType().equals( CLineBreakpoint.getMarkerType() ) || + marker.getType().equals( CFunctionBreakpoint.getMarkerType() ) || marker.getType().equals( CAddressBreakpoint.getMarkerType() ) ); } catch( CoreException e ) @@ -221,6 +223,10 @@ public class DisassemblyMarkerAnnotationModel extends AbstractMarkerAnnotationMo { return createPositionFromLineBreakpoint( marker ); } + if ( marker.getType().equals( CFunctionBreakpoint.getMarkerType() ) ) + { + return createPositionFromLineBreakpoint( marker ); + } if ( marker.getType().equals( CAddressBreakpoint.getMarkerType() ) ) { return createPositionFromAddressBreakpoint( marker );