Debian Codegraph @

testsuite/systemtap.examples/process/errsnoop.stp

raw
1 #! /usr/bin/env stap
2 # errsnoop.stp
3 # Copyright (C) 2009-2018 Red Hat, Inc., Eugene Teo <[email protected]>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation.
8 #
9 # attack "stupid userspace" apps
10 #
11
12 global error%[6000], trace // about 18.5MB kernel RAM
13
14 probe syscall.* {
15 # assume syscall don't nest
16 trace[tid()] = argstr
17 }
18
19 probe syscall.*.return {
20 errno = errno_p(retval)
21 if (errno != 0) {
22 argstr = trace[tid()]
23 delete trace[tid()]
24 errstr = sprintf("%3d/%s", errno, errno_str(errno))
25 error[sprintf("%-13s %17s %15s %5d %s", errstr, name, execname(), pid(), argstr)] <<< 1
26 }
27 }
28
29 probe timer.s(%( $# > 0 %? $1 %: 5 %)) {
30 ansi_clear_screen()
31 printf("%4s %-13s %17s %15s %5s %s\n",
32 "HITS", "ERRSTR", "SYSCALL", "PROCESS", "PID", "ARGSTR")
33 foreach([bigstr] in error- limit %( $# > 1 %? $2 %: 20 %))
34 printf("%4d %s\n", @count(error[bigstr]), bigstr)
35 delete error
36 }