Bug 253924 - Source files appear twice in the Binaries container and Executable view
Summary: Source files appear twice in the Binaries container and Executable view
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build (show other bugs)
Version: 5.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-build-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-05 09:56 EST by Alex Freidin CLA
Modified: 2020-09-04 15:19 EDT (History)
3 users (show)

See Also:


Attachments
Example project (11.40 KB, application/zip)
2008-11-05 09:56 EST, Alex Freidin CLA
no flags Details
CVS patch with proposed fix (2.13 KB, patch)
2008-11-05 10:19 EST, Alex Freidin CLA
no flags Details | Diff
Updated patch based on CDT_6_0_0 tag (2.13 KB, patch)
2009-08-05 08:27 EDT, Alex Freidin CLA
no flags Details | Diff
patch (1.34 KB, patch)
2011-02-21 03:41 EST, Alex Freidin CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Freidin CLA 2008-11-05 09:56:49 EST
Created attachment 117092 [details]
Example project

Build ID: I20080617-2000

I'm importing an executable, built with the Cygwin toolchain, using the import executable wizard or through the Executables view Import button. Some source files appear twice, when expanding the binary container and in the Executables view.
Steps To Reproduce:
1.Compile the attached project in the cygwin shell or cygwin toolchain
2.Import the executable using the import executables wizard
3.Expand the binary container
4.Observe that the source files appear twice. Same is in Executables view.
This is observed only under Windows with Cygwin toolchain.

More information:
The same source file may appear twice in the stabs debug info. As a result, in current implementation we get from StabsReader.getSourceFiles() two paths to the same file, e.g. ../file.c and C:/blabla/Debug/../file.c. The second string should be transformed to C:/blabla/file.c. Another modification is required in Executable class. When adding the source files to the list, it should check for duplicates, like the Binary class does.
I will post a patch shortly.
Comment 1 Alex Freidin CLA 2008-11-05 10:19:48 EST
Created attachment 117096 [details]
CVS patch with proposed fix
Comment 2 Alex Freidin CLA 2009-08-05 08:27:51 EDT
Created attachment 143498 [details]
Updated patch based on CDT_6_0_0 tag

Please review and commit.

Thanks
Comment 3 Alex Freidin CLA 2011-02-21 03:28:18 EST
After reviewing the status at HEAD (CDT 8 stream), it seems that the problem in Executables view is fixed. 
There are still two problems with the Binaries container, the same source file appears twice and source files cannot be opened. This is part of CDT Core, so I'm changing the component.

Here are updated steps to reproduce problem #1 - files cannot be opened:
1)Import the attached project
2)Add "-gstabs+" to Compiler > Debugging > Other debugging flags. The problem appears in executables with STABS debug info. The newer versions of GCC use DWARF debug info by default, while older version use STABS. So, best is to enable STABS explicitly.
3)Build the project
4)Expand the "TestProject.exe" in the Binaries container and double click on "defines.h". The NPE dialog pops up. Select the file and look at its path at the status bar, the path is incorrect.

Steps to reproduce problem #2 - files appear twice:
1)Close the project "TestProject" in the workspace !
2)Use Import > C/C++ Executable wizard to import "TestProject.exe" into a new project.
3)Expand the "TestProject.exe" in the Binaries container. Observe the same source files appear twice. Clicking on one of the duplicate names opens a file, clicking on a second, pops up NPE dialog.
4)Clicking on defines.h pops up NPE dialog.

More information on problem #1:
The file may appear with relative path in STABS debug info -> ../inc/defines.h. The Executables view takes care of that by trying to make it relative to executable. The Binaries container doesn't do it, resulting in an invalid path to the file.

More information on problem #2:
The same source file may appear twice in STABS debug info, e.g. ../file.c and C:/blabla/Debug/../file.c. In Executables view, both are resolved to the same file, but in Binaries container, relative path is not resolved, so we get two handles, one of which is invalid.

A fairly simple solution is to apply the same handling of relative path as in the Executables view.
Comment 4 Alex Freidin CLA 2011-02-21 03:41:49 EST
Created attachment 189394 [details]
patch

Added the handling of relative paths in the same manner as in Executables view.