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