Path: blob/master/tools/perf/scripts/python/Perf-Trace-Util/Context.c
10824 views
/*1* Context.c. Python interfaces for perf script.2*3* Copyright (C) 2010 Tom Zanussi <[email protected]>4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*19*/2021#include <Python.h>22#include "../../../perf.h"23#include "../../../util/trace-event.h"2425PyMODINIT_FUNC initperf_trace_context(void);2627static PyObject *perf_trace_context_common_pc(PyObject *self, PyObject *args)28{29static struct scripting_context *scripting_context;30PyObject *context;31int retval;3233if (!PyArg_ParseTuple(args, "O", &context))34return NULL;3536scripting_context = PyCObject_AsVoidPtr(context);37retval = common_pc(scripting_context);3839return Py_BuildValue("i", retval);40}4142static PyObject *perf_trace_context_common_flags(PyObject *self,43PyObject *args)44{45static struct scripting_context *scripting_context;46PyObject *context;47int retval;4849if (!PyArg_ParseTuple(args, "O", &context))50return NULL;5152scripting_context = PyCObject_AsVoidPtr(context);53retval = common_flags(scripting_context);5455return Py_BuildValue("i", retval);56}5758static PyObject *perf_trace_context_common_lock_depth(PyObject *self,59PyObject *args)60{61static struct scripting_context *scripting_context;62PyObject *context;63int retval;6465if (!PyArg_ParseTuple(args, "O", &context))66return NULL;6768scripting_context = PyCObject_AsVoidPtr(context);69retval = common_lock_depth(scripting_context);7071return Py_BuildValue("i", retval);72}7374static PyMethodDef ContextMethods[] = {75{ "common_pc", perf_trace_context_common_pc, METH_VARARGS,76"Get the common preempt count event field value."},77{ "common_flags", perf_trace_context_common_flags, METH_VARARGS,78"Get the common flags event field value."},79{ "common_lock_depth", perf_trace_context_common_lock_depth,80METH_VARARGS, "Get the common lock depth event field value."},81{ NULL, NULL, 0, NULL}82};8384PyMODINIT_FUNC initperf_trace_context(void)85{86(void) Py_InitModule("perf_trace_context", ContextMethods);87}888990