summaryrefslogtreecommitdiffstats
path: root/testsuite/semok/eleven.stp
blob: f7fc6914932d9639f99c42494fcc636f4092fb37 (plain)
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
#! stap -p2

global entry_time, my_count, my_fd, read_times

# future built-ins
function string (v) { return "" }
function hexstring (v) { return "" }
function trace (s) { return 0 }

probe begin /* kernel.syscall("read") */ {
      $count=0 $timestamp=0 $fd=0

      thread->entry_time = $timestamp # "macro" variable
      thread->my_count = $count # function argument
      thread->my_fd = $fd # function argument
      trace ("my_count = " . string(thread->my_count) .
             "my_fd = " . string(thread->my_fd))
}

probe end /* kernel.syscall("read").return */ {
      $syscall_name="" $retvalue=0

      if (thread->entry_time) {
         read_times[$syscall_name]    # variable from provider alias
            += $timestamp - thread->entry_time
      }
      trace ("syscall " . $syscall_name .
             " return value = " .
             hexstring ($retvalue))  # function pseudo-argument
}

probe end {
      foreach (syscall in read_times) {
          trace ("syscall " . syscall .
                 " total-time=" . string (read_times[syscall]))
      }
}