A "profiler" for Informix-4GL
Posted in 1995
In article <D2CLuH.FLG@world.std.com>, mdl@world.std.com (Michael D Lemon) wrote: > I need a profiler for Informix-4gl. Specifically, I would like to > print a function call tree for a program which is giving me 'out > of temporary string space' errors. Here's one I hacked together. It's not exactly what you're looking for and I'd suggest would be of little use to you wrt your problem. That said, I've found it quite handy when trying to decipher the odd piece of spaghetti. -------- This file is "pf" ------ I dunno how to create SHAR archives ----- #/bin/sh # # 16/12/94 Kerry S - Cope with FUNCTION function_name space bracket # 19/12/94 Kerry S - Cope with more than 99 functions per program if test $1x = x then echo "pathfinder - shell to find path to a given piece of code " echo " in a 4GL function" echo echo "USAGE: pf <searchtext> <filenames>.4gl" echo " EG: pf \\"INSERT.INTO.olines\\" op0100*4gl" echo " (yes - you need the dots, I write unfriendly shells)" echo exit 1 fi echo "Splitting program into composite functions..." > `tty` rm -rf pftemp mkdir pftemp 2>/dev/null search=$1 while test $2x != x do sed -e "s/^MAIN/FUNCTION MAIN()/" $2 > pftemp/pf.4gl csplit -k -s pftemp/pf.4gl /FUNCTION.*\\(/ {99} 2>/dev/null rm pftemp/pf.4gl ilist=`ls xx*` for i in $ilist do newname=`grep "^FUNCTION" $i` if test $? = 1 then newname="MAIN" else newname=`echo $newname | sed -e "s/FUNCTION //" -e "s/(.*//" -e "s/ //g"`"\\\\(" fi mv $i pftemp/$newname done shift 1 done cd pftemp echo "Building function tree..." > `tty` pfbuild $search echo "Outputing function tree..." > `tty` pfoutput MAIN 1 MAIN $search cd .. rm -rf pftemp -------- This file is "pfbuild" ---- I dunno how to create SHAR archives ----- #/bin/sh # Shell function called by "pf" - pathfinder # # 16/12/94 Kerry S - Cope with multiple search criteria, via egrep if test $1x != MAINx then echo $1 | grep "(" > /dev/null if test $? = 0 then baselist=`egrep -l "=$1| $1" *` else baselist=`egrep -l $1 *` fi iter=`echo 0` for bot in $baselist do if test $bot != $1 then func=`echo $bot--$1 | sed -e "s/.(//g"` if test ! -f $func then if test `echo $bot | sed -e "s/.(//g"` != $1 then cat /dev/null > $func /usr/e4gl/bin/pfbuild $bot fi fi fi done fi -------- This file is "pfoutput" ---- I dunno how to create SHAR archives ----- #/bin/sh # Shell function called by pf - pathfinder # # 16/12/94 Kerry S - Cope with FUNCTION a CALLing b CALLing a # 16/12/94 Kerry S - Cope with multiple search critera per egrep # 19/12/94 Kerry S - Show depth level numerically lvl=$2 spaces=`echo "............................" | cut -c1-$lvl` spaces=`echo $spaces | sed -e "s/./.../g"` if test $1 = $4 then egrep $1 "$3\\\\(" | sed -e "s/^/$lvl$spaces/" else echo $lvl$spaces $1 fi outlist=`ls $1--* 2>/dev/null` for out in $outlist do new=`echo $out | cut -d"-" -f3` pfoutput $new `echo $lvl+1 | bc` $1 $4 done ---------------------- One more thing: It's kinda slow too. I wonder why I bothered to post it? --------------------------------------,------------------------------------- Kerry Sainsbury, kerry@kcbbs.gen.nz | THE INFORMIX FAQ Quanta Systems, Auckland, New Zealand | kcbbs.gen.nz:/informix/* | mathcs.emory.edu:/pub/informix/faq/* +64 9 377-4473 (work) 276-5546 (home) | quasar.ucar.edu:/?