mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Core support of function breakpoints.
This commit is contained in:
parent
7e62df880f
commit
e77cef039e
4 changed files with 135 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <code>"org.eclipse.cdt.debug.core.function"</code>).
|
||||
* This attribute is a <code>String</code>.
|
||||
*/
|
||||
public static final String FUNCTION = "org.eclipse.cdt.debug.core.function"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns the function this breakpoint suspends execution in.
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue