Re: [PATCH] perf test arm64: Test unwinding using fame-pointer (fp) mode

From: German Gomez
Date: Tue Mar 15 2022 - 10:34:02 EST



On 01/03/2022 13:34, German Gomez wrote:
> Add a shell script to check that the call-graphs generated using frame
> pointers (--call-graph fp) are complete and not missing leaf functions:
>
> [...]
>
> +cat << EOF > $TEST_PROGRAM_SOURCE
> +int a = 0;
> +void leaf(void) {
> + for (;;)
> + a += a;
> +}
> +void parent(void) {
> + leaf();
> +}
> +int main(void) {
> + parent();
> + return 0;
> +}
> +EOF
> +
> +echo " + Compiling test program ($TEST_PROGRAM)..."
> +CFLAGS="-O0 -fno-inline -fno-omit-frame-pointer"

This fails when the test program is compiled with gcc-7, due to missing -g flag.

I will re-spin with this fixed.

> +cc $CFLAGS $TEST_PROGRAM_SOURCE -o $TEST_PROGRAM || exit 1
> +
> +# Add a 1 second delay to skip samples that are not in the leaf() function
> +perf record -o $PERF_DATA --call-graph fp -e cycles//u -D 1000 -- $TEST_PROGRAM 2> /dev/null &
> +PID=$!
> +echo " + Recording (PID=$PID)..."
> +sleep 2
> +echo " + Stopping perf-record..."
> +kill $PID
> +wait $PID
> +
> +# example perf-script output:
> +#
> +# program
> +# 728 leaf
> +# 753 parent
> +# 76c main
> +# ...
> +
> +perf script -i $PERF_DATA -F comm,ip,sym | head -n4
> +perf script -i $PERF_DATA -F comm,ip,sym | head -n4 |
> + awk '{ if ($2 != "") sym[i++] = $2 } END { if (sym[0] != "leaf" ||
> + sym[1] != "parent" ||
> + sym[2] != "main") exit 1 }'