1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 09:45:39 +02:00

Fix for bug 79452: Unable to set a breakpoint on a class method.

This commit is contained in:
Mikhail Khodjaiants 2004-11-25 23:58:29 +00:00
parent e22e2cadc1
commit 7877aedb36
6 changed files with 64 additions and 53 deletions

View file

@ -1,3 +1,8 @@
2004-11-25 Mikhail Khodjaiants
Fix for bug 79452: Unable to set a breakpoint on a class method.
* CDebugUtils.java: cleanup.
* CBreakpointManager.java
2004-11-25 Mikhail Khodjaiants
The "decrementInstallCount" method of IBreakpoint should be called from the UI thread.
Replaced the "breakpointRemoved" method of ICBreakpointListener by the "breakpointsRemoved"

View file

@ -22,14 +22,10 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.model.IFunction;
import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.internal.core.model.CFloatingPointValue;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.DebugPlugin;
@ -214,42 +210,6 @@ public class CDebugUtils {
return s.toString( "UTF8" ); //$NON-NLS-1$
}
public static IResource getFunctionResource( IFunction function ) {
ITranslationUnit tu = function.getTranslationUnit();
return (tu != null) ? tu.getResource() : function.getCProject().getProject();
}
public static IResource getMethodResource( IMethod method ) {
ITranslationUnit tu = method.getTranslationUnit();
return (tu != null) ? tu.getResource() : method.getCProject().getProject();
}
public static String getFunctionName( IFunction function ) {
String functionName = function.getElementName();
StringBuffer name = new StringBuffer( functionName );
if ( functionName.indexOf( "::" ) != -1 ) //$NON-NLS-1$
{
String[] params = function.getParameterTypes();
name.append( '(' );
if ( params.length == 0 ) {
name.append( "void" ); //$NON-NLS-1$
}
else {
for( int i = 0; i < params.length; ++i ) {
name.append( params[i] );
if ( i != params.length - 1 )
name.append( ',' );
}
}
name.append( ')' );
}
return name.toString();
}
public static String getMethodQualifiedName( IMethod method ) {
return null;
}
public static Number getFloatingPointValue( ICValue value ) {
if ( value instanceof CFloatingPointValue ) {
try {

View file

@ -533,8 +533,9 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
final boolean enabled = breakpoint.isEnabled();
final ICDITarget cdiTarget = getCDITarget();
String function = breakpoint.getFunction();
String fileName = (function != null && function.indexOf( "::" ) == -1) ? breakpoint.getFileName() : null; //$NON-NLS-1$
final ICDILocation location = cdiTarget.createLocation( fileName, function, -1 );
String fileName = breakpoint.getFileName();
int lineNumber = breakpoint.getLineNumber();
final ICDILocation location = cdiTarget.createLocation( fileName, function, lineNumber );
final ICDICondition condition = createCondition( breakpoint );
setLocationBreakpointOnTarget( breakpoint, cdiTarget, location, condition, enabled );
}

View file

@ -1,3 +1,8 @@
2004-11-25 Mikhail Khodjaiants
Fix for bug 79452: Unable to set a breakpoint on a class method.
* plugin.xml
* ToggleBreakpointAdapter.java
2004-11-25 Mikhail Khodjaiants
Replaced the "breakpointRemoved" method of ICBreakpointListener by the "breakpointsRemoved"
method that accepts multiple breakpoints.

View file

@ -595,6 +595,20 @@
id="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate">
</action>
</objectContribution>
<objectContribution
objectClass="org.eclipse.cdt.core.model.IMethod"
id="org.eclipse.cdt.debug.ui.FunctionBreakpointActions">
<action
label="%ManageFunctionBreakpointAction.label"
icon="icons/full/elcl16/function_brkpt_co.gif"
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">
</action>
</objectContribution>
<objectContribution
objectClass="org.eclipse.cdt.core.model.IVariable"
id="org.eclipse.cdt.debug.ui.WatchpointActions">

View file

@ -12,8 +12,10 @@ package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IDeclaration;
import org.eclipse.cdt.core.model.IFunction;
import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IVariable;
@ -161,11 +163,11 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
public void toggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
if ( selection instanceof IStructuredSelection ) {
IStructuredSelection ss = (IStructuredSelection)selection;
if ( ss.size() == 1 && ss.getFirstElement() instanceof IFunction ) {
IFunction function = (IFunction)ss.getFirstElement();
String sourceHandle = getSourceHandle( function );
IResource resource = getElementResource( function );
String functionName = getFunctionName( function );
if ( ss.size() == 1 && (ss.getFirstElement() instanceof IFunction || ss.getFirstElement() instanceof IMethod) ) {
IDeclaration declaration = (IDeclaration)ss.getFirstElement();
String sourceHandle = getSourceHandle( declaration );
IResource resource = getElementResource( declaration );
String functionName = ( declaration instanceof IFunction ) ? getFunctionName( (IFunction)declaration ) : getMethodName( (IMethod)declaration );
ICFunctionBreakpoint breakpoint = CDIDebugModel.functionBreakpointExists( sourceHandle, resource, functionName );
if ( breakpoint != null ) {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
@ -175,7 +177,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
int charStart = -1;
int charEnd = -1;
try {
ISourceRange sourceRange = function.getSourceRange();
ISourceRange sourceRange = declaration.getSourceRange();
if ( sourceRange != null ) {
charStart = sourceRange.getStartPos();
charEnd = charStart + sourceRange.getLength();
@ -201,8 +203,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
true );
}
}
}
}
}
/* (non-Javadoc)
@ -212,7 +213,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
if ( selection instanceof IStructuredSelection ) {
IStructuredSelection ss = (IStructuredSelection)selection;
if ( ss.size() == 1 ) {
return ( ss.getFirstElement() instanceof IFunction );
return ( ss.getFirstElement() instanceof IFunction || ss.getFirstElement() instanceof IMethod );
}
}
return false;
@ -381,8 +382,8 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
private String getFunctionName( IFunction function ) {
String functionName = function.getElementName();
StringBuffer name = new StringBuffer( functionName );
//??????
if ( functionName.indexOf( "::" ) != -1 && functionName.indexOf( '(' ) == -1 ) { //$NON-NLS-1$
ITranslationUnit tu = function.getTranslationUnit();
if ( tu != null && tu.isCXXLanguage() ) {
String[] params = function.getParameterTypes();
name.append( '(' );
if ( params.length == 0 ) {
@ -400,6 +401,31 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
return name.toString();
}
private String getMethodName( IMethod method ) {
StringBuffer name = new StringBuffer();
String methodName = method.getElementName();
ICElement parent = method.getParent();
while ( parent != null && ( parent.getElementType() == ICElement.C_NAMESPACE || parent.getElementType() == ICElement.C_CLASS ) ) {
name.append( parent.getElementName() ).append( "::" ); //$NON-NLS-1$
parent = parent.getParent();
}
name.append( methodName );
String[] params = method.getParameterTypes();
name.append( '(' );
if ( params.length == 0 ) {
name.append( "void" ); //$NON-NLS-1$
}
else {
for( int i = 0; i < params.length; ++i ) {
name.append( params[i] );
if ( i != params.length - 1 )
name.append( ',' );
}
}
name.append( ')' );
return name.toString();
}
private String getVariableName( IVariable variable ) {
return variable.getElementName();
}