SystemTap
sudo apt-get install build-essential
sudo apt-get install elfutils
sudo apt-get install libdw-dev
wget wget https://sourceware.org/systemtap/ftp/releases/systemtap-2.4.tar.gz
tar -xzvf systemtap-2.4.tar.gz
cd systemtap-2.4
./configure
sudo make
sudo make install
測試語句
sudo stap --all-modules -ve ‘probe begin { log("hello world") exit () }‘
sudo stap -ve ‘probe begin { log("hello world") exit () }‘
sudo stap -ve ‘probe kernel.function("sys_open") {log("hello world") exit()}‘
sudo stap -ve ‘probe module("libiscsi").function("iscsi_queuecommand") {log("hello world") exit()}‘
打印堆棧
print_backtrace
在Ubuntu上使用SystemTap
http://www.ningoo.net/html/2010/use_systemtap_on_ubuntu.html
ubuntu+systemtap進行Linux內核和用戶空間開發測試
http://blog.csdn.net/sailor_8318/article/details/25076745
SystemTap在Ubuntu 12.04上的安裝 Build-id mismatch
http://www.it165.net/os/html/201310/6486.html
使用systemtap調試linux內核
http://blog.csdn.net/heli007/article/details/7187748
利用systemtap定位ifconfig dropped數據包的原因
http://www.it165.net/os/html/201308/5944.html
範例
https://sourceware.org/systemtap/wiki
System語言具體解釋
http://blog.csdn.net/linyt/article/details/5204841
#! /usr/bin/env stap global host_no = 17 global channel = 0 global targetid = 0 global lunid = 15 # 推斷io是否下發到iscsi probe module("libiscsi").function("iscsi_queuecommand") { if ( $host!=0 && $sc!=0 ) { if ( $host->host_no==host_no && $sc->device->channel==channel && $sc->device->id==targetid && $sc->device->lun==lunid ) { printf("====================send scsi=======================\n") printf("tag = %d\n", $sc->tag) printf("serial_number = %lu\n", $sc->serial_number) printf("jiffies_at_alloc = %lu\n", $sc->jiffies_at_alloc) print_backtrace() printf("\n") } } } probe kernel.function("do_sync_read") { if ($filp!=0) { if ($filp->f_inode!=0) { if ($filp->f_inode->i_ino == 3978543828) { printf("===========================================do_sync_read\n\n") } } } } # 推斷IO在iscsi被正確下發 probe module("libiscsi").statement("[email protected]
SystemTap