1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# description: Generic dynamic event - add/remove probes with BTF arguments 4# requires: dynamic_events "<argname>":README 5 6KPROBES= 7FPROBES= 8 9if grep -qF "p[:[<group>/][<event>]] <place> [<args>]" README ; then 10 KPROBES=yes 11fi 12if grep -qF "f[:[<group>/][<event>]] <func-name>[%return] [<args>]" README ; then 13 FPROBES=yes 14fi 15 16if [ -z "$KPROBES" -a "$FPROBES" ] ; then 17 exit_unsupported 18fi 19 20echo 0 > events/enable 21echo > dynamic_events 22 23TP=kfree 24 25if [ "$FPROBES" ] ; then 26echo "f:fpevent $TP object" >> dynamic_events 27echo "t:tpevent $TP ptr" >> dynamic_events 28 29grep -q "fpevent.*object=object" dynamic_events 30grep -q "tpevent.*ptr=ptr" dynamic_events 31 32echo > dynamic_events 33 34echo "f:fpevent $TP "'$arg1' >> dynamic_events 35grep -q "fpevent.*object=object" dynamic_events 36echo > dynamic_events 37 38echo "f:fpevent $TP "'$arg*' >> dynamic_events 39echo "t:tpevent $TP "'$arg*' >> dynamic_events 40 41grep -q "fpevent.*object=object" dynamic_events 42grep -q "tpevent.*ptr=ptr" dynamic_events 43! grep -q "tpevent.*_data" dynamic_events 44fi 45 46echo > dynamic_events 47 48if [ "$KPROBES" ] ; then 49echo "p:kpevent $TP object" >> dynamic_events 50grep -q "kpevent.*object=object" dynamic_events 51 52echo > dynamic_events 53 54echo "p:kpevent $TP "'$arg*' >> dynamic_events 55grep -q "kpevent.*object=object" dynamic_events 56fi 57 58clear_trace 59