PHP User-Space Markers

Since PHP-5.5.x released in June 2013 PHP has included support for SystemTap user-space markers. The SystemTap user-space markers are enabled in Fedora 28 and RHEL 7 and allow SystemTap to probe various aspects of PHP operation such as handling exceptions and executing functions. Below is the SystemTap command and the resulting output listing the PHP user-space probes points:

$ stap -L 'process("/usr/bin/php*").provider("php").mark("*")' 
process("/usr/bin/php").provider("php").mark("compile__file__entry") $arg1:long $arg2:long
process("/usr/bin/php").provider("php").mark("compile__file__return") $arg1:long $arg2:long
process("/usr/bin/php").provider("php").mark("error") $arg1:long $arg2:long $arg3:long
process("/usr/bin/php").provider("php").mark("exception__caught") $arg1:long
process("/usr/bin/php").provider("php").mark("exception__thrown") $arg1:long
process("/usr/bin/php").provider("php").mark("execute__entry") $arg1:long $arg2:long
process("/usr/bin/php").provider("php").mark("execute__return") $arg1:long $arg2:long
process("/usr/bin/php").provider("php").mark("function__entry") $arg1:long $arg2:long $arg3:long $arg4:long $arg5:long
process("/usr/bin/php").provider("php").mark("function__return") $arg1:long $arg2:long $arg3:long $arg4:long $arg5:long
process("/usr/bin/php").provider("php").mark("request__shutdown") $arg1:long $arg2:long $arg3:long
process("/usr/bin/php").provider("php").mark("request__startup") $arg1:long $arg2:long $arg3:long
process("/usr/bin/php-cgi").provider("php").mark("compile__file__entry") $arg1:long $arg2:long
process("/usr/bin/php-cgi").provider("php").mark("compile__file__return") $arg1:long $arg2:long
process("/usr/bin/php-cgi").provider("php").mark("error") $arg1:long $arg2:long $arg3:long
process("/usr/bin/php-cgi").provider("php").mark("exception__caught") $arg1:long
process("/usr/bin/php-cgi").provider("php").mark("exception__thrown") $arg1:long
process("/usr/bin/php-cgi").provider("php").mark("execute__entry") $arg1:long $arg2:long
process("/usr/bin/php-cgi").provider("php").mark("execute__return") $arg1:long $arg2:long
process("/usr/bin/php-cgi").provider("php").mark("function__entry") $arg1:long $arg2:long $arg3:long $arg4:long $arg5:long
process("/usr/bin/php-cgi").provider("php").mark("function__return") $arg1:long $arg2:long $arg3:long $arg4:long $arg5:long
process("/usr/bin/php-cgi").provider("php").mark("request__shutdown") $arg1:long $arg2:long $arg3:long
process("/usr/bin/php-cgi").provider("php").mark("request__startup") $arg1:long $arg2:long $arg3:long

Using PHP User-Space Markers

To use the SystemTap user-space markers on a Fedora you will need:

Examples Scripts for PHP Probing

Short example scripts:

References