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