我正在尝试使用perf打印特定函数中的变量的值。因此,我尝试使用-V选项进行perf探测,但得到的错误消息如下。
# perf probe -V tcp_sendmsg
Failed to find the path for the kernel: Invalid ELF file
Error: Failed to show vars.因此,我下载了内核符号和源包,并检查了/boot/config-5.3.0-46-generic中的值CONFIG_DEBUG_INFO是否设置为1,但仍然出现相同的错误。
我应该如何解决这个问题?
Ubuntu 18.04 LTS版本:5.3.0-46-通用版本: 38~18.04.01
发布于 2020-05-03 13:12:07
要使perf probe -V工作,您必须传递一个包含debuginfo的vmlinux文件,根据您的注释,您似乎已经这样做了-
sudo perf probe --vmlinux /usr/lib/debug/boot/vmlinux-4.15.0-1077-azure
-V tcp_sendmsg
Available variables at tcp_sendmsg
@<tcp_sendmsg+0>
size_t size
struct msghdr* msg
struct sock* sk现在根据手册页,perf probe -L意味着
-L, --line=
Show source code lines which can be probed.
This needs an argument which specifies a range of the source code.
(see LINE SYNTAX for detail) 这意味着当您运行perf probe -L时,您需要指定内核源代码的位置,否则使用debuginfo分析vmlinux文件的elfutils工具将无法确定内核源代码的正确路径。
您可以按照前面提到的here下载内核源代码
然后在指定--source开关的地方运行perf probe,
sudo perf probe --source /usr/src/linux-source-4.4.0 --vmlinux /usr/lib/debug/boot/vmlinux-4.15.0-1077-azure -L tcp_sendmsg
<tcp_sendmsg@/usr/src/linux-source-4.4.0//net/ipv4/tcp.c:0>
0 /* Clear memory counter. */
1 tp->ucopy.memory = 0;
}
4 static struct sk_buff *tcp_recv_skb(struct sock *sk, u32 seq, u32 *off)
5 {
6 struct sk_buff *skb;
u32 offset;
9 while ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) {
offset = seq - TCP_SKB_CB(skb)->seq;
if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)
offset--;https://stackoverflow.com/questions/61495388
复制相似问题