Just another possible way: Compile it as normally you would do, generate a map and an asm output. Try to find the calls to the functions in the generated asm (you will know the function addresses from the map file...) Tamas On 29 January 2013 15:54, Tamas Rudnai wrote: > Yes, a simple string search sometimes not good enough, you probably would > need a proper parser for that which can recognize what are string literal= s, > comments, function declarations, defines and other language elements. I > assume there is no any profiler nor static analyser for PicBasic Pro? > > If not, you can write a state machine powered parser for yourself in Perl > / Python or Lex/Yacc and C/C++ for example. This might take some time but > then you have your tool forever. > > Or you can just try different things, like put counters to each functions= , > initialize variables with a specific value, then run and try to trigger > each functionalities, and then see these counters and variable values. > There is a danger that not all functions been called even though all the > functionalities been tested, so be extremely careful with this approach. > > Or the "barbarian way" is when a script walks through the code and keeps > renaming the functions and tries to compile -- if failed, marks the > function used, otherwise as not used. This takes time but probably you > leave it overnight and by the morning you get some results... If there ar= e > too many to rename, do it by 4-5 each time and parse the compiler results > which one was missing... Did I mention this is "barbarian" ;-) Oh and btw > this is an iteration, so if you find any functions that can be commented > out, then you need to start this analysis from the beginning -- maybe > previously examined functions and variables were used only from this > removed one... > > Tamas > > > On 29 January 2013 12:51, Carey Fisher wrote: > >> I've been handed a rather large application written in PicBasic Pro with >> a goal of shrinking its size by 10-20% I need to find any dead code or >> declared but unused variables. >> Does anyone know of any good source code tools that will perform >> functions like this? >> (I tried using a word counting program to count the number of >> occurrences of each unique word and then examine the code for the words >> with only one occurrence. It sorta worked but, of course, it got all >> the DEFINES etc from the processor's INCLUDE file.) >> Thanks, >> Carey >> >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> > > > > -- > int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; > printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", > q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } > --=20 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .