1 2clear_trace() { # reset trace output 3 echo > trace 4} 5 6disable_tracing() { # stop trace recording 7 echo 0 > tracing_on 8} 9 10enable_tracing() { # start trace recording 11 echo 1 > tracing_on 12} 13 14reset_tracer() { # reset the current tracer 15 echo nop > current_tracer 16} 17 18reset_trigger() { # reset all current setting triggers 19 grep -v ^# events/*/*/trigger | 20 while read line; do 21 cmd=`echo $line | cut -f2- -d: | cut -f1 -d" "` 22 echo "!$cmd" > `echo $line | cut -f1 -d:` 23 done 24} 25 26reset_events_filter() { # reset all current setting filters 27 grep -v ^none events/*/*/filter | 28 while read line; do 29 echo 0 > `echo $line | cut -f1 -d:` 30 done 31} 32 33reset_ftrace_filter() { # reset all triggers in set_ftrace_filter 34 echo > set_ftrace_filter 35 grep -v '^#' set_ftrace_filter | while read t; do 36 tr=`echo $t | cut -d: -f2` 37 if [ "$tr" = "" ]; then 38 continue 39 fi 40 if ! grep -q "$t" set_ftrace_filter; then 41 continue; 42 fi 43 name=`echo $t | cut -d: -f1 | cut -d' ' -f1` 44 if [ $tr = "enable_event" -o $tr = "disable_event" ]; then 45 tr=`echo $t | cut -d: -f2-4` 46 limit=`echo $t | cut -d: -f5` 47 else 48 tr=`echo $t | cut -d: -f2` 49 limit=`echo $t | cut -d: -f3` 50 fi 51 if [ "$limit" != "unlimited" ]; then 52 tr="$tr:$limit" 53 fi 54 echo "!$name:$tr" > set_ftrace_filter 55 done 56} 57 58disable_events() { 59 echo 0 > events/enable 60} 61 62clear_synthetic_events() { # reset all current synthetic events 63 grep -v ^# synthetic_events | 64 while read line; do 65 echo "!$line" >> synthetic_events 66 done 67} 68 69initialize_ftrace() { # Reset ftrace to initial-state 70# As the initial state, ftrace will be set to nop tracer, 71# no events, no triggers, no filters, no function filters, 72# no probes, and tracing on. 73 disable_tracing 74 reset_tracer 75 reset_trigger 76 reset_events_filter 77 disable_events 78 echo > set_event_pid # event tracer is always on 79 [ -f set_ftrace_filter ] && echo | tee set_ftrace_* 80 [ -f set_graph_function ] && echo | tee set_graph_* 81 [ -f stack_trace_filter ] && echo > stack_trace_filter 82 [ -f kprobe_events ] && echo > kprobe_events 83 [ -f uprobe_events ] && echo > uprobe_events 84 enable_tracing 85} 86