stap用法
1.列出可探测的局部变量 stap -L
如何列出 nginx
调用 libluajit-5.1.so.2
中 lua_pcall
时的所有可用局部变量,需结合进程名和库路径进行精确探测?
[root@localhost xx]# stap -L 'process("/xx/sbin/nginx
").library("/xx
/lib/libluajit-5.1.so.2").function("lua_pcall")'
process("/xx/sbin/nginx
").library("/xx
/lib/libluajit-5.1.so.2").function("lua_pcall@/yy/src/LuaJIT-2.1.0/src/lj_api.c:1114") $L:lua_State* $nargs:int $nresults:int $errfunc:int
[root@localhost sbin]# stap -L 'process("/root/agw/sbin/agw_engine").function("ngx_http_lua_init")'
process("/root/agw/sbin/agw_engine").function("ngx_http_lua_init@./src/luam/src/ngx_http_lua_module.c:629") $cf:ngx_conf_t* $multi_http_blocks:int $rc:ngx_int_t $arr:ngx_array_t* $h:ngx_http_handler_pt* $saved_cycle:ngx_cycle_t volatile* $cmcf:ngx_http_core_main_conf_t* $lmcf:ngx_http_lua_main_conf_t* $cln:ngx_pool_cleanup_t*
[root@localhost ~]# stap -e 'probe process("/root/agw/sbin/agw_engine").function("ngx_http_lua_init") { printf("cf at %p\n", $cf); println($cf$) }'
cf at 0x7ffda8d49f00
{.name=0x0, .args=0x7f805b0ee0e0, .cycle=0x7f805b0ec050, .pool=0x7f805b0ec000, .temp_pool=0x7f805b0f0000, .conf_file=0x7ffda8d49c50, .log=0x9171c0, .ctx=0x7f805b0ee2b0, .module_type=1347703880, .cmd_type=33554432, .handler=0x0, .handler_conf=0x0}
NB!
2.执行探测指令 stap -e
[root@localhost sbin]# stap -e 'probe process("nginx").library("../lib/libluajit-5.1.so.2.0.5").function("lua_pcall") {
printf("L=%p\n", $L)
}'
没有条件到达的时候是没有数据输出的。
L=0x7fa02c90e378
L=0x7fa02c90e378
L=0x7fa02c90e378
L=0x7fa02c90e378
L=0x7fa02c90e378
L=0x7fa02c90e378
L=0x7fa02c90e378
L=0x7fa02c90e378
之前报错:
解决方法:
修改/usr/share/systemtap/runtime/sym.c将buildid相关检验逻辑注释掉。