2015-06-24 76 views
1

我正在尝试使用systemtap在内核中调试一些代码。我需要在该函数中打印局部变量的值,但它看起来像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个变量,其是函数参数,但没有看到局部变量。

[email protected]: /mnt/linux-3.13.0 # stap -L 
'kernel.function("tcp_write_xmit")' 
kernel.function("[email protected]/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 

这里是我运行

[email protected]: /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 

[email protected]: /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 

任何想法内核和SystemTap的版本?

+0

你读过这个https://sourceware.org/systemtap/wiki/TipContextVariables了吗? – Tsyvarev

回答

3

您正在使用函数探针。在此探针中,只有传递给函数的参数才可见。如果您需要检查本地变量,则需要使用。语句探针。

More info about probing

+0

我用**。语句**试过,而且这也不起作用,所以只给我函数参数。 – syed

+0

你尝试在不同的行添加探针吗?并且正在调试信息可用?如果不是,则需要检查** DWARF-less探测** –

0

尝试stap -L 'kernel.statement("[email protected]*:*")'看什么语句和变量在每一个仍然处在你的debuginfo软。确保你的内核不会将gcc与像KCFLAGS += -fno-var-tracking-assignments这样的有害内容绑定在一起。