aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlns <matzeton@googlemail.com>2022-07-08 08:55:59 +0200
committerlns <matzeton@googlemail.com>2022-07-08 09:53:37 +0200
commite4c116359a5c06024151087cbc3cf851823eb9a7 (patch)
treecfa715ef5fdeea26087c6721059feebeeec97b91
parentf8076e3a58e628d6761d16acdb4c8c7220a260ec (diff)
Enhances gprof usage.improved/gprof
* gprof results were incorrectly displayed Signed-off-by: lns <matzeton@googlemail.com>
-rw-r--r--configure.ac7
-rwxr-xr-xtests/do.sh.in20
2 files changed, 20 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index 260b8c1bd..8d58f8d56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,11 @@ AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = se
],[
CFLAGS="${CFLAGS} -g"
])
+AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set],[
+ AS_IF([test "x$enable_gprof" = "xyes"], [
+ AC_MSG_ERROR([Configure options `--with-sanitizer' / `--with_thread_sanitizer' can not used together with `--enable-gprof'.])
+ ])
+])
AS_IF([test "${with_sanitizer+set}" = set],[
CFLAGS="${CFLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak -fno-omit-frame-pointer"
@@ -287,7 +292,7 @@ AS_IF([test "x$enable_gprof" = "xyes"], [
])
GPROF_ENABLED=1
GPROF_LIBS="-ltcmalloc_and_profiler"
- GPROF_CFLAGS="${pkg_cv_PROFILER_CFLAGS} ${pkg_cv_TCMALLOC_CFLAGS}"
+ GPROF_CFLAGS="-g3 -fvisibility=default -fno-omit-frame-pointer ${pkg_cv_PROFILER_CFLAGS} ${pkg_cv_TCMALLOC_CFLAGS}"
])
AC_CHECK_LIB(pthread, pthread_setaffinity_np, AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SETAFFINITY_NP, 1, [libc has pthread_setaffinity_np]))
diff --git a/tests/do.sh.in b/tests/do.sh.in
index b3ff16a06..c728a6d1c 100755
--- a/tests/do.sh.in
+++ b/tests/do.sh.in
@@ -36,7 +36,14 @@ if [ ! -x "../example/ndpiReader${EXE_SUFFIX}" ]; then
fi
if [ ${GPROF_ENABLED} -eq 1 ]; then
- GPROF="$(which pprof)"
+ GPROF="${GPROF:-$(which pprof)}"
+ if [ ! -x "${GPROF}" ]; then
+ echo "$0: ${GPROF} not found or not executable"
+ exit 1
+ fi
+ echo "$0: Using pprof executable ${GPROF}"
+ echo "$0: Please make sure that you use google-pprof and not gperftools"
+ echo "$0: See https://github.com/google/pprof"
else
GPROF=false
fi
@@ -81,7 +88,7 @@ check_results() {
if [ -f result/$f.out ]; then
CMD="$READER -q -K JSON -k /dev/null -t -i pcap/$f -w /tmp/reader.$$.out -v 2"
- CPUPROFILE=result/$f.cprof HEAPPROFILE=result/$f $CMD
+ CPUPROFILE=./result/$f.cprof HEAPPROFILE=./result/$f $CMD
CMD_RET=$?
if [ $CMD_RET -eq 0 ]; then
NUM_DIFF=`${CMD_DIFF} result/$f.out /tmp/reader.$$.out | wc -l`
@@ -108,10 +115,11 @@ check_results() {
done
if [ ${GPROF_ENABLED} -eq 1 ]; then
- ${GPROF} -top -nodecount 100 -nodefraction 0 -show '^(ndpi|.*_ndpi)' ../example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || exit 1
- ${GPROF} -png -output ./result/cpu_profile.png -nodecount 100 -nodefraction 0 -show '^(ndpi|.*_ndpi)' ../example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || exit 1
- ${GPROF} -top -nodecount 100 -nodefraction 0 -show '^(ndpi|.*_ndpi)' ../example/ndpiReader${EXE_SUFFIX} ./result/*.heap || exit 1
- ${GPROF} -png -output ./result/heap_profile.png -nodecount 100 -nodefraction 0 -show '^(ndpi|.*_ndpi)' ../example/ndpiReader${EXE_SUFFIX} ./result/*.heap || exit 1
+ GPROF_ARGS='-nodecount 100 -nodefraction 0 -symbolize=fastlocal'
+ ${GPROF} -top ${GPROF_ARGS} ../example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || exit 1
+ ${GPROF} -png -output ./result/cpu_profile.png ${GPROF_ARGS} ../example/ndpiReader${EXE_SUFFIX} ./result/*.cprof || exit 1
+ ${GPROF} -top ${GPROF_ARGS} -sample_index=alloc_space ../example/ndpiReader${EXE_SUFFIX} ./result/*.heap || exit 1
+ ${GPROF} -png -output ./result/heap_profile.png ${GPROF_ARGS} -sample_index=alloc_space ../example/ndpiReader${EXE_SUFFIX} ./result/*.heap || exit 1
fi
}