gpt4 book ai didi

linux - Systemtap 不显示内核函数中的所有局部变量

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:51:14 24 4
gpt4 key购买 nike

我正在尝试使用 systemtap 调试内核中的一些代码。我需要在该函数中打印局部变量的值,但看起来 systemtap 只能看到函数参数,而看不到该函数中定义的局部变量。这是我的探测脚本。

probe kernel.function("tcp_write_xmit") {
if( execname() == "bw_client"){
printf(
"tcp_write_xmit skb len %d\n",
$skb
);
}
}

当我运行它时,出现以下错误

semantic error: failed to retrieve location attribute for 'skb'
[man error::dwarf] (dieoffset: 0x5bd30b4): identifier
'$skb' at /home/cca-user/systaptest/txprobe.stp:37:6
source: $skb
^
Pass 2: analysis failed. [man error::pass2]

然而函数tcp_write_xmit显然有skb

使用 -L 选项打印可用变量给我 5 个变量,它们是函数参数,但没有看到任何局部变量。

root@i-sahmed-node2: /mnt/linux-3.13.0 # stap -L
'kernel.function("tcp_write_xmit")'
kernel.function("tcp_write_xmit@/build/buildd/linux-3.13.0/net/ipv4
/tcp_output.c:1832") $sk:struct sock* $mss_now:unsigned int $nonagle:int
$push_one:int $gfp:gfp_t

这是我正在运行的内核和systemtap版本

root@i-sahmed-node2: /mnt/linux-3.13.0 # stap --version
Systemtap translator/driver (version 2.3/0.158, Debian version 2.3-1ubuntu1 (trusty))
Copyright (C) 2005-2013 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
enabled features: AVAHI LIBSQLITE3 NSS TR1_UNORDERED_MAP NLS

root@i-sahmed-node2: /mnt/linux-3.13.0 # uname -a
Linux i-sahmed-node2 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

有什么想法吗?

最佳答案

您正在使用.function 探针。在此探测器中,只有传递给函数的参数是可见的。如果您需要检查局部变量,则需要使用 .statement 探针。

More info about probing

关于linux - Systemtap 不显示内核函数中的所有局部变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31031651/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com