1 #!/bin/sh 2 # description: Kprobe dynamic event with function tracer 3 4 [ -f kprobe_events ] || exit_unsupported # this is configurable 5 grep function available_tracers || exit_unsupported # this is configurable 6 7 # prepare 8 echo nop > current_tracer 9 echo _do_fork > set_ftrace_filter 10 echo 0 > events/enable 11 echo > kprobe_events 12 echo 'p:testprobe _do_fork' > kprobe_events 13 14 # kprobe on / ftrace off 15 echo 1 > events/kprobes/testprobe/enable 16 echo > trace 17 ( echo "forked") 18 grep testprobe trace 19 ! grep '_do_fork <-' trace 20 21 # kprobe on / ftrace on 22 echo function > current_tracer 23 echo > trace 24 ( echo "forked") 25 grep testprobe trace 26 grep '_do_fork <-' trace 27 28 # kprobe off / ftrace on 29 echo 0 > events/kprobes/testprobe/enable 30 echo > trace 31 ( echo "forked") 32 ! grep testprobe trace 33 grep '_do_fork <-' trace 34 35 # kprobe on / ftrace on 36 echo 1 > events/kprobes/testprobe/enable 37 echo function > current_tracer 38 echo > trace 39 ( echo "forked") 40 grep testprobe trace 41 grep '_do_fork <-' trace 42 43 # kprobe on / ftrace off 44 echo nop > current_tracer 45 echo > trace 46 ( echo "forked") 47 grep testprobe trace 48 ! grep '_do_fork <-' trace 49 50 # cleanup 51 echo nop > current_tracer 52 echo > set_ftrace_filter 53 echo 0 > events/kprobes/testprobe/enable 54 echo > kprobe_events 55 echo > trace 56