diff options
author | Mikhail Khodjaiants | 2004-11-25 23:58:29 +0000 |
---|---|---|
committer | Mikhail Khodjaiants | 2004-11-25 23:58:29 +0000 |
commit | 7877aedb36486cab529cbc5fc08caf413b84f17b (patch) | |
tree | 6746670efa76f62e75c50aed2045e1f07b8cd1ba /debug | |
parent | e22e2cadc19fc85f0c0a9c4db5e8440e0ef2afbe (diff) | |
download | org.eclipse.cdt-7877aedb36486cab529cbc5fc08caf413b84f17b.tar.gz org.eclipse.cdt-7877aedb36486cab529cbc5fc08caf413b84f17b.tar.xz org.eclipse.cdt-7877aedb36486cab529cbc5fc08caf413b84f17b.zip |
Fix for bug 79452: Unable to set a breakpoint on a class method.
Diffstat (limited to 'debug')
6 files changed, 64 insertions, 53 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index af25283f068..be362819d1c 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,4 +1,9 @@ 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"
method that accepts multiple breakpoints.
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java index f2e192a33a5..af2233a7b0e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java @@ -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 { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java index 59261f26dbf..6ed77e1e1b3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java @@ -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 ); } diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 77fb19dd50f..4a7da3639eb 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,4 +1,9 @@ 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.
* CBreakpointUpdater.java
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 3ae777d0a1e..981a2a7934b 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -596,6 +596,20 @@ </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"> <action diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java index 43fefac5b97..ce5547887e0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java @@ -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(); } |