Commit 69c9e7e7 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

build: New configure --enable-coverage option

Some of the autoconf logic is originally from Asad. In addition, the
explicit call to __gcov_flush() is now vendored in vdef.h like other
toolchain abstractions.
parent db18d840
...@@ -125,6 +125,10 @@ cscope.*out ...@@ -125,6 +125,10 @@ cscope.*out
/lib/libvarnishapi/vsl_glob_test /lib/libvarnishapi/vsl_glob_test
/lib/libvarnishapi/vxp_test /lib/libvarnishapi/vxp_test
# GCOV droppings
*.gcda
*.gcno
# vtc-bisect.sh default vtc # vtc-bisect.sh default vtc
/bisect.vtc /bisect.vtc
......
...@@ -42,6 +42,9 @@ install-data-local: ...@@ -42,6 +42,9 @@ install-data-local:
$(install_sh) -d -m 0755 $(DESTDIR)$(localstatedir)/varnish $(install_sh) -d -m 0755 $(DESTDIR)$(localstatedir)/varnish
distclean-local:
find . '(' -name '*.gcda' -o -name '*.gcda' ')' -exec rm '{}' ';'
distcleancheck_listfiles = \ distcleancheck_listfiles = \
find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \ find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \
sh '{}' ';' sh '{}' ';'
......
...@@ -65,10 +65,6 @@ ...@@ -65,10 +65,6 @@
* *
*/ */
#ifdef GCOVING
int __gcov_flush(void);
#endif
static struct vsb pan_vsb_storage, *pan_vsb; static struct vsb pan_vsb_storage, *pan_vsb;
static pthread_mutex_t panicstr_mtx; static pthread_mutex_t panicstr_mtx;
...@@ -812,9 +808,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, ...@@ -812,9 +808,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
VSB_cat(pan_vsb, "\n"); VSB_cat(pan_vsb, "\n");
VSB_putc(pan_vsb, '\0'); /* NUL termination */ VSB_putc(pan_vsb, '\0'); /* NUL termination */
#ifdef GCOVING v_gcov_flush();
__gcov_flush();
#endif
abort(); abort();
} }
......
...@@ -63,10 +63,6 @@ static const struct cli_cmd_desc *cmds[] = { ...@@ -63,10 +63,6 @@ static const struct cli_cmd_desc *cmds[] = {
#include "tbl/cli_cmds.h" #include "tbl/cli_cmds.h"
}; };
#ifdef GCOVING
int __gcov_flush(void);
#endif
static const int ncmds = sizeof cmds / sizeof cmds[0]; static const int ncmds = sizeof cmds / sizeof cmds[0];
static int cli_i = -1, cli_o = -1; static int cli_i = -1, cli_o = -1;
...@@ -112,9 +108,7 @@ mcf_panic(struct cli *cli, const char * const *av, void *priv) ...@@ -112,9 +108,7 @@ mcf_panic(struct cli *cli, const char * const *av, void *priv)
(void)cli; (void)cli;
(void)av; (void)av;
(void)priv; (void)priv;
#ifdef GCOVING v_gcov_flush();
__gcov_flush();
#endif
AZ(strcmp("", "You asked for it")); AZ(strcmp("", "You asked for it"));
/* NOTREACHED */ /* NOTREACHED */
abort(); abort();
......
...@@ -769,6 +769,13 @@ case $CFLAGS in ...@@ -769,6 +769,13 @@ case $CFLAGS in
;; ;;
esac esac
# --enable-coverage
AC_ARG_ENABLE(coverage,
AS_HELP_STRING([--enable-coverage],
[enable coverage (implies debugging symbols, default is NO)]),
[],
[enable_coverage=no])
# --enable-debugging-symbols # --enable-debugging-symbols
AC_ARG_ENABLE(debugging-symbols, AC_ARG_ENABLE(debugging-symbols,
AS_HELP_STRING([--enable-debugging-symbols], AS_HELP_STRING([--enable-debugging-symbols],
...@@ -776,6 +783,25 @@ AC_ARG_ENABLE(debugging-symbols, ...@@ -776,6 +783,25 @@ AC_ARG_ENABLE(debugging-symbols,
[], [],
[enable_debugging_symbols=no]) [enable_debugging_symbols=no])
if test "$enable_coverage" != no; then
AC_DEFINE([GCOVING], [1], [Define to 1 if code coverage is enabled.])
save_CFLAGS=$CFLAGS
CFLAGS=
AX_CHECK_COMPILE_FLAG([--coverage],
[COV_FLAGS=--coverage],
[AX_CHECK_COMPILE_FLAG([-fprofile-arcs -ftest-coverage],
[COV_FLAGS="-fprofile-arcs -ftest-coverage"])])
AX_CHECK_COMPILE_FLAG([-fprofile-abs-path],
[COV_FLAGS="$COV_FLAGS -fprofile-abs-path"])
AX_CHECK_COMPILE_FLAG([-fPIC], [COV_FLAGS="$COV_FLAGS -fPIC"])
CFLAGS=$COV_FLAGS
AC_CHECK_FUNCS([__gcov_flush])
AC_CHECK_FUNCS([__gcov_dump])
AC_CHECK_FUNCS([__llvm_gcov_flush])
CFLAGS="$save_CFLAGS $COV_FLAGS"
enable_debugging_symbols=yes
fi
if test "$enable_debugging_symbols" != no; then if test "$enable_debugging_symbols" != no; then
if test "x$SUNCC" = "xyes" ; then if test "x$SUNCC" = "xyes" ; then
CFLAGS="${CFLAGS} -O0 -g" CFLAGS="${CFLAGS} -O0 -g"
......
...@@ -112,6 +112,19 @@ ...@@ -112,6 +112,19 @@
# define v_dont_optimize # define v_dont_optimize
#endif #endif
#ifdef HAVE___GCOV_FLUSH
# define v_gcov_flush() __gcov_flush()
int __gcov_flush(void);
#elif defined HAVE___GCOV_DUMP
# define v_gcov_flush() __gcov_dump()
void __gcov_dump(void);
#elif defined HAVE___LLVM_GCOV_FLUSH
# define v_gcov_flush() __llvm_gcov_flush()
int __llvm_gcov_flush(void);
#else
# define v_gcov_flush() do { } while (0)
#endif
/********************************************************************* /*********************************************************************
* Fundamental numerical limits * Fundamental numerical limits
* These limits track RFC8941 * These limits track RFC8941
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment