[Discuss] finding dead code in C projects
Greg Rundlett (freephile)
greg at freephile.com
Mon Jun 17 17:03:30 EDT 2013
I'm wondering if anyone has success stories about finding dead code in
large (C) projects?
There are discussions on how to use the linker [1] and/or the GNU compiler
[2] to find dead code. However, it appears (I do not know C programming)
the best you can do is have that dead code not compiled into the binary. I
want to be able to find dead code that should be removed from the source.
I've found some projects that deal with C++ code but they don't do C
I've found some projects (e.g. http://www.cs.umd.edu/~jfoster/cqual/) that
deal with C, but they have slightly different capabilities.
And I've found some projects (e.g. CScope http://cscope.sourceforge.net/)
that might do what I want, but I'm not sure.
It looks like this perl code by Andrew Tridgell might do what I want
http://www.samba.org/ftp/unpacked/junkcode/findstatic.pl
Btw, my investigation reveals an interesting call graph generator called
Egypt. http://www.gson.org/egypt/
[1]
http://embeddedfreak.wordpress.com/2009/02/10/removing-unused-functionsdead-codes-with-gccgnu-ld/
[2]
http://stackoverflow.com/questions/4195494/using-gcc-to-find-unreachable-functions-dead-code
Greg Rundlett
More information about the Discuss
mailing list