18cb0bc9eSMasami Hiramatsu#!/bin/sh 2b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 38cb0bc9eSMasami Hiramatsu# description: Kprobe event auto/manual naming 43591e90fSMasami Hiramatsu# requires: kprobe_events 58cb0bc9eSMasami Hiramatsu 68cb0bc9eSMasami Hiramatsu:;: "Add an event on function without name" ;: 78cb0bc9eSMasami Hiramatsu 88cb0bc9eSMasami HiramatsuFUNC=`grep " [tT] .*vfs_read$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "` 98cb0bc9eSMasami Hiramatsu[ "x" != "x$FUNC" ] || exit_unresolved 108cb0bc9eSMasami Hiramatsuecho "p $FUNC" > kprobe_events 118cb0bc9eSMasami HiramatsuPROBE_NAME=`echo $FUNC | tr ".:" "_"` 128cb0bc9eSMasami Hiramatsutest -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure 138cb0bc9eSMasami Hiramatsu 148cb0bc9eSMasami Hiramatsu:;: "Add an event on function with new name" ;: 158cb0bc9eSMasami Hiramatsu 168cb0bc9eSMasami Hiramatsuecho "p:event1 $FUNC" > kprobe_events 178cb0bc9eSMasami Hiramatsutest -d events/kprobes/event1 || exit_failure 188cb0bc9eSMasami Hiramatsu 198cb0bc9eSMasami Hiramatsu:;: "Add an event on function with new name and group" ;: 208cb0bc9eSMasami Hiramatsu 218cb0bc9eSMasami Hiramatsuecho "p:kprobes2/event2 $FUNC" > kprobe_events 228cb0bc9eSMasami Hiramatsutest -d events/kprobes2/event2 || exit_failure 238cb0bc9eSMasami Hiramatsu 248cb0bc9eSMasami Hiramatsu:;: "Add an event on dot function without name" ;: 258cb0bc9eSMasami Hiramatsu 26604e3548SSteven Rostedt (VMware)find_dot_func() { 27604e3548SSteven Rostedt (VMware) if [ ! -f available_filter_functions ]; then 28604e3548SSteven Rostedt (VMware) grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " " 29604e3548SSteven Rostedt (VMware) return; 30604e3548SSteven Rostedt (VMware) fi 31604e3548SSteven Rostedt (VMware) 32604e3548SSteven Rostedt (VMware) grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do 33*fcb88dc6SSteven Rostedt (Google) cnt=`grep -s $f available_filter_functions | wc -l`; 34*fcb88dc6SSteven Rostedt (Google) if [ $cnt -eq 1 ]; then 35604e3548SSteven Rostedt (VMware) echo $f 36604e3548SSteven Rostedt (VMware) break 37604e3548SSteven Rostedt (VMware) fi 38604e3548SSteven Rostedt (VMware) done 39604e3548SSteven Rostedt (VMware)} 40604e3548SSteven Rostedt (VMware) 41604e3548SSteven Rostedt (VMware)FUNC=`find_dot_func | tail -n 1` 428cb0bc9eSMasami Hiramatsu[ "x" != "x$FUNC" ] || exit_unresolved 438cb0bc9eSMasami Hiramatsuecho "p $FUNC" > kprobe_events 448cb0bc9eSMasami HiramatsuEVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:` 458cb0bc9eSMasami Hiramatsu[ "x" != "x$EVENT" ] || exit_failure 468cb0bc9eSMasami Hiramatsutest -d events/$EVENT || exit_failure 47