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