WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / ftrace / test.d / kprobe / kprobe_args_syntax.tc
blob474ca1a9a088528e2f15b5a642fcd775a518e5d2
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # description: Kprobe event argument syntax
4 # requires: kprobe_events "x8/16/32/64":README
6 PROBEFUNC="vfs_read"
7 GOODREG=
8 BADREG=
9 GOODSYM="_sdata"
10 if ! grep -qw ${GOODSYM} /proc/kallsyms ; then
11 GOODSYM=$PROBEFUNC
13 BADSYM="deaqswdefr"
14 SYMADDR=0x`grep -w ${GOODSYM} /proc/kallsyms | cut -f 1 -d " "`
15 GOODTYPE="x16"
16 BADTYPE="y16"
18 case `uname -m` in
19 x86_64|i[3456]86)
20 GOODREG=%ax
21 BADREG=%ex
23 aarch64)
24 GOODREG=%x0
25 BADREG=%ax
27 arm*)
28 GOODREG=%r0
29 BADREG=%ax
31 ppc*)
32 GOODREG=%r3
33 BADREG=%msr
36 echo "Please implement other architecture here"
37 exit_untested
38 esac
40 test_goodarg() # Good-args
42 while [ "$1" ]; do
43 echo "p ${PROBEFUNC} $1" > kprobe_events
44 shift 1
45 done;
48 test_badarg() # Bad-args
50 while [ "$1" ]; do
51 ! echo "p ${PROBEFUNC} $1" > kprobe_events
52 shift 1
53 done;
56 echo > kprobe_events
58 : "Register access"
59 test_goodarg ${GOODREG}
60 test_badarg ${BADREG}
62 : "Symbol access"
63 test_goodarg "@${GOODSYM}" "@${SYMADDR}" "@${GOODSYM}+10" "@${GOODSYM}-10"
64 test_badarg "@" "@${BADSYM}" "@${GOODSYM}*10" "@${GOODSYM}/10" \
65 "@${GOODSYM}%10" "@${GOODSYM}&10" "@${GOODSYM}|10"
67 : "Stack access"
68 test_goodarg "\$stack" "\$stack0" "\$stack1"
69 test_badarg "\$stackp" "\$stack0+10" "\$stack1-10"
71 : "Retval access"
72 echo "r ${PROBEFUNC} \$retval" > kprobe_events
73 ! echo "p ${PROBEFUNC} \$retval" > kprobe_events
75 # $comm was introduced in 4.8, older kernels reject it.
76 if grep -A1 "fetcharg:" README | grep -q '\$comm' ; then
77 : "Comm access"
78 test_goodarg "\$comm"
81 : "Indirect memory access"
82 test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \
83 "+0(\$stack1)" "+10(@${GOODSYM}-10)" "+0(+10(+20(\$stack)))"
84 test_badarg "+(${GOODREG})" "(${GOODREG}+10)" "-(${GOODREG})" "(${GOODREG})" \
85 "+10(\$comm)" "+0(${GOODREG})+10"
87 : "Name assignment"
88 test_goodarg "varname=${GOODREG}"
89 test_badarg "varname=varname2=${GOODREG}"
91 : "Type syntax"
92 test_goodarg "${GOODREG}:${GOODTYPE}"
93 test_badarg "${GOODREG}::${GOODTYPE}" "${GOODREG}:${BADTYPE}" \
94 "${GOODTYPE}:${GOODREG}"
96 : "Combination check"
98 test_goodarg "\$comm:string" "+0(\$stack):string"
99 test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string"