From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933284AbcGJLIU (ORCPT ); Sun, 10 Jul 2016 07:08:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39677 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757154AbcGJLIQ (ORCPT ); Sun, 10 Jul 2016 07:08:16 -0400 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra Subject: [PATCH 06/10] perf python: Add perf.tracepoint method Date: Sun, 10 Jul 2016 13:07:58 +0200 Message-Id: <1468148882-10362-7-git-send-email-jolsa@kernel.org> In-Reply-To: <1468148882-10362-1-git-send-email-jolsa@kernel.org> References: <1468148882-10362-1-git-send-email-jolsa@kernel.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 10 Jul 2016 11:08:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Link: http://lkml.kernel.org/n/tip-ssizvbkk2lds6bti2z69tikh@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/python.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 @@ #include #include #include +#include #include "evlist.h" #include "evsel.h" #include "event.h" @@ -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, } }; -- 2.4.11