stackusage 794 B

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