Bug 60407 - [Search] Fails to find methods with certain signatures
Summary: [Search] Fails to find methods with certain signatures
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Andrew Niefer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 68739
Blocks:
  Show dependency tree
 
Reported: 2004-04-29 09:22 EDT by James Langley CLA
Modified: 2004-07-13 14:13 EDT (History)
2 users (show)

See Also:


Attachments
Demonstrates the bug. (14.98 KB, text/plain)
2004-04-29 09:23 EDT, James Langley CLA
no flags Details
count_binary.h (3.27 KB, application/octet-stream)
2004-04-30 12:13 EDT, James Langley CLA
no flags Details
screen grab (105.06 KB, image/png)
2004-06-28 08:30 EDT, John Camelon CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Langley CLA 2004-04-29 09:22:28 EDT
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.
Comment 1 James Langley CLA 2004-04-29 09:23:34 EDT
Created attachment 10107 [details]
Demonstrates the bug.
Comment 2 James Ciesielski CLA 2004-04-29 10:18:57 EDT
Though logged against 1.2, this problem is also present in 2.0.0.200404290300
Comment 3 Bogdan Gheorghe CLA 2004-04-29 10:56:07 EDT
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...
Comment 4 John Camelon CLA 2004-04-30 11:19:14 EDT
Can we get the header file count_binary.h as well?
Comment 5 James Langley CLA 2004-04-30 12:13:17 EDT
Created attachment 10174 [details]
count_binary.h

As requested.
Comment 6 John Camelon CLA 2004-05-03 21:31:05 EDT
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;	
}
Comment 7 Kleo Hapitas CLA 2004-05-11 10:13:53 EDT
Changing the priority to P2 to raise the visibility, these defects need to be 
resolved to clear up failed test cases.
Comment 8 John Camelon CLA 2004-05-11 13:48:46 EDT
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.
Comment 9 John Camelon CLA 2004-06-23 14:27:43 EDT
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
Comment 10 James Langley CLA 2004-06-23 14:31:24 EDT
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
Comment 11 John Camelon CLA 2004-06-25 10:41:55 EDT
Marking as RESOLVED, please REOPEN if there is a problem.  
Comment 12 James Langley CLA 2004-06-25 11:30:54 EDT
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.
Comment 13 John Camelon CLA 2004-06-25 11:44:22 EDT
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;	
}
Comment 14 John Camelon CLA 2004-06-25 15:39:19 EDT
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). 
Comment 15 John Camelon CLA 2004-06-28 08:30:00 EDT
Created attachment 12860 [details]
screen grab

Screen grab demonstrating that things are working here @ IBM.
Comment 16 John Camelon CLA 2004-06-28 08:32:42 EDT
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.  
Comment 17 James Langley CLA 2004-07-01 08:54:08 EDT
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.
Comment 18 Andrew Niefer CLA 2004-07-13 14:13:59 EDT
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)