- 论坛徽章:
- 0
|
bibliography:
http://www.ibm.com/developerworks/cn/linux/l-systemtap/
man
stap(1)
man
stapprobes(5)
man
stapex(5)
less
/usr/share/doc/systemtap-0.5.13/*
probe
syntax:
probe
PROBEPOINT [, PROBEPOINT] { [STMT ...] }
The
probe handler is interpreted relative to the context of each
event. For events associated with kernel code, this context may
include variables defined in the source code at that spot. These
[color="#ff0000"]"target variables" are
presented to the script as variables whose names are prefixed with
[color="#ff0000"]"$".
[color="#ff0000"]Important:
most
of the local variables are optimized and omitted. So be aware of the
variables exported by “nm ”
probe
point:
begin/end:
begin:
when session starting.
End:
when session ending, i.e. After calling exit().
Never:
never
insert probe point, just check to see if error.
Timers:
timer.jiffies(N)
timer.jiffies(N).randomize(M)
timer.ms(N) //
millisecond
timer.ms(N).randomize(M)
dwarf:
kernel.function(PATTERN)
kernel.function(PATTERN).return
kernel.inline(PATTERN)
module(MPATTERN).function(PATTERN)
module(MPATTERN).function(PATTERN).return
module(MPATTERN).inline(PATTERN)
kernel.statement(PATTERN)
kernel.statement(ADDRESS).absolute
module(MPATTERN).statement(PATTERN)
notation:
MPATTERN:
module pattern (without “.ko”)
PATTERN:
func[@pathname[:line num]]
statement:
a point to relative or absolute address
markers:
unknown
yet.
[color="#ff0000"]STATISTICS:
define
varible as global
use
“
invoke
functions defined by systemtap to fetch statistics, i.e. @count(v),
@sum(v), @min(v), @max(v), @avg(v)
[color="#ff0000"]expressions:
%(
CONDITION %? TRUE_VALUE %: FALSE_VALUE %)
#
eg. Attention $arch
%(
[color="#ff0000"]arch == "ia64" %? probe
syscall.vliw = kernel.function("vliw_widget") {} %)
#
else, we could use kernel_vr or kernel_r to express like “2.6.18”
some
examples:
#!/usr/bin/stap
#
Usage: stap
#
when invoking arguments for filename, @1 is expressed as strings, $2
is expressed as integer
probe
syscall.read
{
printf("fd = %d\n",fd)
printf("strings:
%s\n", @1)
printf("integer:
%d\n", $2)
}
probe
syscall.read.return
{
exit() }
#!/usr/bin/stap
#
To aggregate statistics
global
x
probe
foo
{
x
}
probe
stat
{
printf(“sum
is: %d”, @sum(x))
exit()
}
#!/usr/bin/stap
#
note: we could get parameters to function before calling the function
probe
module("cdrom").function("cdrom_open")
{
printf("before
running\n")
[color="#800000"]
printf("give me local
variable ret: %d\n", $cdi->speed)
}
probe
module("cdrom").statement("cdrom_open@drivers/cdrom/cdrom.c:997")
{
printf("into
func\n")
}
probe
module("cdrom").function("cdrom_open").return
{
printf("after
running\n")
exit()
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/7356/showart_373121.html |
|