kprobe_module.tc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. # description: Kprobe dynamic event - probing module
  4. # requires: kprobe_events
  5. rmmod trace-printk ||:
  6. if ! modprobe trace-printk ; then
  7. echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK=
  8. m"
  9. exit_unresolved;
  10. fi
  11. MOD=trace_printk
  12. FUNC=trace_printk_irq_work
  13. :;: "Add an event on a module function without specifying event name" ;:
  14. echo "p $MOD:$FUNC" > kprobe_events
  15. PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"`
  16. test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure
  17. :;: "Add an event on a module function with new event name" ;:
  18. echo "p:event1 $MOD:$FUNC" > kprobe_events
  19. test -d events/kprobes/event1 || exit_failure
  20. :;: "Add an event on a module function with new event and group name" ;:
  21. echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events
  22. test -d events/kprobes1/event1 || exit_failure
  23. :;: "Remove target module, but event still be there" ;:
  24. if ! rmmod trace-printk ; then
  25. echo "Failed to unload module - please enable CONFIG_MODULE_UNLOAD"
  26. exit_unresolved;
  27. fi
  28. test -d events/kprobes1/event1
  29. :;: "Check posibility to defining events on unloaded module";:
  30. echo "p:event2 $MOD:$FUNC" >> kprobe_events
  31. :;: "Target is gone, but we can prepare for next time";:
  32. echo 1 > events/kprobes1/event1/enable
  33. :;: "Load module again, which means the event1 should be recorded";:
  34. modprobe trace-printk
  35. grep "event1:" trace
  36. :;: "Remove the module again and check the event is not locked"
  37. rmmod trace-printk
  38. echo 0 > events/kprobes1/event1/enable
  39. echo "-:kprobes1/event1" >> kprobe_events