1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 18:55:38 +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 2004-11-25 Mikhail Khodjaiants
The "decrementInstallCount" method of IBreakpoint should be called from the UI thread. The "decrementInstallCount" method of IBreakpoint should be called from the UI thread.
Replaced the "breakpointRemoved" method of ICBreakpointListener by the "breakpointsRemoved" 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.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; 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.cdi.CDIException;
import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.internal.core.model.CFloatingPointValue; import org.eclipse.cdt.debug.internal.core.model.CFloatingPointValue;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
@ -214,42 +210,6 @@ public class CDebugUtils {
return s.toString( "UTF8" ); //$NON-NLS-1$ 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 ) { public static Number getFloatingPointValue( ICValue value ) {
if ( value instanceof CFloatingPointValue ) { if ( value instanceof CFloatingPointValue ) {
try { try {

View file

@ -533,8 +533,9 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
final boolean enabled = breakpoint.isEnabled(); final boolean enabled = breakpoint.isEnabled();
final ICDITarget cdiTarget = getCDITarget(); final ICDITarget cdiTarget = getCDITarget();
String function = breakpoint.getFunction(); String function = breakpoint.getFunction();
String fileName = (function != null && function.indexOf( "::" ) == -1) ? breakpoint.getFileName() : null; //$NON-NLS-1$ String fileName = breakpoint.getFileName();
final ICDILocation location = cdiTarget.createLocation( fileName, function, -1 ); int lineNumber = breakpoint.getLineNumber();
final ICDILocation location = cdiTarget.createLocation( fileName, function, lineNumber );
final ICDICondition condition = createCondition( breakpoint ); final ICDICondition condition = createCondition( breakpoint );
setLocationBreakpointOnTarget( breakpoint, cdiTarget, location, condition, enabled ); 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 2004-11-25 Mikhail Khodjaiants
Replaced the "breakpointRemoved" method of ICBreakpointListener by the "breakpointsRemoved" Replaced the "breakpointRemoved" method of ICBreakpointListener by the "breakpointsRemoved"
method that accepts multiple breakpoints. method that accepts multiple breakpoints.

View file

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