Debian Codegraph @

testsuite/systemtap.examples/process/thread-business.stp

raw
1 #! /usr/bin/env stap
2
3 global activity // [execname,tid]->syscall-count
4 global activity2 // [execname,tid]->syscall-name-string-history
5
6 global syscall_history_length = 50 // override with stap -Gsyscall_history_length=NNN
7 global top_threads = 20
8
9 probe syscall_any # use tracepoint based syscall_any; we don't need context data
10 {
11 activity[execname(),tid()]<<<1
12 history = name." ".activity2[execname(),tid()]
13 activity2[execname(),tid()] = substr(history,0,syscall_history_length)
14 }
15
16
17 probe timer.s(5)
18 {
19 printf("%16s %6s %5s %-*s\n\n", "execname", "tid", "count",
20 syscall_history_length, "recent syscalls");
21 foreach ([e,t] in activity- limit top_threads) {
22 printf("%16s %6d %5d %s", e, t, @count(activity[e,t]), activity2[e,t])
23 printf("\n")
24 }
25 printf("\n")
26 delete activity
27 delete activity2
28 }