Bug 253681 - [Import executable wizard] Outline view doesn't display accurate data for projects created with this wizard
Summary: [Import executable wizard] Outline view doesn't display accurate data for pro...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: 5.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-debug-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on: 337780
Blocks:
  Show dependency tree
 
Reported: 2008-11-04 07:20 EST by Alex Freidin CLA
Modified: 2020-09-04 15:20 EDT (History)
1 user (show)

See Also:


Attachments
Test project (11.40 KB, application/octet-stream)
2008-11-04 07:20 EST, Alex Freidin CLA
no flags Details
Patch to add include paths discovery (6.91 KB, patch)
2008-11-04 09:24 EST, Alex Freidin CLA
no flags Details | Diff
Updated patch based on CDT_6_0_0 tag (7.19 KB, patch)
2009-08-05 10:32 EDT, 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-04 07:20:01 EST
Created attachment 116922 [details]
Test project

Build ID: I20080617-2000

When importing a binary using the import executable wizard, the Outline view:
1) Does not always display all functions of the selected source file. 
2) Fails to follow the header files, i.e. double clicking on the header in the Outline view pops up an error message.

Since this is an indexing issue, it effects also the expanding of source files in the binary container or Executables view. Some functions are not displayed. 
Importing the executable using the Executable view "Import" button has the same problems, since it is similar to import executable wizard.
Note that the above happens when the binary is compiled in a command-line environment at the same machine. So, all the files and paths are present and correct in the debug info.

Steps To Reproduce:
1) Import the attached simplified example project and build it with Cygwin GCC toolchain. 
2) Close the project and restart Eclipse. This is an important step, otherwise the indexer will reuse previously discovered information. This simulates the state, as if the executable was compiled using command-line build environment.
3) Use the import executable wizard to import the executable into a new project.
4) Expand TestProject.exe, you should see "main.c" and test.c appear twice in the list and only one of the items can be expanded. This is only happens when using import executable wizard, but not for normal projects. Needs to be open as separate bug.
5) Double click on "main.c" and observe the Outline view. The functions funcA, funcB and funcC are missing. Double-click on "defines.h" in the Outline view, an error message pops up.

This is because the indexer fails to gather the required information, which is available in the debug info.
The problem is reproducible both in WinXP and Linux, probably also on other platforms.

More information:
The reason for the above is because the indexer does not have the include paths. So, it fails finding the header files and this messes up the parsing of the source files. To overcome this, I suggest to add the include paths by analyzing the binary container in the import executable wizard and in the Executables view Import button wizard. These wizards can then add the include paths to the created project. With that, additional thing should be done, the Indexer setting to parse all source files should be set for such projects. This will make the indexer to index the headers and display full info in the Outline view.
I'll post a patch for this shortly.
Comment 1 Alex Freidin CLA 2008-11-04 09:24:28 EST
Created attachment 116936 [details]
Patch to add include paths discovery

I added include paths discovery in Import Executable wizard and Executables view import button. The paths are computed based on the headers that appear in the Binary container and then added to a project. The indexer is set to index all files and then invoked to index the project. The indexer settings are then saved for the project.

Some comments in general:

*) The problem is that setting the Indexer and saving its options is an internal API. It should be exposed to allow plugins to set indexer preferences.

*) It's unclear to me why Executables view is implemented in org.eclipse.cdt.debug.core plugin, while this is a pure UI (cdt.debug.ui) contribution.

*) I found that MinGW GCC produces executables that are not properly handled by the binary container/parser. It doesn't display the source files tree when expanded, only the list of functions. This is different from other toolchains, perhaps a bug.

Shall I submit these as separate bugzilla items?
Comment 2 Alex Freidin CLA 2008-11-04 09:59:02 EST
Uups, forgot another observation related to this issue.
MinGW and Cygwin GCC do not add header files into the debug info if it doesn't include a function definition, e.g. static function. There may be other cases when the header is added to the debug info. On Linux and GNUARM GCC, the headers are always added to the debug info. So, the proposed patch may not work if the header is missing from the debug info. Looks like GCC porting bug, I don't know.
Comment 3 Alex Freidin CLA 2009-08-05 10:32:25 EDT
Created attachment 143507 [details]
Updated patch based on CDT_6_0_0 tag

This is an updated patch for CDT 6.0. Please review.

Thanks
Comment 4 Alex Freidin CLA 2011-02-23 12:14:35 EST
The patch applies clean on HEAD (CDT 7.0.1 and 8 stream). 
The update of indexer search paths that enable better code navigation can be added with a check-box, since it is not always desired, specifically for existing projects. If there is interest, I'll update the patch.