[PATCH 07/10] perf python: Add struct evsel into struct pyrf_event

From: Jiri Olsa
Date: Sun Jul 10 2016 - 07:08:26 EST


To be able to find out event configuration info
during sample parsing.

Link: http://lkml.kernel.org/n/tip-b63rh6l44ort2t76etobvvui@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/python.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 45fdd4a68721..dc7adaa3a02c 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -48,6 +48,7 @@ PyMODINIT_FUNC initperf(void);

struct pyrf_event {
PyObject_HEAD
+ struct perf_evsel *evsel;
struct perf_sample sample;
union perf_event event;
};
@@ -865,11 +866,18 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
if (event != NULL) {
PyObject *pyevent = pyrf_event__new(event);
struct pyrf_event *pevent = (struct pyrf_event *)pyevent;
+ struct perf_evsel *evsel;

if (pyevent == NULL)
return PyErr_NoMemory();

- err = perf_evlist__parse_sample(evlist, event, &pevent->sample);
+ evsel = perf_evlist__event2evsel(evlist, event);
+ if (!evsel)
+ return Py_None;
+
+ pevent->evsel = evsel;
+
+ err = perf_evsel__parse_sample(evsel, event, &pevent->sample);

/* Consume the even only after we parsed it out. */
perf_evlist__mmap_consume(evlist, cpu);
--
2.4.11