2 clear_trace() { # reset trace output
6 disable_tracing() { # stop trace recording
10 enable_tracing() { # start trace recording
14 reset_tracer() { # reset the current tracer
15 echo nop > current_tracer
18 reset_trigger_file() {
19 # remove action triggers first
20 grep -H ':on[^:]*(' $@ |
22 cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
23 file=`echo $line | cut -f1 -d:`
28 cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
29 file=`echo $line | cut -f1 -d:`
34 reset_trigger() { # reset all current setting triggers
35 if [ -d events/synthetic ]; then
36 reset_trigger_file events/synthetic/*/trigger
38 reset_trigger_file events/*/*/trigger
41 reset_events_filter() { # reset all current setting filters
42 grep -v ^none events/*/*/filter |
44 echo 0 > `echo $line | cut -f1 -d:`
48 reset_ftrace_filter() { # reset all triggers in set_ftrace_filter
49 echo > set_ftrace_filter
50 grep -v '^#' set_ftrace_filter | while read t; do
51 tr=`echo $t | cut -d: -f2`
52 if [ "$tr" = "" ]; then
55 if ! grep -q "$t" set_ftrace_filter; then
58 name=`echo $t | cut -d: -f1 | cut -d' ' -f1`
59 if [ $tr = "enable_event" -o $tr = "disable_event" ]; then
60 tr=`echo $t | cut -d: -f2-4`
61 limit=`echo $t | cut -d: -f5`
63 tr=`echo $t | cut -d: -f2`
64 limit=`echo $t | cut -d: -f3`
66 if [ "$limit" != "unlimited" ]; then
69 echo "!$name:$tr" > set_ftrace_filter
74 echo 0 > events/enable
77 clear_synthetic_events() { # reset all current synthetic events
78 grep -v ^# synthetic_events |
80 echo "!$line" >> synthetic_events
84 initialize_ftrace() { # Reset ftrace to initial-state
85 # As the initial state, ftrace will be set to nop tracer,
86 # no events, no triggers, no filters, no function filters,
87 # no probes, and tracing on.
94 [ -f set_event_pid ] && echo > set_event_pid
95 [ -f set_ftrace_pid ] && echo > set_ftrace_pid
96 [ -f set_ftrace_filter ] && echo | tee set_ftrace_*
97 [ -f set_graph_function ] && echo | tee set_graph_*
98 [ -f stack_trace_filter ] && echo > stack_trace_filter
99 [ -f kprobe_events ] && echo > kprobe_events
100 [ -f uprobe_events ] && echo > uprobe_events
101 [ -f synthetic_events ] && echo > synthetic_events
102 [ -f snapshot ] && echo 0 > snapshot
110 ping $LOCALHOST -c 1 || sleep .001 || usleep 1 || sleep 1
113 ftrace_errlog_check() { # err-prefix command-with-error-pos-by-^ command-file
114 pos=$(echo -n "${2%^*}" | wc -c) # error position
115 command=$(echo "$2" | tr -d ^)
116 echo "Test command: $command"
118 (! echo "$command" > "$3" ) 2> /dev/null
119 grep "$1: error:" -A 3 error_log
120 N=$(tail -n 1 error_log | wc -c)
121 # " Command: " and "^\n" => 13
122 test $(expr 13 + $pos) -eq $N