| 1 |
# Test cases for probefunc() function |
| 2 |
|
| 3 |
proc grep {fd re } { |
| 4 |
while {[gets $fd s] >= 0} { |
| 5 |
if [regexp $re $s] { |
| 6 |
return $s |
| 7 |
} |
| 8 |
} |
| 9 |
} |
| 10 |
|
| 11 |
proc sleep_one_sec {} { |
| 12 |
wait_n_secs 1; |
| 13 |
return 0; |
| 14 |
} |
| 15 |
|
| 16 |
set systemtap_script { |
| 17 |
global funcname |
| 18 |
probe %s { |
| 19 |
funcname = probefunc() |
| 20 |
exit() |
| 21 |
} |
| 22 |
probe begin { |
| 23 |
log("systemtap starting probe") |
| 24 |
} |
| 25 |
probe end { |
| 26 |
log("systemtap ending probe") |
| 27 |
printf("%%s\n", funcname) |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
# open /proc/kallsyms to get address for scheduler_tick symbol |
| 32 |
set symf "/proc/kallsyms" |
| 33 |
set symfd [open $symf r] |
| 34 |
set re "\\mscheduler_tick\\M" |
| 35 |
set rs [grep $symfd $re] |
| 36 |
set flds [split $rs " "] |
| 37 |
set addr [lindex $flds 0] |
| 38 |
close $symfd |
| 39 |
|
| 40 |
set prefix "probefunc:" |
| 41 |
|
| 42 |
# test probefunc() with kernel.statement().absolute |
| 43 |
set output_string "\\mscheduler_tick\\M\r\n" |
| 44 |
set probepoint "kernel.statement(0x$addr).absolute" |
| 45 |
set script [format $systemtap_script $probepoint] |
| 46 |
stap_run "${prefix}.statement.(0xaddr).absolute" sleep_one_sec $output_string -g -e $script |
| 47 |
|
| 48 |
# test probefunc() with kernel.function() |
| 49 |
set probepoint "kernel.function(\"scheduler_tick\")" |
| 50 |
set script [format $systemtap_script $probepoint] |
| 51 |
stap_run $prefix$probepoint sleep_one_sec $output_string -e $script |
| 52 |
|
| 53 |
# test probefunc() with kernel.function().inline |
| 54 |
# NOTE probefunc inline behavior changed after 1.8. |
| 55 |
# |
| 56 |
# Notice we're keeping the name of the test the same |
| 57 |
# 'probefunc:kernel.function("context_switch").inline', but broadening |
| 58 |
# the test a bit to also include 'kernel.function("should_resched")' |
| 59 |
# for newer kernels. Keeping the name the same helps in comparing |
| 60 |
# results between releases. |
| 61 |
set output_string "\\m(context_switch|should_resched)\\M\r\n" |
| 62 |
set testname "kernel.function(\"context_switch\").inline" |
| 63 |
set probepoint "kernel.function(\"context_switch\").inline ?, kernel.function(\"should_resched\").inline ?" |
| 64 |
set script [format $systemtap_script $probepoint] |
| 65 |
stap_run $prefix$testname sleep_one_sec $output_string -e $script --compatible=1.8 |