2015-06-24 22 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這樣的有害內容綁定在一起。

相關問題