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.

Wednesday, May 6, 2009

my "find"ing troubles:
New day new finds. i have a full directory tree/structure that has to be copied - is there any utility in Unix?
I don't know. But this worked:
find ./ -type f | xargs -n 1 -I {} mkdir /{}
I dont know if it works even when all o/p is simultaneously redirected but i'll find out when the prvoerbial "tomorrow" comes Till then i have a way out, so who bothers
Oh BTW if you can procrastinate to procrastinate then pls do let me know whether it works without the -n 1 option. Nwys that's a whole new research I need to do my "find" has some problems it never returns all the files or somehow they are lost in the pipe and the loss is reduced with the -n 1 option. More on this later, else why would you come back, or even now why would you?