aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/python.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/python.c')
-rw-r--r--tools/perf/util/python.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 863b61478edd..ce501ba14b08 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -11,6 +11,7 @@
11#include "cpumap.h" 11#include "cpumap.h"
12#include "print_binary.h" 12#include "print_binary.h"
13#include "thread_map.h" 13#include "thread_map.h"
14#include "mmap.h"
14 15
15#if PY_MAJOR_VERSION < 3 16#if PY_MAJOR_VERSION < 3
16#define _PyUnicode_FromString(arg) \ 17#define _PyUnicode_FromString(arg) \
@@ -341,7 +342,7 @@ static bool is_tracepoint(struct pyrf_event *pevent)
341static PyObject* 342static PyObject*
342tracepoint_field(struct pyrf_event *pe, struct format_field *field) 343tracepoint_field(struct pyrf_event *pe, struct format_field *field)
343{ 344{
344 struct pevent *pevent = field->event->pevent; 345 struct tep_handle *pevent = field->event->pevent;
345 void *data = pe->sample.raw_data; 346 void *data = pe->sample.raw_data;
346 PyObject *ret = NULL; 347 PyObject *ret = NULL;
347 unsigned long long val; 348 unsigned long long val;
@@ -351,7 +352,7 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field)
351 offset = field->offset; 352 offset = field->offset;
352 len = field->size; 353 len = field->size;
353 if (field->flags & FIELD_IS_DYNAMIC) { 354 if (field->flags & FIELD_IS_DYNAMIC) {
354 val = pevent_read_number(pevent, data + offset, len); 355 val = tep_read_number(pevent, data + offset, len);
355 offset = val; 356 offset = val;
356 len = offset >> 16; 357 len = offset >> 16;
357 offset &= 0xffff; 358 offset &= 0xffff;
@@ -364,8 +365,8 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field)
364 field->flags &= ~FIELD_IS_STRING; 365 field->flags &= ~FIELD_IS_STRING;
365 } 366 }
366 } else { 367 } else {
367 val = pevent_read_number(pevent, data + field->offset, 368 val = tep_read_number(pevent, data + field->offset,
368 field->size); 369 field->size);
369 if (field->flags & FIELD_IS_POINTER) 370 if (field->flags & FIELD_IS_POINTER)
370 ret = PyLong_FromUnsignedLong((unsigned long) val); 371 ret = PyLong_FromUnsignedLong((unsigned long) val);
371 else if (field->flags & FIELD_IS_SIGNED) 372 else if (field->flags & FIELD_IS_SIGNED)
@@ -394,7 +395,7 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name)
394 evsel->tp_format = tp_format; 395 evsel->tp_format = tp_format;
395 } 396 }
396 397
397 field = pevent_find_any_field(evsel->tp_format, str); 398 field = tep_find_any_field(evsel->tp_format, str);
398 if (!field) 399 if (!field)
399 return NULL; 400 return NULL;
400 401
@@ -976,6 +977,20 @@ static PyObject *pyrf_evlist__add(struct pyrf_evlist *pevlist,
976 return Py_BuildValue("i", evlist->nr_entries); 977 return Py_BuildValue("i", evlist->nr_entries);
977} 978}
978 979
980static struct perf_mmap *get_md(struct perf_evlist *evlist, int cpu)
981{
982 int i;
983
984 for (i = 0; i < evlist->nr_mmaps; i++) {
985 struct perf_mmap *md = &evlist->mmap[i];
986
987 if (md->cpu == cpu)
988 return md;
989 }
990
991 return NULL;
992}
993
979static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, 994static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
980 PyObject *args, PyObject *kwargs) 995 PyObject *args, PyObject *kwargs)
981{ 996{
@@ -990,7 +1005,10 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
990 &cpu, &sample_id_all)) 1005 &cpu, &sample_id_all))
991 return NULL; 1006 return NULL;
992 1007
993 md = &evlist->mmap[cpu]; 1008 md = get_md(evlist, cpu);
1009 if (!md)
1010 return NULL;
1011
994 if (perf_mmap__read_init(md) < 0) 1012 if (perf_mmap__read_init(md) < 0)
995 goto end; 1013 goto end;
996 1014