diff options
author | David Ahern <daahern@cisco.com> | 2011-04-06 21:54:20 -0600 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-04-20 07:27:52 -0300 |
commit | 9cbdb702092a2d82f909312f4ec3eeded77bb82e (patch) | |
tree | db5f06a2b534c2731c5da085a5a995b230c0091c /tools/perf/util/session.c | |
parent | 0817a6a3a4fc7c069111083351ca33a78da2a0c9 (diff) |
perf script: improve validation of sample attributes for output fields
Check for required sample attributes using evsel rather than sample_type
in the session header. If the attribute for a default field is not
present for the event type (e.g., new command operating on file from
older kernel) the field is removed from the output list.
Expected event types must exist. For example, if a user specifies
-f trace:time,trace -f sw:time,cpu,sym
the perf.data file must contain both tracepoints and software events
(ie., it is an error if either does not exist in the file).
Attribute checking is done once at the beginning of perf-script rather
than for each sample.
v1 -> v2:
- addressed comments from acme
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1302148460-570-1-git-send-email-daahern@cisco.com
Signed-off-by: David Ahern <daahern@cisco.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r-- | tools/perf/util/session.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index caa224522fe..fff66741f18 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1156,6 +1156,18 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp) return ret; } +struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, + unsigned int type) +{ + struct perf_evsel *pos; + + list_for_each_entry(pos, &session->evlist->entries, node) { + if (pos->attr.type == type) + return pos; + } + return NULL; +} + void perf_session__print_symbols(union perf_event *event, struct perf_sample *sample, struct perf_session *session) |