forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests: ftrace: Add probe event argument syntax testcase
Add a testcase for probe event argument syntax which ensures the kprobe_events interface correctly parses given event arguments. Link: http://lkml.kernel.org/r/152129033679.31874.12705519603869152799.stgit@devbox Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
- Loading branch information
Showing
1 changed file
with
97 additions
and
0 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# description: Kprobe event argument syntax | ||
|
||
[ -f kprobe_events ] || exit_unsupported # this is configurable | ||
|
||
grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue | ||
|
||
echo 0 > events/enable | ||
echo > kprobe_events | ||
|
||
PROBEFUNC="vfs_read" | ||
GOODREG= | ||
BADREG= | ||
GOODSYM="_sdata" | ||
if ! grep -qw ${GOODSYM} /proc/kallsyms ; then | ||
GOODSYM=$PROBEFUNC | ||
fi | ||
BADSYM="deaqswdefr" | ||
SYMADDR=0x`grep -w ${GOODSYM} /proc/kallsyms | cut -f 1 -d " "` | ||
GOODTYPE="x16" | ||
BADTYPE="y16" | ||
|
||
case `uname -m` in | ||
x86_64|i[3456]86) | ||
GOODREG=%ax | ||
BADREG=%ex | ||
;; | ||
aarch64) | ||
GOODREG=%x0 | ||
BADREG=%ax | ||
;; | ||
arm*) | ||
GOODREG=%r0 | ||
BADREG=%ax | ||
;; | ||
esac | ||
|
||
test_goodarg() # Good-args | ||
{ | ||
while [ "$1" ]; do | ||
echo "p ${PROBEFUNC} $1" > kprobe_events | ||
shift 1 | ||
done; | ||
} | ||
|
||
test_badarg() # Bad-args | ||
{ | ||
while [ "$1" ]; do | ||
! echo "p ${PROBEFUNC} $1" > kprobe_events | ||
shift 1 | ||
done; | ||
} | ||
|
||
echo > kprobe_events | ||
|
||
: "Register access" | ||
test_goodarg ${GOODREG} | ||
test_badarg ${BADREG} | ||
|
||
: "Symbol access" | ||
test_goodarg "@${GOODSYM}" "@${SYMADDR}" "@${GOODSYM}+10" "@${GOODSYM}-10" | ||
test_badarg "@" "@${BADSYM}" "@${GOODSYM}*10" "@${GOODSYM}/10" \ | ||
"@${GOODSYM}%10" "@${GOODSYM}&10" "@${GOODSYM}|10" | ||
|
||
: "Stack access" | ||
test_goodarg "\$stack" "\$stack0" "\$stack1" | ||
test_badarg "\$stackp" "\$stack0+10" "\$stack1-10" | ||
|
||
: "Retval access" | ||
echo "r ${PROBEFUNC} \$retval" > kprobe_events | ||
! echo "p ${PROBEFUNC} \$retval" > kprobe_events | ||
|
||
: "Comm access" | ||
test_goodarg "\$comm" | ||
|
||
: "Indirect memory access" | ||
test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \ | ||
"+0(\$stack1)" "+10(@${GOODSYM}-10)" "+0(+10(+20(\$stack)))" | ||
test_badarg "+(${GOODREG})" "(${GOODREG}+10)" "-(${GOODREG})" "(${GOODREG})" \ | ||
"+10(\$comm)" "+0(${GOODREG})+10" | ||
|
||
: "Name assignment" | ||
test_goodarg "varname=${GOODREG}" | ||
test_badarg "varname=varname2=${GOODREG}" | ||
|
||
: "Type syntax" | ||
test_goodarg "${GOODREG}:${GOODTYPE}" | ||
test_badarg "${GOODREG}::${GOODTYPE}" "${GOODREG}:${BADTYPE}" \ | ||
"${GOODTYPE}:${GOODREG}" | ||
|
||
: "Combination check" | ||
|
||
test_goodarg "\$comm:string" "+0(\$stack):string" | ||
test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string" | ||
|
||
echo > kprobe_events |