1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Fix for bug 72555: "Toggle breakpoint" action doesn't remove function breakpoints from editor.

This commit is contained in:
Mikhail Khodjaiants 2004-09-13 20:11:38 +00:00
parent 413c618734
commit 3fa82e8395
5 changed files with 56 additions and 62 deletions

View file

@ -1,3 +1,7 @@
2004-09-13 Mikhail Khodjaiants
Fix for bug 72555: "Toggle breakpoint" action doesn't remove function breakpoints from editor.
* CDIDebugModel.java
2004-09-10 Mikhail Khodjaiants
Fixes for breakpoint filtering.
* CBreakpointManager.java

View file

@ -376,7 +376,6 @@ public class CDIDebugModel {
*/
public static ICLineBreakpoint lineBreakpointExists( String sourceHandle, IResource resource, int lineNumber ) throws CoreException {
String modelId = getPluginIdentifier();
String markerType = CLineBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for( int i = 0; i < breakpoints.length; i++ ) {
@ -384,52 +383,10 @@ public class CDIDebugModel {
continue;
}
ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) ) {
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
if ( breakpoint.getLineNumber() == lineNumber ) {
return breakpoint;
}
}
}
}
}
return null;
}
/**
* Returns the address breakpoint that is already registered with the breakpoint
* manager for a source with the given handle and the given resource at the
* given address.
*
* @param sourceHandle the source handle
* @param resource the breakpoint resource
* @param address the address
* @return the address breakpoint that is already registered with the breakpoint
* manager or <code>null</code> if no such breakpoint is registered
* @exception CoreException if unable to retrieve the associated marker
* attributes (line number).
*/
public static ICAddressBreakpoint addressBreakpointExists( String sourceHandle, IResource resource, long address ) throws CoreException {
String modelId = getPluginIdentifier();
String markerType = CAddressBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
for( int i = 0; i < breakpoints.length; i++ ) {
if ( !(breakpoints[i] instanceof ICAddressBreakpoint) ) {
continue;
}
ICAddressBreakpoint breakpoint = (ICAddressBreakpoint)breakpoints[i];
if ( breakpoint.getMarker().getType().equals( markerType ) ) {
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
try {
if ( Long.parseLong( breakpoint.getAddress() ) == address ) {
return breakpoint;
}
}
catch( NumberFormatException e ) {
}
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
if ( breakpoint.getLineNumber() == lineNumber ) {
return breakpoint;
}
}
}

View file

@ -1,3 +1,8 @@
2004-09-13 Mikhail Khodjaiants
Fix for bug 72555: "Toggle breakpoint" action doesn't remove function breakpoints from editor.
* DisassemblyEditorInput.java
* ToggleBreakpointAdapter.java
2004-09-10 Mikhail Khodjaiants
Fixes for breakpoint filtering.
* CBreakpointUpdater.java

View file

@ -17,7 +17,6 @@ import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IVariable;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
@ -28,7 +27,6 @@ import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
@ -112,15 +110,18 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
}
else {
IResource resource = ResourcesPlugin.getWorkspace().getRoot();
String sourceHandle = getSourceHandle( input );
long address = ((DisassemblyEditorInput)input).getAddress( lineNumber );
if ( address != 0 ) {
ICAddressBreakpoint breakpoint = CDIDebugModel.addressBreakpointExists( sourceHandle, resource, address );
if ( address == 0 ) {
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
}
else {
ICLineBreakpoint breakpoint = ((DisassemblyEditorInput)input).breakpointExists( address );
if ( breakpoint != null ) {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
}
else {
IResource resource = ResourcesPlugin.getWorkspace().getRoot();
String sourceHandle = getSourceHandle( input );
CDIDebugModel.createAddressBreakpoint( sourceHandle,
resource,
address,
@ -131,7 +132,6 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
}
return;
}
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
}
}
}
@ -179,9 +179,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
if ( sourceRange != null ) {
charStart = sourceRange.getStartPos();
charEnd = charStart + sourceRange.getLength();
// for now
if ( charEnd == 0 )
lineNumber = sourceRange.getStartLine();
lineNumber = sourceRange.getStartLine();
}
}
catch( CModelException e ) {
@ -364,10 +362,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
private String getSourceHandle( IDeclaration declaration ) {
ITranslationUnit tu = declaration.getTranslationUnit();
if ( tu != null ) {
IPath path = tu.getPath();
if ( path != null ) {
return path.toOSString();
}
IResource resource = tu.getResource();
if ( resource != null )
return resource.getLocation().toOSString();
return tu.getPath().toOSString();
}
return ""; //$NON-NLS-1$
}

View file

@ -11,7 +11,7 @@
package org.eclipse.cdt.debug.internal.ui.views.disassembly;
import java.util.Arrays;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.model.IAsmInstruction;
import org.eclipse.cdt.debug.core.model.IAsmSourceLine;
import org.eclipse.cdt.debug.core.model.IBreakpointTarget;
@ -21,10 +21,14 @@ import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.IDisassembly;
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.util.Assert;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
@ -277,4 +281,30 @@ public class DisassemblyEditorInput implements IEditorInput {
protected IDisassembly getDisassembly() {
return ( fBlock != null ) ? fBlock.getDisassembly() : null;
}
public ICLineBreakpoint breakpointExists( long address ) throws CoreException {
Assert.isTrue( address != 0 );
IDisassembly dis = getDisassembly();
if ( dis != null ) {
IBreakpointTarget bt = (IBreakpointTarget)dis.getDebugTarget().getAdapter( IBreakpointTarget.class );
if ( bt != null ) {
String modelId = CDIDebugModel.getPluginIdentifier();
IBreakpoint[] bps = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( modelId );
for ( int i = 0; i < bps.length; ++i ) {
if ( bps[i] instanceof ICLineBreakpoint ) {
ICLineBreakpoint b = (ICLineBreakpoint)bps[i];
try {
if ( address == bt.getBreakpointAddress( b ) )
return b;
}
catch( NumberFormatException e ) {
}
catch( CoreException e ) {
}
}
}
}
}
return null;
}
}