xref: /linux/tools/perf/tests/shell/lib/probe_vfs_getname.sh (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1a5f3171bSAthira Rajeev#!/bin/sh
25ce669a5SArnaldo Carvalho de Melo# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
35ce669a5SArnaldo Carvalho de Melo
435435cd0SKim Phillipsperf probe -l 2>&1 | grep -q probe:vfs_getname
55ce669a5SArnaldo Carvalho de Melohad_vfs_getname=$?
65ce669a5SArnaldo Carvalho de Melo
75ce669a5SArnaldo Carvalho de Melocleanup_probe_vfs_getname() {
85ce669a5SArnaldo Carvalho de Melo	if [ $had_vfs_getname -eq 1 ] ; then
921316ac6SArnaldo Carvalho de Melo		perf probe -q -d probe:vfs_getname*
105ce669a5SArnaldo Carvalho de Melo	fi
115ce669a5SArnaldo Carvalho de Melo}
125ce669a5SArnaldo Carvalho de Melo
135ce669a5SArnaldo Carvalho de Meloadd_probe_vfs_getname() {
14a5f3171bSAthira Rajeev	add_probe_verbose=$1
155ce669a5SArnaldo Carvalho de Melo	if [ $had_vfs_getname -eq 1 ] ; then
16a68080e1SArnaldo Carvalho de Melo		result_filename_re="[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*"
17*83420d5fSArnaldo Carvalho de Melo		line=$(perf probe -L getname_flags 2>&1 | grep -E "$result_filename_re" | sed -r "s/$result_filename_re/\1/")
18a68080e1SArnaldo Carvalho de Melo		if [ -z "$line" ] ; then
19a68080e1SArnaldo Carvalho de Melo			result_aname_re="[[:space:]]+([[:digit:]]+)[[:space:]]+result->aname = NULL;"
20*83420d5fSArnaldo Carvalho de Melo			line=$(perf probe -L getname_flags 2>&1 | grep -E "$result_aname_re" | sed -r "s/$result_aname_re/\1/")
21a68080e1SArnaldo Carvalho de Melo		fi
2203fa4838SArnaldo Carvalho de Melo		perf probe -q       "vfs_getname=getname_flags:${line} pathname=result->name:string" || \
23a5f3171bSAthira Rajeev		perf probe $add_probe_verbose "vfs_getname=getname_flags:${line} pathname=filename:ustring"
245ce669a5SArnaldo Carvalho de Melo	fi
255ce669a5SArnaldo Carvalho de Melo}
265ce669a5SArnaldo Carvalho de Melo
275ce669a5SArnaldo Carvalho de Meloskip_if_no_debuginfo() {
28818448e9STiezhu Yang	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
295ce669a5SArnaldo Carvalho de Melo	return 1
305ce669a5SArnaldo Carvalho de Melo}
31766b0beeSAthira Rajeev
32766b0beeSAthira Rajeev# check if perf is compiled with libtraceevent support
33766b0beeSAthira Rajeevskip_no_probe_record_support() {
34766b0beeSAthira Rajeev	if [ $had_vfs_getname -eq 1 ] ; then
35512fcf7dSAthira Rajeev		perf check feature -q libtraceevent && return 1
36512fcf7dSAthira Rajeev		return 2
37766b0beeSAthira Rajeev	fi
38766b0beeSAthira Rajeev}
39