kprobe_module.tc 946 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. # description: Kprobe dynamic event - probing module
  4. [ -f kprobe_events ] || exit_unsupported # this is configurable
  5. disable_events
  6. echo > kprobe_events
  7. :;: "Add an event on a module function without specifying event name" ;:
  8. MOD=`lsmod | head -n 2 | tail -n 1 | cut -f1 -d" "`
  9. FUNC=`grep -m 1 ".* t .*\\[$MOD\\]" /proc/kallsyms | xargs | cut -f3 -d" "`
  10. [ "x" != "x$MOD" -a "y" != "y$FUNC" ] || exit_unresolved
  11. echo "p $MOD:$FUNC" > kprobe_events
  12. PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"`
  13. test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure
  14. :;: "Add an event on a module function with new event name" ;:
  15. echo "p:event1 $MOD:$FUNC" > kprobe_events
  16. test -d events/kprobes/event1 || exit_failure
  17. :;: "Add an event on a module function with new event and group name" ;:
  18. echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events
  19. test -d events/kprobes1/event1 || exit_failure
  20. echo > kprobe_events