Community
Participate
Working Groups
Open the attached file count_binary.c, select C/C++ Search and search for the function count_all. If you choose the All Occurences option, it should find several results, but instead finds none. The same is true for printf and fprintf.
Created attachment 10107 [details] Demonstrates the bug.
Though logged against 1.2, this problem is also present in 2.0.0.200404290300
In terms of printf and fprintf, the file doesn't include stdio. This goes against how the indexer indexes things at the moment (but is going to change). But the function count_all should have been found...
Can we get the header file count_binary.h as well?
Created attachment 10174 [details] count_binary.h As requested.
There are still header files referenced in count_binary.h that are not included in your attachment, so I trimmed the example down. Using a managed make C project on Cygwin/WinXP (freshly created) I was able to make the following example work using F3, Selection Search Context Menu and the C++ Search dialog. Rather than have you attach more source, I ask you to reproduce this in your own environment using one of the latest CDT 2.0 builds. If you check the .log file in the cdt.core metadata directory you may find out what if the parser or scanner is encountering some kind of unknown condition that is causing the entire parse to die out. Another test you can do is to try content assist out in this file, as it is a good indicator as to how well the parser is working at a particular point in the file. If you need to send me further source or environment, I suggest you email it privately to me rather than attaching more to bugzilla. Thanks. ========================================================================= #include <stdio.h> static void count_lcd(FILE * lcd) { fprintf(lcd, "%c%s 0x%x\n", ESC, ESC_COL2_INDENT5, count); } static void count_all(FILE * lcd) { count_lcd(lcd); } int main(int argc, char **argv) { FILE * file = fopen( "/home/johnc", "RW" ); count_all( file ); return 0; }
Changing the priority to P2 to raise the visibility, these defects need to be resolved to clear up failed test cases.
James (Langley, not Ciesielski :-) ): I have tried smaller examples (Windows, Cygwin) and they work fine in the 2.0 stream. I suggest that once we have produced an M9 milestone build that you try it out with your full source tree and let me know if this is still a problem. I shall keep the defect open until then. Kleo: I don't believe this needs to be a P2 anymore : if it was raised on V2.0 of the product it would be closed by now; it remains open purely to maintain dialogue w/Altera and other companies delivering products off of CDT 1.2. I've discussed this with James C. and he agrees.
James Langley, We're trying to close out CDT 2.0 and this defect is still on our radar. While its not particularly gating, I'd like to resolve the defect. In order to do that, I need you to try your source tree out with a CDT 2.0 build from this week. Please advise as to whether or not you can do this for me, Thanks in advance JohnC
John, As it happens I'm downloading M9 as we speak. I'll try out a test tomorrow and let you know whether it works. James
Marking as RESOLVED, please REOPEN if there is a problem.
Reopening. Sorry, I didn't get round to posting the results of my findings with M9. I tried creating a managed make project, but I still couldn't find the function. I even tried your cut down version (see earlier comments), but that fails too. I am selecting Search -> C/C++ and then selecting Search For - Function, Limit To - All Occurrences, Scope - Workspace. The search returns no results both for my original file and for the cut down version. Interestingly the Outline view shows the function for both files, so some parser somewhere knows that the function exists. The search also fails if I select Search For - Any Element. It can't find count_lcd either. It can successfully find main though.
If I change the source to something that actually will compile on my machine, imported into a standard make project with scanner discovery enabled so that the include paths get populated, the search works. I find that Open Declaration isn't working, though, so I'm keeping the defect open to investigate. Let me know what you have for #include paths and discovery options. Thanks #include <stdio.h> static int count = 2; static void count_lcd(FILE * lcd) { fprintf(lcd, "%c%s 0x%x\n", ' ', "\t", count); } static void count_all(FILE * lcd) { count_lcd(lcd); } int main(int argc, char **argv) { FILE * file = fopen( "/home/johnc", "RW" ); count_all( file ); return 0; }
OpenDeclaration is failing on count_all due to something going wrong with how we parse _FILE. FILE is just a typedef of _FILE, and it shows up in the indexer problems (enabled off the project properties).
Created attachment 12860 [details] screen grab Screen grab demonstrating that things are working here @ IBM.
I've committed a fix that now allows count_all() to work with F3. There was a bug in the parser symbol table. Since things work from our side of the wall, and this defect is not marked as gating, I'm moving it off to 2.0.1, where James and I can continue discussions as to why it fails for him and not for me.
I've just installed a new copy of cygwin with the development tools (gcc etc.) and that seems to have solved the problem. I was looking at John's screenshot and trying to work out why I didn't have the "Includes" item in the "C/C++ Projects" tree view. So there's obviously a dependency here on a tool that I now have installed but didn't before. I can now perform a search and find two occurrences of count_all in the file. Can someone shed some light on what tool is required? I suspect that the problem we have in the released version of our product may be due to a tool not being found.
I've just fixed a problem with resolving functions with > 2 parameters. So we should be good now. As for your discovered includes, the discovery mechanism just needs make and gcc, it parses the output of gcc -E -P -v. Note that CDT doesn't come with these, you need to get them seperately (ie via cygwin or mingw)