summaryrefslogtreecommitdiffstats
path: root/examples/small_demos/proc_snoop.stp
blob: df0f2c81a32c7e12d2280d0a3b848f4c3b57a263 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env stap

global start_ts

probe begin {
    start_ts = gettimeofday_us()
    printf("%12s  %5s  %5s  %-16s  ACTION\n",
            "TIMESTAMP", "PID", "TID", "EXECNAME")
}

function report(action:string) {
    printf("%12d  %5d  %5d  %-16s  %s\n", gettimeofday_us() - start_ts,
            pid(), tid(), execname(), action)
}

function id:string(task:long) {
    return sprintf("p:%d t:%d n:%s", task_pid(task), task_tid(task),
            task_execname(task))
}

probe process.create {
    report(sprintf("create %s", id(task)))
}

probe process.start {
    report("start")
}

probe process.exec {
    report(sprintf("exec %s", filename))
}

probe process.exec_complete {
    if (success)
        report("exec success")
    else
        report(sprintf("exec failed %d (%s)", errno, errno_str(errno)))
}

probe process.exit {
    report(sprintf("exit %d", code))
}

probe process.release {
    report(sprintf("remove %s", id(task)))
}

probe process.signal_send {
    report(sprintf("sigsend %d (%s) to %s%s", signal, signal_name, id(task),
                shared? " [SHARED]" : ""))
}

probe process.signal_handle {
    report(sprintf("sighandle %d (%s)", signal, signal_name))
}