Skip to content

Commit

Permalink
perf python: Add perf.tracepoint method
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Jul 12, 2016
1 parent 85e37de commit 1075fbb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tools/perf/util/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <structmember.h>
#include <inttypes.h>
#include <poll.h>
#include <linux/err.h>
#include "evlist.h"
#include "evsel.h"
#include "event.h"
Expand Down Expand Up @@ -1076,7 +1077,32 @@ static struct {
{ .name = NULL, },
};

static PyObject *pyrf__tracepoint(struct pyrf_evsel *pevsel,
PyObject *args, PyObject *kwargs)
{
struct event_format *tp_format;
static char *kwlist[] = { "sys", "name", NULL };
char *sys = NULL;
char *name = NULL;

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss", kwlist,
&sys, &name))
return NULL;

tp_format = trace_event__tp_format(sys, name);
if (IS_ERR(tp_format))
return PyInt_FromLong(-1);

return PyInt_FromLong(tp_format->id);
}

static PyMethodDef perf__methods[] = {
{
.ml_name = "tracepoint",
.ml_meth = (PyCFunction) pyrf__tracepoint,
.ml_flags = METH_VARARGS | METH_KEYWORDS,
.ml_doc = PyDoc_STR("Get tracepoint config.")
},
{ .ml_name = NULL, }
};

Expand Down

0 comments on commit 1075fbb

Please sign in to comment.