Using SystemTap with PHP DTrace Static Probes

On some Linux distributions, the SystemTap tracing utility can beused to trace PHP's static DTrace probes. This is available withPHP 5.4.20 and PHP 5.5. 

Installing PHP with SystemTap

Install the SystemTap SDT development package: 

# yum install systemtap-sdt-devel

Install PHP with the DTrace probes enabled: 

# ./configure --enable-dtrace ...

# make

Listing Static Probes with SystemTap

The static probes in PHP can be listed using stap: 

# stap -l 'process.provider("php").mark("*")' -c 'sapi/cli/php -i'

This outputs: 

process("sapi/cli/php").provider("php").mark("compile__file__entry")

process("sapi/cli/php").provider("php").mark("compile__file__return")

process("sapi/cli/php").provider("php").mark("error")

process("sapi/cli/php").provider("php").mark("exception__caught")

process("sapi/cli/php").provider("php").mark("exception__thrown")

process("sapi/cli/php").provider("php").mark("execute__entry")

process("sapi/cli/php").provider("php").mark("execute__return")

process("sapi/cli/php").provider("php").mark("function__entry")

process("sapi/cli/php").provider("php").mark("function__return")

process("sapi/cli/php").provider("php").mark("request__shutdown")

process("sapi/cli/php").provider("php").mark("request__startup")

SystemTap with PHP Example

Example #1 all_probes.stp for tracing all PHP Static Probes with SystemTap

probe process("sapi/cli/php").provider("php").mark("compile__file__entry") {

    printf("Probe compile__file__entry\n");

    printf("  compile_file %s\n", user_string($arg1));

    printf("  compile_file_translated %s\n", user_string($arg2));

}

probe process("sapi/cli/php").provider("php").mark("compile__file__return") {

    printf("Probe compile__file__return\n");

    printf("  compile_file %s\n", user_string($arg1));

    printf("  compile_file_translated %s\n", user_string($arg2));

}

probe process("sapi/cli/php").provider("php").mark("error") {

    printf("Probe error\n");

    printf("  errormsg %s\n", user_string($arg1));

    printf("  request_file %s\n", user_string($arg2));

    printf("  lineno %d\n", $arg3);

}

probe process("sapi/cli/php").provider("php").mark("exception__caught") {

    printf("Probe exception__caught\n");

    printf("  classname %s\n", user_string($arg1));

}

probe process("sapi/cli/php").provider("php").mark("exception__thrown") {

    printf("Probe exception__thrown\n");

    printf("  classname %s\n", user_string($arg1));

}

probe process("sapi/cli/php").provider("php").mark("execute__entry") {

    printf("Probe execute__entry\n");

    printf("  request_file %s\n", user_string($arg1));

    printf("  lineno %d\n", $arg2);

}

probe process("sapi/cli/php").provider("php").mark("execute__return") {

    printf("Probe execute__return\n");

    printf("  request_file %s\n", user_string($arg1));

    printf("  lineno %d\n", $arg2);

}

probe process("sapi/cli/php").provider("php").mark("function__entry") {

    printf("Probe function__entry\n");

    printf("  function_name %s\n", user_string($arg1));

    printf("  request_file %s\n", user_string($arg2));

    printf("  lineno %d\n", $arg3);

    printf("  classname %s\n", user_string($arg4));

    printf("  scope %s\n", user_string($arg5));

}

probe process("sapi/cli/php").provider("php").mark("function__return") {

    printf("Probe function__return: %s\n", user_string($arg1));

    printf(" function_name %s\n", user_string($arg1));

    printf("  request_file %s\n", user_string($arg2));

    printf("  lineno %d\n", $arg3);

    printf("  classname %s\n", user_string($arg4));

    printf("  scope %s\n", user_string($arg5));

}

probe process("sapi/cli/php").provider("php").mark("request__shutdown") {

    printf("Probe request__shutdown\n");

    printf("  file %s\n", user_string($arg1));

    printf("  request_uri %s\n", user_string($arg2));

    printf("  request_method %s\n", user_string($arg3));

}

probe process("sapi/cli/php").provider("php").mark("request__startup") {

    printf("Probe request__startup\n");

    printf("  file %s\n", user_string($arg1));

    printf("  request_uri %s\n", user_string($arg2));

    printf("  request_method %s\n", user_string($arg3));

}

The above script will trace all core PHP static probe pointsthroughout the duration of a running PHP script: 

# stap -c 'sapi/cli/php test.php' all_probes.stp

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

热门产品

php编程基础教程.pptx|php编程培训,php,编程,基础,教程,pptx
php编程基础教程.pptx

历史上的今天:04月20日

ThinkPHP5快速入门基础

ThinkPHP5快速入门基础一、基础快速入门 ( 一 ) :基础本章介绍了 ThinkPHP5 .0 的安装及基本使用 ,并给出了一个最简单的示例带你了解如何开始开发 ,主要包 含 :简介官网下载 omposer安装和更新CGit下载和更新目录结构运行环境入口文件调试模式控制器视图读取数据总结在学习 ThinkPHP5.0 之前 ,如果你还不理解面向对象和命名空间的概念 ,建议首先去PHP手册恶

ThinkPHP5快速入门

ThinkPHP5快速入门目 录零、序言一、基础二、URL和路由三、请求和响应四、数据库五、查询语言六、模型和关联 (1)模型定义 (2)基础操作 (3)读取器和修改器 (4)类型转换和自动完成 (5)查询范围 (6)输入和验证 (7)关联 (8)模型输出七、视图和模板八、调试和日志九、API开发十、命令行工具十一、扩展十二、杂项SessionCookie验证

热门专题

昆明网站建设|昆明网站建设,昆明网站开发,昆明网站建设公司,昆明网站建设价格,昆明网站设计,昆明网站制作,网页设计,高端网站建设,高端网站设计
昆明网站建设
一年制中专|中专学历,中专是什么学历,中专是什么,中专有什么专业,中专升大专,一年制中专
一年制中专
金诺幼儿园(春城路金诺幼儿园)|昆明官渡区幼儿园,幼儿园报名,官渡区幼儿园,春城路幼儿园,幼儿园招生,学前班,昆明幼儿园,金诺幼儿园,环城南路幼儿园,石井路幼儿园
金诺幼儿园(春城路金诺幼儿园)
昆明综合高中|昆明综合高中
昆明综合高中
综合高中|云南综合高中,昆明综合高中,综合高中能考本一吗,综合高中和普通高中的区别,综合高中是什么意思,综合高中能参加全国统一高考吗,综合高中可以考哪些大学,综合高中的学籍是什么
综合高中
云南高职单招|云南单招,云南单招网,云南高职单招网,云南高职单招,云南单招学校,云南单招培训
云南高职单招
云南巨榕教育投资集团有限公司|云南巨榕教育投资集团有限公司,巨榕教育集团,巨榕教育
云南巨榕教育投资集团有限公司
大理科技管理学校|大理科技管理中等职业技术学校,大理市科技管理中等职业技术学校
大理科技管理学校

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部