男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

使用 PHP 和 DTrace

在支持 DTrace 動(dòng)態(tài)跟蹤的平臺上,可以配置 PHP 打開(kāi) DTrace 靜態(tài)探針。

PHP DTrace 靜態(tài)探針配置

請參考操作系統文檔獲取啟用操作系統 DTrace 支持的信息。 例如,在 Oracle Linux 系統上啟動(dòng) UEK3 內核,并進(jìn)行如下操作:

# modprobe fasttrap
# chmod 666 /dev/dtrace/helper

除了 chmod 命令,您也可以使用 ACL 包規則來(lái)限制特定用戶(hù)對于設備的訪(fǎng)問(wèn)權限。

使用 --enable-dtrace 配置參數構建 PHP:

# ./configure --enable-dtrace ...
# make
# make install

這樣就啟用了 PHP 核心的靜態(tài)探針。對于提供了自有探針的 PHP 擴展需要分別構建。

PHP 核心的 DTrace 靜態(tài)探針

PHP 中包括以下可用的靜態(tài)探針
探針名稱(chēng) 探針描述 探針參數
request-startup 請求開(kāi)始時(shí)觸發(fā)。 char *file, char *request_uri, char *request_method
request-shutdown 請求關(guān)閉時(shí)觸發(fā)。 char *file, char *request_uri, char *request_method
compile-file-entry 腳本開(kāi)始編譯時(shí)觸發(fā)。 char *compile_file, char *compile_file_translated
compile-file-return 腳本完成編譯時(shí)觸發(fā)。 char *compile_file, char *compile_file_translated
execute-entry 操作數數組開(kāi)始執行時(shí)觸發(fā)。例如:函數調用,文件包含以及生成器恢復時(shí)會(huì )被觸發(fā)。 char *request_file, int lineno
execute-return 操作數數組執行完畢之后觸發(fā)。 char *request_file, int lineno
function-entry PHP 引擎進(jìn)入 PHP 函數或者方法調用時(shí)觸發(fā)。 char *function_name, char *request_file, int lineno, char *classname, char *scope
function-return PHP 引擎從 PHP 函數或者方法調用返回后觸發(fā)。. char *function_name, char *request_file, int lineno, char *classname, char *scope
exception-thrown 有異常拋出時(shí)觸發(fā)。 char *classname
exception-caught 有異常被捕獲時(shí)觸發(fā)。 char *classname
error 無(wú)論 error_reporting 的設定如何,在發(fā)生錯誤時(shí)都會(huì )觸發(fā)。 char *errormsg, char *request_file, int lineno

PHP 擴展可以擁有額外的靜態(tài)探針。

列出 PHP 中可用的靜態(tài)探針

要列出 PHP 中可用的靜態(tài)探針,開(kāi)啟一個(gè) PHP 進(jìn)程,然后運行:

# dtrace -l

輸出信息類(lèi)似如下所示:

   ID   PROVIDER            MODULE                          FUNCTION NAME
   [ . . . ]
    4   php15271               php               dtrace_compile_file compile-file-entry
    5   php15271               php               dtrace_compile_file compile-file-return
    6   php15271               php                        zend_error error
    7   php15271               php  ZEND_CATCH_SPEC_CONST_CV_HANDLER exception-caught
    8   php15271               php     zend_throw_exception_internal exception-thrown
    9   php15271               php                 dtrace_execute_ex execute-entry
   10   php15271               php           dtrace_execute_internal execute-entry
   11   php15271               php                 dtrace_execute_ex execute-return
   12   php15271               php           dtrace_execute_internal execute-return
   13   php15271               php                 dtrace_execute_ex function-entry
   14   php15271               php                 dtrace_execute_ex function-return
   15   php15271               php              php_request_shutdown request-shutdown
   16   php15271               php               php_request_startup request-startup

Provider 一列由 php 和當前進(jìn)程 id 的組成。

如果運行的是 Apache web 服務(wù)器,那么模塊名稱(chēng)可能是 libphp5.so, 并且可能會(huì )出現多塊信息,每個(gè)運行中的 Apache 進(jìn)程對應一個(gè)輸出塊。

Function Name 一列表示 Provider 對應的 PHP 內部 C 實(shí)現函數名稱(chēng)。

