Hello,
I was able to compile [1] and and run PHP Dtrace provider on
FreeBSD-STABLE. Everything works as expected and looks very cool. It
works both from Apache (mod_php) and cli. If there are port commiters
with dtrace experience - please, take it.
Below there is a small demo:
This is a test script:
<?php
/* useless dtrace demo script */
$file = file_get_contents("test.php"); /* classless func. */
$demo = new demoClass(); /* call constructor */
$demo->PrintTest();
class demoClass{
function demoClass(){
@chdir("/notexists");
}
function PrintTest(){
echo "TEST\n";
}
}
?>
This is the most basic output to demonstrate how provider works:
# dtrace -n 'php*::: /arg0/
{printf("\t\t%s%s%s",copyinstr(arg3),copyinstr(arg4),copyinstr(arg0))}'
dtrace: description 'php*::: ' matched 24 probes
dtrace: buffer size lowered to 2m
CPU ID FUNCTION:NAME
2 44455 php_dtrace_execute_internal:function-entry
file_get_contents
2 44457 php_dtrace_execute_internal:function-return
file_get_contents
2 44456 php_dtrace_execute:function-entry
demoClass::demoClass
2 44455 php_dtrace_execute_internal:function-entry chdir
2 44457 php_dtrace_execute_internal:function-return chdir
2 44458 php_dtrace_execute:function-return
demoClass::demoClass
2 44456 php_dtrace_execute:function-entry
demoClass::PrintTest
2 44458 php_dtrace_execute:function-return
demoClass::PrintTest
As you could see there is information about all functions (and
classnames) in our test.
Also there is a possibility to trace syscalls used by PHP function. This
is output from ./php_syscolors.d (with minor modifications):
for the file_get_contents (reads file to variable):
1 16019/100898 6 test.php:4 func ->
file_get_contents
1 16019/100898 18 ":- syscall -> __getcwd
1 16019/100898 8 ":- syscall <- __getcwd
1 16019/100898 8 ":- syscall ->
clock_gettime
1 16019/100898 4 ":- syscall <- clock_gettime
1 16019/100898 5 ":- syscall -> open
1 16019/100898 9 ":- syscall <- open
1 16019/100898 5 ":- syscall -> fstat
1 16019/100898 5 ":- syscall <- fstat
1 16019/100898 4 ":- syscall -> lseek
1 16019/100898 4 ":- syscall <- lseek
1 16019/100898 5 ":- syscall -> fstat
1 16019/100898 4 ":- syscall <- fstat
1 16019/100898 4 ":- syscall -> read
1 16019/100898 6 ":- syscall <- read
1 16019/100898 9 ":- syscall -> read
1 16019/100898 5 ":- syscall <- read
1 16019/100898 4 ":- syscall -> read
1 16019/100898 4 ":- syscall <- read
1 16019/100898 5 ":- syscall -> close
1 16019/100898 10 ":- syscall <- close
1 16019/100898 8 test.php:4 func <- file_get_contents
Of course it is possible to use aggregations, filtering and all other
dtrace features.
Problems: I found that buffer size in dtrace is always about 2m. I am
using a lot of events while trying to debug running web server.
Todo: latest PHP alpha releases include dtrace support internally (and
it is extended, compared to this pecl extension). Currently build
failing on BSD and i had no time to investigate problem source (i think
they are using some ugly linker hacks). It would be great to get it
fixed before PHP release to have it in FreeBSD out of the box.
[1] http://www.freebsd.org/cgi/query-pr.cgi?pr=158983
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"