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 'p:testprobe _do_fork' > kprobe_events
12
13# kprobe on / ftrace off
14echo 1 > events/kprobes/testprobe/enable
15echo > trace
16( echo "forked")
17grep testprobe trace
18! grep '_do_fork <-' trace
19
20# kprobe on / ftrace on
21echo function > current_tracer
22echo > trace
23( echo "forked")
24grep testprobe trace
25grep '_do_fork <-' trace
26
27# kprobe off / ftrace on
28echo 0 > events/kprobes/testprobe/enable
29echo > trace
30( echo "forked")
31! grep testprobe trace
32grep '_do_fork <-' trace
33
34# kprobe on / ftrace on
35echo 1 > events/kprobes/testprobe/enable
36echo function > current_tracer
37echo > trace
38( echo "forked")
39grep testprobe trace
40grep '_do_fork <-' trace
41
42# kprobe on / ftrace off
43echo nop > current_tracer
44echo > trace
45( echo "forked")
46grep testprobe trace
47! grep '_do_fork <-' trace
48