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