diff options
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/evlist.c | 9 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 4 | ||||
-rw-r--r-- | tools/perf/util/python.c | 6 | ||||
-rw-r--r-- | tools/perf/util/session.c | 19 | ||||
-rw-r--r-- | tools/perf/util/session.h | 4 |
5 files changed, 18 insertions, 24 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 3edfd34..1a560e0 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -881,3 +881,12 @@ int perf_evlist__start_workload(struct perf_evlist *evlist) return 0; } + +int perf_evlist__parse_sample(struct perf_evlist *evlist, + const union perf_event *event, + struct perf_sample *sample, bool swapped) +{ + struct perf_evsel *e = list_entry(evlist->entries.next, struct perf_evsel, node); + return perf_event__parse_sample(event, e->attr.sample_type, e->sample_size, + e->attr.sample_id_all, sample, swapped); +} diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 40d4d3c..a5a4911 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -122,6 +122,10 @@ u64 perf_evlist__sample_type(const struct perf_evlist *evlist); bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist); u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist); +int perf_evlist__parse_sample(struct perf_evlist *evlist, + const union perf_event *event, + struct perf_sample *sample, bool swapped); + bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index b0d6f85..0688bfb 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -797,17 +797,13 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, event = perf_evlist__mmap_read(evlist, cpu); if (event != NULL) { - struct perf_evsel *first; PyObject *pyevent = pyrf_event__new(event); struct pyrf_event *pevent = (struct pyrf_event *)pyevent; if (pyevent == NULL) return PyErr_NoMemory(); - first = list_entry(evlist->entries.next, struct perf_evsel, node); - err = perf_event__parse_sample(event, first->attr.sample_type, - first->sample_size, - sample_id_all, &pevent->sample, false); + err = perf_evlist__parse_sample(evlist, event, &pevent->sample, false); if (err) return PyErr_Format(PyExc_OSError, "perf: can't parse sample, err=%d", err); diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5b8601d..7d07324 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -16,19 +16,6 @@ #include "cpumap.h" #include "event-parse.h" -int perf_session__parse_sample(struct perf_session *session, - const union perf_event *event, - struct perf_sample *sample) -{ - struct perf_evsel *first; - first = list_entry(session->evlist->entries.next, struct perf_evsel, node); - - return perf_event__parse_sample(event, first->attr.sample_type, - first->sample_size, - first->attr.sample_id_all, sample, - session->header.needs_swap); -} - int perf_session__synthesize_sample(struct perf_session *session, union perf_event *event, const struct perf_sample *sample) @@ -692,7 +679,8 @@ static void flush_sample_queue(struct perf_session *s, if (iter->timestamp > limit) break; - ret = perf_session__parse_sample(s, iter->event, &sample); + ret = perf_evlist__parse_sample(s->evlist, iter->event, &sample, + s->header.needs_swap); if (ret) pr_err("Can't parse sample, err = %d\n", ret); else @@ -1103,7 +1091,8 @@ static int perf_session__process_event(struct perf_session *session, /* * For all kernel events we get the sample data */ - ret = perf_session__parse_sample(session, event, &sample); + ret = perf_evlist__parse_sample(session->evlist, event, &sample, + session->header.needs_swap); if (ret) return ret; diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index e2a1a4b..7389fb1 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -126,10 +126,6 @@ size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp); -int perf_session__parse_sample(struct perf_session *session, - const union perf_event *event, - struct perf_sample *sample); - int perf_session__synthesize_sample(struct perf_session *session, union perf_event *event, const struct perf_sample *sample); |