| 1 |
#! stap -p2 |
| 2 |
|
| 3 |
global entry_time, my_count, my_fd, read_times |
| 4 |
|
| 5 |
# future built-ins |
| 6 |
function trace (s) { return 0 } |
| 7 |
|
| 8 |
global tid |
| 9 |
|
| 10 |
probe begin /* kernel.function("read") */ { |
| 11 |
count=0 timestamp=0 fd=0 |
| 12 |
tid=1 |
| 13 |
|
| 14 |
entry_time[tid] = timestamp # "macro" variable |
| 15 |
my_count[tid] = count # function argument |
| 16 |
my_fd[tid] = fd # function argument |
| 17 |
trace ("my_count = " . sprint(my_count[tid]) . |
| 18 |
"my_fd = " . sprint(my_fd[tid])) |
| 19 |
} |
| 20 |
|
| 21 |
probe end /* kernel.function("read").return */ { |
| 22 |
syscall_name="" retvalue=0 |
| 23 |
tid=1 |
| 24 |
|
| 25 |
if (entry_time[tid]) { |
| 26 |
read_times[syscall_name] # variable from provider alias |
| 27 |
+= timestamp - entry_time[tid] |
| 28 |
} |
| 29 |
trace ("syscall " . (syscall_name) . |
| 30 |
" return value = " . |
| 31 |
sprintf ("0x%x", retvalue)) # function pseudo-argument |
| 32 |
} |
| 33 |
|
| 34 |
probe end { |
| 35 |
foreach (syscall in read_times) { |
| 36 |
trace ("syscall " . syscall . |
| 37 |
" total-time=" . sprint (read_times[syscall])) |
| 38 |
} |
| 39 |
} |
| 40 |
|