diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog
index 9ad6a7e7f7c..8e14e284b7c 100644
--- a/debug/org.eclipse.cdt.debug.core/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.core/ChangeLog
@@ -1,3 +1,9 @@
+2003-04-09 Mikhail Khodjaiants
+ Core support of function breakpoints.
+ * CDebugModel.java
+ * ICFunctionBreakpoint.java
+ * CDebugTarget.java
+
2003-04-07 Mikhail Khodjaiants
Changed the message text in the 'getStackDepth' method.
* CThread.java
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
index 97d1c2201af..e461b2a7eed 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
@@ -9,6 +9,10 @@ package org.eclipse.cdt.debug.core;
import java.text.MessageFormat;
import java.util.HashMap;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IFunction;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
@@ -21,12 +25,14 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
+import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
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.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
@@ -352,6 +358,7 @@ public class CDebugModel
attributes.put( IMarker.CHAR_START, new Integer( 0 ) );
attributes.put( IMarker.CHAR_END, new Integer( 0 ) );
attributes.put( IMarker.LINE_NUMBER, new Integer( -1 ) );
+ attributes.put( IMarker.LINE_NUMBER, new Integer( -1 ) );
attributes.put( ICAddressBreakpoint.ADDRESS, Long.toString( address ) );
attributes.put( ICBreakpoint.ENABLED, new Boolean( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
@@ -359,6 +366,70 @@ public class CDebugModel
return new CAddressBreakpoint( resource, attributes, add );
}
+ public static ICFunctionBreakpoint functionBreakpointExists( IFunction function ) throws CoreException
+ {
+ String modelId = getPluginIdentifier();
+ String markerType = CFunctionBreakpoint.getMarkerType();
+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
+ IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
+ for ( int i = 0; i < breakpoints.length; i++ )
+ {
+ if ( !( breakpoints[i] instanceof ICFunctionBreakpoint ) )
+ {
+ continue;
+ }
+ ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint)breakpoints[i];
+ if ( breakpoint.getMarker().getType().equals( markerType ) )
+ {
+ if ( breakpoint.getMarker().getResource().equals( getFunctionResource( function ) ) )
+ {
+ if ( breakpoint.getFunction() != null && breakpoint.getFunction().equals( function.getElementName() ) )
+ {
+ return breakpoint;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static ICFunctionBreakpoint createFunctionBreakpoint( IFunction function,
+ boolean enabled,
+ int ignoreCount,
+ String condition,
+ boolean add ) throws DebugException
+ {
+ HashMap attributes = new HashMap( 10 );
+ attributes.put( ICBreakpoint.ID, getPluginIdentifier() );
+ int lineNumber = -1;
+ int charStart = -1;
+ int charEnd = -1;
+ try
+ {
+ ISourceRange sourceRange = function.getSourceRange();
+ if ( sourceRange != null )
+ {
+ charStart = sourceRange.getStartPos();
+ charEnd = charStart + sourceRange.getLength();
+ // for now
+ if ( charEnd == 0 )
+ lineNumber = sourceRange.getStartLine();
+ }
+ }
+ catch( CModelException e )
+ {
+ CDebugCorePlugin.log( e.getStatus() );
+ }
+ attributes.put( IMarker.CHAR_START, new Integer( charStart ) );
+ attributes.put( IMarker.CHAR_END, new Integer( charEnd ) );
+ attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
+ attributes.put( ICFunctionBreakpoint.FUNCTION, function.getElementName() );
+ attributes.put( ICBreakpoint.ENABLED, new Boolean( enabled ) );
+ attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
+ attributes.put( ICBreakpoint.CONDITION, condition );
+ return new CFunctionBreakpoint( getFunctionResource( function ), attributes, add );
+ }
+
public static ICWatchpoint watchpointExists( IResource resource, boolean write, boolean read, String expression ) throws CoreException
{
String modelId = getPluginIdentifier();
@@ -527,4 +598,10 @@ public class CDebugModel
}
}
}
+
+ private static IResource getFunctionResource( IFunction function )
+ {
+ ITranslationUnit tu = function.getTranslationUnit();
+ return ( tu != null ) ? tu.getResource() : null;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java
index b5ccece2264..b5ecf9eea4d 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java
@@ -15,6 +15,13 @@ import org.eclipse.core.runtime.CoreException;
*/
public interface ICFunctionBreakpoint extends ICLineBreakpoint
{
+ /**
+ * Breakpoint attribute storing the function this breakpoint suspends
+ * execution at (value "org.eclipse.cdt.debug.core.function"
).
+ * This attribute is a String
.
+ */
+ public static final String FUNCTION = "org.eclipse.cdt.debug.core.function"; //$NON-NLS-1$
+
/**
* Returns the function this breakpoint suspends execution in.
*
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
index 516708c05ed..65d80c26f99 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
@@ -61,6 +61,7 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator;
+import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport;
@@ -697,7 +698,11 @@ public class CDebugTarget extends CDebugElement
{
try
{
- if ( breakpoint instanceof ICAddressBreakpoint )
+ if ( breakpoint instanceof ICFunctionBreakpoint )
+ {
+ setFunctionBreakpoint( (ICFunctionBreakpoint)breakpoint );
+ }
+ else if ( breakpoint instanceof ICAddressBreakpoint )
{
if ( supportsAddressBreakpoint( (ICAddressBreakpoint)breakpoint ) )
setAddressBreakpoint( (ICAddressBreakpoint)breakpoint );
@@ -1939,6 +1944,45 @@ public class CDebugTarget extends CDebugElement
return cdiBreakpoint;
}
+ private void setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws DebugException
+ {
+ try
+ {
+ ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)getBreakpoints().get( breakpoint );
+ if ( cdiBreakpoint == null )
+ {
+ cdiBreakpoint = setFunctionBreakpoint0( breakpoint );
+ }
+ ((CBreakpoint)breakpoint).incrementInstallCount();
+ if ( !breakpoint.isEnabled() )
+ {
+ cdiBreakpoint.setEnabled( false );
+ }
+ }
+ catch( CoreException ce )
+ {
+ requestFailed( "Operation failed. Reason: ", ce );
+ }
+ catch( CDIException e )
+ {
+ requestFailed( "Operation failed. Reason: ", e );
+ }
+ catch( NumberFormatException e )
+ {
+ requestFailed( "Operation failed. Reason: ", e );
+ }
+ }
+
+ private synchronized ICDIBreakpoint setFunctionBreakpoint0( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException
+ {
+ ICDIBreakpointManager bm = getCDISession().getBreakpointManager();
+ ICDILocation location = bm.createLocation( null, breakpoint.getFunction(), -1 );
+ ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() );
+ ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, condition, null );
+ getBreakpoints().put( breakpoint, cdiBreakpoint );
+ return cdiBreakpoint;
+ }
+
private void setWatchpoint( ICWatchpoint watchpoint ) throws DebugException
{
try