Saturday, June 20, 2009

Finding unused functions, variables, symbols

my new project at work:
make a script that can find all the unused variables, functions etc in the code. what's to it you say?
Use gcc's --unused-functions i hear? Well problem is we dont use gcc - soe modified version of it for our h/w platform, which does not support that option. So you see I fall back to some ever helpful guys:
  1. nm;
  2. objdump;
  3. grep;
  4. gawk;
  5. uniq; and
  6. cut
the idea is simple:
  1. generate a symbols file
  2. generate 2 assembly instruction file
  • one contains all normal functions
  • one contais even functions that we place on a "spl" RAM
now for each line from symbols serach these two files for atleast 3 and 2 occurences of the address respectively. Simple? Well not so very. I will put the scipt in the next post. Meanwhile I make my life more miserable, "I" have been asked to do it for C++ !!! :-(
Well cant help it now Can I?
I think a step ahead. How about a script that also adds "#if 0" to the source code? Well more work.
That shall come later if completed.

No comments:

Post a Comment