1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# description: Checking dynamic events limitations 4# requires: dynamic_events "imm-value":README 5 6# Max arguments limitation 7MAX_ARGS=128 8EXCEED_ARGS=$((MAX_ARGS + 1)) 9 10# bash and dash evaluate variables differently. 11# dash will evaluate '\\' every time it is read whereas bash does not. 12# 13# TEST_STRING="$TEST_STRING \\$i" 14# echo $TEST_STRING 15# 16# With i=123 17# On bash, that will print "\123" 18# but on dash, that will print the escape sequence of \123 as the \ will 19# be interpreted again in the echo. 20# 21# Set a variable "bs" to save a double backslash, then echo that 22# to "ts" to see if $ts changed or not. If it changed, it's dash, 23# if not, it's bash, and then bs can equal a single backslash. 24bs='\\' 25ts=`echo $bs` 26if [ "$ts" = '\\' ]; then 27 # this is bash 28 bs='\' 29fi 30 31check_max_args() { # event_header 32 TEST_STRING=$1 33 # Acceptable 34 for i in `seq 1 $MAX_ARGS`; do 35 TEST_STRING="$TEST_STRING $bs$i" 36 done 37 echo "$TEST_STRING" >> dynamic_events 38 echo > dynamic_events 39 # Error 40 TEST_STRING="$TEST_STRING \\$EXCEED_ARGS" 41 ! echo "$TEST_STRING" >> dynamic_events 42 return 0 43} 44 45# Kprobe max args limitation 46if grep -q "kprobe_events" README; then 47 check_max_args "p vfs_read" 48fi 49 50# Fprobe max args limitation 51if grep -q "f[:[<group>/][<event>]] <func-name>[%return] [<args>]" README; then 52 check_max_args "f vfs_read" 53fi 54 55# Tprobe max args limitation 56if grep -q "t[:[<group>/][<event>]] <tracepoint> [<args>]" README; then 57 check_max_args "t kfree" 58fi 59 60# Uprobe max args limitation 61if grep -q "uprobe_events" README; then 62 check_max_args "p /bin/sh:10" 63fi 64