近来使用stapxx等工具和火焰图调优nginx程序,采用tengine-2.1.0版本和最新的stapxx工具包。
使用过程中,有一些曲折,既有自身系统的原因,又有openresty和tengine不一致的原因,也有一些其他的原因。
我想提出已经遇到的两种情况,一个:
出错信息为:
0> sudo ./samples/ngx-req-latency-distr.sxx -x 30126 -I ./tapset/nginx/
semantic error: not accessible at this address [man error::dwarf] (0x44a53b, dieoffset: 0x13a891): identifier '$r' at <input>:33:29
source: begin = begin_times[$r]
semantic error: not accessible at this address [man error::dwarf] (0x44a53b, dieoffset: 0x13a891): identifier '$r' at :36:32
source: delete begin_times[$r]
以及
130> sudo ./samples/ngx-rps.sxx -x 7005
semantic error: not accessible at this address [man error::dwarf] (0x44a53b, dieoffset: 0x13a891): identifier '$r' at <input>:10:30
source: if (pid() == target() && $r == $r->main) {
^
Pass 2: analysis failed. [man error::pass2]
均是指$r的问题。group里的https://groups.google.com/forum/#!topic/openresty/pVfoi5iV-2U这个帖子有相同情况,不过在春哥问完gcc版本和nginx构造过程后就没有下文了。
我的tengine编译选项是:
CFLAGS="-g -O2" ./configure --with-http_lua_module --with-luajit-lib=/usr/local/lib/ --with-luajit-inc=/usr/local/include/luajit-2.0/ --with-ld-opt=-Wl,-rpath,/usr/local/lib
使用rpmbuild生成debuginfo包,采用nginx-systemtap-toolkit的sample-bt都可以生成火焰图,说明debuginfo和dwarf生成正确。
系统版本centos 6.5,内核2.6.32,gcc版本4.4.7。
联想到春哥使用的内核和centos版本,以及经常提到的systemtap最新版等,我觉得我的这个问题在于gcc版本过低的问题。我采用相同的编译选项在centos 7,内核3.10,gcc4.8的机器上,可以正常使用
[huang@localhost stapxx]$ sudo ./samples/ngx-rps.sxx -x 4976
WARNING: Tracing process 4976 (/usr/local/openresty/nginx/sbin/nginx).
同时参考:gcc4.5之前的版本有限制 https://sourceware.org/systemtap/man/error::dwarf.7stap.html
请教春哥和大家,这个问题的错误愿意是gcc版本过老或者相关原因吗?
第二 ,在使用openresty bundle中的软件工具时有一定兼容问题。一个例子:
[huang@localhost stapxx]$ sudo ./samples/ngx-lua-exec-time.sxx -x 23768
semantic error: while resolving probe point: identifier 'process' at <input>:58:7
source: process("/usr/local/nginx/sbin/nginx").function("ngx_http_lua_free_fake_request")
semantic error: no match (similar functions: ngx_http_lua_get_request, ngx_http_create_request, ngx_http_free_request, ngx_http_lua_post_subrequest, ngx_http_scgi_create_request)
Pass 2: analysis failed. [man error::pass2]
在ngx-lua-exec-times.sxx的出错地点为:
probe @pfunc(ngx_http_free_request),
@pfunc(ngx_http_lua_free_fake_request)
elapsed = exec_elapsed[r]
%( "$^arg_max :default()" != "" %?
if (elapsed <= $^arg_max) {
经查原因是,ngx_http_lua_free_fake_request属于ngx-lua模块,而在比较新的tengine版本中,已经将ngx-lua模块作为http模块的一部分了,在路tengine-2.1.0/src/http/modules/lua路径下。并且ngx_http_lua_free_fake_request函数在tengine中的ngx-lua中已经去掉了,所以导致这样的错误,所以在这里报一下,很多stapxx脚本需要我们自己动手来写了。
谢谢大家。