Thursday, December 30, 2010

Flow diagram of systemtap debugging scripting tool


■ Requirement : Flow diagram of systemtap debugging scripting tool
■ OS Environment : Linux[RHEL, Centos]
■ Application: systemtap
■ Implementation Steps : 

Systemtap: Scripting tool to debug and monitor the whole system processes or any events.

Installation step : 

yum install kernel-devel
yum install kernel-debuginfo
yum install systemtap















Usage Syntax :

-------------
probe {handler}

Where event is kernel.function, process.statement, timer.ms, begin, end etc

and handler can be filtering/control statement and
helper function : log, printf, pid etc
-------------


Example :

$cat hellworld.stp
probe begin
{
print("This is hello world\n")
exit()
}


Execution of above script :

$ stap hellworld.stp 
This is hello world
$ cat primecheck.stp
function isprime (x) {
if (x < 2) return 0
for (i = 2; i < x; i++) {
if (x % i == 0) return 0
if (i * i > x) break
}
return 1
}

probe begin {
for (i = 0; i < 50; i++)
if (isprime (i)) printf("%d\n", i)
exit()
}


stap-authorize-signing-cert stap-report
$ stap primecheck.stp
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47




No comments:

Post a Comment