|
| 1 | +#! /bin/sh |
| 2 | + |
| 3 | +# Copyright 2015 vonnyfly(lifeng1519@gmail.com) |
| 4 | + |
| 5 | +# suppress some run-time errors here for cleaner output |
| 6 | +//bin/true && exec stap --all-modules --suppress-handler-errors --skip-badvars $0 ${1+"$@"} |
| 7 | + |
| 8 | + |
| 9 | +/* configuration options; set these with stap -G */ |
| 10 | +global g_extra = 1 |
| 11 | +global black_lists |
| 12 | +global g_incalls |
| 13 | +function trace(entry_p, extra) { |
| 14 | + if (g_extra == 0) extra = "" |
| 15 | + if (tid() in g_incalls) |
| 16 | + printf("%s%s%s %s\n", |
| 17 | + thread_indent (entry_p), |
| 18 | + (entry_p>0?"->":"<-"), |
| 19 | + ppfunc (), |
| 20 | + extra) |
| 21 | +} |
| 22 | + |
| 23 | + |
| 24 | +/*probe module("scsi_mod").function("*").call, |
| 25 | + module("sg").function("*").call, |
| 26 | + module("scsi_transport_spi").function("*").call, |
| 27 | + module("libata").function("*").call, |
| 28 | + module("mptspi").function("*").call, |
| 29 | + module("vmw_pvscsi").function("*").call, |
| 30 | + module("sd_mod").function("*").call, |
| 31 | + module("sr_mod").function("*").call, |
| 32 | + module("mptscsih").function("*").call*/ |
| 33 | +probe module("scsi_mod").function("*").call, |
| 34 | + module("sg").function("*").call, |
| 35 | + module("sd_mod").function("*").call |
| 36 | +{ |
| 37 | + if (execname() in black_lists) next |
| 38 | + trace(1, $$parms) |
| 39 | +} |
| 40 | + |
| 41 | +/*probe module("scsi_mod").function("*").return, |
| 42 | + module("sg").function("*").return, |
| 43 | + module("scsi_transport_spi").function("*").return, |
| 44 | + module("libata").function("*").return, |
| 45 | + module("mptspi").function("*").return, |
| 46 | + module("vmw_pvscsi").function("*").return, |
| 47 | + module("sd_mod").function("*").return, |
| 48 | + module("sr_mod").function("*").return, |
| 49 | + module("mptscsih").function("*").return*/ |
| 50 | +probe module("scsi_mod").function("*").return, |
| 51 | + module("sg").function("*").return, |
| 52 | + module("sd_mod").function("*").return |
| 53 | +{ |
| 54 | + if (execname() in black_lists) next |
| 55 | + trace(-1, $$return) |
| 56 | +} |
| 57 | + |
| 58 | +//probe kernel.function($1).call { |
| 59 | +//probe module("scsi_mod").function($1).call { |
| 60 | +probe $1.call { |
| 61 | + printf("\nkernel backtrace:\n") |
| 62 | + print_backtrace() |
| 63 | + black_lists["stapio"] = 1 |
| 64 | + black_lists["swapper/0"] = 1 |
| 65 | + g_incalls[tid()] = 1 |
| 66 | + trace(1, $$parms) |
| 67 | +} |
| 68 | +probe $1.return { |
| 69 | + trace(-1, $$return) |
| 70 | + delete g_incalls[tid()] |
| 71 | + printf("---------------------------------------------------------\n") |
| 72 | +} |
0 commit comments