Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Method and function breakpoints

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v
retrieving revision 1.127
diff -u -r1.127 ChangeLog
--- ChangeLog 8 Apr 2003 21:06:50 -0000 1.127
+++ ChangeLog 11 Apr 2003 22:34:39 -0000
@@ -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
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.properties,v
retrieving revision 1.40
diff -u -r1.40 plugin.properties
--- plugin.properties 2 Apr 2003 22:01:21 -0000 1.40
+++ plugin.properties 11 Apr 2003 22:34:39 -0000
@@ -33,6 +33,8 @@
 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_...
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.xml,v
retrieving revision 1.60
diff -u -r1.60 plugin.xml
--- plugin.xml 2 Apr 2003 22:01:21 -0000 1.60
+++ plugin.xml 11 Apr 2003 22:34:39 -0000
@@ -854,6 +854,25 @@
             </enablement>
          </action>
       </objectContribution>
+      <objectContribution
+            objectClass="org.eclipse.cdt.core.model.IFunction"
+            id="org.eclipse.cdt.debug.ui.FunctionBreakpointActions">
+         <action
+               label="%ManageFunctionBreakpointAction.label"
+               helpContextId="manage_function_breakpoint_action_context"
+               tooltip="%ManageFunctionBreakpointAction.tooltip"
+               class="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate"
+               menubarPath="additions"
+               enablesFor="1"
+               id="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate">
+            <enablement>
+               <pluginState
+                     value="installed"
+                     id="org.eclipse.cdt.debug.ui">
+               </pluginState>
+            </enablement>
+         </action>
+      </objectContribution>
    </extension>
    <extension
          point="org.eclipse.ui.viewActions">
Index: icons/full/obj16/brkpd_obj.gif
===================================================================
RCS file: icons/full/obj16/brkpd_obj.gif
diff -N icons/full/obj16/brkpd_obj.gif
Binary files /dev/null and brkpd_obj.gif differ
Index: icons/full/obj16/funbrkp_obj.gif
===================================================================
RCS file: icons/full/obj16/funbrkp_obj.gif
diff -N icons/full/obj16/funbrkp_obj.gif
Binary files /dev/null and funbrkp_obj.gif differ
Index: icons/full/obj16/funbrkpd_obj.gif
===================================================================
RCS file: icons/full/obj16/funbrkpd_obj.gif
diff -N icons/full/obj16/funbrkpd_obj.gif
Binary files /dev/null and funbrkpd_obj.gif differ
Index: src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java,v
retrieving revision 1.46
diff -u -r1.46 CDTDebugModelPresentation.java
--- src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java 18 Mar 2003 22:31:51 -0000 1.46
+++ src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java 11 Apr 2003 22:34:40 -0000
@@ -531,6 +531,10 @@
   {
    return getAddressBreakpointImage( (ICAddressBreakpoint)breakpoint );
   }
+  if ( breakpoint instanceof ICFunctionBreakpoint )
+  {
+   return getFunctionBreakpointImage( (ICFunctionBreakpoint)breakpoint );
+  }
   if ( breakpoint instanceof ICLineBreakpoint )
   {
    return getLineBreakpointImage( (ICLineBreakpoint)breakpoint );
@@ -572,6 +576,21 @@
   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 @@
   {
    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 @@
 
  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
@@ -691,6 +715,20 @@
   }
   catch( NumberFormatException e )
   {
+  }
+  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;
  }
Index: src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java,v
retrieving revision 1.19
diff -u -r1.19 CDebugImages.java
--- src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java 1 Apr 2003 16:51:23 -0000 1.19
+++ src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java 11 Apr 2003 22:34:40 -0000
@@ -53,6 +53,8 @@
  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 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 );
Index: src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java,v
retrieving revision 1.6
diff -u -r1.6 CBreakpointPreferencePage.java
--- src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java 10 Jan 2003 19:36:39 -0000 1.6
+++ src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java 11 Apr 2003 22:34:40 -0000
@@ -7,6 +7,7 @@
 
 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 @@
   */
  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";
Index: src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java
diff -N src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java 11 Apr 2003 22:34:41 -0000
@@ -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;
+ }
+}
Index: src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java,v
retrieving revision 1.1
diff -u -r1.1 DisassemblyMarkerAnnotation.java
--- src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java 10 Jan 2003 19:36:39 -0000 1.1
+++ src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotation.java 11 Apr 2003 22:34:41 -0000
@@ -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 @@
   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();
Index: src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java,v
retrieving revision 1.1
diff -u -r1.1 DisassemblyMarkerAnnotationModel.java
--- src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java 10 Jan 2003 19:36:39 -0000 1.1
+++ src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java 11 Apr 2003 22:34:41 -0000
@@ -11,6 +11,7 @@
 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 @@
   try
   {
    return ( marker.getType().equals( CLineBreakpoint.getMarkerType() ) ||
+      marker.getType().equals( CFunctionBreakpoint.getMarkerType() ) ||
       marker.getType().equals( CAddressBreakpoint.getMarkerType() ) );
   }
   catch( CoreException e )
@@ -218,6 +220,10 @@
   try
   {
    if ( marker.getType().equals( CLineBreakpoint.getMarkerType() ) )
+   {
+    return createPositionFromLineBreakpoint( marker );
+   }
+   if ( marker.getType().equals( CFunctionBreakpoint.getMarkerType() ) )
    {
     return createPositionFromLineBreakpoint( marker );
    }

Back to the top