/usr/share/systemtap/examples/general
NameSizeModeActions
alias_suffixes.meta7240644editdlrm
alias_suffixes.stp10600755editdlrm
also_ran.meta6050644editdlrm
also_ran.stp8040755editdlrm
ansi_colors.meta5070644editdlrm
ansi_colors.stp7160755editdlrm
ansi_colors2.meta5700644editdlrm
ansi_colors2.stp7380755editdlrm
badname.meta4590644editdlrm
badname.stp13350755editdlrm
badname.txt1260644editdlrm
callgraph.meta3880644editdlrm
callgraph.stp2120755editdlrm
callgraph.txt37000644editdlrm
click.wav12900644editdlrm
cpu_throttle.meta7950644editdlrm
cpu_throttle.stp14810755editdlrm
eventcount.meta6370644editdlrm
eventcount.stp69310755editdlrm
eventcount.txt18980644editdlrm
floatingpoint.meta4790644editdlrm
floatingpoint.stp5170644editdlrm
floatingpoint.txt1560644editdlrm
func_time_stats.meta6960644editdlrm
func_time_stats.stp5200755editdlrm
func_time_stats.txt4930644editdlrm
grapher.stp12860755editdlrm
graphs.meta4530644editdlrm
graphs.stp14990755editdlrm
helloworld.meta3970644editdlrm
helloworld.stp570755editdlrm
key.meta3190644editdlrm
key.stp4140755editdlrm
keyhack.meta3550644editdlrm
keyhack.stp2880755editdlrm
measureinterval.meta15820644editdlrm
measureinterval.stp8300755editdlrm
para-callgraph-verbose.meta8790644editdlrm
para-callgraph-verbose.stp4070755editdlrm
para-callgraph.meta7560644editdlrm
para-callgraph.stp4050755editdlrm
para-callgraph.txt44150644editdlrm
py2example.meta5310644editdlrm
py2example.tcl790644editdlrm
py3example.meta5320644editdlrm
py3example.tcl790644editdlrm
pyexample.py8320644editdlrm
pyexample.stp2160644editdlrm
regex.meta5040644editdlrm
regex.stp4910755editdlrm
return.wav65840644editdlrm
sizeof.meta6640644editdlrm
sizeof.stp4820755editdlrm
sizeof.txt1000644editdlrm
sizeof_interactive.meta8160644editdlrm
sizeof_interactive.stp5720644editdlrm
sizeof_interactive.txt1540644editdlrm
socket-events.meta5630644editdlrm
socket-events.stp54510755editdlrm
stopwatches.meta8600644editdlrm
stopwatches.stp9570755editdlrm
tcl-funtop.meta4790644editdlrm
tcl-funtop.stp8170755editdlrm
tcl-trace.meta3640644editdlrm
tcl-trace.stp10370755editdlrm
varwatch.meta5830644editdlrm
varwatch.stp4590755editdlrm
varwatch.txt26780644editdlrm
watchdog.meta9220644editdlrm
watchdog.stp4470755editdlrm
whythefail.meta4810644editdlrm
whythefail.stp22770644editdlrm
whythefail.txt37900644editdlrm
Edit: /usr/share/systemtap/examples/general/whythefail.stp (2277B)
#!/usr/bin/stap /* Print a trace of the the last few statements (file:line numbers, along with selected local variables) that were executed within a given function, if it ends up returning with a given condition. (No trace is shown for functions that return with the condition false, demonstrating use of speculation tapset.) Usage: stap whythefail.stp PROC_OR_KERNEL FUNCTION_NAME CONDITION_EXPRESSION [$VARIABLE$] PROC_OR_KERNEL: the first part of the probe point, e.g.: 'kernel' 'module("foo")' or 'process("bar")' FUNCTION_NAME: the function name (assumed non-recursive) CONDITION: expression to evaluate at function return, e.g.: '$return != 0' or '1' or 'randint(100)<20' VARIABLE: optional context-variable string to print at each statement, e.g.: '$a_var$' or '@var("global")$' or (default) '$$vars' If the script is invoked with -c CMD or -x PID, probes are filtered for that process target-set (it and its descendants). e.g.: stap whythefail.stp kernel do_mlock '$return < 0' */ global specs% global counts probe $1 . function(@2) . call { if (target() && !target_set_pid(pid())) next; specs[tid()] = speculation() counts["entry"] <<< 1 } probe $1 . statement(@2 "@*:*") { if (target() && !target_set_pid(pid())) next; tokenize(pp(),"@"); fileline=tokenize("","@"); file=tokenize(fileline,":\""); line=tokenize("",":\""); speculate(specs[tid()], sprintf("%s[%d] %s:%s %s\n", execname(), tid(), file, line, %( $# >= 4 %? @4.": ".@choose_defined($4,"?") %: "$$vars: ".$$vars %) )) counts["statement"] <<< 1 } probe $1 . function(@2) . return { if (target() && !target_set_pid(pid())) next; if ($3) { printf("\n%s[%d] %s function(%s) $return: %s\n", execname(), tid(), @1, @2, $return$) commit(specs[tid()]) counts["exit-hit"] <<< 1 } else { discard(specs[tid()]) counts["exit-miss"] <<< 1 } } probe end,error { printf("\nstatistics:\n") foreach (reason+ in counts) { printf("%s count: %d\n", reason, @count(counts[reason])) } }