perf tools: Fail properly in case pattern matching fails to find tracepoint
Jiri Olsa
reviewerPATCH 1/1 perf tools: Fail properly in case pattern matching fails to find tracepoint
Currently we dont fail properly when pattern matching fails to find any tracepoint.
Current behaviour:
$ perf record -e 'sched:krava*' sleep 1 WARNING: event parser found nothinginvalid or unsupported event: 'sched:krava*' Run 'perf list' for a list of valid events
usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
This patch change:
$ perf record -e 'sched:krava*' sleep 1
event syntax error: 'sched:krava*'
\___ unknown tracepoint Error: File /sys/kernel/debug/tracing/events/sched/krava* not found.
Hint: Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
Run 'perf list' for a list of valid events
usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
--- tools/perf/util/parse-events.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/util/parse-events.c +8 -1
@@ -449,7 +449,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,char evt_path[MAXPATHLEN ];struct dirent *evt_ent;DIR *evt_dir; -int ret =0 ; +int ret =0 , found =0 ;snprintf (evt_path,MAXPATHLEN ,"%s/%s" , tracing_events_path, sys_name); evt_dir =opendir (evt_path);
@@ -468,10 +468,17 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,if (!strglobmatch (evt_ent->d_name, evt_name))continue ; + found++; + ret =add_tracepoint (list, idx, sys_name, evt_ent->d_name, err, head_config); } +if (!found) { +tracepoint_error (err,ENOENT , sys_name, evt_name); + ret =-1 ; + } +closedir (evt_dir);return ret; }
Signature · 1 line
2.4.3
tip-bot for Jiri Olsa
merge botperf tools: Fail properly in case pattern matching fails to find tracepoint
Commit-ID: 27bf90bf0690f55c3679bcc4c325823cf1cfd19d Gitweb: http://git.kernel.org/tip/27bf90bf0690f55c3679bcc4c325823cf1cfd19d Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Oct 2015 21:31:17 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Oct 2015 17:59:50 -0300
perf tools: Fail properly in case pattern matching fails to find tracepoint
Currently we dont fail properly when pattern matching fails to find any tracepoint.
Current behaviour:
$ perf record -e 'sched:krava*' sleep 1 WARNING: event parser found nothinginvalid or unsupported event: 'sched:krava*' Run 'perf list' for a list of valid events
usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
This patch change:
$ perf record -e 'sched:krava*' sleep 1
event syntax error: 'sched:krava*'
\___ unknown tracepoint Error: File /sys/kernel/debug/tracing/events/sched/krava* not found.
Hint: Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
Run 'perf list' for a list of valid events
usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
--- tools/perf/util/parse-events.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/util/parse-events.c +8 -1
@@ -449,7 +449,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,char evt_path[MAXPATHLEN ];struct dirent *evt_ent;DIR *evt_dir; -int ret =0 ; +int ret =0 , found =0 ;snprintf (evt_path,MAXPATHLEN ,"%s/%s" , tracing_events_path, sys_name); evt_dir =opendir (evt_path);
@@ -468,10 +468,17 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,if (!strglobmatch (evt_ent->d_name, evt_name))continue ; + found++; + ret =add_tracepoint (list, idx, sys_name, evt_ent->d_name, err, head_config); } +if (!found) { +tracepoint_error (err,ENOENT , sys_name, evt_name); + ret =-1 ; + } +closedir (evt_dir);return ret; }