diff options
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/Makefile.config | 23 | ||||
| -rw-r--r-- | tools/perf/Makefile.perf | 4 | ||||
| -rw-r--r-- | tools/perf/scripts/python/Perf-Trace-Util/Context.c | 34 | ||||
| -rw-r--r-- | tools/perf/util/python.c | 95 | ||||
| -rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 147 | ||||
| -rw-r--r-- | tools/perf/util/setup.py | 6 |
6 files changed, 221 insertions, 88 deletions
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 577a5d2988fe..89cb2a36b8ff 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config | |||
| @@ -668,25 +668,10 @@ else | |||
| 668 | ifneq ($(feature-libpython), 1) | 668 | ifneq ($(feature-libpython), 1) |
| 669 | $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev) | 669 | $(call disable-python,No 'Python.h' (for Python 2.x support) was found: disables Python support - please install python-devel/python-dev) |
| 670 | else | 670 | else |
| 671 | ifneq ($(feature-libpython-version), 1) | 671 | LDFLAGS += $(PYTHON_EMBED_LDFLAGS) |
| 672 | $(warning Python 3 is not yet supported; please set) | 672 | EXTLIBS += $(PYTHON_EMBED_LIBADD) |
| 673 | $(warning PYTHON and/or PYTHON_CONFIG appropriately.) | 673 | LANG_BINDINGS += $(obj-perf)python/perf.so |
| 674 | $(warning If you also have Python 2 installed, then) | 674 | $(call detected,CONFIG_LIBPYTHON) |
| 675 | $(warning try something like:) | ||
| 676 | $(warning $(and ,)) | ||
| 677 | $(warning $(and ,) make PYTHON=python2) | ||
| 678 | $(warning $(and ,)) | ||
| 679 | $(warning Otherwise, disable Python support entirely:) | ||
| 680 | $(warning $(and ,)) | ||
| 681 | $(warning $(and ,) make NO_LIBPYTHON=1) | ||
| 682 | $(warning $(and ,)) | ||
| 683 | $(error $(and ,)) | ||
| 684 | else | ||
| 685 | LDFLAGS += $(PYTHON_EMBED_LDFLAGS) | ||
| 686 | EXTLIBS += $(PYTHON_EMBED_LIBADD) | ||
| 687 | LANG_BINDINGS += $(obj-perf)python/perf.so | ||
| 688 | $(call detected,CONFIG_LIBPYTHON) | ||
| 689 | endif | ||
| 690 | endif | 675 | endif |
| 691 | endif | 676 | endif |
| 692 | endif | 677 | endif |
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 9b0351d3ce34..126ef6e0475c 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
| @@ -302,7 +302,7 @@ PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/ | |||
| 302 | PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/ | 302 | PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/ |
| 303 | export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP | 303 | export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP |
| 304 | 304 | ||
| 305 | python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so | 305 | python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so |
| 306 | 306 | ||
| 307 | PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) | 307 | PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) |
| 308 | PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI) | 308 | PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI) |
| @@ -479,7 +479,7 @@ $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_D | |||
| 479 | $(PYTHON_WORD) util/setup.py \ | 479 | $(PYTHON_WORD) util/setup.py \ |
| 480 | --quiet build_ext; \ | 480 | --quiet build_ext; \ |
| 481 | mkdir -p $(OUTPUT)python && \ | 481 | mkdir -p $(OUTPUT)python && \ |
| 482 | cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/ | 482 | cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/ |
| 483 | 483 | ||
| 484 | please_set_SHELL_PATH_to_a_more_modern_shell: | 484 | please_set_SHELL_PATH_to_a_more_modern_shell: |
| 485 | $(Q)$$(:) | 485 | $(Q)$$(:) |
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Context.c b/tools/perf/scripts/python/Perf-Trace-Util/Context.c index fcd1dd667906..1a0d27757eec 100644 --- a/tools/perf/scripts/python/Perf-Trace-Util/Context.c +++ b/tools/perf/scripts/python/Perf-Trace-Util/Context.c | |||
| @@ -23,7 +23,17 @@ | |||
| 23 | #include "../../../perf.h" | 23 | #include "../../../perf.h" |
| 24 | #include "../../../util/trace-event.h" | 24 | #include "../../../util/trace-event.h" |
| 25 | 25 | ||
| 26 | #if PY_MAJOR_VERSION < 3 | ||
| 27 | #define _PyCapsule_GetPointer(arg1, arg2) \ | ||
| 28 | PyCObject_AsVoidPtr(arg1) | ||
| 29 | |||
| 26 | PyMODINIT_FUNC initperf_trace_context(void); | 30 | PyMODINIT_FUNC initperf_trace_context(void); |
| 31 | #else | ||
| 32 | #define _PyCapsule_GetPointer(arg1, arg2) \ | ||
| 33 | PyCapsule_GetPointer((arg1), (arg2)) | ||
| 34 | |||
| 35 | PyMODINIT_FUNC PyInit_perf_trace_context(void); | ||
| 36 | #endif | ||
| 27 | 37 | ||
| 28 | static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args) | 38 | static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args) |
| 29 | { | 39 | { |
| @@ -34,7 +44,7 @@ static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args) | |||
| 34 | if (!PyArg_ParseTuple(args, "O", &context)) | 44 | if (!PyArg_ParseTuple(args, "O", &context)) |
| 35 | return NULL; | 45 | return NULL; |
| 36 | 46 | ||
| 37 | scripting_context = PyCObject_AsVoidPtr(context); | 47 | scripting_context = _PyCapsule_GetPointer(context, NULL); |
| 38 | retval = common_pc(scripting_context); | 48 | retval = common_pc(scripting_context); |
| 39 | 49 | ||
| 40 | return Py_BuildValue("i", retval); | 50 | return Py_BuildValue("i", retval); |
| @@ -50,7 +60,7 @@ static PyObject *perf_trace_context_common_flags(PyObject *obj, | |||
| 50 | if (!PyArg_ParseTuple(args, "O", &context)) | 60 | if (!PyArg_ParseTuple(args, "O", &context)) |
| 51 | return NULL; | 61 | return NULL; |
| 52 | 62 | ||
| 53 | scripting_context = PyCObject_AsVoidPtr(context); | 63 | scripting_context = _PyCapsule_GetPointer(context, NULL); |
| 54 | retval = common_flags(scripting_context); | 64 | retval = common_flags(scripting_context); |
| 55 | 65 | ||
| 56 | return Py_BuildValue("i", retval); | 66 | return Py_BuildValue("i", retval); |
| @@ -66,7 +76,7 @@ static PyObject *perf_trace_context_common_lock_depth(PyObject *obj, | |||
| 66 | if (!PyArg_ParseTuple(args, "O", &context)) | 76 | if (!PyArg_ParseTuple(args, "O", &context)) |
| 67 | return NULL; | 77 | return NULL; |
| 68 | 78 | ||
| 69 | scripting_context = PyCObject_AsVoidPtr(context); | 79 | scripting_context = _PyCapsule_GetPointer(context, NULL); |
| 70 | retval = common_lock_depth(scripting_context); | 80 | retval = common_lock_depth(scripting_context); |
| 71 | 81 | ||
| 72 | return Py_BuildValue("i", retval); | 82 | return Py_BuildValue("i", retval); |
| @@ -82,7 +92,25 @@ static PyMethodDef ContextMethods[] = { | |||
| 82 | { NULL, NULL, 0, NULL} | 92 | { NULL, NULL, 0, NULL} |
| 83 | }; | 93 | }; |
| 84 | 94 | ||
| 95 | #if PY_MAJOR_VERSION < 3 | ||
| 85 | PyMODINIT_FUNC initperf_trace_context(void) | 96 | PyMODINIT_FUNC initperf_trace_context(void) |
| 86 | { | 97 | { |
| 87 | (void) Py_InitModule("perf_trace_context", ContextMethods); | 98 | (void) Py_InitModule("perf_trace_context", ContextMethods); |
| 88 | } | 99 | } |
| 100 | #else | ||
| 101 | PyMODINIT_FUNC PyInit_perf_trace_context(void) | ||
| 102 | { | ||
| 103 | static struct PyModuleDef moduledef = { | ||
| 104 | PyModuleDef_HEAD_INIT, | ||
| 105 | "perf_trace_context", /* m_name */ | ||
| 106 | "", /* m_doc */ | ||
| 107 | -1, /* m_size */ | ||
| 108 | ContextMethods, /* m_methods */ | ||
| 109 | NULL, /* m_reload */ | ||
| 110 | NULL, /* m_traverse */ | ||
| 111 | NULL, /* m_clear */ | ||
| 112 | NULL, /* m_free */ | ||
| 113 | }; | ||
| 114 | return PyModule_Create(&moduledef); | ||
| 115 | } | ||
| 116 | #endif | ||
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index b1e999bd21ef..2918cac7a142 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
| @@ -12,6 +12,30 @@ | |||
| 12 | #include "print_binary.h" | 12 | #include "print_binary.h" |
| 13 | #include "thread_map.h" | 13 | #include "thread_map.h" |
| 14 | 14 | ||
| 15 | #if PY_MAJOR_VERSION < 3 | ||
| 16 | #define _PyUnicode_FromString(arg) \ | ||
| 17 | PyString_FromString(arg) | ||
| 18 | #define _PyUnicode_AsString(arg) \ | ||
| 19 | PyString_AsString(arg) | ||
| 20 | #define _PyUnicode_FromFormat(...) \ | ||
| 21 | PyString_FromFormat(__VA_ARGS__) | ||
| 22 | #define _PyLong_FromLong(arg) \ | ||
| 23 | PyInt_FromLong(arg) | ||
| 24 | |||
| 25 | #else | ||
| 26 | |||
| 27 | #define _PyUnicode_FromString(arg) \ | ||
| 28 | PyUnicode_FromString(arg) | ||
| 29 | #define _PyUnicode_FromFormat(...) \ | ||
| 30 | PyUnicode_FromFormat(__VA_ARGS__) | ||
| 31 | #define _PyLong_FromLong(arg) \ | ||
| 32 | PyLong_FromLong(arg) | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #ifndef Py_TYPE | ||
| 36 | #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) | ||
| 37 | #endif | ||
| 38 | |||
| 15 | /* | 39 | /* |
| 16 | * Provide these two so that we don't have to link against callchain.c and | 40 | * Provide these two so that we don't have to link against callchain.c and |
| 17 | * start dragging hist.c, etc. | 41 | * start dragging hist.c, etc. |
| @@ -49,7 +73,11 @@ int eprintf(int level, int var, const char *fmt, ...) | |||
| 49 | # define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size, | 73 | # define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size, |
| 50 | #endif | 74 | #endif |
| 51 | 75 | ||
| 76 | #if PY_MAJOR_VERSION < 3 | ||
| 52 | PyMODINIT_FUNC initperf(void); | 77 | PyMODINIT_FUNC initperf(void); |
| 78 | #else | ||
| 79 | PyMODINIT_FUNC PyInit_perf(void); | ||
| 80 | #endif | ||
| 53 | 81 | ||
| 54 | #define member_def(type, member, ptype, help) \ | 82 | #define member_def(type, member, ptype, help) \ |
| 55 | { #member, ptype, \ | ||
