File: probefunc.exp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (65 lines) | stat: -rw-r--r-- 2,002 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Test cases for probefunc() function

proc grep {fd re } {
   while {[gets $fd s] >= 0} {
      if [regexp $re $s] {
         return $s
      }
   }
}

proc sleep_one_sec {} {
    wait_n_secs 1;
    return 0;
}

set systemtap_script {
    global funcname 
    probe %s {
        funcname = probefunc()
        exit()
    }
    probe begin {
        log("systemtap starting probe")
    }
    probe end {
        log("systemtap ending probe")
        printf("%%s\n", funcname)
    }
}

# open /proc/kallsyms to get address for scheduler_tick symbol 
set symf "/proc/kallsyms"
set symfd [open $symf r]
set re "\\mscheduler_tick\\M"
set rs [grep $symfd $re]
set flds [split $rs " "]
set addr [lindex $flds 0]
close $symfd

set prefix "probefunc:"

# test probefunc() with kernel.statement().absolute
set output_string "\\mscheduler_tick\\M\r\n"
set probepoint "kernel.statement(0x$addr).absolute"
set script [format $systemtap_script $probepoint]
stap_run "${prefix}.statement.(0xaddr).absolute" sleep_one_sec $output_string -g -e $script

# test probefunc() with kernel.function()
set probepoint "kernel.function(\"scheduler_tick\")"
set script [format $systemtap_script $probepoint]
stap_run $prefix$probepoint sleep_one_sec $output_string -e $script

# test probefunc() with kernel.function().inline
# NOTE probefunc inline behavior changed after 1.8.
#
# Notice we're keeping the name of the test the same
# 'probefunc:kernel.function("context_switch").inline', but broadening
# the test a bit to also include 'kernel.function("should_resched")'
# for newer kernels. Keeping the name the same helps in comparing
# results between releases.
set output_string "\\m(context_switch|should_resched)\\M\r\n"
set testname "kernel.function(\"context_switch\").inline"
set probepoint "kernel.function(\"context_switch\").inline ?, kernel.function(\"should_resched\").inline ?"
set script [format $systemtap_script $probepoint]
stap_run $prefix$testname sleep_one_sec $output_string -e $script --compatible=1.8