probepoint.tc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. # description: Kprobe events - probe points
  4. [ -f kprobe_events ] || exit_unsupported # this is configurable
  5. TARGET_FUNC=tracefs_create_dir
  6. dec_addr() { # hexaddr
  7. printf "%d" "0x"`echo $1 | tail -c 8`
  8. }
  9. set_offs() { # prev target next
  10. A1=`dec_addr $1`
  11. A2=`dec_addr $2`
  12. A3=`dec_addr $3`
  13. TARGET="0x$2" # an address
  14. PREV=`expr $A1 - $A2` # offset to previous symbol
  15. NEXT=+`expr $A3 - $A2` # offset to next symbol
  16. OVERFLOW=+`printf "0x%x" ${PREV}` # overflow offset to previous symbol
  17. }
  18. # We have to decode symbol addresses to get correct offsets.
  19. # If the offset is not an instruction boundary, it cause -EILSEQ.
  20. set_offs `grep -A1 -B1 ${TARGET_FUNC} /proc/kallsyms | cut -f 1 -d " " | xargs`
  21. UINT_TEST=no
  22. # printf "%x" -1 returns (unsigned long)-1.
  23. if [ `printf "%x" -1 | wc -c` != 9 ]; then
  24. UINT_TEST=yes
  25. fi
  26. echo 0 > events/enable
  27. echo > kprobe_events
  28. echo "p:testprobe ${TARGET_FUNC}" > kprobe_events
  29. echo "p:testprobe ${TARGET}" > kprobe_events
  30. echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events
  31. ! echo "p:testprobe ${TARGET_FUNC}${PREV}" > kprobe_events
  32. if [ "${UINT_TEST}" = yes ]; then
  33. ! echo "p:testprobe ${TARGET_FUNC}${OVERFLOW}" > kprobe_events
  34. fi
  35. echo > kprobe_events
  36. clear_trace