使用SystemTap
打印user-space
程序的调用栈信息时,需要产生足够的调试信息。这时需要-d
和--ldd
两个选项:
-d MODULE
Add symbol/unwind information for the given module into the kernel object module. This may enable symbolic tracebacks
from those modules/programs, even if they do not have an explicit probe placed into them.
--ldd Add symbol/unwind information for all shared libraries suspected by ldd to be necessary for user-space binaries being
probe or listed with the -d option. Caution: this can make the probe modules considerably larger.
-d
选项负责加载模块/可执行程序的符号表信息,而-ldd
则加载-d module
中module
或是probe
需要的共享库符号表信息。参考下例:
# stap -d /usr/lib/systemd/systemd-udevd --ldd -e 'probe kprocess.create {print_ubacktrace()}'
<no user backtrace at kernel.function("copy_process@../kernel/fork.c:1146").return>
0x7fec1d14f011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7f6feb135011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
WARNING: Missing unwind data for module, rerun with 'stap -d /usr/lib64/libglib-2.0.so.0.3800.2'
0x7f22c3026011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7f22c2ff7ed4 : __fork+0xb4/0x320 [/lib64/libc-2.19.so]
0x7f22c3a01c35 [/usr/lib64/libglib-2.0.so.0.3800.2+0x8cc35/0x302000]
0x7f20966a5011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7f22c3026011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7f20966a5011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
WARNING: Missing unwind data for module, rerun with 'stap -d /usr/lib/systemd/systemd'
0x7f4e59945ed4 : __fork+0xb4/0x320 [/lib64/libc-2.19.so]
0x4364f3 [/usr/lib/systemd/systemd+0x364f3/0x113000]
0x7f22c2ff7ed4 : __fork+0xb4/0x320 [/lib64/libc-2.19.so]
0x7f22c3a01c35 [/usr/lib64/libglib-2.0.so.0.3800.2+0x8cc35/0x302000]
0x7fb1bdfb6011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7f22c3026011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7fb1bdfb6011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7f3bb6e94011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7f3bb6e94011 : clone+0x31/0x90 [/lib64/libc-2.19.so]
0x7f783f704ed4 : __fork+0xb4/0x320 [/lib64/libc-2.19.so]
0x7f783fd2169b [/usr/lib64/libpython2.7.so.1.0+0x10f69b/0x3a0000]
参考资料:
Is there any better method to pass “-d OBJECT” options in command line?;
User-Space Stack Backtraces。