mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Fix for bug 72555: "Toggle breakpoint" action doesn't remove function breakpoints from editor.
This commit is contained in:
parent
413c618734
commit
3fa82e8395
5 changed files with 56 additions and 62 deletions
|
@ -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
|
2004-09-10 Mikhail Khodjaiants
|
||||||
Fixes for breakpoint filtering.
|
Fixes for breakpoint filtering.
|
||||||
* CBreakpointManager.java
|
* CBreakpointManager.java
|
||||||
|
|
|
@ -376,7 +376,6 @@ public class CDIDebugModel {
|
||||||
*/
|
*/
|
||||||
public static ICLineBreakpoint lineBreakpointExists( String sourceHandle, IResource resource, int lineNumber ) throws CoreException {
|
public static ICLineBreakpoint lineBreakpointExists( String sourceHandle, IResource resource, int lineNumber ) throws CoreException {
|
||||||
String modelId = getPluginIdentifier();
|
String modelId = getPluginIdentifier();
|
||||||
String markerType = CLineBreakpoint.getMarkerType();
|
|
||||||
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
|
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
|
||||||
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
|
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
|
||||||
for( int i = 0; i < breakpoints.length; i++ ) {
|
for( int i = 0; i < breakpoints.length; i++ ) {
|
||||||
|
@ -384,7 +383,6 @@ public class CDIDebugModel {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i];
|
ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i];
|
||||||
if ( breakpoint.getMarker().getType().equals( markerType ) ) {
|
|
||||||
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
|
if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
|
||||||
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
|
if ( breakpoint.getMarker().getResource().equals( resource ) ) {
|
||||||
if ( breakpoint.getLineNumber() == lineNumber ) {
|
if ( breakpoint.getLineNumber() == lineNumber ) {
|
||||||
|
@ -393,47 +391,6 @@ public class CDIDebugModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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 ) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
2004-09-10 Mikhail Khodjaiants
|
||||||
Fixes for breakpoint filtering.
|
Fixes for breakpoint filtering.
|
||||||
* CBreakpointUpdater.java
|
* CBreakpointUpdater.java
|
||||||
|
|
|
@ -17,7 +17,6 @@ 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;
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
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.ICFunctionBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
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.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
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$
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IResource resource = ResourcesPlugin.getWorkspace().getRoot();
|
|
||||||
String sourceHandle = getSourceHandle( input );
|
|
||||||
long address = ((DisassemblyEditorInput)input).getAddress( lineNumber );
|
long address = ((DisassemblyEditorInput)input).getAddress( lineNumber );
|
||||||
if ( address != 0 ) {
|
if ( address == 0 ) {
|
||||||
ICAddressBreakpoint breakpoint = CDIDebugModel.addressBreakpointExists( sourceHandle, resource, address );
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ICLineBreakpoint breakpoint = ((DisassemblyEditorInput)input).breakpointExists( address );
|
||||||
if ( breakpoint != null ) {
|
if ( breakpoint != null ) {
|
||||||
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
|
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
IResource resource = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
String sourceHandle = getSourceHandle( input );
|
||||||
CDIDebugModel.createAddressBreakpoint( sourceHandle,
|
CDIDebugModel.createAddressBreakpoint( sourceHandle,
|
||||||
resource,
|
resource,
|
||||||
address,
|
address,
|
||||||
|
@ -131,7 +132,6 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,8 +179,6 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
||||||
if ( sourceRange != null ) {
|
if ( sourceRange != null ) {
|
||||||
charStart = sourceRange.getStartPos();
|
charStart = sourceRange.getStartPos();
|
||||||
charEnd = charStart + sourceRange.getLength();
|
charEnd = charStart + sourceRange.getLength();
|
||||||
// for now
|
|
||||||
if ( charEnd == 0 )
|
|
||||||
lineNumber = sourceRange.getStartLine();
|
lineNumber = sourceRange.getStartLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,10 +362,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
||||||
private String getSourceHandle( IDeclaration declaration ) {
|
private String getSourceHandle( IDeclaration declaration ) {
|
||||||
ITranslationUnit tu = declaration.getTranslationUnit();
|
ITranslationUnit tu = declaration.getTranslationUnit();
|
||||||
if ( tu != null ) {
|
if ( tu != null ) {
|
||||||
IPath path = tu.getPath();
|
IResource resource = tu.getResource();
|
||||||
if ( path != null ) {
|
if ( resource != null )
|
||||||
return path.toOSString();
|
return resource.getLocation().toOSString();
|
||||||
}
|
return tu.getPath().toOSString();
|
||||||
}
|
}
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
package org.eclipse.cdt.debug.internal.ui.views.disassembly;
|
package org.eclipse.cdt.debug.internal.ui.views.disassembly;
|
||||||
|
|
||||||
import java.util.Arrays;
|
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.IAsmInstruction;
|
||||||
import org.eclipse.cdt.debug.core.model.IAsmSourceLine;
|
import org.eclipse.cdt.debug.core.model.IAsmSourceLine;
|
||||||
import org.eclipse.cdt.debug.core.model.IBreakpointTarget;
|
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.IDisassembly;
|
||||||
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
|
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
|
||||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
|
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.DebugException;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.Region;
|
import org.eclipse.jface.text.Region;
|
||||||
|
import org.eclipse.jface.util.Assert;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IPersistableElement;
|
import org.eclipse.ui.IPersistableElement;
|
||||||
|
|
||||||
|
@ -277,4 +281,30 @@ public class DisassemblyEditorInput implements IEditorInput {
|
||||||
protected IDisassembly getDisassembly() {
|
protected IDisassembly getDisassembly() {
|
||||||
return ( fBlock != null ) ? fBlock.getDisassembly() : null;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue