Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 # description: Kprobe dynamic event - probing module
0004 # requires: kprobe_events
0005 
0006 rmmod trace-printk ||:
0007 if ! modprobe trace-printk ; then
0008   echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK=
0009 m"
0010   exit_unresolved;
0011 fi
0012 
0013 MOD=trace_printk
0014 FUNC=trace_printk_irq_work
0015 
0016 :;: "Add an event on a module function without specifying event name" ;:
0017 
0018 echo "p $MOD:$FUNC" > kprobe_events
0019 PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"`
0020 test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure
0021 
0022 :;: "Add an event on a module function with new event name" ;:
0023 
0024 echo "p:event1 $MOD:$FUNC" > kprobe_events
0025 test -d events/kprobes/event1 || exit_failure
0026 
0027 :;: "Add an event on a module function with new event and group name" ;:
0028 
0029 echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events
0030 test -d events/kprobes1/event1 || exit_failure
0031 
0032 :;: "Remove target module, but event still be there" ;:
0033 if ! rmmod trace-printk ; then
0034   echo "Failed to unload module - please enable CONFIG_MODULE_UNLOAD"
0035   exit_unresolved;
0036 fi
0037 test -d events/kprobes1/event1
0038 
0039 :;: "Check posibility to defining events on unloaded module";:
0040 echo "p:event2 $MOD:$FUNC" >> kprobe_events
0041 
0042 :;: "Target is gone, but we can prepare for next time";:
0043 echo 1 > events/kprobes1/event1/enable
0044 
0045 :;: "Load module again, which means the event1 should be recorded";:
0046 modprobe trace-printk
0047 grep "event1:" trace
0048 
0049 :;: "Remove the module again and check the event is not locked"
0050 rmmod trace-printk
0051 echo 0 > events/kprobes1/event1/enable
0052 echo "-:kprobes1/event1" >> kprobe_events