From: Dmitry Stogov Date: Wed, 31 May 2017 13:16:56 +0000 (+0300) Subject: Exclude warm-up requests from callgrind profile. X-Git-Tag: php-7.2.0alpha1~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc1ae1d1d3b1752c581e258fd3fcc3a184631baa;p=php Exclude warm-up requests from callgrind profile. --- diff --git a/acinclude.m4 b/acinclude.m4 index bc0e792f4e..07ae363f65 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -3224,3 +3224,23 @@ AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [ dnl Load the AX_CHECK_COMPILE_FLAG macro from the autoconf archive. m4_include([build/ax_check_compile_flag.m4]) + +dnl PHP_CHECK_VALGRIND +AC_DEFUN([PHP_CHECK_VALGRIND], [ + AC_MSG_CHECKING([for valgrind]) + + SEARCH_PATH="/usr/local /usr" + SEARCH_FOR="/include/valgrind/valgrind.h" + for i in $SEARCH_PATH ; do + if test -r $i/$SEARCH_FOR; then + VALGRIND_DIR=$i + fi + done + + if test -z "$VALGRIND_DIR"; then + AC_MSG_RESULT([not found]) + else + AC_MSG_RESULT(found in $VALGRIND_DIR) + AC_DEFINE(HAVE_VALGRIND, 1, [ ]) + fi +]) diff --git a/configure.ac b/configure.ac index 598418fd89..9937a4c15d 100644 --- a/configure.ac +++ b/configure.ac @@ -751,6 +751,8 @@ if test "x$php_crypt_r" = "x1"; then PHP_CRYPT_R_STYLE fi +PHP_CHECK_VALGRIND + dnl General settings. dnl ------------------------------------------------------------------------- PHP_CONFIGURE_PART(General settings) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 2cf16449f9..8639027dbc 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -96,6 +96,10 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; # include "openssl/applink.c" #endif +#ifdef HAVE_VALGRIND +# include "valgrind/callgrind.h" +#endif + #ifndef PHP_WIN32 /* XXX this will need to change later when threaded fastcgi is implemented. shane */ struct sigaction act, old_term, old_quit, old_int; @@ -2246,6 +2250,11 @@ consult the installation file that came with this distribution, or visit \n\ if (comma) { warmup_repeats = atoi(php_optarg); repeats = atoi(comma + 1); +#ifdef HAVE_VALGRIND + if (warmup_repeats > 0) { + CALLGRIND_STOP_INSTRUMENTATION; + } +#endif } else { repeats = atoi(php_optarg); } @@ -2667,6 +2676,9 @@ fastcgi_request_done: gettimeofday(&start, NULL); #else time(&start); +#endif +#ifdef HAVE_VALGRIND + CALLGRIND_START_INSTRUMENTATION; #endif } continue;