diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 43d2e974718..748bc7e28f7 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,8 @@ +2005-07-08 Mikhail Khodjaiants + Filter breakpoints before setting using the source lookup mechanism. + * CBreakpointManager.java + * CSourceLookupDirector.java + 2005-07-08 Mikhail Khodjaiants Bug 79371: Setting breakpoints in the left hand side ruler of the disassembly view is sluggish. Asynchronous breakpoint handling. 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 2e3722a4c71..c73402fefdc 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 @@ -882,7 +882,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana if ( sl instanceof ICSourceLocator ) return ( ((ICSourceLocator)sl).findSourceElement( handle ) != null ); else if ( sl instanceof CSourceLookupDirector ) { - return true;//( ((CSourceLookupDirector)sl).getCompilationPath( handle ) != null || ((CSourceLookupDirector)sl).findSourceElements( handle ).length > 0 ); + return ( ((CSourceLookupDirector)sl).contains( breakpoint ) ); } } catch( CoreException e ) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java index 64d9cbf4c83..14cbd434dfb 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java @@ -10,13 +10,18 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.core.sourcelookup; +import java.io.File; import java.util.HashSet; import java.util.Set; +import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer; import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.debug.core.sourcelookup.ISourceContainerType; @@ -54,6 +59,20 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector { return fSupportedTypes.contains( type.getId() ); } + public boolean contains( ICBreakpoint breakpoint ) { + try { + String handle = breakpoint.getSourceHandle(); + ISourceContainer[] containers = getSourceContainers(); + for ( int i = 0; i < containers.length; ++i ) { + if ( contains( containers[i], handle ) ) + return true; + } + } + catch( CoreException e ) { + } + return false; + } + public boolean contains( IProject project ) { ISourceContainer[] containers = getSourceContainers(); for ( int i = 0; i < containers.length; ++i ) { @@ -80,6 +99,49 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector { return false; } + private boolean contains( ISourceContainer container, String sourceName ) { + IPath path = new Path( sourceName ); + if ( !path.isValidPath( sourceName ) ) + return false; + if ( container instanceof ProjectSourceContainer ) { + IProject project = ((ProjectSourceContainer)container).getProject(); + IPath projPath = project.getLocation(); + if ( projPath.isPrefixOf( path ) ) { + IFile file = ((ProjectSourceContainer)container).getProject().getFile( path.removeFirstSegments( projPath.segmentCount() ) ); + return ( file != null && file.exists() ); + } + } + if ( container instanceof FolderSourceContainer ) { + IContainer folder = ((FolderSourceContainer)container).getContainer(); + IPath folderPath = folder.getLocation(); + if ( folderPath.isPrefixOf( path ) ) { + IFile file = ((FolderSourceContainer)container).getContainer().getFile( path.removeFirstSegments( folderPath.segmentCount() ) ); + return ( file != null && file.exists() ); + } + } + if ( container instanceof CDirectorySourceContainer ) { + File dir = ((CDirectorySourceContainer)container).getDirectory(); + boolean searchSubfolders = ((CDirectorySourceContainer)container).searchSubfolders(); + IPath dirPath = new Path( dir.getAbsolutePath() ); + if ( searchSubfolders || dirPath.segmentCount() + 1 == path.segmentCount() ) + return dirPath.isPrefixOf( path ); + } + if ( container instanceof MappingSourceContainer ) { + return ( ((MappingSourceContainer)container).getCompilationPath( sourceName ) != null ); + } + try { + ISourceContainer[] containers; + containers = container.getSourceContainers(); + for ( int i = 0; i < containers.length; ++i ) { + if ( contains( containers[i], sourceName ) ) + return true; + } + } + catch( CoreException e ) { + } + return false; + } + public IPath getCompilationPath( String sourceName ) { IPath path = null; ISourceContainer[] containers = getSourceContainers();