1 # SPDX-License-Identifier: GPL-2.0-only 2 3 clear_trace() { # reset trace output 4 echo > trace 5 } 6 7 disable_tracing() { # stop trace recording 8 echo 0 > tracing_on 9 } 10 11 enable_tracing() { # start trace recording 12 echo 1 > tracing_on 13 } 14 15 reset_tracer() { # reset the current tracer 16 echo nop > current_tracer 17 } 18 19 reset_trigger_file() { 20 # remove action triggers first 21 grep -H ':on[^:]*(' $@ | 22 while read line; do 23 cmd=`echo $line | cut -f2- -d: | cut - 24 file=`echo $line | cut -f1 -d:` 25 echo "!$cmd" >> $file 26 done 27 grep -Hv ^# $@ | 28 while read line; do 29 cmd=`echo $line | cut -f2- -d: | cut - 30 file=`echo $line | cut -f1 -d:` 31 echo "!$cmd" > $file 32 done 33 } 34 35 reset_trigger() { # reset all current setting 36 if [ -d events/synthetic ]; then 37 reset_trigger_file events/synthetic/*/ 38 fi 39 reset_trigger_file events/*/*/trigger 40 } 41 42 reset_events_filter() { # reset all current se 43 grep -v ^none events/*/*/filter | 44 while read line; do 45 echo 0 > `echo $line | cut -f1 -d:` 46 done 47 } 48 49 reset_ftrace_filter() { # reset all triggers i 50 if [ ! -f set_ftrace_filter ]; then 51 return 0 52 fi 53 echo > set_ftrace_filter 54 grep -v '^#' set_ftrace_filter | while rea 55 tr=`echo $t | cut -d: -f2` 56 if [ "$tr" = "" ]; then 57 continue 58 fi 59 if ! grep -q "$t" set_ftrace_filter; t 60 continue; 61 fi 62 name=`echo $t | cut -d: -f1 | cut -d' 63 if [ $tr = "enable_event" -o $tr = "di 64 tr=`echo $t | cut -d: -f2-4` 65 limit=`echo $t | cut -d: -f5` 66 else 67 tr=`echo $t | cut -d: -f2` 68 limit=`echo $t | cut -d: -f3` 69 fi 70 if [ "$limit" != "unlimited" ]; then 71 tr="$tr:$limit" 72 fi 73 echo "!$name:$tr" > set_ftrace_filter 74 done 75 } 76 77 disable_events() { 78 echo 0 > events/enable 79 } 80 81 clear_synthetic_events() { # reset all current 82 grep -v ^# synthetic_events | 83 while read line; do 84 echo "!$line" >> synthetic_events 85 done 86 } 87 88 initialize_ftrace() { # Reset ftrace to initia 89 # As the initial state, ftrace will be set to 90 # no events, no triggers, no filters, no funct 91 # no probes, and tracing on. 92 disable_tracing 93 reset_tracer 94 reset_trigger 95 reset_events_filter 96 reset_ftrace_filter 97 disable_events 98 [ -f set_event_pid ] && echo > set_event_p 99 [ -f set_ftrace_pid ] && echo > set_ftrace 100 [ -f set_ftrace_notrace ] && echo > set_ft 101 [ -f set_graph_function ] && echo | tee se 102 [ -f stack_trace_filter ] && echo > stack_ 103 [ -f kprobe_events ] && echo > kprobe_even 104 [ -f uprobe_events ] && echo > uprobe_even 105 [ -f synthetic_events ] && echo > syntheti 106 [ -f snapshot ] && echo 0 > snapshot 107 clear_trace 108 enable_tracing 109 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.