Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1239868

[PATCH] perf tools: Fail properly in case pattern matching fails to find tracepoint

From Jiri Olsa <jolsa@kernel.org>
Newsgroups linux.kernel
Subject [PATCH] perf tools: Fail properly in case pattern matching fails to find tracepoint
Date 2015-10-05 21:40 +0200
Message-ID <qgjM6-8oR-19@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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>]

Reported-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Link: http://lkml.kernel.org/n/tip-s1bliap7gzrf8do15bjs7s13@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/parse-events.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5d0cfce2599b..0d756f01d25f 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -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;
 }
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] perf tools: Fail properly in case pattern matching fails to find tracepoint Jiri Olsa <jolsa@kernel.org> - 2015-10-05 21:40 +0200
  [tip:perf/core] perf tools:   Fail properly in case pattern matching fails to find tracepoint tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-10-06 09:20 +0200

csiph-web