stackusage 759 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. outfile=""
  3. now=`date +%s`
  4. while [ $# -gt 0 ]
  5. do
  6. case "$1" in
  7. -o)
  8. outfile="$2"
  9. shift 2;;
  10. -h)
  11. echo "usage: $0 [-o outfile] <make options/args>"
  12. exit 0;;
  13. *) break;;
  14. esac
  15. done
  16. if [ -z "$outfile" ]
  17. then
  18. outfile=`mktemp --tmpdir stackusage.$$.XXXX`
  19. fi
  20. KCFLAGS="${KCFLAGS} -fstack-usage" make "$@"
  21. # Prepend directory name to file names, remove column information,
  22. # make file:line/function/size/type properly tab-separated.
  23. find . -name '*.su' -newermt "@${now}" -print | \
  24. xargs perl -MFile::Basename -pe \
  25. '$d = dirname($ARGV); s#([^:]+:[0-9]+):[0-9]+:#$d/$1\t#;' | \
  26. sort -k3,3nr > "${outfile}"
  27. echo "$0: output written to ${outfile}"