aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/evlist.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-06-02 10:04:54 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-06-02 10:04:54 -0400
commitc2a70653af45c9cbb0cab900e8931b062e57b1ae (patch)
treee7b1b10cc71c5cccd3d3b7d20cb8001ec313fbff /tools/perf/util/evlist.c
parent5c6970af2f4be4e04b06fe78214f6809777a8354 (diff)
perf evlist: Don't die if sample_{id_all|type} is invalid
Fixes two more cases where the python binding would not load: . Not finding die(), which it shouldn't anyway, not good to just stop the world because some particular perf.data file is invalid, just propagate the error to the caller. . Not finding perf_sample_size: fix it by moving it from event.c to evsel, where it belongs, as most cases are moving to operate on an evsel object.o One of the fixed problems: [root@emilia ~]# python >>> import perf Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: /home/acme/git/build/perf/python/perf.so: undefined symbol: perf_sample_size >>> [root@emilia ~]# Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-1hkj7b2cvgbfnoizsekjb6c9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r--tools/perf/util/evlist.c55
1 files changed, 34 insertions, 21 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 04c8a60075b3..b021ea9265c3 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -455,33 +455,46 @@ int perf_evlist__set_filters(struct perf_evlist *evlist)
455 return 0; 455 return 0;
456} 456}
457 457
458u64 perf_evlist__sample_type(struct perf_evlist *evlist) 458bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist)
459{ 459{
460 struct perf_evsel *pos; 460 struct perf_evsel *pos, *first;
461 u64 type = 0; 461
462 462 pos = first = list_entry(evlist->entries.next, struct perf_evsel, node);
463 list_for_each_entry(pos, &evlist->entries, node) { 463
464 if (!type) 464 list_for_each_entry_continue(pos, &evlist->entries, node) {
465 type = pos->attr.sample_type; 465 if (first->attr.sample_type != pos->attr.sample_type)
466 else if (type != pos->attr.sample_type) 466 return false;
467 die("non matching sample_type");
468 } 467 }
469 468
470 return type; 469 return true;
471} 470}
472 471
473bool perf_evlist__sample_id_all(const struct perf_evlist *evlist) 472u64 perf_evlist__sample_type(const struct perf_evlist *evlist)
473{
474 struct perf_evsel *first;
475
476 first = list_entry(evlist->entries.next, struct perf_evsel, node);
477 return first->attr.sample_type;
478}
479
480bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist)
474{ 481{
475 bool value = false, first = true; 482 struct perf_evsel *pos, *first;
476 struct perf_evsel *pos; 483
477 484 pos = first = list_entry(evlist->entries.next, struct perf_evsel, node);
478 list_for_each_entry(pos, &evlist->entries, node) { 485
479 if (first) { 486 list_for_each_entry_continue(pos, &evlist->entries, node) {
480 value = pos->attr.sample_id_all; 487 if (first->attr.sample_id_all != pos->attr.sample_id_all)
481 first = false; 488 return false;
482 } else if (value != pos->attr.sample_id_all)
483 die("non matching sample_id_all");
484 } 489 }
485 490
486 return value; 491 return true;
492}
493
494bool perf_evlist__sample_id_all(const struct perf_evlist *evlist)
495{
496 struct perf_evsel *first;
497
498 first = list_entry(evlist->entries.next, struct perf_evsel, node);
499 return first->attr.sample_id_all;
487} 500}