ubuntu13.04安装使用systemtap
添加包含dbgsym版本包的源:
为12.04添加apt-get源:
deb http://ddebs.ubuntu.com/ precise main restricted universe multiverse
deb http://ddebs.ubuntu.com/ precise-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ precise-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com/ precise-proposed main restricted universe multiverse
为12.10添加apt-get源:
deb http://ddebs.ubuntu.com/ quantal main restricted universe multiverse
deb http://ddebs.ubuntu.com/ quantal-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ quantal-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com/ quantal-proposed main restricted universe multiverse
为13.04添加apt-get源:
sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ raring main restricted universe multiverse
deb http://ddebs.ubuntu.com/ raring-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ raring-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com/ raring-proposed main restricted universe multiverse
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01
sudo apt-get update
安装内核
sudo apt-get install linux-image-$(uname -r)-dbgsym
安装systemtap
sudo apt-get install systemtap
使用
-
准备一个简单的c程序:
void hello(int r) { int haha = 100; printf("kljasldjfksajdkfjds\n"); } int main(int argc,void* argv) { while(1){ hello(23423423); sleep(1); } exit(0); }
-
带debug 编译:
gcc -g hello.c
-
运行:
stap -e 'probe process("a.out").function("*") { printf("%s(%d) %s(%s)\n", execname(), pid(),ppfunc(), $$parms$$) }' -c '/home/liangwei/a.out'
-
结果:
kljasldjfksajdkfjds a.out(23959) main(argc=0x0 argv=0x7fff5b4ed450) a.out(23959) hello(r=0x0) kljasldjfksajdkfjds a.out(23959) hello(r=0x0) kljasldjfksajdkfjds a.out(23959) hello(r=0x16569bf) kljasldjfksajdkfjds a.out(23959) hello(r=0x16569bf) kljasldjfksajdkfjds a.out(23959) hello(r=0x16569bf) kljasldjfksajdkfjds a.out(23959) hello(r=0x16569bf) kljasldjfksajdkfjds a.out(23959) hello(r=0x16569bf) kljasldjfksajdkfjds a.out(23959) hello(r=0x16569bf)