mirror of
https://github.com/torvalds/linux.git
synced 2026-04-30 04:22:32 -04:00
Running the ftrace selftests on the latest kernel caused the kprobe_eventname test to fail. It was due to the test that searches for a function with at "dot" in the name and adding a probe to that. Unfortunately, for this test, it picked: optimize_nops.isra.2.cold.4 Which happens to be marked as "__init", which means it no longer exists in the kernel! (kallsyms keeps those function names around for tracing purposes) As only functions that still exist are in the available_filter_functions file, as they are removed when the functions are freed at boot or module exit, have the test search for a function with ".isra." in the name as well as being in the available_filter_functions (if the file exists). Link: http://lkml.kernel.org/r/20190322150923.1b58eca5@gandalf.local.home Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
47 lines
1.3 KiB
Bash
47 lines
1.3 KiB
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# description: Kprobe event auto/manual naming
|
|
|
|
[ -f kprobe_events ] || exit_unsupported # this is configurable
|
|
|
|
:;: "Add an event on function without name" ;:
|
|
|
|
FUNC=`grep " [tT] .*vfs_read$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "`
|
|
[ "x" != "x$FUNC" ] || exit_unresolved
|
|
echo "p $FUNC" > kprobe_events
|
|
PROBE_NAME=`echo $FUNC | tr ".:" "_"`
|
|
test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure
|
|
|
|
:;: "Add an event on function with new name" ;:
|
|
|
|
echo "p:event1 $FUNC" > kprobe_events
|
|
test -d events/kprobes/event1 || exit_failure
|
|
|
|
:;: "Add an event on function with new name and group" ;:
|
|
|
|
echo "p:kprobes2/event2 $FUNC" > kprobe_events
|
|
test -d events/kprobes2/event2 || exit_failure
|
|
|
|
:;: "Add an event on dot function without name" ;:
|
|
|
|
find_dot_func() {
|
|
if [ ! -f available_filter_functions ]; then
|
|
grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "
|
|
return;
|
|
fi
|
|
|
|
grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
|
|
if grep -s $f available_filter_functions; then
|
|
echo $f
|
|
break
|
|
fi
|
|
done
|
|
}
|
|
|
|
FUNC=`find_dot_func | tail -n 1`
|
|
[ "x" != "x$FUNC" ] || exit_unresolved
|
|
echo "p $FUNC" > kprobe_events
|
|
EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`
|
|
[ "x" != "x$EVENT" ] || exit_failure
|
|
test -d events/$EVENT || exit_failure
|