1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: Kprobe dynamic event with function tracer
4# requires: kprobe_events stack_trace_filter function:tracer
5
6# prepare
7echo nop > current_tracer
8echo $FUNCTION_FORK > set_ftrace_filter
9echo "p:testprobe $FUNCTION_FORK" > kprobe_events
10
11# kprobe on / ftrace off
12echo 1 > events/kprobes/testprobe/enable
13echo > trace
14( echo "forked")
15grep testprobe trace
16! grep "$FUNCTION_FORK <-" trace
17
18# kprobe on / ftrace on
19echo function > current_tracer
20echo > trace
21( echo "forked")
22grep testprobe trace
23grep "$FUNCTION_FORK <-" trace
24
25# kprobe off / ftrace on
26echo 0 > events/kprobes/testprobe/enable
27echo > trace
28( echo "forked")
29! grep testprobe trace
30grep "$FUNCTION_FORK <-" trace
31
32# kprobe on / ftrace on
33echo 1 > events/kprobes/testprobe/enable
34echo function > current_tracer
35echo > trace
36( echo "forked")
37grep testprobe trace
38grep "$FUNCTION_FORK <-" trace
39
40# kprobe on / ftrace off
41echo nop > current_tracer
42echo > trace
43( echo "forked")
44grep testprobe trace
45! grep "$FUNCTION_FORK <-" trace
46