Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Alternatives to Scanner Discovery...

Hi All,

Having had a lot of difficulty getting scanner configuration to work in
the past -- both in terms of user's workflow and it just not working
right -- I thought I'd have a go getting Macros and Includes in from an
external source.

I've extended the Dwarf reader to parse the Macinfo section of Dwarf
(found in files compiled with -g3 in gcc), and modified it slightly to
collect the -I included directores and any --included files.  I then
tied the binary to an ICConfigurationDescription using a simple property
page and registered a resource change listener, which reparse the debug
info each time the file changes. On a medium sized project with ~3000
files so far so good.

To save duplication, I propogate identical Macros / Includes up the
source tree towards the root to remove redundancy -- this reduces number
of individual ICResourceConfigurations needed to ~400 (which appears a
reasonable number?) [although it looks like I could be more aggresive in
propgating -I's upwards...].  To persist to the project I do:
1: CoreModel.getDefault().getProjectDescription()
2: Iterate down the tree creating new resource descriptions based on the
nearest parent
3: getLanguageSetting().get/setSettingEntry(...)
4: CoreModel.getDefault().setProjectDescription(...)

Effectively I'm copying the behavious of the Include/Symbol Properties
tab, and the result is that headers are resolved, source navigation etc.
works; magic!

Unfortunately when it comes to persisting this things go a little
pear-shaped.  CDT turns what was ~3000line (221k) list of Includes and
Macros into a 1.7M xml file. It seems to store all the parent Include
and Macro entires in the child resource config.  While performance is
'reasonable' for this operation, it isn't good for other operations that
might blog alterting the cdt project description.  For example time
taken for this:
Fetching Includes and Macros <1s
Create/fetch ResDescs 4-10s
setProjectDesc ~5-10s
Total ~11-20s

Which made me wonder: am I doing something fundamentally wrong in
updating the resource descriptions in this way?  How do others
contribute includes and preprocessor symbols to the model?  Surely the
model should support a few hundred delta'd resource configs?

Tomorrow I'll post the code as a plugin (and patches to the dwarf
parser) in case anyone else is interested in this solution.


Back to the top