PCOV - CodeCoverage compatible driver for PHP

Overview

PCOV

Build Status Build status

A self contained CodeCoverage compatible driver for PHP

Requirements and Installation

See INSTALL.md

API

/**
 * Shall start recording coverage information
 */
function \pcov\start() : void;

/**
 * Shall stop recording coverage information
 */
function \pcov\stop() : void;

/**
 * Shall collect coverage information
 *
 * @param integer $type define witch type of information should be collected
 *		 \pcov\all        shall collect coverage information for all files
 *		 \pcov\inclusive  shall collect coverage information for the specified files
 *		 \pcov\exclusive  shall collect coverage information for all but the specified files
 * @param array $filter path of files (realpath) that should be filtered
 *
 * @return array
 */
function \pcov\collect(int $type = \pcov\all, array $filter = []) : array;

/**
 * Shall clear stored information
 *
 * @param bool $files set true to clear file tables
 *
 * Note: clearing the file tables may have surprising consequences
 */
function \pcov\clear(bool $files = false) : void;

/**
 * Shall return list of files waiting to be collected
 */
function \pcov\waiting() : array;

/**
 * Shall return the current size of the trace and cfg arena
 */
function \pcov\memory() : int;

Configuration

PCOV is configured using PHP.ini:

Option Default Changeable Description
pcov.enabled 1 SYSTEM enable or disable zend hooks for pcov
pcov.directory auto SYSTEM,PERDIR restrict collection to files under this path
pcov.exclude unused SYSTEM,PERDIR exclude files under pcov.directory matching this PCRE
pcov.initial.memory 65536 SYSTEM,PERDIR shall set initial size of arena
pcov.initial.files 64 SYSTEM,PERDIR shall set initial size of tables

Notes

The recommended defaults for production should be:

  • pcov.enabled = 0

The recommended defaults for development should be:

  • pcov.enabled = 1
  • pcov.directory = /path/to/your/source/directory

When pcov.directory is left unset, PCOV will attempt to find src, lib or, app in the current working directory, in that order; If none are found the current directory will be used, which may waste resources storing coverage information for the test suite.

If pcov.directory contains test code, it's recommended to set pcov.exclude to avoid wasting resources.

To avoid unnecessary allocation of additional arenas for traces and control flow graphs, pcov.initial.memory should be set according to the memory required by the test suite, which may be discovered with \pcov\memory().

To avoid reallocation of tables, pcov.initial.files should be set to a number higher than the number of files that will be loaded during testing, inclusive of test files.

Note that arenas are allocated in chunks: If the chunk size is set to 65536 and pcov require 65537 bytes, the system will allocate two chunks, each 65536 bytes. When setting arena space therefore, be generous in your estimates.

Interoperability

When PCOV is enabled by configuration pcov.enabled=1:

  • interoperability with Xdebug is not possible
  • interoperability with phpdbg is not possible
  • interoperability with Blackfire profiler is not possible

At an internals level, the executor function is overriden by pcov, so any extension or SAPI which does the same will be broken.

When PCOV is disabled by configuration pcov.enabled=0:

  • PCOV is zero cost - code runs at full speed
  • Xdebug may be loaded
  • phpdbg may be executed
  • Blackfire probe may be loaded

At an internals level, the executor function is untouched, and pcov allocates no memory.

Differences in Reporting

There are subtle differences between Xdebug and PCOV in reporting: Both Xdebug and PCOV perform branch analysis in order to detect executable code. Xdebug has custom written (very mature, proven) analysis, while PCOV uses the very well proven control flow graph from Optimizer. They generate comparably accurate reports, while phpdbg uses less robust detection of executable code and generates reports with known defects. One such defect in phpdbg is this:

/* 2 */ function foo($bar) {
/* 3 */ 	if ($bar) {
/* 4 */			return true;
/* 5 */		}
/* 6 */	}

phpdbg will detect that this function is 100% covered when the first control path is taken, if ($bar), because it cannot correctly detect which implicit return paths inserted by Zend at compile time are executable, and so chooses to ignore them all. While this may seem like a trivial difference to some, it means that the reports generated by phpdbg are not completely trustworthy.

While the accuracy of Xdebug and PCOV are comparable, the reports they generate are not precisely the same, one such example is the switch construct:

/* 2 */ switch ($condition) {
/* 3 */		case 1:
/* 4 */			return "PHP rox!";
/* 5 */	}

From PHP 7.2.15 and PCOV 1.0, PCOV will detect the executability of the cases inside the switch body correctly, but will not detect line 2 (with the switch statement) as executable because Zend didn't output an executable opcode on that line. Xdebug's custom analysis doesn't use the same method and so will show an extra executable line on 2. Pre 7.2.15 and PCOV 1.0, the coverage of some switches is questionable as a result of the way Zend constructs the opcodes in the body of the switch - it may not execute them depending on a jump table optimization.

