关于systemtap 生成Flame Graphs的疑问

1,040 views
Skip to first unread message

fuyou001

unread,
Nov 8, 2014, 8:00:49 AM11/8/14
to open...@googlegroups.com

大家好

看了Brendan D. Gregg CPU Flame Graphs 的文章。有一个问题是用systemtap 要产生怎么样格式的数据,才能用 https://github.com/brendangregg/FlameGraph 此工具生成Flame Graphs图?

参照agentzh sample-bt 代码写了一个简单例子

global bts;
global quit = 0;
probe timer.profile {
    if (1) {
        if (!quit) {
            bts[ubacktrace()] <<< 1;
        } else {
            foreach (bt in bts- limit 10) {
                print_ustack(bt);
                printf("%d", @count(bts[bt]));
            }
            exit()
        }
    }
}
probe timer.s(10) {
    nstacks = 0
    foreach (bt in bts limit 1) {
        nstacks++
    }
    if (nstacks == 0) {
        warn("No backtraces found. Quitting now...\\n")
        exit()
    } else {
        warn("Time's up. Quitting now...(it may take a while)\\n")
        quit = 1
    }
}

去掉警告信息
ARNING: Missing unwind data for module, rerun with 'stap -d /lib64/libc-2.5.so'
WARNING: Missing unwind data for module, rerun with 'stap -d /bin/dd'
WARNING: too many pending (warning) messages
WARNING: Missing unwind data for module, rerun with 'stap -d /bin/bash'
WARNING: Missing unwind data for module, rerun with 'stap -d /lib64/ld-2.5.so'
WARNING: Missing unwind data for module, rerun with 'stap -d /lib64/libpthread-2.5.so'
WARNING: Missing unwind data for module, rerun with 'stap -d /lib64/libcrypto.so.0.9.8e'
WARNING: Time's up. Quitting now...(it may take a while)\n
执行的结果如下保存到文件a.bt

4153 0x3c5eec6050
318 0x3c5eec67d0
211 0x3c5eec6750
48 0x3c5eecd722
6 0x3c60a044eb
3 0x3c5eed48ac
3 0x7fae009b67a9
3 0x3c5f60e38f
3 0x402722

生成图

[@FlameGraph]$ ./stackcollapse-stap.pl a.bt > a.cbt
[@FlameGraph]$ ./flamegraph.pl a.cbt > a.svg
ERROR: No stack counts found

要怎么样才生成Flame Graphs图?

Yichun Zhang (agentzh)

unread,
Nov 10, 2014, 2:58:14 PM11/10/14
to openresty
Hello!

2014-11-08 5:00 GMT-08:00 fuyou001:
> 参照agentzh sample-bt 代码写了一个简单例子
>

为什么不直接使用 sample-bt 工具?

> 执行的结果如下保存到文件a.bt
>
> 4153 0x3c5eec6050
> 318 0x3c5eec67d0
> 211 0x3c5eec6750
> 48 0x3c5eecd722
> 6 0x3c60a044eb
> 3 0x3c5eed48ac
> 3 0x7fae009b67a9
> 3 0x3c5f60e38f
> 3 0x402722
>

显然你这些调用栈都缺少 DWARF 调试信息。

Regards,
-agentzh

fuyou001

unread,
Nov 10, 2014, 10:00:16 PM11/10/14
to open...@googlegroups.com
多谢!我主要是为了学习!
看了文档,发现了少了下面二步。
sudo apt-get install linux-image-debug-generic

sudo ln -s /boot/vmlinux-debug-$(uname -r) /lib/modules/$(uname -r)/vmlinux
Reply all
Reply to author
Forward
0 new messages