aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2016-07-10 07:07:58 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-07-12 15:17:54 -0400
commit1075fbb22f095c857930190e30fd3ae422d424b6 (patch)
treea339b96b07b678b2f921f51c93e32eb278bd1d90
parent85e37de3a993b9e407398f792b996acad27f4cdc (diff)
perf python: Add perf.tracepoint method
To get id of the tracepoint from subsystem and name strings. The interface is: id = perf.tracepoint(sys, name) In case of error -1 is returned. It will be used to get python tracepoint event's config value for tracepoint event. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1468148882-10362-7-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/python.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index fc277e486d17..45fdd4a68721 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -2,6 +2,7 @@
2#include <structmember.h> 2#include <structmember.h>
3#include <inttypes.h> 3#include <inttypes.h>
4#include <poll.h> 4#include <poll.h>
5#include <linux/err.h>
5#include "evlist.h" 6#include "evlist.h"
6#include "evsel.h" 7#include "evsel.h"
7#include "event.h" 8#include "event.h"
@@ -1076,7 +1077,32 @@ static struct {
1076 { .name = NULL, }, 1077 { .name = NULL, },
1077}; 1078};
1078 1079
1080static PyObject *pyrf__tracepoint(struct pyrf_evsel *pevsel,
1081 PyObject *args, PyObject *kwargs)
1082{
1083 struct event_format *tp_format;
1084 static char *kwlist[] = { "sys", "name", NULL };
1085 char *sys = NULL;
1086 char *name = NULL;
1087
1088 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss", kwlist,
1089 &sys, &name))
1090 return NULL;
1091
1092 tp_format = trace_event__tp_format(sys, name);
1093 if (IS_ERR(tp_format))
1094 return PyInt_FromLong(-1);
1095
1096 return PyInt_FromLong(tp_format->id);
1097}
1098
1079static PyMethodDef perf__methods[] = { 1099static PyMethodDef perf__methods[] = {
1100 {
1101 .ml_name = "tracepoint",
1102 .ml_meth = (PyCFunction) pyrf__tracepoint,
1103 .ml_flags = METH_VARARGS | METH_KEYWORDS,
1104 .ml_doc = PyDoc_STR("Get tracepoint config.")
1105 },
1080 { .ml_name = NULL, } 1106 { .ml_name = NULL, }
1081}; 1107};
1082 1108