Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 # description: Kprobe events - probe points
0004 # requires: kprobe_events
0005 
0006 TARGET_FUNC=tracefs_create_dir
0007 
0008 dec_addr() { # hexaddr
0009   printf "%d" "0x"`echo $1 | tail -c 8`
0010 }
0011 
0012 set_offs() { # prev target next
0013   A1=`dec_addr $1`
0014   A2=`dec_addr $2`
0015   A3=`dec_addr $3`
0016   TARGET="0x$2" # an address
0017   PREV=`expr $A1 - $A2` # offset to previous symbol
0018   NEXT=+`expr $A3 - $A2` # offset to next symbol
0019   OVERFLOW=+`printf "0x%x" ${PREV}` # overflow offset to previous symbol
0020 }
0021 
0022 # We have to decode symbol addresses to get correct offsets.
0023 # If the offset is not an instruction boundary, it cause -EILSEQ.
0024 set_offs `grep -A1 -B1 ${TARGET_FUNC} /proc/kallsyms | cut -f 1 -d " " | xargs`
0025 
0026 UINT_TEST=no
0027 # printf "%x" -1 returns (unsigned long)-1.
0028 if [ `printf "%x" -1 | wc -c` != 9 ]; then
0029   UINT_TEST=yes
0030 fi
0031 
0032 echo "p:testprobe ${TARGET_FUNC}" > kprobe_events
0033 echo "p:testprobe ${TARGET}" > kprobe_events
0034 echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events
0035 ! echo "p:testprobe ${TARGET_FUNC}${PREV}" > kprobe_events
0036 if [ "${UINT_TEST}" = yes ]; then
0037 ! echo "p:testprobe ${TARGET_FUNC}${OVERFLOW}" > kprobe_events
0038 fi