Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debug/org.eclipse.cdt.debug.core/.classpath3
-rw-r--r--debug/org.eclipse.cdt.debug.core/.project1
-rw-r--r--debug/org.eclipse.cdt.debug.core/plugin.xml1
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java1
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CDirectorySourceLocation.java140
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceLocation.java115
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java38
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java (renamed from debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICSourceLocator.java)18
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java227
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java49
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java6
11 files changed, 446 insertions, 153 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/.classpath b/debug/org.eclipse.cdt.debug.core/.classpath
index cad3c8f8f8e..dfcc15b5539 100644
--- a/debug/org.eclipse.cdt.debug.core/.classpath
+++ b/debug/org.eclipse.cdt.debug.core/.classpath
@@ -3,8 +3,9 @@
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="/org.eclipse.core.resources"/>
<classpathentry kind="src" path="/org.eclipse.debug.core"/>
+ <classpathentry kind="src" path="/org.eclipse.cdt.core"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
- <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT/" sourcepath="JRE_SRC"/>
+ <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/debug/org.eclipse.cdt.debug.core/.project b/debug/org.eclipse.cdt.debug.core/.project
index 80d525ded05..f22a8a7909a 100644
--- a/debug/org.eclipse.cdt.debug.core/.project
+++ b/debug/org.eclipse.cdt.debug.core/.project
@@ -3,6 +3,7 @@
<name>org.eclipse.cdt.debug.core</name>
<comment></comment>
<projects>
+ <project>org.eclipse.cdt.core</project>
<project>org.eclipse.core.boot</project>
<project>org.eclipse.core.resources</project>
<project>org.eclipse.core.runtime</project>
diff --git a/debug/org.eclipse.cdt.debug.core/plugin.xml b/debug/org.eclipse.cdt.debug.core/plugin.xml
index f4f0c1a78a9..735fa0fb8f1 100644
--- a/debug/org.eclipse.cdt.debug.core/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.core/plugin.xml
@@ -14,6 +14,7 @@
<requires>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.debug.core"/>
+ <import plugin="org.eclipse.cdt.core"/>
</requires>
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
index bf84cd3bdde..df948c44ca1 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
@@ -15,6 +15,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDISourceManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
+import org.eclipse.cdt.debug.internal.core.CSourceLocator;
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CDebugElement;
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CDirectorySourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CDirectorySourceLocation.java
new file mode 100644
index 00000000000..32f99fd9368
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CDirectorySourceLocation.java
@@ -0,0 +1,140 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.core.sourcelookup;
+
+import java.io.File;
+
+import org.eclipse.cdt.core.resources.FileStorage;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+/**
+ *
+ * Locates source elements in a directory in the local
+ * file system. Returns instances of <code>FileStorage</code>.
+ *
+ * @since Sep 23, 2002
+ */
+public class CDirectorySourceLocation implements ICSourceLocation
+{
+ /**
+ * The directory associated with this source location
+ */
+ private IPath fDirectory;
+
+ /**
+ * Constructor for CDirectorySourceLocation.
+ */
+ public CDirectorySourceLocation( IPath directory )
+ {
+ setDirectory( directory );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#findSourceElement(String)
+ */
+ public Object findSourceElement( String name ) throws CoreException
+ {
+ if ( getDirectory() != null )
+ {
+ File file = new File( name );
+ if ( file.isAbsolute() )
+ return findFileByAbsolutePath( name );
+ else
+ return findFileByRelativePath( name );
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
+ */
+ public Object getAdapter( Class adapter )
+ {
+ if ( adapter.equals( ICSourceLocation.class ) )
+ return this;
+ if ( adapter.equals( CDirectorySourceLocation.class ) )
+ return this;
+ return null;
+ }
+
+ /**
+ * Sets the directory in which source elements will
+ * be searched for.
+ *
+ * @param directory a directory
+ */
+ private void setDirectory( IPath directory )
+ {
+ fDirectory = directory;
+ }
+
+ /**
+ * Returns the directory associated with this source
+ * location.
+ *
+ * @return directory
+ */
+ public IPath getDirectory()
+ {
+ return fDirectory;
+ }
+
+ private Object findFileByAbsolutePath( String fileName )
+ {
+ IPath filePath = new Path( fileName );
+ String name = filePath.lastSegment();
+ filePath = filePath.removeLastSegments( 1 );
+ IPath path = getDirectory();
+ if ( path.equals( filePath ) )
+ {
+ path = path.append( name );
+
+ // Try for a file in another workspace project
+ IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
+ if ( f != null )
+ {
+ return f;
+ }
+
+ File file = path.toFile();
+ if ( file.exists() )
+ {
+ return createExternalFileStorage( path );
+ }
+ }
+ return null;
+ }
+
+ private Object findFileByRelativePath( String fileName )
+ {
+ IPath path = getDirectory();
+ path.append( fileName );
+
+ // Try for a file in another workspace project
+ IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
+ if ( f != null )
+ {
+ return f;
+ }
+
+ File file = path.toFile();
+ if ( file.exists() )
+ {
+ return createExternalFileStorage( path );
+ }
+ return null;
+ }
+
+ private IStorage createExternalFileStorage( IPath path )
+ {
+ return new FileStorage( path );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceLocation.java
new file mode 100644
index 00000000000..229f0f6096e
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceLocation.java
@@ -0,0 +1,115 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.core.sourcelookup;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+/**
+ *
+ * Locates source elements in a Java project. Returns instances of <code>IFile</code>.
+ *
+ * @since Sep 23, 2002
+ */
+public class CProjectSourceLocation implements ICSourceLocation
+{
+ /**
+ * The project associated with this source location
+ */
+ private IProject fProject;
+
+ /**
+ * Constructor for CProjectSourceLocation.
+ */
+ public CProjectSourceLocation( IProject project )
+ {
+ setProject( project );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#findSourceElement(String)
+ */
+ public Object findSourceElement( String name ) throws CoreException
+ {
+ if ( getProject() != null )
+ {
+ IPath path = new Path( name );
+ String fileName = path.toOSString();
+
+ String pPath = new String( getProject().getLocation().toOSString() );
+ int i = 0;
+ if ( (i = fileName.indexOf( pPath )) >= 0 )
+ {
+ i += pPath.length() + 1;
+ if ( fileName.length() > i )
+ return getProject().getFile( fileName.substring( i ) );
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
+ */
+ public Object getAdapter( Class adapter )
+ {
+ if ( adapter.equals( ICSourceLocation.class ) )
+ return this;
+ if ( adapter.equals( CProjectSourceLocation.class ) )
+ return this;
+ return null;
+ }
+
+ /**
+ * Sets the project in which source elements will be searched for.
+ *
+ * @param project the project
+ */
+ private void setProject( IProject project )
+ {
+ fProject = project;
+ }
+
+ /**
+ * Returns the project associated with this source location.
+ *
+ * @return project
+ */
+ public IProject getProject()
+ {
+ return fProject;
+ }
+
+ private IFile findFile( IContainer parent, IPath name ) throws CoreException
+ {
+ if ( name.isAbsolute() )
+ {
+ if ( name.toOSString().startsWith( parent.getLocation().toOSString() ) )
+ {
+ name = new Path( name.toOSString().substring( parent.getLocation().toOSString().length() + 1 ) );
+ }
+ }
+ IResource found = parent.findMember( name );
+ if ( found != null && found.getType() == IResource.FILE )
+ {
+ return (IFile)found;
+ }
+ IResource[] children= parent.members();
+ for ( int i= 0; i < children.length; i++ )
+ {
+ if ( children[i] instanceof IContainer )
+ {
+ return findFile( (IContainer)children[i], name );
+ }
+ }
+ return null;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java
new file mode 100644
index 00000000000..4977f89bd5d
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java
@@ -0,0 +1,38 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.core.sourcelookup;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ *
+ * A source location defines the location of a repository
+ * of source code. A source location is capable of retrieving
+ * source elements.
+ * <p>
+ * For example, a source location could be a project, zip/archive
+ * file, or a directory in the file system.
+ * </p>
+ *
+ * @since Sep 23, 2002
+ */
+public interface ICSourceLocation extends IAdaptable
+{
+ /**
+ * Returns an object representing the source code
+ * for a type with the specified name, or <code>null</code>
+ * if none could be found. The source element
+ * returned is implementation specific - for example, a
+ * resource, a local file, a zip file entry, etc.
+ *
+ * @param name the name of the object for which source is being searched for
+ *
+ * @return source element
+ * @exception CoreException if an exception occurs while searching for the specified source element
+ */
+ Object findSourceElement( String name ) throws CoreException;
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICSourceLocator.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java
index 989f9f148d3..2d65afd6bd6 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICSourceLocator.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java
@@ -3,11 +3,13 @@
* All Rights Reserved.
*
*/
-package org.eclipse.cdt.debug.core;
+package org.eclipse.cdt.debug.core.sourcelookup;
+import org.eclipse.cdt.debug.core.IStackFrameInfo;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.ISourceLocator;
@@ -77,10 +79,16 @@ public interface ICSourceLocator extends ISourceLocator
Object getSourceElementForAddress( long address );
/**
- * Returns whether the given resource is contained in this source locator.
+ * Returns the source locations of this locator.
*
- * @param resource the resource
- * @return whether the given resource is contained in this source locator
+ * @return the source locations of this locator
*/
- boolean contains( IResource resource );
+ ICSourceLocation[] getSourceLocations();
+
+ /**
+ * Sets the source locations of this locator.
+ *
+ * @param location - an array of source locations
+ */
+ void setSourceLocations( ICSourceLocation[] locations );
} \ No newline at end of file
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java
index 86b6e1b466f..6c84284daf8 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java
@@ -6,9 +6,13 @@
package org.eclipse.cdt.debug.internal.core;
+import java.util.ArrayList;
+
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.ICSourceLocator;
import org.eclipse.cdt.debug.core.IStackFrameInfo;
+import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceLocation;
+import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
+import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.model.*;
import org.eclipse.core.internal.resources.File;
import org.eclipse.core.resources.IContainer;
@@ -30,14 +34,9 @@ import org.eclipse.debug.core.model.IStackFrame;
public class CSourceLocator implements ICSourceLocator
{
/**
- * The project in which to look for source.
- */
- private IProject fProject;
-
- /**
- * The debug target this source locator is associated with.
+ * The array of source locations associated with this locator.
*/
- private CDebugTarget fTarget;
+ private ICSourceLocation[] fSourceLocations;
/**
* The source presentation mode.
@@ -49,10 +48,17 @@ public class CSourceLocator implements ICSourceLocator
/**
* Constructor for CSourceLocator.
*/
- public CSourceLocator( CDebugTarget target, IProject project )
+ public CSourceLocator( IProject project )
{
- fProject = project;
- fTarget = target;
+ fSourceLocations = getDefaultSourceLocations( project );
+ }
+
+ /**
+ * Constructor for CSourceLocator.
+ */
+ public CSourceLocator( ICSourceLocation[] locations )
+ {
+ fSourceLocations = locations;
}
/* (non-Javadoc)
@@ -129,12 +135,27 @@ public class CSourceLocator implements ICSourceLocator
private Object getSourceInput( IStackFrameInfo info )
{
Object result = null;
- if ( info != null && fProject != null )
+ if ( info != null )
{
setInternalMode( ICSourceLocator.MODE_SOURCE );
String fileName = info.getFile();
if ( fileName != null && fileName.length() > 0 )
- result = findFile( fProject, fileName );
+ {
+ ICSourceLocation[] locations = getSourceLocations();
+ for ( int i = 0; i < locations.length; ++i )
+ {
+ try
+ {
+ result = locations[i].findSourceElement( fileName );
+ }
+ catch( CoreException e )
+ {
+ // do nothing
+ }
+ if ( result != null )
+ break;
+ }
+ }
}
// switch to assembly mode if source file not found
/*
@@ -144,84 +165,30 @@ public class CSourceLocator implements ICSourceLocator
return result;
}
- private Object findFile( IProject project, String fileName )
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.ICSourceLocator#getSourceElement(String)
+ */
+ public Object getSourceElement( String fileName )
{
- IPath path = new Path( fileName );
- fileName = path.toOSString();
-
- /*
- * We have a few possible cases: either we get a source file name with no path,
- * or we get a fully-qualified filename from the debugger.
- */
- String pPath = new String( project.getLocation().toOSString() );
- int i;
-
- if ( (i = fileName.indexOf( pPath )) >= 0 )
- {
- i += pPath.length() + 1;
- if ( fileName.length() > i )
- return project.getFile( fileName.substring( i ) );
- }
- // Then just do a search on our project, and if that fails, any dependent projects
- IFile f = null;
- try
+ Object result = null;
+ if ( fileName != null && fileName.length() > 0 )
{
- f = findFile( (IContainer)project, path );
- if ( f != null )
- return f;
- if ( f == null )
+ ICSourceLocation[] locations = getSourceLocations();
+ for ( int i = 0; i < locations.length; ++i )
{
- IProject[] p = project.getReferencedProjects();
- for ( int j= 0; j < p.length; j++ )
+ try
{
- if ( (f = findFile( (IContainer)p[j], new Path( fileName ) )) != null )
- {
- return f;
- }
+ result = locations[i].findSourceElement( fileName );
}
- }
- }
- catch( CoreException e )
- {
- }
- if ( f != null )
- return f;
- // Search for an external file
-// return findExternalFile( fileName );
- return null;
- }
-
- private IFile findFile( IContainer parent, IPath name ) throws CoreException
- {
- if ( name.isAbsolute() )
- {
- if ( name.toOSString().startsWith( parent.getLocation().toOSString() ) )
- {
- name = new Path( name.toOSString().substring( parent.getLocation().toOSString().length() + 1 ) );
- }
- }
- IResource found = parent.findMember( name );
- if ( found != null && found.getType() == IResource.FILE )
- {
- return (IFile)found;
- }
- IResource[] children= parent.members();
- for ( int i= 0; i < children.length; i++ )
- {
- if ( children[i] instanceof IContainer )
- {
- return findFile( (IContainer)children[i], name );
+ catch( CoreException e )
+ {
+ // do nothing
+ }
+ if ( result != null )
+ break;
}
}
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.core.ICSourceLocator#getSourceElement(String)
- */
- public Object getSourceElement( String fileName )
- {
- return findFile( fProject, fileName );
+ return result;
}
/* (non-Javadoc)
@@ -245,59 +212,77 @@ public class CSourceLocator implements ICSourceLocator
*/
public boolean contains( IResource resource )
{
- if ( resource instanceof IProject )
+ ICSourceLocation[] locations = getSourceLocations();
+ for ( int i = 0; i < locations.length; ++i )
{
- if ( fProject.equals( resource ) )
+ if ( resource instanceof IProject )
{
- return true;
+ if ( locations[i] instanceof CProjectSourceLocation &&
+ ((CProjectSourceLocation)locations[i]).equals( resource ) )
+ {
+ return true;
+ }
}
- IProject[] projects = getReferencedProjects();
- for ( int i = 0; i < projects.length; ++i )
+ if ( resource instanceof IFile )
{
- if ( projects[i].equals( resource ) )
+ try
+ {
+ if ( locations[i].findSourceElement( resource.getLocation().toOSString() ) != null )
+ return true;
+ }
+ catch( CoreException e )
{
- return true;
}
}
- return false;
- }
- if ( resource instanceof IFile )
- {
- return containsFile( resource.getLocation() );
}
return false;
}
-
- protected IProject[] getReferencedProjects()
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getSourceLocations()
+ */
+ public ICSourceLocation[] getSourceLocations()
{
- IProject[] projects = new IProject[0];
- try
- {
- projects = fProject.getReferencedProjects();
- }
- catch( CoreException e )
- {
- CDebugCorePlugin.log( e );
- }
- return projects;
+ return fSourceLocations;
}
-
- protected boolean containsFile( IPath path )
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#setSourceLocations(ICSourceLocation[])
+ */
+ public void setSourceLocations( ICSourceLocation[] locations )
{
- try
+ fSourceLocations = locations;
+ }
+
+ /**
+ * Returns a default collection of source locations for
+ * the given project. Default source locations consist
+ * of the given project and all of its referenced projects .
+ *
+ * @param project a project
+ * @return a collection of source locations for all required
+ * projects
+ * @exception CoreException
+ */
+ public static ICSourceLocation[] getDefaultSourceLocations( IProject project )
+ {
+ ArrayList list = new ArrayList();
+ if ( project != null )
{
- if ( findFile( (IContainer)fProject, path ) != null )
- return true;
- IProject[] p = fProject.getReferencedProjects();
- for ( int j= 0; j < p.length; j++ )
+ try
{
- if ( findFile( (IContainer)p[j], path ) != null )
- return true;
+ IProject[] projects = project.getReferencedProjects();
+ list.add( new CProjectSourceLocation( project ) );
+ for ( int i = 0; i < projects.length; i++ )
+ {
+ list.add( new CProjectSourceLocation( projects[i] ) );
+ }
+ }
+ catch( CoreException e )
+ {
+ // do nothing
}
- }
- catch( CoreException e )
- {
}
- return false;
+ return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
}
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
index 541aaec19a0..0d9a5f072bc 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
@@ -7,6 +7,7 @@ package org.eclipse.cdt.debug.internal.core.model;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -16,7 +17,6 @@ import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.ICBreakpoint;
import org.eclipse.cdt.debug.core.ICExpressionEvaluator;
import org.eclipse.cdt.debug.core.ICLineBreakpoint;
-import org.eclipse.cdt.debug.core.ICSourceLocator;
import org.eclipse.cdt.debug.core.ICWatchpoint;
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
@@ -53,12 +53,16 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
+import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceLocation;
+import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
+import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.CSourceLocator;
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
@@ -177,11 +181,6 @@ public class CDebugTarget extends CDebugElement
private int fSuspendCount = 0;
/**
- * The source locator for this target.
- */
- private ICSourceLocator fSourceLocator = null;
-
- /**
* Collection of breakpoints added to this target. Values are of type <code>ICBreakpoint</code>.
*/
private HashMap fBreakpoints;
@@ -216,11 +215,12 @@ public class CDebugTarget extends CDebugElement
setCDITarget( cdiTarget );
setBreakpoints( new HashMap( 5 ) );
setTemporaryBreakpoints( new ArrayList() );
+// Temporary
+ getLaunch().setSourceLocator( createSourceLocator( project ) );
+
setConfiguration( cdiTarget.getSession().getConfiguration() );
fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate();
fSupportsDisconnect = allowsDisconnect & getConfiguration().supportsDisconnect();
- fSourceLocator = createSourceLocator( project );
- launch.setSourceLocator( fSourceLocator );
setThreadList( new ArrayList( 5 ) );
initialize();
DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
@@ -355,9 +355,9 @@ public class CDebugTarget extends CDebugElement
if ( breakpoint instanceof ICBreakpoint )
{
ISourceLocator sl = getSourceLocator();
- if ( sl != null && sl instanceof ICSourceLocator )
+ if ( sl != null && sl instanceof CSourceLocator )
{
- return ((ICSourceLocator)sl).contains( breakpoint.getMarker().getResource() );
+ return ((CSourceLocator)sl).contains( breakpoint.getMarker().getResource() );
}
return true;
}
@@ -1513,21 +1513,6 @@ public class CDebugTarget extends CDebugElement
super.fireSuspendEvent( detail );
}
- /**
- * Creates the source locator for this target.
- *
- * @return the source locator for this target
- */
- private ICSourceLocator createSourceLocator( IProject project )
- {
- return new CSourceLocator( this, project );
- }
-
- protected ICSourceLocator getSourceLocator()
- {
- return fSourceLocator;
- }
-
protected void setCurrentThread()
{
ICDIThread currentCDIThread = null;
@@ -1851,4 +1836,18 @@ public class CDebugTarget extends CDebugElement
targetRequestFailed( e.getMessage(), null );
}
}
+
+ protected ISourceLocator getSourceLocator()
+ {
+ return getLaunch().getSourceLocator();
+ }
+
+ protected ISourceLocator createSourceLocator( IProject project )
+ {
+ CSourceLocator locator = new CSourceLocator( project );
+ List list = Arrays.asList( locator.getSourceLocations() );
+ list.add( new CDirectorySourceLocation( new Path( project.getLocation().toOSString() ) ) );
+ locator.setSourceLocations( (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ) );
+ return locator;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
index abff5c35b1f..19890f956e0 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
@@ -22,8 +22,10 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
import org.eclipse.cdt.debug.core.cdi.model.ICDIArgument;
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
+import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IVariable;
@@ -177,7 +179,9 @@ public class CStackFrame extends CDebugElement
{
if ( isSuspended() )
{
- return ((CDebugTarget)getDebugTarget()).getSourceLocator().getLineNumber( this );
+ ISourceLocator locator = ((CDebugTarget)getDebugTarget()).getSourceLocator();
+ if ( locator != null && locator instanceof ICSourceLocator )
+ return ((ICSourceLocator)locator).getLineNumber( this );
}
return -1;
}

Back to the top