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= 8FIELDS= 9 10if grep -qF "p[:[<group>/][<event>]] <place> [<args>]" README ; then 11 KPROBES=yes 12fi 13if grep -qF "f[:[<group>/][<event>]] <func-name>[%return] [<args>]" README ; then 14 FPROBES=yes 15fi 16if grep -qF "<argname>[->field[->field|.field...]]" README ; then 17 FIELDS=yes 18fi 19 20if [ -z "$KPROBES" -a -z "$FPROBES" ] ; then 21 exit_unsupported 22fi 23 24echo 0 > events/enable 25echo > dynamic_events 26 27TP=kfree 28TP2=kmem_cache_alloc 29TP3=getname_flags 30TP4=sched_wakeup 31 32if [ "$FPROBES" ] ; then 33echo "f:fpevent $TP object" >> dynamic_events 34echo "t:tpevent $TP ptr" >> dynamic_events 35 36grep -q "fpevent.*object=object" dynamic_events 37grep -q "tpevent.*ptr=ptr" dynamic_events 38 39echo > dynamic_events 40 41echo "f:fpevent $TP "'$arg1' >> dynamic_events 42grep -q "fpevent.*object=object" dynamic_events 43 44echo > dynamic_events 45 46echo "f:fpevent $TP "'$arg*' >> dynamic_events 47echo "t:tpevent $TP "'$arg*' >> dynamic_events 48 49grep -q "fpevent.*object=object" dynamic_events 50grep -q "tpevent.*ptr=ptr" dynamic_events 51! grep -q "tpevent.*_data" dynamic_events 52fi 53 54echo > dynamic_events 55 56if [ "$FIELDS" -a "$FPROBES" ] ; then 57echo "t:tpevent ${TP2} obj_size=s->object_size" >> dynamic_events 58echo "f:fpevent ${TP3}%return path=\$retval->name:string" >> dynamic_events 59echo "t:tpevent2 ${TP4} p->se.group_node.next->prev" >> dynamic_events 60 61grep -q "tpevent .*obj_size=s->object_size" dynamic_events 62grep -q "fpevent.*path=\$retval->name:string" dynamic_events 63grep -q 'tpevent2 .*p->se.group_node.next->prev' dynamic_events 64 65echo > dynamic_events 66fi 67 68if [ "$KPROBES" ] ; then 69echo "p:kpevent $TP object" >> dynamic_events 70grep -q "kpevent.*object=object" dynamic_events 71 72echo > dynamic_events 73 74echo "p:kpevent $TP "'$arg*' >> dynamic_events 75grep -q "kpevent.*object=object" dynamic_events 76fi 77 78clear_trace 79