summaryrefslogtreecommitdiffstats
path: root/testsuite/semok/eleven.stp
blob: e5e3c01c4f009af4dd339ff1c118384781a36422 (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
39
40
41
42
#! 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 }

global tid

probe begin /* kernel.function("read") */ {
      count=0 timestamp=0 fd=0
      tid=1

      entry_time[tid] = timestamp # "macro" variable
      my_count[tid] = count # function argument
      my_fd[tid] = fd # function argument
      trace ("my_count = " . string(my_count[tid]) .
             "my_fd = " . string(my_fd[tid]))
}

probe end /* kernel.function("read").return */ {
      syscall_name="" retvalue=0
      tid=1

      if (entry_time[tid]) {
         read_times[syscall_name]    # variable from provider alias
            += timestamp - entry_time[tid]
      }
      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]))
      }
}