如果沒(méi)有運行任何 PHP 進(jìn)程,那么就不會(huì )顯示任何 PHP 探針。

PHP DTrace 示例

下例展示了基本的 DTrace D 腳本。

示例 #1 all_probes.d for tracing all PHP Static Probes with DTrace

#!/usr/sbin/dtrace -Zs

#pragma D option quiet

php*:::compile-file-entry
{
    printf("PHP compile-file-entry\n");
    printf("  compile_file              %s\n", copyinstr(arg0));
    printf("  compile_file_translated   %s\n", copyinstr(arg1));
}

php*:::compile-file-return
{
    printf("PHP compile-file-return\n");
    printf("  compile_file              %s\n", copyinstr(arg0));
    printf("  compile_file_translated   %s\n", copyinstr(arg1));
}

php*:::error
{
    printf("PHP error\n");
    printf("  errormsg                  %s\n", copyinstr(arg0));
    printf("  request_file              %s\n", copyinstr(arg1));
    printf("  lineno                    %d\n", (int)arg2);
}

php*:::exception-caught
{
    printf("PHP exception-caught\n");
    printf("  classname                 %s\n", copyinstr(arg0));
}

php*:::exception-thrown
{
    printf("PHP exception-thrown\n");
    printf("  classname                 %s\n", copyinstr(arg0));
}

php*:::execute-entry
{
    printf("PHP execute-entry\n");
    printf("  request_file              %s\n", copyinstr(arg0));
    printf("  lineno                    %d\n", (int)arg1);
}

php*:::execute-return
{
    printf("PHP execute-return\n");
    printf("  request_file              %s\n", copyinstr(arg0));
    printf("  lineno                    %d\n", (int)arg1);
}

php*:::function-entry
{
    printf("PHP function-entry\n");
    printf("  function_name             %s\n", copyinstr(arg0));
    printf("  request_file              %s\n", copyinstr(arg1));
    printf("  lineno                    %d\n", (int)arg2);
    printf("  classname                 %s\n", copyinstr(arg3));
    printf("  scope                     %s\n", copyinstr(arg4));
}

php*:::function-return
{
    printf("PHP function-return\n");
    printf("  function_name             %s\n", copyinstr(arg0));
    printf("  request_file              %s\n", copyinstr(arg1));
    printf("  lineno                    %d\n", (int)arg2);
    printf("  classname                 %s\n", copyinstr(arg3));
    printf("  scope                     %s\n", copyinstr(arg4));
}

php*:::request-shutdown
{
    printf("PHP request-shutdown\n");
    printf("  file                      %s\n", copyinstr(arg0));
    printf("  request_uri               %s\n", copyinstr(arg1));
    printf("  request_method            %s\n", copyinstr(arg2));
}

php*:::request-startup
{
    printf("PHP request-startup\n");
    printf("  file                      %s\n", copyinstr(arg0));
    printf("  request_uri               %s\n", copyinstr(arg1));
    printf("  request_method            %s\n", copyinstr(arg2));
}

此腳本在 dtrace 命令中使用了 -Z 選項。 此選項保證即使在沒(méi)有任何 PHP 進(jìn)程運行的時(shí)候腳本也能夠正確執行。 如果省略了此選項,當沒(méi)有任何探針可監控的時(shí)候,腳本會(huì )立即終止執行。

在運行此腳本的過(guò)程中,它將監控全部 PHP 核心靜態(tài)探針。 運行 D 腳本:

# ./all_probes.d

再運行一個(gè) PHP 腳本或者 PHP 應用,用來(lái)進(jìn)行監控的 D 腳本會(huì )輸出每個(gè)探針被觸發(fā)時(shí)所攜帶的參數。

監控完成之后,使用 ^C 來(lái)終止 D 腳本的執行。

在多 CPU 的主機上,探針的顯示順序可能不是連續的,這取決于哪顆 CPU 執行探針以及多個(gè) CPU 之間的線(xiàn)程遷移情況。 可以通過(guò)顯示探針時(shí)間戳來(lái)減少混淆,例如:

php*:::function-entry
{
      printf("%lld: PHP function-entry ", walltimestamp);
      [ . . .]
}

男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站