Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327856 - [Scanner Discovery] Scanner recognizes Symbols with values wrong
Summary: [Scanner Discovery] Scanner recognizes Symbols with values wrong
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build (show other bugs)
Version: 8.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: 2010-10-15 02:22 EDT by s.michel CLA
Modified: 2020-09-04 15:18 EDT (History)
2 users (show)

See Also:


Attachments
cdt patch (1.43 KB, text/plain)
2010-10-29 04:32 EDT, s.michel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description s.michel CLA 2010-10-15 02:22:36 EDT
Build Identifier: 20100917-0705

I have the following situation:

For each make target I have created a build configuration. Then I have different make targets. The first with define DEBUG_LEVEL=0 and the second with define DEBUG_LEVEL=2.

What should happen is that when I make target one, the DEBUG_LEVEL=2 areas in the editor should be greyed out and when I make target two, the DEBUG_LEVEL=0 areas should be greyed out.

The problem must be in the Scanner. In the file <workspace>/.metadata/.plugins/org.eclipse.cdt.make.core/<project_name>.sc I have the following scanner result:
...
<definedSymbol symbol="DEBUG_LEVEL=2"/>
<definedSymbol symbol="DEBUG_LEVEL=0"/>
...

The scanner just adds the new scanner results on each run. What I would like to have is that the scanner throws away the old results and just uses the new ones.
Or the scanner handles defines with values correctly by looking for the define names and if it already exists just replace the define values.



Reproducible: Always
Comment 1 s.michel CLA 2010-10-15 06:06:17 EDT
I think it is not really clear what I mean with make targets, sorry.


The name of my build configuration matches a target in my Makefile.

In eclipse in the "make target"-view I added several targets that point to ${ConfigName} with several different defines (e.g. DEBUG_LEVEL=2). ConfigName is an eclipse variable, that contains the build configuration name.

Now I can start different configs in the eclipse "make target"-view for each build configuration.

Everything is working fine, except the above explained scanner problems.
Comment 2 Andrew Gvozdev CLA 2010-10-15 10:49:15 EDT
Do you use "per project" or "per file" Discovery Profile? "Per project" won't be able to handle that by nature as it just adds up to the project list not aware where existing entries came from. You can try "per file" but I am skeptical about it as well, probably the current design does not support that either.
Comment 3 s.michel CLA 2010-10-25 04:43:12 EDT
I just tested "per file" Discovery Profile, but this also did not work. Do you have any suggestion for me?

Is my setup that uncommon or do I have to configure Eclipse in a different way?
Comment 4 s.michel CLA 2010-10-28 06:33:25 EDT
The problem is, that the new value of the symbol is just added and not replaced. 

It is in ScannerConfigUtil.java -> function scAddSymbolsList2SymbolEntryMap. There is a call to "rc |= sEntry.add(value, active);".

But when does it make sense to add the new value and keep the old one?
Comment 5 Andrew Gvozdev CLA 2010-10-28 09:38:26 EDT
There are 2 possible reasons I can think of. One is that for "per-project" type entries for all resources are accumulated in one storage per project. Another reason is that they are accumulated together to be displayed under "Includes" which displays all the include path entries for all resources.
Comment 6 s.michel CLA 2010-10-29 04:32:59 EDT
Created attachment 182020 [details]
cdt patch

The attached change resolves the problem for me. It sets all "old/previous" symbol values to inactive.

But I have problems to create a cdt deploy package.
Comment 7 s.michel CLA 2010-11-01 02:59:13 EDT
Another solution could be, if the new define value is always inserted in the value list at index zero respectively moved to index zero. But I did not tested it yet.

The problem is, that the editor does not know what areas to grey out if a define can have more than one value.
Comment 8 s.michel CLA 2011-01-17 02:08:30 EST
Are there any news on this?

I'm really looking forward to find a proper solution for this issue. I hope the problem is clear: If a symbol can have more than one value, than it is not clear what code regions are active and what not.
Comment 9 Andrew Gvozdev CLA 2011-01-17 13:29:33 EST
We are moving toward a different approach for scanner discovery, see bug 290631. It should be easier to solve problems like this one with it. I plan to go over this and other tasks once the framework is in place, hopefully before CDT 8.0 is released.