diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2011-05-21 20:17:22 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2011-05-21 21:38:49 -0400 |
commit | 5538becaec9ca2ff21e7826372941dc46f498487 (patch) | |
tree | 66b51fae732a6993f4af1434a1ffe4a83110c71c /tools | |
parent | 98e1da905cbe64bb023a165c7c01eef5e800609e (diff) |
perf tools: Propagate event parse error handling
Better handle event parsing error by propagating the details
in upper layers or by dumping some failure message. So that
the user knows he has some crazy events in the batch.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-test.c | 9 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 7 | ||||
-rw-r--r-- | tools/perf/util/python.c | 14 | ||||
-rw-r--r-- | tools/perf/util/session.c | 14 |
4 files changed, 33 insertions, 11 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 44d7df280430..1fa9f58c2af2 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -559,8 +559,13 @@ static int test__basic_mmap(void) | |||
559 | goto out_munmap; | 559 | goto out_munmap; |
560 | } | 560 | } |
561 | 561 | ||
562 | perf_event__parse_sample(event, attr.sample_type, sample_size, | 562 | err = perf_event__parse_sample(event, attr.sample_type, sample_size, |
563 | false, &sample); | 563 | false, &sample); |
564 | if (err) { | ||
565 | pr_err("Can't parse sample, err = %d\n", err); | ||
566 | goto out_munmap; | ||
567 | } | ||
568 | |||
564 | evsel = perf_evlist__id2evsel(evlist, sample.id); | 569 | evsel = perf_evlist__id2evsel(evlist, sample.id); |
565 | if (evsel == NULL) { | 570 | if (evsel == NULL) { |
566 | pr_debug("event with id %" PRIu64 | 571 | pr_debug("event with id %" PRIu64 |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 7e3d6e310bf8..74f533cbf6ca 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -805,9 +805,14 @@ static void perf_session__mmap_read_cpu(struct perf_session *self, int cpu) | |||
805 | { | 805 | { |
806 | struct perf_sample sample; | 806 | struct perf_sample sample; |
807 | union perf_event *event; | 807 | union perf_event *event; |
808 | int ret; | ||
808 | 809 | ||
809 | while ((event = perf_evlist__read_on_cpu(top.evlist, cpu)) != NULL) { | 810 | while ((event = perf_evlist__read_on_cpu(top.evlist, cpu)) != NULL) { |
810 | perf_session__parse_sample(self, event, &sample); | 811 | ret = perf_session__parse_sample(self, event, &sample); |
812 | if (ret) { | ||
813 | pr_err("Can't parse sample, err = %d\n", ret); | ||
814 | continue; | ||
815 | } | ||
811 | 816 | ||
812 | if (event->header.type == PERF_RECORD_SAMPLE) | 817 | if (event->header.type == PERF_RECORD_SAMPLE) |
813 | perf_event__process_sample(event, &sample, self); | 818 | perf_event__process_sample(event, &sample, self); |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 4174c0990320..3344d6e6f048 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -675,6 +675,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, | |||
675 | union perf_event *event; | 675 | union perf_event *event; |
676 | int sample_id_all = 1, cpu; | 676 | int sample_id_all = 1, cpu; |
677 | static char *kwlist[] = {"sample_id_all", NULL, NULL}; | 677 | static char *kwlist[] = {"sample_id_all", NULL, NULL}; |
678 | int err; | ||
678 | 679 | ||
679 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist, | 680 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist, |
680 | &cpu, &sample_id_all)) | 681 | &cpu, &sample_id_all)) |
@@ -690,12 +691,17 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, | |||
690 | return PyErr_NoMemory(); | 691 | return PyErr_NoMemory(); |
691 | 692 | ||
692 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | 693 | first = list_entry(evlist->entries.next, struct perf_evsel, node); |
693 | perf_event__parse_sample(event, first->attr.sample_type, | 694 | err = perf_event__parse_sample(event, first->attr.sample_type, |
694 | perf_sample_size(first->attr.sample_type), | 695 | perf_sample_size(first->attr.sample_type), |
695 | sample_id_all, &pevent->sample); | 696 | sample_id_all, &pevent->sample); |
697 | if (err) { | ||
698 | pr_err("Can't parse sample, err = %d\n", err); | ||
699 | goto end; | ||
700 | } | ||
701 | |||
696 | return pyevent; | 702 | return pyevent; |
697 | } | 703 | } |
698 | 704 | end: | |
699 | Py_INCREF(Py_None); | 705 | Py_INCREF(Py_None); |
700 | return Py_None; | 706 | return Py_None; |
701 | } | 707 | } |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 8940fd871eae..948327d9e92b 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -480,6 +480,7 @@ static void flush_sample_queue(struct perf_session *s, | |||
480 | struct perf_sample sample; | 480 | struct perf_sample sample; |
481 | u64 limit = os->next_flush; | 481 | u64 limit = os->next_flush; |
482 | u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL; | 482 | u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL; |
483 | int ret; | ||
483 | 484 | ||
484 | if (!ops->ordered_samples || !limit) | 485 | if (!ops->ordered_samples || !limit) |
485 | return; | 486 | return; |
@@ -488,9 +489,12 @@ static void flush_sample_queue(struct perf_session *s, | |||
488 | if (iter->timestamp > limit) | 489 | if (iter->timestamp > limit) |
489 | break; | 490 | break; |
490 | 491 | ||
491 | perf_session__parse_sample(s, iter->event, &sample); | 492 | ret = perf_session__parse_sample(s, iter->event, &sample); |
492 | perf_session_deliver_event(s, iter->event, &sample, ops, | 493 | if (ret) |
493 | iter->file_offset); | 494 | pr_err("Can't parse sample, err = %d\n", ret); |
495 | else | ||
496 | perf_session_deliver_event(s, iter->event, &sample, ops, | ||
497 | iter->file_offset); | ||
494 | 498 | ||
495 | os->last_flush = iter->timestamp; | 499 | os->last_flush = iter->timestamp; |
496 | list_del(&iter->list); | 500 | list_del(&iter->list); |
@@ -806,7 +810,9 @@ static int perf_session__process_event(struct perf_session *session, | |||
806 | /* | 810 | /* |
807 | * For all kernel events we get the sample data | 811 | * For all kernel events we get the sample data |
808 | */ | 812 | */ |
809 | perf_session__parse_sample(session, event, &sample); | 813 | ret = perf_session__parse_sample(session, event, &sample); |
814 | if (ret) | ||
815 | return ret; | ||
810 | 816 | ||
811 | /* Preprocess sample records - precheck callchains */ | 817 | /* Preprocess sample records - precheck callchains */ |
812 | if (perf_session__preprocess_sample(session, event, &sample)) | 818 | if (perf_session__preprocess_sample(session, event, &sample)) |