xref: /linux/tools/perf/tests/shell/lib/probe_vfs_getname.sh (revision 4b132aacb0768ac1e652cf517097ea6f237214b9)
1#!/bin/sh
2# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
3
4perf probe -l 2>&1 | grep -q probe:vfs_getname
5had_vfs_getname=$?
6
7cleanup_probe_vfs_getname() {
8	if [ $had_vfs_getname -eq 1 ] ; then
9		perf probe -q -d probe:vfs_getname*
10	fi
11}
12
13add_probe_vfs_getname() {
14	add_probe_verbose=$1
15	if [ $had_vfs_getname -eq 1 ] ; then
16		line=$(perf probe -L getname_flags 2>&1 | grep -E 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/')
17		perf probe -q       "vfs_getname=getname_flags:${line} pathname=result->name:string" || \
18		perf probe $add_probe_verbose "vfs_getname=getname_flags:${line} pathname=filename:ustring"
19	fi
20}
21
22skip_if_no_debuginfo() {
23	add_probe_vfs_getname -v 2>&1 | grep -E -q "^(Failed to find the path for the kernel|Debuginfo-analysis is not supported)|(file has no debug information)" && return 2
24	return 1
25}
26
27# check if perf is compiled with libtraceevent support
28skip_no_probe_record_support() {
29	if [ $had_vfs_getname -eq 1 ] ; then
30		perf record --dry-run -e $1 2>&1 | grep "libtraceevent is necessary for tracepoint support" && return 2
31		return 1
32	fi
33}
34