[PATCH 05/10] perf python: Put perf.event objects into dictionary

2016-07-10 Thread Jiri Olsa
Make perf.event object parts of the perf module
dictionary so we can address them by name.

Following objects/names are added:
  mmap_event
  lost_event
  comm_event
  task_event
  throttle_event
  task_event
  read_event
  sample_event
  switch_event

We can now use it in python script like:
  ...
  event = evlist.read_on_cpu(cpu)
  ...
  if not isinstance(event, perf.sample_event):

Link: http://lkml.kernel.org/n/tip-s8rjqtol03f9wwueghadb...@git.kernel.org
Signed-off-by: Jiri Olsa 
---
 tools/perf/util/python.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index c68ef0319114..fc277e486d17 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -1103,6 +1103,33 @@ PyMODINIT_FUNC initperf(void)
Py_INCREF(_evsel__type);
PyModule_AddObject(module, "evsel", (PyObject*)_evsel__type);
 
+   Py_INCREF(_mmap_event__type);
+   PyModule_AddObject(module, "mmap_event", (PyObject 
*)_mmap_event__type);
+
+   Py_INCREF(_lost_event__type);
+   PyModule_AddObject(module, "lost_event", (PyObject 
*)_lost_event__type);
+
+   Py_INCREF(_comm_event__type);
+   PyModule_AddObject(module, "comm_event", (PyObject 
*)_comm_event__type);
+
+   Py_INCREF(_task_event__type);
+   PyModule_AddObject(module, "task_event", (PyObject 
*)_task_event__type);
+
+   Py_INCREF(_throttle_event__type);
+   PyModule_AddObject(module, "throttle_event", (PyObject 
*)_throttle_event__type);
+
+   Py_INCREF(_task_event__type);
+   PyModule_AddObject(module, "task_event", (PyObject 
*)_task_event__type);
+
+   Py_INCREF(_read_event__type);
+   PyModule_AddObject(module, "read_event", (PyObject 
*)_read_event__type);
+
+   Py_INCREF(_sample_event__type);
+   PyModule_AddObject(module, "sample_event", (PyObject 
*)_sample_event__type);
+
+   Py_INCREF(_context_switch_event__type);
+   PyModule_AddObject(module, "switch_event", (PyObject 
*)_context_switch_event__type);
+
Py_INCREF(_thread_map__type);
PyModule_AddObject(module, "thread_map", 
(PyObject*)_thread_map__type);
 
-- 
2.4.11



[PATCH 05/10] perf python: Put perf.event objects into dictionary

2016-07-10 Thread Jiri Olsa
Make perf.event object parts of the perf module
dictionary so we can address them by name.

Following objects/names are added:
  mmap_event
  lost_event
  comm_event
  task_event
  throttle_event
  task_event
  read_event
  sample_event
  switch_event

We can now use it in python script like:
  ...
  event = evlist.read_on_cpu(cpu)
  ...
  if not isinstance(event, perf.sample_event):

Link: http://lkml.kernel.org/n/tip-s8rjqtol03f9wwueghadb...@git.kernel.org
Signed-off-by: Jiri Olsa 
---
 tools/perf/util/python.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index c68ef0319114..fc277e486d17 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -1103,6 +1103,33 @@ PyMODINIT_FUNC initperf(void)
Py_INCREF(_evsel__type);
PyModule_AddObject(module, "evsel", (PyObject*)_evsel__type);
 
+   Py_INCREF(_mmap_event__type);
+   PyModule_AddObject(module, "mmap_event", (PyObject 
*)_mmap_event__type);
+
+   Py_INCREF(_lost_event__type);
+   PyModule_AddObject(module, "lost_event", (PyObject 
*)_lost_event__type);
+
+   Py_INCREF(_comm_event__type);
+   PyModule_AddObject(module, "comm_event", (PyObject 
*)_comm_event__type);
+
+   Py_INCREF(_task_event__type);
+   PyModule_AddObject(module, "task_event", (PyObject 
*)_task_event__type);
+
+   Py_INCREF(_throttle_event__type);
+   PyModule_AddObject(module, "throttle_event", (PyObject 
*)_throttle_event__type);
+
+   Py_INCREF(_task_event__type);
+   PyModule_AddObject(module, "task_event", (PyObject 
*)_task_event__type);
+
+   Py_INCREF(_read_event__type);
+   PyModule_AddObject(module, "read_event", (PyObject 
*)_read_event__type);
+
+   Py_INCREF(_sample_event__type);
+   PyModule_AddObject(module, "sample_event", (PyObject 
*)_sample_event__type);
+
+   Py_INCREF(_context_switch_event__type);
+   PyModule_AddObject(module, "switch_event", (PyObject 
*)_context_switch_event__type);
+
Py_INCREF(_thread_map__type);
PyModule_AddObject(module, "thread_map", 
(PyObject*)_thread_map__type);
 
-- 
2.4.11