Bug 159833 - Problem with breakpoints in source files not found in source containers
Summary: Problem with breakpoints in source files not found in source containers
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: 3.1.1   Edit
Hardware: All Windows XP
: P3 normal (vote)
Target Milestone: 3.1.2   Edit
Assignee: Ken Ryall CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-10-05 00:57 EDT by Ken Ryall CLA
Modified: 2008-06-19 14:04 EDT (History)
2 users (show)

See Also:


Attachments
Icon for contianer (924 bytes, image/gif)
2006-10-05 10:25 EDT, Pawel Piech CLA
bjorn.freeman-benson: iplog+
Details
Initial, patch against CDT_31 (10.20 KB, patch)
2006-10-05 16:17 EDT, Ken Ryall CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Ryall CLA 2006-10-05 00:57:49 EDT
The debugger may display source files outside the scope of the launch's source containers because the back-end is able to provide the full path to the file. However when you set a breakpoint in one of these files the break will be ignored because the source locator is unable to locate it even though the full path is available.

This problem was first identified in bug 91808 and a subsequent workaround in CSourceLookupParticipant.java was added that enables display of these files.

A more comprehensive way to address this is to add a source container that knows how to “find” files specified by their full absolute path. Adding a AbsolutePathSourceContainer removes the need for the workaround, fixes this bug where breakpoints can not be set in these files, and should cover additional cases in the future.

Patch to follow...
Comment 1 Pawel Piech CLA 2006-10-05 10:25:01 EDT
Created attachment 51473 [details]
Icon for contianer

In Wind River product, we called this container the "Debugger Path in Filesystem" and we add it by default to every launch using the path computer.

I attached the container icon.
Comment 2 Ryan Boder CLA 2006-10-05 11:53:30 EDT
(In reply to comment #0)
> A more comprehensive way to address this is to add a source container that
> knows how to “find” files specified by their full absolute path. Adding a
> AbsolutePathSourceContainer removes the need for the workaround, fixes this bug
> where breakpoints can not be set in these files, and should cover additional
> cases in the future.

How is this different from org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer, which CDT already uses when you add a "File System Directory" to the source lookup path in the Source tab of the launch config dialog?
Comment 3 Pawel Piech CLA 2006-10-05 13:19:47 EDT
DirectorySourceContainer will take the path that comes from the debugger and append it to the directory path that its configured for.  I suppose you could create a directory SC for the root directory, but it won't work on windows because of the drive letter thing.  Also the directory SC will only return the LocalFileStorage object as a result, which is not so desirable if the file also referenced in the workspace.  I'm not sure if Ken had this in mind, but our version of this container first searched for the file in workspace, if it wasn't there, only then it would return the LocalFileStorage version.

For reference this is what our find elements method looks like.  Note that the searching under canonical path was necessary in some cases when the pre-processor changed the case of the filenames that ended up in the symbol file.

    public Object[] findSourceElements(String name) throws CoreException {
        List retVal = new ArrayList();

        File searchFile = new File(name);
        if (searchFile.exists() && searchFile.isFile()) {
            // Try to find the file in the workspace
            IFile[] files = ResourcesPlugin.getWorkspace().getRoot().
                findFilesForLocation( new Path(searchFile.getAbsolutePath()) );
            for (int i = 0; i < files.length; i++) {
                if (files[i].exists()) {
                    retVal.add(files[i]);
                }
            }

            // Also search for files under the canonical path.  This will
            // guarantee that the search path is in correct case if looking on
            // a windows system.
            try {
                files = ResourcesPlugin.getWorkspace().getRoot().
                    findFilesForLocation( new Path(searchFile.getCanonicalPath()) );
                for (int i = 0; i < files.length; i++) {
                    if (files[i].exists()) {
                        retVal.add(files[i]);
                    }
                }
            } 
            catch (IOException e) {} // getCanonicalPath() can throw

            retVal.add( new LocalFileStorage(searchFile) );
        }

        return retVal.toArray();
    }
Comment 4 Ken Ryall CLA 2006-10-05 16:17:26 EDT
Created attachment 51502 [details]
Initial, patch against CDT_31

This was my first pass at this. It needs Pawel's icon and I'll add the canonical path stuff too.
Comment 5 Ken Ryall CLA 2006-11-02 13:35:33 EST
After incorporating Pawel's feedback, committed fix to HEAD and CDT_3_1.