1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Method and function breakpoints.

This commit is contained in:
Mikhail Khodjaiants 2003-04-11 22:36:17 +00:00
parent ee742625a1
commit 4befd93ed7
12 changed files with 261 additions and 7 deletions

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

View file

@ -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...

View file

@ -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">

View file

@ -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();

View file

@ -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 );

View file

@ -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";

View file

@ -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;
}
}

View file

@ -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();

View file

@ -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 );