162306a36Sopenharmony_ci#!/bin/sh 262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 362306a36Sopenharmony_ci# description: Kprobe events - probe points 462306a36Sopenharmony_ci# requires: kprobe_events 562306a36Sopenharmony_ci 662306a36Sopenharmony_ciTARGET_FUNC=tracefs_create_dir 762306a36Sopenharmony_ci 862306a36Sopenharmony_cidec_addr() { # hexaddr 962306a36Sopenharmony_ci printf "%d" "0x"`echo $1 | tail -c 8` 1062306a36Sopenharmony_ci} 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciset_offs() { # prev target next 1362306a36Sopenharmony_ci A1=`dec_addr $1` 1462306a36Sopenharmony_ci A2=`dec_addr $2` 1562306a36Sopenharmony_ci A3=`dec_addr $3` 1662306a36Sopenharmony_ci TARGET="0x$2" # an address 1762306a36Sopenharmony_ci PREV=`expr $A1 - $A2` # offset to previous symbol 1862306a36Sopenharmony_ci NEXT=+`expr $A3 - $A2` # offset to next symbol 1962306a36Sopenharmony_ci OVERFLOW=+`printf "0x%x" ${PREV}` # overflow offset to previous symbol 2062306a36Sopenharmony_ci} 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci# We have to decode symbol addresses to get correct offsets. 2362306a36Sopenharmony_ci# If the offset is not an instruction boundary, it cause -EILSEQ. 2462306a36Sopenharmony_ciset_offs `grep -v __pfx_ /proc/kallsyms | grep -A1 -B1 ${TARGET_FUNC} | cut -f 1 -d " " | xargs` 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciUINT_TEST=no 2762306a36Sopenharmony_ci# printf "%x" -1 returns (unsigned long)-1. 2862306a36Sopenharmony_ciif [ `printf "%x" -1 | wc -c` != 9 ]; then 2962306a36Sopenharmony_ci UINT_TEST=yes 3062306a36Sopenharmony_cifi 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciecho "p:testprobe ${TARGET_FUNC}" > kprobe_events 3362306a36Sopenharmony_ciecho "p:testprobe ${TARGET}" > kprobe_events 3462306a36Sopenharmony_ciecho "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events 3562306a36Sopenharmony_ci! echo "p:testprobe ${TARGET_FUNC}${PREV}" > kprobe_events 3662306a36Sopenharmony_ciif [ "${UINT_TEST}" = yes ]; then 3762306a36Sopenharmony_ci! echo "p:testprobe ${TARGET_FUNC}${OVERFLOW}" > kprobe_events 3862306a36Sopenharmony_cifi 39