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