While Xdebug and PCOV both do the same kind of analysis of code, Xdebug is currently able to do more with that information than just generate accurate line coverage reports, it has path coverage and PCOV does not, although path coverage is not yet implemented (and probably won't be) by CodeCoverage.

Differences in Performance

The differences in performance of Xdebug and PCOV are not slight. Xdebug is first and foremost a debugging extension, and when you load it, you incur the overhead of a debugger even when it's disabled. PCOV is less than 1000 lines of code (not including CFG) and doesn't have anything like the overhead of a debugger.

Comments
  • Lines not covered when more tests are run

    Lines not covered when more tests are run

    Hello,

    I've spot an issue that some lines are not covered when tests are run together with other ones.

    Easiest way to reproduce is to clone this repository: git clone [email protected]:kubawerlos/php-cs-fixer-custom-fixers.git.

    When running vendor/bin/phpunit tests/Fixer all fixers get covered, which is expected.

    But when running vendor/bin/phpunit tests some fixers don't get covered fully (but only some) and always the problematic is function isRisky, e.g. InternalClassCasingFixer::isRisky.

    I've tested with PCOV v1.0.3 and phpunit/php-code-coverage 7.0.4.

    opened by kubawerlos 17
  • Segmentation fault on 7.4 on macOS with anonymous class

    Segmentation fault on 7.4 on macOS with anonymous class

    On PHP 7.4 (tested with 7.4.2 and 7.4.3) on macOS collecting code coverage for code that contains an anonymous class segfaults. The same code on Linux doesn't have any problems.

    Test script:

    <?php
    \pcov\start();
    $a = new class() {};
    \pcov\stop();
    var_dump(\pcov\collect());
    

    Expected result (at least that's what one receives with PHP 7.3):

    array(1) {
      ["[...redacted...]src/foo.php"]=>
      array(5) {
        [2]=>
        int(-1)
        [3]=>
        int(1)
        [4]=>
        int(1)
        [5]=>
        int(-1)
        [6]=>
        int(-1)
      }
    }
    

    Actual result:

    [1]    63456 segmentation fault  php src/foo.php
    
    opened by mikey179 15
  • Empty results

    Empty results

    Tests run and report is generated as normal, however, the coverage report shows 0% all the way through.

    If I run the same config using phpdbg or Xdebug, it takes a lot longer, but it yields correct results.

    I suspect it may be related to processIsolation? Here is my config

    <?xml version="1.0" encoding="UTF-8"?>
    <phpunit bootstrap                   = "tests/bootstrap.php"
             backupGlobals               = "false"
             backupStaticAttributes      = "false"
             colors                      = "true"
             convertErrorsToExceptions   = "true"
             convertNoticesToExceptions  = "true"
             convertWarningsToExceptions = "true"
             processIsolation            = "true"
             stopOnFailure               = "false">
        <php>
            <env name="APP_ENV" value="test"/>
        </php>
        
        <testsuites>
            <testsuite name="Unit Tests">
                <directory>tests/unit</directory>
            </testsuite>
        </testsuites>
    
        <logging>
            <log type="coverage-html" target=".output/report" />
        </logging>
        <filter>
            <whitelist processUncoveredFilesFromWhitelist="true">
                <directory suffix=".php">./app</directory>
            </whitelist>
        </filter>
    </phpunit>
    
    opened by ext-pewa 11
  • Problem with installation PCOV on php 7.3.8

    Problem with installation PCOV on php 7.3.8

    git clone .... git checkout release (not develop)

    -rw-r--r--   1 pvsaintpe  staff     0B  8 окт 14:35 missing
    -rw-r--r--   1 pvsaintpe  staff     0B  8 окт 14:35 mkinstalldirs
    drwxr-xr-x   2 pvsaintpe  staff    64B  8 окт 14:10 modules
    -rw-r--r--   1 pvsaintpe  staff   5,1K  8 окт 14:35 package.xml
    -rw-r--r--   1 pvsaintpe  staff    21K  8 окт 14:35 pcov.c
    -rw-r--r--   1 root       staff   221B  8 окт 14:38 pcov.loT
    -rw-r--r--   1 pvsaintpe  staff   2,5K  8 окт 14:35 php_pcov.h
    -rw-r--r--   1 pvsaintpe  staff    85K  8 окт 14:35 run-tests.php
    drwxr-xr-x   6 pvsaintpe  staff   192B  8 окт 14:09 tests
    
    pvsaintpe@UMB-0049 pcov % make 
    /bin/sh /Users/pvsaintpe/pcov/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/Users/pvsaintpe/pcov -DPHP_ATOM_INC -I/Users/pvsaintpe/pcov/include -I/Users/pvsaintpe/pcov/main -I/Users/pvsaintpe/pcov -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/Users/pvsaintpe/pcov/cfg/703  -DHAVE_CONFIG_H  -g -O2   -c /Users/pvsaintpe/pcov/pcov.c -o pcov.lo 
     cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/Users/pvsaintpe/pcov -DPHP_ATOM_INC -I/Users/pvsaintpe/pcov/include -I/Users/pvsaintpe/pcov/main -I/Users/pvsaintpe/pcov -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/Users/pvsaintpe/pcov/cfg/703 -DHAVE_CONFIG_H -g -O2 -c /Users/pvsaintpe/pcov/pcov.c  -fno-common -DPIC -o .libs/pcov.o
    /Users/pvsaintpe/pcov/pcov.c:25:10: fatal error: 'php.h' file not found
    #include "php.h"
             ^~~~~~~
    1 error generated.
    make: *** [pcov.lo] Error 1
    

    OS: MacOS Catalina (official release) 10.15 PEAR Version: 1.10.9 PHP Version: 7.3.8 Zend Engine Version: 3.3.8

    Installation via pecl also got errors.

    What am I doing wrong?

    opened by pvsaintpe 9
  • Pcov using almost 14 GB of memory to generate coverage

    Pcov using almost 14 GB of memory to generate coverage

    Hi,

    While running code coverage on a recent project I discovered that pcov consumed nearly 14 GB of memory and I can't figure out why exactly. I tried code coverage using xdebug and it only used 68 MB of memory to generate coverage for the same code. This was using PHP 7.4.20 on WSL2/Ubuntu 20.04. Please let me know if I can provide any additional information.

    Steps to reproduce:

    1. Clone https://github.com/TRowbotham/Encoding
    2. Run composer install
    3. Run php -dextension=<path-to-pcov> vendor/phpunit/phpunit/phpunit --coverage-html build/coverage

    These are the results of running pcov vs xdebug on my PC:

    $ php -dextension=/home/trevor/.phpbrew/php/php-7.4.20/lib/php/extensions/no-debug-non-zts-20190902/pcov.so vendor/phpunit/phpunit/phpunit --coverage-html build/coverage
    
    PHPUnit 9.5.4 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 7.4.20 with PCOV 1.0.8
    Configuration: /home/trevor/GitHub/Encoding/phpunit.xml
    
    .............................................................   61 / 1375 (  4%)
    .............................................................  122 / 1375 (  8%)
    .............................................................  183 / 1375 ( 13%)
    .............................................................  244 / 1375 ( 17%)
    .............................................................  305 / 1375 ( 22%)
    .............................................................  366 / 1375 ( 26%)
    .............................................................  427 / 1375 ( 31%)
    .............................................................  488 / 1375 ( 35%)
    .............................................................  549 / 1375 ( 39%)
    .............................................................  610 / 1375 ( 44%)
    .............................................................  671 / 1375 ( 48%)
    .............................................................  732 / 1375 ( 53%)
    .............................................................  793 / 1375 ( 57%)
    .............................................................  854 / 1375 ( 62%)
    .............................................................  915 / 1375 ( 66%)
    .............................................................  976 / 1375 ( 70%)
    ............................................................. 1037 / 1375 ( 75%)
    ............................................................. 1098 / 1375 ( 79%)
    ............................................................. 1159 / 1375 ( 84%)
    ............................................................. 1220 / 1375 ( 88%)
    ............................................................. 1281 / 1375 ( 93%)
    ............................................................. 1342 / 1375 ( 97%)
    .................................                             1375 / 1375 (100%)
    
    Time: 01:37.026, Memory: 13.84 GB
    
    OK (1375 tests, 427415 assertions)
    
    $ php -dzend_extension=/home/trevor/.phpbrew/php/php-7.4.20/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so -dxdebug.mode=coverage vendor/phpunit/phpunit/phpunit --coverage-html build/coverage
    
    PHPUnit 9.5.4 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 7.4.20 with Xdebug 3.0.4
    Configuration: /home/trevor/GitHub/Encoding/phpunit.xml
    
    .............................................................   61 / 1375 (  4%)
    .............................................................  122 / 1375 (  8%)
    .............................................................  183 / 1375 ( 13%)
    .............................................................  244 / 1375 ( 17%)
    .............................................................  305 / 1375 ( 22%)
    .............................................................  366 / 1375 ( 26%)
    .............................................................  427 / 1375 ( 31%)
    .............................................................  488 / 1375 ( 35%)
    .............................................................  549 / 1375 ( 39%)
    .............................................................  610 / 1375 ( 44%)
    .............................................................  671 / 1375 ( 48%)
    .............................................................  732 / 1375 ( 53%)
    .............................................................  793 / 1375 ( 57%)
    .............................................................  854 / 1375 ( 62%)
    .............................................................  915 / 1375 ( 66%)
    .............................................................  976 / 1375 ( 70%)
    ............................................................. 1037 / 1375 ( 75%)
    ............................................................. 1098 / 1375 ( 79%)
    ............................................................. 1159 / 1375 ( 84%)
    ............................................................. 1220 / 1375 ( 88%)
    ............................................................. 1281 / 1375 ( 93%)
    ............................................................. 1342 / 1375 ( 97%)
    .................................                             1375 / 1375 (100%)
    
    Time: 02:04.912, Memory: 68.00 MB
    
    OK (1375 tests, 427415 assertions)
    
    opened by TRowbotham 8
  • Undefined variable: argv when running

    Undefined variable: argv when running

    Running PHPUnit on https://github.com/vimeo/psalm I get

    > vendor/bin/phpunit
    PHPUnit 8.1.6 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 7.3.5 with PCOV 1.0.5
    Configuration: /xxx/psalm/phpunit.xml.dist
    
    Undefined variable: argv
    

    It works just fine without pcov enabled. Unsure how to proceed.

    register_argc_argv = Off
    

    in my php.ini (but setting it to On doesn't help either).

    opened by muglug 7
  • Code that is not executed is reported as being executed

    Code that is not executed is reported as being executed

    When I run the tests for the diff test suite with code coverage reporting based on PCOV then I get two tests marked as risky:

    There were 2 risky tests:
    
    1) SebastianBergmann\Diff\DifferTest::testArrayRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsImplementation with data set #0 (array(array('a', 2), array('b', 1)), 'a', 'b')
    This test executed code that is not listed as code to be covered or used:
    - SebastianBergmann\Diff\Chunk::__construct
    - SebastianBergmann\Diff\Diff::__construct
    - SebastianBergmann\Diff\Diff::getChunks
    - SebastianBergmann\Diff\Diff::setChunks
    
    2) SebastianBergmann\Diff\MemoryEfficientImplementationTest::testBothEmpty
    This test executed code that is not listed as code to be covered or used:
    - SebastianBergmann\Diff\Line::__construct
    - SebastianBergmann\Diff\Line::getContent
    

    These tests are not marked as risky when code coverage is reported using Xdebug or PHPDBG.

    When I add an exit statement to the constructor of Chunk like so

    diff --git a/src/Chunk.php b/src/Chunk.php
    index d030954..21f3367 100644
    --- a/src/Chunk.php
    +++ b/src/Chunk.php
    @@ -39,6 +39,7 @@ final class Chunk
     
         public function __construct(int $start = 0, int $startRange = 1, int $end = 0, int $endRange = 1, array $lines = [])
         {
    +        exit;
             $this->start      = $start;
             $this->startRange = $startRange;
             $this->end        = $end;
    

    and run the testArrayRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsImplementation test (./vendor/bin/phpunit --filter testArrayRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsImplementation) then it works, meaning the exit statement is not reached, meaning that Chunk is not used.

    When I add an exit statement to the constructor of Diff like so

    diff --git a/src/Diff.php b/src/Diff.php
    index 3029e59..ea5c15d 100644
    --- a/src/Diff.php
    +++ b/src/Diff.php
    @@ -34,6 +34,7 @@ final class Diff
          */
         public function __construct(string $from, string $to, array $chunks = [])
         {
    +        exit;
             $this->from   = $from;
             $this->to     = $to;
             $this->chunks = $chunks;
    

    and run the testArrayRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsImplementation test (./vendor/bin/phpunit --filter testArrayRepresentationOfDiffCanBeRenderedUsingTimeEfficientLcsImplementation) then it works, meaning the exit statement is not reached, meaning that Diff is not used.

    When I add an exit statement to the constructor of Line like so

    diff --git a/src/Line.php b/src/Line.php
    index 125bafd..0ec4266 100644
    --- a/src/Line.php
    +++ b/src/Line.php
    @@ -28,6 +28,7 @@ final class Line
     
         public function __construct(int $type = self::UNCHANGED, string $content = '')
         {
    +        exit;
             $this->type    = $type;
             $this->content = $content;
         }
    

    and run the testBothEmpty test (./vendor/bin/phpunit --filter testBothEmpty) then it works, meaning the exit statement is not reached, meaning that Line is not used.

    How to run the tests where I see the problem

    git clone https://github.com/sebastianbergmann/diff.git
    cd diff
    composer install
    ./vendor/bin/phpunit
    
    opened by sebastianbergmann 7
  • Release v1.0.4

    Release v1.0.4

    • Fix #17 Lines not covered when more tests are run
    • Improve perf of clear routine
    • Merge upstream cfg updates (switch block change)
    • Omit ignored opcodes from internal coverage data completely (doesn't effect users, except less memory used)

    over to you @remicollet, thanks :)

    Release 
    opened by krakjoe 6
  • cfg/800 missing

    cfg/800 missing

    At least when building with PHP 8.0 on Windows, I get

    ext\pcov\pcov.c(32): fatal error C1083: Datei (Include) kann nicht geöffnet werden: "zend_cfg.h": No such file or directory
    
    opened by cmb69 5
  • [WIP] Lines marked as red or white but never green

    [WIP] Lines marked as red or white but never green

    Hi, I'm having issues on how PCOV reports some lines.

    This is a WIP since I know all the following details still aren't enough for you to help me, I need to dig deeper and isolate better where the problem lies, but still I prefer to open an Issue now, maybe you can help me find it.

    Env details

    1. Codeception 3.0
    2. PHPUnit 8.3.3
    3. php-code-coverage 7.0.7
    4. PHP 7.3.8
    5. PCOV 1.0.6
    6. OS: Docker, see https://github.com/Slamdunk/docker-php/blob/master/7.3.Dockerfile#L53

    1) Executed lines may differ depending on the run

    Two different runs, the only change was removing every @covers annotations from unit and functional tests.

    Without @covers: pcov-full

    With @covers: pcov-part

    All 3 lines 60, 61 and 62 are executed for sure, as lines 62 is green, but the output differs.

    1. How can lines 60 and 61 marked as red?
    2. How is that executed lines differ?

    2) Function parameters may be signed as executed or not

    pcov-wut

    1. How can lines 990 and 991 not marked as executed?
    opened by Slamdunk 5
  • Release 1.0.0

    Release 1.0.0

    Hi Remi :)

    I know you're afk at the moment ... whenever you've time ...

    Release v1.0.0 is ready for PECL ... I know I said the API was stable, but I changed it, hence version bump.

    I think I've removed all the unused stuff, but if you could cast your eye over it, that'd be good.

    The changelog should be brief, just "Import Zend CFG" or something. Probably still go with beta, even though the CFG is probably some of the best tested code in the ecosystem, let us be cautious ...

    Thanks in advance, hope you're enjoying conference :)

    opened by krakjoe 5
  • Compile error with PHP 8.1: use option -std=c99 or -std=gnu99 to compile your code

    Compile error with PHP 8.1: use option -std=c99 or -std=gnu99 to compile your code

    I am installing pocv via PECL 1.0.11 on CentOS 7 and PHP 8.1 and I am getting a C99 error:

     pecl install pcov
    downloading pcov-1.0.11.tgz ...
    Starting to download pcov-1.0.11.tgz (25,300 bytes)
    .........done: 25,300 bytes
    16 source files, building
    running: phpize
    Configuring for:
    PHP Api Version:         20210902
    Zend Module Api No:      20210902
    Zend Extension Api No:   420210902
    building in /var/tmp/pear-build-defaultuserODr6gO/pcov-1.0.11
    running: /var/tmp/pcov/configure --with-php-config=/usr/bin/php-config
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for a sed that does not truncate output... /usr/bin/sed
    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    checking for cc... cc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether cc accepts -g... yes
    checking for cc option to accept ISO C89... none needed
    checking how to run the C preprocessor... cc -E
    checking for icc... no
    checking for suncc... no
    checking for system library directory... lib
    checking if compiler supports -Wl,-rpath,... yes
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... x86_64-pc-linux-gnu
    checking target system type... x86_64-pc-linux-gnu
    checking for PHP prefix... /usr
    checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
    checking for PHP extension directory... /usr/lib64/php/modules
    checking for PHP installed headers prefix... /usr/include/php
    checking if debug is enabled... no
    checking if zts is enabled... no
    checking for gawk... gawk
    checking whether to enable php coverage support... yes, shared
    checking PHP version... checking how to print strings... printf
    checking for a sed that does not truncate output... (cached) /usr/bin/sed
    checking for fgrep... /usr/bin/grep -F
    checking for ld used by cc... /usr/bin/ld
    checking if the linker (/usr/bin/ld) is GNU ld... yes
    checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
    checking the name lister (/usr/bin/nm -B) interface... BSD nm
    checking whether ln -s works... yes
    checking the maximum length of command line arguments... 1572864
    checking whether the shell understands some XSI constructs... yes
    checking whether the shell understands "+="... yes
    checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
    checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
    checking for /usr/bin/ld option to reload object files... -r
    checking for objdump... objdump
    checking how to recognize dependent libraries... pass_all
    checking for dlltool... no
    checking how to associate runtime and link libraries... printf %s\n
    checking for ar... ar
    checking for archiver @FILE support... @
    checking for strip... strip
    checking for ranlib... ranlib
    checking for gawk... (cached) gawk
    checking command to parse /usr/bin/nm -B output from cc object... ok
    checking for sysroot... no
    /var/tmp/pcov/configure: line 6696: /usr/bin/file: No such file or directory
    checking for mt... no
    checking if : is a manifest tool... no
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for dlfcn.h... yes
    checking for objdir... .libs
    checking if cc supports -fno-rtti -fno-exceptions... no
    checking for cc option to produce PIC... -fPIC -DPIC
    checking if cc PIC flag -fPIC -DPIC works... yes
    checking if cc static flag -static works... no
    checking if cc supports -c -o file.o... yes
    checking if cc supports -c -o file.o... (cached) yes
    checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes
    checking whether -lc should be explicitly linked in... no
    checking dynamic linker characteristics... GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking whether stripping libraries is possible... yes
    checking if libtool supports shared libraries... yes
    checking whether to build shared libraries... yes
    checking whether to build static libraries... no
    configure: patching config.h.in
    configure: creating ./config.status
    config.status: creating config.h
    config.status: executing libtool commands
    running: make
    /bin/sh /var/tmp/pear-build-defaultuserODr6gO/pcov-1.0.11/libtool --mode=compile cc -I. -I/var/tmp/pcov -I/var/tmp/pear-build-defaultuserODr6gO/pcov-1.0.11/include -I/var/tmp/pear-build-defaultuserODr6gO/pcov-1.0.11/main -I/var/tmp/pcov -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DZEND_COMPILE_DL_EXT=1 -c /var/tmp/pcov/pcov.c -o pcov.lo  -MMD -MF pcov.dep -MT pcov.lo
    libtool: compile:  cc -I. -I/var/tmp/pcov -I/var/tmp/pear-build-defaultuserODr6gO/pcov-1.0.11/include -I/var/tmp/pear-build-defaultuserODr6gO/pcov-1.0.11/main -I/var/tmp/pcov -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DZEND_COMPILE_DL_EXT=1 -c /var/tmp/pcov/pcov.c -MMD -MF pcov.dep -MT pcov.lo  -fPIC -DPIC -o .libs/pcov.o
    /var/tmp/pcov/pcov.c: In function 'php_pcov_discover_code':
    /var/tmp/pcov/pcov.c:604:5: error: 'for' loop initial declarations are only allowed in C99 mode
         for (uint32_t def = 0; def < ops->num_dynamic_func_defs; def++) {
         ^
    /var/tmp/pcov/pcov.c:604:5: note: use option -std=c99 or -std=gnu99 to compile your code
    make: *** [pcov.lo] Error 1
    ERROR: `make' failed
    

    Am I making an error installing it?

    opened by wieczo 0
  • Segmentation fault at the end of Phpunit job

    Segmentation fault at the end of Phpunit job

    Happens with PHP 8.1 and PHP 8.2

    Backtrace

    #0  0x000056267b19e9b2 in ?? ()
    #1  0x000056267b1d49b0 in zend_vm_call_opcode_handler ()
    #2  0x00007f928d32dd08 in php_pcov_execute_ex () from /usr/lib/php/20210902/pcov.so
    #3  0x000056267b155aac in zend_call_function ()
    #4  0x000056267b155d79 in _call_user_function_impl ()
    #5  0x000056267b11ce36 in ?? ()
    #6  0x000056267b115ca4 in _php_stream_free ()
    #7  0x000056267b115f46 in ?? ()
    #8  0x000056267b179325 in ?? ()
    #9  0x000056267b1798dc in ?? ()
    #10 0x000056267b153fec in zend_shutdown_executor_values ()
    #11 0x000056267b1540c3 in ?? ()
    #12 0x000056267b163fe3 in zend_deactivate ()
    #13 0x000056267b0ffd86 in php_request_shutdown ()
    #14 0x000056267b24bfa0 in ?? ()
    #15 0x000056267afa2f78 in ?? ()
    #16 0x00007f9290afe083 in __libc_start_main (main=0x56267afa2b70, argc=10, argv=0x7fff918af0d8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff918af0c8) at ../csu/libc-start.c:308
    #17 0x000056267afa374e in _start ()
    
    opened by shyim 0
  • Thanks!  Improvement of 50% of my phpunit stage

    Thanks! Improvement of 50% of my phpunit stage

    Wow! Just by disabling XDEBUG_MODE (=off) and installing pcov in my Docker image, I've reduced the time needed by my unit tests stage from 11 minutes to 5 minutes and 30 seconds. 50% of increase with the same features. The same number of tests are fired and the code covering is the same.

    Amazing.

    Thanks for you work!!!

    opened by cavo789 0
  • PCOV causes segmentation fault during memory overflow.

    PCOV causes segmentation fault during memory overflow.

    Description

    The following code:

    <?php declare(strict_types=1);
    
    ////
    // Execute the bug
    ////
    main();
    
    
    ////
    // Minimum Viable Bug
    ////
    
    interface SessionCookieInterface
    {
    }
    
    interface SessionRepositoryInterface
    {
    }
    
    class SessionFactory
    {
    	public function createSession(string $session_name, ?SessionCookieInterface $cookie = null, ?SessionRepositoryInterface $repo = null) : SessionInterface
    	{
    		if ($cookie === null)
    		{
    			$cookie = self::generateDefaultSession();
    		}
    
    		return (new Session())
    			->withName($session_name)
    			->withCookieParams($cookie);
    	}
    
    	public static function generateDefaultSession() : SessionInterface
    	{
    		return (new SessionFactory())->createSession('test1234');
    	}
    }
    
    class Session
    {
    	private string $name = 'SID';
    	private SessionCookieInterface $cookie;
    
    	public function withName(string $session_name) : self
    	{
    		$new = clone $this;
    		$new->name = $session_name;
    
    		return $new;
    	}
    
    	public function withCookieParams(SessionCookieInterface $cookie) : self
    	{
    		$new = clone $this;
    		$new->cookie = $cookie;
    
    		return $new;
    	}
    }
    
    function main()
    {
    	$session = (new SessionFactory())->createSession('test1234');
    }
    

    Resulted in this output:

    
    Output of script
    
    root@175dab3f7cb7:/home/app/src/Session# php test_segmentation.php
    Segmentation fault (core dumped)
    root@175dab3f7cb7:/home/app/src/Session# 
    
    ===========Core Dump information=========
    [vmarone@vinnielab: ~/projects/aiur/aiur-api]$ gdb /usr/bin/php /tmp/coredump-php.741983
    GNU gdb (GDB) 12.1
    Copyright (C) 2022 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Type "show copying" and "show warranty" for details.
    This GDB was configured as "x86_64-pc-linux-gnu".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <https://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
        <http://www.gnu.org/software/gdb/documentation/>.
    
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from /usr/bin/php...
    (No debugging symbols found in /usr/bin/php)
    [New LWP 741983]
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/usr/lib/libthread_db.so.1".
    Core was generated by `php src/Session/test_segmentation.php'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  0x00007f2bc2a796bb in php_pcov_execute_ex () from /usr/lib/php/modules/pcov.so
    (gdb) q
    [vmarone@vinnielab: ~/projects/aiur/aiur-api]$
    
    =========LOGS========
    
    aiur_php    | [27-Sep-2022 19:43:08] WARNING: [pool www] child 8 exited on signal 11 (SIGSEGV - core dumped) after 3.834072 seconds from start
    aiur_php    | [27-Sep-2022 19:43:08] NOTICE: [pool www] child 10 started
    aiur_php    | [27-Sep-2022 19:43:38] WARNING: [pool www] child 9 exited on signal 11 (SIGSEGV - core dumped) after 33.987749 seconds from start
    aiur_php    | [27-Sep-2022 19:43:38] NOTICE: [pool www] child 11 started
    aiur_php    | 172.31.0.5 -  27/Sep/2022:19:44:01 +0000 "POST /index.php" 200
    aiur_php    | [27-Sep-2022 19:44:44] ALERT: oops, unknown child (22) exited with code 0. Please open a bug report (https://github.com/php/php-src/issues).
    aiur_php    | [27-Sep-2022 19:44:56] WARNING: [pool www] child 11 exited on signal 11 (SIGSEGV - core dumped) after 78.615515 seconds from start
    aiur_php    | [27-Sep-2022 19:44:56] NOTICE: [pool www] child 27 started
    aiur_php    | [27-Sep-2022 19:45:41] WARNING: [pool www] child 10 exited on signal 11 (SIGSEGV - core dumped) after 153.733791 seconds from start
    aiur_php    | [27-Sep-2022 19:45:41] NOTICE: [pool www] child 28 started
    aiur_php    | [27-Sep-2022 19:45:49] WARNING: [pool www] child 27 exited on signal 11 (SIGSEGV - core dumped) after 52.722584 seconds from start
    aiur_php    | [27-Sep-2022 19:45:49] NOTICE: [pool www] child 29 started
    aiur_php    | [27-Sep-2022 19:45:59] WARNING: [pool www] child 28 exited on signal 11 (SIGSEGV - core dumped) after 17.311002 seconds from start
    aiur_php    | [27-Sep-2022 19:45:59] NOTICE: [pool www] child 30 started
    aiur_php    | [27-Sep-2022 19:47:00] ALERT: oops, unknown child (42) exited with code 0. Please open a bug report (https://github.com/php/php-src/issues).
    aiur_php    | [27-Sep-2022 19:47:17] ALERT: oops, unknown child (57) exited with code 0. Please open a bug report (https://github.com/php/php-src/issues).
    aiur_php    | [27-Sep-2022 19:48:19] ALERT: oops, unknown child (72) exited with code 0. Please open a bug report (https://github.com/php/php-src/issues).
    aiur_php    | [27-Sep-2022 19:48:48] ALERT: oops, unknown child (87) exited with code 0. Please open a bug report (https://github.com/php/php-src/issues).
    

    But I expected this output instead:

    The expected output should of probably been some sort of fatal exception, not crash the entire php-fpm child.
    
    Something like this.
    
    [vmarone@vinnielab: ~/projects/aiur/aiur-api]$ php src/Session/test_segmentation.php
    PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /home/vmarone/projects/aiur/aiur-api/src/Session/test_segmentation.php on line 37
    [vmarone@vinnielab: ~/projects/aiur/aiur-api]$
    

    PHP Version

    8.1.9

    Operating System

    Linux 175dab3f7cb7 5.19.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 05 Sep 2022 18:09:09 +0000 x86_64 GNU/Linux

    opened by Porthorian 1
  • Pcov crashes with PHP 8.2

    Pcov crashes with PHP 8.2

    Process 88175 launched: '/opt/homebrew/bin/php' (arm64)
    PHPUnit 9.5.21 #StandWithUkraine
    
    Random Seed:   1659429554
    
    Testing Shopware\Tests\Unit\Core\Framework\Validation\DataBag\DataBagTest
    Process 88175 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x1100000024)
        frame #0: 0x0000000100f1f7b4 pcov.so`php_pcov_discover_code + 172
    pcov.so`php_pcov_discover_code:
    ->  0x100f1f7b4 <+172>: ldrb   w8, [x22, #0x1c]
        0x100f1f7b8 <+176>: sub    w9, w8, #0x7f
        0x100f1f7bc <+180>: cmp    w9, #0x29
        0x100f1f7c0 <+184>: lsl    x9, x25, x9
    Target 0: (php) stopped.
    
    PHP 8.2.0-dev (cli) (built: Aug  2 2022 00:23:38) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.2.0-dev, Copyright (c) Zend Technologies
        with Zend OPcache v8.2.0-dev, Copyright (c), by Zend Technologies
    
    opened by shyim 0
Owner
Joe Watkins
Joe Watkins
Handle PHP errors, dump variables, execute PHP code remotely in Google Chrome

PHP Console server library PHP Console allows you to handle PHP errors & exceptions, dump variables, execute PHP code remotely and many other things u

Sergey 1.4k Dec 25, 2022
PHP APM (Alternative PHP Monitor)

APM (Alternative PHP Monitor) APM (Alternative PHP Monitor) is a monitoring extension enabling native Application Performance Management (APM) for PHP

Patrick Allaert 310 Dec 4, 2022
Zipkin PHP is the official PHP Tracer implementation for Zipkin

Zipkin PHP is the official PHP Tracer implementation for Zipkin, supported by the OpenZipkin community. Installation composer require openz

Open Zipkin 250 Nov 12, 2022
Debug bar for PHP

PHP Debug Bar Displays a debug bar in the browser with information from php. No more var_dump() in your code! Features: Generic debug bar Easy to inte

Maxime Bouroumeau-Fuseau 4k Jan 8, 2023
Xdebug — Step Debugger and Debugging Aid for PHP

Xdebug Xdebug is a debugging tool for PHP. It provides step-debugging and a whole range of development aids, such as stack traces, a code profiler, fe

Xdebug 2.8k Jan 3, 2023
Kint - a powerful and modern PHP debugging tool.

Kint - debugging helper for PHP developers What am I looking at? At first glance Kint is just a pretty replacement for var_dump(), print_r() and debug

null 2.7k Dec 25, 2022
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

Tracy - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

Nette Foundation 1.6k Dec 23, 2022
PHP Benchmarking framework

PHPBench is a benchmark runner for PHP analogous to PHPUnit but for performance rather than correctness. Features include: Revolutions: Repeat your co

PHPBench 1.7k Jan 2, 2023
The Interactive PHP Debugger

The interactive PHP debugger Implemented as a SAPI module, phpdbg can exert complete control over the environment without impacting the functionality

Joe Watkins 841 Oct 9, 2022
Dontbug is a reverse debugger for PHP

Dontbug Debugger Dontbug is a reverse debugger (aka time travel debugger) for PHP. It allows you to record the execution of PHP scripts (in command li

Sidharth Kshatriya 709 Dec 30, 2022
PHP Debug Console

PHP Console A web console to try your PHP code into Creating a test file or using php's interactive mode can be a bit cumbersome to try random php sni

Jordi Boggiano 523 Nov 7, 2022
Php Debugger to run in terminal to debug your code easily.

What is Dephpugger? Dephpugger (read depugger) is an open source lib to make a debug in php direct in terminal, without necessary configure an IDE. Th

Renato Cassino 190 Dec 3, 2022
Low-overhead sampling profiler for PHP 7+

phpspy phpspy is a low-overhead sampling profiler for PHP. For now, it works with Linux 3.2+ x86_64 non-ZTS PHP 7.0+ with CLI, Apache, and FPM SAPIs.

Adam 1.3k Dec 24, 2022
The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function that you can use instead of var_dump().

VarDumper Component The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function t

Symfony 7.1k Jan 1, 2023
PHP errors for cool kids

whoops PHP errors for cool kids whoops is an error handler framework for PHP. Out-of-the-box, it provides a pretty error interface that helps you debu

Filipe Dobreira 12.9k Dec 24, 2022
Clockwork - php dev tools in your browser - server-side component

Clockwork is a development tool for PHP available right in your browser. Clockwork gives you an insight into your application runtime - including requ

its 4.8k Dec 29, 2022
Laravel Debugbar (Integrates PHP Debug Bar)

Laravel Debugbar This is a package to integrate PHP Debug Bar with Laravel. It includes a ServiceProvider to register the debugbar and attach it to th

Barry vd. Heuvel 14.8k Jan 9, 2023
This package connects a Laravel Octance application with Tideways for PHP Monitoring, Profiling and Exception Tracking.

Tideways Middleware for Laravel Octane This package connects a Laravel Octance application with Tideways for PHP Monitoring, Profiling and Exception T

Tideways 7 Jan 6, 2022
A tool to profile mysql queries in php env.

MysqlQueryProfiler This tool helps you to quickly profile a mysql query in a PHP 7.4+ environnement. You can also compare 2 queries. This image shows

null 8 Jul 30, 2021