Debian Codegraph @

testsuite/systemtap.examples/profiling/syscallerrorsbypid.stp

raw
1 #! /usr/bin/env stap
2 #
3 # Copyright (C) 2018 Red Hat, Inc.
4 # By William Cohen, Red Hat Inc.
5 # [email protected]
6 #
7 # USAGE: stap syscallerrorsbypid.stp --suppress-handler-errors
8 #
9 # The "--suppress-handler-errors" option allows the script to continue
10 # run when probes are skipped. The probe skips make the data less accurate,
11 # but are otherwise harmless.
12
13 global arr%[20000], sys%[20000]
14 global procname%
15
16 probe syscall_any {
17 sys[tid()] = syscall_nr
18 }
19 probe syscall_any.return {
20 if (tid() in sys && retval < 0 ) {
21 arr[pid(), sys[tid()], retval]++
22 procname[pid()] = execname()
23 }
24 delete sys[tid()]
25 }
26
27 probe scheduler.process_exit {
28 delete arr[pid(),*,*]
29 delete procname[pid()]
30 }
31
32 function process_name(pid) {
33 return sprintf("%s[%d]", procname[pid], pid)
34 }
35
36 probe prometheus {
37 @prometheus_dump_array3_map(arr, "syscall_error_count", "pid", "syscall", "error",
38 sprint, process_name, syscall_name, errno_str)
39 }