...

View Full Version : Tool to determine include file usage



Spookster
07-03-2007, 04:26 PM
Let's say you have a c file containing 10,000 lines of code and it has 15 include files. It would be too difficult to go through every function of every include file to determine if the include file is actually needed. Surely there is some tool that can parse the C file and headers and determine if the header is actually being used?

mentalhorse
07-03-2007, 09:37 PM
Edit:
http://www.profactor.co.uk/includemanager.php

Could this work?

Spookster
07-03-2007, 10:14 PM
Thanks. That is along the lines of what I am looking for. I've determined now though that I also really need to see what functions/data are specifically being used from those included files also rather than just if they are being used. I am redesigning a large portion of some software that other parts are dependent on so along with seeing which files are depending upon this I need to also see what functions/data they are using.

mentalhorse
07-04-2007, 06:21 PM
I guess you could comment out the '#include' line and if there are not compile errors than it isn't needed. This would work right?

sage45
07-04-2007, 08:47 PM
Technically he could but what would that solve? Many headers are used as includes for other headers and just simply disabling one won't show whether a function is depended upon the specific header you disabled/commented...

What Spookster is really looking for is a plug-in or program, that can monitor another program at runtime do determine what functions are being used from whichever headers. At the completion of the run-time event, this plug-in would generate some sort of report that shows which functions and headers were used and which were not.

Natively many compilers will show you whether a variable is referenced or used, but not functions or headers.

This might be a good pet project Spookitha... :D

-sage-

oracleguy
07-05-2007, 03:02 AM
Well you could even write a program that would just check to see if the function is ever called in the source code. It wouldn't necessarily have to monitor the program execution.

Spookster
07-05-2007, 08:36 AM
That's exactly what I need. Might be a neat tool to come up with.

mentalhorse
07-05-2007, 01:06 PM
Or just put breakpoints on all the functions. But I wouldn't know how to make the programs mentioned so that's what I would do.

oracleguy
07-05-2007, 04:40 PM
That's exactly what I need. Might be a neat tool to come up with.

That it would, though I've heard C++ is one of the harder languages to parse since it isn't context free. However I guess you wouldn't need to care about the stuff in the functions except for function calls and you wouldn't be trying to validate the syntax so that wouldn't matter. Now I wonder if some well crafted regular expressions could do it... I might have to play around with that later.

sage45
07-05-2007, 05:42 PM
That it would, though I've heard C++ is one of the harder languages to parse since it isn't context free. However I guess you wouldn't need to care about the stuff in the functions except for function calls and you wouldn't be trying to validate the syntax so that wouldn't matter. Now I wonder if some well crafted regular expressions could do it... I might have to play around with that later.

Be worth putting our heads together to do something worthwhile????

-saige-



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum