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